auto-point 0.0.23 → 0.0.25

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/AP/auto_point.js CHANGED
@@ -209,9 +209,15 @@
209
209
  })
210
210
  this.#POINT_LAST_SEND_TIME = new Date().getTime() // 更新最后发送时间
211
211
  navigator.sendBeacon(this.#SERVER, JSON.stringify(this.#POINT_LIST));
212
- let res = await this.#SEND_FUNC(this.#POINT_LIST)
213
- // 发送后清空埋点列表数据
214
- this.#POINT_LIST = new Array()
212
+ let res
213
+ try {
214
+ res = await this.#SEND_FUNC(this.#POINT_LIST)
215
+ } catch (error) {
216
+ console.error("Error sending data:", error)
217
+ } finally {
218
+ // 发送后清空埋点列表数据
219
+ this.#POINT_LIST = new Array()
220
+ }
215
221
  return res
216
222
  }
217
223
  }
package/README.md CHANGED
@@ -23,7 +23,10 @@ const ap = new AP().init({
23
23
  server: 'https://your-server.com/api/track', // 替换为真实的服务端地址
24
24
  interval_time: 5000, // 发送间隔:5秒
25
25
  events: ['click'], // 监听的事件类型
26
- point_sing: 'data-track-id' // 埋点标记属性名 如果元素上带有该属性名,AP会自动记录该属性值,否则不会记录
26
+ point_sing: 'data-track-id', // 埋点标记属性名 如果元素上带有该属性名,AP会自动记录该属性值,否则不会记录
27
+ send_func: function(data){
28
+ // 自定义发送函数,默认使用fetch发送数据,data为埋点数据
29
+ }
27
30
  });
28
31
 
29
32
  // 挂载中间件(在发送数据前执行)
package/package.json CHANGED
@@ -13,5 +13,5 @@
13
13
  "scripts": {
14
14
  "test": "echo \"Error: no test specified\" && exit 1"
15
15
  },
16
- "version": "0.0.23"
16
+ "version": "0.0.25"
17
17
  }