@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
|
@@ -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 { noop } from '../tools';
|
|
2
4
|
/**
|
|
3
5
|
* Custom implementation of JSON.stringify that ignores some toJSON methods. We need to do that
|
|
@@ -9,7 +11,7 @@ import { noop } from '../tools';
|
|
|
9
11
|
*/
|
|
10
12
|
|
|
11
13
|
export function jsonStringify(value, replacer, space) {
|
|
12
|
-
if (
|
|
14
|
+
if (_typeof(value) !== 'object' || value === null) {
|
|
13
15
|
return JSON.stringify(value);
|
|
14
16
|
} // Note: The order matter here. We need to detach toJSON methods on parent classes before their
|
|
15
17
|
// subclasses.
|
|
@@ -37,7 +39,7 @@ export function detachToJsonMethod(value) {
|
|
|
37
39
|
|
|
38
40
|
if (objectToJson) {
|
|
39
41
|
delete object.toJSON;
|
|
40
|
-
return ()
|
|
42
|
+
return function () {
|
|
41
43
|
object.toJSON = objectToJson;
|
|
42
44
|
};
|
|
43
45
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
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 { jsonStringify } from './jsonStringify';
|
|
2
4
|
import { isString } from '../tools';
|
|
3
5
|
export function escapeRowData(str) {
|
|
4
|
-
if (
|
|
6
|
+
if (_typeof(str) === 'object' && str) {
|
|
5
7
|
str = jsonStringify(str);
|
|
6
8
|
} else if (!isString(str)) {
|
|
7
9
|
return str;
|
|
@@ -23,7 +25,7 @@ export function escapeFieldValueStr(str) {
|
|
|
23
25
|
return '"' + str.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
|
|
24
26
|
}
|
|
25
27
|
export function escapeRowField(value) {
|
|
26
|
-
if (
|
|
28
|
+
if (_typeof(value) === 'object' && value) {
|
|
27
29
|
return escapeFieldValueStr(jsonStringify(value));
|
|
28
30
|
} else if (isString(value)) {
|
|
29
31
|
return escapeFieldValueStr(value);
|
package/esm/helper/tools.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 { setTimeout, clearTimeout } from './timer';
|
|
3
5
|
var ArrayProto = Array.prototype;
|
|
@@ -6,9 +8,7 @@ var ObjProto = Object.prototype;
|
|
|
6
8
|
var slice = ArrayProto.slice;
|
|
7
9
|
var toString = ObjProto.toString;
|
|
8
10
|
var hasOwnProperty = ObjProto.hasOwnProperty;
|
|
9
|
-
var nativeBind = FuncProto.bind;
|
|
10
11
|
var nativeForEach = ArrayProto.forEach;
|
|
11
|
-
var nativeIndexOf = ArrayProto.indexOf;
|
|
12
12
|
var nativeIsArray = Array.isArray;
|
|
13
13
|
var breaker = false;
|
|
14
14
|
export var each = function each(obj, iterator, context) {
|
|
@@ -272,7 +272,7 @@ export var cssEscape = function cssEscape(str) {
|
|
|
272
272
|
if (asCodePoint) {
|
|
273
273
|
// U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
|
|
274
274
|
if (ch === '\0') {
|
|
275
|
-
return
|
|
275
|
+
return "\uFFFD";
|
|
276
276
|
} // Control characters and (dependent upon position) numbers get escaped as code points
|
|
277
277
|
|
|
278
278
|
|
|
@@ -445,15 +445,15 @@ export var hashCode = function hashCode(str) {
|
|
|
445
445
|
}
|
|
446
446
|
|
|
447
447
|
var hash = 0;
|
|
448
|
-
var
|
|
448
|
+
var _char = null;
|
|
449
449
|
|
|
450
450
|
if (str.length == 0) {
|
|
451
451
|
return hash;
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
for (var i = 0; i < str.length; i++) {
|
|
455
|
-
|
|
456
|
-
hash = (hash << 5) - hash +
|
|
455
|
+
_char = str.charCodeAt(i);
|
|
456
|
+
hash = (hash << 5) - hash + _char;
|
|
457
457
|
hash = hash & hash;
|
|
458
458
|
}
|
|
459
459
|
|
|
@@ -689,7 +689,7 @@ export var urlParse = function urlParse(para) {
|
|
|
689
689
|
};
|
|
690
690
|
|
|
691
691
|
URLParser.prototype.addQueryString = function (queryObj) {
|
|
692
|
-
if (
|
|
692
|
+
if (_typeof(queryObj) !== 'object') {
|
|
693
693
|
return false;
|
|
694
694
|
}
|
|
695
695
|
|
|
@@ -944,7 +944,7 @@ export var ajax = function ajax(para) {
|
|
|
944
944
|
}, para);
|
|
945
945
|
|
|
946
946
|
try {
|
|
947
|
-
if (
|
|
947
|
+
if (_typeof(g) === 'object' && 'timeout' in g) {
|
|
948
948
|
g.timeout = para.timeout;
|
|
949
949
|
} else {
|
|
950
950
|
setTimeout(function () {
|
|
@@ -1134,7 +1134,7 @@ export function getType(value) {
|
|
|
1134
1134
|
return 'array';
|
|
1135
1135
|
}
|
|
1136
1136
|
|
|
1137
|
-
return
|
|
1137
|
+
return _typeof(value);
|
|
1138
1138
|
}
|
|
1139
1139
|
/**
|
|
1140
1140
|
* Iterate over source and affect its sub values into destination, recursively.
|
|
@@ -1151,7 +1151,7 @@ export function mergeInto(destination, source, circularReferenceChecker) {
|
|
|
1151
1151
|
return destination;
|
|
1152
1152
|
}
|
|
1153
1153
|
|
|
1154
|
-
if (
|
|
1154
|
+
if (_typeof(source) !== 'object' || source === null) {
|
|
1155
1155
|
// primitive values - just return source
|
|
1156
1156
|
return source;
|
|
1157
1157
|
} else if (source instanceof Date) {
|
|
@@ -1360,7 +1360,7 @@ export var strip_sa_properties = function strip_sa_properties(p) {
|
|
|
1360
1360
|
return p;
|
|
1361
1361
|
};
|
|
1362
1362
|
export var searchConfigData = function searchConfigData(data) {
|
|
1363
|
-
if (
|
|
1363
|
+
if (_typeof(data) === 'object' && data.$option) {
|
|
1364
1364
|
var data_config = data.$option;
|
|
1365
1365
|
delete data.$option;
|
|
1366
1366
|
return data_config;
|
|
@@ -1646,7 +1646,7 @@ export function deepSnakeCase(candidate) {
|
|
|
1646
1646
|
});
|
|
1647
1647
|
}
|
|
1648
1648
|
|
|
1649
|
-
if (
|
|
1649
|
+
if (_typeof(candidate) === 'object' && candidate !== null) {
|
|
1650
1650
|
return withSnakeCaseKeys(candidate);
|
|
1651
1651
|
}
|
|
1652
1652
|
|
package/esm/init.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 { extend, each } from './helper/tools';
|
|
2
4
|
export function makeGlobal(stub) {
|
|
3
5
|
var global = extend({}, stub, {
|
|
@@ -34,27 +36,27 @@ export function defineGlobal(global, name, api) {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
export function getGlobalObject() {
|
|
37
|
-
if (typeof globalThis === 'object') {
|
|
39
|
+
if ((typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) === 'object') {
|
|
38
40
|
return globalThis;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
Object.defineProperty(Object.prototype, '
|
|
43
|
+
Object.defineProperty(Object.prototype, '_gc_temp_', {
|
|
42
44
|
get: function get() {
|
|
43
45
|
return this;
|
|
44
46
|
},
|
|
45
47
|
configurable: true
|
|
46
48
|
}); // @ts-ignore
|
|
47
49
|
|
|
48
|
-
var globalObject =
|
|
50
|
+
var globalObject = _gc_temp_; // @ts-ignore
|
|
49
51
|
|
|
50
|
-
delete Object.prototype.
|
|
52
|
+
delete Object.prototype._gc_temp_;
|
|
51
53
|
|
|
52
|
-
if (
|
|
53
|
-
// on safari
|
|
54
|
+
if (_typeof(globalObject) !== 'object') {
|
|
55
|
+
// on safari _gc_temp_ is available on window but not globally
|
|
54
56
|
// fallback on other browser globals check
|
|
55
|
-
if (typeof self === 'object') {
|
|
57
|
+
if ((typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object') {
|
|
56
58
|
globalObject = self;
|
|
57
|
-
} else if (typeof window === 'object') {
|
|
59
|
+
} else if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object') {
|
|
58
60
|
globalObject = window;
|
|
59
61
|
} else {
|
|
60
62
|
globalObject = {};
|
|
@@ -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 { each } from '../helper/tools';
|
|
2
4
|
var UNKNOWN_FUNCTION = '?';
|
|
3
5
|
/**
|
|
@@ -130,7 +132,7 @@ function parseGeckoLine(line) {
|
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
function tryToGetString(candidate, property) {
|
|
133
|
-
if (
|
|
135
|
+
if (_typeof(candidate) !== 'object' || !candidate || !(property in candidate)) {
|
|
134
136
|
return undefined;
|
|
135
137
|
}
|
|
136
138
|
|
package/esm/tracekit/tracekit.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { instrumentMethodAndCallOriginal } from '../helper/instrumentMethod';
|
|
2
|
+
import { isNullUndefinedDefaultValue } from '../helper/tools';
|
|
2
3
|
import { computeStackTrace } from './computeStackTrace'; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Error_types
|
|
3
4
|
|
|
4
|
-
var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(
|
|
5
|
+
var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;
|
|
5
6
|
/**
|
|
6
7
|
* Cross-browser collection of unhandled errors
|
|
7
8
|
*
|
|
@@ -53,40 +54,48 @@ export function startUnhandledErrorCollection(callback) {
|
|
|
53
54
|
|
|
54
55
|
function instrumentOnError(callback) {
|
|
55
56
|
return instrumentMethodAndCallOriginal(window, 'onerror', {
|
|
56
|
-
before: function before(
|
|
57
|
-
var
|
|
57
|
+
before: function before(messageObj, url, line, column, errorObj) {
|
|
58
|
+
var stackTrace;
|
|
58
59
|
|
|
59
|
-
if (errorObj) {
|
|
60
|
-
|
|
61
|
-
callback(stack, errorObj);
|
|
60
|
+
if (errorObj instanceof Error) {
|
|
61
|
+
stackTrace = computeStackTrace(errorObj);
|
|
62
62
|
} else {
|
|
63
63
|
var location = {
|
|
64
64
|
url: url,
|
|
65
|
-
column:
|
|
66
|
-
line:
|
|
65
|
+
column: column,
|
|
66
|
+
line: line
|
|
67
67
|
};
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var groups = ERROR_TYPES_RE.exec(msg);
|
|
73
|
-
|
|
74
|
-
if (groups) {
|
|
75
|
-
name = groups[1];
|
|
76
|
-
msg = groups[2];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
stack = {
|
|
81
|
-
name: name,
|
|
82
|
-
message: typeof msg === 'string' ? msg : undefined,
|
|
68
|
+
var parse = tryToParseMessage(messageObj);
|
|
69
|
+
stackTrace = {
|
|
70
|
+
name: parse.name,
|
|
71
|
+
message: parse.message,
|
|
83
72
|
stack: [location]
|
|
84
73
|
};
|
|
85
|
-
callback(stack, message);
|
|
86
74
|
}
|
|
75
|
+
|
|
76
|
+
callback(stackTrace, isNullUndefinedDefaultValue(errorObj, messageObj));
|
|
87
77
|
}
|
|
88
78
|
});
|
|
89
79
|
}
|
|
80
|
+
|
|
81
|
+
function tryToParseMessage(messageObj) {
|
|
82
|
+
var name;
|
|
83
|
+
var message;
|
|
84
|
+
|
|
85
|
+
if ({}.toString.call(messageObj) === '[object String]') {
|
|
86
|
+
var groups = ERROR_TYPES_RE.exec(messageObj);
|
|
87
|
+
|
|
88
|
+
if (groups) {
|
|
89
|
+
name = groups[1];
|
|
90
|
+
message = groups[2];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
name: name,
|
|
96
|
+
message: message
|
|
97
|
+
};
|
|
98
|
+
}
|
|
90
99
|
/**
|
|
91
100
|
* Install a global onunhandledrejection handler
|
|
92
101
|
*/
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getGlobalObject } from '../init';
|
|
2
|
+
|
|
3
|
+
function getEventBridgeGlobal() {
|
|
4
|
+
return getGlobalObject().FTWebViewJavascriptBridge;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function getEventBridge() {
|
|
8
|
+
var eventBridgeGlobal = getEventBridgeGlobal();
|
|
9
|
+
|
|
10
|
+
if (!eventBridgeGlobal) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
send: function send(eventType, event) {
|
|
16
|
+
eventBridgeGlobal.sendEvent(JSON.stringify({
|
|
17
|
+
name: eventType,
|
|
18
|
+
data: event
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function canUseEventBridge() {
|
|
24
|
+
var bridge = getEventBridge();
|
|
25
|
+
return !!bridge;
|
|
26
|
+
}
|
|
@@ -8,13 +8,11 @@ import { clearTimeout, setTimeout } from '../helper/timer'; // type FlushReason
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export function createFlushController(_ref) {
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
sessionExpireObservable
|
|
17
|
-
} = _ref;
|
|
11
|
+
var messagesLimit = _ref.messagesLimit,
|
|
12
|
+
bytesLimit = _ref.bytesLimit,
|
|
13
|
+
durationLimit = _ref.durationLimit,
|
|
14
|
+
pageExitObservable = _ref.pageExitObservable,
|
|
15
|
+
sessionExpireObservable = _ref.sessionExpireObservable;
|
|
18
16
|
var flushObservable = new Observable();
|
|
19
17
|
pageExitObservable.subscribe(function (event) {
|
|
20
18
|
return flush(event.reason);
|
|
@@ -23,7 +23,7 @@ export function createHttpRequest(endpointUrl, bytesLimit, reportError) {
|
|
|
23
23
|
|
|
24
24
|
return {
|
|
25
25
|
send: function send(payload) {
|
|
26
|
-
sendWithRetryStrategy(payload, retryState, sendStrategyForRetry, reportError);
|
|
26
|
+
sendWithRetryStrategy(payload, retryState, sendStrategyForRetry, endpointUrl, reportError);
|
|
27
27
|
},
|
|
28
28
|
|
|
29
29
|
/**
|
package/esm/transport/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createHttpRequest } from './httpRequest';
|
|
2
|
-
export { Batch } from './batch';
|
|
2
|
+
export { Batch, processedMessageByDataMap } from './batch';
|
|
3
3
|
export { startBatchWithReplica } from './startBatchWithReplica';
|
|
4
|
-
export { createFlushController } from './flushController';
|
|
4
|
+
export { createFlushController } from './flushController';
|
|
5
|
+
export { getEventBridge, canUseEventBridge } from './eventBridge';
|
|
@@ -16,15 +16,15 @@ var RetryReason = {
|
|
|
16
16
|
AFTER_SUCCESS: 0,
|
|
17
17
|
AFTER_RESUME: 1
|
|
18
18
|
};
|
|
19
|
-
export function sendWithRetryStrategy(payload, state, sendStrategy, reportError) {
|
|
19
|
+
export function sendWithRetryStrategy(payload, state, sendStrategy, endpointUrl, reportError) {
|
|
20
20
|
if (state.transportStatus === TransportStatus.UP && state.queuedPayloads.size() === 0 && state.bandwidthMonitor.canHandle(payload)) {
|
|
21
21
|
send(payload, state, sendStrategy, {
|
|
22
22
|
onSuccess: function onSuccess() {
|
|
23
|
-
return retryQueuedPayloads(RetryReason.AFTER_SUCCESS, state, sendStrategy, reportError);
|
|
23
|
+
return retryQueuedPayloads(RetryReason.AFTER_SUCCESS, state, sendStrategy, endpointUrl, reportError);
|
|
24
24
|
},
|
|
25
25
|
onFailure: function onFailure() {
|
|
26
26
|
state.queuedPayloads.enqueue(payload);
|
|
27
|
-
scheduleRetry(state, sendStrategy, reportError);
|
|
27
|
+
scheduleRetry(state, sendStrategy, endpointUrl, reportError);
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
} else {
|
|
@@ -32,7 +32,7 @@ export function sendWithRetryStrategy(payload, state, sendStrategy, reportError)
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function scheduleRetry(state, sendStrategy, reportError) {
|
|
35
|
+
function scheduleRetry(state, sendStrategy, endpointUrl, reportError) {
|
|
36
36
|
if (state.transportStatus !== TransportStatus.DOWN) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
@@ -48,11 +48,11 @@ function scheduleRetry(state, sendStrategy, reportError) {
|
|
|
48
48
|
// }
|
|
49
49
|
|
|
50
50
|
state.currentBackoffTime = INITIAL_BACKOFF_TIME;
|
|
51
|
-
retryQueuedPayloads(RetryReason.AFTER_RESUME, state, sendStrategy, reportError);
|
|
51
|
+
retryQueuedPayloads(RetryReason.AFTER_RESUME, state, sendStrategy, endpointUrl, reportError);
|
|
52
52
|
},
|
|
53
53
|
onFailure: function onFailure() {
|
|
54
54
|
state.currentBackoffTime = Math.min(MAX_BACKOFF_TIME, state.currentBackoffTime * 2);
|
|
55
|
-
scheduleRetry(state, sendStrategy, reportError);
|
|
55
|
+
scheduleRetry(state, sendStrategy, endpointUrl, reportError);
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
}, state.currentBackoffTime);
|
|
@@ -77,10 +77,10 @@ function send(payload, state, sendStrategy, responseData) {
|
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function retryQueuedPayloads(reason, state, sendStrategy, reportError) {
|
|
80
|
+
function retryQueuedPayloads(reason, state, sendStrategy, endpointUrl, reportError) {
|
|
81
81
|
if (reason === RetryReason.AFTER_SUCCESS && state.queuedPayloads.isFull() && !state.queueFullReported) {
|
|
82
82
|
reportError({
|
|
83
|
-
message: 'Reached max events size queued for upload: ' + MAX_QUEUE_BYTES_COUNT / ONE_MEBI_BYTE + 'MiB',
|
|
83
|
+
message: 'Reached max ' + endpointUrl + ' events size queued for upload: ' + MAX_QUEUE_BYTES_COUNT / ONE_MEBI_BYTE + 'MiB',
|
|
84
84
|
source: ErrorSource.AGENT,
|
|
85
85
|
startClocks: clocksNow()
|
|
86
86
|
});
|
|
@@ -91,7 +91,7 @@ function retryQueuedPayloads(reason, state, sendStrategy, reportError) {
|
|
|
91
91
|
state.queuedPayloads = newPayloadQueue();
|
|
92
92
|
|
|
93
93
|
while (previousQueue.size() > 0) {
|
|
94
|
-
sendWithRetryStrategy(previousQueue.dequeue(), state, sendStrategy, reportError);
|
|
94
|
+
sendWithRetryStrategy(previousQueue.dequeue(), state, sendStrategy, endpointUrl, reportError);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
package/esm/user/user.js
CHANGED
|
@@ -3,7 +3,6 @@ import { assign, getType, each } from '../helper/tools';
|
|
|
3
3
|
/**
|
|
4
4
|
* Clone input data and ensure known user properties (id, name, email)
|
|
5
5
|
* are strings, as defined here:
|
|
6
|
-
* https://docs.datadoghq.com/logs/log_configuration/attributes_naming_convention/#user-related-attributes
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
export function sanitizeUser(newUser) {
|
package/esm/worker.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { concatBuffers } from './helper/byteUtils';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcare/browser-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.22",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"author": "dataflux",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"description": "DataFlux RUM Web 端数据指标监控",
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "c42f3cdce8c9f1af6ac6bec06c7a7e83a9638467"
|
|
24
24
|
}
|
package/src/dataMap.js
CHANGED
package/src/helper/byteUtils.js
CHANGED
|
@@ -15,3 +15,15 @@ export function computeBytesCount(candidate) {
|
|
|
15
15
|
|
|
16
16
|
return new Blob([candidate]).size
|
|
17
17
|
}
|
|
18
|
+
export function concatBuffers(buffers) {
|
|
19
|
+
var length = buffers.reduce(function (total, buffer) {
|
|
20
|
+
return total + buffer.length
|
|
21
|
+
}, 0)
|
|
22
|
+
var result = new Uint8Array(length)
|
|
23
|
+
var offset = 0
|
|
24
|
+
for (var buffer of buffers) {
|
|
25
|
+
result.set(buffer, offset)
|
|
26
|
+
offset += buffer.length
|
|
27
|
+
}
|
|
28
|
+
return result
|
|
29
|
+
}
|
package/src/helper/deviceInfo.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { display } from '../helper/display'
|
|
2
2
|
var VariableLibrary = {
|
|
3
|
-
navigator:
|
|
3
|
+
navigator:
|
|
4
|
+
typeof window !== 'undefined' && typeof window.navigator != 'undefined'
|
|
5
|
+
? window.navigator
|
|
6
|
+
: {},
|
|
4
7
|
// 信息map
|
|
5
8
|
infoMap: {
|
|
6
9
|
engine: ['WebKit', 'Trident', 'Gecko', 'Presto'],
|
|
@@ -154,7 +157,7 @@ var MethodLibrary = {
|
|
|
154
157
|
},
|
|
155
158
|
// 在信息map和匹配库中进行匹配
|
|
156
159
|
matchInfoMap: function (_this) {
|
|
157
|
-
var u = VariableLibrary.navigator.userAgent ||
|
|
160
|
+
var u = VariableLibrary.navigator.userAgent || ''
|
|
158
161
|
var match = MethodLibrary.getMatchMap(u)
|
|
159
162
|
for (var s in VariableLibrary.infoMap) {
|
|
160
163
|
for (var i = 0; i < VariableLibrary.infoMap[s].length; i++) {
|
|
@@ -174,7 +177,7 @@ var MethodLibrary = {
|
|
|
174
177
|
// 获取操作系统版本
|
|
175
178
|
getOSVersion: function () {
|
|
176
179
|
var _this = this
|
|
177
|
-
var u = VariableLibrary.navigator.userAgent ||
|
|
180
|
+
var u = VariableLibrary.navigator.userAgent || ''
|
|
178
181
|
_this.osVersion = ''
|
|
179
182
|
_this.osMajor = ''
|
|
180
183
|
// 系统版本信息
|
|
@@ -293,7 +296,8 @@ var MethodLibrary = {
|
|
|
293
296
|
_this.language = (function () {
|
|
294
297
|
var language =
|
|
295
298
|
VariableLibrary.navigator.browserLanguage ||
|
|
296
|
-
VariableLibrary.navigator.language
|
|
299
|
+
VariableLibrary.navigator.language ||
|
|
300
|
+
''
|
|
297
301
|
var arr = language.split('-')
|
|
298
302
|
if (arr[1]) {
|
|
299
303
|
arr[1] = arr[1].toUpperCase()
|
|
@@ -307,7 +311,7 @@ var MethodLibrary = {
|
|
|
307
311
|
var _this = this
|
|
308
312
|
MethodLibrary.matchInfoMap(_this)
|
|
309
313
|
|
|
310
|
-
var u = VariableLibrary.navigator.userAgent ||
|
|
314
|
+
var u = VariableLibrary.navigator.userAgent || ''
|
|
311
315
|
|
|
312
316
|
var _mime = function (option, value) {
|
|
313
317
|
var mimeTypes = VariableLibrary.navigator.mimeTypes
|
|
@@ -322,7 +326,7 @@ var MethodLibrary = {
|
|
|
322
326
|
var match = MethodLibrary.getMatchMap(u)
|
|
323
327
|
|
|
324
328
|
var is360 = false
|
|
325
|
-
if (window.chrome) {
|
|
329
|
+
if (typeof window !== 'undefined' && window.chrome) {
|
|
326
330
|
var chrome_version = u.replace(/^.*Chrome\/([\d]+).*$/, '$1')
|
|
327
331
|
if (chrome_version > 36 && window.showModalDialog) {
|
|
328
332
|
is360 = true
|
|
@@ -602,15 +606,18 @@ var MethodLibrary = {
|
|
|
602
606
|
)
|
|
603
607
|
}
|
|
604
608
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
609
|
+
var _deviceInfo = {}
|
|
610
|
+
if (typeof window !== 'undefined') {
|
|
611
|
+
_deviceInfo = {
|
|
612
|
+
os: MethodLibrary.getOS(),
|
|
613
|
+
osVersion: MethodLibrary.getOSVersion().version,
|
|
614
|
+
osVersionMajor: MethodLibrary.getOSVersion().osMajor,
|
|
615
|
+
browser: MethodLibrary.getBrowserInfo().browser,
|
|
616
|
+
browserVersion: MethodLibrary.getBrowserInfo().browserVersion,
|
|
617
|
+
browserVersionMajor: MethodLibrary.getBrowserInfo().browserMajor,
|
|
618
|
+
screenSize: window.screen.width + '*' + window.screen.height,
|
|
619
|
+
networkType: MethodLibrary.getNetwork(),
|
|
620
|
+
divice: MethodLibrary.getDeviceType()
|
|
621
|
+
}
|
|
616
622
|
}
|
|
623
|
+
export var deviceInfo = _deviceInfo
|
package/src/helper/tools.js
CHANGED
|
@@ -6,9 +6,7 @@ var ObjProto = Object.prototype
|
|
|
6
6
|
var slice = ArrayProto.slice
|
|
7
7
|
var toString = ObjProto.toString
|
|
8
8
|
var hasOwnProperty = ObjProto.hasOwnProperty
|
|
9
|
-
var nativeBind = FuncProto.bind
|
|
10
9
|
var nativeForEach = ArrayProto.forEach
|
|
11
|
-
var nativeIndexOf = ArrayProto.indexOf
|
|
12
10
|
var nativeIsArray = Array.isArray
|
|
13
11
|
var breaker = false
|
|
14
12
|
export var each = function (obj, iterator, context) {
|
package/src/init.js
CHANGED
|
@@ -39,18 +39,18 @@ export function getGlobalObject() {
|
|
|
39
39
|
if (typeof globalThis === 'object') {
|
|
40
40
|
return globalThis
|
|
41
41
|
}
|
|
42
|
-
Object.defineProperty(Object.prototype, '
|
|
42
|
+
Object.defineProperty(Object.prototype, '_gc_temp_', {
|
|
43
43
|
get: function () {
|
|
44
44
|
return this
|
|
45
45
|
},
|
|
46
46
|
configurable: true
|
|
47
47
|
})
|
|
48
48
|
// @ts-ignore
|
|
49
|
-
var globalObject =
|
|
49
|
+
var globalObject = _gc_temp_
|
|
50
50
|
// @ts-ignore
|
|
51
|
-
delete Object.prototype.
|
|
51
|
+
delete Object.prototype._gc_temp_
|
|
52
52
|
if (typeof globalObject !== 'object') {
|
|
53
|
-
// on safari
|
|
53
|
+
// on safari _gc_temp_ is available on window but not globally
|
|
54
54
|
// fallback on other browser globals check
|
|
55
55
|
if (typeof self === 'object') {
|
|
56
56
|
globalObject = self
|