@tmsfe/tms-core 0.0.49 → 0.0.50
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/package.json
CHANGED
|
@@ -77,7 +77,7 @@ function deepClone(obj: any, depth = 0, maxDepth = 5): any {
|
|
|
77
77
|
* 获取触发绑定事件的携带数据
|
|
78
78
|
* @param event
|
|
79
79
|
*/
|
|
80
|
-
function
|
|
80
|
+
function getEventExtra(event: any): any {
|
|
81
81
|
if (!event) {
|
|
82
82
|
return '';
|
|
83
83
|
}
|
|
@@ -100,5 +100,5 @@ function getEventExtend(event: any): any {
|
|
|
100
100
|
|
|
101
101
|
export default {
|
|
102
102
|
deepClone,
|
|
103
|
-
|
|
103
|
+
getEventExtra,
|
|
104
104
|
};
|
|
@@ -17,13 +17,13 @@ function proxyBindEvent(componentName: string, methods: any, methodName: string)
|
|
|
17
17
|
}
|
|
18
18
|
// eslint-disable-next-line no-param-reassign
|
|
19
19
|
methods[methodName] = function (...args: any[]): any {
|
|
20
|
-
const
|
|
20
|
+
const extra = clone.getEventExtra(args[0]) ; // 把触发事件附加数据也带上
|
|
21
21
|
// 执行原函数之后再发埋点
|
|
22
22
|
return helper.executeFunc(this, original, args, () => {
|
|
23
23
|
const data = clone.deepClone(this.data);
|
|
24
24
|
const eventName = `Component_${componentName}`;
|
|
25
|
-
helper.setLastBindEvent({ eventName, methodName, data,
|
|
26
|
-
helper.reportData(eventName, methodName, data,
|
|
25
|
+
helper.setLastBindEvent({ eventName, methodName, data, extra });
|
|
26
|
+
helper.reportData(eventName, methodName, data, extra);
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
}
|
package/src/report/proxy/page.ts
CHANGED
|
@@ -28,8 +28,8 @@ function proxyLifeMethod(pageOptions: any, methodName: string): void {
|
|
|
28
28
|
pageOptions[methodName] = function (...args: any[]): any {
|
|
29
29
|
// 生命周期函数先发埋点,避免次过程用户退出而丢失埋点
|
|
30
30
|
const options = clone.deepClone(args[0], 0, 1);
|
|
31
|
-
const
|
|
32
|
-
helper.reportData(`Page_${methodName}`, options,
|
|
31
|
+
const extra = getPageLifeExtra(this, methodName);
|
|
32
|
+
helper.reportData(`Page_${methodName}`, options, extra);
|
|
33
33
|
|
|
34
34
|
// 执行原函数
|
|
35
35
|
return helper.executeFunc(this, original, args, helper.emptyFunc);
|
|
@@ -37,9 +37,8 @@ function proxyLifeMethod(pageOptions: any, methodName: string): void {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// 获取生命周期函数上报时的附加信息
|
|
40
|
-
function
|
|
40
|
+
function getPageLifeExtra(page: any, methodName: string): IPageLifeExtra {
|
|
41
41
|
/* eslint-disable */
|
|
42
|
-
page.tmsPageShowCount = page.tmsPageShowCount || 0;
|
|
43
42
|
// 页面生命周期内第几次曝光
|
|
44
43
|
let showCount: number;
|
|
45
44
|
// 距离onShow的时长,如果是onShow函数则为距离onLoad的时长
|
|
@@ -50,9 +49,10 @@ function getPageLifeExtend(page: any, methodName: string): IPageLifeExtend {
|
|
|
50
49
|
showCount = page.tmsPageShowCount;
|
|
51
50
|
lessShowTime = page.tmsPageShowTime - page.tmsPageLoadTime;
|
|
52
51
|
} else if (methodName === 'onLoad') {
|
|
52
|
+
page.tmsPageShowCount = 0;
|
|
53
|
+
page.tmsPageLoadTime = Date.now();
|
|
53
54
|
showCount = 1;
|
|
54
55
|
lessShowTime = 0;
|
|
55
|
-
page.tmsPageLoadTime = Date.now();
|
|
56
56
|
} else {
|
|
57
57
|
showCount = page.tmsPageShowCount;
|
|
58
58
|
lessShowTime = Date.now() - page.tmsPageShowTime;
|
|
@@ -70,13 +70,13 @@ function proxyBindEvent(pageOptions: any, methodName: string): void {
|
|
|
70
70
|
}
|
|
71
71
|
// eslint-disable-next-line no-param-reassign
|
|
72
72
|
pageOptions[methodName] = function (...args: any[]): any {
|
|
73
|
-
const
|
|
73
|
+
const extra = clone.getEventExtra(args[0]) ; // 把触发事件附加数据也带上
|
|
74
74
|
// 执行原函数之后再发埋点
|
|
75
75
|
return helper.executeFunc(this, original, args, () => {
|
|
76
76
|
const data = clone.deepClone(this.data);
|
|
77
77
|
const eventName = `Page_${methodName}`;
|
|
78
|
-
helper.setLastBindEvent({ eventName, methodName, data,
|
|
79
|
-
helper.reportData(eventName, data,
|
|
78
|
+
helper.setLastBindEvent({ eventName, methodName, data, extra });
|
|
79
|
+
helper.reportData(eventName, data, extra);
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
82
|
}
|
|
@@ -23,13 +23,13 @@ interface IBindEvent {
|
|
|
23
23
|
/**
|
|
24
24
|
* 触发事件的携带参数
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
extra: object,
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* 页面生命周期函数的埋点附加数据
|
|
31
31
|
*/
|
|
32
|
-
interface
|
|
32
|
+
interface IPageLifeExtra {
|
|
33
33
|
/**
|
|
34
34
|
* 页面生命周期内第几次曝光
|
|
35
35
|
*/
|
|
@@ -37,7 +37,7 @@ interface IPageLifeExtend {
|
|
|
37
37
|
/**
|
|
38
38
|
* 距离onShow的时长,如果是onShow函数则为距离onLoad的时长
|
|
39
39
|
*/
|
|
40
|
-
lessShowTime
|
|
40
|
+
lessShowTime: number,
|
|
41
41
|
/**
|
|
42
42
|
* 最后一个触发绑定事件埋点
|
|
43
43
|
*/
|