@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
|
@@ -4,37 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startSetDataColloction = startSetDataColloction;
|
|
7
|
-
|
|
8
7
|
var _lifeCycle = require("../core/lifeCycle");
|
|
9
|
-
|
|
10
8
|
var _utils = require("../helper/utils");
|
|
11
|
-
|
|
12
9
|
var _sdk = require("../core/sdk");
|
|
13
|
-
|
|
14
10
|
function resetSetData(data, callback, lifeCycle, mpInstance) {
|
|
15
11
|
var pendingStartTimestamp = (0, _utils.now)();
|
|
16
|
-
|
|
17
12
|
var _callback = function _callback() {
|
|
18
13
|
lifeCycle.notify(_lifeCycle.LifeCycleEventType.PAGE_SET_DATA_UPDATE, {
|
|
19
14
|
pendingStartTimestamp: pendingStartTimestamp,
|
|
20
15
|
updateEndTimestamp: (0, _utils.now)()
|
|
21
16
|
});
|
|
22
|
-
|
|
23
17
|
if (typeof callback === 'function') {
|
|
24
18
|
callback.call(mpInstance);
|
|
25
19
|
}
|
|
26
20
|
};
|
|
27
|
-
|
|
28
21
|
return _callback;
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
function proxyPage(pageOptions, lifeCycle) {
|
|
32
24
|
var userDefinedMethod = pageOptions['onLoad'];
|
|
33
|
-
|
|
34
25
|
pageOptions['onLoad'] = function () {
|
|
35
26
|
var mpInstance = this.$scope;
|
|
36
27
|
var setData = mpInstance.setData;
|
|
37
|
-
|
|
38
28
|
if (typeof setData === 'function') {
|
|
39
29
|
try {
|
|
40
30
|
// 这里暂时这么处理 只读属性 会抛出错误
|
|
@@ -51,15 +41,12 @@ function proxyPage(pageOptions, lifeCycle) {
|
|
|
51
41
|
});
|
|
52
42
|
}
|
|
53
43
|
}
|
|
54
|
-
|
|
55
44
|
return userDefinedMethod && userDefinedMethod.apply(this, arguments);
|
|
56
45
|
};
|
|
57
46
|
}
|
|
58
|
-
|
|
59
47
|
function startSetDataColloction(lifeCycle, Vue) {
|
|
60
48
|
if (Vue && Vue.extend) {
|
|
61
49
|
var originVueExtend = Vue.extend;
|
|
62
|
-
|
|
63
50
|
Vue.extend = function (vueOptions) {
|
|
64
51
|
proxyPage(vueOptions, lifeCycle);
|
|
65
52
|
return originVueExtend.call(this, vueOptions);
|
|
@@ -67,14 +54,11 @@ function startSetDataColloction(lifeCycle, Vue) {
|
|
|
67
54
|
} else {
|
|
68
55
|
if (!_sdk.tracker) return;
|
|
69
56
|
var originCreatePage = _sdk.tracker.createPage;
|
|
70
|
-
|
|
71
57
|
_sdk.tracker.createPage = function (pageOptions) {
|
|
72
58
|
proxyPage(pageOptions, lifeCycle);
|
|
73
59
|
return originCreatePage.call(this, pageOptions);
|
|
74
60
|
};
|
|
75
|
-
|
|
76
61
|
var originCreateComponent = _sdk.tracker.createComponent;
|
|
77
|
-
|
|
78
62
|
_sdk.tracker.createComponent = function (component) {
|
|
79
63
|
proxyPage(component, lifeCycle);
|
|
80
64
|
return originCreateComponent.call(this, component);
|
|
@@ -4,30 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DDtraceTracer = DDtraceTracer;
|
|
7
|
-
|
|
8
7
|
// === Generate a random 64-bit number in fixed-length hex format
|
|
9
8
|
function randomTraceId() {
|
|
10
9
|
var digits = '0123456789abcdef';
|
|
11
10
|
var n = '';
|
|
12
|
-
|
|
13
11
|
for (var i = 0; i < 19; i += 1) {
|
|
14
12
|
var rand = Math.floor(Math.random() * 10);
|
|
15
13
|
n += digits[rand];
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
return n;
|
|
19
16
|
}
|
|
20
17
|
/**
|
|
21
18
|
*
|
|
22
19
|
* @param {*} configuration 配置信息
|
|
23
20
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
21
|
function DDtraceTracer(configuration) {
|
|
27
22
|
this._spanId = randomTraceId();
|
|
28
23
|
this._traceId = randomTraceId();
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
DDtraceTracer.prototype = {
|
|
32
26
|
isTracingSupported: function isTracingSupported() {
|
|
33
27
|
return true;
|
|
@@ -4,38 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.JaegerTracer = JaegerTracer;
|
|
7
|
-
|
|
8
7
|
// === Generate a random 64-bit number in fixed-length hex format
|
|
9
8
|
function randomTraceId() {
|
|
10
9
|
var digits = '0123456789abcdef';
|
|
11
10
|
var n = '';
|
|
12
|
-
|
|
13
11
|
for (var i = 0; i < 16; i += 1) {
|
|
14
12
|
var rand = Math.floor(Math.random() * 16);
|
|
15
13
|
n += digits[rand];
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
return n;
|
|
19
16
|
}
|
|
17
|
+
|
|
20
18
|
/**
|
|
21
19
|
*
|
|
22
20
|
* @param {*} configuration 配置信息
|
|
23
21
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
22
|
function JaegerTracer(configuration) {
|
|
27
|
-
var rootSpanId = randomTraceId();
|
|
28
|
-
|
|
23
|
+
var rootSpanId = randomTraceId();
|
|
24
|
+
// this._traceId = randomTraceId() + rootSpanId // 默认用128bit,兼容其他配置
|
|
29
25
|
if (configuration.traceId128Bit) {
|
|
30
26
|
// 128bit生成traceid
|
|
31
27
|
this._traceId = randomTraceId() + rootSpanId;
|
|
32
28
|
} else {
|
|
33
29
|
this._traceId = rootSpanId;
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
this._spanId = rootSpanId;
|
|
37
32
|
}
|
|
38
|
-
|
|
39
33
|
JaegerTracer.prototype = {
|
|
40
34
|
isTracingSupported: function isTracingSupported() {
|
|
41
35
|
return true;
|
|
@@ -4,27 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SkyWalkingTracer = SkyWalkingTracer;
|
|
7
|
-
|
|
8
7
|
var _utils = require("../../helper/utils");
|
|
9
|
-
|
|
10
8
|
// start SkyWalking
|
|
11
9
|
function uuid() {
|
|
12
10
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
13
11
|
/* tslint:disable */
|
|
14
12
|
var r = Math.random() * 16 | 0;
|
|
15
13
|
/* tslint:disable */
|
|
16
|
-
|
|
17
14
|
var v = c === 'x' ? r : r & 0x3 | 0x8;
|
|
18
15
|
return v.toString(16);
|
|
19
16
|
});
|
|
20
17
|
}
|
|
18
|
+
|
|
21
19
|
/**
|
|
22
20
|
*
|
|
23
21
|
* @param {*} configuration 配置信息
|
|
24
22
|
* @param {*} requestUrl 请求的url
|
|
25
23
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
24
|
function SkyWalkingTracer(configuration, requestUrl) {
|
|
29
25
|
this._spanId = uuid();
|
|
30
26
|
this._traceId = uuid();
|
|
@@ -33,7 +29,6 @@ function SkyWalkingTracer(configuration, requestUrl) {
|
|
|
33
29
|
this._version = configuration.version;
|
|
34
30
|
this._urlParse = (0, _utils.urlParse)(requestUrl).getParse();
|
|
35
31
|
}
|
|
36
|
-
|
|
37
32
|
SkyWalkingTracer.prototype = {
|
|
38
33
|
isTracingSupported: function isTracingSupported() {
|
|
39
34
|
if (this._env && this._version && this._urlParse) return true;
|
|
@@ -53,15 +48,13 @@ SkyWalkingTracer.prototype = {
|
|
|
53
48
|
var instance = String((0, _utils.base64Encode)(this._version));
|
|
54
49
|
var activePage = (0, _utils.getActivePage)();
|
|
55
50
|
var endpointPage = '';
|
|
56
|
-
|
|
57
51
|
if (activePage && activePage.route) {
|
|
58
52
|
endpointPage = activePage.route;
|
|
59
53
|
}
|
|
60
|
-
|
|
61
54
|
var endpoint = String((0, _utils.base64Encode)(endpointPage));
|
|
62
55
|
var peer = String((0, _utils.base64Encode)(this._urlParse.Host));
|
|
63
|
-
var index = '0';
|
|
64
|
-
|
|
56
|
+
var index = '0';
|
|
57
|
+
// var values = `${1}-${traceIdStr}-${segmentId}-${index}-${service}-${instance}-${endpoint}-${peer}`;
|
|
65
58
|
return '1-' + traceIdStr + '-' + segmentId + '-' + index + '-' + service + '-' + instance + '-' + endpoint + '-' + peer;
|
|
66
59
|
} catch (err) {
|
|
67
60
|
return '';
|
|
@@ -4,32 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.clearTracingIfCancelled = clearTracingIfCancelled;
|
|
7
|
-
exports.startTracer = startTracer;
|
|
8
7
|
exports.injectHeadersIfTracingAllowed = injectHeadersIfTracingAllowed;
|
|
9
|
-
|
|
8
|
+
exports.startTracer = startTracer;
|
|
10
9
|
var _utils = require("../../helper/utils");
|
|
11
|
-
|
|
12
10
|
var _enums = require("../../helper/enums");
|
|
13
|
-
|
|
14
11
|
var _ddtraceTracer = require("./ddtraceTracer");
|
|
15
|
-
|
|
16
12
|
var _skywalkingTracer = require("./skywalkingTracer");
|
|
17
|
-
|
|
18
13
|
var _jaegerTracer = require("./jaegerTracer");
|
|
19
|
-
|
|
20
14
|
var _zipkinSingleTracer = require("./zipkinSingleTracer");
|
|
21
|
-
|
|
22
15
|
var _zipkinMultiTracer = require("./zipkinMultiTracer");
|
|
23
|
-
|
|
24
16
|
var _w3cTraceParentTracer = require("./w3cTraceParentTracer");
|
|
25
|
-
|
|
26
17
|
function clearTracingIfCancelled(context) {
|
|
27
18
|
if (context.status === 0) {
|
|
28
19
|
context.traceId = undefined;
|
|
29
20
|
context.spanId = undefined;
|
|
30
21
|
}
|
|
31
22
|
}
|
|
32
|
-
|
|
33
23
|
function startTracer(configuration) {
|
|
34
24
|
return {
|
|
35
25
|
clearTracingIfCancelled: clearTracingIfCancelled,
|
|
@@ -37,19 +27,16 @@ function startTracer(configuration) {
|
|
|
37
27
|
return injectHeadersIfTracingAllowed(configuration, context, function (tracingHeaders) {
|
|
38
28
|
context.option = (0, _utils.extend)({}, context.option);
|
|
39
29
|
var header = {};
|
|
40
|
-
|
|
41
30
|
if (context.option.header) {
|
|
42
31
|
(0, _utils.each)(context.option.header, function (value, key) {
|
|
43
32
|
header[key] = value;
|
|
44
33
|
});
|
|
45
34
|
}
|
|
46
|
-
|
|
47
35
|
context.option.header = (0, _utils.extend)(header, tracingHeaders);
|
|
48
36
|
});
|
|
49
37
|
}
|
|
50
38
|
};
|
|
51
39
|
}
|
|
52
|
-
|
|
53
40
|
function isAllowedUrl(configuration, requestUrl) {
|
|
54
41
|
var requestOrigin = (0, _utils.getOrigin)(requestUrl);
|
|
55
42
|
var flag = false;
|
|
@@ -61,47 +48,36 @@ function isAllowedUrl(configuration, requestUrl) {
|
|
|
61
48
|
});
|
|
62
49
|
return flag;
|
|
63
50
|
}
|
|
64
|
-
|
|
65
51
|
function injectHeadersIfTracingAllowed(configuration, context, inject) {
|
|
66
52
|
if (!isAllowedUrl(configuration, context.url) || !configuration.traceType) {
|
|
67
53
|
return;
|
|
68
54
|
}
|
|
69
|
-
|
|
70
55
|
var tracer;
|
|
71
|
-
|
|
72
56
|
switch (configuration.traceType) {
|
|
73
57
|
case _enums.TraceType.DDTRACE:
|
|
74
58
|
tracer = new _ddtraceTracer.DDtraceTracer();
|
|
75
59
|
break;
|
|
76
|
-
|
|
77
60
|
case _enums.TraceType.SKYWALKING_V3:
|
|
78
61
|
tracer = new _skywalkingTracer.SkyWalkingTracer(configuration, context.url);
|
|
79
62
|
break;
|
|
80
|
-
|
|
81
63
|
case _enums.TraceType.ZIPKIN_MULTI_HEADER:
|
|
82
64
|
tracer = new _zipkinMultiTracer.ZipkinMultiTracer(configuration);
|
|
83
65
|
break;
|
|
84
|
-
|
|
85
66
|
case _enums.TraceType.JAEGER:
|
|
86
67
|
tracer = new _jaegerTracer.JaegerTracer(configuration);
|
|
87
68
|
break;
|
|
88
|
-
|
|
89
69
|
case _enums.TraceType.W3C_TRACEPARENT:
|
|
90
70
|
tracer = new _w3cTraceParentTracer.W3cTraceParentTracer(configuration);
|
|
91
71
|
break;
|
|
92
|
-
|
|
93
72
|
case _enums.TraceType.ZIPKIN_SINGLE_HEADER:
|
|
94
73
|
tracer = new _zipkinSingleTracer.ZipkinSingleTracer(configuration);
|
|
95
74
|
break;
|
|
96
|
-
|
|
97
75
|
default:
|
|
98
76
|
break;
|
|
99
77
|
}
|
|
100
|
-
|
|
101
78
|
if (!tracer || !tracer.isTracingSupported()) {
|
|
102
79
|
return;
|
|
103
80
|
}
|
|
104
|
-
|
|
105
81
|
context.traceId = tracer.getTraceId();
|
|
106
82
|
context.spanId = tracer.getSpanId();
|
|
107
83
|
inject(tracer.makeTracingHeaders());
|
|
@@ -4,31 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.W3cTraceParentTracer = W3cTraceParentTracer;
|
|
7
|
-
|
|
8
7
|
// === Generate a random 64-bit number in fixed-length hex format
|
|
9
8
|
function randomTraceId() {
|
|
10
9
|
var digits = '0123456789abcdef';
|
|
11
10
|
var n = '';
|
|
12
|
-
|
|
13
11
|
for (var i = 0; i < 16; i += 1) {
|
|
14
12
|
var rand = Math.floor(Math.random() * 16);
|
|
15
13
|
n += digits[rand];
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
return n;
|
|
19
16
|
}
|
|
17
|
+
|
|
20
18
|
/**
|
|
21
19
|
*
|
|
22
20
|
* @param {*} configuration 配置信息
|
|
23
21
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
22
|
function W3cTraceParentTracer(configuration) {
|
|
27
23
|
var rootSpanId = randomTraceId();
|
|
28
24
|
this._traceId = randomTraceId() + rootSpanId;
|
|
29
25
|
this._spanId = rootSpanId;
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
W3cTraceParentTracer.prototype = {
|
|
33
28
|
isTracingSupported: function isTracingSupported() {
|
|
34
29
|
return true;
|
|
@@ -4,38 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ZipkinMultiTracer = ZipkinMultiTracer;
|
|
7
|
-
|
|
8
7
|
// === Generate a random 64-bit number in fixed-length hex format
|
|
9
8
|
function randomTraceId() {
|
|
10
9
|
var digits = '0123456789abcdef';
|
|
11
10
|
var n = '';
|
|
12
|
-
|
|
13
11
|
for (var i = 0; i < 16; i += 1) {
|
|
14
12
|
var rand = Math.floor(Math.random() * 16);
|
|
15
13
|
n += digits[rand];
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
return n;
|
|
19
16
|
}
|
|
17
|
+
|
|
20
18
|
/**
|
|
21
19
|
*
|
|
22
20
|
* @param {*} configuration 配置信息
|
|
23
21
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
22
|
function ZipkinMultiTracer(configuration) {
|
|
27
23
|
var rootSpanId = randomTraceId();
|
|
28
|
-
|
|
29
24
|
if (configuration.traceId128Bit) {
|
|
30
25
|
// 128bit生成traceid
|
|
31
26
|
this._traceId = randomTraceId() + rootSpanId;
|
|
32
27
|
} else {
|
|
33
28
|
this._traceId = rootSpanId;
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
this._spanId = rootSpanId;
|
|
37
31
|
}
|
|
38
|
-
|
|
39
32
|
ZipkinMultiTracer.prototype = {
|
|
40
33
|
isTracingSupported: function isTracingSupported() {
|
|
41
34
|
return true;
|
|
@@ -51,8 +44,8 @@ ZipkinMultiTracer.prototype = {
|
|
|
51
44
|
'X-B3-TraceId': this.getTraceId(),
|
|
52
45
|
'X-B3-SpanId': this.getSpanId(),
|
|
53
46
|
// 'X-B3-ParentSpanId': '',
|
|
54
|
-
'X-B3-Sampled': '1'
|
|
55
|
-
|
|
47
|
+
'X-B3-Sampled': '1'
|
|
48
|
+
// 'X-B3-Flags': '0'
|
|
56
49
|
};
|
|
57
50
|
}
|
|
58
51
|
};
|
|
@@ -4,31 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ZipkinSingleTracer = ZipkinSingleTracer;
|
|
7
|
-
|
|
8
7
|
// === Generate a random 64-bit number in fixed-length hex format
|
|
9
8
|
function randomTraceId() {
|
|
10
9
|
var digits = '0123456789abcdef';
|
|
11
10
|
var n = '';
|
|
12
|
-
|
|
13
11
|
for (var i = 0; i < 16; i += 1) {
|
|
14
12
|
var rand = Math.floor(Math.random() * 16);
|
|
15
13
|
n += digits[rand];
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
return n;
|
|
19
16
|
}
|
|
17
|
+
|
|
20
18
|
/**
|
|
21
19
|
*
|
|
22
20
|
* @param {*} configuration 配置信息
|
|
23
21
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
22
|
function ZipkinSingleTracer(configuration) {
|
|
27
23
|
var rootSpanId = randomTraceId();
|
|
28
24
|
this._traceId = randomTraceId() + rootSpanId;
|
|
29
25
|
this._spanId = rootSpanId;
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
ZipkinSingleTracer.prototype = {
|
|
33
28
|
isTracingSupported: function isTracingSupported() {
|
|
34
29
|
return true;
|
|
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.trackEventCounts = trackEventCounts;
|
|
7
|
-
|
|
8
7
|
var _utils = require("../helper/utils");
|
|
9
|
-
|
|
10
8
|
var _enums = require("../helper/enums");
|
|
11
|
-
|
|
12
9
|
var _lifeCycle = require("../core/lifeCycle");
|
|
13
|
-
|
|
14
10
|
function trackEventCounts(lifeCycle, callback) {
|
|
15
11
|
if (typeof callback === 'undefined') {
|
|
16
12
|
callback = _utils.noop;
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
var eventCounts = {
|
|
20
15
|
errorCount: 0,
|
|
21
16
|
resourceCount: 0,
|
|
@@ -24,18 +19,15 @@ function trackEventCounts(lifeCycle, callback) {
|
|
|
24
19
|
};
|
|
25
20
|
var subscription = lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (data) {
|
|
26
21
|
var rawRumEvent = data.rawRumEvent;
|
|
27
|
-
|
|
28
22
|
switch (rawRumEvent.type) {
|
|
29
23
|
case _enums.RumEventType.ERROR:
|
|
30
24
|
eventCounts.errorCount += 1;
|
|
31
25
|
callback(eventCounts);
|
|
32
26
|
break;
|
|
33
|
-
|
|
34
27
|
case _enums.RumEventType.RESOURCE:
|
|
35
28
|
eventCounts.resourceCount += 1;
|
|
36
29
|
callback(eventCounts);
|
|
37
30
|
break;
|
|
38
|
-
|
|
39
31
|
case _enums.RumEventType.ACTION:
|
|
40
32
|
eventCounts.userActionCount += 1;
|
|
41
33
|
callback(eventCounts);
|
|
@@ -3,46 +3,35 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.PAGE_ACTIVITY_VALIDATION_DELAY = exports.PAGE_ACTIVITY_MAX_DURATION = exports.PAGE_ACTIVITY_END_DELAY = void 0;
|
|
7
7
|
exports.trackPageActivities = trackPageActivities;
|
|
8
|
+
exports.waitIdlePageActivity = waitIdlePageActivity;
|
|
8
9
|
exports.waitPageActivitiesCompletion = waitPageActivitiesCompletion;
|
|
9
|
-
exports.PAGE_ACTIVITY_MAX_DURATION = exports.PAGE_ACTIVITY_END_DELAY = exports.PAGE_ACTIVITY_VALIDATION_DELAY = void 0;
|
|
10
|
-
|
|
11
10
|
var _utils = require("../helper/utils");
|
|
12
|
-
|
|
13
11
|
var _lifeCycle = require("../core/lifeCycle");
|
|
14
|
-
|
|
15
12
|
var _observable = require("../core/observable");
|
|
16
|
-
|
|
17
13
|
// Delay to wait for a page activity to validate the tracking process
|
|
18
|
-
var PAGE_ACTIVITY_VALIDATION_DELAY = 100;
|
|
19
|
-
|
|
20
|
-
exports.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
exports.PAGE_ACTIVITY_END_DELAY = PAGE_ACTIVITY_END_DELAY;
|
|
24
|
-
var PAGE_ACTIVITY_MAX_DURATION = 10000;
|
|
25
|
-
exports.PAGE_ACTIVITY_MAX_DURATION = PAGE_ACTIVITY_MAX_DURATION;
|
|
26
|
-
|
|
14
|
+
var PAGE_ACTIVITY_VALIDATION_DELAY = exports.PAGE_ACTIVITY_VALIDATION_DELAY = 100;
|
|
15
|
+
// Delay to wait after a page activity to end the tracking process
|
|
16
|
+
var PAGE_ACTIVITY_END_DELAY = exports.PAGE_ACTIVITY_END_DELAY = 100;
|
|
17
|
+
// Maximum duration of the tracking process
|
|
18
|
+
var PAGE_ACTIVITY_MAX_DURATION = exports.PAGE_ACTIVITY_MAX_DURATION = 10000;
|
|
27
19
|
function waitIdlePageActivity(lifeCycle, completionCallback) {
|
|
28
20
|
var _trackPageActivities = trackPageActivities(lifeCycle);
|
|
29
|
-
|
|
30
21
|
var pageActivitiesObservable = _trackPageActivities.observable;
|
|
31
22
|
var stopPageActivitiesTracking = _trackPageActivities.stop;
|
|
32
|
-
|
|
33
23
|
var _waitPageActivitiesCompletion = waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActivitiesTracking, completionCallback);
|
|
34
|
-
|
|
35
24
|
var stopWaitPageActivitiesCompletion = _waitPageActivitiesCompletion.stop;
|
|
36
|
-
|
|
37
25
|
function stop() {
|
|
38
26
|
stopWaitPageActivitiesCompletion();
|
|
39
27
|
stopPageActivitiesTracking();
|
|
40
28
|
}
|
|
41
|
-
|
|
42
29
|
return {
|
|
43
30
|
stop: stop
|
|
44
31
|
};
|
|
45
|
-
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Automatic action collection lifecycle overview:
|
|
46
35
|
// (Start new trackPageActivities)
|
|
47
36
|
// .-------------------'--------------------.
|
|
48
37
|
// v v
|
|
@@ -66,8 +55,6 @@ function waitIdlePageActivity(lifeCycle, completionCallback) {
|
|
|
66
55
|
//
|
|
67
56
|
// Note: because MAX_DURATION > VALIDATION_DELAY, we are sure that if the process is still alive
|
|
68
57
|
// after MAX_DURATION, it has been validated.
|
|
69
|
-
|
|
70
|
-
|
|
71
58
|
function trackPageActivities(lifeCycle) {
|
|
72
59
|
var observable = new _observable.Observable();
|
|
73
60
|
var subscriptions = [];
|
|
@@ -82,7 +69,6 @@ function trackPageActivities(lifeCycle) {
|
|
|
82
69
|
if (firstRequestIndex === undefined) {
|
|
83
70
|
firstRequestIndex = startEvent.requestIndex;
|
|
84
71
|
}
|
|
85
|
-
|
|
86
72
|
pendingRequestsCount += 1;
|
|
87
73
|
notifyPageActivity();
|
|
88
74
|
}));
|
|
@@ -91,17 +77,14 @@ function trackPageActivities(lifeCycle) {
|
|
|
91
77
|
if (firstRequestIndex === undefined || request.requestIndex < firstRequestIndex) {
|
|
92
78
|
return;
|
|
93
79
|
}
|
|
94
|
-
|
|
95
80
|
pendingRequestsCount -= 1;
|
|
96
81
|
notifyPageActivity();
|
|
97
82
|
}));
|
|
98
|
-
|
|
99
83
|
function notifyPageActivity() {
|
|
100
84
|
observable.notify({
|
|
101
85
|
isBusy: pendingRequestsCount > 0
|
|
102
86
|
});
|
|
103
87
|
}
|
|
104
|
-
|
|
105
88
|
return {
|
|
106
89
|
observable: observable,
|
|
107
90
|
stop: function stop() {
|
|
@@ -111,7 +94,6 @@ function trackPageActivities(lifeCycle) {
|
|
|
111
94
|
}
|
|
112
95
|
};
|
|
113
96
|
}
|
|
114
|
-
|
|
115
97
|
function waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActivitiesTracking, completionCallback) {
|
|
116
98
|
var idleTimeoutId;
|
|
117
99
|
var hasCompleted = false;
|
|
@@ -131,7 +113,6 @@ function waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActiviti
|
|
|
131
113
|
clearTimeout(validationTimeoutId);
|
|
132
114
|
clearTimeout(idleTimeoutId);
|
|
133
115
|
var lastChangeTime = (0, _utils.now)();
|
|
134
|
-
|
|
135
116
|
if (!isBusy) {
|
|
136
117
|
idleTimeoutId = setTimeout(function () {
|
|
137
118
|
complete({
|
|
@@ -141,7 +122,6 @@ function waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActiviti
|
|
|
141
122
|
}, PAGE_ACTIVITY_END_DELAY);
|
|
142
123
|
}
|
|
143
124
|
});
|
|
144
|
-
|
|
145
125
|
function stop() {
|
|
146
126
|
hasCompleted = true;
|
|
147
127
|
clearTimeout(validationTimeoutId);
|
|
@@ -149,16 +129,13 @@ function waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActiviti
|
|
|
149
129
|
clearTimeout(maxDurationTimeoutId);
|
|
150
130
|
stopPageActivitiesTracking();
|
|
151
131
|
}
|
|
152
|
-
|
|
153
132
|
function complete(params) {
|
|
154
133
|
if (hasCompleted) {
|
|
155
134
|
return;
|
|
156
135
|
}
|
|
157
|
-
|
|
158
136
|
stop();
|
|
159
137
|
completionCallback(params);
|
|
160
138
|
}
|
|
161
|
-
|
|
162
139
|
return {
|
|
163
140
|
stop: stop
|
|
164
141
|
};
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startRumBatch = startRumBatch;
|
|
7
|
-
|
|
8
7
|
var _lifeCycle = require("../../core/lifeCycle");
|
|
9
|
-
|
|
10
8
|
var _transport = require("../../core/transport");
|
|
11
|
-
|
|
12
9
|
var _enums = require("../../helper/enums");
|
|
13
|
-
|
|
14
10
|
function startRumBatch(configuration, lifeCycle) {
|
|
15
11
|
var batch = makeRumBatch(configuration, lifeCycle);
|
|
16
12
|
lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
|
|
@@ -26,21 +22,17 @@ function startRumBatch(configuration, lifeCycle) {
|
|
|
26
22
|
}
|
|
27
23
|
};
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
function makeRumBatch(configuration, lifeCycle) {
|
|
31
26
|
var primaryBatch = createRumBatch(configuration.datakitUrl, lifeCycle);
|
|
32
|
-
|
|
33
27
|
function createRumBatch(endpointUrl, lifeCycle) {
|
|
34
28
|
return new _transport.Batch(new _transport.HttpRequest(endpointUrl, configuration.batchBytesLimit), configuration.maxBatchSize, configuration.batchBytesLimit, configuration.maxMessageSize, configuration.flushTimeout, lifeCycle);
|
|
35
29
|
}
|
|
36
|
-
|
|
37
30
|
var stopped = false;
|
|
38
31
|
return {
|
|
39
32
|
add: function add(message) {
|
|
40
33
|
if (stopped) {
|
|
41
34
|
return;
|
|
42
35
|
}
|
|
43
|
-
|
|
44
36
|
primaryBatch.add(message);
|
|
45
37
|
},
|
|
46
38
|
stop: function stop() {
|
|
@@ -50,7 +42,6 @@ function makeRumBatch(configuration, lifeCycle) {
|
|
|
50
42
|
if (stopped) {
|
|
51
43
|
return;
|
|
52
44
|
}
|
|
53
|
-
|
|
54
45
|
primaryBatch.upsert(message, key);
|
|
55
46
|
}
|
|
56
47
|
};
|
package/esm/boot/buildEnv.js
CHANGED