@jasolar/tracker-sdk 1.0.5 → 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 +23 -0
- package/dist/index.esm.js +23 -0
- 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
|
@@ -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
|
@@ -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
|
/**
|