@cloudcare/rum-uniapp 2.1.18 → 2.1.20
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 +42 -34
- package/cjs/boot/buildEnv.js +3 -4
- package/cjs/boot/rum.entry.js +11 -36
- package/cjs/boot/rum.js +2 -25
- package/cjs/core/baseInfo.js +6 -25
- package/cjs/core/boundedBuffer.js +1 -7
- package/cjs/core/configuration.js +15 -27
- package/cjs/core/contextManager.js +5 -17
- package/cjs/core/dataMap.js +5 -10
- package/cjs/core/downloadProxy.js +4 -26
- package/cjs/core/errorCollection.js +5 -35
- package/cjs/core/errorFilter.js +0 -8
- package/cjs/core/errorTools.js +2 -10
- package/cjs/core/heavyCustomerDataWarning.js +3 -9
- package/cjs/core/lifeCycle.js +8 -18
- package/cjs/core/observable.js +7 -13
- package/cjs/core/sdk.js +4 -13
- package/cjs/core/sessionManagement.js +8 -17
- package/cjs/core/transport.js +6 -53
- package/cjs/core/user.js +2 -7
- package/cjs/core/xhrProxy.js +4 -26
- package/cjs/helper/byteUtils.js +6 -12
- package/cjs/helper/commonContext.js +2 -3
- package/cjs/helper/enums.js +17 -28
- package/cjs/helper/jsonStringify.js +5 -12
- package/cjs/helper/limitModification.js +3 -21
- package/cjs/helper/tracekit.js +33 -145
- package/cjs/helper/utils.js +92 -306
- package/cjs/index.js +0 -1
- package/cjs/rumEventsCollection/action/actionCollection.js +0 -9
- package/cjs/rumEventsCollection/action/trackActions.js +6 -28
- package/cjs/rumEventsCollection/app/appCollection.js +0 -6
- package/cjs/rumEventsCollection/app/index.js +14 -26
- package/cjs/rumEventsCollection/assembly.js +0 -14
- package/cjs/rumEventsCollection/error/errorCollection.js +1 -16
- package/cjs/rumEventsCollection/internalContext.js +0 -2
- package/cjs/rumEventsCollection/page/index.js +5 -43
- package/cjs/rumEventsCollection/page/viewCollection.js +0 -8
- package/cjs/rumEventsCollection/parentContexts.js +3 -20
- package/cjs/rumEventsCollection/performanceCollection.js +0 -4
- package/cjs/rumEventsCollection/requestCollection.js +1 -14
- package/cjs/rumEventsCollection/resource/resourceCollection.js +0 -11
- package/cjs/rumEventsCollection/resource/resourceUtils.js +50 -46
- package/cjs/rumEventsCollection/setDataCollection.js +0 -16
- package/cjs/rumEventsCollection/tracing/ddtraceTracer.js +0 -6
- package/cjs/rumEventsCollection/tracing/jaegerTracer.js +3 -9
- package/cjs/rumEventsCollection/tracing/skywalkingTracer.js +3 -10
- package/cjs/rumEventsCollection/tracing/tracer.js +1 -25
- package/cjs/rumEventsCollection/tracing/w3cTraceParentTracer.js +1 -6
- package/cjs/rumEventsCollection/tracing/zipkinMultiTracer.js +3 -10
- package/cjs/rumEventsCollection/tracing/zipkinSingleTracer.js +1 -6
- package/cjs/rumEventsCollection/trackEventCounts.js +0 -8
- package/cjs/rumEventsCollection/trackPageActiveites.js +10 -33
- package/cjs/rumEventsCollection/transport/batch.js +0 -9
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/rum.entry.js +8 -20
- package/esm/boot/rum.js +0 -4
- package/esm/core/baseInfo.js +0 -11
- package/esm/core/boundedBuffer.js +0 -3
- package/esm/core/configuration.js +13 -21
- package/esm/core/contextManager.js +3 -8
- package/esm/core/dataMap.js +2 -2
- package/esm/core/downloadProxy.js +2 -17
- package/esm/core/errorCollection.js +2 -15
- package/esm/core/errorFilter.js +0 -5
- package/esm/core/errorTools.js +0 -3
- package/esm/core/heavyCustomerDataWarning.js +3 -3
- package/esm/core/lifeCycle.js +0 -5
- package/esm/core/observable.js +0 -3
- package/esm/core/sdk.js +1 -6
- package/esm/core/sessionManagement.js +0 -3
- package/esm/core/transport.js +4 -38
- package/esm/core/user.js +2 -4
- package/esm/core/xhrProxy.js +2 -17
- package/esm/helper/byteUtils.js +4 -7
- package/esm/helper/commonContext.js +2 -2
- package/esm/helper/jsonStringify.js +4 -7
- package/esm/helper/limitModification.js +1 -11
- package/esm/helper/tracekit.js +30 -130
- package/esm/helper/utils.js +27 -125
- package/esm/rumEventsCollection/action/actionCollection.js +0 -4
- package/esm/rumEventsCollection/action/trackActions.js +6 -20
- package/esm/rumEventsCollection/app/appCollection.js +0 -1
- package/esm/rumEventsCollection/app/index.js +12 -18
- package/esm/rumEventsCollection/assembly.js +0 -6
- package/esm/rumEventsCollection/error/errorCollection.js +0 -7
- package/esm/rumEventsCollection/internalContext.js +0 -1
- package/esm/rumEventsCollection/page/index.js +5 -37
- package/esm/rumEventsCollection/page/viewCollection.js +0 -3
- package/esm/rumEventsCollection/parentContexts.js +0 -10
- package/esm/rumEventsCollection/requestCollection.js +0 -4
- package/esm/rumEventsCollection/resource/resourceCollection.js +0 -5
- package/esm/rumEventsCollection/resource/resourceUtils.js +48 -39
- package/esm/rumEventsCollection/setDataCollection.js +0 -13
- package/esm/rumEventsCollection/tracing/ddtraceTracer.js +0 -4
- package/esm/rumEventsCollection/tracing/jaegerTracer.js +3 -7
- package/esm/rumEventsCollection/tracing/skywalkingTracer.js +5 -9
- package/esm/rumEventsCollection/tracing/tracer.js +0 -14
- package/esm/rumEventsCollection/tracing/w3cTraceParentTracer.js +1 -4
- package/esm/rumEventsCollection/tracing/zipkinMultiTracer.js +3 -8
- package/esm/rumEventsCollection/tracing/zipkinSingleTracer.js +1 -4
- package/esm/rumEventsCollection/trackEventCounts.js +0 -4
- package/esm/rumEventsCollection/trackPageActiveites.js +9 -22
- package/esm/rumEventsCollection/transport/batch.js +0 -5
- package/package.json +6 -3
package/cjs/index.js
CHANGED
|
@@ -4,24 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startActionCollection = startActionCollection;
|
|
7
|
-
|
|
8
7
|
var _utils = require("../../helper/utils");
|
|
9
|
-
|
|
10
8
|
var _lifeCycle = require("../../core/lifeCycle");
|
|
11
|
-
|
|
12
9
|
var _enums = require("../../helper/enums");
|
|
13
|
-
|
|
14
10
|
var _trackActions = require("./trackActions");
|
|
15
|
-
|
|
16
11
|
function startActionCollection(lifeCycle, configuration, Vue) {
|
|
17
12
|
lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.AUTO_ACTION_COMPLETED, function (action) {
|
|
18
13
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action));
|
|
19
14
|
});
|
|
20
|
-
|
|
21
15
|
if (configuration.trackInteractions) {
|
|
22
16
|
(0, _trackActions.trackActions)(lifeCycle, Vue);
|
|
23
17
|
}
|
|
24
|
-
|
|
25
18
|
return {
|
|
26
19
|
addAction: function addAction(action, savedCommonContext) {
|
|
27
20
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, (0, _utils.extend2Lev)({
|
|
@@ -30,7 +23,6 @@ function startActionCollection(lifeCycle, configuration, Vue) {
|
|
|
30
23
|
}
|
|
31
24
|
};
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
function processAction(action) {
|
|
35
27
|
var autoActionProperties = isAutoAction(action) ? {
|
|
36
28
|
action: {
|
|
@@ -68,7 +60,6 @@ function processAction(action) {
|
|
|
68
60
|
startTime: action.startClocks
|
|
69
61
|
};
|
|
70
62
|
}
|
|
71
|
-
|
|
72
63
|
function isAutoAction(action) {
|
|
73
64
|
return action.type !== _enums.ActionType.custom;
|
|
74
65
|
}
|
|
@@ -4,31 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.trackActions = trackActions;
|
|
7
|
-
|
|
8
7
|
var _utils = require("../../helper/utils");
|
|
9
|
-
|
|
10
8
|
var _lifeCycle = require("../../core/lifeCycle");
|
|
11
|
-
|
|
12
9
|
var _trackEventCounts = require("../trackEventCounts");
|
|
13
|
-
|
|
14
10
|
var _trackPageActiveites = require("../trackPageActiveites");
|
|
15
|
-
|
|
16
11
|
var _enums = require("../../helper/enums");
|
|
17
|
-
|
|
18
12
|
var _sdk = require("../../core/sdk");
|
|
19
|
-
|
|
20
13
|
var WHITE_METHOD = ['setup'];
|
|
21
|
-
|
|
22
14
|
function trackActions(lifeCycle, Vue) {
|
|
23
|
-
var action = startActionManagement(lifeCycle);
|
|
15
|
+
var action = startActionManagement(lifeCycle);
|
|
24
16
|
|
|
17
|
+
// New views trigger the discard of the current pending Action
|
|
25
18
|
lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.VIEW_CREATED, function () {
|
|
26
19
|
action.discardCurrent();
|
|
27
20
|
});
|
|
28
|
-
|
|
29
21
|
if (Vue && Vue.extend) {
|
|
30
22
|
var originVueExtend = Vue.extend;
|
|
31
|
-
|
|
32
23
|
Vue.extend = function (vueOptions) {
|
|
33
24
|
proxyInstance(vueOptions, action, lifeCycle);
|
|
34
25
|
return originVueExtend.call(this, vueOptions);
|
|
@@ -36,25 +27,23 @@ function trackActions(lifeCycle, Vue) {
|
|
|
36
27
|
} else {
|
|
37
28
|
if (!_sdk.tracker) return;
|
|
38
29
|
var originCreatePage = _sdk.tracker.createPage;
|
|
39
|
-
|
|
40
30
|
_sdk.tracker.createPage = function (page) {
|
|
41
31
|
// methods 方法
|
|
42
32
|
proxyInstance(page, action, lifeCycle);
|
|
43
33
|
return originCreatePage.call(this, page);
|
|
44
34
|
};
|
|
45
|
-
|
|
46
35
|
var originCreateComponent = _sdk.tracker.createComponent;
|
|
47
|
-
|
|
48
36
|
_sdk.tracker.createComponent = function (component) {
|
|
49
37
|
proxyInstance(component, action, lifeCycle);
|
|
50
38
|
return originCreateComponent.call(this, component);
|
|
51
39
|
};
|
|
52
|
-
}
|
|
53
|
-
|
|
40
|
+
}
|
|
41
|
+
// var originVueExtend = Vue.extend
|
|
54
42
|
|
|
55
43
|
return {
|
|
56
44
|
stop: function stop() {
|
|
57
|
-
action.discardCurrent();
|
|
45
|
+
action.discardCurrent();
|
|
46
|
+
// stopListener()
|
|
58
47
|
}
|
|
59
48
|
};
|
|
60
49
|
}
|
|
@@ -69,7 +58,6 @@ function proxyInstance(options, action, lifeCycle) {
|
|
|
69
58
|
}, lifeCycle);
|
|
70
59
|
});
|
|
71
60
|
}
|
|
72
|
-
|
|
73
61
|
var originMethods = (0, _utils.getMethods)(options);
|
|
74
62
|
originMethods.forEach(function (methodName) {
|
|
75
63
|
clickProxy(options, methodName, function (_action) {
|
|
@@ -77,20 +65,16 @@ function proxyInstance(options, action, lifeCycle) {
|
|
|
77
65
|
}, lifeCycle);
|
|
78
66
|
});
|
|
79
67
|
}
|
|
80
|
-
|
|
81
68
|
function clickProxy(origin, methodName, callback, lifeCycle) {
|
|
82
69
|
if (WHITE_METHOD.indexOf(methodName) > -1) return;
|
|
83
70
|
var originMethod = origin[methodName];
|
|
84
|
-
|
|
85
71
|
origin[methodName] = function () {
|
|
86
72
|
var result = originMethod.apply(this, arguments);
|
|
87
73
|
var action = {};
|
|
88
|
-
|
|
89
74
|
if ((0, _utils.isObject)(arguments[0])) {
|
|
90
75
|
var currentTarget = arguments[0].currentTarget || {};
|
|
91
76
|
var dataset = currentTarget.dataset || {};
|
|
92
77
|
var actionType = arguments[0].type;
|
|
93
|
-
|
|
94
78
|
if (actionType && _enums.ActionType[actionType]) {
|
|
95
79
|
action.type = actionType;
|
|
96
80
|
action.name = dataset.name || dataset.content || dataset.type;
|
|
@@ -119,11 +103,9 @@ function clickProxy(origin, methodName, callback, lifeCycle) {
|
|
|
119
103
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.PAGE_ALIAS_ACTION, true);
|
|
120
104
|
}
|
|
121
105
|
}
|
|
122
|
-
|
|
123
106
|
return result;
|
|
124
107
|
};
|
|
125
108
|
}
|
|
126
|
-
|
|
127
109
|
function startActionManagement(lifeCycle) {
|
|
128
110
|
var currentAction;
|
|
129
111
|
var currentIdlePageActivitySubscription;
|
|
@@ -133,7 +115,6 @@ function startActionManagement(lifeCycle) {
|
|
|
133
115
|
// Ignore any new action if another one is already occurring.
|
|
134
116
|
return;
|
|
135
117
|
}
|
|
136
|
-
|
|
137
118
|
var pendingAutoAction = new PendingAutoAction(lifeCycle, type, name);
|
|
138
119
|
currentAction = pendingAutoAction;
|
|
139
120
|
currentIdlePageActivitySubscription = (0, _trackPageActiveites.waitIdlePageActivity)(lifeCycle, function (params) {
|
|
@@ -142,7 +123,6 @@ function startActionManagement(lifeCycle) {
|
|
|
142
123
|
} else {
|
|
143
124
|
pendingAutoAction.discard();
|
|
144
125
|
}
|
|
145
|
-
|
|
146
126
|
currentAction = undefined;
|
|
147
127
|
});
|
|
148
128
|
},
|
|
@@ -155,7 +135,6 @@ function startActionManagement(lifeCycle) {
|
|
|
155
135
|
}
|
|
156
136
|
};
|
|
157
137
|
}
|
|
158
|
-
|
|
159
138
|
var PendingAutoAction = function PendingAutoAction(lifeCycle, type, name) {
|
|
160
139
|
this.id = (0, _utils.UUID)();
|
|
161
140
|
this.startClocks = (0, _utils.now)();
|
|
@@ -168,7 +147,6 @@ var PendingAutoAction = function PendingAutoAction(lifeCycle, type, name) {
|
|
|
168
147
|
startClocks: this.startClocks
|
|
169
148
|
});
|
|
170
149
|
};
|
|
171
|
-
|
|
172
150
|
PendingAutoAction.prototype = {
|
|
173
151
|
complete: function complete(endTime) {
|
|
174
152
|
var eventCounts = this.eventCountsSubscription.eventCounts;
|
|
@@ -4,22 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startAppCollection = startAppCollection;
|
|
7
|
-
|
|
8
7
|
var _index = require("./index");
|
|
9
|
-
|
|
10
8
|
var _lifeCycle = require("../../core/lifeCycle");
|
|
11
|
-
|
|
12
9
|
var _enums = require("../../helper/enums");
|
|
13
|
-
|
|
14
10
|
var _utils = require("../../helper/utils");
|
|
15
|
-
|
|
16
11
|
function startAppCollection(lifeCycle, configuration) {
|
|
17
12
|
lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.APP_UPDATE, function (appinfo) {
|
|
18
13
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAppUpdate(appinfo));
|
|
19
14
|
});
|
|
20
15
|
return (0, _index.rewriteApp)(configuration, lifeCycle);
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
function processAppUpdate(appinfo) {
|
|
24
18
|
var appEvent = {
|
|
25
19
|
date: appinfo.startTime,
|
|
@@ -3,36 +3,30 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.THROTTLE_VIEW_UPDATE_PERIOD = void 0;
|
|
6
7
|
exports.rewriteApp = rewriteApp;
|
|
7
|
-
exports.startupTypes =
|
|
8
|
-
|
|
8
|
+
exports.startupTypes = void 0;
|
|
9
9
|
var _utils = require("../../helper/utils");
|
|
10
|
-
|
|
11
10
|
var _lifeCycle = require("../../core/lifeCycle");
|
|
12
|
-
|
|
13
11
|
// 劫持原小程序App方法
|
|
14
|
-
var THROTTLE_VIEW_UPDATE_PERIOD = 3000;
|
|
15
|
-
exports.
|
|
16
|
-
var startupTypes = {
|
|
12
|
+
var THROTTLE_VIEW_UPDATE_PERIOD = exports.THROTTLE_VIEW_UPDATE_PERIOD = 3000;
|
|
13
|
+
var startupTypes = exports.startupTypes = {
|
|
17
14
|
COLD: 'cold',
|
|
18
15
|
HOT: 'hot'
|
|
19
16
|
};
|
|
20
|
-
exports.startupTypes = startupTypes;
|
|
21
|
-
|
|
22
17
|
function rewriteApp(configuration, lifeCycle, Vue) {
|
|
23
18
|
var originApp = App;
|
|
24
19
|
var appInfo = {
|
|
25
20
|
isStartUp: false // 是否启动
|
|
26
|
-
|
|
27
21
|
};
|
|
28
|
-
var startTime;
|
|
29
22
|
|
|
23
|
+
var startTime;
|
|
30
24
|
App = function App(app) {
|
|
31
|
-
startTime = (0, _utils.now)()
|
|
25
|
+
startTime = (0, _utils.now)()
|
|
26
|
+
// 合并方法,插入记录脚本
|
|
32
27
|
;
|
|
33
28
|
['onLaunch', 'onShow', 'onHide'].forEach(function (methodName) {
|
|
34
29
|
var userDefinedMethod = app[methodName]; // 暂存用户定义的方法
|
|
35
|
-
|
|
36
30
|
app[methodName] = function (options) {
|
|
37
31
|
if (methodName === 'onLaunch') {
|
|
38
32
|
appInfo.isStartUp = true;
|
|
@@ -41,22 +35,20 @@ function rewriteApp(configuration, lifeCycle, Vue) {
|
|
|
41
35
|
} else if (methodName === 'onShow') {
|
|
42
36
|
if (appInfo.isStartUp && appInfo.isHide) {
|
|
43
37
|
// 判断是热启动
|
|
44
|
-
appInfo.startupType = startupTypes.HOT;
|
|
38
|
+
appInfo.startupType = startupTypes.HOT;
|
|
39
|
+
// appUpdate()
|
|
45
40
|
}
|
|
46
41
|
} else if (methodName === 'onHide') {
|
|
47
42
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.APP_HIDE);
|
|
48
43
|
appInfo.isHide = true;
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
return userDefinedMethod && userDefinedMethod.call(this, options);
|
|
52
46
|
};
|
|
53
47
|
});
|
|
54
48
|
return originApp(app);
|
|
55
49
|
};
|
|
56
|
-
|
|
57
50
|
startPerformanceObservable(lifeCycle);
|
|
58
51
|
}
|
|
59
|
-
|
|
60
52
|
function startPerformanceObservable(lifeCycle) {
|
|
61
53
|
var subscribe = lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entitys) {
|
|
62
54
|
// 过滤掉其他页面监听,只保留首次启动
|
|
@@ -64,7 +56,6 @@ function startPerformanceObservable(lifeCycle) {
|
|
|
64
56
|
var launchEntity = entitys.find(function (entity) {
|
|
65
57
|
return entity.entryType === 'navigation' && entity.navigationType === 'appLaunch';
|
|
66
58
|
});
|
|
67
|
-
|
|
68
59
|
if (typeof launchEntity !== 'undefined') {
|
|
69
60
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.APP_UPDATE, {
|
|
70
61
|
startTime: launchEntity.startTime,
|
|
@@ -74,11 +65,9 @@ function startPerformanceObservable(lifeCycle) {
|
|
|
74
65
|
duration: launchEntity.duration
|
|
75
66
|
});
|
|
76
67
|
}
|
|
77
|
-
|
|
78
68
|
var scriptentity = entitys.find(function (entity) {
|
|
79
69
|
return entity.entryType === 'script' && entity.name === 'evaluateScript';
|
|
80
70
|
});
|
|
81
|
-
|
|
82
71
|
if (typeof scriptentity !== 'undefined') {
|
|
83
72
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.APP_UPDATE, {
|
|
84
73
|
startTime: scriptentity.startTime,
|
|
@@ -88,27 +77,26 @@ function startPerformanceObservable(lifeCycle) {
|
|
|
88
77
|
duration: scriptentity.duration
|
|
89
78
|
});
|
|
90
79
|
}
|
|
91
|
-
|
|
92
80
|
var firstEntity = entitys.find(function (entity) {
|
|
93
81
|
return entity.entryType === 'render' && entity.name === 'firstRender';
|
|
94
82
|
});
|
|
95
|
-
|
|
96
83
|
if (firstEntity && scriptentity && launchEntity) {
|
|
97
84
|
if (!(0, _utils.areInOrder)(firstEntity.duration, launchEntity.duration) || !(0, _utils.areInOrder)(scriptentity.duration, launchEntity.duration)) {
|
|
98
85
|
return;
|
|
99
86
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
87
|
+
codeDownloadDuration = launchEntity.duration - firstEntity.duration - scriptentity.duration;
|
|
88
|
+
// 资源下载耗时
|
|
103
89
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.APP_UPDATE, {
|
|
104
90
|
startTime: launchEntity.startTime,
|
|
105
91
|
name: '小程序包下载',
|
|
106
92
|
type: 'package_download',
|
|
107
93
|
id: (0, _utils.UUID)(),
|
|
108
94
|
duration: codeDownloadDuration
|
|
109
|
-
});
|
|
95
|
+
});
|
|
96
|
+
// 资源下载时间暂时定为:首次启动时间-脚本加载时间-初次渲染时间
|
|
110
97
|
}
|
|
111
98
|
});
|
|
99
|
+
|
|
112
100
|
return {
|
|
113
101
|
stop: subscribe.unsubscribe
|
|
114
102
|
};
|
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startRumAssembly = startRumAssembly;
|
|
7
|
-
|
|
8
7
|
var _utils = require("../helper/utils");
|
|
9
|
-
|
|
10
8
|
var _lifeCycle = require("../core/lifeCycle");
|
|
11
|
-
|
|
12
9
|
var _enums = require("../helper/enums");
|
|
13
|
-
|
|
14
10
|
var _baseInfo = _interopRequireDefault(require("../core/baseInfo"));
|
|
15
|
-
|
|
16
11
|
var _sessionManagement = require("../core/sessionManagement");
|
|
17
|
-
|
|
18
12
|
var _errorFilter = require("../core/errorFilter");
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
-
|
|
22
14
|
function startRumAssembly(applicationId, configuration, session, lifeCycle, parentContexts, getCommonContext) {
|
|
23
15
|
var errorFilter = (0, _errorFilter.createErrorFilter)(configuration, function (error) {
|
|
24
16
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_ERROR_COLLECTED, {
|
|
@@ -39,7 +31,6 @@ function startRumAssembly(applicationId, configuration, session, lifeCycle, pare
|
|
|
39
31
|
launch: _baseInfo["default"].getLaunchOptions()
|
|
40
32
|
}
|
|
41
33
|
};
|
|
42
|
-
|
|
43
34
|
if (session.isTracked() && (viewContext || rawRumEvent.type === _enums.RumEventType.APP)) {
|
|
44
35
|
var actionContext = parentContexts.findAction(startTime);
|
|
45
36
|
var commonContext = savedCommonContext || getCommonContext();
|
|
@@ -69,11 +60,9 @@ function startRumAssembly(applicationId, configuration, session, lifeCycle, pare
|
|
|
69
60
|
var rumEvent = (0, _utils.extend2Lev)(rumContext, deviceContext, appContext, viewContext, actionContext, rawRumEvent);
|
|
70
61
|
var serverRumEvent = (0, _utils.withSnakeCaseKeys)(rumEvent);
|
|
71
62
|
var context = (0, _utils.extend2Lev)({}, commonContext.context, customerContext);
|
|
72
|
-
|
|
73
63
|
if (!(0, _utils.isEmptyObject)(context)) {
|
|
74
64
|
serverRumEvent.tags = context;
|
|
75
65
|
}
|
|
76
|
-
|
|
77
66
|
if (!(0, _utils.isEmptyObject)(commonContext.user)) {
|
|
78
67
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
79
68
|
serverRumEvent.user = (0, _utils.extend2Lev)({
|
|
@@ -81,18 +70,15 @@ function startRumAssembly(applicationId, configuration, session, lifeCycle, pare
|
|
|
81
70
|
is_signin: 'T'
|
|
82
71
|
}, commonContext.user);
|
|
83
72
|
}
|
|
84
|
-
|
|
85
73
|
if (shouldSend(serverRumEvent, errorFilter)) {
|
|
86
74
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
|
|
87
75
|
}
|
|
88
76
|
}
|
|
89
77
|
});
|
|
90
78
|
}
|
|
91
|
-
|
|
92
79
|
function shouldSend(event, errorFilter) {
|
|
93
80
|
if (event.type === _enums.RumEventType.ERROR) {
|
|
94
81
|
return !errorFilter.isLimitReached();
|
|
95
82
|
}
|
|
96
|
-
|
|
97
83
|
return true;
|
|
98
84
|
}
|
|
@@ -3,21 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.startErrorCollection = startErrorCollection;
|
|
7
6
|
exports.doStartErrorCollection = doStartErrorCollection;
|
|
8
|
-
|
|
7
|
+
exports.startErrorCollection = startErrorCollection;
|
|
9
8
|
var _errorCollection = require("../../core/errorCollection");
|
|
10
|
-
|
|
11
9
|
var _enums = require("../../helper/enums");
|
|
12
|
-
|
|
13
10
|
var _lifeCycle = require("../../core/lifeCycle");
|
|
14
|
-
|
|
15
11
|
var _errorTools = require("../../core/errorTools");
|
|
16
|
-
|
|
17
12
|
var _utils = require("../../helper/utils");
|
|
18
|
-
|
|
19
13
|
var _tracekit = require("../../helper/tracekit");
|
|
20
|
-
|
|
21
14
|
function startErrorCollection(lifeCycle, configuration) {
|
|
22
15
|
(0, _errorCollection.startAutomaticErrorCollection)(configuration).subscribe(function (error) {
|
|
23
16
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_ERROR_COLLECTED, {
|
|
@@ -26,7 +19,6 @@ function startErrorCollection(lifeCycle, configuration) {
|
|
|
26
19
|
});
|
|
27
20
|
return doStartErrorCollection(lifeCycle);
|
|
28
21
|
}
|
|
29
|
-
|
|
30
22
|
function doStartErrorCollection(lifeCycle) {
|
|
31
23
|
lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.RAW_ERROR_COLLECTED, function (error) {
|
|
32
24
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processError(error.error));
|
|
@@ -41,7 +33,6 @@ function doStartErrorCollection(lifeCycle) {
|
|
|
41
33
|
}
|
|
42
34
|
};
|
|
43
35
|
}
|
|
44
|
-
|
|
45
36
|
function computeRawError(error, startTime, context) {
|
|
46
37
|
var stackTrace = error instanceof Error ? (0, _tracekit.computeStackTrace)(error) : undefined;
|
|
47
38
|
return (0, _utils.extend)({
|
|
@@ -50,11 +41,9 @@ function computeRawError(error, startTime, context) {
|
|
|
50
41
|
context: context
|
|
51
42
|
}, (0, _errorTools.formatUnknownError)(stackTrace, error, 'Provided'));
|
|
52
43
|
}
|
|
53
|
-
|
|
54
44
|
function processError(error) {
|
|
55
45
|
var resource = error.resource;
|
|
56
46
|
var tracingInfo;
|
|
57
|
-
|
|
58
47
|
if (resource) {
|
|
59
48
|
tracingInfo = computeRequestTracingInfo(resource);
|
|
60
49
|
var urlObj = (0, _utils.urlParse)(error.resource.url).getParse();
|
|
@@ -68,7 +57,6 @@ function processError(error) {
|
|
|
68
57
|
urlPathGroup: (0, _utils.replaceNumberCharByPath)(urlObj.Path)
|
|
69
58
|
};
|
|
70
59
|
}
|
|
71
|
-
|
|
72
60
|
var rawRumEvent = (0, _utils.extend2Lev)({
|
|
73
61
|
date: error.startTime,
|
|
74
62
|
error: {
|
|
@@ -87,14 +75,11 @@ function processError(error) {
|
|
|
87
75
|
startTime: error.startTime
|
|
88
76
|
};
|
|
89
77
|
}
|
|
90
|
-
|
|
91
78
|
function computeRequestTracingInfo(request) {
|
|
92
79
|
var hasBeenTraced = request.traceId && request.spanId;
|
|
93
|
-
|
|
94
80
|
if (!hasBeenTraced) {
|
|
95
81
|
return undefined;
|
|
96
82
|
}
|
|
97
|
-
|
|
98
83
|
return {
|
|
99
84
|
_dd: {
|
|
100
85
|
spanId: request.spanId,
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startInternalContext = startInternalContext;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Internal context keep returning v1 format
|
|
10
9
|
* to not break compatibility with logs data format
|
|
@@ -13,7 +12,6 @@ function startInternalContext(applicationId, session, parentContexts) {
|
|
|
13
12
|
return {
|
|
14
13
|
get: function get(startTime) {
|
|
15
14
|
var viewContext = parentContexts.findView(startTime);
|
|
16
|
-
|
|
17
15
|
if (session.isTracked() && viewContext) {
|
|
18
16
|
var actionContext = parentContexts.findAction(startTime);
|
|
19
17
|
return {
|
|
@@ -3,80 +3,62 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.rewritePage = rewritePage;
|
|
7
6
|
exports.THROTTLE_VIEW_UPDATE_PERIOD = void 0;
|
|
8
|
-
|
|
7
|
+
exports.rewritePage = rewritePage;
|
|
9
8
|
var _utils = require("../../helper/utils");
|
|
10
|
-
|
|
11
9
|
var _trackEventCounts2 = require("../trackEventCounts");
|
|
12
|
-
|
|
13
10
|
var _lifeCycle = require("../../core/lifeCycle");
|
|
14
|
-
|
|
15
11
|
// 劫持原小程序App方法
|
|
16
|
-
var THROTTLE_VIEW_UPDATE_PERIOD = 3000;
|
|
17
|
-
exports.THROTTLE_VIEW_UPDATE_PERIOD = THROTTLE_VIEW_UPDATE_PERIOD;
|
|
18
|
-
|
|
12
|
+
var THROTTLE_VIEW_UPDATE_PERIOD = exports.THROTTLE_VIEW_UPDATE_PERIOD = 3000;
|
|
19
13
|
function proxyPage(pageOptions, lifeCycle) {
|
|
20
14
|
// 合并方法,插入记录脚本
|
|
21
15
|
var currentView,
|
|
22
|
-
|
|
16
|
+
startTime = (0, _utils.now)();
|
|
23
17
|
['onReady', 'onShow', 'onLoad', 'onUnload', 'onHide'].forEach(function (methodName) {
|
|
24
18
|
var userDefinedMethod = pageOptions[methodName];
|
|
25
|
-
|
|
26
19
|
pageOptions[methodName] = function () {
|
|
27
20
|
var mpType = this.mpType || this.$vm.mpType;
|
|
28
|
-
|
|
29
21
|
if (mpType !== 'page') {
|
|
30
22
|
return userDefinedMethod && userDefinedMethod.apply(this, arguments);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
}
|
|
24
|
+
// 只处理page类型
|
|
34
25
|
if (methodName === 'onShow' || methodName === 'onLoad') {
|
|
35
26
|
if (typeof currentView === 'undefined') {
|
|
36
27
|
var activePage = (0, _utils.getActivePage)();
|
|
37
28
|
currentView = newView(lifeCycle, activePage && activePage.route, startTime);
|
|
38
29
|
}
|
|
39
30
|
}
|
|
40
|
-
|
|
41
31
|
currentView && currentView.setLoadEventEnd(methodName);
|
|
42
|
-
|
|
43
32
|
if ((methodName === 'onUnload' || methodName === 'onHide' || methodName === 'onShow') && currentView) {
|
|
44
33
|
currentView.triggerUpdate();
|
|
45
|
-
|
|
46
34
|
if (methodName === 'onUnload' || methodName === 'onHide') {
|
|
47
35
|
currentView.end();
|
|
48
36
|
currentView = undefined;
|
|
49
37
|
}
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
return userDefinedMethod && userDefinedMethod.apply(this, arguments);
|
|
53
40
|
};
|
|
54
41
|
});
|
|
55
42
|
}
|
|
56
|
-
|
|
57
43
|
function rewritePage(configuration, lifeCycle, Vue) {
|
|
58
44
|
if (Vue && Vue.extend) {
|
|
59
45
|
var originVueExtend = Vue.extend;
|
|
60
|
-
|
|
61
46
|
Vue.extend = function (vueOptions) {
|
|
62
47
|
proxyPage(vueOptions, lifeCycle);
|
|
63
48
|
return originVueExtend.call(this, vueOptions);
|
|
64
49
|
};
|
|
65
50
|
} else {
|
|
66
51
|
var originComponent = Component;
|
|
67
|
-
|
|
68
52
|
Component = function Component(pageOptions) {
|
|
69
53
|
proxyPage(pageOptions.methods, lifeCycle);
|
|
70
54
|
return originComponent.call(this, pageOptions);
|
|
71
55
|
};
|
|
72
56
|
}
|
|
73
57
|
}
|
|
74
|
-
|
|
75
58
|
function newView(lifeCycle, route, startTime) {
|
|
76
59
|
if (typeof startTime === 'undefined' || Number(startTime) === 0) {
|
|
77
60
|
startTime = (0, _utils.now)();
|
|
78
61
|
}
|
|
79
|
-
|
|
80
62
|
var id = (0, _utils.UUID)();
|
|
81
63
|
var isActive = true;
|
|
82
64
|
var eventCounts = {
|
|
@@ -104,21 +86,16 @@ function newView(lifeCycle, route, startTime) {
|
|
|
104
86
|
});
|
|
105
87
|
var scheduleViewUpdate = scheduleViewThrottled.throttled;
|
|
106
88
|
var cancelScheduleViewUpdate = scheduleViewThrottled.cancel;
|
|
107
|
-
|
|
108
89
|
var _trackEventCounts = (0, _trackEventCounts2.trackEventCounts)(lifeCycle, function (newEventCounts) {
|
|
109
90
|
eventCounts = newEventCounts;
|
|
110
91
|
scheduleViewUpdate();
|
|
111
92
|
});
|
|
112
|
-
|
|
113
93
|
var stopEventCountsTracking = _trackEventCounts.stop;
|
|
114
|
-
|
|
115
94
|
var _trackFptTime = trackFptTime(lifeCycle, function (duration) {
|
|
116
95
|
fpt = duration;
|
|
117
96
|
scheduleViewUpdate();
|
|
118
97
|
});
|
|
119
|
-
|
|
120
98
|
var stopFptTracking = _trackFptTime.stop;
|
|
121
|
-
|
|
122
99
|
var _trackSetDataTime = trackSetDataTime(lifeCycle, function (duration) {
|
|
123
100
|
if ((0, _utils.isNumber)(duration)) {
|
|
124
101
|
setdataDuration += duration;
|
|
@@ -126,25 +103,20 @@ function newView(lifeCycle, route, startTime) {
|
|
|
126
103
|
scheduleViewUpdate();
|
|
127
104
|
}
|
|
128
105
|
});
|
|
129
|
-
|
|
130
106
|
var stopSetDataTracking = _trackSetDataTime.stop;
|
|
131
|
-
|
|
132
107
|
var _trackLoadingTime = trackLoadingTime(lifeCycle, function (duration) {
|
|
133
108
|
if ((0, _utils.isNumber)(duration)) {
|
|
134
109
|
loadingDuration = duration;
|
|
135
110
|
scheduleViewUpdate();
|
|
136
111
|
}
|
|
137
112
|
});
|
|
138
|
-
|
|
139
113
|
var stopLoadingTimeTracking = _trackLoadingTime.stop;
|
|
140
|
-
|
|
141
114
|
var setLoadEventEnd = function setLoadEventEnd(type) {
|
|
142
115
|
if (type === 'onLoad') {
|
|
143
116
|
loadingTime = (0, _utils.now)();
|
|
144
117
|
loadingDuration = loadingTime - startTime;
|
|
145
118
|
} else if (type === 'onShow') {
|
|
146
119
|
showTime = (0, _utils.now)();
|
|
147
|
-
|
|
148
120
|
if (typeof onload2onshowTime === 'undefined' && typeof loadingTime !== 'undefined') {
|
|
149
121
|
onload2onshowTime = showTime - loadingTime;
|
|
150
122
|
}
|
|
@@ -152,7 +124,6 @@ function newView(lifeCycle, route, startTime) {
|
|
|
152
124
|
if (typeof onshow2onready === 'undefined' && typeof showTime !== 'undefined') {
|
|
153
125
|
onshow2onready = (0, _utils.now)() - showTime;
|
|
154
126
|
}
|
|
155
|
-
|
|
156
127
|
if (typeof fmp === 'undefined') {
|
|
157
128
|
fmp = (0, _utils.now)() - startTime; // 从开发者角度看,小程序首屏渲染完成的标志是首页 Page.onReady 事件触发。
|
|
158
129
|
}
|
|
@@ -160,13 +131,10 @@ function newView(lifeCycle, route, startTime) {
|
|
|
160
131
|
if (typeof showTime !== 'undefined') {
|
|
161
132
|
stayTime = (0, _utils.now)() - showTime;
|
|
162
133
|
}
|
|
163
|
-
|
|
164
134
|
isActive = false;
|
|
165
135
|
}
|
|
166
|
-
|
|
167
136
|
triggerViewUpdate();
|
|
168
137
|
};
|
|
169
|
-
|
|
170
138
|
function triggerViewUpdate() {
|
|
171
139
|
documentVersion += 1;
|
|
172
140
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.VIEW_UPDATED, {
|
|
@@ -187,7 +155,6 @@ function newView(lifeCycle, route, startTime) {
|
|
|
187
155
|
isActive: isActive
|
|
188
156
|
});
|
|
189
157
|
}
|
|
190
|
-
|
|
191
158
|
return {
|
|
192
159
|
scheduleUpdate: scheduleViewUpdate,
|
|
193
160
|
setLoadEventEnd: setLoadEventEnd,
|
|
@@ -207,13 +174,11 @@ function newView(lifeCycle, route, startTime) {
|
|
|
207
174
|
}
|
|
208
175
|
};
|
|
209
176
|
}
|
|
210
|
-
|
|
211
177
|
function trackFptTime(lifeCycle, callback) {
|
|
212
178
|
var subscribe = lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entitys) {
|
|
213
179
|
var firstRenderEntity = entitys.find(function (entity) {
|
|
214
180
|
return entity.entryType === 'render' && entity.name === 'firstRender';
|
|
215
181
|
});
|
|
216
|
-
|
|
217
182
|
if (typeof firstRenderEntity !== 'undefined') {
|
|
218
183
|
callback(firstRenderEntity.duration);
|
|
219
184
|
}
|
|
@@ -222,13 +187,11 @@ function trackFptTime(lifeCycle, callback) {
|
|
|
222
187
|
stop: subscribe.unsubscribe
|
|
223
188
|
};
|
|
224
189
|
}
|
|
225
|
-
|
|
226
190
|
function trackLoadingTime(lifeCycle, callback) {
|
|
227
191
|
var subscribe = lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entitys) {
|
|
228
192
|
var navigationEnity = entitys.find(function (entity) {
|
|
229
193
|
return entity.entryType === 'navigation';
|
|
230
194
|
});
|
|
231
|
-
|
|
232
195
|
if (typeof navigationEnity !== 'undefined') {
|
|
233
196
|
callback(navigationEnity.duration);
|
|
234
197
|
}
|
|
@@ -237,7 +200,6 @@ function trackLoadingTime(lifeCycle, callback) {
|
|
|
237
200
|
stop: subscribe.unsubscribe
|
|
238
201
|
};
|
|
239
202
|
}
|
|
240
|
-
|
|
241
203
|
function trackSetDataTime(lifeCycle, callback) {
|
|
242
204
|
var subscribe = lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.PAGE_SET_DATA_UPDATE, function (data) {
|
|
243
205
|
if (!data) return;
|