@fle-sdk/event-tracking-web 1.2.0-beta.1 → 1.2.0

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.
@@ -1,243 +1,466 @@
1
- export interface Target extends Window {
2
- /**
3
- * @description 自定义扩展取消监听函数
4
- * @default
5
- */
6
- detachEvent?: (type: string, fun: (event: Event) => void, bol: boolean) => void;
7
- /**
8
- * @description 自定义扩展添加监听函数
9
- * @default
10
- */
11
- attachEvent?: (type: string, fun: (event: Event) => void, bol: boolean) => void;
12
- }
13
- export declare type ContentType = "application/x-www-form-urlencoded" | "application/json";
14
- export interface EventParams extends Event {
15
- /**
16
- * @description 重写添加 arguments
17
- * @default
18
- */
19
- arguments?: any[];
20
- }
21
- export interface JsonProps {
22
- [key: string]: any;
23
- }
24
- /**
25
- * @description 事件类型
26
- */
27
- export declare type EventTypes = "PageView" | "PageRetained" | "CustomTrack" | "WebClick";
28
- export interface PresetParams {
29
- /**
30
- * @description 应用唯一标识(由接口生成)
31
- */
32
- appKey?: string;
33
- /**
34
- * @description 数据接收地址
35
- */
36
- serverUrl?: string;
37
- /**
38
- * @description 手动指定客户端平台类型(h5、pc、ipad、other)
39
- */
40
- platform?: PlatformType | string;
41
- /**
42
- * @description 是否在网页控制台打印发送的数据
43
- * @default false
44
- */
45
- showLog?: boolean;
46
- /**
47
- * @description 是否开启全埋点 指的是:页面浏览、元素点击事件自动上报
48
- * @default true
49
- */
50
- autoTrack?: boolean;
51
- /**
52
- * @description (是否使用客户端系统时间)注意:客户端系统时间可能会不准确,导致该字段不准确
53
- * @default true
54
- */
55
- useClientTime?: boolean;
56
- /**
57
- * @description 接口发送超时时长,超过该时长未发送成功将强制取消,单位:毫秒
58
- * @default 3000
59
- */
60
- sendTimeout?: number;
61
- /**
62
- * @description 是否采集单页面应用的路由变化
63
- * @default false
64
- */
65
- isTrackSinglePage?: boolean;
66
- /**
67
- * @description 数据类型
68
- * @default "application/json"
69
- */
70
- contentType?: ContentType;
71
- /**
72
- * @description 全局自定义业务参数
73
- * @default {}
74
- */
75
- business?: {
76
- [key: string]: any;
77
- };
78
- /**
79
- * @description 请求头
80
- * @default {}
81
- */
82
- header?: {
83
- [key: string]: any;
84
- };
85
- }
86
- export interface InitParams extends PresetParams {
87
- /**
88
- * @description 应用唯一标识(由接口生成)
89
- */
90
- appKey: string;
91
- /**
92
- * @description 数据接收地址
93
- */
94
- serverUrl: string;
95
- }
96
- export declare type PlatformType = "h5" | "pc" | "ipad" | "other";
97
- export interface SystemsInfoTypes {
98
- language?: string;
99
- /**
100
- * 网络类型
101
- */
102
- network?: string;
103
- ua?: string;
104
- /**
105
- * @description 客户端(Mac/Android/iPhone/iPad/iPod/WeChat)
106
- */
107
- client?: string;
108
- /**
109
- * @description 客户端平台类型(h5、pc、ipad)
110
- */
111
- platform?: PlatformType | string;
112
- }
113
- export interface TrackParams {
114
- /**
115
- * @description 控件/自定义事件的唯一标识
116
- */
117
- partkey: string | number;
118
- /**
119
- * @description 自定义代码埋点描述
120
- * @default "自定义代码埋点上报"
121
- */
122
- desc?: string;
123
- /**
124
- * @description 自定义业务参数
125
- * @default {}
126
- */
127
- business?: {
128
- [key: string]: any;
129
- };
130
- /**
131
- * @description 请求头
132
- * @default {}
133
- */
134
- header?: {
135
- [key: string]: any;
136
- };
137
- }
138
- export interface TargetEleProps {
139
- /**
140
- * @description dom节点名称
141
- */
142
- nodeName?: string;
143
- /**
144
- * @description id类名
145
- */
146
- id?: string;
147
- /**
148
- * @description class类名
149
- */
150
- className?: string;
151
- /**
152
- * @description 元素触发位置:[x, y]
153
- */
154
- position?: [number, number];
155
- }
156
- /**
157
- * @description 基础系统信息
158
- */
159
- export interface PrivateParamProps {
160
- /**
161
- * @description 当前URL
162
- */
163
- currentUrl?: string;
164
- /**
165
- * @description 目标URL
166
- */
167
- targetUrl?: string;
168
- /**
169
- * @description 手动埋点参数
170
- */
171
- business?: JsonProps;
172
- /**
173
- * @description 触发元素属性
174
- */
175
- targetEle?: TargetEleProps;
176
- /**
177
- * @description 页面可视区宽度
178
- */
179
- pageWidth?: number;
180
- /**
181
- * @description 页面可视区高度
182
- */
183
- pageHeight?: number;
184
- /**
185
- * @description 显示屏宽度
186
- */
187
- screenWidth?: number;
188
- /**
189
- * @description 显示屏高度
190
- */
191
- screenHeight?: number;
192
- /**
193
- * @description 手动触发的指针类型
194
- */
195
- pointerType?: "mouse" | "touch" | "pen";
196
- /**
197
- * @description 触发元素链路
198
- */
199
- elementSelector?: string;
200
- /**
201
- * @description 用户信息
202
- */
203
- userInfo?: JsonProps;
204
- /**
205
- * @description 路由参数
206
- */
207
- urlParams?: JsonProps;
208
- /**
209
- * @description 系统信息
210
- */
211
- systemsInfo?: SystemsInfoTypes;
212
- /**
213
- * @description SDk版本
214
- */
215
- sdkVersion?: string;
216
- /**
217
- * @description 页面停留时长(毫秒)
218
- */
219
- retainedDuration?: number;
220
- }
221
- export interface TrackingPostParams {
222
- /**
223
- * @description 事件类型
224
- */
225
- event: EventTypes;
226
- /**
227
- * @description 埋点事件描述
228
- */
229
- desc: string;
230
- /**
231
- * @description 当前埋点事件Key
232
- */
233
- itemKey?: string;
234
- /**
235
- * @description 发送请求事件
236
- */
237
- requestTime?: number;
238
- /**
239
- * @description 私有参数
240
- */
241
- privateParamMap?: PrivateParamProps;
242
- }
243
- export declare type HistoryType = "load" | "beforeunload" | "pushState" | "replaceState" | "popstate" | "hashchange";
1
+ export interface Target extends Window {
2
+ /**
3
+ * @description 自定义扩展取消监听函数
4
+ * @default
5
+ */
6
+ detachEvent?: (type: string, fun: (event: Event) => void, bol: boolean) => void;
7
+ /**
8
+ * @description 自定义扩展添加监听函数
9
+ * @default
10
+ */
11
+ attachEvent?: (type: string, fun: (event: Event) => void, bol: boolean) => void;
12
+ }
13
+ export declare type ContentType = "application/x-www-form-urlencoded" | "application/json";
14
+ export interface EventParams extends Event {
15
+ /**
16
+ * @description 重写添加 arguments
17
+ * @default
18
+ */
19
+ arguments?: IArguments | unknown[];
20
+ }
21
+ /**
22
+ * @description JSON对象类型,支持嵌套对象和基本类型
23
+ * 使用 Record 类型以支持更灵活的值类型
24
+ * 先定义 JsonProps,避免在 JsonValue 中直接循环引用
25
+ */
26
+ export interface JsonProps extends Record<string, JsonValue | unknown> {
27
+ }
28
+ /**
29
+ * @description JSON值类型,支持所有可序列化的值
30
+ * 包含基本类型、JsonProps 对象和 JsonValue 数组
31
+ */
32
+ export declare type JsonValue = string | number | boolean | null | undefined | JsonProps | JsonValue[];
33
+ /**
34
+ * @description 事件类型
35
+ */
36
+ export declare type EventTypes = "PageView" | "PageRetained" | "CustomTrack" | "WebClick";
37
+ export interface PresetParams {
38
+ /**
39
+ * @description 应用唯一标识(由接口生成)
40
+ */
41
+ appKey?: string;
42
+ /**
43
+ * @description 数据接收地址
44
+ */
45
+ serverUrl?: string;
46
+ /**
47
+ * @description 手动指定客户端平台类型(h5、pc、ipad、other)
48
+ */
49
+ platform?: PlatformType | string;
50
+ /**
51
+ * @description 是否在网页控制台打印发送的数据
52
+ * @default false
53
+ */
54
+ showLog?: boolean;
55
+ /**
56
+ * @description 是否开启全埋点 指的是:页面浏览、元素点击事件自动上报
57
+ * @default false
58
+ */
59
+ autoTrack?: boolean;
60
+ /**
61
+ * @description (是否使用客户端系统时间)注意:客户端系统时间可能会不准确,导致该字段不准确
62
+ * @default true
63
+ */
64
+ useClientTime?: boolean;
65
+ /**
66
+ * @description 接口发送超时时长,超过该时长未发送成功将强制取消,单位:毫秒
67
+ * @default 3000
68
+ */
69
+ sendTimeout?: number;
70
+ /**
71
+ * @description 是否采集单页面应用的路由变化
72
+ * @default false
73
+ */
74
+ isTrackSinglePage?: boolean;
75
+ /**
76
+ * @description 数据类型
77
+ * @default "application/json"
78
+ */
79
+ contentType?: ContentType;
80
+ /**
81
+ * @description 全局自定义业务参数
82
+ * @default {}
83
+ */
84
+ business?: JsonProps;
85
+ /**
86
+ * @description 请求头
87
+ * @default {}
88
+ */
89
+ header?: JsonProps;
90
+ /**
91
+ * @description 数据采样率,0-1之间,1表示100%采样
92
+ * @default 1
93
+ */
94
+ sampleRate?: number;
95
+ /**
96
+ * @description 是否启用批量发送
97
+ * @default false
98
+ */
99
+ batchSend?: boolean;
100
+ /**
101
+ * @description 批量发送间隔时间(ms)
102
+ * @default 5000
103
+ */
104
+ batchInterval?: number;
105
+ /**
106
+ * @description 批量发送最大数量
107
+ * @default 10
108
+ */
109
+ batchMaxSize?: number;
110
+ }
111
+ export interface InitParams extends PresetParams {
112
+ /**
113
+ * @description 应用唯一标识(由接口生成)
114
+ */
115
+ appKey: string;
116
+ /**
117
+ * @description 数据接收地址
118
+ */
119
+ serverUrl: string;
120
+ }
121
+ export declare type PlatformType = "h5" | "pc" | "ipad" | "other";
122
+ export interface SystemsInfoTypes {
123
+ language?: string;
124
+ /**
125
+ * 网络类型
126
+ */
127
+ network?: string;
128
+ ua?: string;
129
+ /**
130
+ * @description 客户端(Mac/Android/iPhone/iPad/iPod/WeChat)
131
+ */
132
+ client?: string;
133
+ /**
134
+ * @description 客户端平台类型(h5、pc、ipad)
135
+ */
136
+ platform?: PlatformType | string;
137
+ }
138
+ export interface TrackParams {
139
+ /**
140
+ * @description 控件/自定义事件的唯一标识
141
+ */
142
+ partkey: string | number;
143
+ /**
144
+ * @description 自定义代码埋点描述
145
+ * @default "自定义代码埋点上报"
146
+ */
147
+ desc?: string;
148
+ /**
149
+ * @description 自定义业务参数
150
+ * @default {}
151
+ */
152
+ business?: JsonProps;
153
+ /**
154
+ * @description 请求头
155
+ * @default {}
156
+ */
157
+ header?: JsonProps;
158
+ }
159
+ export interface TargetEleProps {
160
+ /**
161
+ * @description dom节点名称
162
+ */
163
+ nodeName?: string;
164
+ /**
165
+ * @description id类名
166
+ */
167
+ id?: string;
168
+ /**
169
+ * @description class类名
170
+ */
171
+ className?: string;
172
+ /**
173
+ * @description 元素触发位置:[x, y]
174
+ */
175
+ position?: [number, number];
176
+ }
177
+ /**
178
+ * @description 基础系统信息
179
+ */
180
+ export interface PrivateParamProps {
181
+ /**
182
+ * @description 当前URL
183
+ */
184
+ currentUrl?: string;
185
+ /**
186
+ * @description 目标URL
187
+ */
188
+ targetUrl?: string;
189
+ /**
190
+ * @description 手动埋点参数
191
+ */
192
+ business?: JsonProps;
193
+ /**
194
+ * @description 触发元素属性
195
+ */
196
+ targetEle?: TargetEleProps;
197
+ /**
198
+ * @description 页面可视区宽度
199
+ */
200
+ pageWidth?: number;
201
+ /**
202
+ * @description 页面可视区高度
203
+ */
204
+ pageHeight?: number;
205
+ /**
206
+ * @description 显示屏宽度
207
+ */
208
+ screenWidth?: number;
209
+ /**
210
+ * @description 显示屏高度
211
+ */
212
+ screenHeight?: number;
213
+ /**
214
+ * @description 手动触发的指针类型
215
+ */
216
+ pointerType?: PointerType;
217
+ /**
218
+ * @description 触发元素链路
219
+ */
220
+ elementSelector?: string;
221
+ /**
222
+ * @description 用户信息
223
+ */
224
+ userInfo?: JsonProps;
225
+ /**
226
+ * @description 路由参数
227
+ */
228
+ urlParams?: JsonProps;
229
+ /**
230
+ * @description 系统信息
231
+ */
232
+ systemsInfo?: SystemsInfoTypes;
233
+ /**
234
+ * @description SDk版本
235
+ */
236
+ sdkVersion?: string;
237
+ /**
238
+ * @description 页面停留时长(毫秒)
239
+ */
240
+ retainedDuration?: number;
241
+ /**
242
+ * @description 设备唯一标识
243
+ */
244
+ deviceId?: string;
245
+ }
246
+ export interface TrackingPostParams {
247
+ /**
248
+ * @description 事件类型
249
+ */
250
+ event: EventTypes;
251
+ /**
252
+ * @description 埋点事件描述
253
+ */
254
+ desc: string;
255
+ /**
256
+ * @description 当前埋点事件Key
257
+ */
258
+ itemKey?: string;
259
+ /**
260
+ * @description 发送请求时间戳(毫秒)
261
+ */
262
+ requestTime?: number;
263
+ /**
264
+ * @description 私有参数
265
+ */
266
+ privateParamMap?: PrivateParamProps;
267
+ }
268
+ /**
269
+ * @description 获取参数选项接口
270
+ */
271
+ export interface GetParamsOptions {
272
+ event: EventTypes;
273
+ desc: string;
274
+ privateParamMap?: PrivateParamProps;
275
+ itemKey?: string;
276
+ }
277
+ /**
278
+ * @description Ajax请求参数接口
279
+ */
280
+ export interface AjaxParams {
281
+ type?: HttpMethod;
282
+ url: string;
283
+ data?: string;
284
+ contentType?: ContentType;
285
+ header?: JsonProps;
286
+ success?: (data: JsonProps) => void;
287
+ error?: (err?: Error | JsonProps, status?: number) => void;
288
+ timeout?: number;
289
+ credentials?: boolean;
290
+ cors?: boolean;
291
+ }
292
+ /**
293
+ * @description SendBeacon参数接口
294
+ */
295
+ export interface SendBeaconParams {
296
+ url: string;
297
+ data: TrackingPostParams | JsonProps;
298
+ contentType: ContentType;
299
+ }
300
+ export declare type HistoryType = "load" | "beforeunload" | "pushState" | "replaceState" | "popstate" | "hashchange";
301
+ /**
302
+ * @description HTTP请求方法类型
303
+ */
304
+ export declare type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
305
+ /**
306
+ * @description 指针设备类型
307
+ */
308
+ export declare type PointerType = "mouse" | "touch" | "pen";
309
+ /**
310
+ * @description 网络连接类型
311
+ */
312
+ export declare type NetworkConnectionType = "slow-2g" | "2g" | "3g" | "4g" | "5g";
313
+ /**
314
+ * @description 网络连接信息接口
315
+ */
316
+ export interface NetworkConnection {
317
+ effectiveType?: NetworkConnectionType;
318
+ downlink?: number;
319
+ rtt?: number;
320
+ saveData?: boolean;
321
+ }
322
+ /**
323
+ * @description 浏览器信息接口
324
+ */
325
+ export interface BrowserInfo {
326
+ name: string;
327
+ version: number;
328
+ }
329
+ /**
330
+ * @description 响应结果接口
331
+ */
332
+ export interface TrackingResponse {
333
+ success: boolean;
334
+ message?: string;
335
+ data?: JsonProps;
336
+ code?: number;
337
+ }
338
+ /**
339
+ * @description 批量发送数据格式
340
+ */
341
+ export interface BatchTrackingData {
342
+ events: TrackingPostParams[];
343
+ timestamp?: number;
344
+ deviceId?: string;
345
+ }
346
+ /**
347
+ * @description 工具类型:将对象的所有属性变为必需
348
+ */
349
+ export declare type RequiredFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
350
+ /**
351
+ * @description 工具类型:将对象的所有属性变为可选
352
+ */
353
+ export declare type PartialFields<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
354
+ /**
355
+ * @description 工具类型:深度只读
356
+ */
357
+ export declare type DeepReadonly<T> = {
358
+ readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];
359
+ };
360
+ /**
361
+ * @description 工具类型:深度部分
362
+ */
363
+ export declare type DeepPartial<T> = {
364
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
365
+ };
366
+ /**
367
+ * @description 工具类型:提取函数参数类型
368
+ */
369
+ export declare type Parameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never;
370
+ /**
371
+ * @description 工具类型:提取函数返回类型
372
+ */
373
+ export declare type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;
374
+ /**
375
+ * @description 设备指纹信息
376
+ */
377
+ export interface DeviceFingerprint {
378
+ /**
379
+ * @description 用户代理字符串
380
+ */
381
+ userAgent?: string;
382
+ /**
383
+ * @description 屏幕宽度
384
+ */
385
+ screenWidth?: number;
386
+ /**
387
+ * @description 屏幕高度
388
+ */
389
+ screenHeight?: number;
390
+ /**
391
+ * @description 颜色深度
392
+ */
393
+ colorDepth?: number;
394
+ /**
395
+ * @description 像素深度
396
+ */
397
+ pixelDepth?: number;
398
+ /**
399
+ * @description 时区
400
+ */
401
+ timezone?: string;
402
+ /**
403
+ * @description 时区偏移
404
+ */
405
+ timezoneOffset?: number;
406
+ /**
407
+ * @description 浏览器语言
408
+ */
409
+ language?: string;
410
+ /**
411
+ * @description 支持的语言列表
412
+ */
413
+ languages?: string[];
414
+ /**
415
+ * @description 平台信息
416
+ */
417
+ platform?: string;
418
+ /**
419
+ * @description WebGL指纹
420
+ */
421
+ webgl?: string;
422
+ /**
423
+ * @description Canvas指纹
424
+ */
425
+ canvas?: string;
426
+ /**
427
+ * @description 音频指纹
428
+ */
429
+ audio?: string;
430
+ /**
431
+ * @description 字体指纹
432
+ */
433
+ fonts?: string;
434
+ /**
435
+ * @description 插件指纹
436
+ */
437
+ plugins?: string;
438
+ /**
439
+ * @description 是否支持localStorage
440
+ */
441
+ localStorage?: boolean;
442
+ /**
443
+ * @description 是否支持sessionStorage
444
+ */
445
+ sessionStorage?: boolean;
446
+ /**
447
+ * @description 是否支持IndexedDB
448
+ */
449
+ indexedDB?: boolean;
450
+ /**
451
+ * @description CPU核心数
452
+ */
453
+ hardwareConcurrency?: number;
454
+ /**
455
+ * @description 设备内存(GB)
456
+ */
457
+ deviceMemory?: number;
458
+ /**
459
+ * @description 最大触摸点数
460
+ */
461
+ maxTouchPoints?: number;
462
+ /**
463
+ * @description 网络连接信息
464
+ */
465
+ connection?: string | NetworkConnection;
466
+ }