@jasolar/tracker-sdk 1.0.4 → 1.0.6
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/README.md +2 -2
- package/dist/index.cjs.js +25 -2
- package/dist/index.esm.js +25 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -95,8 +95,8 @@ tracker.enter({
|
|
|
95
95
|
- **options.appId**: 应用唯一标识。
|
|
96
96
|
|
|
97
97
|
### `tracker.enter(module)`
|
|
98
|
-
|
|
99
|
-
- **module**: 对象,通常包含 `module` (模块名), `sub_module` (子模块名)
|
|
98
|
+
记录进入某个模块/页面的开始,并自动上报 `module_enter` 事件。
|
|
99
|
+
- **module**: 对象,通常包含 `system` (系统名), `module` (模块名), `sub_module` (子模块名) 等字段。调用此方法会自动计算上一个模块的停留时长并上报 `module_leave` 事件,然后上报当前模块的 `module_enter` 事件。
|
|
100
100
|
|
|
101
101
|
### `tracker.leave()`
|
|
102
102
|
手动记录离开当前模块。通常配合 `enter` 使用。在 `enter` 新模块或页面关闭/隐藏时会自动触发。
|
package/dist/index.cjs.js
CHANGED
|
@@ -212,7 +212,7 @@ function send(url, data) {
|
|
|
212
212
|
var beaconUrl = url;
|
|
213
213
|
if (token) {
|
|
214
214
|
var separator = url.includes('?') ? '&' : '?';
|
|
215
|
-
beaconUrl = "".concat(url).concat(separator, "
|
|
215
|
+
beaconUrl = "".concat(url).concat(separator, "Authorization=").concat(encodeURIComponent('Bearer ' + token));
|
|
216
216
|
}
|
|
217
217
|
var blob = new Blob([body], {
|
|
218
218
|
type: 'application/json'
|
|
@@ -243,7 +243,7 @@ function send(url, data) {
|
|
|
243
243
|
var _beaconUrl = url;
|
|
244
244
|
if (token) {
|
|
245
245
|
var _separator = url.includes('?') ? '&' : '?';
|
|
246
|
-
_beaconUrl = "".concat(url).concat(_separator, "
|
|
246
|
+
_beaconUrl = "".concat(url).concat(_separator, "Authorization=").concat(encodeURIComponent('Bearer ' + token));
|
|
247
247
|
}
|
|
248
248
|
var _blob = new Blob([body], {
|
|
249
249
|
type: 'application/json'
|
|
@@ -486,6 +486,29 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
486
486
|
this.current = _objectSpread2(_objectSpread2({}, module), {}, {
|
|
487
487
|
enterTime: now()
|
|
488
488
|
});
|
|
489
|
+
|
|
490
|
+
// 构建 context 对象
|
|
491
|
+
var context = {
|
|
492
|
+
device_id: this.deviceId,
|
|
493
|
+
session_id: this.sessionId,
|
|
494
|
+
user_id: this.userId
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
// 构建 ext 对象(合并全局扩展参数和当前模块的额外信息)
|
|
498
|
+
var extData = _objectSpread2(_objectSpread2({}, this.globalExt), this.current.ext);
|
|
499
|
+
|
|
500
|
+
// 上报 module_enter 事件
|
|
501
|
+
var event = {
|
|
502
|
+
system: this.current.system || '',
|
|
503
|
+
module: this.current.module || '',
|
|
504
|
+
sub_module: this.current.sub_module || '',
|
|
505
|
+
duration: 0,
|
|
506
|
+
event: 'module_enter',
|
|
507
|
+
timestamp: formatTime(now()),
|
|
508
|
+
context: context,
|
|
509
|
+
ext: extData
|
|
510
|
+
};
|
|
511
|
+
this.queue.push(event);
|
|
489
512
|
}
|
|
490
513
|
|
|
491
514
|
/**
|
package/dist/index.esm.js
CHANGED
|
@@ -210,7 +210,7 @@ function send(url, data) {
|
|
|
210
210
|
var beaconUrl = url;
|
|
211
211
|
if (token) {
|
|
212
212
|
var separator = url.includes('?') ? '&' : '?';
|
|
213
|
-
beaconUrl = "".concat(url).concat(separator, "
|
|
213
|
+
beaconUrl = "".concat(url).concat(separator, "Authorization=").concat(encodeURIComponent('Bearer ' + token));
|
|
214
214
|
}
|
|
215
215
|
var blob = new Blob([body], {
|
|
216
216
|
type: 'application/json'
|
|
@@ -241,7 +241,7 @@ function send(url, data) {
|
|
|
241
241
|
var _beaconUrl = url;
|
|
242
242
|
if (token) {
|
|
243
243
|
var _separator = url.includes('?') ? '&' : '?';
|
|
244
|
-
_beaconUrl = "".concat(url).concat(_separator, "
|
|
244
|
+
_beaconUrl = "".concat(url).concat(_separator, "Authorization=").concat(encodeURIComponent('Bearer ' + token));
|
|
245
245
|
}
|
|
246
246
|
var _blob = new Blob([body], {
|
|
247
247
|
type: 'application/json'
|
|
@@ -484,6 +484,29 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
484
484
|
this.current = _objectSpread2(_objectSpread2({}, module), {}, {
|
|
485
485
|
enterTime: now()
|
|
486
486
|
});
|
|
487
|
+
|
|
488
|
+
// 构建 context 对象
|
|
489
|
+
var context = {
|
|
490
|
+
device_id: this.deviceId,
|
|
491
|
+
session_id: this.sessionId,
|
|
492
|
+
user_id: this.userId
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
// 构建 ext 对象(合并全局扩展参数和当前模块的额外信息)
|
|
496
|
+
var extData = _objectSpread2(_objectSpread2({}, this.globalExt), this.current.ext);
|
|
497
|
+
|
|
498
|
+
// 上报 module_enter 事件
|
|
499
|
+
var event = {
|
|
500
|
+
system: this.current.system || '',
|
|
501
|
+
module: this.current.module || '',
|
|
502
|
+
sub_module: this.current.sub_module || '',
|
|
503
|
+
duration: 0,
|
|
504
|
+
event: 'module_enter',
|
|
505
|
+
timestamp: formatTime(now()),
|
|
506
|
+
context: context,
|
|
507
|
+
ext: extData
|
|
508
|
+
};
|
|
509
|
+
this.queue.push(event);
|
|
487
510
|
}
|
|
488
511
|
|
|
489
512
|
/**
|