@cloudcare/browser-core 2.0.17 → 3.0.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/cjs/dataMap.js +1 -0
- package/cjs/helper/byteUtils.js +33 -0
- package/cjs/helper/deviceInfo.js +23 -17
- package/cjs/helper/limitModification.js +1 -1
- package/cjs/helper/tools.js +0 -2
- package/cjs/init.js +4 -4
- package/cjs/tracekit/tracekit.js +34 -24
- package/cjs/transport/eventBridge.js +35 -0
- package/cjs/transport/httpRequest.js +1 -1
- package/cjs/transport/index.js +21 -1
- package/cjs/transport/sendWithRetryStrategy.js +9 -9
- package/cjs/user/user.js +0 -1
- package/cjs/worker.js +13 -0
- package/esm/dataMap.js +1 -0
- package/esm/helper/byteUtils.js +30 -0
- package/esm/helper/deviceInfo.js +23 -17
- package/esm/helper/limitModification.js +22 -5
- package/esm/helper/readBytesFromStream.js +1 -1
- package/esm/helper/sanitize.js +5 -3
- package/esm/helper/serialisation/jsonStringify.js +4 -2
- package/esm/helper/serialisation/rowData.js +4 -2
- package/esm/helper/tools.js +12 -12
- package/esm/init.js +10 -8
- package/esm/tracekit/computeStackTrace.js +3 -1
- package/esm/tracekit/tracekit.js +33 -24
- package/esm/transport/eventBridge.js +26 -0
- package/esm/transport/flushController.js +5 -7
- package/esm/transport/httpRequest.js +1 -1
- package/esm/transport/index.js +3 -2
- package/esm/transport/sendWithRetryStrategy.js +9 -9
- package/esm/user/user.js +0 -1
- package/esm/worker.js +1 -0
- package/package.json +2 -2
- package/src/dataMap.js +1 -0
- package/src/helper/byteUtils.js +12 -0
- package/src/helper/deviceInfo.js +24 -17
- package/src/helper/tools.js +0 -2
- package/src/init.js +4 -4
- package/src/tracekit/tracekit.js +31 -30
- package/src/transport/eventBridge.js +24 -0
- package/src/transport/httpRequest.js +1 -0
- package/src/transport/index.js +2 -1
- package/src/transport/sendWithRetryStrategy.js +17 -5
- package/src/user/user.js +0 -1
- package/src/worker.js +1 -0
package/cjs/dataMap.js
CHANGED
package/cjs/helper/byteUtils.js
CHANGED
|
@@ -5,6 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ONE_MEBI_BYTE = exports.ONE_KIBI_BYTE = void 0;
|
|
7
7
|
exports.computeBytesCount = computeBytesCount;
|
|
8
|
+
exports.concatBuffers = concatBuffers;
|
|
9
|
+
|
|
10
|
+
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; } } }; }
|
|
11
|
+
|
|
12
|
+
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); }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
8
16
|
var ONE_KIBI_BYTE = 1024;
|
|
9
17
|
exports.ONE_KIBI_BYTE = ONE_KIBI_BYTE;
|
|
10
18
|
var ONE_MEBI_BYTE = 1024 * ONE_KIBI_BYTE; // eslint-disable-next-line no-control-regex
|
|
@@ -23,4 +31,29 @@ function computeBytesCount(candidate) {
|
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
return new Blob([candidate]).size;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function concatBuffers(buffers) {
|
|
37
|
+
var length = buffers.reduce(function (total, buffer) {
|
|
38
|
+
return total + buffer.length;
|
|
39
|
+
}, 0);
|
|
40
|
+
var result = new Uint8Array(length);
|
|
41
|
+
var offset = 0;
|
|
42
|
+
|
|
43
|
+
var _iterator = _createForOfIteratorHelper(buffers),
|
|
44
|
+
_step;
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
48
|
+
var buffer = _step.value;
|
|
49
|
+
result.set(buffer, offset);
|
|
50
|
+
offset += buffer.length;
|
|
51
|
+
}
|
|
52
|
+
} catch (err) {
|
|
53
|
+
_iterator.e(err);
|
|
54
|
+
} finally {
|
|
55
|
+
_iterator.f();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return result;
|
|
26
59
|
}
|
package/cjs/helper/deviceInfo.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.deviceInfo = void 0;
|
|
|
8
8
|
var _display = require("../helper/display");
|
|
9
9
|
|
|
10
10
|
var VariableLibrary = {
|
|
11
|
-
navigator: typeof window.navigator != 'undefined' ? window.navigator : {},
|
|
11
|
+
navigator: typeof window !== 'undefined' && typeof window.navigator != 'undefined' ? window.navigator : {},
|
|
12
12
|
// 信息map
|
|
13
13
|
infoMap: {
|
|
14
14
|
engine: ['WebKit', 'Trident', 'Gecko', 'Presto'],
|
|
@@ -93,7 +93,7 @@ var MethodLibrary = {
|
|
|
93
93
|
},
|
|
94
94
|
// 在信息map和匹配库中进行匹配
|
|
95
95
|
matchInfoMap: function matchInfoMap(_this) {
|
|
96
|
-
var u = VariableLibrary.navigator.userAgent ||
|
|
96
|
+
var u = VariableLibrary.navigator.userAgent || '';
|
|
97
97
|
var match = MethodLibrary.getMatchMap(u);
|
|
98
98
|
|
|
99
99
|
for (var s in VariableLibrary.infoMap) {
|
|
@@ -117,7 +117,7 @@ var MethodLibrary = {
|
|
|
117
117
|
getOSVersion: function getOSVersion() {
|
|
118
118
|
var _this = this;
|
|
119
119
|
|
|
120
|
-
var u = VariableLibrary.navigator.userAgent ||
|
|
120
|
+
var u = VariableLibrary.navigator.userAgent || '';
|
|
121
121
|
_this.osVersion = '';
|
|
122
122
|
_this.osMajor = ''; // 系统版本信息
|
|
123
123
|
|
|
@@ -246,7 +246,7 @@ var MethodLibrary = {
|
|
|
246
246
|
var _this = this;
|
|
247
247
|
|
|
248
248
|
_this.language = function () {
|
|
249
|
-
var language = VariableLibrary.navigator.browserLanguage || VariableLibrary.navigator.language;
|
|
249
|
+
var language = VariableLibrary.navigator.browserLanguage || VariableLibrary.navigator.language || '';
|
|
250
250
|
var arr = language.split('-');
|
|
251
251
|
|
|
252
252
|
if (arr[1]) {
|
|
@@ -263,7 +263,7 @@ var MethodLibrary = {
|
|
|
263
263
|
var _this = this;
|
|
264
264
|
|
|
265
265
|
MethodLibrary.matchInfoMap(_this);
|
|
266
|
-
var u = VariableLibrary.navigator.userAgent ||
|
|
266
|
+
var u = VariableLibrary.navigator.userAgent || '';
|
|
267
267
|
|
|
268
268
|
var _mime = function _mime(option, value) {
|
|
269
269
|
var mimeTypes = VariableLibrary.navigator.mimeTypes;
|
|
@@ -280,7 +280,7 @@ var MethodLibrary = {
|
|
|
280
280
|
var match = MethodLibrary.getMatchMap(u);
|
|
281
281
|
var is360 = false;
|
|
282
282
|
|
|
283
|
-
if (window.chrome) {
|
|
283
|
+
if (typeof window !== 'undefined' && window.chrome) {
|
|
284
284
|
var chrome_version = u.replace(/^.*Chrome\/([\d]+).*$/, '$1');
|
|
285
285
|
|
|
286
286
|
if (chrome_version > 36 && window.showModalDialog) {
|
|
@@ -572,15 +572,21 @@ var MethodLibrary = {
|
|
|
572
572
|
});
|
|
573
573
|
}
|
|
574
574
|
};
|
|
575
|
-
var
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
575
|
+
var _deviceInfo = {};
|
|
576
|
+
|
|
577
|
+
if (typeof window !== 'undefined') {
|
|
578
|
+
_deviceInfo = {
|
|
579
|
+
os: MethodLibrary.getOS(),
|
|
580
|
+
osVersion: MethodLibrary.getOSVersion().version,
|
|
581
|
+
osVersionMajor: MethodLibrary.getOSVersion().osMajor,
|
|
582
|
+
browser: MethodLibrary.getBrowserInfo().browser,
|
|
583
|
+
browserVersion: MethodLibrary.getBrowserInfo().browserVersion,
|
|
584
|
+
browserVersionMajor: MethodLibrary.getBrowserInfo().browserMajor,
|
|
585
|
+
screenSize: window.screen.width + '*' + window.screen.height,
|
|
586
|
+
networkType: MethodLibrary.getNetwork(),
|
|
587
|
+
divice: MethodLibrary.getDeviceType()
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
var deviceInfo = _deviceInfo;
|
|
586
592
|
exports.deviceInfo = deviceInfo;
|
|
@@ -13,7 +13,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symb
|
|
|
13
13
|
|
|
14
14
|
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
15
|
|
|
16
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
16
|
+
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
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Current limitation:
|
package/cjs/helper/tools.js
CHANGED
|
@@ -99,9 +99,7 @@ var ObjProto = Object.prototype;
|
|
|
99
99
|
var slice = ArrayProto.slice;
|
|
100
100
|
var toString = ObjProto.toString;
|
|
101
101
|
var hasOwnProperty = ObjProto.hasOwnProperty;
|
|
102
|
-
var nativeBind = FuncProto.bind;
|
|
103
102
|
var nativeForEach = ArrayProto.forEach;
|
|
104
|
-
var nativeIndexOf = ArrayProto.indexOf;
|
|
105
103
|
var nativeIsArray = Array.isArray;
|
|
106
104
|
var breaker = false;
|
|
107
105
|
|
package/cjs/init.js
CHANGED
|
@@ -54,19 +54,19 @@ function getGlobalObject() {
|
|
|
54
54
|
return globalThis;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
Object.defineProperty(Object.prototype, '
|
|
57
|
+
Object.defineProperty(Object.prototype, '_gc_temp_', {
|
|
58
58
|
get: function get() {
|
|
59
59
|
return this;
|
|
60
60
|
},
|
|
61
61
|
configurable: true
|
|
62
62
|
}); // @ts-ignore
|
|
63
63
|
|
|
64
|
-
var globalObject =
|
|
64
|
+
var globalObject = _gc_temp_; // @ts-ignore
|
|
65
65
|
|
|
66
|
-
delete Object.prototype.
|
|
66
|
+
delete Object.prototype._gc_temp_;
|
|
67
67
|
|
|
68
68
|
if (_typeof(globalObject) !== 'object') {
|
|
69
|
-
// on safari
|
|
69
|
+
// on safari _gc_temp_ is available on window but not globally
|
|
70
70
|
// fallback on other browser globals check
|
|
71
71
|
if ((typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object') {
|
|
72
72
|
globalObject = self;
|
package/cjs/tracekit/tracekit.js
CHANGED
|
@@ -7,10 +7,12 @@ exports.startUnhandledErrorCollection = startUnhandledErrorCollection;
|
|
|
7
7
|
|
|
8
8
|
var _instrumentMethod = require("../helper/instrumentMethod");
|
|
9
9
|
|
|
10
|
+
var _tools = require("../helper/tools");
|
|
11
|
+
|
|
10
12
|
var _computeStackTrace = require("./computeStackTrace");
|
|
11
13
|
|
|
12
14
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types
|
|
13
|
-
var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(
|
|
15
|
+
var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;
|
|
14
16
|
/**
|
|
15
17
|
* Cross-browser collection of unhandled errors
|
|
16
18
|
*
|
|
@@ -63,40 +65,48 @@ function startUnhandledErrorCollection(callback) {
|
|
|
63
65
|
|
|
64
66
|
function instrumentOnError(callback) {
|
|
65
67
|
return (0, _instrumentMethod.instrumentMethodAndCallOriginal)(window, 'onerror', {
|
|
66
|
-
before: function before(
|
|
67
|
-
var
|
|
68
|
+
before: function before(messageObj, url, line, column, errorObj) {
|
|
69
|
+
var stackTrace;
|
|
68
70
|
|
|
69
|
-
if (errorObj) {
|
|
70
|
-
|
|
71
|
-
callback(stack, errorObj);
|
|
71
|
+
if (errorObj instanceof Error) {
|
|
72
|
+
stackTrace = (0, _computeStackTrace.computeStackTrace)(errorObj);
|
|
72
73
|
} else {
|
|
73
74
|
var location = {
|
|
74
75
|
url: url,
|
|
75
|
-
column:
|
|
76
|
-
line:
|
|
76
|
+
column: column,
|
|
77
|
+
line: line
|
|
77
78
|
};
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
var groups = ERROR_TYPES_RE.exec(msg);
|
|
83
|
-
|
|
84
|
-
if (groups) {
|
|
85
|
-
name = groups[1];
|
|
86
|
-
msg = groups[2];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
stack = {
|
|
91
|
-
name: name,
|
|
92
|
-
message: typeof msg === 'string' ? msg : undefined,
|
|
79
|
+
var parse = tryToParseMessage(messageObj);
|
|
80
|
+
stackTrace = {
|
|
81
|
+
name: parse.name,
|
|
82
|
+
message: parse.message,
|
|
93
83
|
stack: [location]
|
|
94
84
|
};
|
|
95
|
-
callback(stack, message);
|
|
96
85
|
}
|
|
86
|
+
|
|
87
|
+
callback(stackTrace, (0, _tools.isNullUndefinedDefaultValue)(errorObj, messageObj));
|
|
97
88
|
}
|
|
98
89
|
});
|
|
99
90
|
}
|
|
91
|
+
|
|
92
|
+
function tryToParseMessage(messageObj) {
|
|
93
|
+
var name;
|
|
94
|
+
var message;
|
|
95
|
+
|
|
96
|
+
if ({}.toString.call(messageObj) === '[object String]') {
|
|
97
|
+
var groups = ERROR_TYPES_RE.exec(messageObj);
|
|
98
|
+
|
|
99
|
+
if (groups) {
|
|
100
|
+
name = groups[1];
|
|
101
|
+
message = groups[2];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
name: name,
|
|
107
|
+
message: message
|
|
108
|
+
};
|
|
109
|
+
}
|
|
100
110
|
/**
|
|
101
111
|
* Install a global onunhandledrejection handler
|
|
102
112
|
*/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.canUseEventBridge = canUseEventBridge;
|
|
7
|
+
exports.getEventBridge = getEventBridge;
|
|
8
|
+
|
|
9
|
+
var _init = require("../init");
|
|
10
|
+
|
|
11
|
+
function getEventBridgeGlobal() {
|
|
12
|
+
return (0, _init.getGlobalObject)().FTWebViewJavascriptBridge;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getEventBridge() {
|
|
16
|
+
var eventBridgeGlobal = getEventBridgeGlobal();
|
|
17
|
+
|
|
18
|
+
if (!eventBridgeGlobal) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
send: function send(eventType, event) {
|
|
24
|
+
eventBridgeGlobal.sendEvent(JSON.stringify({
|
|
25
|
+
name: eventType,
|
|
26
|
+
data: event
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function canUseEventBridge() {
|
|
33
|
+
var bridge = getEventBridge();
|
|
34
|
+
return !!bridge;
|
|
35
|
+
}
|
|
@@ -32,7 +32,7 @@ function createHttpRequest(endpointUrl, bytesLimit, reportError) {
|
|
|
32
32
|
|
|
33
33
|
return {
|
|
34
34
|
send: function send(payload) {
|
|
35
|
-
(0, _sendWithRetryStrategy.sendWithRetryStrategy)(payload, retryState, sendStrategyForRetry, reportError);
|
|
35
|
+
(0, _sendWithRetryStrategy.sendWithRetryStrategy)(payload, retryState, sendStrategyForRetry, endpointUrl, reportError);
|
|
36
36
|
},
|
|
37
37
|
|
|
38
38
|
/**
|
package/cjs/transport/index.js
CHANGED
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "Batch", {
|
|
|
9
9
|
return _batch.Batch;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "canUseEventBridge", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _eventBridge.canUseEventBridge;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(exports, "createFlushController", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
get: function get() {
|
|
@@ -21,6 +27,18 @@ Object.defineProperty(exports, "createHttpRequest", {
|
|
|
21
27
|
return _httpRequest.createHttpRequest;
|
|
22
28
|
}
|
|
23
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "getEventBridge", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _eventBridge.getEventBridge;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "processedMessageByDataMap", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _batch.processedMessageByDataMap;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
24
42
|
Object.defineProperty(exports, "startBatchWithReplica", {
|
|
25
43
|
enumerable: true,
|
|
26
44
|
get: function get() {
|
|
@@ -34,4 +52,6 @@ var _batch = require("./batch");
|
|
|
34
52
|
|
|
35
53
|
var _startBatchWithReplica = require("./startBatchWithReplica");
|
|
36
54
|
|
|
37
|
-
var _flushController = require("./flushController");
|
|
55
|
+
var _flushController = require("./flushController");
|
|
56
|
+
|
|
57
|
+
var _eventBridge = require("./eventBridge");
|
|
@@ -35,15 +35,15 @@ var RetryReason = {
|
|
|
35
35
|
AFTER_RESUME: 1
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
function sendWithRetryStrategy(payload, state, sendStrategy, reportError) {
|
|
38
|
+
function sendWithRetryStrategy(payload, state, sendStrategy, endpointUrl, reportError) {
|
|
39
39
|
if (state.transportStatus === TransportStatus.UP && state.queuedPayloads.size() === 0 && state.bandwidthMonitor.canHandle(payload)) {
|
|
40
40
|
send(payload, state, sendStrategy, {
|
|
41
41
|
onSuccess: function onSuccess() {
|
|
42
|
-
return retryQueuedPayloads(RetryReason.AFTER_SUCCESS, state, sendStrategy, reportError);
|
|
42
|
+
return retryQueuedPayloads(RetryReason.AFTER_SUCCESS, state, sendStrategy, endpointUrl, reportError);
|
|
43
43
|
},
|
|
44
44
|
onFailure: function onFailure() {
|
|
45
45
|
state.queuedPayloads.enqueue(payload);
|
|
46
|
-
scheduleRetry(state, sendStrategy, reportError);
|
|
46
|
+
scheduleRetry(state, sendStrategy, endpointUrl, reportError);
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
} else {
|
|
@@ -51,7 +51,7 @@ function sendWithRetryStrategy(payload, state, sendStrategy, reportError) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
function scheduleRetry(state, sendStrategy, reportError) {
|
|
54
|
+
function scheduleRetry(state, sendStrategy, endpointUrl, reportError) {
|
|
55
55
|
if (state.transportStatus !== TransportStatus.DOWN) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
@@ -67,11 +67,11 @@ function scheduleRetry(state, sendStrategy, reportError) {
|
|
|
67
67
|
// }
|
|
68
68
|
|
|
69
69
|
state.currentBackoffTime = INITIAL_BACKOFF_TIME;
|
|
70
|
-
retryQueuedPayloads(RetryReason.AFTER_RESUME, state, sendStrategy, reportError);
|
|
70
|
+
retryQueuedPayloads(RetryReason.AFTER_RESUME, state, sendStrategy, endpointUrl, reportError);
|
|
71
71
|
},
|
|
72
72
|
onFailure: function onFailure() {
|
|
73
73
|
state.currentBackoffTime = Math.min(MAX_BACKOFF_TIME, state.currentBackoffTime * 2);
|
|
74
|
-
scheduleRetry(state, sendStrategy, reportError);
|
|
74
|
+
scheduleRetry(state, sendStrategy, endpointUrl, reportError);
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
}, state.currentBackoffTime);
|
|
@@ -96,10 +96,10 @@ function send(payload, state, sendStrategy, responseData) {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
function retryQueuedPayloads(reason, state, sendStrategy, reportError) {
|
|
99
|
+
function retryQueuedPayloads(reason, state, sendStrategy, endpointUrl, reportError) {
|
|
100
100
|
if (reason === RetryReason.AFTER_SUCCESS && state.queuedPayloads.isFull() && !state.queueFullReported) {
|
|
101
101
|
reportError({
|
|
102
|
-
message: 'Reached max events size queued for upload: ' + MAX_QUEUE_BYTES_COUNT / _byteUtils.ONE_MEBI_BYTE + 'MiB',
|
|
102
|
+
message: 'Reached max ' + endpointUrl + ' events size queued for upload: ' + MAX_QUEUE_BYTES_COUNT / _byteUtils.ONE_MEBI_BYTE + 'MiB',
|
|
103
103
|
source: _errorTools.ErrorSource.AGENT,
|
|
104
104
|
startClocks: (0, _tools.clocksNow)()
|
|
105
105
|
});
|
|
@@ -110,7 +110,7 @@ function retryQueuedPayloads(reason, state, sendStrategy, reportError) {
|
|
|
110
110
|
state.queuedPayloads = newPayloadQueue();
|
|
111
111
|
|
|
112
112
|
while (previousQueue.size() > 0) {
|
|
113
|
-
sendWithRetryStrategy(previousQueue.dequeue(), state, sendStrategy, reportError);
|
|
113
|
+
sendWithRetryStrategy(previousQueue.dequeue(), state, sendStrategy, endpointUrl, reportError);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
package/cjs/user/user.js
CHANGED
|
@@ -13,7 +13,6 @@ var _tools = require("../helper/tools");
|
|
|
13
13
|
/**
|
|
14
14
|
* Clone input data and ensure known user properties (id, name, email)
|
|
15
15
|
* are strings, as defined here:
|
|
16
|
-
* https://docs.datadoghq.com/logs/log_configuration/attributes_naming_convention/#user-related-attributes
|
|
17
16
|
*/
|
|
18
17
|
function sanitizeUser(newUser) {
|
|
19
18
|
// We shallow clone only to prevent mutation of user data.
|
package/cjs/worker.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "concatBuffers", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _byteUtils.concatBuffers;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _byteUtils = require("./helper/byteUtils");
|
package/esm/dataMap.js
CHANGED
package/esm/helper/byteUtils.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
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; } } }; }
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
1
7
|
export var ONE_KIBI_BYTE = 1024;
|
|
2
8
|
export var ONE_MEBI_BYTE = 1024 * ONE_KIBI_BYTE; // eslint-disable-next-line no-control-regex
|
|
3
9
|
|
|
@@ -13,4 +19,28 @@ export function computeBytesCount(candidate) {
|
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
return new Blob([candidate]).size;
|
|
22
|
+
}
|
|
23
|
+
export function concatBuffers(buffers) {
|
|
24
|
+
var length = buffers.reduce(function (total, buffer) {
|
|
25
|
+
return total + buffer.length;
|
|
26
|
+
}, 0);
|
|
27
|
+
var result = new Uint8Array(length);
|
|
28
|
+
var offset = 0;
|
|
29
|
+
|
|
30
|
+
var _iterator = _createForOfIteratorHelper(buffers),
|
|
31
|
+
_step;
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
35
|
+
var buffer = _step.value;
|
|
36
|
+
result.set(buffer, offset);
|
|
37
|
+
offset += buffer.length;
|
|
38
|
+
}
|
|
39
|
+
} catch (err) {
|
|
40
|
+
_iterator.e(err);
|
|
41
|
+
} finally {
|
|
42
|
+
_iterator.f();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return result;
|
|
16
46
|
}
|
package/esm/helper/deviceInfo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { display } from '../helper/display';
|
|
2
2
|
var VariableLibrary = {
|
|
3
|
-
navigator: typeof window.navigator != 'undefined' ? window.navigator : {},
|
|
3
|
+
navigator: typeof window !== 'undefined' && typeof window.navigator != 'undefined' ? window.navigator : {},
|
|
4
4
|
// 信息map
|
|
5
5
|
infoMap: {
|
|
6
6
|
engine: ['WebKit', 'Trident', 'Gecko', 'Presto'],
|
|
@@ -85,7 +85,7 @@ var MethodLibrary = {
|
|
|
85
85
|
},
|
|
86
86
|
// 在信息map和匹配库中进行匹配
|
|
87
87
|
matchInfoMap: function matchInfoMap(_this) {
|
|
88
|
-
var u = VariableLibrary.navigator.userAgent ||
|
|
88
|
+
var u = VariableLibrary.navigator.userAgent || '';
|
|
89
89
|
var match = MethodLibrary.getMatchMap(u);
|
|
90
90
|
|
|
91
91
|
for (var s in VariableLibrary.infoMap) {
|
|
@@ -109,7 +109,7 @@ var MethodLibrary = {
|
|
|
109
109
|
getOSVersion: function getOSVersion() {
|
|
110
110
|
var _this = this;
|
|
111
111
|
|
|
112
|
-
var u = VariableLibrary.navigator.userAgent ||
|
|
112
|
+
var u = VariableLibrary.navigator.userAgent || '';
|
|
113
113
|
_this.osVersion = '';
|
|
114
114
|
_this.osMajor = ''; // 系统版本信息
|
|
115
115
|
|
|
@@ -238,7 +238,7 @@ var MethodLibrary = {
|
|
|
238
238
|
var _this = this;
|
|
239
239
|
|
|
240
240
|
_this.language = function () {
|
|
241
|
-
var language = VariableLibrary.navigator.browserLanguage || VariableLibrary.navigator.language;
|
|
241
|
+
var language = VariableLibrary.navigator.browserLanguage || VariableLibrary.navigator.language || '';
|
|
242
242
|
var arr = language.split('-');
|
|
243
243
|
|
|
244
244
|
if (arr[1]) {
|
|
@@ -255,7 +255,7 @@ var MethodLibrary = {
|
|
|
255
255
|
var _this = this;
|
|
256
256
|
|
|
257
257
|
MethodLibrary.matchInfoMap(_this);
|
|
258
|
-
var u = VariableLibrary.navigator.userAgent ||
|
|
258
|
+
var u = VariableLibrary.navigator.userAgent || '';
|
|
259
259
|
|
|
260
260
|
var _mime = function _mime(option, value) {
|
|
261
261
|
var mimeTypes = VariableLibrary.navigator.mimeTypes;
|
|
@@ -272,7 +272,7 @@ var MethodLibrary = {
|
|
|
272
272
|
var match = MethodLibrary.getMatchMap(u);
|
|
273
273
|
var is360 = false;
|
|
274
274
|
|
|
275
|
-
if (window.chrome) {
|
|
275
|
+
if (typeof window !== 'undefined' && window.chrome) {
|
|
276
276
|
var chrome_version = u.replace(/^.*Chrome\/([\d]+).*$/, '$1');
|
|
277
277
|
|
|
278
278
|
if (chrome_version > 36 && window.showModalDialog) {
|
|
@@ -564,14 +564,20 @@ var MethodLibrary = {
|
|
|
564
564
|
});
|
|
565
565
|
}
|
|
566
566
|
};
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
567
|
+
var _deviceInfo = {};
|
|
568
|
+
|
|
569
|
+
if (typeof window !== 'undefined') {
|
|
570
|
+
_deviceInfo = {
|
|
571
|
+
os: MethodLibrary.getOS(),
|
|
572
|
+
osVersion: MethodLibrary.getOSVersion().version,
|
|
573
|
+
osVersionMajor: MethodLibrary.getOSVersion().osMajor,
|
|
574
|
+
browser: MethodLibrary.getBrowserInfo().browser,
|
|
575
|
+
browserVersion: MethodLibrary.getBrowserInfo().browserVersion,
|
|
576
|
+
browserVersionMajor: MethodLibrary.getBrowserInfo().browserMajor,
|
|
577
|
+
screenSize: window.screen.width + '*' + window.screen.height,
|
|
578
|
+
networkType: MethodLibrary.getNetwork(),
|
|
579
|
+
divice: MethodLibrary.getDeviceType()
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
export var deviceInfo = _deviceInfo;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
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; } } }; }
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
1
7
|
import { extend2Lev, each, objectEntries, getType, deepClone } from './tools';
|
|
2
8
|
import { sanitize } from './sanitize';
|
|
3
9
|
/**
|
|
@@ -26,12 +32,23 @@ export function limitModification(object, modifiableFieldPaths, modifier) {
|
|
|
26
32
|
function get(object, path) {
|
|
27
33
|
var current = object;
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
35
|
+
var _iterator = _createForOfIteratorHelper(path.split('.')),
|
|
36
|
+
_step;
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
try {
|
|
39
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
40
|
+
var field = _step.value;
|
|
41
|
+
|
|
42
|
+
if (!isValidObjectContaining(current, field)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
current = current[field];
|
|
47
|
+
}
|
|
48
|
+
} catch (err) {
|
|
49
|
+
_iterator.e(err);
|
|
50
|
+
} finally {
|
|
51
|
+
_iterator.f();
|
|
35
52
|
}
|
|
36
53
|
|
|
37
54
|
return current;
|
|
@@ -35,7 +35,7 @@ export function readBytesFromStream(stream, callback, options) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function onDone() {
|
|
38
|
-
reader.cancel()
|
|
38
|
+
reader.cancel()["catch"]( // we don't care if cancel fails, but we still need to catch the error to avoid reporting it
|
|
39
39
|
// as an unhandled rejection
|
|
40
40
|
noop);
|
|
41
41
|
var bytes;
|
package/esm/helper/sanitize.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
|
|
1
3
|
import { display } from './display';
|
|
2
4
|
import { ONE_KIBI_BYTE } from './byteUtils';
|
|
3
5
|
import { detachToJsonMethod } from './serialisation/jsonStringify'; // The maximum size of a single event is 256KiB. By default, we ensure that user-provided data
|
|
@@ -108,7 +110,7 @@ function sanitizeProcessor(source, parentPath, key, queue, visitedObjectsWithPat
|
|
|
108
110
|
// Start by handling toJSON, as we want to sanitize its output
|
|
109
111
|
var sourceToSanitize = tryToApplyToJSON(source);
|
|
110
112
|
|
|
111
|
-
if (!sourceToSanitize ||
|
|
113
|
+
if (!sourceToSanitize || _typeof(sourceToSanitize) !== 'object') {
|
|
112
114
|
return sanitizePrimitivesAndFunctions(sourceToSanitize);
|
|
113
115
|
}
|
|
114
116
|
|
|
@@ -133,7 +135,7 @@ function sanitizeProcessor(source, parentPath, key, queue, visitedObjectsWithPat
|
|
|
133
135
|
visitedObjectsWithPath.set(sourceAsObject, currentPath);
|
|
134
136
|
queue.push({
|
|
135
137
|
source: sourceToSanitize,
|
|
136
|
-
target,
|
|
138
|
+
target: target,
|
|
137
139
|
path: currentPath
|
|
138
140
|
});
|
|
139
141
|
return target;
|
|
@@ -157,7 +159,7 @@ function sanitizePrimitivesAndFunctions(value) {
|
|
|
157
159
|
} // JSON.stringify() does not serialize symbols.
|
|
158
160
|
|
|
159
161
|
|
|
160
|
-
if (
|
|
162
|
+
if (_typeof(value) === 'symbol') {
|
|
161
163
|
// symbol.description is part of ES2019+
|
|
162
164
|
return '[Symbol] ' + value.description || value.toString();
|
|
163
165
|
}
|