You need to enable JavaScript to run this app.
文档中心
应用性能监控全链路版

应用性能监控全链路版

复制全文
下载 pdf
SDK 接入
配置插件
复制全文
下载 pdf
配置插件
插件是客户端监控内置的功能,可以通过SDK侧配置决定是否开启和关闭这些功能。插件配置属于一次性配置,初始化后修改不再生效。​
使用说明​
全文的client代表的是SDK实例。​
开启插件​
默认情况下所有插件都是开启状态。以下为开启Js Error插件的示例配置。​
​
client('init', {​
...​
plugins: {​
js_error: true​
}​
...​
})​
​
关闭插件​
将插件配置成false则表示关闭插件。以下为关闭Js Error插件的示例配置。​
​
client('init', {​
...​
plugins: {​
js_error: false​
}​
...​
})​
​
配置插件​
Pageview​
页面加载时上报,用于统计PV、UV、页面停留时长。​
注意​
为了避免引发意外错误,PV 插件自定义的 pid 避免携带特殊符号,推荐使用字母、数字、斜杠(/)、中划线(-)进行命名。​
​
pageview: {​
// 路由模式,为 manual 时不上报​
routeMode: 'history' | 'manual' = 'history'​
// 指定 history 变化时如何从 URL 中提取 pid​
extractPid?: (url: string) => string​
}​
​
Js Error​
发生Js Error、Navigate Error时上报。​
​
jsError: {​
// 忽略error message匹配得上的错误​
ignoreErrors: (string | RegExp)[] = []​
// 监听 App.error​
hookOnError: boolean = true​
// 监听 App.unhandledRejection​
hookOnUnhandledRejection: boolean = true​
// 监听路由错误​
hookRouteError: boolean = true​
// 对比前后发生的相同错误并且去重​
dedupe: boolean = true​
}​
​
收集http、路由切换信息,并在Js Error上报时一并上报。​
​
breadcrumb: {​
// 最多保留面包屑数量​
maxBreadcrumbs?: number = 20​
// 新增面包屑时调用的钩子​
onAddBreadcrumb?: (b: Breadcrumb) => Breadcrumb | false​
// 面包屑存满时调用的钩子​
onMaxBreadcrumbs?: (bs: Breadcrumb[], maxBreadcrumbs: number) => Breadcrumb[]​
}​
​
Http​
调用request、downloadFile、uploadFile时上报。​
其中trace字段用于配置前后端打通,如果请求路径命中配置的origins,则会在请求头里补充traceparent头和baggage头,便于应用性能监控串联整个链路。​
​
http: {​
// whether to intercept instance.request​
hookRequest: boolean = true​
// whether to intercept instance.downloadFile​
hookDownloadFile: boolean = true​
// whether to intercept instance.uploadFile​
hookUploadFile: boolean = true​
// ignore the urls or RegExps passed in​
ignoreUrls: (string | RegExp)[] = ['/settings/minipro','monitor_browser/collect/batch']​
// whether to gather request.body and response.body when response.statusCode >= 400​
collectBodyOnError: boolean = false​
// developer can extract extra with response.body and httpPayload.if the value returned wasn't undefined or null, it would be set to extra and is_custom_error would be set to true​
extraExtractor?: (body: string | any, related: HttpPayload) => { [key: string]: string } | false​
// whether to enable trace​
trace?: TraceConfig | boolean​
}​
​
/*​
export interface TraceConfig {​
// session维度采样率,可设置为小于等于1且大于等于0的数,默认为1。表示有多少比例的session增加全链路trace相关请求头。​
sampleRate?: number​
// 请求命中规则即会携带trace相关请求头​
origins: (string | RegExp)[]​
}​
*/​
​
setData​
调用setData时上报,默认将计算参数大小改为false,由于setData调用较为频繁,所以开启后可能会对页面性能造成一些小波动。​
​
setData: {​
// 是否计算 setData 传入参数的大小​
isCalculateSize: boolean = false​
}​
​
App Launch Perf​
收集启动性能,并在启动完成后上报,没有额外配置项。​
​
// 无需配置,默认开启,如需关闭,请设置为false​
appLaunchPerf: {}​
​
Page Perf​
收集页面性能,在切换页面后且页面加载完后上报,没有额外配置项。​
​
// 无需配置,默认开启,如需关闭,请设置为false​
pagePerf: {}​
​
Performance​
收集单性能指标,例如:FR、FP、FCP、LCP,目前只有微信、抖音小程序的部分机型能被获取到,没有额外配置项。​
​
// 无需配置,默认开启,如需关闭,请设置为false​
performance: {}​
​
​
最近更新时间:2026.10.15 20:24:46
这个页面对您有帮助吗?
有用
有用
无用
无用