@cloudcare/rum-uniapp 2.1.18 → 2.1.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/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 +11 -19
- 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 +32 -145
- package/cjs/helper/utils.js +92 -306
- package/cjs/index.js +0 -1
- package/cjs/main.js +10 -0
- package/cjs/rumEventsCollection/action/actionCollection.js +0 -9
- package/cjs/rumEventsCollection/action/trackActions.js +46 -39
- package/cjs/rumEventsCollection/app/appCollection.js +0 -6
- package/cjs/rumEventsCollection/app/index.js +14 -25
- 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 +19 -49
- 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 +8 -12
- 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 +29 -130
- package/esm/helper/utils.js +27 -125
- package/esm/main.js +4 -0
- package/esm/rumEventsCollection/action/actionCollection.js +0 -4
- package/esm/rumEventsCollection/action/trackActions.js +46 -31
- package/esm/rumEventsCollection/app/appCollection.js +0 -1
- package/esm/rumEventsCollection/app/index.js +12 -17
- 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 +19 -43
- 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 +7 -4
|
@@ -3,80 +3,70 @@
|
|
|
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
|
-
var mpType = this.mpType || this.$vm.mpType;
|
|
28
|
-
|
|
20
|
+
var mpType = this.mpType || this.$vm && this.$vm.mpType;
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
if (Page) {
|
|
52
|
+
var originPage = Page;
|
|
53
|
+
Page = function Page(pageOptions) {
|
|
54
|
+
proxyPage(pageOptions, lifeCycle);
|
|
55
|
+
return originPage.call(this, pageOptions);
|
|
56
|
+
};
|
|
57
|
+
} else {
|
|
58
|
+
var originComponent = Component;
|
|
59
|
+
Component = function Component(pageOptions) {
|
|
60
|
+
proxyPage(pageOptions.methods, lifeCycle);
|
|
61
|
+
return originComponent.call(this, pageOptions);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
72
64
|
}
|
|
73
65
|
}
|
|
74
|
-
|
|
75
66
|
function newView(lifeCycle, route, startTime) {
|
|
76
67
|
if (typeof startTime === 'undefined' || Number(startTime) === 0) {
|
|
77
68
|
startTime = (0, _utils.now)();
|
|
78
69
|
}
|
|
79
|
-
|
|
80
70
|
var id = (0, _utils.UUID)();
|
|
81
71
|
var isActive = true;
|
|
82
72
|
var eventCounts = {
|
|
@@ -104,21 +94,16 @@ function newView(lifeCycle, route, startTime) {
|
|
|
104
94
|
});
|
|
105
95
|
var scheduleViewUpdate = scheduleViewThrottled.throttled;
|
|
106
96
|
var cancelScheduleViewUpdate = scheduleViewThrottled.cancel;
|
|
107
|
-
|
|
108
97
|
var _trackEventCounts = (0, _trackEventCounts2.trackEventCounts)(lifeCycle, function (newEventCounts) {
|
|
109
98
|
eventCounts = newEventCounts;
|
|
110
99
|
scheduleViewUpdate();
|
|
111
100
|
});
|
|
112
|
-
|
|
113
101
|
var stopEventCountsTracking = _trackEventCounts.stop;
|
|
114
|
-
|
|
115
102
|
var _trackFptTime = trackFptTime(lifeCycle, function (duration) {
|
|
116
103
|
fpt = duration;
|
|
117
104
|
scheduleViewUpdate();
|
|
118
105
|
});
|
|
119
|
-
|
|
120
106
|
var stopFptTracking = _trackFptTime.stop;
|
|
121
|
-
|
|
122
107
|
var _trackSetDataTime = trackSetDataTime(lifeCycle, function (duration) {
|
|
123
108
|
if ((0, _utils.isNumber)(duration)) {
|
|
124
109
|
setdataDuration += duration;
|
|
@@ -126,25 +111,20 @@ function newView(lifeCycle, route, startTime) {
|
|
|
126
111
|
scheduleViewUpdate();
|
|
127
112
|
}
|
|
128
113
|
});
|
|
129
|
-
|
|
130
114
|
var stopSetDataTracking = _trackSetDataTime.stop;
|
|
131
|
-
|
|
132
115
|
var _trackLoadingTime = trackLoadingTime(lifeCycle, function (duration) {
|
|
133
116
|
if ((0, _utils.isNumber)(duration)) {
|
|
134
117
|
loadingDuration = duration;
|
|
135
118
|
scheduleViewUpdate();
|
|
136
119
|
}
|
|
137
120
|
});
|
|
138
|
-
|
|
139
121
|
var stopLoadingTimeTracking = _trackLoadingTime.stop;
|
|
140
|
-
|
|
141
122
|
var setLoadEventEnd = function setLoadEventEnd(type) {
|
|
142
123
|
if (type === 'onLoad') {
|
|
143
124
|
loadingTime = (0, _utils.now)();
|
|
144
125
|
loadingDuration = loadingTime - startTime;
|
|
145
126
|
} else if (type === 'onShow') {
|
|
146
127
|
showTime = (0, _utils.now)();
|
|
147
|
-
|
|
148
128
|
if (typeof onload2onshowTime === 'undefined' && typeof loadingTime !== 'undefined') {
|
|
149
129
|
onload2onshowTime = showTime - loadingTime;
|
|
150
130
|
}
|
|
@@ -152,7 +132,6 @@ function newView(lifeCycle, route, startTime) {
|
|
|
152
132
|
if (typeof onshow2onready === 'undefined' && typeof showTime !== 'undefined') {
|
|
153
133
|
onshow2onready = (0, _utils.now)() - showTime;
|
|
154
134
|
}
|
|
155
|
-
|
|
156
135
|
if (typeof fmp === 'undefined') {
|
|
157
136
|
fmp = (0, _utils.now)() - startTime; // 从开发者角度看,小程序首屏渲染完成的标志是首页 Page.onReady 事件触发。
|
|
158
137
|
}
|
|
@@ -160,13 +139,10 @@ function newView(lifeCycle, route, startTime) {
|
|
|
160
139
|
if (typeof showTime !== 'undefined') {
|
|
161
140
|
stayTime = (0, _utils.now)() - showTime;
|
|
162
141
|
}
|
|
163
|
-
|
|
164
142
|
isActive = false;
|
|
165
143
|
}
|
|
166
|
-
|
|
167
144
|
triggerViewUpdate();
|
|
168
145
|
};
|
|
169
|
-
|
|
170
146
|
function triggerViewUpdate() {
|
|
171
147
|
documentVersion += 1;
|
|
172
148
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.VIEW_UPDATED, {
|
|
@@ -187,7 +163,6 @@ function newView(lifeCycle, route, startTime) {
|
|
|
187
163
|
isActive: isActive
|
|
188
164
|
});
|
|
189
165
|
}
|
|
190
|
-
|
|
191
166
|
return {
|
|
192
167
|
scheduleUpdate: scheduleViewUpdate,
|
|
193
168
|
setLoadEventEnd: setLoadEventEnd,
|
|
@@ -207,13 +182,11 @@ function newView(lifeCycle, route, startTime) {
|
|
|
207
182
|
}
|
|
208
183
|
};
|
|
209
184
|
}
|
|
210
|
-
|
|
211
185
|
function trackFptTime(lifeCycle, callback) {
|
|
212
186
|
var subscribe = lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entitys) {
|
|
213
187
|
var firstRenderEntity = entitys.find(function (entity) {
|
|
214
188
|
return entity.entryType === 'render' && entity.name === 'firstRender';
|
|
215
189
|
});
|
|
216
|
-
|
|
217
190
|
if (typeof firstRenderEntity !== 'undefined') {
|
|
218
191
|
callback(firstRenderEntity.duration);
|
|
219
192
|
}
|
|
@@ -222,13 +195,11 @@ function trackFptTime(lifeCycle, callback) {
|
|
|
222
195
|
stop: subscribe.unsubscribe
|
|
223
196
|
};
|
|
224
197
|
}
|
|
225
|
-
|
|
226
198
|
function trackLoadingTime(lifeCycle, callback) {
|
|
227
199
|
var subscribe = lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entitys) {
|
|
228
200
|
var navigationEnity = entitys.find(function (entity) {
|
|
229
201
|
return entity.entryType === 'navigation';
|
|
230
202
|
});
|
|
231
|
-
|
|
232
203
|
if (typeof navigationEnity !== 'undefined') {
|
|
233
204
|
callback(navigationEnity.duration);
|
|
234
205
|
}
|
|
@@ -237,7 +208,6 @@ function trackLoadingTime(lifeCycle, callback) {
|
|
|
237
208
|
stop: subscribe.unsubscribe
|
|
238
209
|
};
|
|
239
210
|
}
|
|
240
|
-
|
|
241
211
|
function trackSetDataTime(lifeCycle, callback) {
|
|
242
212
|
var subscribe = lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.PAGE_SET_DATA_UPDATE, function (data) {
|
|
243
213
|
if (!data) return;
|
|
@@ -4,30 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startViewCollection = startViewCollection;
|
|
7
|
-
|
|
8
7
|
var _index = require("./index");
|
|
9
|
-
|
|
10
8
|
var _enums = require("../../helper/enums");
|
|
11
|
-
|
|
12
9
|
var _utils = require("../../helper/utils");
|
|
13
|
-
|
|
14
10
|
var _lifeCycle = require("../../core/lifeCycle");
|
|
15
|
-
|
|
16
11
|
function startViewCollection(lifeCycle, configuration, Vue) {
|
|
17
12
|
lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.VIEW_UPDATED, function (view) {
|
|
18
13
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processViewUpdate(view));
|
|
19
14
|
});
|
|
20
15
|
return (0, _index.rewritePage)(configuration, lifeCycle, Vue);
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
function processViewUpdate(view) {
|
|
24
18
|
var apdexLevel;
|
|
25
|
-
|
|
26
19
|
if (view.fmp) {
|
|
27
20
|
apdexLevel = parseInt(Number(view.fmp) / 1000);
|
|
28
21
|
apdexLevel = apdexLevel > 9 ? 9 : apdexLevel;
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
var viewEvent = {
|
|
32
24
|
_dd: {
|
|
33
25
|
documentVersion: view.documentVersion
|
|
@@ -3,20 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.VIEW_CONTEXT_TIME_OUT_DELAY = exports.CLEAR_OLD_CONTEXTS_INTERVAL = void 0;
|
|
6
7
|
exports.startParentContexts = startParentContexts;
|
|
7
|
-
exports.CLEAR_OLD_CONTEXTS_INTERVAL = exports.VIEW_CONTEXT_TIME_OUT_DELAY = void 0;
|
|
8
|
-
|
|
9
8
|
var _enums = require("../helper/enums");
|
|
10
|
-
|
|
11
9
|
var _utils = require("../helper/utils");
|
|
12
|
-
|
|
13
10
|
var _lifeCycle = require("../core/lifeCycle");
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
exports.VIEW_CONTEXT_TIME_OUT_DELAY = VIEW_CONTEXT_TIME_OUT_DELAY;
|
|
17
|
-
var CLEAR_OLD_CONTEXTS_INTERVAL = _enums.ONE_MINUTE;
|
|
18
|
-
exports.CLEAR_OLD_CONTEXTS_INTERVAL = CLEAR_OLD_CONTEXTS_INTERVAL;
|
|
19
|
-
|
|
11
|
+
var VIEW_CONTEXT_TIME_OUT_DELAY = exports.VIEW_CONTEXT_TIME_OUT_DELAY = 4 * _enums.ONE_HOUR;
|
|
12
|
+
var CLEAR_OLD_CONTEXTS_INTERVAL = exports.CLEAR_OLD_CONTEXTS_INTERVAL = _enums.ONE_MINUTE;
|
|
20
13
|
function startParentContexts(lifeCycle) {
|
|
21
14
|
var currentView;
|
|
22
15
|
var currentAction;
|
|
@@ -53,7 +46,6 @@ function startParentContexts(lifeCycle) {
|
|
|
53
46
|
startTime: currentAction.startClocks
|
|
54
47
|
});
|
|
55
48
|
}
|
|
56
|
-
|
|
57
49
|
currentAction = undefined;
|
|
58
50
|
});
|
|
59
51
|
lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.AUTO_ACTION_DISCARDED, function () {
|
|
@@ -68,15 +60,12 @@ function startParentContexts(lifeCycle) {
|
|
|
68
60
|
var clearOldContextsInterval = setInterval(function () {
|
|
69
61
|
clearOldContexts(previousViews, VIEW_CONTEXT_TIME_OUT_DELAY);
|
|
70
62
|
}, CLEAR_OLD_CONTEXTS_INTERVAL);
|
|
71
|
-
|
|
72
63
|
function clearOldContexts(previousContexts, timeOutDelay) {
|
|
73
64
|
var oldTimeThreshold = (0, _utils.now)() - timeOutDelay;
|
|
74
|
-
|
|
75
65
|
while (previousContexts.length > 0 && previousContexts[previousContexts.length - 1].startTime < oldTimeThreshold) {
|
|
76
66
|
previousContexts.pop();
|
|
77
67
|
}
|
|
78
68
|
}
|
|
79
|
-
|
|
80
69
|
function buildCurrentActionContext() {
|
|
81
70
|
return {
|
|
82
71
|
userAction: {
|
|
@@ -84,7 +73,6 @@ function startParentContexts(lifeCycle) {
|
|
|
84
73
|
}
|
|
85
74
|
};
|
|
86
75
|
}
|
|
87
|
-
|
|
88
76
|
function buildCurrentViewContext() {
|
|
89
77
|
return {
|
|
90
78
|
page: {
|
|
@@ -94,22 +82,18 @@ function startParentContexts(lifeCycle) {
|
|
|
94
82
|
}
|
|
95
83
|
};
|
|
96
84
|
}
|
|
97
|
-
|
|
98
85
|
function findContext(buildContext, previousContexts, currentContext, startTime) {
|
|
99
86
|
if (startTime === undefined) {
|
|
100
87
|
return currentContext ? buildContext() : undefined;
|
|
101
88
|
}
|
|
102
|
-
|
|
103
89
|
if (currentContext && startTime >= currentContext.startTime) {
|
|
104
90
|
return buildContext();
|
|
105
91
|
}
|
|
106
|
-
|
|
107
92
|
var flag = undefined;
|
|
108
93
|
(0, _utils.each)(previousContexts, function (previousContext) {
|
|
109
94
|
if (startTime > previousContext.endTime) {
|
|
110
95
|
return false;
|
|
111
96
|
}
|
|
112
|
-
|
|
113
97
|
if (startTime >= previousContext.startTime) {
|
|
114
98
|
flag = previousContext.context;
|
|
115
99
|
return false;
|
|
@@ -117,7 +101,6 @@ function startParentContexts(lifeCycle) {
|
|
|
117
101
|
});
|
|
118
102
|
return flag;
|
|
119
103
|
}
|
|
120
|
-
|
|
121
104
|
var parentContexts = {
|
|
122
105
|
findView: function findView(startTime) {
|
|
123
106
|
return findContext(buildCurrentViewContext, previousViews, currentView, startTime);
|
|
@@ -4,15 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startPagePerformanceObservable = startPagePerformanceObservable;
|
|
7
|
-
|
|
8
7
|
var _lifeCycle = require("../core/lifeCycle");
|
|
9
|
-
|
|
10
8
|
var _sdk = require("../core/sdk");
|
|
11
|
-
|
|
12
9
|
function startPagePerformanceObservable(lifeCycle, configuration) {
|
|
13
10
|
if (!!_sdk.tracker.getPerformance) {
|
|
14
11
|
var performance = _sdk.tracker.getPerformance();
|
|
15
|
-
|
|
16
12
|
if (!performance || typeof performance.createObserver !== 'function') return;
|
|
17
13
|
var observer = performance.createObserver(function (entryList) {
|
|
18
14
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, entryList.getEntries());
|
|
@@ -4,29 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startRequestCollection = startRequestCollection;
|
|
7
|
-
exports.trackXhr = trackXhr;
|
|
8
7
|
exports.trackDownload = trackDownload;
|
|
9
|
-
|
|
8
|
+
exports.trackXhr = trackXhr;
|
|
10
9
|
var _xhrProxy = require("../core/xhrProxy");
|
|
11
|
-
|
|
12
10
|
var _downloadProxy = require("../core/downloadProxy");
|
|
13
|
-
|
|
14
11
|
var _lifeCycle = require("../core/lifeCycle");
|
|
15
|
-
|
|
16
12
|
var _utils = require("../helper/utils");
|
|
17
|
-
|
|
18
13
|
var _resourceUtils = require("../rumEventsCollection/resource/resourceUtils");
|
|
19
|
-
|
|
20
14
|
var _tracer = require("../rumEventsCollection/tracing/tracer");
|
|
21
|
-
|
|
22
15
|
var nextRequestIndex = 1;
|
|
23
|
-
|
|
24
16
|
function startRequestCollection(lifeCycle, configuration) {
|
|
25
17
|
var tracer = (0, _tracer.startTracer)(configuration);
|
|
26
18
|
trackXhr(lifeCycle, configuration, tracer);
|
|
27
19
|
trackDownload(lifeCycle, configuration);
|
|
28
20
|
}
|
|
29
|
-
|
|
30
21
|
function parseHeader(header) {
|
|
31
22
|
// 大小写兼容
|
|
32
23
|
if (!(0, _utils.isObject)(header)) return header;
|
|
@@ -36,7 +27,6 @@ function parseHeader(header) {
|
|
|
36
27
|
});
|
|
37
28
|
return res;
|
|
38
29
|
}
|
|
39
|
-
|
|
40
30
|
function getHeaderString(header) {
|
|
41
31
|
if (!(0, _utils.isObject)(header)) return header;
|
|
42
32
|
var headerStr = '';
|
|
@@ -45,7 +35,6 @@ function getHeaderString(header) {
|
|
|
45
35
|
});
|
|
46
36
|
return headerStr;
|
|
47
37
|
}
|
|
48
|
-
|
|
49
38
|
function trackXhr(lifeCycle, configuration, tracer) {
|
|
50
39
|
var xhrProxy = (0, _xhrProxy.startXhrProxy)(configuration);
|
|
51
40
|
xhrProxy.beforeSend(function (context) {
|
|
@@ -77,7 +66,6 @@ function trackXhr(lifeCycle, configuration, tracer) {
|
|
|
77
66
|
});
|
|
78
67
|
return xhrProxy;
|
|
79
68
|
}
|
|
80
|
-
|
|
81
69
|
function trackDownload(lifeCycle, configuration) {
|
|
82
70
|
var dwonloadProxy = (0, _downloadProxy.startDownloadProxy)(configuration);
|
|
83
71
|
dwonloadProxy.beforeSend(function (context) {
|
|
@@ -105,7 +93,6 @@ function trackDownload(lifeCycle, configuration) {
|
|
|
105
93
|
});
|
|
106
94
|
return dwonloadProxy;
|
|
107
95
|
}
|
|
108
|
-
|
|
109
96
|
function getNextRequestIndex() {
|
|
110
97
|
var result = nextRequestIndex;
|
|
111
98
|
nextRequestIndex += 1;
|
|
@@ -4,23 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startResourceCollection = startResourceCollection;
|
|
7
|
-
|
|
8
7
|
var _resourceUtils = require("./resourceUtils");
|
|
9
|
-
|
|
10
8
|
var _lifeCycle = require("../../core/lifeCycle");
|
|
11
|
-
|
|
12
9
|
var _utils = require("../../helper/utils");
|
|
13
|
-
|
|
14
10
|
var _jsonStringify = require("../../helper/jsonStringify");
|
|
15
|
-
|
|
16
11
|
var _enums = require("../../helper/enums");
|
|
17
|
-
|
|
18
12
|
function startResourceCollection(lifeCycle, configuration) {
|
|
19
13
|
lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.REQUEST_COMPLETED, function (request) {
|
|
20
14
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processRequest(request));
|
|
21
15
|
});
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
function processRequest(request) {
|
|
25
18
|
var type = request.type;
|
|
26
19
|
var timing = request.performance;
|
|
@@ -49,14 +42,11 @@ function processRequest(request) {
|
|
|
49
42
|
rawRumEvent: resourceEvent
|
|
50
43
|
};
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
function computeRequestTracingInfo(request) {
|
|
54
46
|
var hasBeenTraced = request.traceId && request.spanId;
|
|
55
|
-
|
|
56
47
|
if (!hasBeenTraced) {
|
|
57
48
|
return undefined;
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
return {
|
|
61
51
|
_dd: {
|
|
62
52
|
spanId: request.spanId,
|
|
@@ -67,7 +57,6 @@ function computeRequestTracingInfo(request) {
|
|
|
67
57
|
}
|
|
68
58
|
};
|
|
69
59
|
}
|
|
70
|
-
|
|
71
60
|
function computePerformanceEntryMetrics(timing) {
|
|
72
61
|
return {
|
|
73
62
|
resource: (0, _utils.extend2Lev)({}, {
|
|
@@ -3,34 +3,30 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.computePerformanceResourceDuration = computePerformanceResourceDuration;
|
|
7
6
|
exports.computePerformanceResourceDetails = computePerformanceResourceDetails;
|
|
8
|
-
exports.
|
|
7
|
+
exports.computePerformanceResourceDuration = computePerformanceResourceDuration;
|
|
9
8
|
exports.computeSize = computeSize;
|
|
10
9
|
exports.isAllowedRequestUrl = isAllowedRequestUrl;
|
|
11
|
-
|
|
10
|
+
exports.toValidEntry = toValidEntry;
|
|
12
11
|
var _utils = require("../../helper/utils");
|
|
13
|
-
|
|
14
12
|
var _configuration = require("../../core/configuration");
|
|
15
|
-
|
|
16
13
|
function areInOrder() {
|
|
17
14
|
var numbers = (0, _utils.toArray)(arguments);
|
|
18
|
-
|
|
19
15
|
for (var i = 1; i < numbers.length; i += 1) {
|
|
20
16
|
if (numbers[i - 1] > numbers[i]) {
|
|
21
17
|
return false;
|
|
22
18
|
}
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
return true;
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
function computePerformanceResourceDuration(entry) {
|
|
29
23
|
// Safari duration is always 0 on timings blocked by cross origin policies.
|
|
30
24
|
if (entry.startTime < entry.responseEnd) {
|
|
31
25
|
return (0, _utils.msToNs)(entry.responseEnd - entry.startTime);
|
|
32
26
|
}
|
|
33
|
-
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// interface PerformanceResourceDetails {
|
|
34
30
|
// redirect?: PerformanceResourceDetailsElement
|
|
35
31
|
// dns?: PerformanceResourceDetailsElement
|
|
36
32
|
// connect?: PerformanceResourceDetailsElement
|
|
@@ -52,75 +48,90 @@ function computePerformanceResourceDuration(entry) {
|
|
|
52
48
|
// page_trans float 内容传输时间 responseEnd - responseStart
|
|
53
49
|
// page_dom float DOM解析耗时 domInteractive - responseEnd
|
|
54
50
|
// page_resource_load_time float 资源加载时间 loadEventStart - domContentLoadedEventEnd
|
|
51
|
+
|
|
55
52
|
// navigationStart:当前浏览器窗口的前一个网页关闭,发生unload事件时的Unix毫秒时间戳。如果没有前一个网页,则等于fetchStart属性。
|
|
53
|
+
|
|
56
54
|
// · unloadEventStart:如果前一个网页与当前网页属于同一个域名,则返回前一个网页的unload事件发生时的Unix毫秒时间戳。如果没有前一个网页,或者之前的网页跳转不是在同一个域名内,则返回值为0。
|
|
55
|
+
|
|
57
56
|
// · unloadEventEnd:如果前一个网页与当前网页属于同一个域名,则返回前一个网页unload事件的回调函数结束时的Unix毫秒时间戳。如果没有前一个网页,或者之前的网页跳转不是在同一个域名内,则返回值为0。
|
|
57
|
+
|
|
58
58
|
// · redirectStart:返回第一个HTTP跳转开始时的Unix毫秒时间戳。如果没有跳转,或者不是同一个域名内部的跳转,则返回值为0。
|
|
59
|
+
|
|
59
60
|
// · redirectEnd:返回最后一个HTTP跳转结束时(即跳转回应的最后一个字节接受完成时)的Unix毫秒时间戳。如果没有跳转,或者不是同一个域名内部的跳转,则返回值为0。
|
|
61
|
+
|
|
60
62
|
// · fetchStart:返回浏览器准备使用HTTP请求读取文档时的Unix毫秒时间戳。该事件在网页查询本地缓存之前发生。
|
|
63
|
+
|
|
61
64
|
// · domainLookupStart:返回域名查询开始时的Unix毫秒时间戳。如果使用持久连接,或者信息是从本地缓存获取的,则返回值等同于fetchStart属性的值。
|
|
65
|
+
|
|
62
66
|
// · domainLookupEnd:返回域名查询结束时的Unix毫秒时间戳。如果使用持久连接,或者信息是从本地缓存获取的,则返回值等同于fetchStart属性的值。
|
|
67
|
+
|
|
63
68
|
// · connectStart:返回HTTP请求开始向服务器发送时的Unix毫秒时间戳。如果使用持久连接(persistent connection),则返回值等同于fetchStart属性的值。
|
|
69
|
+
|
|
64
70
|
// · connectEnd:返回浏览器与服务器之间的连接建立时的Unix毫秒时间戳。如果建立的是持久连接,则返回值等同于fetchStart属性的值。连接建立指的是所有握手和认证过程全部结束。
|
|
71
|
+
|
|
65
72
|
// · secureConnectionStart:返回浏览器与服务器开始安全链接的握手时的Unix毫秒时间戳。如果当前网页不要求安全连接,则返回0。
|
|
73
|
+
|
|
66
74
|
// · requestStart:返回浏览器向服务器发出HTTP请求时(或开始读取本地缓存时)的Unix毫秒时间戳。
|
|
75
|
+
|
|
67
76
|
// · responseStart:返回浏览器从服务器收到(或从本地缓存读取)第一个字节时的Unix毫秒时间戳。
|
|
77
|
+
|
|
68
78
|
// · responseEnd:返回浏览器从服务器收到(或从本地缓存读取)最后一个字节时(如果在此之前HTTP连接已经关闭,则返回关闭时)的Unix毫秒时间戳。
|
|
79
|
+
|
|
69
80
|
// · domLoading:返回当前网页DOM结构开始解析时(即Document.readyState属性变为“loading”、相应的readystatechange事件触发时)的Unix毫秒时间戳。
|
|
81
|
+
|
|
70
82
|
// · domInteractive:返回当前网页DOM结构结束解析、开始加载内嵌资源时(即Document.readyState属性变为“interactive”、相应的readystatechange事件触发时)的Unix毫秒时间戳。
|
|
83
|
+
|
|
71
84
|
// · domContentLoadedEventStart:返回当前网页DOMContentLoaded事件发生时(即DOM结构解析完毕、所有脚本开始运行时)的Unix毫秒时间戳。
|
|
85
|
+
|
|
72
86
|
// · domContentLoadedEventEnd:返回当前网页所有需要执行的脚本执行完成时的Unix毫秒时间戳。
|
|
87
|
+
|
|
73
88
|
// · domComplete:返回当前网页DOM结构生成时(即Document.readyState属性变为“complete”,以及相应的readystatechange事件发生时)的Unix毫秒时间戳。
|
|
74
|
-
// · loadEventStart:返回当前网页load事件的回调函数开始时的Unix毫秒时间戳。如果该事件还没有发生,返回0。
|
|
75
|
-
// · loadEventEnd:返回当前网页load事件的回调函数运行结束时的Unix毫秒时间戳。如果该事件还没有发生,返回0
|
|
76
89
|
|
|
90
|
+
// · loadEventStart:返回当前网页load事件的回调函数开始时的Unix毫秒时间戳。如果该事件还没有发生,返回0。
|
|
77
91
|
|
|
92
|
+
// · loadEventEnd:返回当前网页load事件的回调函数运行结束时的Unix毫秒时间戳。如果该事件还没有发生,返回0
|
|
78
93
|
function computePerformanceResourceDetails(entry) {
|
|
79
94
|
var validEntry = toValidEntry(entry);
|
|
80
|
-
|
|
81
95
|
if (!validEntry) {
|
|
82
96
|
return undefined;
|
|
83
97
|
}
|
|
84
|
-
|
|
85
98
|
var startTime = validEntry.startTime,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
fetchStart = validEntry.fetchStart,
|
|
100
|
+
redirectStart = validEntry.redirectStart,
|
|
101
|
+
redirectEnd = validEntry.redirectEnd,
|
|
102
|
+
domainLookupStart = validEntry.domainLookupStart || validEntry.domainLookUpStart,
|
|
103
|
+
domainLookupEnd = validEntry.domainLookupEnd || validEntry.domainLookUpEnd,
|
|
104
|
+
connectStart = validEntry.connectStart,
|
|
105
|
+
SSLconnectionStart = validEntry.SSLconnectionStart,
|
|
106
|
+
SSLconnectionEnd = validEntry.SSLconnectionEnd,
|
|
107
|
+
connectEnd = validEntry.connectEnd,
|
|
108
|
+
requestStart = validEntry.requestStart,
|
|
109
|
+
responseStart = validEntry.responseStart,
|
|
110
|
+
responseEnd = validEntry.responseEnd;
|
|
98
111
|
var details = {
|
|
99
112
|
firstbyte: formatTiming(startTime, domainLookupStart, responseStart),
|
|
100
113
|
trans: formatTiming(startTime, responseStart, responseEnd),
|
|
101
114
|
ttfb: formatTiming(startTime, requestStart, responseStart)
|
|
102
|
-
};
|
|
103
|
-
|
|
115
|
+
};
|
|
116
|
+
// Make sure a connection occurred
|
|
104
117
|
if (connectEnd !== fetchStart) {
|
|
105
|
-
details.tcp = formatTiming(startTime, connectStart, connectEnd);
|
|
118
|
+
details.tcp = formatTiming(startTime, connectStart, connectEnd);
|
|
106
119
|
|
|
120
|
+
// Make sure a secure connection occurred
|
|
107
121
|
if (areInOrder(connectStart, SSLconnectionStart, SSLconnectionEnd)) {
|
|
108
122
|
details.ssl = formatTiming(startTime, SSLconnectionStart, SSLconnectionEnd);
|
|
109
123
|
}
|
|
110
|
-
}
|
|
111
|
-
|
|
124
|
+
}
|
|
112
125
|
|
|
126
|
+
// Make sure a domain lookup occurred
|
|
113
127
|
if (domainLookupEnd !== fetchStart) {
|
|
114
128
|
details.dns = formatTiming(startTime, domainLookupStart, domainLookupEnd);
|
|
115
129
|
}
|
|
116
|
-
|
|
117
130
|
if (hasRedirection(entry)) {
|
|
118
131
|
details.redirect = formatTiming(startTime, redirectStart, redirectEnd);
|
|
119
132
|
}
|
|
120
|
-
|
|
121
133
|
return details;
|
|
122
134
|
}
|
|
123
|
-
|
|
124
135
|
function toValidEntry(entry) {
|
|
125
136
|
// Ensure timings are in the right order. On top of filtering out potential invalid
|
|
126
137
|
// RumPerformanceResourceTiming, it will ignore entries from requests where timings cannot be
|
|
@@ -142,32 +153,29 @@ function toValidEntry(entry) {
|
|
|
142
153
|
if (!areInOrder(entry.startTime, entry.fetchStart, entry.domainLookupStart, entry.domainLookupEnd, entry.connectStart, entry.connectEnd, entry.requestStart, entry.responseStart, entry.responseEnd)) {
|
|
143
154
|
return undefined;
|
|
144
155
|
}
|
|
145
|
-
|
|
146
156
|
if (!hasRedirection(entry)) {
|
|
147
157
|
return entry;
|
|
148
158
|
}
|
|
149
|
-
|
|
150
159
|
var redirectStart = entry.redirectStart;
|
|
151
|
-
var redirectEnd = entry.redirectEnd;
|
|
160
|
+
var redirectEnd = entry.redirectEnd;
|
|
161
|
+
// Firefox doesn't provide redirect timings on cross origin requests.
|
|
152
162
|
// Provide a default for those.
|
|
153
|
-
|
|
154
163
|
if (redirectStart < entry.startTime) {
|
|
155
164
|
redirectStart = entry.startTime;
|
|
156
165
|
}
|
|
157
|
-
|
|
158
166
|
if (redirectEnd < entry.startTime) {
|
|
159
167
|
redirectEnd = entry.fetchStart;
|
|
160
|
-
}
|
|
161
|
-
|
|
168
|
+
}
|
|
162
169
|
|
|
170
|
+
// Make sure redirect timings are in order
|
|
163
171
|
if (!areInOrder(entry.startTime, redirectStart, redirectEnd, entry.fetchStart)) {
|
|
164
172
|
return undefined;
|
|
165
173
|
}
|
|
166
|
-
|
|
167
174
|
return (0, _utils.extend)({}, entry, {
|
|
168
175
|
redirectEnd: redirectEnd,
|
|
169
176
|
redirectStart: redirectStart
|
|
170
|
-
});
|
|
177
|
+
});
|
|
178
|
+
// return {
|
|
171
179
|
// ...entry,
|
|
172
180
|
// redirectEnd,
|
|
173
181
|
// redirectStart
|
|
@@ -178,20 +186,16 @@ function hasRedirection(entry) {
|
|
|
178
186
|
// The only time fetchStart is different than startTime is if a redirection occurred.
|
|
179
187
|
return entry.fetchStart !== entry.startTime;
|
|
180
188
|
}
|
|
181
|
-
|
|
182
189
|
function formatTiming(origin, start, end) {
|
|
183
190
|
return (0, _utils.msToNs)(end - start);
|
|
184
191
|
}
|
|
185
|
-
|
|
186
192
|
function computeSize(entry) {
|
|
187
193
|
// Make sure a request actually occurred
|
|
188
194
|
if (entry.startTime < entry.responseStart) {
|
|
189
195
|
return entry.receivedBytedCount;
|
|
190
196
|
}
|
|
191
|
-
|
|
192
197
|
return undefined;
|
|
193
198
|
}
|
|
194
|
-
|
|
195
199
|
function isAllowedRequestUrl(configuration, url) {
|
|
196
200
|
return url && !(0, _configuration.isIntakeRequest)(url, configuration);
|
|
197
201
|
}
|