auto-point 0.0.20 → 0.0.22
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 +4 -3
- package/README.md +1 -1
- package/package.json +1 -1
package/AP/auto_point.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// 事件列表
|
|
17
17
|
#EVENTS = ['click']
|
|
18
18
|
// 发送数据间隔 单位毫秒 默认10秒
|
|
19
|
-
#
|
|
19
|
+
#INTERVAL_TIME = 10000
|
|
20
20
|
// sing挂载事件元素标记
|
|
21
21
|
#POINT_SING = "auto_point"
|
|
22
22
|
// 埋点队列
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
#init(params) {
|
|
89
89
|
if (this.#INIT_STATE && this.#isObject(params, "Init only accepts object type data") && this.#params_hash_server(params.server)) {
|
|
90
90
|
this.#SERVER = params.server
|
|
91
|
-
this.#
|
|
91
|
+
this.#INTERVAL_TIME = params.interval_time || this.#INTERVAL_TIME
|
|
92
92
|
this.#POINT_SING = params.point_sing || this.#POINT_SING
|
|
93
93
|
if (params.events && this.#isArray(params.events, "events must be an Array")) {
|
|
94
94
|
this.#EVENTS = params.events
|
|
@@ -196,6 +196,7 @@
|
|
|
196
196
|
item.apply(this)
|
|
197
197
|
}
|
|
198
198
|
})
|
|
199
|
+
this.#POINT_LAST_SEND_TIME = new Date().getTime() // 更新最后发送时间
|
|
199
200
|
navigator.sendBeacon(this.#SERVER, JSON.stringify(this.#POINT_LIST));
|
|
200
201
|
// 发送后清空埋点列表数据
|
|
201
202
|
this.#POINT_LIST = new Array()
|
|
@@ -206,7 +207,7 @@
|
|
|
206
207
|
#timer_send() {
|
|
207
208
|
setInterval(() => {
|
|
208
209
|
this.#send()
|
|
209
|
-
}, this.#
|
|
210
|
+
}, this.#INTERVAL_TIME)
|
|
210
211
|
}
|
|
211
212
|
|
|
212
213
|
/**
|
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ npm i -S auto-point
|
|
|
21
21
|
import AP from "auto-point";
|
|
22
22
|
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
26
|
point_sing: 'data-track-id' // 埋点标记属性名 如果元素上带有该属性名,AP会自动记录该属性值,否则不会记录
|
|
27
27
|
});
|
package/package.json
CHANGED