@cloudcare/browser-core 2.0.18 → 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 CHANGED
@@ -79,6 +79,7 @@ var dataMap = {
79
79
  dom: 'view.dom',
80
80
  dom_ready: 'view.dom_ready',
81
81
  time_spent: 'view.time_spent',
82
+ first_byte: 'view.first_byte',
82
83
  in_foreground_periods: 'view.in_foreground_periods',
83
84
  frustration_count: 'view.frustration.count'
84
85
  }
@@ -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
  }
@@ -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 deviceInfo = {
576
- os: MethodLibrary.getOS(),
577
- osVersion: MethodLibrary.getOSVersion().version,
578
- osVersionMajor: MethodLibrary.getOSVersion().osMajor,
579
- browser: MethodLibrary.getBrowserInfo().browser,
580
- browserVersion: MethodLibrary.getBrowserInfo().browserVersion,
581
- browserVersionMajor: MethodLibrary.getBrowserInfo().browserMajor,
582
- screenSize: window.screen.width + '*' + window.screen.height,
583
- networkType: MethodLibrary.getNetwork(),
584
- divice: MethodLibrary.getDeviceType()
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++) { arr2[i] = arr[i]; } return arr2; }
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:
@@ -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
 
@@ -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
  /**
@@ -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
@@ -69,6 +69,7 @@ export var dataMap = {
69
69
  dom: 'view.dom',
70
70
  dom_ready: 'view.dom_ready',
71
71
  time_spent: 'view.time_spent',
72
+ first_byte: 'view.first_byte',
72
73
  in_foreground_periods: 'view.in_foreground_periods',
73
74
  frustration_count: 'view.frustration.count'
74
75
  }
@@ -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
  }
@@ -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
- export var deviceInfo = {
568
- os: MethodLibrary.getOS(),
569
- osVersion: MethodLibrary.getOSVersion().version,
570
- osVersionMajor: MethodLibrary.getOSVersion().osMajor,
571
- browser: MethodLibrary.getBrowserInfo().browser,
572
- browserVersion: MethodLibrary.getBrowserInfo().browserVersion,
573
- browserVersionMajor: MethodLibrary.getBrowserInfo().browserMajor,
574
- screenSize: window.screen.width + '*' + window.screen.height,
575
- networkType: MethodLibrary.getNetwork(),
576
- divice: MethodLibrary.getDeviceType()
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
- for (var field of path.split('.')) {
30
- if (!isValidObjectContaining(current, field)) {
31
- return;
32
- }
35
+ var _iterator = _createForOfIteratorHelper(path.split('.')),
36
+ _step;
33
37
 
34
- current = current[field];
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().catch( // we don't care if cancel fails, but we still need to catch the error to avoid reporting it
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;
@@ -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 || typeof sourceToSanitize !== 'object') {
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 (typeof value === 'symbol') {
162
+ if (_typeof(value) === 'symbol') {
161
163
  // symbol.description is part of ES2019+
162
164
  return '[Symbol] ' + value.description || value.toString();
163
165
  }
@@ -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 (typeof value !== 'object' || value === null) {
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 (typeof str === 'object' && str) {
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 (typeof value === 'object' && value) {
28
+ if (_typeof(value) === 'object' && value) {
27
29
  return escapeFieldValueStr(jsonStringify(value));
28
30
  } else if (isString(value)) {
29
31
  return escapeFieldValueStr(value);
@@ -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 '\uFFFD';
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 char = null;
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
- char = str.charCodeAt(i);
456
- hash = (hash << 5) - hash + char;
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 (typeof queryObj !== 'object') {
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 (typeof g === 'object' && 'timeout' in g) {
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 typeof value;
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 (typeof source !== 'object' || source === null) {
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 (typeof data === 'object' && data.$option) {
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 (typeof candidate === 'object' && candidate !== null) {
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,7 +36,7 @@ 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
 
@@ -49,12 +51,12 @@ export function getGlobalObject() {
49
51
 
50
52
  delete Object.prototype._gc_temp_;
51
53
 
52
- if (typeof globalObject !== 'object') {
54
+ if (_typeof(globalObject) !== 'object') {
53
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 (typeof candidate !== 'object' || !candidate || !(property in candidate)) {
135
+ if (_typeof(candidate) !== 'object' || !candidate || !(property in candidate)) {
134
136
  return undefined;
135
137
  }
136
138
 
@@ -12,13 +12,12 @@ export function getEventBridge() {
12
12
  }
13
13
 
14
14
  return {
15
- send(eventType, event) {
15
+ send: function send(eventType, event) {
16
16
  eventBridgeGlobal.sendEvent(JSON.stringify({
17
17
  name: eventType,
18
18
  data: event
19
19
  }));
20
20
  }
21
-
22
21
  };
23
22
  }
24
23
  export function canUseEventBridge() {
@@ -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
- messagesLimit,
13
- bytesLimit,
14
- durationLimit,
15
- pageExitObservable,
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
  /**
@@ -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": "2.0.18",
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": "95a35040844e8959ebf322eeeeb1269fc369e679"
23
+ "gitHead": "c42f3cdce8c9f1af6ac6bec06c7a7e83a9638467"
24
24
  }
package/src/dataMap.js CHANGED
@@ -68,6 +68,7 @@ export var dataMap = {
68
68
  dom: 'view.dom',
69
69
  dom_ready: 'view.dom_ready',
70
70
  time_spent: 'view.time_spent',
71
+ first_byte: 'view.first_byte',
71
72
  in_foreground_periods: 'view.in_foreground_periods',
72
73
  frustration_count: 'view.frustration.count'
73
74
  }
@@ -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
+ }
@@ -1,6 +1,9 @@
1
1
  import { display } from '../helper/display'
2
2
  var VariableLibrary = {
3
- navigator: typeof window.navigator != 'undefined' ? window.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
- export var deviceInfo = {
607
- os: MethodLibrary.getOS(),
608
- osVersion: MethodLibrary.getOSVersion().version,
609
- osVersionMajor: MethodLibrary.getOSVersion().osMajor,
610
- browser: MethodLibrary.getBrowserInfo().browser,
611
- browserVersion: MethodLibrary.getBrowserInfo().browserVersion,
612
- browserVersionMajor: MethodLibrary.getBrowserInfo().browserMajor,
613
- screenSize: window.screen.width + '*' + window.screen.height,
614
- networkType: MethodLibrary.getNetwork(),
615
- divice: MethodLibrary.getDeviceType()
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
@@ -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) {
@@ -24,6 +24,7 @@ export function createHttpRequest(endpointUrl, bytesLimit, reportError) {
24
24
  payload,
25
25
  retryState,
26
26
  sendStrategyForRetry,
27
+ endpointUrl,
27
28
  reportError
28
29
  )
29
30
  },
@@ -23,6 +23,7 @@ export function sendWithRetryStrategy(
23
23
  payload,
24
24
  state,
25
25
  sendStrategy,
26
+ endpointUrl,
26
27
  reportError
27
28
  ) {
28
29
  if (
@@ -36,12 +37,13 @@ export function sendWithRetryStrategy(
36
37
  RetryReason.AFTER_SUCCESS,
37
38
  state,
38
39
  sendStrategy,
40
+ endpointUrl,
39
41
  reportError
40
42
  )
41
43
  },
42
44
  onFailure: function () {
43
45
  state.queuedPayloads.enqueue(payload)
44
- scheduleRetry(state, sendStrategy, reportError)
46
+ scheduleRetry(state, sendStrategy, endpointUrl, reportError)
45
47
  }
46
48
  })
47
49
  } else {
@@ -49,7 +51,7 @@ export function sendWithRetryStrategy(
49
51
  }
50
52
  }
51
53
 
52
- function scheduleRetry(state, sendStrategy, reportError) {
54
+ function scheduleRetry(state, sendStrategy, endpointUrl, reportError) {
53
55
  if (state.transportStatus !== TransportStatus.DOWN) {
54
56
  return
55
57
  }
@@ -68,6 +70,7 @@ function scheduleRetry(state, sendStrategy, reportError) {
68
70
  RetryReason.AFTER_RESUME,
69
71
  state,
70
72
  sendStrategy,
73
+ endpointUrl,
71
74
  reportError
72
75
  )
73
76
  },
@@ -76,7 +79,7 @@ function scheduleRetry(state, sendStrategy, reportError) {
76
79
  MAX_BACKOFF_TIME,
77
80
  state.currentBackoffTime * 2
78
81
  )
79
- scheduleRetry(state, sendStrategy, reportError)
82
+ scheduleRetry(state, sendStrategy, endpointUrl, reportError)
80
83
  }
81
84
  })
82
85
  }, state.currentBackoffTime)
@@ -103,7 +106,13 @@ function send(payload, state, sendStrategy, responseData) {
103
106
  })
104
107
  }
105
108
 
106
- function retryQueuedPayloads(reason, state, sendStrategy, reportError) {
109
+ function retryQueuedPayloads(
110
+ reason,
111
+ state,
112
+ sendStrategy,
113
+ endpointUrl,
114
+ reportError
115
+ ) {
107
116
  if (
108
117
  reason === RetryReason.AFTER_SUCCESS &&
109
118
  state.queuedPayloads.isFull() &&
@@ -111,7 +120,9 @@ function retryQueuedPayloads(reason, state, sendStrategy, reportError) {
111
120
  ) {
112
121
  reportError({
113
122
  message:
114
- 'Reached max events size queued for upload: ' +
123
+ 'Reached max ' +
124
+ endpointUrl +
125
+ ' events size queued for upload: ' +
115
126
  MAX_QUEUE_BYTES_COUNT / ONE_MEBI_BYTE +
116
127
  'MiB',
117
128
  source: ErrorSource.AGENT,
@@ -126,6 +137,7 @@ function retryQueuedPayloads(reason, state, sendStrategy, reportError) {
126
137
  previousQueue.dequeue(),
127
138
  state,
128
139
  sendStrategy,
140
+ endpointUrl,
129
141
  reportError
130
142
  )
131
143
  }
package/src/user/user.js CHANGED
@@ -4,7 +4,6 @@ import { assign, getType, each } from '../helper/tools'
4
4
  /**
5
5
  * Clone input data and ensure known user properties (id, name, email)
6
6
  * are strings, as defined here:
7
- * https://docs.datadoghq.com/logs/log_configuration/attributes_naming_convention/#user-related-attributes
8
7
  */
9
8
  export function sanitizeUser(newUser) {
10
9
  // We shallow clone only to prevent mutation of user data.
package/src/worker.js ADDED
@@ -0,0 +1 @@
1
+ export { concatBuffers } from './helper/byteUtils'