aibox-web-tracing 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # Start
2
+ WebTracing是一个基于 JavaScript 的埋点SDK 官方文档:https://m-cheng-web.github.io/web-tracing/
3
+
4
+ 这个包基于 WebTracing 做了二开, 改成了js版本,添加了一些自定义的东西,例如自定义请求参数等。删除了对react、vue2的支持,仅支持 vue3
5
+
6
+ 它努力为你的前端项目提供【 行为、性能、异常、请求、资源、路由、曝光、录屏 】监控手段
7
+
8
+ ## 自定义请求参数
9
+ 主要通过 transformSendParams 实现
10
+ 主要实现在src/libs/sendData.js这个文件
11
+ ```js
12
+ app.use(WebTracing, {
13
+ dsn: '/report',
14
+ appName: 'aibox-client',
15
+ debug: false,
16
+ pv: false,
17
+ performance: {
18
+ firstResource: true,
19
+ },
20
+ recordScreen: false,
21
+ error: true,
22
+ event: true,
23
+ cacheMaxLength: 10,
24
+ cacheWatingTime: 1000,
25
+ transformSendParams: (sendParams) => {
26
+ const { baseInfo, eventInfo} = sendParams
27
+ const data = {
28
+ data:{
29
+ events: [],
30
+ metrics: [],
31
+ errors: [],
32
+ performance: []
33
+ },
34
+ }
35
+ eventInfo.reduce((acc, cur) => {
36
+ if (cur.eventId === SENDID.PAGE) {
37
+ acc.data.performance.push(cur)
38
+ return acc
39
+ }
40
+ if (cur.eventType === SEDNEVENTTYPES.ERROR) {
41
+ acc.data.errors.push(cur)
42
+ return acc
43
+ }
44
+ if(Object.values(CUSTOMEVENTTYPE).includes(cur?.type)){
45
+ acc.data[cur.type].push(cur)
46
+ return acc
47
+ }
48
+ acc.data.events.push(cur)
49
+ return acc
50
+ }, data)
51
+ return {
52
+ service: baseInfo.appName,
53
+ serviceVersion: baseInfo.sdkVersion,
54
+ sessionId: baseInfo.sessionId,
55
+ sendTime: baseInfo.sendTime,
56
+ userId: baseInfo.userUuid,
57
+ // ...baseInfo,
58
+ ...data
59
+ }
60
+ //return sendParams
61
+ }
62
+ })
63
+ ```
64
+ 其他的内容可以看看官方文档或者翻一下源码实现
65
+
66
+ ## performance 增加了对fcp和lcp的监控
67
+ 详细看src/libs/performance.js这个文件