interface ContextAgent { set: (k: string, v: any) => ContextAgent; merge: (ctx: Record) => ContextAgent; delete: (k: string) => ContextAgent; clear: () => ContextAgent; get: (k: string) => string; toString: () => Record; } declare type ParametersForFn any> = T extends (args: infer P) => any ? P : never; declare type Filter = (e: E) => boolean; declare type SafeObservable = [(f: T) => () => void, (f: T) => void]; declare type Observer any> = (next: (args: ParametersForFn) => ReturnType>, attach: (disconnect: () => void, onSubscribe?: (f: T) => void) => void) => void; declare type NextLink any> = (args: ParametersForFn, cb: T[]) => NextLink>; interface DestroyAgent { set: (pluginName: string, evType: string, tearDownGroup: (() => void)[]) => void; has: (pluginName: string) => boolean; remove: (k: string) => void; removeByEvType: (k: string) => void; clear: () => void; } declare type WithCommandDestroy = C & { 'destroyAgent.set': DestroyAgent['set']; 'destroyAgent.has': DestroyAgent['has']; 'destroyAgent.remove': DestroyAgent['remove']; 'destroyAgent.removeByEvType': DestroyAgent['removeByEvType']; 'destroyAgent.clear': DestroyAgent['clear']; }; declare type ReportEventFromClient = C extends { report: (e: infer R) => void; } ? R : never; declare type SendEventFromClient = C extends { send: (e: infer R) => void; } ? R : never; interface Client, Sender extends EventSender, InitConfig, UserConfig, Config> { getBuilder: () => Builder; getSender: () => Sender | undefined; getPreStartQueue: () => ReportEvent[]; /** * passing InitConfig, can only be called once * @param {InitConfig} c */ init: (c: InitConfig) => void; /** * update common config, can be called multiple times * @param {Partial} c */ config: ConfigAgent; /** * update internal SDKConfig directly without normalization * @param {Partial} c */ set: (c: Partial) => void; /** * called when user finishes configuration and ready to send */ start: () => void; /** * to report any valid event * @param {ReportEvent} e */ report: (e: ReportEvent) => void; /** * build the reported event into server-specific format * @param {ReportEvent} e */ build: (e: ReportEvent) => void; /** * report event in server-specific format * @param {SendEvent} e */ send: (e: SendEvent) => void; destroy: () => void; on: EventToEventHandlerParams>; off: EventToEventHandlerParams>; /** * mount any value onto the client with name, so as to extend the client APIs * @param {string} name 挂载属性名 * @param {any} value 挂载属性值 */ provide: (k: string, v: any) => void; /** * manage all teardownGroup */ destroyAgent: DestroyAgent; } declare type AnyClient = Client; declare type ConfigAgent = { (c?: Partial): Config | undefined; }; interface EventBuilder { build: (d: ReportEvent) => SendEvent | Falsy; } interface EventSender { send: (e: SendEvent) => void; } interface ClientEvent { init: () => void; start: () => void; config: () => void; beforeConfig: Callback>; beforeDestroy: () => void; provide: Callback; beforeReport: Processor; report: Processor; beforeBuild: Processor; build: Processor; beforeSend: Processor; send: Callback; } interface Processor { (e: E): E | Falsy; } declare type Falsy = false | null | undefined; interface SdkTransport { get: (options: any) => void; post: (options: any) => void; } interface Callback { (arg: T): void; } declare type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; declare type EventToEventHandlerPair, T extends keyof Event> = T extends any ? (ev: T, handler: Event[T]) => void : never; declare type EventToEventHandlerParams> = UnionToIntersection>; declare type FailureCallbackType = (err: Error, batchData: string) => void; declare type SuccessCallbackType = (batchData: string) => void; declare type BatchSender = EventSender & { success?: (callback: SuccessCallbackType | undefined) => void; fail?: (callback: FailureCallbackType | undefined) => void; getSize: () => number; getWait: () => number; setSize: (v: number) => void; setWait: (v: number) => void; getEndpoint: () => string; setEndpoint: (v: string) => void; flush: () => void; getBatchData: () => string; clear: () => void; }; declare type WithContext = C & { context?: ContextAgent; }; declare type WithCommandContext = C & { 'context.set': (k: string, v: any) => ContextAgent; 'context.merge': (ctx: Record) => ContextAgent; 'context.delete': (k: string) => ContextAgent; 'context.clear': () => ContextAgent; 'context.get': (k: string) => string; 'context.toString': () => Record; }; declare type WithCommandArray = C & GetCommandFunction; declare type PropertyToFunction, P extends keyof C> = P extends infer K ? K extends keyof C ? C[K] extends ((...args: any) => any) | undefined ? (m: K, ...args: Parameters>) => ReturnType> | undefined : (m: K) => C[K] : never : never; declare type Event = ClientEvent, SendEventFromClient, any>; declare type EventToOnFunctions, T extends keyof Event> = T extends infer K ? K extends keyof Event ? (m: 'on', ev: K, handler: Event[K]) => void : never : never; declare type EventToOffFunctions, T extends keyof Event> = T extends infer K ? K extends keyof Event ? (m: 'off', ev: K, handler: Event[K]) => void : never : never; declare type EventFunctions = EventToOnFunctions, keyof Event> | EventToOffFunctions, keyof Event>; declare type GetCommandFunction = Function & UnionToIntersection, Exclude> | EventFunctions>; interface Integration { name: string; setup: (client: T) => void; tearDown?: () => void; } declare type WithApplyIntegrations = C & { applyIntegrations?: (integrations: Integration[]) => void; }; declare type WithSubject = C & { setFilter: (filterKey: string, filter: Filter) => void; initSubject: any>(args: [subjectKey: string, collector: Observer]) => SafeObservable; getSubject: (key: string) => SafeObservable | undefined; privateSubject: SubjectMap; }; declare type SubjectMap = { [key: string]: SafeObservable | undefined; }; declare global { interface Window { __SLARDAR_DEVTOOLS_GLOBAL_HOOK__?: WithContext[]; } } /** 公共筛选条件 */ interface FilterCondition$1 { /** or 或者 and 或者rule */ type: string; field?: string; op?: string; groupKey?: string; values?: Array; /** 如果下层还有条件,则放入该处,这一层与field,op,groupkey以及values不能同时存在 */ children?: Array; } interface HeatMapConfig$1 { open_list: Array; url: string; } interface HeatMapItem$1 { heat_map_id: number; /** 监控热力图的url,模糊匹配 */ monitor_url: string; } interface SampleConfig$2 { sample_rate: number; include_users: Array; /** session | event */ sample_granularity: string; rules: Array; } interface ApdexConfig$1 { /** 满意阈值 */ satisfying_threshold: number; /** 沮丧阈值 */ frustrating_threshold: number; /** [js_err weight, request err weight, resource err weight, blanksceen err weight] */ error_weight: Array; /** [request long duration weight, resource long duration weight, longtask long duration weight] */ duration_apdex: Array>; perf_apdex: { [key: string]: Array; }; /** 最近 n 分钟,单位 ms,加一个限制 */ last_n: number; } interface SingleApdex$1 { weight: number; /** undefind 等于极大值 */ threshold?: number; } interface EventSampleRule$1 { name: string; enable: boolean; sample_rate: number; conditional_sample_rules: Array; label?: string; } interface ConditionalSampleRule$1 { sample_rate: number; filter: FilterCondition$1; } declare type SampleConfig$1 = Omit & { rules: Record>; r?: number; }; declare type PluginsConfig = AjaxMonitorPluginConfig & BreadcrumbMonitorPluginConfig & FMPMonitorPluginConfig & FetchMonitorPluginConfig & JsErrorMonitorPluginConfig & PerformanceMonitorPluginConfig & ResourceErrorMonitorPluginConfig & ResourceMonitorPluginConfig & TTIMonitorPluginConfig & PageviewMonitorPluginConfig & BlankScreenMonitorPluginConfig & ActionMonitorPluginConfig & HeatmapMonitorPluginConfig; declare type WebConfig = { pid: string; userId: string; deviceId: string; viewId: string; sessionId: string; sampleConfigVersion?: number; actionId?: string; plugins: PluginsConfig; pluginPathPrefix?: string; apdex?: ApdexConfig$1; sample?: SampleConfig$1; heatmap?: any; }; declare type WebTransport = SdkTransport & { useBeacon?: boolean; }; interface Common$1 { /** 应用标识 */ bid: string; /** 页面标识 */ pid: string; /** 页面访问标识,用于区别同一个 pid 的多次访问 */ view_id: string; /** 用户标识,由接入方设定 */ user_id: string; /** 用户标识 加密id ttwid */ ttwid?: string; /** 用户操作id */ action_id?: string; /** 设备标识,保存在本地存储 */ device_id: string; /** 实例会话标识 */ session_id: string; /** 自定义维度 */ context: { [key: string]: string; }; /** 代码部署版本 */ release: string; /** 代码部署环境 */ env: string; /** 环境 */ url: string; /** 动态变化,需要监听 */ network_type: string; /** 客户端时间戳,发生时间 */ timestamp: number; /** 上报 SDK 版本 */ sdk_version: string; /** 上报 SDK 名称, 以区分第三方 SDK */ sdk_name: string; /** 当前事件命中的有效采样率 */ sample_rate: number; /** 小程序专用, 当前小程序宿主类型 */ sdk_host?: string; /** 客户端时间偏移量, 协助服务端进行时间校准 */ sdk_offset: number; } interface CustomPayload { /** 自定义名称, type 为 event时必填 */ name?: string; /** 自定义数值 */ metrics?: { [key: string]: number; }; /** 事件本身的维度,不要跟外部 context 合并 */ categories?: { [key: string]: string; }; /** 自定义日志内容,可以是日志或者对象的 JSON 表示, type为log 时必填 */ content?: string; /** 自定义日志的级别 debug | info | warn | error */ level?: string; /** 自定义类型 event | log */ type: string; /** 可附加的日志,长度限制 100K */ attached_log?: string; } interface PerformanceTimingPayload { /** level 1 https://www.w3.org/TR/navigation-timing/ */ timing?: PerformanceTiming; /** level 2 https://www.w3.org/TR/navigation-timing-2/ */ navigation_timing?: PerformanceNavigationTiming; /** 是否跳出 */ isBounced: boolean; } interface PerformanceTiming { connectEnd: number; connectStart: number; domComplete: number; domContentLoadedEventEnd: number; domContentLoadedEventStart: number; domInteractive: number; domLoading: number; domainLookupEnd: number; domainLookupStart: number; fetchStart: number; loadEventEnd: number; loadEventStart: number; navigationStart: number; redirectEnd: number; redirectStart: number; requestStart: number; responseEnd: number; responseStart: number; secureConnectionStart: number; unloadEventEnd: number; unloadEventStart: number; } interface PerformanceNavigationTiming { /** struct PerformanceResourceTiming { */ /** struct PerformanceEntry { */ duration: number; entryType: string; name: string; startTime: number; /** } */ connectEnd: number; connectStart: number; decodedBodySize: number; domainLookupEnd: number; domainLookupStart: number; encodedBodySize: number; fetchStart: number; initiatorType: string; nextHopProtocol: string; redirectEnd: number; redirectStart: number; requestStart: number; responseEnd: number; responseStart: number; secureConnectionStart: number; transferSize: number; workerStart: number; /** } */ domComplete: number; domContentLoadedEventEnd: number; domContentLoadedEventStart: number; domInteractive: number; loadEventEnd: number; loadEventStart: number; redirectCount: number; type: string; unloadEventEnd: number; unloadEventStart: number; } interface PerformanceResourceTiming { /** struct PerformanceEntry { */ duration: number; entryType: string; name: string; startTime: number; /** } */ connectEnd: number; connectStart: number; decodedBodySize: number; domainLookupEnd: number; domainLookupStart: number; encodedBodySize: number; fetchStart: number; initiatorType: string; nextHopProtocol: string; redirectEnd: number; redirectStart: number; requestStart: number; responseEnd: number; responseStart: number; secureConnectionStart: number; transferSize: number; workerStart: number; serverTiming?: ReadonlyArray; } interface PerformanceServerTiming { description: string; duration: number; name: string; } interface HttpPayload { /** xhr | fetch | request | jsbridge */ api: string; request: HttpReq; response: HttpRes; duration: number; extra?: { [key: string]: string; }; trace?: HttpTrace; } interface HttpReq { method: string; url: string; headers?: { [key: string]: string; }; body?: string; timestamp: number; } interface HttpRes { status: number; is_custom_error: boolean; headers?: { [key: string]: string; }; body?: string; timing?: PerformanceResourceTiming; timestamp: number; } interface HttpTrace { trace_id: string; trace_host: string; log_id: string; } interface JsErrorPayload { error: JsError; breadcrumbs: Array; extra?: { [key: string]: string; }; react?: ReactInfo; source?: JsErrorSource; } interface JsErrorSource { type: string; data?: { [key: string]: string; }; } interface JsError { /** 错误名称 */ name?: string; /** 错误信息 */ message: string; /** 堆栈 */ stack?: string; /** 错误文件名 */ filename?: string; lineno?: string; colno?: string; } interface Breadcrumb { /** dom | http */ type: string; /** xpath, keyvalue | url */ message: string; /** ui.click, ui.keypress | post,get */ category: string; /** status: 400 for http */ data?: { [key: string]: string; }; timestamp: number; } interface ReactInfo { version: string; componentStack: string; } interface PageviewPayload { pid: string; /** 触发原因 init | path change | hash change | history state change | user-set */ source: string; /** @schema maxLength:64 */ last?: LastPageviewDetail; } interface LastPageviewDetail { /** 上一个pid */ pid: string; /** 上一个view_id */ view_id: string; /** 页面开始时间 */ start: number; /** 页面结束时间 */ end: number; /** 页面停留时间,指的是当前页面在前台的时间 */ time_spent: number; /** 原始值[satisfying, tolerable, frustrating] */ apdex: Array; /** satisfying=0, tolerable=1, frustrating=2 */ rank: number; detail: ApdexPayload; } interface SessionPayload { /** 会话开始时间 */ start: number; /** 会话结束时间 */ end: number; /** 会话停留时间,指的是会话在前台的时间 */ time_spent: number; /** 会话是否跳出 */ is_bounced: boolean; /** 会话入口 pid */ entry: string; /** 会话出口 pid */ exit: string; /** 原始值[satisfying, tolerable, frustrating] */ apdex?: Array; /** satisfying=0, tolerable=1, frustrating=2 */ rank?: number; /** 最近n分钟的沮丧汇总数据 */ last_n?: ApdexPayload; /** 整个会话的沮丧汇总数据 */ apdex_detail?: ApdexPayload; /** 最后一个 pageview 的详情 */ last_page?: LastPageviewDetail; /** pageview count */ p_count: number; /** action count */ a_count: number; } interface ApdexPayload { /** [js_err count, request err count, resource err count, blanksceen err count] */ error_count: Array; /** [request long duration count, resource long duration count, longtask long duration count] */ duration_count: Array; /** { fcp_0: count, fcp_1: count }, 如果不存在fcp2, 说明count是0;action指标名:ation.duration */ perf_apdex: { [key: string]: number; }; } interface ActionPayload { start_time: number; id: string; type: string; duration?: number; target: ActionTarget; frontend_time?: number; /** 自定义数值 string 对应 ev_type, 比如 http 、js_error */ metrics?: { [key: string]: ActionRelatedDetail; }; } interface ActionTarget { /** 目标元素可获取到的信息。比如【确定】 【取消】 */ name: string; path?: string; } interface ActionRelatedDetail { count: number; duration?: number; } interface PerformancePayload { /** 指标名称 */ name: string; /** 当前值 */ value: number; /** 性能指标类型, perf => 传统性能, spa => SPA 性能, mf => 微前端性能 */ type: string; /** 是否支持 */ isSupport?: boolean; /** 是否是Polyfill */ isPolyfill?: boolean; /** 是否跳出 */ isBounced?: boolean; /** 是否自定义 */ isCustom?: boolean; /** 指标的相关信息 */ extra?: { [key: string]: string; }; } interface PerformanceLongtaskPayload { longtasks: Array; /** 性能指标类型, perf => 传统性能, spa => SPA 性能, mf => 微前端性能 */ type: string; } interface PerformanceLongtask { /** struct PerformanceEntry { */ duration: number; entryType: string; name: string; startTime: number; /** } */ attribution?: Array; } interface TaskAttributionTiming { /** struct PerformanceEntry { */ duration: number; entryType: string; name: string; startTime: number; /** } */ containerType: string; containerSrc: string; containerId: string; containerName: string; } interface ResourceErrorPayload { /** 触发标签的类型 script/link/css */ type: string; url: string; xpath?: string; timing?: PerformanceResourceTiming; } declare type ResourcePayload = PerformanceResourceTiming; interface SriPayload { /** 错误的文件大小 */ error_file_size: number; /** 正确的文件大小 */ real_file_size: number; /** 错误的文件内容 */ error_file_context: string; /** 静态资源文件下载地址, 绝对路径 */ static_file_url: string; /** 静态资源 src 属性, 相对路径 */ static_file_src: string; } interface BlankScreenPayload { timestamp: number; /** dom 分 */ score: number; /** 截图 base64 */ screenshot?: string; error?: BlankRelatedError; /** 序列化 Dom 结构 */ serialized_dom?: string; } interface BlankRelatedError { type: string; message: string; } interface MouseEvtData { xpath: string; offset_x: number; offset_y: number; } interface ScrollEvtData { xpath: string; start_y: number; end_y: number; } interface HeatmapPayload { type: string; name: string; /** 热力图id */ heat_map_id: number; mousemove?: MouseEvtData; mouseover?: MouseEvtData; click?: MouseEvtData; scroll?: ScrollEvtData; } declare type CustomReport = { ev_type: 'custom'; payload: CustomPayload; }; declare type HttpReport = { ev_type: 'http'; payload: HttpPayload; }; declare type JsErrorReport = { ev_type: 'js_error'; payload: JsErrorPayload; }; declare type PageviewReport = { ev_type: 'pageview'; payload: PageviewPayload; }; declare type ActionReport = { ev_type: 'action'; payload: ActionPayload; }; declare type PerformanceReport = { ev_type: 'performance'; payload: PerformancePayload | { metrics: PerformancePayload[]; }; }; declare type PerformanceLongTaskReport = { ev_type: 'performance_longtask'; payload: PerformanceLongtaskPayload; }; declare type PerformanceTimingReport = { ev_type: 'performance_timing'; payload: PerformanceTimingPayload; }; declare type ResourceErrorReport = { ev_type: 'resource_error'; payload: ResourceErrorPayload; }; declare type ResourceReport = { ev_type: 'resource'; payload: ResourcePayload | { resources: ResourcePayload[]; }; }; declare type SriReport = { ev_type: 'sri'; payload: SriPayload; }; declare type BlankReport = { ev_type: 'blank_screen'; payload: BlankScreenPayload; }; declare type HeatmapReport = { ev_type: 'heatmap'; payload: HeatmapPayload; }; declare type SessionReport = { ev_type: 'session'; payload: SessionPayload; }; declare type WebReport = CustomReport | HttpReport | JsErrorReport | PageviewReport | PerformanceReport | PerformanceLongTaskReport | PerformanceTimingReport | ResourceErrorReport | ResourceReport | SriReport | BlankReport | ActionReport | HeatmapReport | SessionReport; declare type ReportToReportEvent$1 = T & { extra?: Partial; overrides?: Partial; }; declare type WebReportEvent = ReportToReportEvent$1; declare type WebSendEvent = WebReport & { common: Partial; }; declare type WebClient = Client; declare type WebVolClient = Client; interface UrlParams { url?: string; protocol?: string; domain?: string; path?: string; query?: string; } declare type CapturedContext = UrlParams & { timestamp: number; context?: Record; pid?: string; }; interface AjaxMonitorProps { autoWrap?: boolean; setContextAtReq: () => (ev: HttpReport) => void; ignoreUrls: (string | RegExp)[]; collectBodyOnError: boolean; extraExtractor?: (resBody: string | any, related: HttpPayload, reqBody: any) => { [key: string]: string; } | false; extractUrl?: (originalUrl: string) => string; trace?: TraceConfig | boolean; setTraceHeader?: (url: string, cb: (key: string, value: string) => void) => void; } interface FetchMonitorProps extends AjaxMonitorProps { } interface TraceConfig { sampleRate?: number; origins: (string | RegExp)[]; } declare const AJAX_MONITOR_PLUGIN_NAME = "ajax"; declare type AjaxMonitorConfig = Omit; interface AjaxMonitorPluginConfig { [AJAX_MONITOR_PLUGIN_NAME]?: Partial | boolean; } declare function AjaxMonitorVolPlugin>(client: C): void; declare type PreBreadcrumb = Omit & Partial>; declare type OnMaxBreadcrumbs = (breadcrumbs: Breadcrumb[], maxBreadcrumbs: number) => Breadcrumb[]; declare type GetBreadcrumbs = () => Breadcrumb[]; declare type AddBreadcrumb = (b: PreBreadcrumb) => void; interface BreadcrumbConfig { maxBreadcrumbs?: number; onAddBreadcrumb?: Processor; onMaxBreadcrumbs?: OnMaxBreadcrumbs; dom?: boolean; } declare const BREADCRUMB_MONITOR_PLUGIN_NAME = "breadcrumb"; declare type WithBreadcrumb = C & { getBreadcrumbs?: GetBreadcrumbs; addBreadcrumb?: AddBreadcrumb; }; declare type BreadcrumbMonitorConfig = BreadcrumbConfig; interface BreadcrumbMonitorPluginConfig { [BREADCRUMB_MONITOR_PLUGIN_NAME]?: Partial | boolean; } declare function BreadcrumbMonitorPlugin>(client: C): void; declare const FETCH_MONITOR_PLUGIN_NAME = "fetch"; declare type FetchMonitorConfig = Omit; interface FetchMonitorPluginConfig { [FETCH_MONITOR_PLUGIN_NAME]?: Partial | boolean; } declare function FetchMonitorVolPlugin>(client: C): void; declare type ReportJsError = (ex: any, extra?: Record, react?: ReactInfo) => void; interface JsErrorConfig { ignoreErrors: (string | RegExp)[]; onerror: boolean; onunhandledrejection: boolean; captureGlobalAsync?: boolean; dedupe?: boolean; } declare const JS_ERROR_MONITOR_PLUGIN_NAME = "jsError"; declare type WithCaptureException = C & { captureException?: ReportJsError; }; declare type WithJSErrorPrecollect = C & { pcErr?: (e: ErrorEvent) => void; pcRej?: (e: PromiseRejectionEvent) => void; }; declare type JsErrorMonitorConfig = JsErrorConfig; interface JsErrorMonitorPluginConfig { [JS_ERROR_MONITOR_PLUGIN_NAME]?: Partial | boolean; } declare function JsErrorMonitorPlugin>>>(client: C): void; interface SendPageview { (pid: string): void; } interface PidExtractor { (url: string): string; } interface PageviewProps { sendInit: boolean; routeMode: 'history' | 'hash' | 'manual'; initPid?: string; extractPid?: PidExtractor; onPidUpdate?: (pid: string) => void; apdex?: 0 | 1 | 2; } declare const PAGEVIEW_MONITOR_PLUGIN_NAME = "pageview"; declare type WithSendPageview> = C & { sendPageview?: SendPageview; }; declare type PageviewMonitorConfig = Omit; interface PageviewMonitorPluginConfig { [PAGEVIEW_MONITOR_PLUGIN_NAME]?: Partial | boolean; } declare function PageviewMonitorPlugin>(client: C): void; interface ResourceProps { ignoreUrls: (string | RegExp)[]; slowSessionThreshold: number; ignoreTypes?: string[]; } declare const RESOURCE_MONITOR_PLUGIN_NAME = "resource"; declare type ResourceMonitorConfig = ResourceProps; interface ResourceMonitorPluginConfig { [RESOURCE_MONITOR_PLUGIN_NAME]?: Partial | boolean; } declare function ResourceMonitorPlugin>(client: C): void; interface ResourceErrorData { url: string; tagName: string; xpath?: string; } interface ReportResourceError { (data: ResourceErrorData): void; } declare type ResourceErrorProps = { ignoreUrls: (string | RegExp)[]; includeUrls: (string | RegExp)[]; dedupe: boolean; gatherPath: boolean; }; declare const RESOURCE_ERROR_MONITOR_PLUGIN_NAME = "resourceError"; declare type WithReportResourceError = C & { reportResourceError?: ReportResourceError; }; declare type ResourceErrorMonitorConfig = ResourceErrorProps; interface ResourceErrorMonitorPluginConfig { [RESOURCE_ERROR_MONITOR_PLUGIN_NAME]?: Partial | boolean; } declare function ResourceErrorMonitorPlugin>(client: C): void; declare type PerformanceInit = () => void; declare type PerformanceSend = () => void; declare const enum MetricEnum { fp = "fp", fcp = "fcp", fid = "fid", mpfid = "mpfid", inp = "inp", lcp = "lcp", cls = "cls", longtask = "longtask", timing = "timing" } interface PerformancePrecollect { entries: PerformanceEntry[]; observer?: PerformanceObserver; } declare type PerformanceMonitorUserConfig = { [key in Exclude]: boolean; } & { [MetricEnum.inp]?: boolean | INPPluginConfig; }; interface INPPluginConfig { setExtra?: (eventTarget: Node) => Record; } declare type WithPerformancePrecollect = C & { pp?: PerformancePrecollect; }; declare type WithSendPerformance = C & { sendCustomPerfMetric?: (metric: CustomPerformancePayload) => void; performanceInit?: PerformanceInit; performanceSend?: PerformanceSend; }; declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; interface PerformanceMonitorPluginConfig { [PERFORMANCE_MONITOR_PLUGIN_NAME]?: Partial | boolean; } declare type CustomPerformancePayload = Partial> & Pick; declare function PerformanceMonitorPlugin>>(client: C): void; declare const TTI_MONITOR_PLUGIN_NAME = "tti"; interface TTIMonitorPluginConfig { [TTI_MONITOR_PLUGIN_NAME]?: boolean | Record; } declare function TTIMonitorPlugin>>(client: C): void; interface FMPMonitorConfig { renderType?: 'CSR' | 'SSR'; } declare const FMP_MONITOR_PLUGIN_NAME = "fmp"; interface FMPMonitorPluginConfig { [FMP_MONITOR_PLUGIN_NAME]?: Partial | boolean; } declare function FMPMonitorPlugin>(client: C): void; interface BlankScreenProps { autoDetect?: boolean; threshold: number; screenshot: boolean; rootSelector?: string; ssUrl: string; mask: boolean; partialShot: boolean; /** * 0 ~ 1,default to 0.1 */ quality: number; initDetTime: number; runDetTime: number; } interface DetectBlankScreen { (): void; } declare type BlankScreenMonitorConfig = Omit; declare const BLANK_SCREEN_MONITOR_PLUGIN_NAME = "blankScreen"; declare type WithDetectBlankScreen = C & { detectBlankScreen?: DetectBlankScreen; }; interface BlankScreenMonitorPluginConfig { [BLANK_SCREEN_MONITOR_PLUGIN_NAME]?: Partial | boolean; } declare function BlankScreenMonitorVolPlugin>(client: C, overrideConfig?: Partial): void; interface ActionMonitorConfig { types: string[] | false; pure?: boolean; ignoreUrls?: (string | RegExp)[]; } declare const ACTION_MONITOR_PLUGIN_NAME = "action"; interface ActionMonitorPluginConfig { [ACTION_MONITOR_PLUGIN_NAME]?: boolean | Partial; } declare const HEATMAP_MONITOR_PLUGIN_NAME = "heatmap"; declare type HeatmapMonitorConfig = HeatMapConfig$1; interface HeatmapMonitorPluginConfig { [HEATMAP_MONITOR_PLUGIN_NAME]?: Partial | boolean; } declare type CustomEventData = { name: string; metrics?: { [key: string]: number; }; categories?: { [key: string]: string; }; attached_log?: string; }; declare type CustomLogData = { content: string; level?: string; extra?: { [key: string]: number | string; }; attached_log?: string; }; declare type SendCustomEvent = (data: CustomEventData) => void; declare type SendCustomLog = (data: CustomLogData) => void; declare type WithSendCustom = C & { sendEvent?: SendCustomEvent; sendLog?: SendCustomLog; }; declare type PluginKeys = keyof PluginsConfig; declare type ReloadPluginType = (pluginName: T, pluginConfig?: T extends PluginKeys ? PluginsConfig[T] : any) => void; declare type WithReloadPlugin = C & { reloadPlugin?: ReloadPluginType; }; declare type WithCommandReloadPlugin = C & { (m: M, pluginName: T, pluginConfig?: T extends keyof PluginsConfig ? PluginsConfig[T] : any): void; }; declare type BrowserSender = BatchSender; declare type BrowserBuilder = EventBuilder; declare const browserBuilder: BrowserBuilder; declare const addEnvToSendEvent: (ev: BrowserReportEvent, config: BrowserConfig | undefined) => BrowserReportEvent & { extra: Partial & Pick; }; declare const InjectEnvPlugin: (client: BrowserClient) => void; declare type PrecollectData = string | Error | { tagName: string; url: string; }; declare type Precollect = (type: string, data: PrecollectData, timestamp: number, url: string) => void; declare type PrecollectStore = Record; declare type WithPrecollect = C & { precollect?: Precollect; }; declare const EV_METHOD_MAP: { sri: string; st: string; err: string; reject: string; }; declare const createStore: (evMap: Record) => PrecollectStore; declare const reverseMap: (map: Record) => Record; declare const getStoreOrConsume: (client: BrowserClient, store: PrecollectStore, evMap: Record) => (type: string, data: PrecollectData, timestamp?: number, url?: string) => void; declare const getConsumeStored: (client: BrowserClient, store: PrecollectStore, evMethods: Record) => (name: string) => void; declare const filterIfPluginDisabled: (config: BrowserConfig | undefined, type: string) => boolean; declare const PrecollectPlugin: (client: BrowserClient, evMap?: Record) => void; /** * This plugin is bound with BrowserConfigManager, so it can't be extract into @sdk/web */ declare const TimeCalibrationPlugin: (client: BrowserClient) => void; declare const addConfigToReportEvent: (ev: BrowserReportEvent, config: BrowserConfig) => BrowserReportEvent; declare const InjectConfigPlugin: (client: BrowserClient) => void; declare const InjectQueryPlugin: (client: BrowserClient) => void; declare const getReportUrl: (domain: string, path?: string) => string; declare const getSettingsUrl: (domain: string, path?: string) => string; declare const getDefaultSessionId: () => string; declare type ObservableArray = Array & { observe: (f: (v: T) => void) => void; }; declare const toObservableArray: (arr: T[]) => ObservableArray; declare const getGlobalName: () => string | undefined; declare const getGlobalInstance: () => BrowserClient | undefined; declare const getStorageKey: (aid?: number | undefined) => string; declare type StorageUserInfo = { userId: string; deviceId: string; r: number; }; /** * glue code for storage security. Maybe it could remove in one year later * @param key storage key * @returns */ declare const glueCodeForStorageSecurity: (key: string, expires: number) => void; declare const getStoreInfo: (aid: number | undefined, expires: number) => StorageUserInfo; declare const saveStoreInfo: (config: BrowserConfig) => void; declare const getStorageItemInObject: (name: string) => Record | null; declare const setStorageItem: (key: string, value: any) => void; declare const getCacheServerConfigKey: (aid: number) => string; declare const getCacheServerConfig: (aid: number) => Record | null; declare const setCacheServerConfig: (aid: number, config: Record) => void; declare type BrowserInitConfig = { aid: number; token: string; useLocalConfig?: boolean; domain?: string; sample?: SampleConfig$1; integrations?: Integration[]; transport?: WebTransport; storageExpires?: number | boolean; plugins?: AjaxMonitorPluginConfig & BreadcrumbMonitorPluginConfig & FMPMonitorPluginConfig & FetchMonitorPluginConfig & JsErrorMonitorPluginConfig & PerformanceMonitorPluginConfig & ResourceErrorMonitorPluginConfig & ResourceMonitorPluginConfig & TTIMonitorPluginConfig & PageviewMonitorPluginConfig & BlankScreenMonitorPluginConfig & ActionMonitorPluginConfig & HeatmapMonitorPluginConfig; } & Partial; declare type BrowserUserConfig = { pid: string; userId: string; deviceId: string; release: string; env: string; }; declare type BrowserConfig = WebConfig & { aid: number; domain: string; token: string; useLocalConfig?: boolean; release: string; env: string; storageExpires?: number | boolean; serverTimestamp?: number; offset?: number; integrations?: Integration[]; transport: WebTransport; }; /** 上报域名:tbm.snssdk.com , path:/monitor_web/collect */ interface Common { /** 应用标识 */ aid: number; /** 页面标识 */ pid: string; /** 页面访问标识,用于区别同一个 pid 的多次访问 */ view_id: string; /** 用户标识,由接入方设定 */ user_id: string; /** 用户标识 加密id ttwid */ ttwid?: string; /** 用户操作id */ action_id?: string; /** 设备标识,保存在本地存储 */ device_id: string; /** 实例会话标识 */ session_id: string; /** 自定义维度 */ context: { [key: string]: string; }; /** 代码部署版本 */ release: string; /** 代码部署环境 */ env: string; /** 环境 */ url: string; /** 动态变化,需要监听 */ network_type: string; /** 客户端时间戳,发生时间 */ timestamp: number; /** 上报 SDK 版本 */ sdk_version: string; /** 上报 SDK 名称, 以区分第三方 SDK */ sdk_name: string; /** 当前事件命中的有效采样率 */ sample_rate: number; /** 小程序专用, 当前小程序宿主类型 */ sdk_host?: string; /** 客户端时间偏移量, 协助服务端进行时间校准 */ sdk_offset: number; } declare type CommonSend = Common; declare type ReportToReportEvent = T & { extra?: Partial; overrides?: Partial; }; declare type BrowserReportEvent = ReportToReportEvent; declare type BrowserSendEvent = WebReport & { common: Partial; }; declare const getDefaultConfig: (c: Partial) => { aid: number; pid: string; token: string; viewId: string; userId: string; deviceId: string; sessionId: string; storageExpires: number; domain: string; plugins: { ajax: { ignoreUrls: string[]; }; fetch: { ignoreUrls: string[]; }; breadcrumb: {}; pageview: {}; jsError: {}; resource: {}; resourceError: {}; performance: {}; tti: {}; fmp: {}; blankScreen: boolean; }; release: string; env: string; sample: { r: number; sample_rate: number; include_users: string[]; sample_granularity: string; rules: Record>; }; transport: WebTransport; }; interface CreateBrowserClientConfig { createSender?: (c: BrowserConfig) => BrowserSender; builder?: BrowserBuilder; createDefaultConfig?: (c: Partial) => BrowserConfig; } declare const createMinimalBrowserClient: ({ createSender, builder, createDefaultConfig, }?: CreateBrowserClientConfig) => WithCommandArray>, "">; declare type PrecollectArg = [string, string, PrecollectData, number, string]; declare type BrowserClient = WithApplyIntegrations>>>>>>>>>>> & { q?: any[]; p?: { a: PrecollectArg[] | ObservableArray; }; pp?: PerformancePrecollect; pcErr?: (e: ErrorEvent) => void; pcRej?: (e: PromiseRejectionEvent) => void; }; declare type BrowserCommandClient = WithCommandReloadPlugin>, 'reloadPlugin'>>> & { create?: (config?: CreateBrowserClientConfig) => BrowserCommandClient; }; /** 公共筛选条件 */ interface FilterCondition { /** or 或者 and 或者rule */ type: string; field?: string; op?: string; groupKey?: string; values?: Array; /** 如果下层还有条件,则放入该处,这一层与field,op,groupkey以及values不能同时存在 */ children?: Array; } interface BrowserSetting { sample: SampleConfig; /** 后端下发配置时返回user_id */ user_id?: string; /** 后端下发配置时返回user_id */ plugins?: PluginConfig; /** 超量丢弃标志符 */ status: number; timestamp: number; apdex?: ApdexConfig; } interface PluginConfig { heatmap?: HeatMapConfig; } interface HeatMapConfig { open_list: Array; url: string; } interface HeatMapItem { heat_map_id: number; /** 监控热力图的url,模糊匹配 */ monitor_url: string; } interface SampleConfig { sample_rate: number; include_users: Array; /** session | event */ sample_granularity: string; rules: Array; } interface ApdexConfig { /** 满意阈值 */ satisfying_threshold: number; /** 沮丧阈值 */ frustrating_threshold: number; /** [js_err weight, request err weight, resource err weight, blanksceen err weight] */ error_weight: Array; /** [request long duration weight, resource long duration weight, longtask long duration weight] */ duration_apdex: Array>; perf_apdex: { [key: string]: Array; }; /** 最近 n 分钟,单位 ms,加一个限制 */ last_n: number; } interface SingleApdex { weight: number; /** undefind 等于极大值 */ threshold?: number; } interface EventSampleRule { name: string; enable: boolean; sample_rate: number; conditional_sample_rules: Array; } interface ConditionalSampleRule { sample_rate: number; filter: FilterCondition; } declare type BrowserServerConfig = BrowserSetting; declare const _default: BrowserCommandClient; declare const PluginMap: { pageview: typeof PageviewMonitorPlugin; ajax: typeof AjaxMonitorVolPlugin; fetch: typeof FetchMonitorVolPlugin; tti: typeof TTIMonitorPlugin; fmp: typeof FMPMonitorPlugin; breadcrumb: typeof BreadcrumbMonitorPlugin; jsError: typeof JsErrorMonitorPlugin; performance: typeof PerformanceMonitorPlugin; resourceError: typeof ResourceErrorMonitorPlugin; resource: typeof ResourceMonitorPlugin; blankScreen: typeof BlankScreenMonitorVolPlugin; }; declare const createBrowserClient: (config?: CreateBrowserClientConfig) => BrowserCommandClient; declare const REPORT_DOMAIN = "apmplus.volces.com"; declare const SETTINGS_DOMAIN = "apmplus.volces.com"; declare const SDK_VERSION: string; declare const SDK_NAME = "APM_PLUS_WEB"; declare const SETTINGS_PATH = "/settings/get/webpro"; declare const BATCH_REPORT_PATH = "/monitor_web/collect"; declare const STORAGE_PREFIX = "APMPLUS"; declare const DEFAULT_IGNORE_PATHS: string[]; declare const DEFAULT_SAMPLE_GRANULARITY = "session"; declare const DEFAULT_SAMPLE_CONFIG: SampleConfig$1; declare const DEFAULT_SENDER_SIZE = 20; declare function normalizeInitConfig(config: Partial): Partial; declare function validateInitConfig(config: BrowserInitConfig): boolean; declare function normalizeUserConfig(config: Partial): Partial; declare function parseServerConfig(serverConfig?: Partial): Partial; declare const createBrowserConfigManager: (defaultConfig: BrowserConfig) => { getConfig(): BrowserConfig; setConfig(c: Partial): BrowserConfig; onChange(fn: () => void): void; onReady(fn: () => void): void; }; declare function getServerConfig(transport: WebTransport, domain: string, aid: number, cb: (setting?: any) => void): void; declare function mergeSampleConfig(a?: Partial, b?: Partial): Partial | undefined; export { ActionPayload, BATCH_REPORT_PATH, BlankScreenPayload, BrowserBuilder, BrowserClient, BrowserCommandClient, BrowserConfig, BrowserInitConfig, BrowserReportEvent, BrowserSendEvent, BrowserServerConfig, BrowserUserConfig, Common as CommonContext, CommonSend, CreateBrowserClientConfig, CustomPayload, DEFAULT_IGNORE_PATHS, DEFAULT_SAMPLE_CONFIG, DEFAULT_SAMPLE_GRANULARITY, DEFAULT_SENDER_SIZE, EV_METHOD_MAP, HeatmapPayload, HttpPayload, InjectConfigPlugin, InjectEnvPlugin, InjectQueryPlugin, JsErrorPayload, ObservableArray, PageviewPayload, PerformanceLongtaskPayload, PerformancePayload, PerformanceTimingPayload, PluginMap, Precollect, PrecollectData, PrecollectPlugin, REPORT_DOMAIN, ReportToReportEvent, ResourceErrorPayload, ResourcePayload, SDK_NAME, SDK_VERSION, SETTINGS_DOMAIN, SETTINGS_PATH, STORAGE_PREFIX, SriPayload, TimeCalibrationPlugin, WithPrecollect, addConfigToReportEvent, addEnvToSendEvent, browserBuilder, createBrowserClient, createBrowserConfigManager, createMinimalBrowserClient, createStore, _default as default, filterIfPluginDisabled, getCacheServerConfig, getCacheServerConfigKey, getConsumeStored, getDefaultConfig, getDefaultSessionId, getGlobalInstance, getGlobalName, getReportUrl, getServerConfig, getSettingsUrl, getStorageItemInObject, getStorageKey, getStoreInfo, getStoreOrConsume, glueCodeForStorageSecurity, mergeSampleConfig, normalizeInitConfig, normalizeUserConfig, parseServerConfig, reverseMap, saveStoreInfo, setCacheServerConfig, setStorageItem, toObservableArray, validateInitConfig };