@openobserve/browser-core 0.2.11-rc1 → 0.2.11
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/boot/init.js +1 -1
- package/cjs/boot/init.js.map +1 -1
- package/cjs/browser/addEventListener.d.ts +4 -12
- package/cjs/browser/addEventListener.js +8 -50
- package/cjs/browser/addEventListener.js.map +1 -1
- package/cjs/browser/cookie.d.ts +0 -7
- package/cjs/browser/cookie.js +2 -19
- package/cjs/browser/cookie.js.map +1 -1
- package/cjs/browser/fetchObservable.js +19 -14
- package/cjs/browser/fetchObservable.js.map +1 -1
- package/cjs/browser/pageExitObservable.js +7 -6
- package/cjs/browser/pageExitObservable.js.map +1 -1
- package/cjs/browser/runOnReadyState.js +1 -1
- package/cjs/browser/runOnReadyState.js.map +1 -1
- package/cjs/browser/xhrObservable.d.ts +2 -1
- package/cjs/browser/xhrObservable.js +34 -26
- package/cjs/browser/xhrObservable.js.map +1 -1
- package/cjs/domain/configuration/configuration.d.ts +12 -17
- package/cjs/domain/configuration/configuration.js +9 -8
- package/cjs/domain/configuration/configuration.js.map +1 -1
- package/cjs/domain/configuration/endpointBuilder.d.ts +10 -6
- package/cjs/domain/configuration/endpointBuilder.js +33 -23
- package/cjs/domain/configuration/endpointBuilder.js.map +1 -1
- package/cjs/domain/configuration/index.d.ts +1 -2
- package/cjs/domain/configuration/index.js +1 -3
- package/cjs/domain/configuration/index.js.map +1 -1
- package/cjs/domain/configuration/tags.js.map +1 -1
- package/cjs/domain/configuration/transportConfiguration.js +1 -1
- package/cjs/domain/configuration/transportConfiguration.js.map +1 -1
- package/cjs/domain/console/consoleObservable.js +7 -4
- package/cjs/domain/console/consoleObservable.js.map +1 -1
- package/cjs/domain/deflate/index.d.ts +1 -0
- package/cjs/domain/{connectivity → deflate}/index.js +1 -1
- package/cjs/domain/deflate/index.js.map +1 -0
- package/cjs/domain/deflate/types.d.ts +26 -0
- package/cjs/domain/error/error.d.ts +1 -1
- package/cjs/domain/error/error.js +3 -3
- package/cjs/domain/error/error.js.map +1 -1
- package/cjs/domain/error/error.types.d.ts +2 -2
- package/cjs/domain/error/error.types.js.map +1 -1
- package/cjs/domain/error/trackRuntimeError.d.ts +0 -8
- package/cjs/domain/error/trackRuntimeError.js +6 -39
- package/cjs/domain/error/trackRuntimeError.js.map +1 -1
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -1
- package/cjs/domain/report/browser.types.d.ts +0 -10
- package/cjs/domain/report/reportObservable.d.ts +0 -2
- package/cjs/domain/report/reportObservable.js +7 -7
- package/cjs/domain/report/reportObservable.js.map +1 -1
- package/cjs/domain/session/oldCookiesMigration.js +4 -4
- package/cjs/domain/session/oldCookiesMigration.js.map +1 -1
- package/cjs/domain/session/sessionManager.js +2 -2
- package/cjs/domain/session/sessionManager.js.map +1 -1
- package/cjs/domain/session/sessionState.js.map +1 -1
- package/cjs/domain/session/sessionStore.js.map +1 -1
- package/cjs/domain/session/sessionStoreOperations.d.ts +5 -0
- package/cjs/domain/session/sessionStoreOperations.js +14 -6
- package/cjs/domain/session/sessionStoreOperations.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionInCookie.js +2 -13
- package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +0 -1
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -1
- package/cjs/domain/synthetics/syntheticsWorkerValues.js +3 -3
- package/cjs/domain/synthetics/syntheticsWorkerValues.js.map +1 -1
- package/cjs/domain/telemetry/rawTelemetryEvent.types.d.ts +0 -4
- package/cjs/domain/telemetry/telemetry.d.ts +1 -5
- package/cjs/domain/telemetry/telemetry.js +6 -17
- package/cjs/domain/telemetry/telemetry.js.map +1 -1
- package/cjs/domain/telemetry/telemetryEvent.types.d.ts +2 -18
- package/cjs/domain/tracekit/computeStackTrace.d.ts +5 -0
- package/cjs/domain/{error → tracekit}/computeStackTrace.js +4 -28
- package/cjs/domain/tracekit/computeStackTrace.js.map +1 -0
- package/cjs/domain/tracekit/index.d.ts +3 -0
- package/cjs/domain/tracekit/index.js +8 -0
- package/cjs/domain/tracekit/index.js.map +1 -0
- package/cjs/domain/tracekit/tracekit.d.ts +35 -0
- package/cjs/domain/tracekit/tracekit.js +95 -0
- package/cjs/domain/tracekit/tracekit.js.map +1 -0
- package/cjs/domain/tracekit/types.d.ts +44 -0
- package/cjs/domain/{context/contextConstants.js → tracekit/types.js} +1 -1
- package/cjs/domain/tracekit/types.js.map +1 -0
- package/cjs/domain/user/user.js.map +1 -1
- package/cjs/index.d.ts +63 -0
- package/cjs/index.js +155 -0
- package/cjs/index.js.map +1 -0
- package/cjs/tools/abstractLifeCycle.js.map +1 -1
- package/cjs/tools/boundedBuffer.js.map +1 -1
- package/cjs/tools/catchUserErrors.js.map +1 -1
- package/cjs/tools/display.d.ts +2 -2
- package/cjs/tools/display.js +17 -13
- package/cjs/tools/display.js.map +1 -1
- package/cjs/tools/experimentalFeatures.d.ts +5 -3
- package/cjs/tools/experimentalFeatures.js +4 -2
- package/cjs/tools/experimentalFeatures.js.map +1 -1
- package/cjs/tools/getGlobalObject.js.map +1 -1
- package/cjs/tools/getZoneJsOriginalValue.js.map +1 -1
- package/cjs/tools/instrumentMethod.d.ts +10 -50
- package/cjs/tools/instrumentMethod.js +36 -59
- package/cjs/tools/instrumentMethod.js.map +1 -1
- package/cjs/tools/matchOption.js.map +1 -1
- package/cjs/tools/mergeInto.js.map +1 -1
- package/cjs/tools/monitor.d.ts +2 -1
- package/cjs/tools/monitor.js +6 -6
- package/cjs/tools/monitor.js.map +1 -1
- package/cjs/tools/observable.d.ts +1 -1
- package/cjs/tools/observable.js +3 -2
- package/cjs/tools/observable.js.map +1 -1
- package/cjs/tools/readBytesFromStream.js.map +1 -1
- package/cjs/tools/sendToExtension.js.map +1 -1
- package/cjs/tools/serialisation/contextManager.d.ts +21 -0
- package/cjs/tools/serialisation/contextManager.js +70 -0
- package/cjs/tools/serialisation/contextManager.js.map +1 -0
- package/cjs/tools/serialisation/heavyCustomerDataWarning.d.ts +8 -0
- package/cjs/tools/serialisation/heavyCustomerDataWarning.js +18 -0
- package/cjs/tools/serialisation/heavyCustomerDataWarning.js.map +1 -0
- package/cjs/tools/serialisation/jsonStringify.d.ts +2 -1
- package/cjs/tools/serialisation/jsonStringify.js.map +1 -1
- package/cjs/tools/serialisation/sanitize.js.map +1 -1
- package/cjs/tools/utils/browserDetection.d.ts +0 -8
- package/cjs/tools/utils/browserDetection.js +3 -33
- package/cjs/tools/utils/browserDetection.js.map +1 -1
- package/cjs/tools/utils/byteUtils.js.map +1 -1
- package/cjs/tools/utils/functionUtils.js.map +1 -1
- package/cjs/tools/utils/objectUtils.js.map +1 -1
- package/cjs/tools/utils/polyfills.js.map +1 -1
- package/cjs/tools/utils/responseUtils.js.map +1 -1
- package/cjs/tools/utils/stringUtils.d.ts +0 -1
- package/cjs/tools/utils/stringUtils.js +4 -31
- package/cjs/tools/utils/stringUtils.js.map +1 -1
- package/cjs/tools/utils/timeUtils.js.map +1 -1
- package/cjs/tools/utils/typeUtils.js.map +1 -1
- package/cjs/tools/utils/urlPolyfill.js.map +1 -1
- package/cjs/tools/valueHistory.js.map +1 -1
- package/cjs/transport/batch.d.ts +3 -5
- package/cjs/transport/batch.js +29 -73
- package/cjs/transport/batch.js.map +1 -1
- package/cjs/transport/eventBridge.js.map +1 -1
- package/cjs/transport/flushController.d.ts +2 -12
- package/cjs/transport/flushController.js +7 -22
- package/cjs/transport/flushController.js.map +1 -1
- package/cjs/transport/httpRequest.d.ts +2 -3
- package/cjs/transport/httpRequest.js +17 -21
- package/cjs/transport/httpRequest.js.map +1 -1
- package/cjs/transport/sendWithRetryStrategy.d.ts +2 -2
- package/cjs/transport/sendWithRetryStrategy.js +9 -9
- package/cjs/transport/sendWithRetryStrategy.js.map +1 -1
- package/cjs/transport/startBatchWithReplica.d.ts +4 -9
- package/cjs/transport/startBatchWithReplica.js +4 -9
- package/cjs/transport/startBatchWithReplica.js.map +1 -1
- package/esm/boot/init.js +1 -1
- package/esm/boot/init.js.map +1 -1
- package/esm/browser/addEventListener.d.ts +4 -12
- package/esm/browser/addEventListener.js +7 -49
- package/esm/browser/addEventListener.js.map +1 -1
- package/esm/browser/cookie.d.ts +0 -7
- package/esm/browser/cookie.js +2 -17
- package/esm/browser/cookie.js.map +1 -1
- package/esm/browser/fetchObservable.js +20 -15
- package/esm/browser/fetchObservable.js.map +1 -1
- package/esm/browser/pageExitObservable.js +8 -7
- package/esm/browser/pageExitObservable.js.map +1 -1
- package/esm/browser/runOnReadyState.js +2 -2
- package/esm/browser/runOnReadyState.js.map +1 -1
- package/esm/browser/xhrObservable.d.ts +2 -1
- package/esm/browser/xhrObservable.js +36 -28
- package/esm/browser/xhrObservable.js.map +1 -1
- package/esm/domain/configuration/configuration.d.ts +12 -17
- package/esm/domain/configuration/configuration.js +9 -8
- package/esm/domain/configuration/configuration.js.map +1 -1
- package/esm/domain/configuration/endpointBuilder.d.ts +10 -6
- package/esm/domain/configuration/endpointBuilder.js +32 -22
- package/esm/domain/configuration/endpointBuilder.js.map +1 -1
- package/esm/domain/configuration/index.d.ts +1 -2
- package/esm/domain/configuration/index.js +0 -1
- package/esm/domain/configuration/index.js.map +1 -1
- package/esm/domain/configuration/tags.js.map +1 -1
- package/esm/domain/configuration/transportConfiguration.js +1 -1
- package/esm/domain/configuration/transportConfiguration.js.map +1 -1
- package/esm/domain/console/consoleObservable.js +5 -2
- package/esm/domain/console/consoleObservable.js.map +1 -1
- package/esm/domain/deflate/types.d.ts +0 -12
- package/esm/domain/error/error.d.ts +1 -1
- package/esm/domain/error/error.js +1 -1
- package/esm/domain/error/error.js.map +1 -1
- package/esm/domain/error/error.types.d.ts +2 -2
- package/esm/domain/error/error.types.js.map +1 -1
- package/esm/domain/error/trackRuntimeError.d.ts +0 -8
- package/esm/domain/error/trackRuntimeError.js +4 -35
- package/esm/domain/error/trackRuntimeError.js.map +1 -1
- package/esm/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -1
- package/esm/domain/report/browser.types.d.ts +0 -10
- package/esm/domain/report/reportObservable.d.ts +0 -2
- package/esm/domain/report/reportObservable.js +8 -8
- package/esm/domain/report/reportObservable.js.map +1 -1
- package/esm/domain/session/oldCookiesMigration.js +5 -5
- package/esm/domain/session/oldCookiesMigration.js.map +1 -1
- package/esm/domain/session/sessionManager.js +3 -3
- package/esm/domain/session/sessionManager.js.map +1 -1
- package/esm/domain/session/sessionState.js.map +1 -1
- package/esm/domain/session/sessionStore.js.map +1 -1
- package/esm/domain/session/sessionStoreOperations.d.ts +5 -0
- package/esm/domain/session/sessionStoreOperations.js +12 -5
- package/esm/domain/session/sessionStoreOperations.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionInCookie.js +2 -13
- package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +0 -1
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -1
- package/esm/domain/synthetics/syntheticsWorkerValues.js +4 -4
- package/esm/domain/synthetics/syntheticsWorkerValues.js.map +1 -1
- package/esm/domain/telemetry/rawTelemetryEvent.types.d.ts +0 -4
- package/esm/domain/telemetry/telemetry.d.ts +1 -5
- package/esm/domain/telemetry/telemetry.js +5 -16
- package/esm/domain/telemetry/telemetry.js.map +1 -1
- package/esm/domain/telemetry/telemetryEvent.types.d.ts +2 -18
- package/esm/domain/tracekit/computeStackTrace.d.ts +5 -0
- package/esm/domain/{error → tracekit}/computeStackTrace.js +3 -26
- package/esm/domain/tracekit/computeStackTrace.js.map +1 -0
- package/esm/domain/tracekit/index.d.ts +3 -0
- package/esm/domain/tracekit/index.js +3 -0
- package/esm/domain/tracekit/index.js.map +1 -0
- package/esm/domain/tracekit/tracekit.d.ts +35 -0
- package/esm/domain/tracekit/tracekit.js +91 -0
- package/esm/domain/tracekit/tracekit.js.map +1 -0
- package/esm/domain/tracekit/types.d.ts +44 -0
- package/esm/domain/tracekit/types.js +2 -0
- package/esm/domain/tracekit/types.js.map +1 -0
- package/esm/domain/user/user.js.map +1 -1
- package/esm/index.d.ts +5 -9
- package/esm/index.js +5 -8
- package/esm/index.js.map +1 -1
- package/esm/tools/abstractLifeCycle.js.map +1 -1
- package/esm/tools/boundedBuffer.js.map +1 -1
- package/esm/tools/catchUserErrors.js.map +1 -1
- package/esm/tools/display.d.ts +2 -2
- package/esm/tools/display.js +15 -12
- package/esm/tools/display.js.map +1 -1
- package/esm/tools/experimentalFeatures.d.ts +5 -3
- package/esm/tools/experimentalFeatures.js +4 -2
- package/esm/tools/experimentalFeatures.js.map +1 -1
- package/esm/tools/getGlobalObject.js.map +1 -1
- package/esm/tools/getZoneJsOriginalValue.js.map +1 -1
- package/esm/tools/instrumentMethod.d.ts +10 -50
- package/esm/tools/instrumentMethod.js +34 -58
- package/esm/tools/instrumentMethod.js.map +1 -1
- package/esm/tools/matchOption.js.map +1 -1
- package/esm/tools/mergeInto.js.map +1 -1
- package/esm/tools/monitor.d.ts +2 -1
- package/esm/tools/monitor.js +7 -7
- package/esm/tools/monitor.js.map +1 -1
- package/esm/tools/observable.d.ts +1 -1
- package/esm/tools/observable.js +3 -2
- package/esm/tools/observable.js.map +1 -1
- package/esm/tools/readBytesFromStream.js.map +1 -1
- package/esm/tools/sendToExtension.js.map +1 -1
- package/esm/tools/serialisation/contextManager.d.ts +21 -0
- package/esm/tools/serialisation/contextManager.js +66 -0
- package/esm/tools/serialisation/contextManager.js.map +1 -0
- package/esm/tools/serialisation/heavyCustomerDataWarning.d.ts +8 -0
- package/esm/tools/serialisation/heavyCustomerDataWarning.js +14 -0
- package/esm/tools/serialisation/heavyCustomerDataWarning.js.map +1 -0
- package/esm/tools/serialisation/jsonStringify.d.ts +2 -1
- package/esm/tools/serialisation/jsonStringify.js.map +1 -1
- package/esm/tools/serialisation/sanitize.js.map +1 -1
- package/esm/tools/utils/browserDetection.d.ts +0 -8
- package/esm/tools/utils/browserDetection.js +2 -30
- package/esm/tools/utils/browserDetection.js.map +1 -1
- package/esm/tools/utils/byteUtils.js.map +1 -1
- package/esm/tools/utils/functionUtils.js.map +1 -1
- package/esm/tools/utils/objectUtils.js.map +1 -1
- package/esm/tools/utils/polyfills.js.map +1 -1
- package/esm/tools/utils/responseUtils.js.map +1 -1
- package/esm/tools/utils/stringUtils.d.ts +0 -1
- package/esm/tools/utils/stringUtils.js +3 -29
- package/esm/tools/utils/stringUtils.js.map +1 -1
- package/esm/tools/utils/timeUtils.js.map +1 -1
- package/esm/tools/utils/typeUtils.js.map +1 -1
- package/esm/tools/utils/urlPolyfill.js.map +1 -1
- package/esm/tools/valueHistory.js.map +1 -1
- package/esm/transport/batch.d.ts +3 -5
- package/esm/transport/batch.js +29 -73
- package/esm/transport/batch.js.map +1 -1
- package/esm/transport/eventBridge.js.map +1 -1
- package/esm/transport/flushController.d.ts +2 -12
- package/esm/transport/flushController.js +7 -22
- package/esm/transport/flushController.js.map +1 -1
- package/esm/transport/httpRequest.d.ts +2 -3
- package/esm/transport/httpRequest.js +17 -21
- package/esm/transport/httpRequest.js.map +1 -1
- package/esm/transport/sendWithRetryStrategy.d.ts +2 -2
- package/esm/transport/sendWithRetryStrategy.js +9 -9
- package/esm/transport/sendWithRetryStrategy.js.map +1 -1
- package/esm/transport/startBatchWithReplica.d.ts +4 -9
- package/esm/transport/startBatchWithReplica.js +4 -9
- package/esm/transport/startBatchWithReplica.js.map +1 -1
- package/package.json +1 -1
- package/src/browser/addEventListener.ts +31 -37
- package/src/browser/cookie.ts +2 -21
- package/src/browser/fetchObservable.ts +25 -21
- package/src/browser/pageExitObservable.ts +3 -1
- package/src/browser/xhrObservable.ts +37 -31
- package/src/domain/configuration/configuration.ts +22 -24
- package/src/domain/configuration/endpointBuilder.ts +46 -33
- package/src/domain/configuration/index.ts +1 -2
- package/src/domain/configuration/transportConfiguration.ts +1 -1
- package/src/domain/console/consoleObservable.ts +7 -3
- package/src/domain/deflate/types.ts +0 -14
- package/src/domain/error/error.ts +2 -2
- package/src/domain/error/error.types.ts +2 -11
- package/src/domain/error/trackRuntimeError.ts +12 -44
- package/src/domain/report/browser.types.ts +0 -12
- package/src/domain/report/reportObservable.ts +6 -8
- package/src/domain/session/oldCookiesMigration.ts +5 -5
- package/src/domain/session/sessionStoreOperations.ts +13 -5
- package/src/domain/session/storeStrategies/sessionInCookie.ts +2 -13
- package/src/domain/session/storeStrategies/sessionInLocalStorage.ts +0 -1
- package/src/domain/session/storeStrategies/sessionStoreStrategy.ts +0 -1
- package/src/domain/synthetics/syntheticsWorkerValues.ts +4 -4
- package/src/domain/telemetry/rawTelemetryEvent.types.ts +0 -5
- package/src/domain/telemetry/telemetry.ts +7 -22
- package/src/domain/telemetry/telemetryEvent.types.ts +2 -18
- package/src/domain/{error → tracekit}/computeStackTrace.ts +4 -49
- package/src/domain/tracekit/index.ts +3 -0
- package/src/domain/tracekit/tracekit.ts +96 -0
- package/src/domain/tracekit/types.ts +47 -0
- package/src/index.ts +7 -13
- package/src/tools/display.ts +13 -14
- package/src/tools/experimentalFeatures.ts +4 -2
- package/src/tools/instrumentMethod.ts +59 -103
- package/src/tools/mergeInto.ts +16 -16
- package/src/tools/monitor.ts +5 -5
- package/src/tools/observable.ts +5 -3
- package/src/tools/serialisation/contextManager.ts +79 -0
- package/src/tools/serialisation/heavyCustomerDataWarning.ts +26 -0
- package/src/tools/utils/browserDetection.ts +2 -43
- package/src/tools/utils/polyfills.ts +4 -1
- package/src/tools/utils/stringUtils.ts +4 -30
- package/src/transport/batch.ts +31 -86
- package/src/transport/flushController.ts +7 -22
- package/src/transport/httpRequest.ts +16 -23
- package/src/transport/sendWithRetryStrategy.ts +10 -10
- package/src/transport/startBatchWithReplica.ts +6 -22
- package/cjs/domain/connectivity/connectivity.d.ts +0 -13
- package/cjs/domain/connectivity/connectivity.js +0 -14
- package/cjs/domain/connectivity/connectivity.js.map +0 -1
- package/cjs/domain/connectivity/index.d.ts +0 -1
- package/cjs/domain/connectivity/index.js.map +0 -1
- package/cjs/domain/context/contextConstants.d.ts +0 -5
- package/cjs/domain/context/contextConstants.js.map +0 -1
- package/cjs/domain/context/contextManager.d.ts +0 -12
- package/cjs/domain/context/contextManager.js +0 -43
- package/cjs/domain/context/contextManager.js.map +0 -1
- package/cjs/domain/context/customerDataTracker.d.ts +0 -45
- package/cjs/domain/context/customerDataTracker.js +0 -107
- package/cjs/domain/context/customerDataTracker.js.map +0 -1
- package/cjs/domain/context/storeContextManager.d.ts +0 -6
- package/cjs/domain/context/storeContextManager.js +0 -38
- package/cjs/domain/context/storeContextManager.js.map +0 -1
- package/cjs/domain/error/computeStackTrace.d.ts +0 -33
- package/cjs/domain/error/computeStackTrace.js.map +0 -1
- package/cjs/tools/encoder.d.ts +0 -53
- package/cjs/tools/encoder.js +0 -41
- package/cjs/tools/encoder.js.map +0 -1
- package/esm/domain/connectivity/connectivity.d.ts +0 -13
- package/esm/domain/connectivity/connectivity.js +0 -10
- package/esm/domain/connectivity/connectivity.js.map +0 -1
- package/esm/domain/connectivity/index.d.ts +0 -1
- package/esm/domain/connectivity/index.js +0 -2
- package/esm/domain/connectivity/index.js.map +0 -1
- package/esm/domain/context/contextConstants.d.ts +0 -5
- package/esm/domain/context/contextConstants.js +0 -2
- package/esm/domain/context/contextConstants.js.map +0 -1
- package/esm/domain/context/contextManager.d.ts +0 -12
- package/esm/domain/context/contextManager.js +0 -39
- package/esm/domain/context/contextManager.js.map +0 -1
- package/esm/domain/context/customerDataTracker.d.ts +0 -45
- package/esm/domain/context/customerDataTracker.js +0 -102
- package/esm/domain/context/customerDataTracker.js.map +0 -1
- package/esm/domain/context/storeContextManager.d.ts +0 -6
- package/esm/domain/context/storeContextManager.js +0 -32
- package/esm/domain/context/storeContextManager.js.map +0 -1
- package/esm/domain/error/computeStackTrace.d.ts +0 -33
- package/esm/domain/error/computeStackTrace.js.map +0 -1
- package/esm/tools/encoder.d.ts +0 -53
- package/esm/tools/encoder.js +0 -37
- package/esm/tools/encoder.js.map +0 -1
- package/src/domain/connectivity/connectivity.ts +0 -27
- package/src/domain/connectivity/index.ts +0 -1
- package/src/domain/context/contextConstants.ts +0 -5
- package/src/domain/context/contextManager.ts +0 -48
- package/src/domain/context/customerDataTracker.ts +0 -134
- package/src/domain/context/storeContextManager.ts +0 -51
- package/src/tools/encoder.ts +0 -102
package/src/transport/batch.ts
CHANGED
|
@@ -2,24 +2,21 @@ import { display } from '../tools/display'
|
|
|
2
2
|
import type { Context } from '../tools/serialisation/context'
|
|
3
3
|
import { objectValues } from '../tools/utils/polyfills'
|
|
4
4
|
import { isPageExitReason } from '../browser/pageExitObservable'
|
|
5
|
-
import { jsonStringify } from '../tools/serialisation/jsonStringify'
|
|
6
|
-
import type { Subscription } from '../tools/observable'
|
|
7
|
-
import type { Encoder, EncoderResult } from '../tools/encoder'
|
|
8
5
|
import { computeBytesCount } from '../tools/utils/byteUtils'
|
|
9
|
-
import
|
|
6
|
+
import { jsonStringify } from '../tools/serialisation/jsonStringify'
|
|
7
|
+
import type { HttpRequest } from './httpRequest'
|
|
10
8
|
import type { FlushController, FlushEvent } from './flushController'
|
|
11
9
|
|
|
12
10
|
export class Batch {
|
|
11
|
+
private pushOnlyBuffer: string[] = []
|
|
13
12
|
private upsertBuffer: { [key: string]: string } = {}
|
|
14
|
-
private flushSubscription: Subscription
|
|
15
13
|
|
|
16
14
|
constructor(
|
|
17
|
-
private encoder: Encoder,
|
|
18
15
|
private request: HttpRequest,
|
|
19
16
|
public flushController: FlushController,
|
|
20
17
|
private messageBytesLimit: number
|
|
21
18
|
) {
|
|
22
|
-
this.
|
|
19
|
+
this.flushController.flushObservable.subscribe((event) => this.flush(event))
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
add(message: Context) {
|
|
@@ -30,57 +27,24 @@ export class Batch {
|
|
|
30
27
|
this.addOrUpdate(message, key)
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
stop() {
|
|
34
|
-
this.flushSubscription.unsubscribe()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
30
|
private flush(event: FlushEvent) {
|
|
38
|
-
const
|
|
31
|
+
const messages = this.pushOnlyBuffer.concat(objectValues(this.upsertBuffer))
|
|
32
|
+
|
|
33
|
+
this.pushOnlyBuffer = []
|
|
39
34
|
this.upsertBuffer = {}
|
|
40
35
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
isPageExit &&
|
|
46
|
-
// Note: checking that the encoder is async is not strictly needed, but it's an optimization:
|
|
47
|
-
// if the encoder is async we need to send two requests in some cases (one for encoded data
|
|
48
|
-
// and the other for non-encoded data). But if it's not async, we don't have to worry about
|
|
49
|
-
// it and always send a single request.
|
|
50
|
-
this.encoder.isAsync
|
|
51
|
-
) {
|
|
52
|
-
const encoderResult = this.encoder.finishSync()
|
|
53
|
-
|
|
54
|
-
// Send encoded messages
|
|
55
|
-
if (encoderResult.outputBytesCount) {
|
|
56
|
-
send(formatPayloadFromEncoder(encoderResult, event))
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Send messages that are not yet encoded at this point
|
|
60
|
-
const pendingMessages = [encoderResult.pendingData, upsertMessages].filter(Boolean).join('\n')
|
|
61
|
-
if (pendingMessages) {
|
|
62
|
-
send({
|
|
63
|
-
data: pendingMessages,
|
|
64
|
-
bytesCount: computeBytesCount(pendingMessages),
|
|
65
|
-
flushReason: event.reason,
|
|
66
|
-
})
|
|
67
|
-
}
|
|
36
|
+
const payload = { data: messages.join('\n'), bytesCount: event.bytesCount, flushReason: event.reason }
|
|
37
|
+
if (isPageExitReason(event.reason)) {
|
|
38
|
+
this.request.sendOnExit(payload)
|
|
68
39
|
} else {
|
|
69
|
-
|
|
70
|
-
this.encoder.write(this.encoder.isEmpty ? upsertMessages : `\n${upsertMessages}`)
|
|
71
|
-
}
|
|
72
|
-
this.encoder.finish((encoderResult) => {
|
|
73
|
-
send(formatPayloadFromEncoder(encoderResult, event))
|
|
74
|
-
})
|
|
40
|
+
this.request.send(payload)
|
|
75
41
|
}
|
|
76
42
|
}
|
|
77
43
|
|
|
78
44
|
private addOrUpdate(message: Context, key?: string) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const estimatedMessageBytesCount = this.encoder.estimateEncodedBytesCount(serializedMessage)
|
|
45
|
+
const { processedMessage, messageBytesCount } = this.process(message)
|
|
82
46
|
|
|
83
|
-
if (
|
|
47
|
+
if (messageBytesCount >= this.messageBytesLimit) {
|
|
84
48
|
display.warn(
|
|
85
49
|
`Discarded a message whose size was bigger than the maximum allowed size ${this.messageBytesLimit}KB.`
|
|
86
50
|
)
|
|
@@ -91,57 +55,38 @@ export class Batch {
|
|
|
91
55
|
this.remove(key)
|
|
92
56
|
}
|
|
93
57
|
|
|
94
|
-
this.push(
|
|
58
|
+
this.push(processedMessage, messageBytesCount, key)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private process(message: Context) {
|
|
62
|
+
const processedMessage = jsonStringify(message)!
|
|
63
|
+
const messageBytesCount = computeBytesCount(processedMessage)
|
|
64
|
+
return { processedMessage, messageBytesCount }
|
|
95
65
|
}
|
|
96
66
|
|
|
97
|
-
private push(
|
|
98
|
-
|
|
67
|
+
private push(processedMessage: string, messageBytesCount: number, key?: string) {
|
|
68
|
+
// If there are other messages, a '\n' will be added at serialization
|
|
69
|
+
const separatorBytesCount = this.flushController.messagesCount > 0 ? 1 : 0
|
|
99
70
|
|
|
71
|
+
this.flushController.notifyBeforeAddMessage(messageBytesCount + separatorBytesCount)
|
|
100
72
|
if (key !== undefined) {
|
|
101
|
-
this.upsertBuffer[key] =
|
|
102
|
-
this.flushController.notifyAfterAddMessage()
|
|
73
|
+
this.upsertBuffer[key] = processedMessage
|
|
103
74
|
} else {
|
|
104
|
-
this.
|
|
105
|
-
this.encoder.isEmpty ? serializedMessage : `\n${serializedMessage}`,
|
|
106
|
-
(realMessageBytesCount) => {
|
|
107
|
-
this.flushController.notifyAfterAddMessage(realMessageBytesCount - estimatedMessageBytesCount)
|
|
108
|
-
}
|
|
109
|
-
)
|
|
75
|
+
this.pushOnlyBuffer.push(processedMessage)
|
|
110
76
|
}
|
|
77
|
+
this.flushController.notifyAfterAddMessage()
|
|
111
78
|
}
|
|
112
79
|
|
|
113
80
|
private remove(key: string) {
|
|
114
81
|
const removedMessage = this.upsertBuffer[key]
|
|
115
82
|
delete this.upsertBuffer[key]
|
|
116
|
-
const messageBytesCount =
|
|
117
|
-
|
|
83
|
+
const messageBytesCount = computeBytesCount(removedMessage)
|
|
84
|
+
// If there are other messages, a '\n' will be added at serialization
|
|
85
|
+
const separatorBytesCount = this.flushController.messagesCount > 1 ? 1 : 0
|
|
86
|
+
this.flushController.notifyAfterRemoveMessage(messageBytesCount + separatorBytesCount)
|
|
118
87
|
}
|
|
119
88
|
|
|
120
89
|
private hasMessageFor(key?: string): key is string {
|
|
121
90
|
return key !== undefined && this.upsertBuffer[key] !== undefined
|
|
122
91
|
}
|
|
123
92
|
}
|
|
124
|
-
|
|
125
|
-
function formatPayloadFromEncoder(encoderResult: EncoderResult, flushEvent: FlushEvent): Payload {
|
|
126
|
-
let data: string | Blob
|
|
127
|
-
if (typeof encoderResult.output === 'string') {
|
|
128
|
-
data = encoderResult.output
|
|
129
|
-
} else {
|
|
130
|
-
data = new Blob([encoderResult.output], {
|
|
131
|
-
// This will set the 'Content-Type: text/plain' header. Reasoning:
|
|
132
|
-
// * The intake rejects the request if there is no content type.
|
|
133
|
-
// * The browser will issue CORS preflight requests if we set it to 'application/json', which
|
|
134
|
-
// could induce higher intake load (and maybe has other impacts).
|
|
135
|
-
// * Also it's not quite JSON, since we are concatenating multiple JSON objects separated by
|
|
136
|
-
// new lines.
|
|
137
|
-
type: 'text/plain',
|
|
138
|
-
})
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return {
|
|
142
|
-
data,
|
|
143
|
-
bytesCount: encoderResult.outputBytesCount,
|
|
144
|
-
encoding: encoderResult.encoding,
|
|
145
|
-
flushReason: flushEvent.reason,
|
|
146
|
-
}
|
|
147
|
-
}
|
|
@@ -33,13 +33,10 @@ export function createFlushController({
|
|
|
33
33
|
pageExitObservable,
|
|
34
34
|
sessionExpireObservable,
|
|
35
35
|
}: FlushControllerOptions) {
|
|
36
|
-
const
|
|
37
|
-
const sessionExpireSubscription = sessionExpireObservable.subscribe(() => flush('session_expire'))
|
|
36
|
+
const flushObservable = new Observable<FlushEvent>()
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
sessionExpireSubscription.unsubscribe()
|
|
42
|
-
})
|
|
38
|
+
pageExitObservable.subscribe((event) => flush(event.reason))
|
|
39
|
+
sessionExpireObservable.subscribe(() => flush('session_expire'))
|
|
43
40
|
|
|
44
41
|
let currentBytesCount = 0
|
|
45
42
|
let currentMessagesCount = 0
|
|
@@ -88,19 +85,16 @@ export function createFlushController({
|
|
|
88
85
|
*
|
|
89
86
|
* This function needs to be called synchronously, right before adding the message, so no flush
|
|
90
87
|
* event can happen after `notifyBeforeAddMessage` and before adding the message.
|
|
91
|
-
*
|
|
92
|
-
* @param estimatedMessageBytesCount: an estimation of the message bytes count once it is
|
|
93
|
-
* actually added.
|
|
94
88
|
*/
|
|
95
|
-
notifyBeforeAddMessage(
|
|
96
|
-
if (currentBytesCount +
|
|
89
|
+
notifyBeforeAddMessage(messageBytesCount: number) {
|
|
90
|
+
if (currentBytesCount + messageBytesCount >= bytesLimit) {
|
|
97
91
|
flush('bytes_limit')
|
|
98
92
|
}
|
|
99
93
|
// Consider the message to be added now rather than in `notifyAfterAddMessage`, because if no
|
|
100
94
|
// message was added yet and `notifyAfterAddMessage` is called asynchronously, we still want
|
|
101
95
|
// to notify when a flush is needed (for example on page exit).
|
|
102
96
|
currentMessagesCount += 1
|
|
103
|
-
currentBytesCount +=
|
|
97
|
+
currentBytesCount += messageBytesCount
|
|
104
98
|
scheduleDurationLimitTimeout()
|
|
105
99
|
},
|
|
106
100
|
|
|
@@ -109,13 +103,8 @@ export function createFlushController({
|
|
|
109
103
|
*
|
|
110
104
|
* This function can be called asynchronously after the message was added, but in this case it
|
|
111
105
|
* should not be called if a flush event occurred in between.
|
|
112
|
-
*
|
|
113
|
-
* @param messageBytesCountDiff: the difference between the estimated message bytes count and
|
|
114
|
-
* its actual bytes count once added to the pool.
|
|
115
106
|
*/
|
|
116
|
-
notifyAfterAddMessage(
|
|
117
|
-
currentBytesCount += messageBytesCountDiff
|
|
118
|
-
|
|
107
|
+
notifyAfterAddMessage() {
|
|
119
108
|
if (currentMessagesCount >= messagesLimit) {
|
|
120
109
|
flush('messages_limit')
|
|
121
110
|
} else if (currentBytesCount >= bytesLimit) {
|
|
@@ -128,10 +117,6 @@ export function createFlushController({
|
|
|
128
117
|
*
|
|
129
118
|
* This function needs to be called synchronously, right after removing the message, so no flush
|
|
130
119
|
* event can happen after removing the message and before `notifyAfterRemoveMessage`.
|
|
131
|
-
*
|
|
132
|
-
* @param messageBytesCount: the message bytes count that was added to the pool. Should
|
|
133
|
-
* correspond to the sum of bytes counts passed to `notifyBeforeAddMessage` and
|
|
134
|
-
* `notifyAfterAddMessage`.
|
|
135
120
|
*/
|
|
136
121
|
notifyAfterRemoveMessage(messageBytesCount: number) {
|
|
137
122
|
currentBytesCount -= messageBytesCount
|
|
@@ -24,11 +24,10 @@ export interface HttpResponse extends Context {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface Payload {
|
|
27
|
-
data: string | FormData
|
|
27
|
+
data: string | FormData
|
|
28
28
|
bytesCount: number
|
|
29
29
|
retry?: RetryInfo
|
|
30
30
|
flushReason?: FlushReason
|
|
31
|
-
encoding?: 'deflate'
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
export interface RetryInfo {
|
|
@@ -48,7 +47,7 @@ export function createHttpRequest(
|
|
|
48
47
|
|
|
49
48
|
return {
|
|
50
49
|
send: (payload: Payload) => {
|
|
51
|
-
sendWithRetryStrategy(payload, retryState, sendStrategyForRetry, endpointBuilder.
|
|
50
|
+
sendWithRetryStrategy(payload, retryState, sendStrategyForRetry, endpointBuilder.endpointType, reportError)
|
|
52
51
|
},
|
|
53
52
|
/**
|
|
54
53
|
* Since fetch keepalive behaves like regular fetch on Firefox,
|
|
@@ -64,13 +63,13 @@ function sendBeaconStrategy(
|
|
|
64
63
|
configuration: Configuration,
|
|
65
64
|
endpointBuilder: EndpointBuilder,
|
|
66
65
|
bytesLimit: number,
|
|
67
|
-
|
|
66
|
+
{ data, bytesCount, flushReason }: Payload
|
|
68
67
|
) {
|
|
69
|
-
const canUseBeacon = !!navigator.sendBeacon &&
|
|
68
|
+
const canUseBeacon = !!navigator.sendBeacon && bytesCount < bytesLimit
|
|
70
69
|
if (canUseBeacon) {
|
|
71
70
|
try {
|
|
72
|
-
const beaconUrl = endpointBuilder.build('beacon',
|
|
73
|
-
const isQueued = navigator.sendBeacon(beaconUrl,
|
|
71
|
+
const beaconUrl = endpointBuilder.build('beacon', flushReason)
|
|
72
|
+
const isQueued = navigator.sendBeacon(beaconUrl, data)
|
|
74
73
|
|
|
75
74
|
if (isQueued) {
|
|
76
75
|
return
|
|
@@ -80,8 +79,8 @@ function sendBeaconStrategy(
|
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
const xhrUrl = endpointBuilder.build('xhr',
|
|
84
|
-
sendXHR(configuration, xhrUrl,
|
|
82
|
+
const xhrUrl = endpointBuilder.build('xhr', flushReason)
|
|
83
|
+
sendXHR(configuration, xhrUrl, data)
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
let hasReportedBeaconError = false
|
|
@@ -97,23 +96,23 @@ export function fetchKeepAliveStrategy(
|
|
|
97
96
|
configuration: Configuration,
|
|
98
97
|
endpointBuilder: EndpointBuilder,
|
|
99
98
|
bytesLimit: number,
|
|
100
|
-
|
|
99
|
+
{ data, bytesCount, flushReason, retry }: Payload,
|
|
101
100
|
onResponse?: (r: HttpResponse) => void
|
|
102
101
|
) {
|
|
103
|
-
const canUseKeepAlive = isKeepAliveSupported() &&
|
|
102
|
+
const canUseKeepAlive = isKeepAliveSupported() && bytesCount < bytesLimit
|
|
104
103
|
if (canUseKeepAlive) {
|
|
105
|
-
const fetchUrl = endpointBuilder.build('fetch',
|
|
106
|
-
fetch(fetchUrl, { method: 'POST', body:
|
|
104
|
+
const fetchUrl = endpointBuilder.build('fetch', flushReason, retry)
|
|
105
|
+
fetch(fetchUrl, { method: 'POST', body: data, keepalive: true, mode: 'cors' }).then(
|
|
107
106
|
monitor((response: Response) => onResponse?.({ status: response.status, type: response.type })),
|
|
108
107
|
monitor(() => {
|
|
109
|
-
const xhrUrl = endpointBuilder.build('xhr',
|
|
108
|
+
const xhrUrl = endpointBuilder.build('xhr', flushReason, retry)
|
|
110
109
|
// failed to queue the request
|
|
111
|
-
sendXHR(configuration, xhrUrl,
|
|
110
|
+
sendXHR(configuration, xhrUrl, data, onResponse)
|
|
112
111
|
})
|
|
113
112
|
)
|
|
114
113
|
} else {
|
|
115
|
-
const xhrUrl = endpointBuilder.build('xhr',
|
|
116
|
-
sendXHR(configuration, xhrUrl,
|
|
114
|
+
const xhrUrl = endpointBuilder.build('xhr', flushReason, retry)
|
|
115
|
+
sendXHR(configuration, xhrUrl, data, onResponse)
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
|
|
@@ -134,12 +133,6 @@ export function sendXHR(
|
|
|
134
133
|
) {
|
|
135
134
|
const request = new XMLHttpRequest()
|
|
136
135
|
request.open('POST', url, true)
|
|
137
|
-
if (data instanceof Blob) {
|
|
138
|
-
// When using a Blob instance, IE does not use its 'type' to define the 'Content-Type' header
|
|
139
|
-
// automatically, so the intake request ends up being rejected with an HTTP status 415
|
|
140
|
-
// Defining the header manually fixes this issue.
|
|
141
|
-
request.setRequestHeader('Content-Type', data.type)
|
|
142
|
-
}
|
|
143
136
|
addEventListener(
|
|
144
137
|
configuration,
|
|
145
138
|
request,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EndpointType } from '../domain/configuration'
|
|
2
2
|
import { setTimeout } from '../tools/timer'
|
|
3
3
|
import { clocksNow, ONE_MINUTE, ONE_SECOND } from '../tools/utils/timeUtils'
|
|
4
4
|
import { ONE_MEBI_BYTE, ONE_KIBI_BYTE } from '../tools/utils/byteUtils'
|
|
@@ -38,7 +38,7 @@ export function sendWithRetryStrategy(
|
|
|
38
38
|
payload: Payload,
|
|
39
39
|
state: RetryState,
|
|
40
40
|
sendStrategy: SendStrategy,
|
|
41
|
-
|
|
41
|
+
endpointType: EndpointType,
|
|
42
42
|
reportError: (error: RawError) => void
|
|
43
43
|
) {
|
|
44
44
|
if (
|
|
@@ -47,10 +47,10 @@ export function sendWithRetryStrategy(
|
|
|
47
47
|
state.bandwidthMonitor.canHandle(payload)
|
|
48
48
|
) {
|
|
49
49
|
send(payload, state, sendStrategy, {
|
|
50
|
-
onSuccess: () => retryQueuedPayloads(RetryReason.AFTER_SUCCESS, state, sendStrategy,
|
|
50
|
+
onSuccess: () => retryQueuedPayloads(RetryReason.AFTER_SUCCESS, state, sendStrategy, endpointType, reportError),
|
|
51
51
|
onFailure: () => {
|
|
52
52
|
state.queuedPayloads.enqueue(payload)
|
|
53
|
-
scheduleRetry(state, sendStrategy,
|
|
53
|
+
scheduleRetry(state, sendStrategy, endpointType, reportError)
|
|
54
54
|
},
|
|
55
55
|
})
|
|
56
56
|
} else {
|
|
@@ -61,7 +61,7 @@ export function sendWithRetryStrategy(
|
|
|
61
61
|
function scheduleRetry(
|
|
62
62
|
state: RetryState,
|
|
63
63
|
sendStrategy: SendStrategy,
|
|
64
|
-
|
|
64
|
+
endpointType: EndpointType,
|
|
65
65
|
reportError: (error: RawError) => void
|
|
66
66
|
) {
|
|
67
67
|
if (state.transportStatus !== TransportStatus.DOWN) {
|
|
@@ -73,11 +73,11 @@ function scheduleRetry(
|
|
|
73
73
|
onSuccess: () => {
|
|
74
74
|
state.queuedPayloads.dequeue()
|
|
75
75
|
state.currentBackoffTime = INITIAL_BACKOFF_TIME
|
|
76
|
-
retryQueuedPayloads(RetryReason.AFTER_RESUME, state, sendStrategy,
|
|
76
|
+
retryQueuedPayloads(RetryReason.AFTER_RESUME, state, sendStrategy, endpointType, reportError)
|
|
77
77
|
},
|
|
78
78
|
onFailure: () => {
|
|
79
79
|
state.currentBackoffTime = Math.min(MAX_BACKOFF_TIME, state.currentBackoffTime * 2)
|
|
80
|
-
scheduleRetry(state, sendStrategy,
|
|
80
|
+
scheduleRetry(state, sendStrategy, endpointType, reportError)
|
|
81
81
|
},
|
|
82
82
|
})
|
|
83
83
|
}, state.currentBackoffTime)
|
|
@@ -112,12 +112,12 @@ function retryQueuedPayloads(
|
|
|
112
112
|
reason: RetryReason,
|
|
113
113
|
state: RetryState,
|
|
114
114
|
sendStrategy: SendStrategy,
|
|
115
|
-
|
|
115
|
+
endpointType: EndpointType,
|
|
116
116
|
reportError: (error: RawError) => void
|
|
117
117
|
) {
|
|
118
118
|
if (reason === RetryReason.AFTER_SUCCESS && state.queuedPayloads.isFull() && !state.queueFullReported) {
|
|
119
119
|
reportError({
|
|
120
|
-
message: `Reached max ${
|
|
120
|
+
message: `Reached max ${endpointType} events size queued for upload: ${MAX_QUEUE_BYTES_COUNT / ONE_MEBI_BYTE}MiB`,
|
|
121
121
|
source: ErrorSource.AGENT,
|
|
122
122
|
startClocks: clocksNow(),
|
|
123
123
|
})
|
|
@@ -126,7 +126,7 @@ function retryQueuedPayloads(
|
|
|
126
126
|
const previousQueue = state.queuedPayloads
|
|
127
127
|
state.queuedPayloads = newPayloadQueue()
|
|
128
128
|
while (previousQueue.size() > 0) {
|
|
129
|
-
sendWithRetryStrategy(previousQueue.dequeue()!, state, sendStrategy,
|
|
129
|
+
sendWithRetryStrategy(previousQueue.dequeue()!, state, sendStrategy, endpointType, reportError)
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -3,35 +3,24 @@ import type { Context } from '../tools/serialisation/context'
|
|
|
3
3
|
import type { Observable } from '../tools/observable'
|
|
4
4
|
import type { PageExitEvent } from '../browser/pageExitObservable'
|
|
5
5
|
import type { RawError } from '../domain/error/error.types'
|
|
6
|
-
import type { Encoder } from '../tools/encoder'
|
|
7
6
|
import { Batch } from './batch'
|
|
8
7
|
import { createHttpRequest } from './httpRequest'
|
|
9
8
|
import { createFlushController } from './flushController'
|
|
10
9
|
|
|
11
|
-
export interface BatchConfiguration {
|
|
12
|
-
endpoint: EndpointBuilder
|
|
13
|
-
encoder: Encoder
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface ReplicaBatchConfiguration<T> extends BatchConfiguration {
|
|
17
|
-
transformMessage?: (message: T) => T
|
|
18
|
-
}
|
|
19
|
-
|
|
20
10
|
export function startBatchWithReplica<T extends Context>(
|
|
21
11
|
configuration: Configuration,
|
|
22
|
-
primary:
|
|
23
|
-
replica:
|
|
12
|
+
primary: { endpoint: EndpointBuilder },
|
|
13
|
+
replica: { endpoint: EndpointBuilder; transformMessage?: (message: T) => T } | undefined,
|
|
24
14
|
reportError: (error: RawError) => void,
|
|
25
15
|
pageExitObservable: Observable<PageExitEvent>,
|
|
26
16
|
sessionExpireObservable: Observable<void>
|
|
27
17
|
) {
|
|
28
|
-
const primaryBatch = createBatch(configuration, primary)
|
|
29
|
-
const replicaBatch = replica && createBatch(configuration, replica)
|
|
18
|
+
const primaryBatch = createBatch(configuration, primary.endpoint)
|
|
19
|
+
const replicaBatch = replica && createBatch(configuration, replica.endpoint)
|
|
30
20
|
|
|
31
|
-
function createBatch(configuration: Configuration,
|
|
21
|
+
function createBatch(configuration: Configuration, endpointBuilder: EndpointBuilder) {
|
|
32
22
|
return new Batch(
|
|
33
|
-
|
|
34
|
-
createHttpRequest(configuration, endpoint, configuration.batchBytesLimit, reportError),
|
|
23
|
+
createHttpRequest(configuration, endpointBuilder, configuration.batchBytesLimit, reportError),
|
|
35
24
|
createFlushController({
|
|
36
25
|
messagesLimit: configuration.batchMessagesLimit,
|
|
37
26
|
bytesLimit: configuration.batchBytesLimit,
|
|
@@ -59,10 +48,5 @@ export function startBatchWithReplica<T extends Context>(
|
|
|
59
48
|
replicaBatch.upsert(replica.transformMessage ? replica.transformMessage(message) : message, key)
|
|
60
49
|
}
|
|
61
50
|
},
|
|
62
|
-
|
|
63
|
-
stop: () => {
|
|
64
|
-
primaryBatch.stop()
|
|
65
|
-
replicaBatch?.stop()
|
|
66
|
-
},
|
|
67
51
|
}
|
|
68
52
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type NetworkInterface = 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
|
|
2
|
-
export type EffectiveType = 'slow-2g' | '2g' | '3g' | '4g';
|
|
3
|
-
export interface NetworkInformation {
|
|
4
|
-
type?: NetworkInterface;
|
|
5
|
-
effectiveType?: EffectiveType;
|
|
6
|
-
}
|
|
7
|
-
export interface Connectivity {
|
|
8
|
-
status: 'connected' | 'not_connected';
|
|
9
|
-
interfaces?: NetworkInterface[];
|
|
10
|
-
effective_type?: EffectiveType;
|
|
11
|
-
[key: string]: unknown;
|
|
12
|
-
}
|
|
13
|
-
export declare function getConnectivity(): Connectivity;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConnectivity = void 0;
|
|
4
|
-
function getConnectivity() {
|
|
5
|
-
var _a;
|
|
6
|
-
var navigator = window.navigator;
|
|
7
|
-
return {
|
|
8
|
-
status: navigator.onLine ? 'connected' : 'not_connected',
|
|
9
|
-
interfaces: navigator.connection && navigator.connection.type ? [navigator.connection.type] : undefined,
|
|
10
|
-
effective_type: (_a = navigator.connection) === null || _a === void 0 ? void 0 : _a.effectiveType,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
exports.getConnectivity = getConnectivity;
|
|
14
|
-
//# sourceMappingURL=connectivity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connectivity.js","sourceRoot":"","sources":["../../../src/domain/connectivity/connectivity.ts"],"names":[],"mappings":";;;AAmBA,SAAgB,eAAe;;IAC7B,IAAM,SAAS,GAAG,MAAM,CAAC,SAA6B,CAAA;IACtD,OAAO;QACL,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe;QACxD,UAAU,EAAE,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;QACvG,cAAc,EAAE,MAAA,SAAS,CAAC,UAAU,0CAAE,aAAa;KACpD,CAAA;AACH,CAAC;AAPD,0CAOC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './connectivity';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/connectivity/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contextConstants.js","sourceRoot":"","sources":["../../../src/domain/context/contextConstants.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../../tools/serialisation/context';
|
|
2
|
-
import { Observable } from '../../tools/observable';
|
|
3
|
-
import type { CustomerDataTracker } from './customerDataTracker';
|
|
4
|
-
export type ContextManager = ReturnType<typeof createContextManager>;
|
|
5
|
-
export declare function createContextManager(customerDataTracker: CustomerDataTracker): {
|
|
6
|
-
getContext: () => Context;
|
|
7
|
-
setContext: (newContext: Context) => void;
|
|
8
|
-
setContextProperty: (key: string, property: any) => void;
|
|
9
|
-
removeContextProperty: (key: string) => void;
|
|
10
|
-
clearContext: () => void;
|
|
11
|
-
changeObservable: Observable<void>;
|
|
12
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createContextManager = void 0;
|
|
4
|
-
var mergeInto_1 = require("../../tools/mergeInto");
|
|
5
|
-
var typeUtils_1 = require("../../tools/utils/typeUtils");
|
|
6
|
-
var sanitize_1 = require("../../tools/serialisation/sanitize");
|
|
7
|
-
var observable_1 = require("../../tools/observable");
|
|
8
|
-
function createContextManager(customerDataTracker) {
|
|
9
|
-
var context = {};
|
|
10
|
-
var changeObservable = new observable_1.Observable();
|
|
11
|
-
var contextManager = {
|
|
12
|
-
getContext: function () { return (0, mergeInto_1.deepClone)(context); },
|
|
13
|
-
setContext: function (newContext) {
|
|
14
|
-
if ((0, typeUtils_1.getType)(newContext) === 'object') {
|
|
15
|
-
context = (0, sanitize_1.sanitize)(newContext);
|
|
16
|
-
customerDataTracker.updateCustomerData(context);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
contextManager.clearContext();
|
|
20
|
-
}
|
|
21
|
-
changeObservable.notify();
|
|
22
|
-
},
|
|
23
|
-
setContextProperty: function (key, property) {
|
|
24
|
-
context[key] = (0, sanitize_1.sanitize)(property);
|
|
25
|
-
customerDataTracker.updateCustomerData(context);
|
|
26
|
-
changeObservable.notify();
|
|
27
|
-
},
|
|
28
|
-
removeContextProperty: function (key) {
|
|
29
|
-
delete context[key];
|
|
30
|
-
customerDataTracker.updateCustomerData(context);
|
|
31
|
-
changeObservable.notify();
|
|
32
|
-
},
|
|
33
|
-
clearContext: function () {
|
|
34
|
-
context = {};
|
|
35
|
-
customerDataTracker.resetCustomerData();
|
|
36
|
-
changeObservable.notify();
|
|
37
|
-
},
|
|
38
|
-
changeObservable: changeObservable,
|
|
39
|
-
};
|
|
40
|
-
return contextManager;
|
|
41
|
-
}
|
|
42
|
-
exports.createContextManager = createContextManager;
|
|
43
|
-
//# sourceMappingURL=contextManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contextManager.js","sourceRoot":"","sources":["../../../src/domain/context/contextManager.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AACjD,yDAAqD;AACrD,+DAA6D;AAE7D,qDAAmD;AAKnD,SAAgB,oBAAoB,CAAC,mBAAwC;IAC3E,IAAI,OAAO,GAAY,EAAE,CAAA;IACzB,IAAM,gBAAgB,GAAG,IAAI,uBAAU,EAAQ,CAAA;IAE/C,IAAM,cAAc,GAAG;QACrB,UAAU,EAAE,cAAM,OAAA,IAAA,qBAAS,EAAC,OAAO,CAAC,EAAlB,CAAkB;QAEpC,UAAU,EAAE,UAAC,UAAmB;YAC9B,IAAI,IAAA,mBAAO,EAAC,UAAU,CAAC,KAAK,QAAQ,EAAE,CAAC;gBACrC,OAAO,GAAG,IAAA,mBAAQ,EAAC,UAAU,CAAC,CAAA;gBAC9B,mBAAmB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;YACjD,CAAC;iBAAM,CAAC;gBACN,cAAc,CAAC,YAAY,EAAE,CAAA;YAC/B,CAAC;YACD,gBAAgB,CAAC,MAAM,EAAE,CAAA;QAC3B,CAAC;QAED,kBAAkB,EAAE,UAAC,GAAW,EAAE,QAAa;YAC7C,OAAO,CAAC,GAAG,CAAC,GAAG,IAAA,mBAAQ,EAAC,QAAQ,CAAC,CAAA;YACjC,mBAAmB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;YAC/C,gBAAgB,CAAC,MAAM,EAAE,CAAA;QAC3B,CAAC;QAED,qBAAqB,EAAE,UAAC,GAAW;YACjC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAA;YACnB,mBAAmB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;YAC/C,gBAAgB,CAAC,MAAM,EAAE,CAAA;QAC3B,CAAC;QAED,YAAY,EAAE;YACZ,OAAO,GAAG,EAAE,CAAA;YACZ,mBAAmB,CAAC,iBAAiB,EAAE,CAAA;YACvC,gBAAgB,CAAC,MAAM,EAAE,CAAA;QAC3B,CAAC;QAED,gBAAgB,kBAAA;KACjB,CAAA;IACD,OAAO,cAAc,CAAA;AACvB,CAAC;AAtCD,oDAsCC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../../tools/serialisation/context';
|
|
2
|
-
import type { CustomerDataType } from './contextConstants';
|
|
3
|
-
export declare const CUSTOMER_DATA_BYTES_LIMIT: number;
|
|
4
|
-
export declare const CUSTOMER_COMPRESSED_DATA_BYTES_LIMIT: number;
|
|
5
|
-
export declare const BYTES_COMPUTATION_THROTTLING_DELAY = 200;
|
|
6
|
-
export type CustomerDataTracker = ReturnType<typeof createCustomerDataTracker>;
|
|
7
|
-
export type CustomerDataTrackerManager = ReturnType<typeof createCustomerDataTrackerManager>;
|
|
8
|
-
export declare const enum CustomerDataCompressionStatus {
|
|
9
|
-
Unknown = 0,
|
|
10
|
-
Enabled = 1,
|
|
11
|
-
Disabled = 2
|
|
12
|
-
}
|
|
13
|
-
export declare function createCustomerDataTrackerManager(compressionStatus?: CustomerDataCompressionStatus): {
|
|
14
|
-
/**
|
|
15
|
-
* Creates a detached tracker. The manager will not store a reference to that tracker, and the
|
|
16
|
-
* bytes count will be counted independently from other detached trackers.
|
|
17
|
-
*
|
|
18
|
-
* This is particularly useful when we don't know when the tracker will be unused, so we don't
|
|
19
|
-
* leak memory (ex: when used in Logger instances).
|
|
20
|
-
*/
|
|
21
|
-
createDetachedTracker: () => {
|
|
22
|
-
updateCustomerData: (context: Context) => void;
|
|
23
|
-
resetCustomerData: () => void;
|
|
24
|
-
getBytesCount: () => number;
|
|
25
|
-
stop: () => void;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Creates a tracker if it doesn't exist, and returns it.
|
|
29
|
-
*/
|
|
30
|
-
getOrCreateTracker: (type: CustomerDataType) => {
|
|
31
|
-
updateCustomerData: (context: Context) => void;
|
|
32
|
-
resetCustomerData: () => void;
|
|
33
|
-
getBytesCount: () => number;
|
|
34
|
-
stop: () => void;
|
|
35
|
-
};
|
|
36
|
-
setCompressionStatus: (newCompressionStatus: CustomerDataCompressionStatus) => void;
|
|
37
|
-
getCompressionStatus: () => CustomerDataCompressionStatus;
|
|
38
|
-
stop: () => void;
|
|
39
|
-
};
|
|
40
|
-
export declare function createCustomerDataTracker(checkCustomerDataLimit: () => void): {
|
|
41
|
-
updateCustomerData: (context: Context) => void;
|
|
42
|
-
resetCustomerData: () => void;
|
|
43
|
-
getBytesCount: () => number;
|
|
44
|
-
stop: () => void;
|
|
45
|
-
};
|