mon-reactive-h5 1.0.6

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.
@@ -0,0 +1,141 @@
1
+ import { MonitorSDKConfig } from './types';
2
+ /**
3
+ * 前端监控SDK核心类
4
+ */
5
+ export declare class MonitorSDK {
6
+ private appId;
7
+ private reportUrl;
8
+ protected sampleRates: Record<string, number>;
9
+ private batchReporter;
10
+ private sessionId;
11
+ protected userId?: string;
12
+ private version;
13
+ private originalFetch?;
14
+ private originalXHRSend?;
15
+ /**
16
+ * 构造函数
17
+ * @param config SDK配置
18
+ */
19
+ constructor(config: MonitorSDKConfig);
20
+ /**
21
+ * 获取应用版本号
22
+ */
23
+ private getAppVersion;
24
+ /**
25
+ * 生成会话ID
26
+ */
27
+ private generateSessionId;
28
+ /**
29
+ * 从token中提取userId
30
+ * 小程序环境:直接从本地缓存中取"token"
31
+ * 网页环境:先尝试从sessionStorage中取"-token",再尝试从cookie里取"Admin-Token"
32
+ * 取出token后截取最后12位作为userid
33
+ */
34
+ private getUserIdFromToken;
35
+ /**
36
+ * 初始化SDK
37
+ */
38
+ protected init(): void;
39
+ /**
40
+ * 清理资源
41
+ */
42
+ cleanup(): void;
43
+ /**
44
+ * 恢复原始方法
45
+ */
46
+ private restoreOriginalMethods;
47
+ private lastPageUrl;
48
+ /**
49
+ * 页面浏览监控
50
+ */
51
+ protected initPageViewMonitor(): void;
52
+ /**
53
+ * 错误监控
54
+ */
55
+ protected initErrorMonitor(): void;
56
+ /**
57
+ * API监控
58
+ */
59
+ private initApiMonitor;
60
+ /**
61
+ * 资源监控
62
+ */
63
+ private initResourceMonitor;
64
+ /**
65
+ * 获取资源类型
66
+ */
67
+ private getResourceType;
68
+ /**
69
+ * 获取性能数据
70
+ */
71
+ private getPerformanceData;
72
+ /**
73
+ * 判断是否首次访问
74
+ */
75
+ private isFirstVisit;
76
+ /**
77
+ * 上报页面浏览
78
+ */
79
+ private reportPageView;
80
+ /**
81
+ * 上报JS错误
82
+ */
83
+ private reportJSError;
84
+ /**
85
+ * 上报API数据
86
+ */
87
+ private reportApi;
88
+ /**
89
+ * 上报资源错误
90
+ */
91
+ private reportResource;
92
+ /**
93
+ * 统一上报处理
94
+ */
95
+ private doReport;
96
+ /**
97
+ * 获取设备信息
98
+ */
99
+ private getDeviceInfo;
100
+ /**
101
+ * 获取网络信息
102
+ */
103
+ private getNetworkInfo;
104
+ /**
105
+ * 获取浏览器信息
106
+ */
107
+ private getBrowser;
108
+ /**
109
+ * 获取浏览器版本
110
+ */
111
+ private getBrowserVersion;
112
+ /**
113
+ * 获取操作系统
114
+ */
115
+ private getOS;
116
+ /**
117
+ * 获取操作系统版本
118
+ */
119
+ private getOSVersion;
120
+ /**
121
+ * 获取设备类型
122
+ */
123
+ private getDeviceType;
124
+ /**
125
+ * 数据脱敏
126
+ */
127
+ private sanitizeData;
128
+ /**
129
+ * 上报自定义事件
130
+ */
131
+ protected reportCustomEvent(eventType: string, eventData: any): void;
132
+ /**
133
+ * 立即上报缓冲区数据
134
+ */
135
+ flush(): Promise<void>;
136
+ /**
137
+ * 销毁SDK实例
138
+ */
139
+ destroy(): void;
140
+ }
141
+ export default MonitorSDK;