@cloudcare/browser-core 3.1.0 → 3.1.2

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 (44) hide show
  1. package/cjs/browser/htmlDomUtils.js +10 -4
  2. package/cjs/browser/htmlDomUtils.js.map +1 -1
  3. package/cjs/configuration/configuration.js +2 -1
  4. package/cjs/configuration/configuration.js.map +1 -1
  5. package/cjs/helper/enums.js +2 -1
  6. package/cjs/helper/enums.js.map +1 -1
  7. package/cjs/helper/serialisation/contextManager.js +20 -5
  8. package/cjs/helper/serialisation/contextManager.js.map +1 -1
  9. package/cjs/helper/serialisation/storedContextManager.js +47 -0
  10. package/cjs/helper/serialisation/storedContextManager.js.map +1 -0
  11. package/cjs/helper/tools.js +18 -3
  12. package/cjs/helper/tools.js.map +1 -1
  13. package/cjs/index.js +11 -0
  14. package/cjs/index.js.map +1 -1
  15. package/cjs/telemetry/telemetry.js.map +1 -1
  16. package/cjs/transport/sendWithRetryStrategy.js +0 -5
  17. package/cjs/transport/sendWithRetryStrategy.js.map +1 -1
  18. package/esm/browser/htmlDomUtils.js +9 -3
  19. package/esm/browser/htmlDomUtils.js.map +1 -1
  20. package/esm/configuration/configuration.js +2 -1
  21. package/esm/configuration/configuration.js.map +1 -1
  22. package/esm/helper/enums.js +2 -1
  23. package/esm/helper/enums.js.map +1 -1
  24. package/esm/helper/serialisation/contextManager.js +21 -6
  25. package/esm/helper/serialisation/contextManager.js.map +1 -1
  26. package/esm/helper/serialisation/storedContextManager.js +39 -0
  27. package/esm/helper/serialisation/storedContextManager.js.map +1 -0
  28. package/esm/helper/tools.js +17 -3
  29. package/esm/helper/tools.js.map +1 -1
  30. package/esm/index.js +1 -0
  31. package/esm/index.js.map +1 -1
  32. package/esm/telemetry/telemetry.js.map +1 -1
  33. package/esm/transport/sendWithRetryStrategy.js +0 -5
  34. package/esm/transport/sendWithRetryStrategy.js.map +1 -1
  35. package/package.json +2 -2
  36. package/src/browser/htmlDomUtils.js +8 -3
  37. package/src/configuration/configuration.js +2 -1
  38. package/src/helper/enums.js +2 -1
  39. package/src/helper/serialisation/contextManager.js +21 -6
  40. package/src/helper/serialisation/storedContextManager.js +56 -0
  41. package/src/helper/tools.js +18 -4
  42. package/src/index.js +1 -0
  43. package/src/telemetry/telemetry.js +4 -3
  44. package/src/transport/sendWithRetryStrategy.js +1 -5
@@ -1 +1 @@
1
- {"version":3,"file":"sendWithRetryStrategy.js","names":["clocksNow","ONE_SECOND","ONE_MEBI_BYTE","ONE_KIBI_BYTE","ErrorSource","setTimeout","MAX_ONGOING_BYTES_COUNT","MAX_ONGOING_REQUESTS","MAX_QUEUE_BYTES_COUNT","MAX_BACKOFF_TIME","INITIAL_BACKOFF_TIME","TransportStatus","UP","FAILURE_DETECTED","DOWN","RetryReason","AFTER_SUCCESS","AFTER_RESUME","sendWithRetryStrategy","payload","state","sendStrategy","endpointUrl","reportError","transportStatus","queuedPayloads","size","bandwidthMonitor","canHandle","send","onSuccess","retryQueuedPayloads","onFailure","enqueue","scheduleRetry","first","dequeue","currentBackoffTime","Math","min","responseData","add","response","remove","shouldRetryRequest","ongoingRequestCount","lastFailureStatus","status","reason","isFull","queueFullReported","message","source","AGENT","startClocks","previousQueue","newPayloadQueue","type","navigator","onLine","newRetryState","newBandwidthMonitor","queue","bytesCount","push","shift","length","ongoingByteCount"],"sources":["../../src/transport/sendWithRetryStrategy.js"],"sourcesContent":["import { clocksNow, ONE_SECOND } from '../helper/tools'\nimport { ONE_MEBI_BYTE, ONE_KIBI_BYTE } from '../helper/byteUtils'\nimport { ErrorSource } from '../helper/errorTools'\nimport { setTimeout } from '../helper/timer'\nexport var MAX_ONGOING_BYTES_COUNT = 80 * ONE_KIBI_BYTE\nexport var MAX_ONGOING_REQUESTS = 32\nexport var MAX_QUEUE_BYTES_COUNT = 3 * ONE_MEBI_BYTE\nexport var MAX_BACKOFF_TIME = 256 * ONE_SECOND\nexport var INITIAL_BACKOFF_TIME = ONE_SECOND\n\nvar TransportStatus = {\n UP: 0,\n FAILURE_DETECTED: 1,\n DOWN: 2\n}\n\nvar RetryReason = {\n AFTER_SUCCESS: 0,\n AFTER_RESUME: 1\n}\n\nexport function sendWithRetryStrategy(\n payload,\n state,\n sendStrategy,\n endpointUrl,\n reportError\n) {\n if (\n state.transportStatus === TransportStatus.UP &&\n state.queuedPayloads.size() === 0 &&\n state.bandwidthMonitor.canHandle(payload)\n ) {\n send(payload, state, sendStrategy, {\n onSuccess: function () {\n return retryQueuedPayloads(\n RetryReason.AFTER_SUCCESS,\n state,\n sendStrategy,\n endpointUrl,\n reportError\n )\n },\n onFailure: function () {\n state.queuedPayloads.enqueue(payload)\n scheduleRetry(state, sendStrategy, endpointUrl, reportError)\n }\n })\n } else {\n state.queuedPayloads.enqueue(payload)\n }\n}\n\nfunction scheduleRetry(state, sendStrategy, endpointUrl, reportError) {\n if (state.transportStatus !== TransportStatus.DOWN) {\n return\n }\n setTimeout(function () {\n var payload = state.queuedPayloads.first()\n send(payload, state, sendStrategy, {\n onSuccess: function () {\n state.queuedPayloads.dequeue()\n // if (state.lastFailureStatus !== 0) {\n // addTelemetryDebug('resuming after transport down', {\n // failureStatus: state.lastFailureStatus,\n // })\n // }\n state.currentBackoffTime = INITIAL_BACKOFF_TIME\n retryQueuedPayloads(\n RetryReason.AFTER_RESUME,\n state,\n sendStrategy,\n endpointUrl,\n reportError\n )\n },\n onFailure: function () {\n state.currentBackoffTime = Math.min(\n MAX_BACKOFF_TIME,\n state.currentBackoffTime * 2\n )\n scheduleRetry(state, sendStrategy, endpointUrl, reportError)\n }\n })\n }, state.currentBackoffTime)\n}\n\nfunction send(payload, state, sendStrategy, responseData) {\n var onSuccess = responseData.onSuccess\n var onFailure = responseData.onFailure\n state.bandwidthMonitor.add(payload)\n sendStrategy(payload, function (response) {\n state.bandwidthMonitor.remove(payload)\n if (!shouldRetryRequest(response)) {\n state.transportStatus = TransportStatus.UP\n onSuccess()\n } else {\n // do not consider transport down if another ongoing request could succeed\n state.transportStatus =\n state.bandwidthMonitor.ongoingRequestCount > 0\n ? TransportStatus.FAILURE_DETECTED\n : TransportStatus.DOWN\n state.lastFailureStatus = response.status\n onFailure()\n }\n })\n}\n\nfunction retryQueuedPayloads(\n reason,\n state,\n sendStrategy,\n endpointUrl,\n reportError\n) {\n if (\n reason === RetryReason.AFTER_SUCCESS &&\n state.queuedPayloads.isFull() &&\n !state.queueFullReported\n ) {\n reportError({\n message:\n 'Reached max ' +\n endpointUrl +\n ' events size queued for upload: ' +\n MAX_QUEUE_BYTES_COUNT / ONE_MEBI_BYTE +\n 'MiB',\n source: ErrorSource.AGENT,\n startClocks: clocksNow()\n })\n state.queueFullReported = true\n }\n var previousQueue = state.queuedPayloads\n state.queuedPayloads = newPayloadQueue()\n while (previousQueue.size() > 0) {\n sendWithRetryStrategy(\n previousQueue.dequeue(),\n state,\n sendStrategy,\n endpointUrl,\n reportError\n )\n }\n}\n\nfunction shouldRetryRequest(response) {\n return (\n response.type !== 'opaque' &&\n ((response.status === 0 && !navigator.onLine) ||\n response.status === 408 ||\n response.status === 429 ||\n response.status >= 500)\n )\n}\nexport function newRetryState() {\n return {\n transportStatus: TransportStatus.UP,\n lastFailureStatus: 0,\n currentBackoffTime: INITIAL_BACKOFF_TIME,\n bandwidthMonitor: newBandwidthMonitor(),\n queuedPayloads: newPayloadQueue(),\n queueFullReported: false\n }\n}\n\nfunction newPayloadQueue() {\n var queue = []\n return {\n bytesCount: 0,\n enqueue: function (payload) {\n if (this.isFull()) {\n return\n }\n queue.push(payload)\n this.bytesCount += payload.bytesCount\n },\n first: function () {\n return queue[0]\n },\n dequeue: function () {\n var payload = queue.shift()\n if (payload) {\n this.bytesCount -= payload.bytesCount\n }\n return payload\n },\n size: function () {\n return queue.length\n },\n isFull: function () {\n return this.bytesCount >= MAX_QUEUE_BYTES_COUNT\n }\n }\n}\n\nfunction newBandwidthMonitor() {\n return {\n ongoingRequestCount: 0,\n ongoingByteCount: 0,\n canHandle: function (payload) {\n return (\n this.ongoingRequestCount === 0 ||\n (this.ongoingByteCount + payload.bytesCount <=\n MAX_ONGOING_BYTES_COUNT &&\n this.ongoingRequestCount < MAX_ONGOING_REQUESTS)\n )\n },\n add: function (payload) {\n this.ongoingRequestCount += 1\n this.ongoingByteCount += payload.bytesCount\n },\n remove: function (payload) {\n this.ongoingRequestCount -= 1\n this.ongoingByteCount -= payload.bytesCount\n }\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,UAAU,QAAQ,iBAAiB;AACvD,SAASC,aAAa,EAAEC,aAAa,QAAQ,qBAAqB;AAClE,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,OAAO,IAAIC,uBAAuB,GAAG,EAAE,GAAGH,aAAa;AACvD,OAAO,IAAII,oBAAoB,GAAG,EAAE;AACpC,OAAO,IAAIC,qBAAqB,GAAG,CAAC,GAAGN,aAAa;AACpD,OAAO,IAAIO,gBAAgB,GAAG,GAAG,GAAGR,UAAU;AAC9C,OAAO,IAAIS,oBAAoB,GAAGT,UAAU;AAE5C,IAAIU,eAAe,GAAG;EACpBC,EAAE,EAAE,CAAC;EACLC,gBAAgB,EAAE,CAAC;EACnBC,IAAI,EAAE;AACR,CAAC;AAED,IAAIC,WAAW,GAAG;EAChBC,aAAa,EAAE,CAAC;EAChBC,YAAY,EAAE;AAChB,CAAC;AAED,OAAO,SAASC,qBAAqBA,CACnCC,OAAO,EACPC,KAAK,EACLC,YAAY,EACZC,WAAW,EACXC,WAAW,EACX;EACA,IACEH,KAAK,CAACI,eAAe,KAAKb,eAAe,CAACC,EAAE,IAC5CQ,KAAK,CAACK,cAAc,CAACC,IAAI,CAAC,CAAC,KAAK,CAAC,IACjCN,KAAK,CAACO,gBAAgB,CAACC,SAAS,CAACT,OAAO,CAAC,EACzC;IACAU,IAAI,CAACV,OAAO,EAAEC,KAAK,EAAEC,YAAY,EAAE;MACjCS,SAAS,EAAE,SAAAA,UAAA,EAA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TES_COUNT","MAX_ONGOING_REQUESTS","MAX_QUEUE_BYTES_COUNT","MAX_BACKOFF_TIME","INITIAL_BACKOFF_TIME","TransportStatus","UP","FAILURE_DETECTED","DOWN","RetryReason","AFTER_SUCCESS","AFTER_RESUME","sendWithRetryStrategy","payload","state","sendStrategy","endpointUrl","reportError","transportStatus","queuedPayloads","size","bandwidthMonitor","canHandle","send","onSuccess","retryQueuedPayloads","onFailure","enqueue","scheduleRetry","first","dequeue","currentBackoffTime","Math","min","responseData","add","response","remove","shouldRetryRequest","ongoingRequestCount","lastFailureStatus","status","reason","isFull","queueFullReported","message","source","AGENT","startClocks","previousQueue","newPayloadQueue","type","navigator","onLine","newRetryState","newBandwidthMonitor","queue","bytesCount","push","shift","length","ongoingByteCount"],"sources":["../../src/transport/sendWithRetryStrategy.js"],"sourcesContent":["import { clocksNow, ONE_SECOND } from '../helper/tools'\nimport { ONE_MEBI_BYTE, ONE_KIBI_BYTE } from '../helper/byteUtils'\nimport { ErrorSource } from '../helper/errorTools'\nimport { setTimeout } from '../helper/timer'\nexport var MAX_ONGOING_BYTES_COUNT = 80 * ONE_KIBI_BYTE\nexport var MAX_ONGOING_REQUESTS = 32\nexport var MAX_QUEUE_BYTES_COUNT = 3 * ONE_MEBI_BYTE\nexport var MAX_BACKOFF_TIME = 256 * ONE_SECOND\nexport var INITIAL_BACKOFF_TIME = ONE_SECOND\n\nvar TransportStatus = {\n UP: 0,\n FAILURE_DETECTED: 1,\n DOWN: 2\n}\n\nvar RetryReason = {\n AFTER_SUCCESS: 0,\n AFTER_RESUME: 1\n}\n\nexport function sendWithRetryStrategy(\n payload,\n state,\n sendStrategy,\n endpointUrl,\n reportError\n) {\n if (\n state.transportStatus === TransportStatus.UP &&\n state.queuedPayloads.size() === 0 &&\n state.bandwidthMonitor.canHandle(payload)\n ) {\n send(payload, state, sendStrategy, {\n onSuccess: function () {\n return retryQueuedPayloads(\n RetryReason.AFTER_SUCCESS,\n state,\n sendStrategy,\n endpointUrl,\n reportError\n )\n },\n onFailure: function () {\n state.queuedPayloads.enqueue(payload)\n scheduleRetry(state, sendStrategy, endpointUrl, reportError)\n }\n })\n } else {\n state.queuedPayloads.enqueue(payload)\n }\n}\n\nfunction scheduleRetry(state, sendStrategy, endpointUrl, reportError) {\n if (state.transportStatus !== TransportStatus.DOWN) {\n return\n }\n setTimeout(function () {\n var payload = state.queuedPayloads.first()\n send(payload, state, sendStrategy, {\n onSuccess: function () {\n state.queuedPayloads.dequeue()\n\n state.currentBackoffTime = INITIAL_BACKOFF_TIME\n retryQueuedPayloads(\n RetryReason.AFTER_RESUME,\n state,\n sendStrategy,\n endpointUrl,\n reportError\n )\n },\n onFailure: function () {\n state.currentBackoffTime = Math.min(\n MAX_BACKOFF_TIME,\n state.currentBackoffTime * 2\n )\n scheduleRetry(state, sendStrategy, endpointUrl, reportError)\n }\n })\n }, state.currentBackoffTime)\n}\n\nfunction send(payload, state, sendStrategy, responseData) {\n var onSuccess = responseData.onSuccess\n var onFailure = responseData.onFailure\n state.bandwidthMonitor.add(payload)\n sendStrategy(payload, function (response) {\n state.bandwidthMonitor.remove(payload)\n if (!shouldRetryRequest(response)) {\n state.transportStatus = TransportStatus.UP\n onSuccess()\n } else {\n // do not consider transport down if another ongoing request could succeed\n state.transportStatus =\n state.bandwidthMonitor.ongoingRequestCount > 0\n ? TransportStatus.FAILURE_DETECTED\n : TransportStatus.DOWN\n state.lastFailureStatus = response.status\n onFailure()\n }\n })\n}\n\nfunction retryQueuedPayloads(\n reason,\n state,\n sendStrategy,\n endpointUrl,\n reportError\n) {\n if (\n reason === RetryReason.AFTER_SUCCESS &&\n state.queuedPayloads.isFull() &&\n !state.queueFullReported\n ) {\n reportError({\n message:\n 'Reached max ' +\n endpointUrl +\n ' events size queued for upload: ' +\n MAX_QUEUE_BYTES_COUNT / ONE_MEBI_BYTE +\n 'MiB',\n source: ErrorSource.AGENT,\n startClocks: clocksNow()\n })\n state.queueFullReported = true\n }\n var previousQueue = state.queuedPayloads\n state.queuedPayloads = newPayloadQueue()\n while (previousQueue.size() > 0) {\n sendWithRetryStrategy(\n previousQueue.dequeue(),\n state,\n sendStrategy,\n endpointUrl,\n reportError\n )\n }\n}\n\nfunction shouldRetryRequest(response) {\n return (\n response.type !== 'opaque' &&\n ((response.status === 0 && !navigator.onLine) ||\n response.status === 408 ||\n response.status === 429 ||\n response.status >= 500)\n )\n}\nexport function newRetryState() {\n return {\n transportStatus: TransportStatus.UP,\n lastFailureStatus: 0,\n currentBackoffTime: INITIAL_BACKOFF_TIME,\n bandwidthMonitor: newBandwidthMonitor(),\n queuedPayloads: newPayloadQueue(),\n queueFullReported: false\n }\n}\n\nfunction newPayloadQueue() {\n var queue = []\n return {\n bytesCount: 0,\n enqueue: function (payload) {\n if (this.isFull()) {\n return\n }\n queue.push(payload)\n this.bytesCount += payload.bytesCount\n },\n first: function () {\n return queue[0]\n },\n dequeue: function () {\n var payload = queue.shift()\n if (payload) {\n this.bytesCount -= payload.bytesCount\n }\n return payload\n },\n size: function () {\n return queue.length\n },\n isFull: function () {\n return this.bytesCount >= MAX_QUEUE_BYTES_COUNT\n }\n }\n}\n\nfunction newBandwidthMonitor() {\n return {\n ongoingRequestCount: 0,\n ongoingByteCount: 0,\n canHandle: function (payload) {\n return (\n this.ongoingRequestCount === 0 ||\n (this.ongoingByteCount + payload.bytesCount <=\n MAX_ONGOING_BYTES_COUNT &&\n this.ongoingRequestCount < MAX_ONGOING_REQUESTS)\n )\n },\n add: function (payload) {\n this.ongoingRequestCount += 1\n this.ongoingByteCount += payload.bytesCount\n },\n remove: function (payload) {\n this.ongoingRequestCount -= 1\n this.ongoingByteCount -= payload.bytesCount\n }\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,UAAU,QAAQ,iBAAiB;AACvD,SAASC,aAAa,EAAEC,aAAa,QAAQ,qBAAqB;AAClE,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,OAAO,IAAIC,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,EAAG;EAC7B,OAAO;IACLhB,mBAAmB,EAAE,CAAC;IACtBsB,gBAAgB,EAAE,CAAC;IACnBvC,SAAS,EAAE,SAAAA,UAAUT,OAAO,EAAE;MAC5B,OACE,IAAI,CAAC0B,mBAAmB,KAAK,CAAC,IAC7B,IAAI,CAACsB,gBAAgB,GAAGhD,OAAO,CAAC4C,UAAU,IACzCzD,uBAAuB,IACvB,IAAI,CAACuC,mBAAmB,GAAGtC,oBAAqB;IAEtD,CAAC;IACDkC,GAAG,EAAE,SAAAA,IAAUtB,OAAO,EAAE;MACtB,IAAI,CAAC0B,mBAAmB,IAAI,CAAC;MAC7B,IAAI,CAACsB,gBAAgB,IAAIhD,OAAO,CAAC4C,UAAU;IAC7C,CAAC;IACDpB,MAAM,EAAE,SAAAA,OAAUxB,OAAO,EAAE;MACzB,IAAI,CAAC0B,mBAAmB,IAAI,CAAC;MAC7B,IAAI,CAACsB,gBAAgB,IAAIhD,OAAO,CAAC4C,UAAU;IAC7C;EACF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcare/browser-core",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
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": "6863a7abc368adb01df9a2de5efbed111db1e286"
23
+ "gitHead": "76a8647c7e9154baecb6c5e6f0cf8dd76e13d508"
24
24
  }
@@ -23,10 +23,15 @@ export function isNodeShadowRoot(node) {
23
23
  )
24
24
  }
25
25
 
26
- export function getChildNodes(node) {
27
- return isNodeShadowHost(node) ? node.shadowRoot.childNodes : node.childNodes
26
+ // export function getChildNodes(node) {
27
+ // return isNodeShadowHost(node) ? node.shadowRoot.childNodes : node.childNodes
28
+ // }
29
+ export function forEachChildNodes(node, callback) {
30
+ node.childNodes.forEach(callback)
31
+ if (isNodeShadowHost(node)) {
32
+ callback(node.shadowRoot)
33
+ }
28
34
  }
29
-
30
35
  /**
31
36
  * Return `host` in case if the current node is a shadow root otherwise will return the `parentNode`
32
37
  */
@@ -82,7 +82,8 @@ export function validateAndBuildConfiguration(initConfiguration) {
82
82
  */
83
83
  batchMessagesLimit: 50,
84
84
  messageBytesLimit: 256 * ONE_KIBI_BYTE,
85
- resourceUrlLimit: 5 * ONE_KIBI_BYTE
85
+ resourceUrlLimit: 5 * ONE_KIBI_BYTE,
86
+ storeContextsToLocal: !!initConfiguration.storeContextsToLocal
86
87
  },
87
88
  computeTransportConfiguration(initConfiguration)
88
89
  )
@@ -31,7 +31,8 @@ export var DOM_EVENT = {
31
31
  PLAY: 'play',
32
32
  PAUSE: 'pause',
33
33
  SECURITY_POLICY_VIOLATION: 'securitypolicyviolation',
34
- SELECTION_CHANGE: 'selectionchange'
34
+ SELECTION_CHANGE: 'selectionchange',
35
+ STORAGE: 'storage'
35
36
  }
36
37
  export var ResourceType = {
37
38
  DOCUMENT: 'document',
@@ -1,6 +1,8 @@
1
1
  import { computeBytesCount } from '../byteUtils'
2
- import { deepClone, throttle } from '../tools'
2
+ import { deepClone, throttle, getType } from '../tools'
3
+ import { sanitize } from '../sanitize'
3
4
  import { jsonStringify } from './jsonStringify'
5
+ import { Observable } from '../observable'
4
6
  import { warnIfCustomerDataLimitReached } from './heavyCustomerDataWarning'
5
7
 
6
8
  export var BYTES_COMPUTATION_THROTTLING_DELAY = 200
@@ -12,7 +14,7 @@ export function createContextManager(customerDataType, computeBytesCountImpl) {
12
14
  var context = {}
13
15
  var bytesCountCache
14
16
  var alreadyWarned = false
15
-
17
+ var changeObservable = new Observable()
16
18
  // Throttle the bytes computation to minimize the impact on performance.
17
19
  // Especially useful if the user call context APIs synchronously multiple times in a row
18
20
  var computeBytesCountThrottled = throttle(function (context) {
@@ -25,7 +27,7 @@ export function createContextManager(customerDataType, computeBytesCountImpl) {
25
27
  }
26
28
  }, BYTES_COMPUTATION_THROTTLING_DELAY).throttled
27
29
 
28
- return {
30
+ var contextManager = {
29
31
  getBytesCount: function () {
30
32
  return bytesCountCache
31
33
  },
@@ -38,18 +40,21 @@ export function createContextManager(customerDataType, computeBytesCountImpl) {
38
40
  add: function (key, value) {
39
41
  context[key] = value
40
42
  computeBytesCountThrottled(context)
43
+ changeObservable.notify()
41
44
  },
42
45
 
43
46
  /** @deprecated renamed to removeContextProperty */
44
47
  remove: function (key) {
45
48
  delete context[key]
46
49
  computeBytesCountThrottled(context)
50
+ changeObservable.notify()
47
51
  },
48
52
 
49
53
  /** @deprecated use setContext instead */
50
54
  set: function (newContext) {
51
55
  context = newContext
52
56
  computeBytesCountThrottled(context)
57
+ changeObservable.notify()
53
58
  },
54
59
 
55
60
  getContext: function () {
@@ -57,23 +62,33 @@ export function createContextManager(customerDataType, computeBytesCountImpl) {
57
62
  },
58
63
 
59
64
  setContext: function (newContext) {
60
- context = deepClone(newContext)
61
- computeBytesCountThrottled(context)
65
+ if (getType(newContext) === 'object') {
66
+ context = sanitize(newContext)
67
+ computeBytesCountThrottled(context)
68
+ } else {
69
+ contextManager.clearContext()
70
+ }
71
+ changeObservable.notify()
62
72
  },
63
73
 
64
74
  setContextProperty: function (key, property) {
65
75
  context[key] = deepClone(property)
66
76
  computeBytesCountThrottled(context)
77
+ changeObservable.notify()
67
78
  },
68
79
 
69
80
  removeContextProperty: function (key) {
70
81
  delete context[key]
71
82
  computeBytesCountThrottled(context)
83
+ changeObservable.notify()
72
84
  },
73
85
 
74
86
  clearContext: function () {
75
87
  context = {}
76
88
  bytesCountCache = 0
77
- }
89
+ changeObservable.notify()
90
+ },
91
+ changeObservable: changeObservable
78
92
  }
93
+ return contextManager
79
94
  }
@@ -0,0 +1,56 @@
1
+ import { computeBytesCount } from '../byteUtils'
2
+ import { DOM_EVENT } from '../enums'
3
+ import { map } from '../tools'
4
+ import { addEventListener } from '../../browser/addEventListener'
5
+ import { createContextManager } from './contextManager'
6
+ var CONTEXT_STORE_KEY_PREFIX = '_gc_s'
7
+
8
+ var storageListeners = []
9
+
10
+ export function createStoredContextManager(
11
+ productKey,
12
+ customerDataType,
13
+ computeBytesCountImpl
14
+ ) {
15
+ if (computeBytesCountImpl === undefined) {
16
+ computeBytesCountImpl = computeBytesCount
17
+ }
18
+ var storageKey = buildStorageKey(productKey, customerDataType)
19
+ var contextManager = createContextManager(
20
+ customerDataType,
21
+ computeBytesCountImpl
22
+ )
23
+
24
+ synchronizeWithStorage()
25
+ storageListeners.push(
26
+ addEventListener(window, DOM_EVENT.STORAGE, function (params) {
27
+ if (storageKey === params.key) {
28
+ synchronizeWithStorage()
29
+ }
30
+ })
31
+ )
32
+ contextManager.changeObservable.subscribe(dumpToStorage)
33
+ function synchronizeWithStorage() {
34
+ var rawContext = localStorage.getItem(storageKey)
35
+ var context = rawContext !== null ? JSON.parse(rawContext) : {}
36
+ contextManager.setContext(context)
37
+ }
38
+
39
+ function dumpToStorage() {
40
+ localStorage.setItem(
41
+ storageKey,
42
+ JSON.stringify(contextManager.getContext())
43
+ )
44
+ }
45
+ return contextManager
46
+ }
47
+
48
+ export function buildStorageKey(productKey, customerDataType) {
49
+ return CONTEXT_STORE_KEY_PREFIX + '_' + productKey + '_' + customerDataType
50
+ }
51
+
52
+ export function removeStorageListeners() {
53
+ map(storageListeners, function (listener) {
54
+ listener.stop()
55
+ })
56
+ }
@@ -1594,14 +1594,28 @@ export function getLocationOrigin() {
1594
1594
  return getLinkElementOrigin(window.location)
1595
1595
  }
1596
1596
 
1597
+ var browserIsIE
1597
1598
  export function isIE() {
1598
- return Boolean(document.documentMode)
1599
+ if (browserIsIE === undefined) {
1600
+ browserIsIE = Boolean(document.documentMode)
1601
+ }
1602
+ return browserIsIE
1599
1603
  }
1600
-
1604
+ var browserIsChromium
1601
1605
  export function isChromium() {
1602
- return !!window.chrome || /HeadlessChrome/.test(window.navigator.userAgent)
1606
+ if (browserIsChromium === undefined) {
1607
+ browserIsChromium =
1608
+ !!window.chrome || /HeadlessChrome/.test(window.navigator.userAgent)
1609
+ }
1610
+ return browserIsChromium
1611
+ }
1612
+ var browserIsSafari
1613
+ export function isSafari() {
1614
+ if (browserIsSafari === undefined) {
1615
+ browserIsSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
1616
+ }
1617
+ return browserIsSafari
1603
1618
  }
1604
-
1605
1619
  /**
1606
1620
  * IE fallback
1607
1621
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/origin
package/src/index.js CHANGED
@@ -47,6 +47,7 @@ export * from './helper/serialisation/contextManager'
47
47
  export * from './helper/serialisation/heavyCustomerDataWarning'
48
48
  export * from './helper/serialisation/jsonStringify'
49
49
  export * from './helper/serialisation/rowData'
50
+ export * from './helper/serialisation/storedContextManager'
50
51
  export * from './user'
51
52
 
52
53
  export * from './telemetry/telemetry'
@@ -153,12 +153,13 @@ export function formatError(e) {
153
153
  }
154
154
 
155
155
  export function scrubCustomerFrames(stackTrace) {
156
- stackTrace.stack = stackTrace.stack.filter(
157
- (frame) =>
156
+ stackTrace.stack = stackTrace.stack.filter(function (frame) {
157
+ return (
158
158
  !frame.url ||
159
159
  ALLOWED_FRAME_URLS.some(function (allowedFrameUrl) {
160
160
  return startsWith(frame.url, allowedFrameUrl)
161
161
  })
162
- )
162
+ )
163
+ })
163
164
  return stackTrace
164
165
  }
@@ -60,11 +60,7 @@ function scheduleRetry(state, sendStrategy, endpointUrl, reportError) {
60
60
  send(payload, state, sendStrategy, {
61
61
  onSuccess: function () {
62
62
  state.queuedPayloads.dequeue()
63
- // if (state.lastFailureStatus !== 0) {
64
- // addTelemetryDebug('resuming after transport down', {
65
- // failureStatus: state.lastFailureStatus,
66
- // })
67
- // }
63
+
68
64
  state.currentBackoffTime = INITIAL_BACKOFF_TIME
69
65
  retryQueuedPayloads(
70
66
  RetryReason.AFTER_RESUME,