@fle-sdk/event-tracking-web 1.2.1 → 1.2.2

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.
@@ -17,6 +17,11 @@ declare class WebTracking extends Tools {
17
17
  private batchTimer;
18
18
  private readonly BATCH_QUEUE_STORAGE_KEY;
19
19
  private useCustomPageKey;
20
+ private pendingRequests;
21
+ private isUnloadListenerSetup;
22
+ private readonly PENDING_REQUESTS_STORAGE_KEY;
23
+ private readonly DEFAULT_PENDING_REQUESTS_MAX_SIZE;
24
+ private readonly MAX_STORAGE_SIZE;
20
25
  constructor();
21
26
  protected userInfo?: JsonProps;
22
27
  protected currentUrl: string;
@@ -116,14 +121,45 @@ declare class WebTracking extends Tools {
116
121
  * 从 LocalStorage 恢复批量队列
117
122
  */
118
123
  private restoreBatchQueueFromStorage;
124
+ /**
125
+ * 添加到待发送请求队列
126
+ * @param params 数据参数
127
+ */
128
+ private addToPendingRequests;
129
+ /**
130
+ * 从 LocalStorage 恢复待发送请求
131
+ */
132
+ private restorePendingRequestsFromStorage;
133
+ /**
134
+ * 检查页面是否即将卸载
135
+ * @returns 如果页面即将卸载返回 true,否则返回 false
136
+ */
137
+ private isPageUnloading;
138
+ /**
139
+ * 使用 sendBeacon 发送数据(页面卸载时的备用方案)
140
+ * @param params 数据参数
141
+ * @param serverUrl 服务器地址
142
+ * @param contentType 内容类型
143
+ * @returns 是否发送成功
144
+ */
145
+ private sendWithBeacon;
146
+ /**
147
+ * 刷新待发送的单个请求(正常情况下的发送)
148
+ * 注意:这个方法会直接发送,不会再次添加到 pendingRequests,避免循环
149
+ */
150
+ private flushPendingRequests;
119
151
  /**
120
152
  * 保存批量队列到 LocalStorage
121
153
  */
122
154
  private saveBatchQueueToStorage;
123
155
  /**
124
- * 设置页面卸载监听器,保存队列
156
+ * 设置页面卸载监听器,确保数据发送
125
157
  */
126
158
  private setupBeforeUnloadListener;
159
+ /**
160
+ * 刷新待发送数据(在页面卸载/跳转时调用)
161
+ */
162
+ private flushPendingData;
127
163
  /**
128
164
  * 发送数据通用函数
129
165
  */
@@ -57,6 +57,11 @@ export interface PresetParams {
57
57
  * @default false
58
58
  */
59
59
  autoTrack?: boolean;
60
+ /**
61
+ * @description 是否对带有 data-part-key 属性的元素点击进行上报(即使 autoTrack 为 false)
62
+ * @default false
63
+ */
64
+ trackPartKeyClick?: boolean;
60
65
  /**
61
66
  * @description (是否使用客户端系统时间)注意:客户端系统时间可能会不准确,导致该字段不准确
62
67
  * @default true
@@ -107,6 +112,11 @@ export interface PresetParams {
107
112
  * @default 10
108
113
  */
109
114
  batchMaxSize?: number;
115
+ /**
116
+ * @description 待发送请求队列最大数量(防止内存溢出)
117
+ * @default 50
118
+ */
119
+ pendingRequestsMaxSize?: number;
110
120
  /**
111
121
  * @description 自定义页面唯一标识,如果不传则自动从路由获取
112
122
  * @default 自动从 window.location.pathname 获取
@@ -122,6 +132,10 @@ export interface InitParams extends PresetParams {
122
132
  * @description 数据接收地址
123
133
  */
124
134
  serverUrl: string;
135
+ /**
136
+ * @description 用户信息,初始化时设置用户信息(可选,也可以通过 login 方法设置)
137
+ */
138
+ userInfo?: JsonProps;
125
139
  }
126
140
  export declare type PlatformType = "h5" | "pc" | "ipad" | "other";
127
141
  export interface SystemsInfoTypes {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fle-sdk/event-tracking-web",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "event tracking in web",
5
5
  "author": "飞象前端团队",
6
6
  "license": "ISC",