@w57124/exs-monitor-sdk 0.1.7 → 0.1.9
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/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +7 -7
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +6 -3
- package/dist/index.d.cts +0 -126
package/dist/index.d.cts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 事件类型枚举
|
|
3
|
-
*/
|
|
4
|
-
type EventType = 'error' | 'unhandledrejection' | 'performance' | 'network' | 'custom' | 'whitescreen';
|
|
5
|
-
/**
|
|
6
|
-
* SDK 上报的基础事件结构
|
|
7
|
-
*/
|
|
8
|
-
interface BaseEvent {
|
|
9
|
-
id: string;
|
|
10
|
-
type: EventType;
|
|
11
|
-
timestamp: number;
|
|
12
|
-
appVersion?: string;
|
|
13
|
-
viewport?: {
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
};
|
|
17
|
-
page?: string;
|
|
18
|
-
context?: Record<string, unknown>;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* 传输层(上报)配置
|
|
22
|
-
*/
|
|
23
|
-
interface TransportOptions {
|
|
24
|
-
endpoint: string;
|
|
25
|
-
headers?: Record<string, string>;
|
|
26
|
-
batch?: boolean;
|
|
27
|
-
batchSize?: number;
|
|
28
|
-
flushIntervalMs?: number;
|
|
29
|
-
mode?: 'http' | 'local';
|
|
30
|
-
localKey?: string;
|
|
31
|
-
localMaxItems?: number;
|
|
32
|
-
useBeacon?: boolean;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* MonitorClient 初始化配置
|
|
36
|
-
*/
|
|
37
|
-
interface MonitorClientOptions {
|
|
38
|
-
dsn: string;
|
|
39
|
-
appVersion?: string;
|
|
40
|
-
release?: string;
|
|
41
|
-
env?: string;
|
|
42
|
-
transport?: Partial<TransportOptions>;
|
|
43
|
-
enableErrors?: boolean;
|
|
44
|
-
enablePerformance?: boolean;
|
|
45
|
-
enableNetwork?: boolean;
|
|
46
|
-
ignoreHttpCode?: number[];
|
|
47
|
-
viewerHotkey?: string;
|
|
48
|
-
enableWhiteScreen?: boolean;
|
|
49
|
-
whiteScreenOptions?: {
|
|
50
|
-
delayMs?: number;
|
|
51
|
-
minVisibleCount?: number;
|
|
52
|
-
minArea?: number;
|
|
53
|
-
sampleTimes?: number;
|
|
54
|
-
sampleIntervalMs?: number;
|
|
55
|
-
includePerf?: boolean;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* 网络拦截白名单:仅当匹配这些域名时才上报网络事件。
|
|
59
|
-
* 支持:
|
|
60
|
-
* - 精确域名:例如 'api.example.com'
|
|
61
|
-
* - 通配后缀:例如 '*.example.com'(匹配任意子域)
|
|
62
|
-
*/
|
|
63
|
-
networkHostsAllowlist?: string[];
|
|
64
|
-
/** 网络拦截黑名单(域名),优先级高于白名单 */
|
|
65
|
-
networkHostsBlocklist?: string[];
|
|
66
|
-
/** URL 允许上报的正则(字符串或 RegExp),存在则需匹配其一 */
|
|
67
|
-
networkUrlAllowPatterns?: (string | RegExp)[];
|
|
68
|
-
/** URL 禁止上报的正则(字符串或 RegExp),命中则直接跳过 */
|
|
69
|
-
networkUrlBlockPatterns?: (string | RegExp)[];
|
|
70
|
-
/**
|
|
71
|
-
* 网络请求/响应 body 最大长度(字符数),超出将截断并标记
|
|
72
|
-
* 默认 1000,设为 0 或负数表示不上报 body
|
|
73
|
-
*/
|
|
74
|
-
networkMaxBodyLength?: number;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 监控客户端:负责构建事件与调用传输层上报
|
|
79
|
-
*/
|
|
80
|
-
declare class MonitorClient {
|
|
81
|
-
private readonly options;
|
|
82
|
-
private readonly transport;
|
|
83
|
-
/**
|
|
84
|
-
* @param options SDK 初始化参数
|
|
85
|
-
*/
|
|
86
|
-
constructor(options: MonitorClientOptions);
|
|
87
|
-
/**
|
|
88
|
-
* 采集一个事件
|
|
89
|
-
* @param type 事件类型
|
|
90
|
-
* @param data 自定义上下文数据
|
|
91
|
-
*/
|
|
92
|
-
capture(type: BaseEvent['type'], data?: Omit<BaseEvent, 'id' | 'type' | 'timestamp' | 'viewport' | 'page'>['context']): void;
|
|
93
|
-
/** 打开本地事件列表查看器 */
|
|
94
|
-
openEventList(): void;
|
|
95
|
-
/** 获取本地缓存事件(仅本地模式有效) */
|
|
96
|
-
getStoredEvents(): BaseEvent[];
|
|
97
|
-
/** 清空本地缓存事件(仅本地模式有效) */
|
|
98
|
-
clearStoredEvents(): void;
|
|
99
|
-
/**
|
|
100
|
-
* 绑定默认的查看器快捷键处理(对外导出)
|
|
101
|
-
* @param hotkey 自定义快捷键(如 'Alt+K'),不传则为默认
|
|
102
|
-
*/
|
|
103
|
-
bindViewerHotkeyDefault(hotkey?: string): void;
|
|
104
|
-
/** 解绑默认的查看器快捷键处理 */
|
|
105
|
-
unbindViewerHotkeyDefault(): void;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* 打开事件查看器覆盖层
|
|
110
|
-
* @param events 要展示的事件数组
|
|
111
|
-
* @param onClear 点击清空后的回调
|
|
112
|
-
*/
|
|
113
|
-
declare function openEventViewer(events: BaseEvent[], onClear?: () => void): void;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* 初始化 SDK 并按配置启用集成
|
|
117
|
-
*/
|
|
118
|
-
declare function initMonitor(options: MonitorClientOptions): MonitorClient;
|
|
119
|
-
declare global {
|
|
120
|
-
interface Window {
|
|
121
|
-
__EXSMONITOR__?: MonitorClientOptions;
|
|
122
|
-
__EXSMONITOR_INSTANCE__?: MonitorClient;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export { type BaseEvent, MonitorClient, type MonitorClientOptions, type TransportOptions, initMonitor, openEventViewer };
|