@fle-sdk/event-tracking-web 1.2.5 → 1.2.7

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,45 @@
1
+ import { TrackingPostParams, ContentType } from "./type";
2
+ interface PendingRequestsConfig {
3
+ pendingRequestsMaxSize: number;
4
+ sendTimeout: number;
5
+ serverUrl: string;
6
+ contentType: ContentType;
7
+ showLog: boolean;
8
+ header?: Record<string, unknown>;
9
+ }
10
+ interface PendingRequestsCallbacks {
11
+ getLocalStorage: (key: string) => string | null;
12
+ setLocalStorage: (key: string, value: string) => void;
13
+ shouldSample: () => boolean;
14
+ ajax: (params: {
15
+ url: string;
16
+ type: string;
17
+ data: string;
18
+ contentType?: ContentType;
19
+ header?: Record<string, unknown>;
20
+ credentials?: boolean;
21
+ timeout?: number;
22
+ cors?: boolean;
23
+ success?: () => void;
24
+ error?: (err?: unknown) => void;
25
+ }) => void;
26
+ printLog: (message: string) => void;
27
+ }
28
+ export declare class PendingRequestsManager {
29
+ private isFlushingPendingData;
30
+ private isUnloadListenerSetup;
31
+ private config;
32
+ private callbacks;
33
+ constructor(config: PendingRequestsConfig, callbacks: PendingRequestsCallbacks);
34
+ updateConfig(config: Partial<PendingRequestsConfig>): void;
35
+ addToQueue(params: TrackingPostParams): void;
36
+ restoreQueue(): void;
37
+ flushQueue(): void;
38
+ flushQueueWithBeacon(): void;
39
+ setupUnloadListener(): void;
40
+ private getQueueFromStorage;
41
+ private saveQueueToStorage;
42
+ private isPageUnloading;
43
+ private sendWithBeacon;
44
+ }
45
+ export {};
@@ -172,16 +172,6 @@ export default class WebTrackingTools {
172
172
  * @returns 音频指纹字符串
173
173
  */
174
174
  private getAudioFingerprint;
175
- /**
176
- * 获取字体指纹
177
- * @returns 字体指纹字符串
178
- */
179
- private getFontFingerprint;
180
- /**
181
- * 获取插件指纹
182
- * @returns 插件指纹字符串
183
- */
184
- private getPluginsFingerprint;
185
175
  /**
186
176
  * 检测localStorage支持
187
177
  * @returns 是否支持localStorage
@@ -197,11 +187,6 @@ export default class WebTrackingTools {
197
187
  * @returns 是否支持IndexedDB
198
188
  */
199
189
  private hasIndexedDB;
200
- /**
201
- * 获取网络连接指纹
202
- * @returns 网络连接指纹字符串
203
- */
204
- private getConnectionFingerprint;
205
190
  /**
206
191
  * 将指纹信息哈希为唯一ID
207
192
  * @param fingerprint 指纹信息
@@ -34,6 +34,31 @@ export declare type JsonValue = string | number | boolean | null | undefined | J
34
34
  * @description 事件类型
35
35
  */
36
36
  export declare type EventTypes = "PageView" | "PageRetained" | "CustomTrack" | "WebClick" | "WebExposure";
37
+ /**
38
+ * @description 自动追踪配置
39
+ */
40
+ export interface AutoTrackConfig {
41
+ /**
42
+ * @description 是否自动追踪页面浏览事件
43
+ * @default false
44
+ */
45
+ view?: boolean;
46
+ /**
47
+ * @description 是否自动追踪点击事件
48
+ * @default false
49
+ */
50
+ click?: boolean;
51
+ /**
52
+ * @description 是否自动追踪曝光事件
53
+ * @default false
54
+ */
55
+ exposure?: boolean;
56
+ /**
57
+ * @description 是否自动追踪页面停留时长
58
+ * @default false
59
+ */
60
+ retained?: boolean;
61
+ }
37
62
  export interface PresetParams {
38
63
  /**
39
64
  * @description 应用唯一标识(由接口生成)
@@ -53,15 +78,12 @@ export interface PresetParams {
53
78
  */
54
79
  showLog?: boolean;
55
80
  /**
56
- * @description 是否开启全埋点 指的是:页面浏览、元素点击事件自动上报
81
+ * @description 是否开启自动追踪,支持 boolean 或 object 配置
82
+ * - boolean: true 表示开启所有自动追踪,false 表示关闭所有自动追踪
83
+ * - object: 可以单独配置 view、click、exposure、retained 的开启/关闭
57
84
  * @default false
58
85
  */
59
- autoTrack?: boolean;
60
- /**
61
- * @description 是否对带有 data-part-key 属性的元素点击进行上报(即使 autoTrack 为 false)
62
- * @default false
63
- */
64
- trackPartKeyClick?: boolean;
86
+ autoTrack?: boolean | AutoTrackConfig;
65
87
  /**
66
88
  * @description (是否使用客户端系统时间)注意:客户端系统时间可能会不准确,导致该字段不准确
67
89
  * @default true
@@ -127,21 +149,11 @@ export interface PresetParams {
127
149
  * @default 自动从 window.location.pathname 获取
128
150
  */
129
151
  pageKey?: string;
130
- /**
131
- * @description 是否定时上报页面停留时长
132
- * @default false
133
- */
134
- autoTrackPageDurationInterval?: boolean;
135
152
  /**
136
153
  * @description 定时上报页面停留时长的间隔时间(毫秒)
137
154
  * @default 30000 (30秒)
138
155
  */
139
156
  pageDurationInterval?: number;
140
- /**
141
- * @description 是否启用曝光埋点
142
- * @default false
143
- */
144
- autoTrackExposure?: boolean;
145
157
  /**
146
158
  * @description 曝光进入可视区判定阈值(0-1之间)
147
159
  * @default 0.5
@@ -197,7 +209,7 @@ export interface TrackParams {
197
209
  /**
198
210
  * @description 控件/自定义事件的唯一标识
199
211
  */
200
- partkey: string | number;
212
+ partKey: string | number;
201
213
  /**
202
214
  * @description 自定义代码埋点描述
203
215
  * @default "自定义代码埋点上报"
@@ -324,6 +336,10 @@ export interface PrivateParamProps {
324
336
  * @description 设备唯一标识
325
337
  */
326
338
  deviceId?: string;
339
+ /**
340
+ * @description 曝光元素位于第几屏
341
+ */
342
+ exposureScreenNo?: number;
327
343
  }
328
344
  export interface TrackingPostParams {
329
345
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fle-sdk/event-tracking-web",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "event tracking in web",
5
5
  "author": "飞象前端团队",
6
6
  "license": "ISC",