@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
package/cjs/core/transport.js
CHANGED
|
@@ -3,36 +3,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.processedMessageByDataMap = exports.HttpRequest = exports.Batch = void 0;
|
|
8
7
|
var _utils = require("../helper/utils");
|
|
9
|
-
|
|
10
8
|
var _sdk = require("../core/sdk");
|
|
11
|
-
|
|
12
9
|
var _byteUtils = require("../helper/byteUtils");
|
|
13
|
-
|
|
14
10
|
var _lifeCycle = require("../core/lifeCycle");
|
|
15
|
-
|
|
16
11
|
var _dataMap = require("./dataMap");
|
|
17
|
-
|
|
18
12
|
// https://en.wikipedia.org/wiki/UTF-8
|
|
19
13
|
var HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/;
|
|
20
14
|
var CUSTOM_KEYS = 'custom_keys';
|
|
21
|
-
|
|
22
15
|
function addBatchPrecision(url) {
|
|
23
16
|
if (!url) return url;
|
|
24
17
|
return url + (url.indexOf('?') === -1 ? '?' : '&') + 'precision=ms';
|
|
25
18
|
}
|
|
26
|
-
|
|
27
19
|
var httpRequest = function httpRequest(endpointUrl, bytesLimit) {
|
|
28
20
|
this.endpointUrl = endpointUrl;
|
|
29
21
|
this.bytesLimit = bytesLimit;
|
|
30
22
|
};
|
|
31
|
-
|
|
32
23
|
httpRequest.prototype = {
|
|
33
24
|
send: function send(data) {
|
|
34
25
|
var url = addBatchPrecision(this.endpointUrl);
|
|
35
|
-
|
|
36
26
|
_sdk.sdk.request({
|
|
37
27
|
method: 'POST',
|
|
38
28
|
header: {
|
|
@@ -43,10 +33,8 @@ httpRequest.prototype = {
|
|
|
43
33
|
});
|
|
44
34
|
}
|
|
45
35
|
};
|
|
46
|
-
var HttpRequest = httpRequest;
|
|
47
|
-
exports.
|
|
48
|
-
|
|
49
|
-
var processedMessageByDataMap = function processedMessageByDataMap(message) {
|
|
36
|
+
var HttpRequest = exports.HttpRequest = httpRequest;
|
|
37
|
+
var processedMessageByDataMap = exports.processedMessageByDataMap = function processedMessageByDataMap(message) {
|
|
50
38
|
if (!message || !message.type) return {
|
|
51
39
|
rowStr: '',
|
|
52
40
|
rowData: undefined
|
|
@@ -64,17 +52,13 @@ var processedMessageByDataMap = function processedMessageByDataMap(message) {
|
|
|
64
52
|
} else {
|
|
65
53
|
rowStr += key + ',';
|
|
66
54
|
}
|
|
67
|
-
|
|
68
55
|
rowData.measurement = key;
|
|
69
56
|
var tagsStr = [];
|
|
70
57
|
var tags = (0, _utils.extend)({}, _dataMap.commonTags, value.tags);
|
|
71
58
|
var filterFileds = ['date', 'type', CUSTOM_KEYS]; // 已经在datamap中定义过的fields和tags
|
|
72
|
-
|
|
73
59
|
(0, _utils.each)(tags, function (value_path, _key) {
|
|
74
60
|
var _value = (0, _utils.findByPath)(message, value_path);
|
|
75
|
-
|
|
76
61
|
filterFileds.push(_key);
|
|
77
|
-
|
|
78
62
|
if (_value || (0, _utils.isNumber)(_value)) {
|
|
79
63
|
rowData.tags[_key] = (0, _utils.escapeJsonValue)(_value);
|
|
80
64
|
tagsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowData)(_value));
|
|
@@ -85,30 +69,22 @@ var processedMessageByDataMap = function processedMessageByDataMap(message) {
|
|
|
85
69
|
(0, _utils.each)(fields, function (_value, _key) {
|
|
86
70
|
if ((0, _utils.isArray)(_value) && _value.length === 2) {
|
|
87
71
|
var type = _value[0],
|
|
88
|
-
|
|
89
|
-
|
|
72
|
+
value_path = _value[1];
|
|
90
73
|
var _valueData = (0, _utils.findByPath)(message, value_path);
|
|
91
|
-
|
|
92
74
|
filterFileds.push(_key);
|
|
93
|
-
|
|
94
75
|
if (_valueData || (0, _utils.isNumber)(_valueData)) {
|
|
95
76
|
rowData.fields[_key] = _valueData; // 这里不需要转译
|
|
96
|
-
|
|
97
77
|
fieldsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowField)(_valueData));
|
|
98
78
|
}
|
|
99
79
|
} else if ((0, _utils.isString)(_value)) {
|
|
100
80
|
var _valueData = (0, _utils.findByPath)(message, _value);
|
|
101
|
-
|
|
102
81
|
filterFileds.push(_key);
|
|
103
|
-
|
|
104
82
|
if (_valueData || (0, _utils.isNumber)(_valueData)) {
|
|
105
83
|
rowData.fields[_key] = _valueData; // 这里不需要转译
|
|
106
|
-
|
|
107
84
|
fieldsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowField)(_valueData));
|
|
108
85
|
}
|
|
109
86
|
}
|
|
110
87
|
});
|
|
111
|
-
|
|
112
88
|
if (message.tags && (0, _utils.isObject)(message.tags) && !(0, _utils.isEmptyObject)(message.tags)) {
|
|
113
89
|
// 自定义tag, 存储成field
|
|
114
90
|
var _tagKeys = [];
|
|
@@ -116,44 +92,35 @@ var processedMessageByDataMap = function processedMessageByDataMap(message) {
|
|
|
116
92
|
// 如果和之前tag重名,则舍弃
|
|
117
93
|
if (filterFileds.indexOf(_key) > -1) return;
|
|
118
94
|
filterFileds.push(_key);
|
|
119
|
-
|
|
120
95
|
if (_value || (0, _utils.isNumber)(_value)) {
|
|
121
96
|
_tagKeys.push(_key);
|
|
122
|
-
|
|
123
97
|
rowData.fields[_key] = _value; // 这里不需要转译
|
|
124
|
-
|
|
125
98
|
fieldsStr.push((0, _utils.escapeRowData)(_key) + '=' + (0, _utils.escapeRowField)(_value));
|
|
126
99
|
}
|
|
127
100
|
});
|
|
128
|
-
|
|
129
101
|
if (_tagKeys.length) {
|
|
130
102
|
rowData.fields[CUSTOM_KEYS] = (0, _utils.escapeRowField)(_tagKeys);
|
|
131
103
|
fieldsStr.push((0, _utils.escapeRowData)(CUSTOM_KEYS) + '=' + (0, _utils.escapeRowField)(_tagKeys));
|
|
132
104
|
}
|
|
133
105
|
}
|
|
134
|
-
|
|
135
106
|
if (tagsStr.length) {
|
|
136
107
|
rowStr += tagsStr.join(',');
|
|
137
108
|
}
|
|
138
|
-
|
|
139
109
|
if (fieldsStr.length) {
|
|
140
110
|
rowStr += ' ';
|
|
141
111
|
rowStr += fieldsStr.join(',');
|
|
142
112
|
hasFileds = true;
|
|
143
113
|
}
|
|
144
|
-
|
|
145
114
|
rowStr = rowStr + ' ' + message.date;
|
|
146
115
|
rowData.time = (0, _utils.toServerDuration)(message.date); // 这里不需要转译
|
|
147
116
|
}
|
|
148
117
|
});
|
|
118
|
+
|
|
149
119
|
return {
|
|
150
120
|
rowStr: hasFileds ? rowStr : '',
|
|
151
121
|
rowData: hasFileds ? rowData : undefined
|
|
152
122
|
};
|
|
153
123
|
};
|
|
154
|
-
|
|
155
|
-
exports.processedMessageByDataMap = processedMessageByDataMap;
|
|
156
|
-
|
|
157
124
|
function batch(request, maxSize, bytesLimit, maxMessageSize, flushTimeout, lifeCycle) {
|
|
158
125
|
this.request = request;
|
|
159
126
|
this.maxSize = maxSize;
|
|
@@ -168,7 +135,6 @@ function batch(request, maxSize, bytesLimit, maxMessageSize, flushTimeout, lifeC
|
|
|
168
135
|
this.flushOnVisibilityHidden();
|
|
169
136
|
this.flushPeriodically();
|
|
170
137
|
}
|
|
171
|
-
|
|
172
138
|
batch.prototype = {
|
|
173
139
|
add: function add(message) {
|
|
174
140
|
this.addOrUpdate(message);
|
|
@@ -192,22 +158,17 @@ batch.prototype = {
|
|
|
192
158
|
addOrUpdate: function addOrUpdate(message, key) {
|
|
193
159
|
var process = this.process(message);
|
|
194
160
|
if (!process.processedMessage || process.processedMessage === '') return;
|
|
195
|
-
|
|
196
161
|
if (process.messageBytesSize >= this.maxMessageSize) {
|
|
197
162
|
console.warn('Discarded a message whose size was bigger than the maximum allowed size' + this.maxMessageSize + 'KB.');
|
|
198
163
|
return;
|
|
199
164
|
}
|
|
200
|
-
|
|
201
165
|
if (this.hasMessageFor(key)) {
|
|
202
166
|
this.remove(key);
|
|
203
167
|
}
|
|
204
|
-
|
|
205
168
|
if (this.willReachedBytesLimitWith(process.messageBytesSize)) {
|
|
206
169
|
this.flush();
|
|
207
170
|
}
|
|
208
|
-
|
|
209
171
|
this.push(process.processedMessage, process.messageBytesSize, key);
|
|
210
|
-
|
|
211
172
|
if (this.isFull()) {
|
|
212
173
|
this.flush();
|
|
213
174
|
}
|
|
@@ -225,13 +186,11 @@ batch.prototype = {
|
|
|
225
186
|
// \n separator at serialization
|
|
226
187
|
this.bufferBytesSize += 1;
|
|
227
188
|
}
|
|
228
|
-
|
|
229
189
|
if (key !== undefined) {
|
|
230
190
|
this.upsertBuffer[key] = processedMessage;
|
|
231
191
|
} else {
|
|
232
192
|
this.pushOnlyBuffer.push(processedMessage);
|
|
233
193
|
}
|
|
234
|
-
|
|
235
194
|
this.bufferBytesSize += messageBytesSize;
|
|
236
195
|
this.bufferMessageCount += 1;
|
|
237
196
|
},
|
|
@@ -241,7 +200,6 @@ batch.prototype = {
|
|
|
241
200
|
var messageBytesSize = (0, _byteUtils.computeBytesCount)(removedMessage);
|
|
242
201
|
this.bufferBytesSize -= messageBytesSize;
|
|
243
202
|
this.bufferMessageCount -= 1;
|
|
244
|
-
|
|
245
203
|
if (this.bufferMessageCount > 0) {
|
|
246
204
|
this.bufferBytesSize -= 1;
|
|
247
205
|
}
|
|
@@ -258,10 +216,8 @@ batch.prototype = {
|
|
|
258
216
|
},
|
|
259
217
|
flushPeriodically: function flushPeriodically() {
|
|
260
218
|
var _this = this;
|
|
261
|
-
|
|
262
219
|
setTimeout(function () {
|
|
263
220
|
_this.flush();
|
|
264
|
-
|
|
265
221
|
_this.flushPeriodically();
|
|
266
222
|
}, _this.flushTimeout);
|
|
267
223
|
},
|
|
@@ -271,12 +227,9 @@ batch.prototype = {
|
|
|
271
227
|
* With sendBeacon, requests are guaranteed to be successfully sent during document unload
|
|
272
228
|
*/
|
|
273
229
|
// @ts-ignore this function is not always defined
|
|
274
|
-
|
|
275
|
-
|
|
276
230
|
this.lifeCycle.subscribe(_lifeCycle.LifeCycleEventType.APP_HIDE, function () {
|
|
277
231
|
_this.flush();
|
|
278
232
|
});
|
|
279
233
|
}
|
|
280
234
|
};
|
|
281
|
-
var Batch = batch;
|
|
282
|
-
exports.Batch = Batch;
|
|
235
|
+
var Batch = exports.Batch = batch;
|
package/cjs/core/user.js
CHANGED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.sanitizeUser = sanitizeUser;
|
|
7
6
|
exports.checkUser = checkUser;
|
|
8
|
-
|
|
7
|
+
exports.sanitizeUser = sanitizeUser;
|
|
9
8
|
var _utils = require("../helper/utils");
|
|
10
|
-
|
|
11
9
|
/**
|
|
12
10
|
* Clone input data and ensure known user properties (id, name, email)
|
|
13
11
|
* are strings, as defined here:
|
|
@@ -24,17 +22,14 @@ function sanitizeUser(newUser) {
|
|
|
24
22
|
});
|
|
25
23
|
return user;
|
|
26
24
|
}
|
|
25
|
+
|
|
27
26
|
/**
|
|
28
27
|
* Simple check to ensure user is valid
|
|
29
28
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
29
|
function checkUser(newUser) {
|
|
33
30
|
var isValid = (0, _utils.getType)(newUser) === 'object';
|
|
34
|
-
|
|
35
31
|
if (!isValid) {
|
|
36
32
|
console.error('Unsupported user:', newUser);
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
return isValid;
|
|
40
35
|
}
|
package/cjs/core/xhrProxy.js
CHANGED
|
@@ -3,22 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.startXhrProxy = startXhrProxy;
|
|
7
6
|
exports.resetXhrProxy = resetXhrProxy;
|
|
8
|
-
|
|
7
|
+
exports.startXhrProxy = startXhrProxy;
|
|
9
8
|
var _sdk = require("./sdk");
|
|
10
|
-
|
|
11
9
|
var _utils = require("../helper/utils");
|
|
12
|
-
|
|
13
10
|
var _enums = require("../helper/enums");
|
|
14
|
-
|
|
15
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
16
|
-
|
|
11
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
17
12
|
var xhrProxySingleton;
|
|
18
13
|
var beforeSendCallbacks = [];
|
|
19
14
|
var onRequestCompleteCallbacks = [];
|
|
20
15
|
var originalXhrRequest;
|
|
21
|
-
|
|
22
16
|
function startXhrProxy(userConfiguration) {
|
|
23
17
|
if (!xhrProxySingleton) {
|
|
24
18
|
proxyXhr(userConfiguration);
|
|
@@ -31,10 +25,8 @@ function startXhrProxy(userConfiguration) {
|
|
|
31
25
|
}
|
|
32
26
|
};
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
return xhrProxySingleton;
|
|
36
29
|
}
|
|
37
|
-
|
|
38
30
|
function resetXhrProxy() {
|
|
39
31
|
if (xhrProxySingleton) {
|
|
40
32
|
xhrProxySingleton = undefined;
|
|
@@ -43,13 +35,10 @@ function resetXhrProxy() {
|
|
|
43
35
|
_sdk.sdk.request = originalXhrRequest;
|
|
44
36
|
}
|
|
45
37
|
}
|
|
46
|
-
|
|
47
38
|
function proxyXhr(userConfiguration) {
|
|
48
39
|
originalXhrRequest = _sdk.sdk.request;
|
|
49
|
-
|
|
50
40
|
_sdk.sdk.request = function () {
|
|
51
41
|
var _this = this;
|
|
52
|
-
|
|
53
42
|
var dataflux_xhr = {
|
|
54
43
|
method: arguments[0].method || 'GET',
|
|
55
44
|
startTime: 0,
|
|
@@ -60,32 +49,24 @@ function proxyXhr(userConfiguration) {
|
|
|
60
49
|
};
|
|
61
50
|
dataflux_xhr.startTime = (0, _utils.now)();
|
|
62
51
|
var originalSuccess = arguments[0].success;
|
|
63
|
-
|
|
64
52
|
arguments[0].success = function () {
|
|
65
53
|
reportXhr(arguments[0]);
|
|
66
|
-
|
|
67
54
|
if (typeof originalSuccess === 'function') {
|
|
68
55
|
originalSuccess.apply(_this, arguments);
|
|
69
56
|
}
|
|
70
57
|
};
|
|
71
|
-
|
|
72
58
|
var originalFail = arguments[0].fail;
|
|
73
|
-
|
|
74
59
|
arguments[0].fail = function () {
|
|
75
60
|
reportXhr(arguments[0]);
|
|
76
|
-
|
|
77
61
|
if (typeof originalFail === 'function') {
|
|
78
62
|
originalFail.apply(_this, arguments);
|
|
79
63
|
}
|
|
80
64
|
};
|
|
81
|
-
|
|
82
65
|
var hasBeenReported = false;
|
|
83
|
-
|
|
84
66
|
var reportXhr = function reportXhr(res) {
|
|
85
67
|
if (hasBeenReported) {
|
|
86
68
|
return;
|
|
87
69
|
}
|
|
88
|
-
|
|
89
70
|
hasBeenReported = true;
|
|
90
71
|
dataflux_xhr.duration = (0, _utils.now)() - dataflux_xhr.startTime;
|
|
91
72
|
dataflux_xhr.response = JSON.stringify(res.data);
|
|
@@ -96,16 +77,14 @@ function proxyXhr(userConfiguration) {
|
|
|
96
77
|
callback(dataflux_xhr);
|
|
97
78
|
});
|
|
98
79
|
};
|
|
99
|
-
|
|
100
80
|
beforeSendCallbacks.forEach(function (callback) {
|
|
101
81
|
callback(dataflux_xhr);
|
|
102
82
|
});
|
|
103
|
-
var result = originalXhrRequest.call(this, dataflux_xhr.option);
|
|
104
|
-
|
|
83
|
+
var result = originalXhrRequest.call(this, dataflux_xhr.option);
|
|
84
|
+
// 判断结果是否为promise
|
|
105
85
|
var isPromise = function isPromise(obj) {
|
|
106
86
|
return !!obj && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
|
|
107
87
|
};
|
|
108
|
-
|
|
109
88
|
if (isPromise(result) && userConfiguration.isVue2) {
|
|
110
89
|
// vue2 版本,success, fail 都在then返回
|
|
111
90
|
return result.then(function (res) {
|
|
@@ -114,7 +93,6 @@ function proxyXhr(userConfiguration) {
|
|
|
114
93
|
} else {
|
|
115
94
|
reportXhr(res[1]);
|
|
116
95
|
}
|
|
117
|
-
|
|
118
96
|
return res;
|
|
119
97
|
});
|
|
120
98
|
} else if (isPromise(result) && !userConfiguration.isVue2) {
|
package/cjs/helper/byteUtils.js
CHANGED
|
@@ -3,27 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.computeBytesCount = computeBytesCount;
|
|
7
6
|
exports.ONE_MEBI_BYTE = exports.ONE_KIBI_BYTE = void 0;
|
|
8
|
-
|
|
9
|
-
exports.ONE_KIBI_BYTE =
|
|
10
|
-
var ONE_MEBI_BYTE = 1024 * ONE_KIBI_BYTE;
|
|
11
|
-
|
|
12
|
-
exports.ONE_MEBI_BYTE = ONE_MEBI_BYTE;
|
|
7
|
+
exports.computeBytesCount = computeBytesCount;
|
|
8
|
+
var ONE_KIBI_BYTE = exports.ONE_KIBI_BYTE = 1024;
|
|
9
|
+
var ONE_MEBI_BYTE = exports.ONE_MEBI_BYTE = 1024 * ONE_KIBI_BYTE;
|
|
10
|
+
// eslint-disable-next-line no-control-regex
|
|
13
11
|
var HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/;
|
|
14
|
-
|
|
15
12
|
function computeBytesCount(candidate) {
|
|
16
13
|
// Accurate byte size computations can degrade performances when there is a lot of events to process
|
|
17
14
|
if (!HAS_MULTI_BYTES_CHARACTERS.test(candidate)) {
|
|
18
15
|
return candidate.length;
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
var total = 0,
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
charCode;
|
|
19
|
+
// utf-8编码
|
|
24
20
|
for (var i = 0, len = candidate.length; i < len; i++) {
|
|
25
21
|
charCode = candidate.charCodeAt(i);
|
|
26
|
-
|
|
27
22
|
if (charCode <= 0x007f) {
|
|
28
23
|
total += 1;
|
|
29
24
|
} else if (charCode <= 0x07ff) {
|
|
@@ -34,6 +29,5 @@ function computeBytesCount(candidate) {
|
|
|
34
29
|
total += 4;
|
|
35
30
|
}
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
return total;
|
|
39
33
|
}
|
|
@@ -4,11 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.buildCommonContext = buildCommonContext;
|
|
7
|
-
|
|
8
7
|
function buildCommonContext(globalContextManager, userContextManager) {
|
|
9
8
|
return {
|
|
10
9
|
context: globalContextManager.getContext(),
|
|
11
|
-
user: userContextManager.getContext()
|
|
12
|
-
|
|
10
|
+
user: userContextManager.getContext()
|
|
11
|
+
// hasReplay: recorderApi.isRecording() ? true : undefined,
|
|
13
12
|
};
|
|
14
13
|
}
|
package/cjs/helper/enums.js
CHANGED
|
@@ -3,23 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.TraceType = exports.RumEventType = exports.RequestType = exports.ONE_SECOND = exports.ONE_MINUTE = exports.ONE_KILO_BYTE = exports.ONE_HOUR = exports.MpHook = exports.ErrorHandling = exports.CLIENT_ID_TOKEN = exports.ActionType = void 0;
|
|
8
7
|
var _RumEventType;
|
|
9
|
-
|
|
10
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
exports.ONE_SECOND =
|
|
14
|
-
var ONE_MINUTE = 60 * ONE_SECOND;
|
|
15
|
-
exports.
|
|
16
|
-
var
|
|
17
|
-
exports.
|
|
18
|
-
var
|
|
19
|
-
exports.ONE_KILO_BYTE = ONE_KILO_BYTE;
|
|
20
|
-
var CLIENT_ID_TOKEN = 'datafluxRum:client:id';
|
|
21
|
-
exports.CLIENT_ID_TOKEN = CLIENT_ID_TOKEN;
|
|
22
|
-
var RumEventType = (_RumEventType = {
|
|
8
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
var ONE_SECOND = exports.ONE_SECOND = 1000;
|
|
13
|
+
var ONE_MINUTE = exports.ONE_MINUTE = 60 * ONE_SECOND;
|
|
14
|
+
var ONE_HOUR = exports.ONE_HOUR = 60 * ONE_MINUTE;
|
|
15
|
+
var ONE_KILO_BYTE = exports.ONE_KILO_BYTE = 1024;
|
|
16
|
+
var CLIENT_ID_TOKEN = exports.CLIENT_ID_TOKEN = 'datafluxRum:client:id';
|
|
17
|
+
var RumEventType = exports.RumEventType = (_RumEventType = {
|
|
23
18
|
ACTION: 'action',
|
|
24
19
|
ERROR: 'error',
|
|
25
20
|
LONG_TASK: 'long_task',
|
|
@@ -27,20 +22,17 @@ var RumEventType = (_RumEventType = {
|
|
|
27
22
|
RESOURCE: 'resource',
|
|
28
23
|
APP: 'app'
|
|
29
24
|
}, _defineProperty(_RumEventType, "ACTION", 'action'), _defineProperty(_RumEventType, "LOGGER", 'logger'), _RumEventType);
|
|
30
|
-
exports.
|
|
31
|
-
var RequestType = {
|
|
25
|
+
var RequestType = exports.RequestType = {
|
|
32
26
|
XHR: 'network',
|
|
33
27
|
DOWNLOAD: 'resource'
|
|
34
28
|
};
|
|
35
|
-
exports.
|
|
36
|
-
var ActionType = {
|
|
29
|
+
var ActionType = exports.ActionType = {
|
|
37
30
|
tap: 'tap',
|
|
38
31
|
longpress: 'longpress',
|
|
39
32
|
longtap: 'longtap',
|
|
40
33
|
custom: 'custom'
|
|
41
34
|
};
|
|
42
|
-
exports.
|
|
43
|
-
var MpHook = {
|
|
35
|
+
var MpHook = exports.MpHook = {
|
|
44
36
|
data: 1,
|
|
45
37
|
onLoad: 1,
|
|
46
38
|
onShow: 1,
|
|
@@ -53,8 +45,7 @@ var MpHook = {
|
|
|
53
45
|
onHide: 1,
|
|
54
46
|
onUnload: 1
|
|
55
47
|
};
|
|
56
|
-
exports.
|
|
57
|
-
var TraceType = {
|
|
48
|
+
var TraceType = exports.TraceType = {
|
|
58
49
|
DDTRACE: 'ddtrace',
|
|
59
50
|
ZIPKIN_MULTI_HEADER: 'zipkin',
|
|
60
51
|
ZIPKIN_SINGLE_HEADER: 'zipkin_single_header',
|
|
@@ -62,9 +53,7 @@ var TraceType = {
|
|
|
62
53
|
SKYWALKING_V3: 'skywalking_v3',
|
|
63
54
|
JAEGER: 'jaeger'
|
|
64
55
|
};
|
|
65
|
-
exports.
|
|
66
|
-
var ErrorHandling = {
|
|
56
|
+
var ErrorHandling = exports.ErrorHandling = {
|
|
67
57
|
HANDLED: 'handled',
|
|
68
58
|
UNHANDLED: 'unhandled'
|
|
69
|
-
};
|
|
70
|
-
exports.ErrorHandling = ErrorHandling;
|
|
59
|
+
};
|
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.jsonStringify = jsonStringify;
|
|
7
6
|
exports.detachToJsonMethod = detachToJsonMethod;
|
|
8
|
-
|
|
7
|
+
exports.jsonStringify = jsonStringify;
|
|
9
8
|
var _utils = require("./utils");
|
|
10
|
-
|
|
11
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
12
|
-
|
|
9
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
13
10
|
/**
|
|
14
11
|
* Custom implementation of JSON.stringify that ignores some toJSON methods. We need to do that
|
|
15
12
|
* because some sites badly override toJSON on certain objects. Removing all toJSON methods from
|
|
@@ -21,15 +18,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
21
18
|
function jsonStringify(value, replacer, space) {
|
|
22
19
|
if (_typeof(value) !== 'object' || value === null) {
|
|
23
20
|
return JSON.stringify(value);
|
|
24
|
-
}
|
|
25
|
-
// subclasses.
|
|
26
|
-
|
|
21
|
+
}
|
|
27
22
|
|
|
23
|
+
// Note: The order matter here. We need to detach toJSON methods on parent classes before their
|
|
24
|
+
// subclasses.
|
|
28
25
|
var restoreObjectPrototypeToJson = detachToJsonMethod(Object.prototype);
|
|
29
26
|
var restoreArrayPrototypeToJson = detachToJsonMethod(Array.prototype);
|
|
30
27
|
var restoreValuePrototypeToJson = detachToJsonMethod(Object.getPrototypeOf(value));
|
|
31
28
|
var restoreValueToJson = detachToJsonMethod(value);
|
|
32
|
-
|
|
33
29
|
try {
|
|
34
30
|
return JSON.stringify(value, replacer, space);
|
|
35
31
|
} catch (error) {
|
|
@@ -41,17 +37,14 @@ function jsonStringify(value, replacer, space) {
|
|
|
41
37
|
restoreValueToJson();
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
function detachToJsonMethod(value) {
|
|
46
41
|
var object = value;
|
|
47
42
|
var objectToJson = object.toJSON;
|
|
48
|
-
|
|
49
43
|
if (objectToJson) {
|
|
50
44
|
delete object.toJSON;
|
|
51
45
|
return function () {
|
|
52
46
|
object.toJSON = objectToJson;
|
|
53
47
|
};
|
|
54
48
|
}
|
|
55
|
-
|
|
56
49
|
return _utils.noop;
|
|
57
50
|
}
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.limitModification = limitModification;
|
|
7
|
-
|
|
8
7
|
var _utils = require("./utils");
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
13
|
-
|
|
8
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
9
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
14
10
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
|
|
16
11
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
17
|
-
|
|
18
12
|
/**
|
|
19
13
|
* Current limitations:
|
|
20
14
|
* - field path do not support array, 'a.b.c' only
|
|
@@ -26,28 +20,22 @@ function limitModification(object, modifiableFieldPaths, modifier) {
|
|
|
26
20
|
(0, _utils.each)(modifiableFieldPaths, function (path) {
|
|
27
21
|
var originalValue = get(object, path);
|
|
28
22
|
var newValue = get(clone, path);
|
|
29
|
-
|
|
30
23
|
if (typeof originalValue === 'string' && typeof newValue === 'string') {
|
|
31
24
|
set(object, path, newValue);
|
|
32
25
|
}
|
|
33
26
|
});
|
|
34
27
|
return result;
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
function get(object, path) {
|
|
38
30
|
var current = object;
|
|
39
|
-
|
|
40
31
|
var _iterator = _createForOfIteratorHelper(path.split('.')),
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
_step;
|
|
43
33
|
try {
|
|
44
34
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
45
35
|
var field = _step.value;
|
|
46
|
-
|
|
47
36
|
if (!isValidObjectContaining(current, field)) {
|
|
48
37
|
return;
|
|
49
38
|
}
|
|
50
|
-
|
|
51
39
|
current = current[field];
|
|
52
40
|
}
|
|
53
41
|
} catch (err) {
|
|
@@ -55,21 +43,16 @@ function get(object, path) {
|
|
|
55
43
|
} finally {
|
|
56
44
|
_iterator.f();
|
|
57
45
|
}
|
|
58
|
-
|
|
59
46
|
return current;
|
|
60
47
|
}
|
|
61
|
-
|
|
62
48
|
function set(object, path, value) {
|
|
63
49
|
var current = object;
|
|
64
50
|
var fields = path.split('.');
|
|
65
|
-
|
|
66
51
|
for (var i = 0; i < fields.length; i += 1) {
|
|
67
52
|
var field = fields[i];
|
|
68
|
-
|
|
69
53
|
if (!isValidObjectContaining(current, field)) {
|
|
70
54
|
return;
|
|
71
55
|
}
|
|
72
|
-
|
|
73
56
|
if (i !== fields.length - 1) {
|
|
74
57
|
current = current[field];
|
|
75
58
|
} else {
|
|
@@ -77,7 +60,6 @@ function set(object, path, value) {
|
|
|
77
60
|
}
|
|
78
61
|
}
|
|
79
62
|
}
|
|
80
|
-
|
|
81
63
|
function isValidObjectContaining(object, field) {
|
|
82
64
|
return _typeof(object) === 'object' && object !== null && field in object;
|
|
83
65
|
}
|