@cloudcare/browser-core 3.0.29 → 3.1.0

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.
Files changed (264) hide show
  1. package/cjs/browser/addEventListener.js +3 -8
  2. package/cjs/browser/addEventListener.js.map +1 -0
  3. package/cjs/browser/cookie.js +3 -14
  4. package/cjs/browser/cookie.js.map +1 -0
  5. package/cjs/browser/fetchObservable.js +4 -21
  6. package/cjs/browser/fetchObservable.js.map +1 -0
  7. package/cjs/browser/htmlDomUtils.js +3 -9
  8. package/cjs/browser/htmlDomUtils.js.map +1 -0
  9. package/cjs/browser/pageExitObservable.js +3 -9
  10. package/cjs/browser/pageExitObservable.js.map +1 -0
  11. package/cjs/browser/runOnReadyState.js +2 -4
  12. package/cjs/browser/runOnReadyState.js.map +1 -0
  13. package/cjs/browser/scroll.js +32 -0
  14. package/cjs/browser/scroll.js.map +1 -0
  15. package/cjs/browser/xhrObservable.js +2 -21
  16. package/cjs/browser/xhrObservable.js.map +1 -0
  17. package/cjs/configuration/configuration.js +9 -20
  18. package/cjs/configuration/configuration.js.map +1 -0
  19. package/cjs/configuration/transportConfiguration.js +6 -20
  20. package/cjs/configuration/transportConfiguration.js.map +1 -0
  21. package/cjs/console/consoleObservable.js +3 -21
  22. package/cjs/console/consoleObservable.js.map +1 -0
  23. package/cjs/dataMap.js +24 -10
  24. package/cjs/dataMap.js.map +1 -0
  25. package/cjs/error/trackRuntimeError.js +3 -7
  26. package/cjs/error/trackRuntimeError.js.map +1 -0
  27. package/cjs/helper/boundedBuffer.js +2 -6
  28. package/cjs/helper/boundedBuffer.js.map +1 -0
  29. package/cjs/helper/byteUtils.js +6 -16
  30. package/cjs/helper/byteUtils.js.map +1 -0
  31. package/cjs/helper/catchUserErrors.js +2 -4
  32. package/cjs/helper/catchUserErrors.js.map +1 -0
  33. package/cjs/helper/contextHistory.js +21 -37
  34. package/cjs/helper/contextHistory.js.map +1 -0
  35. package/cjs/helper/createEventRateLimiter.js +2 -10
  36. package/cjs/helper/createEventRateLimiter.js.map +1 -0
  37. package/cjs/helper/deviceInfo.js +10 -64
  38. package/cjs/helper/deviceInfo.js.map +1 -0
  39. package/cjs/helper/display.js +2 -5
  40. package/cjs/helper/display.js.map +1 -0
  41. package/cjs/helper/enums.js +8 -2
  42. package/cjs/helper/enums.js.map +1 -0
  43. package/cjs/helper/errorTools.js +32 -38
  44. package/cjs/helper/errorTools.js.map +1 -0
  45. package/cjs/helper/eventEmitter.js +2 -6
  46. package/cjs/helper/eventEmitter.js.map +1 -0
  47. package/cjs/helper/getZoneJsOriginalValue.js +2 -5
  48. package/cjs/helper/getZoneJsOriginalValue.js.map +1 -0
  49. package/cjs/helper/instrumentMethod.js +10 -22
  50. package/cjs/helper/instrumentMethod.js.map +1 -0
  51. package/cjs/helper/lifeCycle.js +2 -9
  52. package/cjs/helper/lifeCycle.js.map +1 -0
  53. package/cjs/helper/limitModification.js +4 -22
  54. package/cjs/helper/limitModification.js.map +1 -0
  55. package/cjs/helper/mobileUtil.js +2 -20
  56. package/cjs/helper/mobileUtil.js.map +1 -0
  57. package/cjs/helper/monitor.js +2 -11
  58. package/cjs/helper/monitor.js.map +1 -0
  59. package/cjs/helper/observable.js +2 -9
  60. package/cjs/helper/observable.js.map +1 -0
  61. package/cjs/helper/readBytesFromStream.js +4 -14
  62. package/cjs/helper/readBytesFromStream.js.map +1 -0
  63. package/cjs/helper/sanitize.js +38 -61
  64. package/cjs/helper/sanitize.js.map +1 -0
  65. package/cjs/helper/serialisation/contextManager.js +5 -15
  66. package/cjs/helper/serialisation/contextManager.js.map +1 -0
  67. package/cjs/helper/serialisation/heavyCustomerDataWarning.js +2 -7
  68. package/cjs/helper/serialisation/heavyCustomerDataWarning.js.map +1 -0
  69. package/cjs/helper/serialisation/jsonStringify.js +6 -12
  70. package/cjs/helper/serialisation/jsonStringify.js.map +1 -0
  71. package/cjs/helper/serialisation/rowData.js +3 -10
  72. package/cjs/helper/serialisation/rowData.js.map +1 -0
  73. package/cjs/helper/timer.js +2 -8
  74. package/cjs/helper/timer.js.map +1 -0
  75. package/cjs/helper/tools.js +57 -444
  76. package/cjs/helper/tools.js.map +1 -0
  77. package/cjs/helper/urlPolyfill.js +5 -18
  78. package/cjs/helper/urlPolyfill.js.map +1 -0
  79. package/cjs/index.js +24 -95
  80. package/cjs/index.js.map +1 -0
  81. package/cjs/init.js +14 -20
  82. package/cjs/init.js.map +1 -0
  83. package/cjs/report/reportObservable.js +5 -24
  84. package/cjs/report/reportObservable.js.map +1 -0
  85. package/cjs/session/sessionConstants.js +2 -3
  86. package/cjs/session/sessionConstants.js.map +1 -0
  87. package/cjs/session/sessionCookieStore.js +11 -46
  88. package/cjs/session/sessionCookieStore.js.map +1 -0
  89. package/cjs/session/sessionManagement.js +2 -19
  90. package/cjs/session/sessionManagement.js.map +1 -0
  91. package/cjs/session/sessionStore.js +3 -28
  92. package/cjs/session/sessionStore.js.map +1 -0
  93. package/cjs/synthetics/syntheticsWorkerValues.js +2 -6
  94. package/cjs/synthetics/syntheticsWorkerValues.js.map +1 -0
  95. package/cjs/synthetics/usr.js +2 -8
  96. package/cjs/synthetics/usr.js.map +1 -0
  97. package/cjs/telemetry/telemetry.js +125 -0
  98. package/cjs/telemetry/telemetry.js.map +1 -0
  99. package/cjs/telemetry/types.js +17 -0
  100. package/cjs/telemetry/types.js.map +1 -0
  101. package/cjs/tracekit/computeStackTrace.js +4 -34
  102. package/cjs/tracekit/computeStackTrace.js.map +1 -0
  103. package/cjs/tracekit/index.js +2 -3
  104. package/cjs/tracekit/index.js.map +1 -0
  105. package/cjs/tracekit/tracekit.js +3 -18
  106. package/cjs/tracekit/tracekit.js.map +1 -0
  107. package/cjs/transport/batch.js +5 -54
  108. package/cjs/transport/batch.js.map +1 -0
  109. package/cjs/transport/eventBridge.js +2 -7
  110. package/cjs/transport/eventBridge.js.map +1 -0
  111. package/cjs/transport/flushController.js +8 -21
  112. package/cjs/transport/flushController.js.map +1 -0
  113. package/cjs/transport/httpRequest.js +4 -18
  114. package/cjs/transport/httpRequest.js.map +1 -0
  115. package/cjs/transport/index.js +2 -6
  116. package/cjs/transport/index.js.map +1 -0
  117. package/cjs/transport/sendWithRetryStrategy.js +4 -23
  118. package/cjs/transport/sendWithRetryStrategy.js.map +1 -0
  119. package/cjs/transport/startBatchWithReplica.js +2 -7
  120. package/cjs/transport/startBatchWithReplica.js.map +1 -0
  121. package/cjs/user/index.js +2 -3
  122. package/cjs/user/index.js.map +1 -0
  123. package/cjs/user/user.js +3 -8
  124. package/cjs/user/user.js.map +1 -0
  125. package/cjs/worker.js +2 -2
  126. package/cjs/worker.js.map +1 -0
  127. package/esm/browser/addEventListener.js +3 -3
  128. package/esm/browser/addEventListener.js.map +1 -0
  129. package/esm/browser/cookie.js +3 -6
  130. package/esm/browser/cookie.js.map +1 -0
  131. package/esm/browser/fetchObservable.js +4 -14
  132. package/esm/browser/fetchObservable.js.map +1 -0
  133. package/esm/browser/htmlDomUtils.js +3 -2
  134. package/esm/browser/htmlDomUtils.js.map +1 -0
  135. package/esm/browser/pageExitObservable.js +3 -2
  136. package/esm/browser/pageExitObservable.js.map +1 -0
  137. package/esm/browser/runOnReadyState.js +2 -1
  138. package/esm/browser/runOnReadyState.js.map +1 -0
  139. package/esm/browser/scroll.js +25 -0
  140. package/esm/browser/scroll.js.map +1 -0
  141. package/esm/browser/xhrObservable.js +2 -14
  142. package/esm/browser/xhrObservable.js.map +1 -0
  143. package/esm/configuration/configuration.js +9 -9
  144. package/esm/configuration/configuration.js.map +1 -0
  145. package/esm/configuration/transportConfiguration.js +6 -17
  146. package/esm/configuration/transportConfiguration.js.map +1 -0
  147. package/esm/console/consoleObservable.js +3 -11
  148. package/esm/console/consoleObservable.js.map +1 -0
  149. package/esm/dataMap.js +24 -8
  150. package/esm/dataMap.js.map +1 -0
  151. package/esm/error/trackRuntimeError.js +4 -3
  152. package/esm/error/trackRuntimeError.js.map +1 -0
  153. package/esm/helper/boundedBuffer.js +2 -4
  154. package/esm/helper/boundedBuffer.js.map +1 -0
  155. package/esm/helper/byteUtils.js +6 -13
  156. package/esm/helper/byteUtils.js.map +1 -0
  157. package/esm/helper/catchUserErrors.js +2 -2
  158. package/esm/helper/catchUserErrors.js.map +1 -0
  159. package/esm/helper/contextHistory.js +21 -33
  160. package/esm/helper/contextHistory.js.map +1 -0
  161. package/esm/helper/createEventRateLimiter.js +2 -6
  162. package/esm/helper/createEventRateLimiter.js.map +1 -0
  163. package/esm/helper/deviceInfo.js +10 -62
  164. package/esm/helper/deviceInfo.js.map +1 -0
  165. package/esm/helper/display.js +2 -3
  166. package/esm/helper/display.js.map +1 -0
  167. package/esm/helper/enums.js +6 -1
  168. package/esm/helper/enums.js.map +1 -0
  169. package/esm/helper/errorTools.js +30 -25
  170. package/esm/helper/errorTools.js.map +1 -0
  171. package/esm/helper/eventEmitter.js +2 -5
  172. package/esm/helper/eventEmitter.js.map +1 -0
  173. package/esm/helper/getZoneJsOriginalValue.js +2 -4
  174. package/esm/helper/getZoneJsOriginalValue.js.map +1 -0
  175. package/esm/helper/instrumentMethod.js +10 -16
  176. package/esm/helper/instrumentMethod.js.map +1 -0
  177. package/esm/helper/lifeCycle.js +2 -5
  178. package/esm/helper/lifeCycle.js.map +1 -0
  179. package/esm/helper/limitModification.js +5 -20
  180. package/esm/helper/limitModification.js.map +1 -0
  181. package/esm/helper/mobileUtil.js +2 -16
  182. package/esm/helper/mobileUtil.js.map +1 -0
  183. package/esm/helper/monitor.js +2 -3
  184. package/esm/helper/monitor.js.map +1 -0
  185. package/esm/helper/observable.js +2 -7
  186. package/esm/helper/observable.js.map +1 -0
  187. package/esm/helper/readBytesFromStream.js +4 -12
  188. package/esm/helper/readBytesFromStream.js.map +1 -0
  189. package/esm/helper/sanitize.js +40 -57
  190. package/esm/helper/sanitize.js.map +1 -0
  191. package/esm/helper/serialisation/contextManager.js +5 -9
  192. package/esm/helper/serialisation/contextManager.js.map +1 -0
  193. package/esm/helper/serialisation/heavyCustomerDataWarning.js +5 -4
  194. package/esm/helper/serialisation/heavyCustomerDataWarning.js.map +1 -0
  195. package/esm/helper/serialisation/jsonStringify.js +7 -10
  196. package/esm/helper/serialisation/jsonStringify.js.map +1 -0
  197. package/esm/helper/serialisation/rowData.js +3 -4
  198. package/esm/helper/serialisation/rowData.js.map +1 -0
  199. package/esm/helper/timer.js +2 -1
  200. package/esm/helper/timer.js.map +1 -0
  201. package/esm/helper/tools.js +57 -256
  202. package/esm/helper/tools.js.map +1 -0
  203. package/esm/helper/urlPolyfill.js +5 -9
  204. package/esm/helper/urlPolyfill.js.map +1 -0
  205. package/esm/index.js +4 -1
  206. package/esm/index.js.map +1 -0
  207. package/esm/init.js +14 -14
  208. package/esm/init.js.map +1 -0
  209. package/esm/report/reportObservable.js +5 -16
  210. package/esm/report/reportObservable.js.map +1 -0
  211. package/esm/session/sessionConstants.js +2 -1
  212. package/esm/session/sessionConstants.js.map +1 -0
  213. package/esm/session/sessionCookieStore.js +11 -38
  214. package/esm/session/sessionCookieStore.js.map +1 -0
  215. package/esm/session/sessionManagement.js +2 -8
  216. package/esm/session/sessionManagement.js.map +1 -0
  217. package/esm/session/sessionStore.js +4 -22
  218. package/esm/session/sessionStore.js.map +1 -0
  219. package/esm/synthetics/syntheticsWorkerValues.js +2 -1
  220. package/esm/synthetics/syntheticsWorkerValues.js.map +1 -0
  221. package/esm/synthetics/usr.js +2 -3
  222. package/esm/synthetics/usr.js.map +1 -0
  223. package/esm/telemetry/telemetry.js +111 -0
  224. package/esm/telemetry/telemetry.js.map +1 -0
  225. package/esm/telemetry/types.js +9 -0
  226. package/esm/telemetry/types.js.map +1 -0
  227. package/esm/tracekit/computeStackTrace.js +4 -31
  228. package/esm/tracekit/computeStackTrace.js.map +1 -0
  229. package/esm/tracekit/index.js +2 -1
  230. package/esm/tracekit/index.js.map +1 -0
  231. package/esm/tracekit/tracekit.js +5 -14
  232. package/esm/tracekit/tracekit.js.map +1 -0
  233. package/esm/transport/batch.js +7 -45
  234. package/esm/transport/batch.js.map +1 -0
  235. package/esm/transport/eventBridge.js +2 -5
  236. package/esm/transport/eventBridge.js.map +1 -0
  237. package/esm/transport/flushController.js +11 -20
  238. package/esm/transport/flushController.js.map +1 -0
  239. package/esm/transport/httpRequest.js +4 -15
  240. package/esm/transport/httpRequest.js.map +1 -0
  241. package/esm/transport/index.js +2 -1
  242. package/esm/transport/index.js.map +1 -0
  243. package/esm/transport/sendWithRetryStrategy.js +4 -17
  244. package/esm/transport/sendWithRetryStrategy.js.map +1 -0
  245. package/esm/transport/startBatchWithReplica.js +2 -3
  246. package/esm/transport/startBatchWithReplica.js.map +1 -0
  247. package/esm/user/index.js.map +1 -0
  248. package/esm/user/user.js +4 -5
  249. package/esm/user/user.js.map +1 -0
  250. package/esm/worker.js.map +1 -0
  251. package/package.json +2 -2
  252. package/src/browser/scroll.js +25 -0
  253. package/src/configuration/configuration.js +16 -0
  254. package/src/configuration/transportConfiguration.js +2 -2
  255. package/src/dataMap.js +17 -3
  256. package/src/error/trackRuntimeError.js +2 -2
  257. package/src/helper/contextHistory.js +3 -3
  258. package/src/helper/enums.js +4 -0
  259. package/src/helper/errorTools.js +49 -19
  260. package/src/helper/tools.js +1 -0
  261. package/src/index.js +3 -0
  262. package/src/report/reportObservable.js +3 -3
  263. package/src/telemetry/telemetry.js +164 -0
  264. package/src/telemetry/types.js +9 -0
@@ -9,37 +9,29 @@ exports.monitor = monitor;
9
9
  exports.resetMonitor = resetMonitor;
10
10
  exports.setDebugMode = setDebugMode;
11
11
  exports.startMonitorErrorCollection = startMonitorErrorCollection;
12
-
13
12
  var _display = require("./display");
14
-
15
13
  var onMonitorErrorCollected;
16
14
  var debugMode = false;
17
-
18
15
  function startMonitorErrorCollection(newOnMonitorErrorCollected) {
19
16
  onMonitorErrorCollected = newOnMonitorErrorCollected;
20
17
  }
21
-
22
18
  function setDebugMode(newDebugMode) {
23
19
  debugMode = newDebugMode;
24
20
  }
25
-
26
21
  function resetMonitor() {
27
22
  onMonitorErrorCollected = undefined;
28
23
  debugMode = false;
29
24
  }
30
-
31
25
  function monitor(fn) {
32
26
  return function () {
33
27
  return callMonitored(fn, this, arguments);
34
28
  };
35
29
  }
36
-
37
30
  function callMonitored(fn, context, args) {
38
31
  try {
39
32
  return fn.apply(context, args);
40
33
  } catch (e) {
41
34
  displayIfDebugEnabled(_display.ConsoleApiName.error, e);
42
-
43
35
  if (onMonitorErrorCollected) {
44
36
  try {
45
37
  onMonitorErrorCollected(e);
@@ -49,11 +41,10 @@ function callMonitored(fn, context, args) {
49
41
  }
50
42
  }
51
43
  }
52
-
53
44
  function displayIfDebugEnabled(api) {
54
45
  var args = [].slice.call(arguments, 1);
55
-
56
46
  if (debugMode) {
57
47
  _display.display.apply(null, [api, '[MONITOR]'].concat(args));
58
48
  }
59
- }
49
+ }
50
+ //# sourceMappingURL=monitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor.js","names":["_display","require","onMonitorErrorCollected","debugMode","startMonitorErrorCollection","newOnMonitorErrorCollected","setDebugMode","newDebugMode","resetMonitor","undefined","monitor","fn","callMonitored","arguments","context","args","apply","e","displayIfDebugEnabled","ConsoleApiName","error","api","slice","call","display","concat"],"sources":["../../src/helper/monitor.js"],"sourcesContent":["import { ConsoleApiName, display } from './display'\nvar onMonitorErrorCollected\nvar debugMode = false\n\nexport function startMonitorErrorCollection(newOnMonitorErrorCollected) {\n onMonitorErrorCollected = newOnMonitorErrorCollected\n}\n\nexport function setDebugMode(newDebugMode) {\n debugMode = newDebugMode\n}\n\nexport function resetMonitor() {\n onMonitorErrorCollected = undefined\n debugMode = false\n}\n\nexport function monitor(fn) {\n return function () {\n return callMonitored(fn, this, arguments)\n }\n}\n\nexport function callMonitored(fn, context, args) {\n try {\n return fn.apply(context, args)\n } catch (e) {\n displayIfDebugEnabled(ConsoleApiName.error, e)\n if (onMonitorErrorCollected) {\n try {\n onMonitorErrorCollected(e)\n } catch (e) {\n displayIfDebugEnabled(ConsoleApiName.error, e)\n }\n }\n }\n}\n\nexport function displayIfDebugEnabled(api) {\n var args = [].slice.call(arguments, 1)\n if (debugMode) {\n display.apply(null, [api, '[MONITOR]'].concat(args))\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAIC,uBAAuB;AAC3B,IAAIC,SAAS,GAAG,KAAK;AAEd,SAASC,2BAA2BA,CAACC,0BAA0B,EAAE;EACtEH,uBAAuB,GAAGG,0BAA0B;AACtD;AAEO,SAASC,YAAYA,CAACC,YAAY,EAAE;EACzCJ,SAAS,GAAGI,YAAY;AAC1B;AAEO,SAASC,YAAYA,CAAA,EAAG;EAC7BN,uBAAuB,GAAGO,SAAS;EACnCN,SAAS,GAAG,KAAK;AACnB;AAEO,SAASO,OAAOA,CAACC,EAAE,EAAE;EAC1B,OAAO,YAAY;IACjB,OAAOC,aAAa,CAACD,EAAE,EAAE,IAAI,EAAEE,SAAS,CAAC;EAC3C,CAAC;AACH;AAEO,SAASD,aAAaA,CAACD,EAAE,EAAEG,OAAO,EAAEC,IAAI,EAAE;EAC/C,IAAI;IACF,OAAOJ,EAAE,CAACK,KAAK,CAACF,OAAO,EAAEC,IAAI,CAAC;EAChC,CAAC,CAAC,OAAOE,CAAC,EAAE;IACVC,qBAAqB,CAACC,uBAAc,CAACC,KAAK,EAAEH,CAAC,CAAC;IAC9C,IAAIf,uBAAuB,EAAE;MAC3B,IAAI;QACFA,uBAAuB,CAACe,CAAC,CAAC;MAC5B,CAAC,CAAC,OAAOA,CAAC,EAAE;QACVC,qBAAqB,CAACC,uBAAc,CAACC,KAAK,EAAEH,CAAC,CAAC;MAChD;IACF;EACF;AACF;AAEO,SAASC,qBAAqBA,CAACG,GAAG,EAAE;EACzC,IAAIN,IAAI,GAAG,EAAE,CAACO,KAAK,CAACC,IAAI,CAACV,SAAS,EAAE,CAAC,CAAC;EACtC,IAAIV,SAAS,EAAE;IACbqB,gBAAO,CAACR,KAAK,CAAC,IAAI,EAAE,CAACK,GAAG,EAAE,WAAW,CAAC,CAACI,MAAM,CAACV,IAAI,CAAC,CAAC;EACtD;AACF"}
@@ -5,31 +5,24 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Observable = void 0;
7
7
  exports.mergeObservables = mergeObservables;
8
-
9
8
  var _tools = require("./tools");
10
-
11
9
  var _Observable = function _Observable(onFirstSubscribe) {
12
10
  this.observers = [];
13
11
  this.onLastUnsubscribe = undefined;
14
12
  this.onFirstSubscribe = onFirstSubscribe;
15
13
  };
16
-
17
14
  _Observable.prototype = {
18
15
  subscribe: function subscribe(f) {
19
16
  if (!this.observers.length && this.onFirstSubscribe) {
20
17
  this.onLastUnsubscribe = this.onFirstSubscribe() || undefined;
21
18
  }
22
-
23
19
  this.observers.push(f);
24
-
25
20
  var _this = this;
26
-
27
21
  return {
28
22
  unsubscribe: function unsubscribe() {
29
23
  _this.observers = (0, _tools.filter)(_this.observers, function (other) {
30
24
  return f !== other;
31
25
  });
32
-
33
26
  if (!_this.observers.length && _this.onLastUnsubscribe) {
34
27
  _this.onLastUnsubscribe();
35
28
  }
@@ -44,7 +37,6 @@ _Observable.prototype = {
44
37
  };
45
38
  var Observable = _Observable;
46
39
  exports.Observable = Observable;
47
-
48
40
  function mergeObservables() {
49
41
  var observables = [].slice.call(arguments);
50
42
  var globalObservable = new Observable(function () {
@@ -60,4 +52,5 @@ function mergeObservables() {
60
52
  };
61
53
  });
62
54
  return globalObservable;
63
- }
55
+ }
56
+ //# sourceMappingURL=observable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observable.js","names":["_tools","require","_Observable","onFirstSubscribe","observers","onLastUnsubscribe","undefined","prototype","subscribe","f","length","push","_this","unsubscribe","filter","other","notify","data","each","observer","Observable","exports","mergeObservables","observables","slice","call","arguments","globalObservable","subscriptions","map","observable","subscription"],"sources":["../../src/helper/observable.js"],"sourcesContent":["import { each, filter, map } from './tools'\nvar _Observable = function (onFirstSubscribe) {\n this.observers = []\n this.onLastUnsubscribe = undefined\n this.onFirstSubscribe = onFirstSubscribe\n}\n_Observable.prototype = {\n subscribe: function (f) {\n if (!this.observers.length && this.onFirstSubscribe) {\n this.onLastUnsubscribe = this.onFirstSubscribe() || undefined\n }\n this.observers.push(f)\n var _this = this\n return {\n unsubscribe: function () {\n _this.observers = filter(_this.observers, function (other) {\n return f !== other\n })\n if (!_this.observers.length && _this.onLastUnsubscribe) {\n _this.onLastUnsubscribe()\n }\n }\n }\n },\n notify: function (data) {\n each(this.observers, function (observer) {\n observer(data)\n })\n }\n}\nexport var Observable = _Observable\n\nexport function mergeObservables() {\n var observables = [].slice.call(arguments)\n var globalObservable = new Observable(function () {\n var subscriptions = map(observables, function (observable) {\n return observable.subscribe(function (data) {\n return globalObservable.notify(data)\n })\n })\n return function () {\n return each(subscriptions, function (subscription) {\n return subscription.unsubscribe()\n })\n }\n })\n return globalObservable\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAIC,WAAW,GAAG,SAAdA,WAAWA,CAAaC,gBAAgB,EAAE;EAC5C,IAAI,CAACC,SAAS,GAAG,EAAE;EACnB,IAAI,CAACC,iBAAiB,GAAGC,SAAS;EAClC,IAAI,CAACH,gBAAgB,GAAGA,gBAAgB;AAC1C,CAAC;AACDD,WAAW,CAACK,SAAS,GAAG;EACtBC,SAAS,EAAE,SAAAA,UAAUC,CAAC,EAAE;IACtB,IAAI,CAAC,IAAI,CAACL,SAAS,CAACM,MAAM,IAAI,IAAI,CAACP,gBAAgB,EAAE;MACnD,IAAI,CAACE,iBAAiB,GAAG,IAAI,CAACF,gBAAgB,CAAC,CAAC,IAAIG,SAAS;IAC/D;IACA,IAAI,CAACF,SAAS,CAACO,IAAI,CAACF,CAAC,CAAC;IACtB,IAAIG,KAAK,GAAG,IAAI;IAChB,OAAO;MACLC,WAAW,EAAE,SAAAA,YAAA,EAAY;QACvBD,KAAK,CAACR,SAAS,GAAG,IAAAU,aAAM,EAACF,KAAK,CAACR,SAAS,EAAE,UAAUW,KAAK,EAAE;UACzD,OAAON,CAAC,KAAKM,KAAK;QACpB,CAAC,CAAC;QACF,IAAI,CAACH,KAAK,CAACR,SAAS,CAACM,MAAM,IAAIE,KAAK,CAACP,iBAAiB,EAAE;UACtDO,KAAK,CAACP,iBAAiB,CAAC,CAAC;QAC3B;MACF;IACF,CAAC;EACH,CAAC;EACDW,MAAM,EAAE,SAAAA,OAAUC,IAAI,EAAE;IACtB,IAAAC,WAAI,EAAC,IAAI,CAACd,SAAS,EAAE,UAAUe,QAAQ,EAAE;MACvCA,QAAQ,CAACF,IAAI,CAAC;IAChB,CAAC,CAAC;EACJ;AACF,CAAC;AACM,IAAIG,UAAU,GAAGlB,WAAW;AAAAmB,OAAA,CAAAD,UAAA,GAAAA,UAAA;AAE5B,SAASE,gBAAgBA,CAAA,EAAG;EACjC,IAAIC,WAAW,GAAG,EAAE,CAACC,KAAK,CAACC,IAAI,CAACC,SAAS,CAAC;EAC1C,IAAIC,gBAAgB,GAAG,IAAIP,UAAU,CAAC,YAAY;IAChD,IAAIQ,aAAa,GAAG,IAAAC,UAAG,EAACN,WAAW,EAAE,UAAUO,UAAU,EAAE;MACzD,OAAOA,UAAU,CAACtB,SAAS,CAAC,UAAUS,IAAI,EAAE;QAC1C,OAAOU,gBAAgB,CAACX,MAAM,CAACC,IAAI,CAAC;MACtC,CAAC,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,YAAY;MACjB,OAAO,IAAAC,WAAI,EAACU,aAAa,EAAE,UAAUG,YAAY,EAAE;QACjD,OAAOA,YAAY,CAAClB,WAAW,CAAC,CAAC;MACnC,CAAC,CAAC;IACJ,CAAC;EACH,CAAC,CAAC;EACF,OAAOc,gBAAgB;AACzB"}
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.readBytesFromStream = readBytesFromStream;
7
-
8
7
  var _tools = require("./tools");
9
-
10
8
  var _monitor = require("./monitor");
11
-
12
9
  /**
13
10
  * Read bytes from a ReadableStream until at least `limit` bytes have been read (or until the end of
14
11
  * the stream). The callback is invoked with the at most `limit` bytes, and indicates that the limit
@@ -19,20 +16,16 @@ function readBytesFromStream(stream, callback, options) {
19
16
  var chunks = [];
20
17
  var readBytesCount = 0;
21
18
  readMore();
22
-
23
19
  function readMore() {
24
20
  reader.read().then((0, _monitor.monitor)(function (result) {
25
21
  if (result.done) {
26
22
  onDone();
27
23
  return;
28
24
  }
29
-
30
25
  if (options.collectStreamBody) {
31
26
  chunks.push(result.value);
32
27
  }
33
-
34
28
  readBytesCount += result.value.length;
35
-
36
29
  if (readBytesCount > options.bytesLimit) {
37
30
  onDone();
38
31
  } else {
@@ -42,17 +35,15 @@ function readBytesFromStream(stream, callback, options) {
42
35
  callback(error);
43
36
  }));
44
37
  }
45
-
46
38
  function onDone() {
47
- reader.cancel()["catch"]( // we don't care if cancel fails, but we still need to catch the error to avoid reporting it
39
+ reader.cancel()["catch"](
40
+ // we don't care if cancel fails, but we still need to catch the error to avoid reporting it
48
41
  // as an unhandled rejection
49
42
  _tools.noop);
50
43
  var bytes;
51
44
  var limitExceeded;
52
-
53
45
  if (options.collectStreamBody) {
54
46
  var completeBuffer;
55
-
56
47
  if (chunks.length === 1) {
57
48
  // optimization: if the response is small enough to fit in a single buffer (provided by the browser), just
58
49
  // use it directly.
@@ -66,11 +57,10 @@ function readBytesFromStream(stream, callback, options) {
66
57
  offset += chunk.length;
67
58
  });
68
59
  }
69
-
70
60
  bytes = completeBuffer.slice(0, options.bytesLimit);
71
61
  limitExceeded = completeBuffer.length > options.bytesLimit;
72
62
  }
73
-
74
63
  callback(undefined, bytes, limitExceeded);
75
64
  }
76
- }
65
+ }
66
+ //# sourceMappingURL=readBytesFromStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readBytesFromStream.js","names":["_tools","require","_monitor","readBytesFromStream","stream","callback","options","reader","getReader","chunks","readBytesCount","readMore","read","then","monitor","result","done","onDone","collectStreamBody","push","value","length","bytesLimit","error","cancel","noop","bytes","limitExceeded","completeBuffer","Uint8Array","offset","each","chunk","set","slice","undefined"],"sources":["../../src/helper/readBytesFromStream.js"],"sourcesContent":["import { noop, each } from './tools'\nimport { monitor } from './monitor'\n/**\n * Read bytes from a ReadableStream until at least `limit` bytes have been read (or until the end of\n * the stream). The callback is invoked with the at most `limit` bytes, and indicates that the limit\n * has been exceeded if more bytes were available.\n */\nexport function readBytesFromStream(stream, callback, options) {\n var reader = stream.getReader()\n var chunks = []\n var readBytesCount = 0\n\n readMore()\n\n function readMore() {\n reader.read().then(\n monitor(function (result) {\n if (result.done) {\n onDone()\n return\n }\n\n if (options.collectStreamBody) {\n chunks.push(result.value)\n }\n readBytesCount += result.value.length\n\n if (readBytesCount > options.bytesLimit) {\n onDone()\n } else {\n readMore()\n }\n }),\n monitor(function (error) {\n callback(error)\n })\n )\n }\n\n function onDone() {\n reader.cancel().catch(\n // we don't care if cancel fails, but we still need to catch the error to avoid reporting it\n // as an unhandled rejection\n noop\n )\n\n var bytes\n var limitExceeded\n if (options.collectStreamBody) {\n var completeBuffer\n if (chunks.length === 1) {\n // optimization: if the response is small enough to fit in a single buffer (provided by the browser), just\n // use it directly.\n completeBuffer = chunks[0]\n } else {\n // else, we need to copy buffers into a larger buffer to concatenate them.\n completeBuffer = new Uint8Array(readBytesCount)\n var offset = 0\n each(chunks, function (chunk) {\n completeBuffer.set(chunk, offset)\n offset += chunk.length\n })\n }\n bytes = completeBuffer.slice(0, options.bytesLimit)\n limitExceeded = completeBuffer.length > options.bytesLimit\n }\n callback(undefined, bytes, limitExceeded)\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,mBAAmBA,CAACC,MAAM,EAAEC,QAAQ,EAAEC,OAAO,EAAE;EAC7D,IAAIC,MAAM,GAAGH,MAAM,CAACI,SAAS,CAAC,CAAC;EA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AM,IAAIE,KAAK,CAACX,MAAM;QACxB,CAAC,CAAC;MACJ;MACAK,KAAK,GAAGE,cAAc,CAACM,KAAK,CAAC,CAAC,EAAE5B,OAAO,CAACgB,UAAU,CAAC;MACnDK,aAAa,GAAGC,cAAc,CAACP,MAAM,GAAGf,OAAO,CAACgB,UAAU;IAC5D;IACAjB,QAAQ,CAAC8B,SAAS,EAAET,KAAK,EAAEC,aAAa,CAAC;EAC3C;AACF"}
@@ -4,23 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.sanitize = sanitize;
7
-
8
7
  var _display = require("./display");
9
-
10
8
  var _byteUtils = require("./byteUtils");
11
-
12
9
  var _jsonStringify = require("./serialisation/jsonStringify");
13
-
14
- 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); }
15
-
10
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
16
11
  // The maximum size of a single event is 256KiB. By default, we ensure that user-provided data
17
12
  // going through sanitize fits inside our events, while leaving room for other contexts, metadata, ...
18
- var SANITIZE_DEFAULT_MAX_CHARACTER_COUNT = 220 * _byteUtils.ONE_KIBI_BYTE; // Symbol for the root element of the JSONPath used for visited objects
13
+ var SANITIZE_DEFAULT_MAX_CHARACTER_COUNT = 220 * _byteUtils.ONE_KIBI_BYTE;
19
14
 
20
- var JSON_PATH_ROOT_ELEMENT = '$'; // When serializing (using JSON.stringify) a key of an object, { key: 42 } gets wrapped in quotes as "key".
21
- // With the separator (:), we need to add 3 characters to the count.
15
+ // Symbol for the root element of the JSONPath used for visited objects
16
+ var JSON_PATH_ROOT_ELEMENT = '$';
22
17
 
18
+ // When serializing (using JSON.stringify) a key of an object, { key: 42 } gets wrapped in quotes as "key".
19
+ // With the separator (:), we need to add 3 characters to the count.
23
20
  var KEY_DECORATION_LENGTH = 3;
21
+
24
22
  /**
25
23
  * Ensures user-provided data is 'safe' for the SDK
26
24
  * - Deep clones data
@@ -39,32 +37,29 @@ var KEY_DECORATION_LENGTH = 3;
39
37
  function sanitize(source, maxCharacterCount) {
40
38
  if (maxCharacterCount === undefined) {
41
39
  maxCharacterCount = SANITIZE_DEFAULT_MAX_CHARACTER_COUNT;
42
- } // Unbind any toJSON function we may have on [] or {} prototypes
43
-
44
-
40
+ }
41
+ // Unbind any toJSON function we may have on [] or {} prototypes
45
42
  var restoreObjectPrototypeToJson = (0, _jsonStringify.detachToJsonMethod)(Object.prototype);
46
- var restoreArrayPrototypeToJson = (0, _jsonStringify.detachToJsonMethod)(Array.prototype); // Initial call to sanitizeProcessor - will populate containerQueue if source is an Array or a plain Object
43
+ var restoreArrayPrototypeToJson = (0, _jsonStringify.detachToJsonMethod)(Array.prototype);
47
44
 
45
+ // Initial call to sanitizeProcessor - will populate containerQueue if source is an Array or a plain Object
48
46
  var containerQueue = [];
49
47
  var visitedObjectsWithPath = new WeakMap();
50
48
  var sanitizedData = sanitizeProcessor(source, JSON_PATH_ROOT_ELEMENT, undefined, containerQueue, visitedObjectsWithPath);
51
49
  var accumulatedCharacterCount = JSON.stringify(sanitizedData) && JSON.stringify(sanitizedData).length || 0;
52
-
53
50
  if (accumulatedCharacterCount > maxCharacterCount) {
54
51
  warnOverCharacterLimit(maxCharacterCount, 'discarded', source);
55
52
  return undefined;
56
53
  }
57
-
58
54
  while (containerQueue.length > 0 && accumulatedCharacterCount < maxCharacterCount) {
59
55
  var containerToProcess = containerQueue.shift();
60
56
  var separatorLength = 0; // 0 for the first element, 1 for subsequent elements
57
+
61
58
  // Arrays and Objects have to be handled distinctly to ensure
62
59
  // we do not pick up non-numerical properties from Arrays
63
-
64
60
  if (Array.isArray(containerToProcess.source)) {
65
61
  for (var key = 0; key < containerToProcess.source.length; key++) {
66
62
  var targetData = sanitizeProcessor(containerToProcess.source[key], containerToProcess.path, key, containerQueue, visitedObjectsWithPath);
67
-
68
63
  if (targetData !== undefined) {
69
64
  accumulatedCharacterCount += JSON.stringify(targetData).length;
70
65
  } else {
@@ -72,75 +67,65 @@ function sanitize(source, maxCharacterCount) {
72
67
  // JSON.stringify([undefined]) => '[null]' - This accounts for 4 characters
73
68
  accumulatedCharacterCount += 4;
74
69
  }
75
-
76
70
  accumulatedCharacterCount += separatorLength;
77
71
  separatorLength = 1;
78
-
79
72
  if (accumulatedCharacterCount > maxCharacterCount) {
80
73
  warnOverCharacterLimit(maxCharacterCount, 'truncated', source);
81
74
  break;
82
75
  }
83
-
84
76
  containerToProcess.target[key] = targetData;
85
77
  }
86
78
  } else {
87
79
  for (var key in containerToProcess.source) {
88
80
  if (Object.prototype.hasOwnProperty.call(containerToProcess.source, key)) {
89
- var targetData = sanitizeProcessor(containerToProcess.source[key], containerToProcess.path, key, containerQueue, visitedObjectsWithPath); // When a property of an object has an undefined value, it will be dropped during serialization:
81
+ var targetData = sanitizeProcessor(containerToProcess.source[key], containerToProcess.path, key, containerQueue, visitedObjectsWithPath);
82
+ // When a property of an object has an undefined value, it will be dropped during serialization:
90
83
  // JSON.stringify({a:undefined}) => '{}'
91
-
92
84
  if (targetData !== undefined) {
93
85
  accumulatedCharacterCount += JSON.stringify(targetData).length + separatorLength + key.length + KEY_DECORATION_LENGTH;
94
86
  separatorLength = 1;
95
87
  }
96
-
97
88
  if (accumulatedCharacterCount > maxCharacterCount) {
98
89
  warnOverCharacterLimit(maxCharacterCount, 'truncated', source);
99
90
  break;
100
91
  }
101
-
102
92
  containerToProcess.target[key] = targetData;
103
93
  }
104
94
  }
105
95
  }
106
- } // Rebind detached toJSON functions
107
-
96
+ }
108
97
 
98
+ // Rebind detached toJSON functions
109
99
  restoreObjectPrototypeToJson();
110
100
  restoreArrayPrototypeToJson();
111
101
  return sanitizedData;
112
102
  }
103
+
113
104
  /**
114
105
  * Internal function to factorize the process common to the
115
106
  * initial call to sanitize, and iterations for Arrays and Objects
116
107
  *
117
108
  */
118
-
119
-
120
109
  function sanitizeProcessor(source, parentPath, key, queue, visitedObjectsWithPath) {
121
110
  // Start by handling toJSON, as we want to sanitize its output
122
111
  var sourceToSanitize = tryToApplyToJSON(source);
123
-
124
112
  if (!sourceToSanitize || _typeof(sourceToSanitize) !== 'object') {
125
113
  return sanitizePrimitivesAndFunctions(sourceToSanitize);
126
114
  }
127
-
128
115
  var sanitizedSource = sanitizeObjects(sourceToSanitize);
129
-
130
116
  if (sanitizedSource !== '[Object]' && sanitizedSource !== '[Array]' && sanitizedSource !== '[Error]') {
131
117
  return sanitizedSource;
132
- } // Handle potential cyclic references
118
+ }
119
+
120
+ // Handle potential cyclic references
133
121
  // We need to use source as sourceToSanitize could be a reference to a new object
134
122
  // At this stage, we know the source is an object type
135
-
136
-
137
123
  var sourceAsObject = source;
138
-
139
124
  if (visitedObjectsWithPath.has(sourceAsObject)) {
140
125
  return '[Reference seen at ' + visitedObjectsWithPath.get(sourceAsObject) + ']';
141
- } // Add processed source to queue
142
-
126
+ }
143
127
 
128
+ // Add processed source to queue
144
129
  var currentPath = key !== undefined ? parentPath + '.' + key : parentPath;
145
130
  var target = Array.isArray(sourceToSanitize) ? [] : {};
146
131
  visitedObjectsWithPath.set(sourceAsObject, currentPath);
@@ -151,32 +136,29 @@ function sanitizeProcessor(source, parentPath, key, queue, visitedObjectsWithPat
151
136
  });
152
137
  return target;
153
138
  }
139
+
154
140
  /**
155
141
  * Handles sanitization of simple, non-object types
156
142
  *
157
143
  */
158
-
159
-
160
144
  function sanitizePrimitivesAndFunctions(value) {
161
145
  // BigInt cannot be serialized by JSON.stringify(), convert it to a string representation
162
146
  if (typeof value === 'bigint') {
163
147
  return '[BigInt] ' + value.toString();
164
- } // Functions cannot be serialized by JSON.stringify(). Moreover, if a faulty toJSON is present, it needs to be converted
148
+ }
149
+ // Functions cannot be serialized by JSON.stringify(). Moreover, if a faulty toJSON is present, it needs to be converted
165
150
  // so it won't prevent stringify from serializing later
166
-
167
-
168
151
  if (typeof value === 'function') {
169
152
  return '[Function] ' + value.name || 'unknown';
170
- } // JSON.stringify() does not serialize symbols.
171
-
172
-
153
+ }
154
+ // JSON.stringify() does not serialize symbols.
173
155
  if (_typeof(value) === 'symbol') {
174
156
  // symbol.description is part of ES2019+
175
157
  return '[Symbol] ' + value.description || value.toString();
176
158
  }
177
-
178
159
  return value;
179
160
  }
161
+
180
162
  /**
181
163
  * Handles sanitization of object types
182
164
  *
@@ -187,8 +169,6 @@ function sanitizePrimitivesAndFunctions(value) {
187
169
  * properties enumerated if any.
188
170
  *
189
171
  */
190
-
191
-
192
172
  function sanitizeObjects(value) {
193
173
  try {
194
174
  // Handle events - Keep a simple implementation to avoid breaking changes
@@ -196,44 +176,41 @@ function sanitizeObjects(value) {
196
176
  return {
197
177
  isTrusted: value.isTrusted
198
178
  };
199
- } // Handle all remaining object types in a generic way
200
-
179
+ }
201
180
 
181
+ // Handle all remaining object types in a generic way
202
182
  var result = Object.prototype.toString.call(value);
203
183
  var match = result.match(/\[object (.*)\]/);
204
-
205
184
  if (match && match[1]) {
206
185
  return '[' + match[1] + ']';
207
186
  }
208
- } catch (_unused) {// If the previous serialization attempts failed, and we cannot convert using
187
+ } catch (_unused) {
188
+ // If the previous serialization attempts failed, and we cannot convert using
209
189
  // Object.prototype.toString, declare the value unserializable
210
190
  }
211
-
212
191
  return '[Unserializable]';
213
192
  }
193
+
214
194
  /**
215
195
  * Checks if a toJSON function exists and tries to execute it
216
196
  *
217
197
  */
218
-
219
-
220
198
  function tryToApplyToJSON(value) {
221
199
  var object = value;
222
-
223
200
  if (object && typeof object.toJSON === 'function') {
224
201
  try {
225
202
  return object.toJSON();
226
- } catch (_unused2) {// If toJSON fails, we continue by trying to serialize the value manually
203
+ } catch (_unused2) {
204
+ // If toJSON fails, we continue by trying to serialize the value manually
227
205
  }
228
206
  }
229
-
230
207
  return value;
231
208
  }
209
+
232
210
  /**
233
211
  * Helper function to display the warning when the accumulated character count is over the limit
234
212
  */
235
-
236
-
237
213
  function warnOverCharacterLimit(maxCharacterCount, changeType, source) {
238
214
  _display.display.warn('The data provided has been ' + changeType + ' as it is over the limit of ' + maxCharacterCount + ' characters:', source);
239
- }
215
+ }
216
+ //# sourceMappingURL=sanitize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.js","names":["_display","require","_byteUtils","_jsonStringify","_typeof","obj","Symbol","iterator","constructor","prototype","SANITIZE_DEFAULT_MAX_CHARACTER_COUNT","ONE_KIBI_BYTE","JSON_PATH_ROOT_ELEMENT","KEY_DECORATION_LENGTH","sanitize","source","maxCharacterCount","undefined","restoreObjectPrototypeToJson","detachToJsonMethod","Object","restoreArrayPrototypeToJson","Array","containerQueue","visitedObjectsWithPath","WeakMap","sanitizedData","sanitizeProcessor","accumulatedCharacterCount","JSON","stringify","length","warnOverCharacterLimit","containerToProcess","shift","separatorLength","isArray","key","targetData","path","target","hasOwnProperty","call","parentPath","queue","sourceToSanitize","tryToApplyToJSON","sanitizePrimitivesAndFunctions","sanitizedSource","sanitizeObjects","sourceAsObject","has","get","currentPath","set","push","value","toString","name","description","Event","isTrusted","result","match","_unused","object","toJSON","_unused2","changeType","display","warn"],"sources":["../../src/helper/sanitize.js"],"sourcesContent":["import { display } from './display'\nimport { ONE_KIBI_BYTE } from './byteUtils'\nimport { detachToJsonMethod } from './serialisation/jsonStringify'\n\n// The maximum size of a single event is 256KiB. By default, we ensure that user-provided data\n// going through sanitize fits inside our events, while leaving room for other contexts, metadata, ...\nvar SANITIZE_DEFAULT_MAX_CHARACTER_COUNT = 220 * ONE_KIBI_BYTE\n\n// Symbol for the root element of the JSONPath used for visited objects\nvar JSON_PATH_ROOT_ELEMENT = '$'\n\n// When serializing (using JSON.stringify) a key of an object, { key: 42 } gets wrapped in quotes as \"key\".\n// With the separator (:), we need to add 3 characters to the count.\nvar KEY_DECORATION_LENGTH = 3\n\n/**\n * Ensures user-provided data is 'safe' for the SDK\n * - Deep clones data\n * - Removes cyclic references\n * - Transforms unserializable types to a string representation\n *\n * LIMITATIONS:\n * - Size is in characters, not byte count (may differ according to character encoding)\n * - Size does not take into account indentation that can be applied to JSON.stringify\n * - Non-numerical properties of Arrays are ignored. Same behavior as JSON.stringify\n *\n * @param source User-provided data meant to be serialized using JSON.stringify\n * @param maxCharacterCount Maximum number of characters allowed in serialized form\n */\n\nexport function sanitize(source, maxCharacterCount) {\n if (maxCharacterCount === undefined) {\n maxCharacterCount = SANITIZE_DEFAULT_MAX_CHARACTER_COUNT\n }\n // Unbind any toJSON function we may have on [] or {} prototypes\n var restoreObjectPrototypeToJson = detachToJsonMethod(Object.prototype)\n var restoreArrayPrototypeToJson = detachToJsonMethod(Array.prototype)\n\n // Initial call to sanitizeProcessor - will populate containerQueue if source is an Array or a plain Object\n var containerQueue = []\n var visitedObjectsWithPath = new WeakMap()\n var sanitizedData = sanitizeProcessor(\n source,\n JSON_PATH_ROOT_ELEMENT,\n undefined,\n containerQueue,\n visitedObjectsWithPath\n )\n var accumulatedCharacterCount =\n (JSON.stringify(sanitizedData) && JSON.stringify(sanitizedData).length) || 0\n if (accumulatedCharacterCount > maxCharacterCount) {\n warnOverCharacterLimit(maxCharacterCount, 'discarded', source)\n return undefined\n }\n\n while (\n containerQueue.length > 0 &&\n accumulatedCharacterCount < maxCharacterCount\n ) {\n var containerToProcess = containerQueue.shift()\n var separatorLength = 0 // 0 for the first element, 1 for subsequent elements\n\n // Arrays and Objects have to be handled distinctly to ensure\n // we do not pick up non-numerical properties from Arrays\n if (Array.isArray(containerToProcess.source)) {\n for (var key = 0; key < containerToProcess.source.length; key++) {\n var targetData = sanitizeProcessor(\n containerToProcess.source[key],\n containerToProcess.path,\n key,\n containerQueue,\n visitedObjectsWithPath\n )\n\n if (targetData !== undefined) {\n accumulatedCharacterCount += JSON.stringify(targetData).length\n } else {\n // When an element of an Array (targetData) is undefined, it is serialized as null:\n // JSON.stringify([undefined]) => '[null]' - This accounts for 4 characters\n accumulatedCharacterCount += 4\n }\n accumulatedCharacterCount += separatorLength\n separatorLength = 1\n if (accumulatedCharacterCount > maxCharacterCount) {\n warnOverCharacterLimit(maxCharacterCount, 'truncated', source)\n break\n }\n containerToProcess.target[key] = targetData\n }\n } else {\n for (var key in containerToProcess.source) {\n if (\n Object.prototype.hasOwnProperty.call(containerToProcess.source, key)\n ) {\n var targetData = sanitizeProcessor(\n containerToProcess.source[key],\n containerToProcess.path,\n key,\n containerQueue,\n visitedObjectsWithPath\n )\n // When a property of an object has an undefined value, it will be dropped during serialization:\n // JSON.stringify({a:undefined}) => '{}'\n if (targetData !== undefined) {\n accumulatedCharacterCount +=\n JSON.stringify(targetData).length +\n separatorLength +\n key.length +\n KEY_DECORATION_LENGTH\n separatorLength = 1\n }\n if (accumulatedCharacterCount > maxCharacterCount) {\n warnOverCharacterLimit(maxCharacterCount, 'truncated', source)\n break\n }\n containerToProcess.target[key] = targetData\n }\n }\n }\n }\n\n // Rebind detached toJSON functions\n restoreObjectPrototypeToJson()\n restoreArrayPrototypeToJson()\n\n return sanitizedData\n}\n\n/**\n * Internal function to factorize the process common to the\n * initial call to sanitize, and iterations for Arrays and Objects\n *\n */\nfunction sanitizeProcessor(\n source,\n parentPath,\n key,\n queue,\n visitedObjectsWithPath\n) {\n // Start by handling toJSON, as we want to sanitize its output\n var sourceToSanitize = tryToApplyToJSON(source)\n\n if (!sourceToSanitize || typeof sourceToSanitize !== 'object') {\n return sanitizePrimitivesAndFunctions(sourceToSanitize)\n }\n\n var sanitizedSource = sanitizeObjects(sourceToSanitize)\n if (\n sanitizedSource !== '[Object]' &&\n sanitizedSource !== '[Array]' &&\n sanitizedSource !== '[Error]'\n ) {\n return sanitizedSource\n }\n\n // Handle potential cyclic references\n // We need to use source as sourceToSanitize could be a reference to a new object\n // At this stage, we know the source is an object type\n var sourceAsObject = source\n if (visitedObjectsWithPath.has(sourceAsObject)) {\n return (\n '[Reference seen at ' + visitedObjectsWithPath.get(sourceAsObject) + ']'\n )\n }\n\n // Add processed source to queue\n var currentPath = key !== undefined ? parentPath + '.' + key : parentPath\n var target = Array.isArray(sourceToSanitize) ? [] : {}\n visitedObjectsWithPath.set(sourceAsObject, currentPath)\n queue.push({ source: sourceToSanitize, target, path: currentPath })\n\n return target\n}\n\n/**\n * Handles sanitization of simple, non-object types\n *\n */\nfunction sanitizePrimitivesAndFunctions(value) {\n // BigInt cannot be serialized by JSON.stringify(), convert it to a string representation\n if (typeof value === 'bigint') {\n return '[BigInt] ' + value.toString()\n }\n // Functions cannot be serialized by JSON.stringify(). Moreover, if a faulty toJSON is present, it needs to be converted\n // so it won't prevent stringify from serializing later\n if (typeof value === 'function') {\n return '[Function] ' + value.name || 'unknown'\n }\n // JSON.stringify() does not serialize symbols.\n if (typeof value === 'symbol') {\n // symbol.description is part of ES2019+\n return '[Symbol] ' + value.description || value.toString()\n }\n\n return value\n}\n\n/**\n * Handles sanitization of object types\n *\n * LIMITATIONS\n * - If a class defines a toStringTag Symbol, it will fall in the catch-all method and prevent enumeration of properties.\n * To avoid this, a toJSON method can be defined.\n * - IE11 does not return a distinct type for objects such as Map, WeakMap, ... These objects will pass through and their\n * properties enumerated if any.\n *\n */\nfunction sanitizeObjects(value) {\n try {\n // Handle events - Keep a simple implementation to avoid breaking changes\n if (value instanceof Event) {\n return {\n isTrusted: value.isTrusted\n }\n }\n\n // Handle all remaining object types in a generic way\n var result = Object.prototype.toString.call(value)\n var match = result.match(/\\[object (.*)\\]/)\n if (match && match[1]) {\n return '[' + match[1] + ']'\n }\n } catch {\n // If the previous serialization attempts failed, and we cannot convert using\n // Object.prototype.toString, declare the value unserializable\n }\n return '[Unserializable]'\n}\n\n/**\n * Checks if a toJSON function exists and tries to execute it\n *\n */\nfunction tryToApplyToJSON(value) {\n var object = value\n if (object && typeof object.toJSON === 'function') {\n try {\n return object.toJSON()\n } catch {\n // If toJSON fails, we continue by trying to serialize the value manually\n }\n }\n\n return value\n}\n\n/**\n * Helper function to display the warning when the accumulated character count is over the limit\n */\nfunction warnOverCharacterLimit(maxCharacterCount, changeType, source) {\n display.warn(\n 'The data provided has been ' +\n changeType +\n ' as it is over the limit of ' +\n maxCharacterCount +\n ' characters:',\n source\n )\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAAkE,SAAAG,QAAAC,GAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,GAAA,kBAAAA,GAAA,gBAAAA,GAAA,WAAAA,GAAA,yBAAAC,MAAA,IAAAD,GAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,GAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,GAAA,KAAAD,OAAA,CAAAC,GAAA;AAElE;AACA;AACA,IAAIK,oCAAoC,GAAG,GAAG,GAAGC,wBAAa;;AAE9D;AACA,IAAIC,sBAAsB,GAAG,GAAG;;AAEhC;AACA;AACA,IAAIC,qBAAqB,GAAG,CAAC;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,SAASC,QAAQA,CAACC,MAAM,EAAEC,iBAAiB,EAAE;EAClD,IAAIA,iBAAiB,KAAKC,SAAS,EAAE;IACnCD,iBAAiB,GAAGN,oCAAoC;EAC1D;EACA;EACA,IAAIQ,4BAA4B,GAAG,IAAAC,iCAAkB,EAACC,MAAM,CAACX,SAAS,CAAC;EACvE,IAAIY,2BAA2B,GAAG,IAAAF,iCAAkB,EAACG,KAAK,CAACb,SAAS,CAAC;;EAErE;EACA,IAAIc,cAAc,GAAG,EAAE;EACvB,IAAIC,sBAAsB,GAAG,I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ACC,QAAQ,CAAC,CAAC;EAC5D;EAEA,OAAOD,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASP,eAAeA,CAACO,KAAK,EAAE;EAC9B,IAAI;IACF;IACA,IAAIA,KAAK,YAAYI,KAAK,EAAE;MAC1B,OAAO;QACLC,SAAS,EAAEL,KAAK,CAACK;MACnB,CAAC;IACH;;IAEA;IACA,IAAIC,MAAM,GAAG1C,MAAM,CAACX,SAAS,CAACgD,QAAQ,CAACf,IAAI,CAACc,KAAK,CAAC;IAClD,IAAIO,KAAK,GAAGD,MAAM,CAACC,KAAK,CAAC,iBAAiB,CAAC;IAC3C,IAAIA,KAAK,IAAIA,KAAK,CAAC,CAAC,CAAC,EAAE;MACrB,OAAO,GAAG,GAAGA,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG;IAC7B;EACF,CAAC,CAAC,OAAAC,OAAA,EAAM;IACN;IACA;EAAA;EAEF,OAAO,kBAAkB;AAC3B;;AAEA;AACA;AACA;AACA;AACA,SAASlB,gBAAgBA,CAACU,KAAK,EAAE;EAC/B,IAAIS,MAAM,GAAGT,KAAK;EAClB,IAAIS,MAAM,IAAI,OAAOA,MAAM,CAACC,MAAM,KAAK,UAAU,EAAE;IACjD,IAAI;MACF,OAAOD,MAAM,CAACC,MAAM,CAAC,CAAC;IACxB,CAAC,CAAC,OAAAC,QAAA,EAAM;MACN;IAAA;EAEJ;EAEA,OAAOX,KAAK;AACd;;AAEA;AACA;AACA;AACA,SAASxB,sBAAsBA,CAAChB,iBAAiB,EAAEoD,UAAU,EAAErD,MAAM,EAAE;EACrEsD,gBAAO,CAACC,IAAI,CACV,6BAA6B,GAC3BF,UAAU,GACV,8BAA8B,GAC9BpD,iBAAiB,GACjB,cAAc,EAChBD,MACF,CAAC;AACH"}
@@ -5,31 +5,24 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.BYTES_COMPUTATION_THROTTLING_DELAY = void 0;
7
7
  exports.createContextManager = createContextManager;
8
-
9
8
  var _byteUtils = require("../byteUtils");
10
-
11
9
  var _tools = require("../tools");
12
-
13
10
  var _jsonStringify = require("./jsonStringify");
14
-
15
11
  var _heavyCustomerDataWarning = require("./heavyCustomerDataWarning");
16
-
17
12
  var BYTES_COMPUTATION_THROTTLING_DELAY = 200;
18
13
  exports.BYTES_COMPUTATION_THROTTLING_DELAY = BYTES_COMPUTATION_THROTTLING_DELAY;
19
-
20
14
  function createContextManager(customerDataType, computeBytesCountImpl) {
21
15
  if (typeof computeBytesCountImpl === 'undefined') {
22
16
  computeBytesCountImpl = _byteUtils.computeBytesCount;
23
17
  }
24
-
25
18
  var context = {};
26
19
  var bytesCountCache;
27
- var alreadyWarned = false; // Throttle the bytes computation to minimize the impact on performance.
28
- // Especially useful if the user call context APIs synchronously multiple times in a row
20
+ var alreadyWarned = false;
29
21
 
22
+ // Throttle the bytes computation to minimize the impact on performance.
23
+ // Especially useful if the user call context APIs synchronously multiple times in a row
30
24
  var computeBytesCountThrottled = (0, _tools.throttle)(function (context) {
31
25
  bytesCountCache = computeBytesCountImpl((0, _jsonStringify.jsonStringify)(context));
32
-
33
26
  if (!alreadyWarned) {
34
27
  alreadyWarned = (0, _heavyCustomerDataWarning.warnIfCustomerDataLimitReached)(bytesCountCache, customerDataType);
35
28
  }
@@ -38,24 +31,20 @@ function createContextManager(customerDataType, computeBytesCountImpl) {
38
31
  getBytesCount: function getBytesCount() {
39
32
  return bytesCountCache;
40
33
  },
41
-
42
34
  /** @deprecated use getContext instead */
43
35
  get: function get() {
44
36
  return context;
45
37
  },
46
-
47
38
  /** @deprecated use setContextProperty instead */
48
39
  add: function add(key, value) {
49
40
  context[key] = value;
50
41
  computeBytesCountThrottled(context);
51
42
  },
52
-
53
43
  /** @deprecated renamed to removeContextProperty */
54
44
  remove: function remove(key) {
55
45
  delete context[key];
56
46
  computeBytesCountThrottled(context);
57
47
  },
58
-
59
48
  /** @deprecated use setContext instead */
60
49
  set: function set(newContext) {
61
50
  context = newContext;
@@ -81,4 +70,5 @@ function createContextManager(customerDataType, computeBytesCountImpl) {
81
70
  bytesCountCache = 0;
82
71
  }
83
72
  };
84
- }
73
+ }
74
+ //# sourceMappingURL=contextManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextManager.js","names":["_byteUtils","require","_tools","_jsonStringify","_heavyCustomerDataWarning","BYTES_COMPUTATION_THROTTLING_DELAY","exports","createContextManager","customerDataType","computeBytesCountImpl","computeBytesCount","context","bytesCountCache","alreadyWarned","computeBytesCountThrottled","throttle","jsonStringify","warnIfCustomerDataLimitReached","throttled","getBytesCount","get","add","key","value","remove","set","newContext","getContext","deepClone","setContext","setContextProperty","property","removeContextProperty","clearContext"],"sources":["../../../src/helper/serialisation/contextManager.js"],"sourcesContent":["import { computeBytesCount } from '../byteUtils'\nimport { deepClone, throttle } from '../tools'\nimport { jsonStringify } from './jsonStringify'\nimport { warnIfCustomerDataLimitReached } from './heavyCustomerDataWarning'\n\nexport var BYTES_COMPUTATION_THROTTLING_DELAY = 200\n\nexport function createContextManager(customerDataType, computeBytesCountImpl) {\n if (typeof computeBytesCountImpl === 'undefined') {\n computeBytesCountImpl = computeBytesCount\n }\n var context = {}\n var bytesCountCache\n var alreadyWarned = false\n\n // Throttle the bytes computation to minimize the impact on performance.\n // Especially useful if the user call context APIs synchronously multiple times in a row\n var computeBytesCountThrottled = throttle(function (context) {\n bytesCountCache = computeBytesCountImpl(jsonStringify(context))\n if (!alreadyWarned) {\n alreadyWarned = warnIfCustomerDataLimitReached(\n bytesCountCache,\n customerDataType\n )\n }\n }, BYTES_COMPUTATION_THROTTLING_DELAY).throttled\n\n return {\n getBytesCount: function () {\n return bytesCountCache\n },\n /** @deprecated use getContext instead */\n get: function () {\n return context\n },\n\n /** @deprecated use setContextProperty instead */\n add: function (key, value) {\n context[key] = value\n computeBytesCountThrottled(context)\n },\n\n /** @deprecated renamed to removeContextProperty */\n remove: function (key) {\n delete context[key]\n computeBytesCountThrottled(context)\n },\n\n /** @deprecated use setContext instead */\n set: function (newContext) {\n context = newContext\n computeBytesCountThrottled(context)\n },\n\n getContext: function () {\n return deepClone(context)\n },\n\n setContext: function (newContext) {\n context = deepClone(newContext)\n computeBytesCountThrottled(context)\n },\n\n setContextProperty: function (key, property) {\n context[key] = deepClone(property)\n computeBytesCountThrottled(context)\n },\n\n removeContextProperty: function (key) {\n delete context[key]\n computeBytesCountThrottled(context)\n },\n\n clearContext: function () {\n context = {}\n bytesCountCache = 0\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,yBAAA,GAAAH,OAAA;AAEO,IAAII,kCAAkC,GAAG,GAAG;AAAAC,OAAA,CAAAD,kCAAA,GAAAA,kCAAA;AAE5C,SAASE,oBAAoBA,CAACC,gBAAgB,EAAEC,qBAAqB,EAAE;EAC5E,IAAI,OAAOA,qBAAqB,KAAK,WAAW,EAAE;IAChDA,qBAAqB,GAAGC,4BAAiB;EAC3C;EACA,IAAIC,OAAO,GAAG,CAAC,CAAC;EAChB,IAAIC,eAAe;EACnB,IAAIC,aAAa,GAAG,KAAK;;EAEzB;EACA;EACA,IAAIC,0BAA0B,GAAG,IAAAC,eAAQ,EAAC,UAAUJ,OAAO,EAAE;IAC3DC,eAAe,GAAGH,qBAAqB,CAAC,IAAAO,4BAAa,EAACL,OAAO,CAAC,CAAC;IAC/D,IAAI,CAACE,aAAa,EAAE;MAClBA,aAAa,GAAG,IAAAI,wDAA8B,EAC5CL,eAAe,EACfJ,gBACF,CAAC;IACH;EACF,CAAC,EAAEH,kCAAkC,CAAC,CAACa,SAAS;EAEhD,OAAO;IACLC,aAAa,EAAE,SAAAA,cAAA,EAAY;MACzB,OAAOP,eAAe;IACxB,CAAC;IACD;IACAQ,GAAG,EAAE,SAAAA,IAAA,EAAY;MACf,OAAOT,OAAO;IAChB,CAAC;IAED;IACAU,GAAG,EAAE,SAAAA,IAAUC,GAAG,EAAEC,KAAK,EAAE;MACzBZ,OAAO,CAACW,GAAG,CAAC,GAAGC,KAAK;MACpBT,0BAA0B,CAACH,OAAO,CAAC;IACrC,CAAC;IAED;IACAa,MAAM,EAAE,SAAAA,OAAUF,GAAG,EAAE;MACrB,OAAOX,OAAO,CAACW,GAAG,CAAC;MACnBR,0BAA0B,CAACH,OAAO,CAAC;IACrC,CAAC;IAED;IACAc,GAAG,EAAE,SAAAA,IAAUC,UAAU,EAAE;MACzBf,OAAO,GAAGe,UAAU;MACpBZ,0BAA0B,CAACH,OAAO,CAAC;IACrC,CAAC;IAEDgB,UAAU,EAAE,SAAAA,WAAA,EAAY;MACtB,OAAO,IAAAC,gBAAS,EAACjB,OAAO,CAAC;IAC3B,CAAC;IAEDkB,UAAU,EAAE,SAAAA,WAAUH,UAAU,EAAE;MAChCf,OAAO,GAAG,IAAAiB,gBAAS,EAACF,UAAU,CAAC;MAC/BZ,0BAA0B,CAACH,OAAO,CAAC;IACrC,CAAC;IAEDmB,kBAAkB,EAAE,SAAAA,mBAAUR,GAAG,EAAES,QAAQ,EAAE;MAC3CpB,OAAO,CAACW,GAAG,CAAC,GAAG,IAAAM,gBAAS,EAACG,QAAQ,CAAC;MAClCjB,0BAA0B,CAACH,OAAO,CAAC;IACrC,CAAC;IAEDqB,qBAAqB,EAAE,SAAAA,sBAAUV,GAAG,EAAE;MACpC,OAAOX,OAAO,CAACW,GAAG,CAAC;MACnBR,0BAA0B,CAACH,OAAO,CAAC;IACrC,CAAC;IAEDsB,YAAY,EAAE,SAAAA,aAAA,EAAY;MACxBtB,OAAO,GAAG,CAAC,CAAC;MACZC,eAAe,GAAG,CAAC;IACrB;EACF,CAAC;AACH"}
@@ -5,11 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.CustomerDataType = exports.CUSTOMER_DATA_BYTES_LIMIT = void 0;
7
7
  exports.warnIfCustomerDataLimitReached = warnIfCustomerDataLimitReached;
8
-
9
8
  var _byteUtils = require("../byteUtils");
10
-
11
9
  var _display = require("../display");
12
-
13
10
  // RUM and logs batch bytes limit is 16KB
14
11
  // ensure that we leave room for other event attributes and maintain a decent amount of event per batch
15
12
  // (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB
@@ -22,13 +19,11 @@ var CustomerDataType = {
22
19
  LoggerContext: 'logger context'
23
20
  };
24
21
  exports.CustomerDataType = CustomerDataType;
25
-
26
22
  function warnIfCustomerDataLimitReached(bytesCount, customerDataType) {
27
23
  if (bytesCount > CUSTOMER_DATA_BYTES_LIMIT) {
28
24
  _display.display.warn('The ' + customerDataType + 'data is over ' + CUSTOMER_DATA_BYTES_LIMIT / _byteUtils.ONE_KIBI_BYTE + " KiB. On low connectivity, the SDK has the potential to exhaust the user's upload bandwidth.");
29
-
30
25
  return true;
31
26
  }
32
-
33
27
  return false;
34
- }
28
+ }
29
+ //# sourceMappingURL=heavyCustomerDataWarning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heavyCustomerDataWarning.js","names":["_byteUtils","require","_display","CUSTOMER_DATA_BYTES_LIMIT","ONE_KIBI_BYTE","exports","CustomerDataType","FeatureFlag","User","GlobalContext","LoggerContext","warnIfCustomerDataLimitReached","bytesCount","customerDataType","display","warn"],"sources":["../../../src/helper/serialisation/heavyCustomerDataWarning.js"],"sourcesContent":["import { ONE_KIBI_BYTE } from '../byteUtils'\nimport { display } from '../display'\n\n// RUM and logs batch bytes limit is 16KB\n// ensure that we leave room for other event attributes and maintain a decent amount of event per batch\n// (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB\nexport var CUSTOMER_DATA_BYTES_LIMIT = 3 * ONE_KIBI_BYTE\n\nexport var CustomerDataType = {\n FeatureFlag: 'feature flag evaluation',\n User: 'user',\n GlobalContext: 'global context',\n LoggerContext: 'logger context'\n}\n\nexport function warnIfCustomerDataLimitReached(bytesCount, customerDataType) {\n if (bytesCount > CUSTOMER_DATA_BYTES_LIMIT) {\n display.warn(\n 'The ' +\n customerDataType +\n 'data is over ' +\n CUSTOMER_DATA_BYTES_LIMIT / ONE_KIBI_BYTE +\n \" KiB. On low connectivity, the SDK has the potential to exhaust the user's upload bandwidth.\"\n )\n return true\n }\n return false\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACO,IAAIE,yBAAyB,GAAG,CAAC,GAAGC,wBAAa;AAAAC,OAAA,CAAAF,yBAAA,GAAAA,yBAAA;AAEjD,IAAIG,gBAAgB,GAAG;EAC5BC,WAAW,EAAE,yBAAyB;EACtCC,IAAI,EAAE,MAAM;EACZC,aAAa,EAAE,gBAAgB;EAC/BC,aAAa,EAAE;AACjB,CAAC;AAAAL,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAEM,SAASK,8BAA8BA,CAACC,UAAU,EAAEC,gBAAgB,EAAE;EAC3E,IAAID,UAAU,GAAGT,yBAAyB,EAAE;IAC1CW,gBAAO,CAACC,IAAI,CACV,MAAM,GACJF,gBAAgB,GAChB,eAAe,GACfV,yBAAyB,GAAGC,wBAAa,GACzC,8FACJ,CAAC;IACD,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd"}
@@ -5,11 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.detachToJsonMethod = detachToJsonMethod;
7
7
  exports.jsonStringify = jsonStringify;
8
-
9
8
  var _tools = require("../tools");
10
-
11
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12
-
9
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
13
10
  /**
14
11
  * Custom implementation of JSON.stringify that ignores some toJSON methods. We need to do that
15
12
  * because some sites badly override toJSON on certain objects. Removing all toJSON methods from
@@ -21,15 +18,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
21
18
  function jsonStringify(value, replacer, space) {
22
19
  if (_typeof(value) !== 'object' || value === null) {
23
20
  return JSON.stringify(value);
24
- } // Note: The order matter here. We need to detach toJSON methods on parent classes before their
25
- // subclasses.
26
-
21
+ }
27
22
 
23
+ // Note: The order matter here. We need to detach toJSON methods on parent classes before their
24
+ // subclasses.
28
25
  var restoreObjectPrototypeToJson = detachToJsonMethod(Object.prototype);
29
26
  var restoreArrayPrototypeToJson = detachToJsonMethod(Array.prototype);
30
27
  var restoreValuePrototypeToJson = detachToJsonMethod(Object.getPrototypeOf(value));
31
28
  var restoreValueToJson = detachToJsonMethod(value);
32
-
33
29
  try {
34
30
  return JSON.stringify(value, replacer, space);
35
31
  } catch (_unused) {
@@ -41,17 +37,15 @@ function jsonStringify(value, replacer, space) {
41
37
  restoreValueToJson();
42
38
  }
43
39
  }
44
-
45
40
  function detachToJsonMethod(value) {
46
41
  var object = value;
47
42
  var objectToJson = object.toJSON;
48
-
49
43
  if (objectToJson) {
50
44
  delete object.toJSON;
51
45
  return function () {
52
46
  object.toJSON = objectToJson;
53
47
  };
54
48
  }
55
-
56
49
  return _tools.noop;
57
- }
50
+ }
51
+ //# sourceMappingURL=jsonStringify.js.map