@openobserve/browser-core 0.2.10 → 0.2.11-rc1
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 +12 -4
- package/cjs/browser/addEventListener.js +50 -8
- package/cjs/browser/addEventListener.js.map +1 -1
- package/cjs/browser/cookie.d.ts +7 -0
- package/cjs/browser/cookie.js +19 -2
- package/cjs/browser/cookie.js.map +1 -1
- package/cjs/browser/fetchObservable.js +14 -19
- package/cjs/browser/fetchObservable.js.map +1 -1
- package/cjs/browser/pageExitObservable.js +6 -7
- 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 +1 -2
- package/cjs/browser/xhrObservable.js +26 -34
- package/cjs/browser/xhrObservable.js.map +1 -1
- package/cjs/domain/configuration/configuration.d.ts +17 -12
- package/cjs/domain/configuration/configuration.js +8 -9
- package/cjs/domain/configuration/configuration.js.map +1 -1
- package/cjs/domain/configuration/endpointBuilder.d.ts +6 -10
- package/cjs/domain/configuration/endpointBuilder.js +23 -33
- package/cjs/domain/configuration/endpointBuilder.js.map +1 -1
- package/cjs/domain/configuration/index.d.ts +2 -1
- package/cjs/domain/configuration/index.js +3 -1
- 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/connectivity/connectivity.d.ts +13 -0
- package/cjs/domain/connectivity/connectivity.js +14 -0
- package/cjs/domain/connectivity/connectivity.js.map +1 -0
- package/cjs/domain/connectivity/index.d.ts +1 -0
- package/cjs/domain/{deflate → connectivity}/index.js +1 -1
- package/cjs/domain/connectivity/index.js.map +1 -0
- package/cjs/domain/console/consoleObservable.js +4 -7
- package/cjs/domain/console/consoleObservable.js.map +1 -1
- package/cjs/domain/context/contextConstants.d.ts +5 -0
- package/cjs/domain/{tracekit/types.js → context/contextConstants.js} +1 -1
- package/cjs/domain/context/contextConstants.js.map +1 -0
- package/cjs/domain/context/contextManager.d.ts +12 -0
- package/cjs/domain/context/contextManager.js +43 -0
- package/cjs/domain/context/contextManager.js.map +1 -0
- package/cjs/domain/context/customerDataTracker.d.ts +45 -0
- package/cjs/domain/context/customerDataTracker.js +107 -0
- package/cjs/domain/context/customerDataTracker.js.map +1 -0
- package/cjs/domain/context/storeContextManager.d.ts +6 -0
- package/cjs/domain/context/storeContextManager.js +38 -0
- package/cjs/domain/context/storeContextManager.js.map +1 -0
- package/cjs/domain/deflate/types.d.ts +0 -26
- package/cjs/domain/error/computeStackTrace.d.ts +33 -0
- package/cjs/domain/{tracekit → error}/computeStackTrace.js +28 -4
- package/cjs/domain/error/computeStackTrace.js.map +1 -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 +8 -0
- package/cjs/domain/error/trackRuntimeError.js +39 -6
- 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 +10 -0
- package/cjs/domain/report/reportObservable.d.ts +2 -0
- 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 +0 -5
- package/cjs/domain/session/sessionStoreOperations.js +6 -14
- package/cjs/domain/session/sessionStoreOperations.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionInCookie.js +13 -2
- package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +1 -0
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.d.ts +1 -0
- 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 +4 -0
- package/cjs/domain/telemetry/telemetry.d.ts +5 -1
- package/cjs/domain/telemetry/telemetry.js +17 -6
- package/cjs/domain/telemetry/telemetry.js.map +1 -1
- package/cjs/domain/telemetry/telemetryEvent.types.d.ts +18 -2
- package/cjs/domain/user/user.js.map +1 -1
- 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 +13 -17
- package/cjs/tools/display.js.map +1 -1
- package/cjs/tools/encoder.d.ts +53 -0
- package/cjs/tools/encoder.js +41 -0
- package/cjs/tools/encoder.js.map +1 -0
- package/cjs/tools/experimentalFeatures.d.ts +3 -5
- package/cjs/tools/experimentalFeatures.js +2 -4
- 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 +50 -10
- package/cjs/tools/instrumentMethod.js +59 -36
- 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 +1 -2
- 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 +2 -3
- 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/jsonStringify.d.ts +1 -2
- 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 +8 -0
- package/cjs/tools/utils/browserDetection.js +33 -3
- 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 +1 -0
- package/cjs/tools/utils/stringUtils.js +31 -4
- 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 +5 -3
- package/cjs/transport/batch.js +73 -29
- package/cjs/transport/batch.js.map +1 -1
- package/cjs/transport/eventBridge.js.map +1 -1
- package/cjs/transport/flushController.d.ts +12 -2
- package/cjs/transport/flushController.js +22 -7
- package/cjs/transport/flushController.js.map +1 -1
- package/cjs/transport/httpRequest.d.ts +3 -2
- package/cjs/transport/httpRequest.js +21 -17
- 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 +9 -4
- package/cjs/transport/startBatchWithReplica.js +9 -4
- 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 +12 -4
- package/esm/browser/addEventListener.js +49 -7
- package/esm/browser/addEventListener.js.map +1 -1
- package/esm/browser/cookie.d.ts +7 -0
- package/esm/browser/cookie.js +17 -2
- package/esm/browser/cookie.js.map +1 -1
- package/esm/browser/fetchObservable.js +15 -20
- package/esm/browser/fetchObservable.js.map +1 -1
- package/esm/browser/pageExitObservable.js +7 -8
- 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 +1 -2
- package/esm/browser/xhrObservable.js +28 -36
- package/esm/browser/xhrObservable.js.map +1 -1
- package/esm/domain/configuration/configuration.d.ts +17 -12
- package/esm/domain/configuration/configuration.js +8 -9
- package/esm/domain/configuration/configuration.js.map +1 -1
- package/esm/domain/configuration/endpointBuilder.d.ts +6 -10
- package/esm/domain/configuration/endpointBuilder.js +22 -32
- package/esm/domain/configuration/endpointBuilder.js.map +1 -1
- package/esm/domain/configuration/index.d.ts +2 -1
- package/esm/domain/configuration/index.js +1 -0
- 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/connectivity/connectivity.d.ts +13 -0
- package/esm/domain/connectivity/connectivity.js +10 -0
- package/esm/domain/connectivity/connectivity.js.map +1 -0
- package/esm/domain/connectivity/index.d.ts +1 -0
- package/esm/domain/connectivity/index.js +2 -0
- package/esm/domain/connectivity/index.js.map +1 -0
- package/esm/domain/console/consoleObservable.js +2 -5
- package/esm/domain/console/consoleObservable.js.map +1 -1
- package/esm/domain/context/contextConstants.d.ts +5 -0
- package/esm/domain/context/contextConstants.js +2 -0
- package/esm/domain/context/contextConstants.js.map +1 -0
- package/esm/domain/context/contextManager.d.ts +12 -0
- package/esm/domain/context/contextManager.js +39 -0
- package/esm/domain/context/contextManager.js.map +1 -0
- package/esm/domain/context/customerDataTracker.d.ts +45 -0
- package/esm/domain/context/customerDataTracker.js +102 -0
- package/esm/domain/context/customerDataTracker.js.map +1 -0
- package/esm/domain/context/storeContextManager.d.ts +6 -0
- package/esm/domain/context/storeContextManager.js +32 -0
- package/esm/domain/context/storeContextManager.js.map +1 -0
- package/esm/domain/deflate/types.d.ts +12 -0
- package/esm/domain/error/computeStackTrace.d.ts +33 -0
- package/esm/domain/{tracekit → error}/computeStackTrace.js +26 -3
- package/esm/domain/error/computeStackTrace.js.map +1 -0
- 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 +8 -0
- package/esm/domain/error/trackRuntimeError.js +35 -4
- 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 +10 -0
- package/esm/domain/report/reportObservable.d.ts +2 -0
- 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 +0 -5
- package/esm/domain/session/sessionStoreOperations.js +5 -12
- package/esm/domain/session/sessionStoreOperations.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionInCookie.js +13 -2
- package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +1 -0
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +1 -0
- 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 +4 -0
- package/esm/domain/telemetry/telemetry.d.ts +5 -1
- package/esm/domain/telemetry/telemetry.js +16 -5
- package/esm/domain/telemetry/telemetry.js.map +1 -1
- package/esm/domain/telemetry/telemetryEvent.types.d.ts +18 -2
- package/esm/domain/user/user.js.map +1 -1
- package/esm/index.d.ts +9 -5
- package/esm/index.js +8 -5
- 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 +12 -15
- package/esm/tools/display.js.map +1 -1
- package/esm/tools/encoder.d.ts +53 -0
- package/esm/tools/encoder.js +37 -0
- package/esm/tools/encoder.js.map +1 -0
- package/esm/tools/experimentalFeatures.d.ts +3 -5
- package/esm/tools/experimentalFeatures.js +2 -4
- 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 +50 -10
- package/esm/tools/instrumentMethod.js +58 -34
- 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 +1 -2
- 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 +2 -3
- 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/jsonStringify.d.ts +1 -2
- 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 +8 -0
- package/esm/tools/utils/browserDetection.js +30 -2
- 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 +1 -0
- package/esm/tools/utils/stringUtils.js +29 -3
- 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 +5 -3
- package/esm/transport/batch.js +73 -29
- package/esm/transport/batch.js.map +1 -1
- package/esm/transport/eventBridge.js.map +1 -1
- package/esm/transport/flushController.d.ts +12 -2
- package/esm/transport/flushController.js +22 -7
- package/esm/transport/flushController.js.map +1 -1
- package/esm/transport/httpRequest.d.ts +3 -2
- package/esm/transport/httpRequest.js +21 -17
- 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 +9 -4
- package/esm/transport/startBatchWithReplica.js +9 -4
- package/esm/transport/startBatchWithReplica.js.map +1 -1
- package/package.json +1 -1
- package/src/browser/addEventListener.ts +37 -31
- package/src/browser/cookie.ts +21 -2
- package/src/browser/fetchObservable.ts +21 -25
- package/src/browser/pageExitObservable.ts +1 -3
- package/src/browser/xhrObservable.ts +31 -37
- package/src/domain/configuration/configuration.ts +24 -22
- package/src/domain/configuration/endpointBuilder.ts +33 -46
- package/src/domain/configuration/index.ts +2 -1
- package/src/domain/configuration/transportConfiguration.ts +1 -1
- package/src/domain/connectivity/connectivity.ts +27 -0
- package/src/domain/connectivity/index.ts +1 -0
- package/src/domain/console/consoleObservable.ts +3 -7
- package/src/domain/context/contextConstants.ts +5 -0
- package/src/domain/context/contextManager.ts +48 -0
- package/src/domain/context/customerDataTracker.ts +134 -0
- package/src/domain/context/storeContextManager.ts +51 -0
- package/src/domain/deflate/types.ts +14 -0
- package/src/domain/{tracekit → error}/computeStackTrace.ts +49 -4
- package/src/domain/error/error.ts +2 -2
- package/src/domain/error/error.types.ts +11 -2
- package/src/domain/error/trackRuntimeError.ts +44 -12
- package/src/domain/report/browser.types.ts +12 -0
- package/src/domain/report/reportObservable.ts +8 -6
- package/src/domain/session/oldCookiesMigration.ts +5 -5
- package/src/domain/session/sessionStoreOperations.ts +5 -13
- package/src/domain/session/storeStrategies/sessionInCookie.ts +13 -2
- package/src/domain/session/storeStrategies/sessionInLocalStorage.ts +1 -0
- package/src/domain/session/storeStrategies/sessionStoreStrategy.ts +1 -0
- package/src/domain/synthetics/syntheticsWorkerValues.ts +4 -4
- package/src/domain/telemetry/rawTelemetryEvent.types.ts +5 -0
- package/src/domain/telemetry/telemetry.ts +22 -7
- package/src/domain/telemetry/telemetryEvent.types.ts +18 -2
- package/src/index.ts +13 -7
- package/src/tools/display.ts +14 -13
- package/src/tools/encoder.ts +102 -0
- package/src/tools/experimentalFeatures.ts +2 -4
- package/src/tools/instrumentMethod.ts +103 -59
- package/src/tools/mergeInto.ts +16 -16
- package/src/tools/monitor.ts +5 -5
- package/src/tools/observable.ts +3 -5
- package/src/tools/utils/browserDetection.ts +43 -2
- package/src/tools/utils/polyfills.ts +1 -4
- package/src/tools/utils/stringUtils.ts +30 -4
- package/src/transport/batch.ts +86 -31
- package/src/transport/flushController.ts +22 -7
- package/src/transport/httpRequest.ts +23 -16
- package/src/transport/sendWithRetryStrategy.ts +10 -10
- package/src/transport/startBatchWithReplica.ts +22 -6
- package/cjs/domain/deflate/index.d.ts +0 -1
- package/cjs/domain/deflate/index.js.map +0 -1
- package/cjs/domain/tracekit/computeStackTrace.d.ts +0 -5
- package/cjs/domain/tracekit/computeStackTrace.js.map +0 -1
- package/cjs/domain/tracekit/index.d.ts +0 -3
- package/cjs/domain/tracekit/index.js +0 -8
- package/cjs/domain/tracekit/index.js.map +0 -1
- package/cjs/domain/tracekit/tracekit.d.ts +0 -35
- package/cjs/domain/tracekit/tracekit.js +0 -95
- package/cjs/domain/tracekit/tracekit.js.map +0 -1
- package/cjs/domain/tracekit/types.d.ts +0 -44
- package/cjs/domain/tracekit/types.js.map +0 -1
- package/cjs/index.d.ts +0 -63
- package/cjs/index.js +0 -155
- package/cjs/index.js.map +0 -1
- package/cjs/tools/serialisation/contextManager.d.ts +0 -21
- package/cjs/tools/serialisation/contextManager.js +0 -70
- package/cjs/tools/serialisation/contextManager.js.map +0 -1
- package/cjs/tools/serialisation/heavyCustomerDataWarning.d.ts +0 -8
- package/cjs/tools/serialisation/heavyCustomerDataWarning.js +0 -18
- package/cjs/tools/serialisation/heavyCustomerDataWarning.js.map +0 -1
- package/esm/domain/tracekit/computeStackTrace.d.ts +0 -5
- package/esm/domain/tracekit/computeStackTrace.js.map +0 -1
- package/esm/domain/tracekit/index.d.ts +0 -3
- package/esm/domain/tracekit/index.js +0 -3
- package/esm/domain/tracekit/index.js.map +0 -1
- package/esm/domain/tracekit/tracekit.d.ts +0 -35
- package/esm/domain/tracekit/tracekit.js +0 -91
- package/esm/domain/tracekit/tracekit.js.map +0 -1
- package/esm/domain/tracekit/types.d.ts +0 -44
- package/esm/domain/tracekit/types.js +0 -2
- package/esm/domain/tracekit/types.js.map +0 -1
- package/esm/tools/serialisation/contextManager.d.ts +0 -21
- package/esm/tools/serialisation/contextManager.js +0 -66
- package/esm/tools/serialisation/contextManager.js.map +0 -1
- package/esm/tools/serialisation/heavyCustomerDataWarning.d.ts +0 -8
- package/esm/tools/serialisation/heavyCustomerDataWarning.js +0 -14
- package/esm/tools/serialisation/heavyCustomerDataWarning.js.map +0 -1
- package/src/domain/tracekit/index.ts +0 -3
- package/src/domain/tracekit/tracekit.ts +0 -96
- package/src/domain/tracekit/types.ts +0 -47
- package/src/tools/serialisation/contextManager.ts +0 -79
- package/src/tools/serialisation/heavyCustomerDataWarning.ts +0 -26
|
@@ -1,7 +1,48 @@
|
|
|
1
|
+
// Exported only for tests
|
|
2
|
+
export const enum Browser {
|
|
3
|
+
IE,
|
|
4
|
+
CHROMIUM,
|
|
5
|
+
SAFARI,
|
|
6
|
+
OTHER,
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
export function isIE() {
|
|
2
|
-
return
|
|
10
|
+
return detectBrowserCached() === Browser.IE
|
|
3
11
|
}
|
|
4
12
|
|
|
5
13
|
export function isChromium() {
|
|
6
|
-
return
|
|
14
|
+
return detectBrowserCached() === Browser.CHROMIUM
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isSafari() {
|
|
18
|
+
return detectBrowserCached() === Browser.SAFARI
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let browserCache: Browser | undefined
|
|
22
|
+
function detectBrowserCached() {
|
|
23
|
+
return browserCache ?? (browserCache = detectBrowser())
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Exported only for tests
|
|
27
|
+
export function detectBrowser(browserWindow: Window = window) {
|
|
28
|
+
const userAgent = browserWindow.navigator.userAgent
|
|
29
|
+
if ((browserWindow as any).chrome || /HeadlessChrome/.test(userAgent)) {
|
|
30
|
+
return Browser.CHROMIUM
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (
|
|
34
|
+
// navigator.vendor is deprecated, but it is the most resilient way we found to detect
|
|
35
|
+
// "Apple maintained browsers" (AKA Safari). If one day it gets removed, we still have the
|
|
36
|
+
// useragent test as a semi-working fallback.
|
|
37
|
+
browserWindow.navigator.vendor?.indexOf('Apple') === 0 ||
|
|
38
|
+
(/safari/i.test(userAgent) && !/chrome|android/i.test(userAgent))
|
|
39
|
+
) {
|
|
40
|
+
return Browser.SAFARI
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if ((browserWindow.document as any).documentMode) {
|
|
44
|
+
return Browser.IE
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return Browser.OTHER
|
|
7
48
|
}
|
|
@@ -27,10 +27,7 @@ export function find<T, S extends T>(
|
|
|
27
27
|
predicate: (item: T, index: number) => item is S
|
|
28
28
|
): S | undefined
|
|
29
29
|
export function find<T>(array: ArrayLike<T>, predicate: (item: T, index: number) => boolean): T | undefined
|
|
30
|
-
export function find(
|
|
31
|
-
array: ArrayLike<unknown>,
|
|
32
|
-
predicate: (item: unknown, index: number) => boolean
|
|
33
|
-
): unknown | undefined {
|
|
30
|
+
export function find(array: ArrayLike<unknown>, predicate: (item: unknown, index: number) => boolean): unknown {
|
|
34
31
|
for (let i = 0; i < array.length; i += 1) {
|
|
35
32
|
const item = array[i]
|
|
36
33
|
if (predicate(item, i)) {
|
|
@@ -9,10 +9,36 @@ export function generateUUID(placeholder?: string): string {
|
|
|
9
9
|
: `${1e7}-${1e3}-${4e3}-${8e3}-${1e11}`.replace(/[018]/g, generateUUID)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const COMMA_SEPARATED_KEY_VALUE = /([\w-]+)\s*=\s*([^;]+)/g
|
|
13
|
+
|
|
14
|
+
export function findCommaSeparatedValue(rawString: string, name: string): string | undefined {
|
|
15
|
+
COMMA_SEPARATED_KEY_VALUE.lastIndex = 0
|
|
16
|
+
// eslint-disable-next-line no-constant-condition
|
|
17
|
+
while (true) {
|
|
18
|
+
const match = COMMA_SEPARATED_KEY_VALUE.exec(rawString)
|
|
19
|
+
if (match) {
|
|
20
|
+
if (match[1] === name) {
|
|
21
|
+
return match[2]
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
break
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function findCommaSeparatedValues(rawString: string): Map<string, string> {
|
|
30
|
+
const result = new Map<string, string>()
|
|
31
|
+
COMMA_SEPARATED_KEY_VALUE.lastIndex = 0
|
|
32
|
+
// eslint-disable-next-line no-constant-condition
|
|
33
|
+
while (true) {
|
|
34
|
+
const match = COMMA_SEPARATED_KEY_VALUE.exec(rawString)
|
|
35
|
+
if (match) {
|
|
36
|
+
result.set(match[1], match[2])
|
|
37
|
+
} else {
|
|
38
|
+
break
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return result
|
|
16
42
|
}
|
|
17
43
|
|
|
18
44
|
export function safeTruncate(candidate: string, length: number, suffix = '') {
|
package/src/transport/batch.ts
CHANGED
|
@@ -2,21 +2,24 @@ 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 { computeBytesCount } from '../tools/utils/byteUtils'
|
|
6
5
|
import { jsonStringify } from '../tools/serialisation/jsonStringify'
|
|
7
|
-
import type {
|
|
6
|
+
import type { Subscription } from '../tools/observable'
|
|
7
|
+
import type { Encoder, EncoderResult } from '../tools/encoder'
|
|
8
|
+
import { computeBytesCount } from '../tools/utils/byteUtils'
|
|
9
|
+
import type { HttpRequest, Payload } from './httpRequest'
|
|
8
10
|
import type { FlushController, FlushEvent } from './flushController'
|
|
9
11
|
|
|
10
12
|
export class Batch {
|
|
11
|
-
private pushOnlyBuffer: string[] = []
|
|
12
13
|
private upsertBuffer: { [key: string]: string } = {}
|
|
14
|
+
private flushSubscription: Subscription
|
|
13
15
|
|
|
14
16
|
constructor(
|
|
17
|
+
private encoder: Encoder,
|
|
15
18
|
private request: HttpRequest,
|
|
16
19
|
public flushController: FlushController,
|
|
17
20
|
private messageBytesLimit: number
|
|
18
21
|
) {
|
|
19
|
-
this.flushController.flushObservable.subscribe((event) => this.flush(event))
|
|
22
|
+
this.flushSubscription = this.flushController.flushObservable.subscribe((event) => this.flush(event))
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
add(message: Context) {
|
|
@@ -27,24 +30,57 @@ export class Batch {
|
|
|
27
30
|
this.addOrUpdate(message, key)
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
stop() {
|
|
34
|
+
this.flushSubscription.unsubscribe()
|
|
35
|
+
}
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
private flush(event: FlushEvent) {
|
|
38
|
+
const upsertMessages = objectValues(this.upsertBuffer).join('\n')
|
|
34
39
|
this.upsertBuffer = {}
|
|
35
40
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
const isPageExit = isPageExitReason(event.reason)
|
|
42
|
+
const send = isPageExit ? this.request.sendOnExit : this.request.send
|
|
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
|
+
}
|
|
39
68
|
} else {
|
|
40
|
-
|
|
69
|
+
if (upsertMessages) {
|
|
70
|
+
this.encoder.write(this.encoder.isEmpty ? upsertMessages : `\n${upsertMessages}`)
|
|
71
|
+
}
|
|
72
|
+
this.encoder.finish((encoderResult) => {
|
|
73
|
+
send(formatPayloadFromEncoder(encoderResult, event))
|
|
74
|
+
})
|
|
41
75
|
}
|
|
42
76
|
}
|
|
43
77
|
|
|
44
78
|
private addOrUpdate(message: Context, key?: string) {
|
|
45
|
-
const
|
|
79
|
+
const serializedMessage = jsonStringify(message)!
|
|
80
|
+
|
|
81
|
+
const estimatedMessageBytesCount = this.encoder.estimateEncodedBytesCount(serializedMessage)
|
|
46
82
|
|
|
47
|
-
if (
|
|
83
|
+
if (estimatedMessageBytesCount >= this.messageBytesLimit) {
|
|
48
84
|
display.warn(
|
|
49
85
|
`Discarded a message whose size was bigger than the maximum allowed size ${this.messageBytesLimit}KB.`
|
|
50
86
|
)
|
|
@@ -55,38 +91,57 @@ export class Batch {
|
|
|
55
91
|
this.remove(key)
|
|
56
92
|
}
|
|
57
93
|
|
|
58
|
-
this.push(
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private process(message: Context) {
|
|
62
|
-
const processedMessage = jsonStringify(message)!
|
|
63
|
-
const messageBytesCount = computeBytesCount(processedMessage)
|
|
64
|
-
return { processedMessage, messageBytesCount }
|
|
94
|
+
this.push(serializedMessage, estimatedMessageBytesCount, key)
|
|
65
95
|
}
|
|
66
96
|
|
|
67
|
-
private push(
|
|
68
|
-
|
|
69
|
-
const separatorBytesCount = this.flushController.messagesCount > 0 ? 1 : 0
|
|
97
|
+
private push(serializedMessage: string, estimatedMessageBytesCount: number, key?: string) {
|
|
98
|
+
this.flushController.notifyBeforeAddMessage(estimatedMessageBytesCount)
|
|
70
99
|
|
|
71
|
-
this.flushController.notifyBeforeAddMessage(messageBytesCount + separatorBytesCount)
|
|
72
100
|
if (key !== undefined) {
|
|
73
|
-
this.upsertBuffer[key] =
|
|
101
|
+
this.upsertBuffer[key] = serializedMessage
|
|
102
|
+
this.flushController.notifyAfterAddMessage()
|
|
74
103
|
} else {
|
|
75
|
-
this.
|
|
104
|
+
this.encoder.write(
|
|
105
|
+
this.encoder.isEmpty ? serializedMessage : `\n${serializedMessage}`,
|
|
106
|
+
(realMessageBytesCount) => {
|
|
107
|
+
this.flushController.notifyAfterAddMessage(realMessageBytesCount - estimatedMessageBytesCount)
|
|
108
|
+
}
|
|
109
|
+
)
|
|
76
110
|
}
|
|
77
|
-
this.flushController.notifyAfterAddMessage()
|
|
78
111
|
}
|
|
79
112
|
|
|
80
113
|
private remove(key: string) {
|
|
81
114
|
const removedMessage = this.upsertBuffer[key]
|
|
82
115
|
delete this.upsertBuffer[key]
|
|
83
|
-
const messageBytesCount =
|
|
84
|
-
|
|
85
|
-
const separatorBytesCount = this.flushController.messagesCount > 1 ? 1 : 0
|
|
86
|
-
this.flushController.notifyAfterRemoveMessage(messageBytesCount + separatorBytesCount)
|
|
116
|
+
const messageBytesCount = this.encoder.estimateEncodedBytesCount(removedMessage)
|
|
117
|
+
this.flushController.notifyAfterRemoveMessage(messageBytesCount)
|
|
87
118
|
}
|
|
88
119
|
|
|
89
120
|
private hasMessageFor(key?: string): key is string {
|
|
90
121
|
return key !== undefined && this.upsertBuffer[key] !== undefined
|
|
91
122
|
}
|
|
92
123
|
}
|
|
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,10 +33,13 @@ export function createFlushController({
|
|
|
33
33
|
pageExitObservable,
|
|
34
34
|
sessionExpireObservable,
|
|
35
35
|
}: FlushControllerOptions) {
|
|
36
|
-
const
|
|
36
|
+
const pageExitSubscription = pageExitObservable.subscribe((event) => flush(event.reason))
|
|
37
|
+
const sessionExpireSubscription = sessionExpireObservable.subscribe(() => flush('session_expire'))
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
const flushObservable = new Observable<FlushEvent>(() => () => {
|
|
40
|
+
pageExitSubscription.unsubscribe()
|
|
41
|
+
sessionExpireSubscription.unsubscribe()
|
|
42
|
+
})
|
|
40
43
|
|
|
41
44
|
let currentBytesCount = 0
|
|
42
45
|
let currentMessagesCount = 0
|
|
@@ -85,16 +88,19 @@ export function createFlushController({
|
|
|
85
88
|
*
|
|
86
89
|
* This function needs to be called synchronously, right before adding the message, so no flush
|
|
87
90
|
* 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.
|
|
88
94
|
*/
|
|
89
|
-
notifyBeforeAddMessage(
|
|
90
|
-
if (currentBytesCount +
|
|
95
|
+
notifyBeforeAddMessage(estimatedMessageBytesCount: number) {
|
|
96
|
+
if (currentBytesCount + estimatedMessageBytesCount >= bytesLimit) {
|
|
91
97
|
flush('bytes_limit')
|
|
92
98
|
}
|
|
93
99
|
// Consider the message to be added now rather than in `notifyAfterAddMessage`, because if no
|
|
94
100
|
// message was added yet and `notifyAfterAddMessage` is called asynchronously, we still want
|
|
95
101
|
// to notify when a flush is needed (for example on page exit).
|
|
96
102
|
currentMessagesCount += 1
|
|
97
|
-
currentBytesCount +=
|
|
103
|
+
currentBytesCount += estimatedMessageBytesCount
|
|
98
104
|
scheduleDurationLimitTimeout()
|
|
99
105
|
},
|
|
100
106
|
|
|
@@ -103,8 +109,13 @@ export function createFlushController({
|
|
|
103
109
|
*
|
|
104
110
|
* This function can be called asynchronously after the message was added, but in this case it
|
|
105
111
|
* 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.
|
|
106
115
|
*/
|
|
107
|
-
notifyAfterAddMessage() {
|
|
116
|
+
notifyAfterAddMessage(messageBytesCountDiff = 0) {
|
|
117
|
+
currentBytesCount += messageBytesCountDiff
|
|
118
|
+
|
|
108
119
|
if (currentMessagesCount >= messagesLimit) {
|
|
109
120
|
flush('messages_limit')
|
|
110
121
|
} else if (currentBytesCount >= bytesLimit) {
|
|
@@ -117,6 +128,10 @@ export function createFlushController({
|
|
|
117
128
|
*
|
|
118
129
|
* This function needs to be called synchronously, right after removing the message, so no flush
|
|
119
130
|
* 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`.
|
|
120
135
|
*/
|
|
121
136
|
notifyAfterRemoveMessage(messageBytesCount: number) {
|
|
122
137
|
currentBytesCount -= messageBytesCount
|
|
@@ -24,10 +24,11 @@ export interface HttpResponse extends Context {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface Payload {
|
|
27
|
-
data: string | FormData
|
|
27
|
+
data: string | FormData | Blob
|
|
28
28
|
bytesCount: number
|
|
29
29
|
retry?: RetryInfo
|
|
30
30
|
flushReason?: FlushReason
|
|
31
|
+
encoding?: 'deflate'
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export interface RetryInfo {
|
|
@@ -47,7 +48,7 @@ export function createHttpRequest(
|
|
|
47
48
|
|
|
48
49
|
return {
|
|
49
50
|
send: (payload: Payload) => {
|
|
50
|
-
sendWithRetryStrategy(payload, retryState, sendStrategyForRetry, endpointBuilder.
|
|
51
|
+
sendWithRetryStrategy(payload, retryState, sendStrategyForRetry, endpointBuilder.trackType, reportError)
|
|
51
52
|
},
|
|
52
53
|
/**
|
|
53
54
|
* Since fetch keepalive behaves like regular fetch on Firefox,
|
|
@@ -63,13 +64,13 @@ function sendBeaconStrategy(
|
|
|
63
64
|
configuration: Configuration,
|
|
64
65
|
endpointBuilder: EndpointBuilder,
|
|
65
66
|
bytesLimit: number,
|
|
66
|
-
|
|
67
|
+
payload: Payload
|
|
67
68
|
) {
|
|
68
|
-
const canUseBeacon = !!navigator.sendBeacon && bytesCount < bytesLimit
|
|
69
|
+
const canUseBeacon = !!navigator.sendBeacon && payload.bytesCount < bytesLimit
|
|
69
70
|
if (canUseBeacon) {
|
|
70
71
|
try {
|
|
71
|
-
const beaconUrl = endpointBuilder.build('beacon',
|
|
72
|
-
const isQueued = navigator.sendBeacon(beaconUrl, data)
|
|
72
|
+
const beaconUrl = endpointBuilder.build('beacon', payload)
|
|
73
|
+
const isQueued = navigator.sendBeacon(beaconUrl, payload.data)
|
|
73
74
|
|
|
74
75
|
if (isQueued) {
|
|
75
76
|
return
|
|
@@ -79,8 +80,8 @@ function sendBeaconStrategy(
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
const xhrUrl = endpointBuilder.build('xhr',
|
|
83
|
-
sendXHR(configuration, xhrUrl, data)
|
|
83
|
+
const xhrUrl = endpointBuilder.build('xhr', payload)
|
|
84
|
+
sendXHR(configuration, xhrUrl, payload.data)
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
let hasReportedBeaconError = false
|
|
@@ -96,23 +97,23 @@ export function fetchKeepAliveStrategy(
|
|
|
96
97
|
configuration: Configuration,
|
|
97
98
|
endpointBuilder: EndpointBuilder,
|
|
98
99
|
bytesLimit: number,
|
|
99
|
-
|
|
100
|
+
payload: Payload,
|
|
100
101
|
onResponse?: (r: HttpResponse) => void
|
|
101
102
|
) {
|
|
102
|
-
const canUseKeepAlive = isKeepAliveSupported() && bytesCount < bytesLimit
|
|
103
|
+
const canUseKeepAlive = isKeepAliveSupported() && payload.bytesCount < bytesLimit
|
|
103
104
|
if (canUseKeepAlive) {
|
|
104
|
-
const fetchUrl = endpointBuilder.build('fetch',
|
|
105
|
-
fetch(fetchUrl, { method: 'POST', body: data, keepalive: true, mode: 'cors' }).then(
|
|
105
|
+
const fetchUrl = endpointBuilder.build('fetch', payload)
|
|
106
|
+
fetch(fetchUrl, { method: 'POST', body: payload.data, keepalive: true, mode: 'cors' }).then(
|
|
106
107
|
monitor((response: Response) => onResponse?.({ status: response.status, type: response.type })),
|
|
107
108
|
monitor(() => {
|
|
108
|
-
const xhrUrl = endpointBuilder.build('xhr',
|
|
109
|
+
const xhrUrl = endpointBuilder.build('xhr', payload)
|
|
109
110
|
// failed to queue the request
|
|
110
|
-
sendXHR(configuration, xhrUrl, data, onResponse)
|
|
111
|
+
sendXHR(configuration, xhrUrl, payload.data, onResponse)
|
|
111
112
|
})
|
|
112
113
|
)
|
|
113
114
|
} else {
|
|
114
|
-
const xhrUrl = endpointBuilder.build('xhr',
|
|
115
|
-
sendXHR(configuration, xhrUrl, data, onResponse)
|
|
115
|
+
const xhrUrl = endpointBuilder.build('xhr', payload)
|
|
116
|
+
sendXHR(configuration, xhrUrl, payload.data, onResponse)
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
|
|
@@ -133,6 +134,12 @@ export function sendXHR(
|
|
|
133
134
|
) {
|
|
134
135
|
const request = new XMLHttpRequest()
|
|
135
136
|
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
|
+
}
|
|
136
143
|
addEventListener(
|
|
137
144
|
configuration,
|
|
138
145
|
request,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TrackType } 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
|
+
trackType: TrackType,
|
|
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, trackType, reportError),
|
|
51
51
|
onFailure: () => {
|
|
52
52
|
state.queuedPayloads.enqueue(payload)
|
|
53
|
-
scheduleRetry(state, sendStrategy,
|
|
53
|
+
scheduleRetry(state, sendStrategy, trackType, 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
|
+
trackType: TrackType,
|
|
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, trackType, 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, trackType, 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
|
+
trackType: TrackType,
|
|
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 ${trackType} 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, trackType, reportError)
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -3,24 +3,35 @@ 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'
|
|
6
7
|
import { Batch } from './batch'
|
|
7
8
|
import { createHttpRequest } from './httpRequest'
|
|
8
9
|
import { createFlushController } from './flushController'
|
|
9
10
|
|
|
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
|
+
|
|
10
20
|
export function startBatchWithReplica<T extends Context>(
|
|
11
21
|
configuration: Configuration,
|
|
12
|
-
primary:
|
|
13
|
-
replica:
|
|
22
|
+
primary: BatchConfiguration,
|
|
23
|
+
replica: ReplicaBatchConfiguration<T> | undefined,
|
|
14
24
|
reportError: (error: RawError) => void,
|
|
15
25
|
pageExitObservable: Observable<PageExitEvent>,
|
|
16
26
|
sessionExpireObservable: Observable<void>
|
|
17
27
|
) {
|
|
18
|
-
const primaryBatch = createBatch(configuration, primary
|
|
19
|
-
const replicaBatch = replica && createBatch(configuration, replica
|
|
28
|
+
const primaryBatch = createBatch(configuration, primary)
|
|
29
|
+
const replicaBatch = replica && createBatch(configuration, replica)
|
|
20
30
|
|
|
21
|
-
function createBatch(configuration: Configuration,
|
|
31
|
+
function createBatch(configuration: Configuration, { endpoint, encoder }: BatchConfiguration) {
|
|
22
32
|
return new Batch(
|
|
23
|
-
|
|
33
|
+
encoder,
|
|
34
|
+
createHttpRequest(configuration, endpoint, configuration.batchBytesLimit, reportError),
|
|
24
35
|
createFlushController({
|
|
25
36
|
messagesLimit: configuration.batchMessagesLimit,
|
|
26
37
|
bytesLimit: configuration.batchBytesLimit,
|
|
@@ -48,5 +59,10 @@ export function startBatchWithReplica<T extends Context>(
|
|
|
48
59
|
replicaBatch.upsert(replica.transformMessage ? replica.transformMessage(message) : message, key)
|
|
49
60
|
}
|
|
50
61
|
},
|
|
62
|
+
|
|
63
|
+
stop: () => {
|
|
64
|
+
primaryBatch.stop()
|
|
65
|
+
replicaBatch?.stop()
|
|
66
|
+
},
|
|
51
67
|
}
|
|
52
68
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/deflate/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"computeStackTrace.js","sourceRoot":"","sources":["../../../src/domain/tracekit/computeStackTrace.ts"],"names":[],"mappings":";;;AAAA,yDAAwD;AAGxD,IAAM,gBAAgB,GAAG,GAAG,CAAA;AAE5B;;GAEG;AACH,SAAgB,iBAAiB,CAAC,EAAW;IAC3C,IAAM,KAAK,GAAiB,EAAE,CAAA;IAE9B,IAAI,aAAa,GAAG,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IAC/C,IAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,CAAA;IAC3B,IAAI,aAA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OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AACtD,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.startUnhandledErrorCollection = exports.computeStackTrace = void 0;
|
|
4
|
-
var computeStackTrace_1 = require("./computeStackTrace");
|
|
5
|
-
Object.defineProperty(exports, "computeStackTrace", { enumerable: true, get: function () { return computeStackTrace_1.computeStackTrace; } });
|
|
6
|
-
var tracekit_1 = require("./tracekit");
|
|
7
|
-
Object.defineProperty(exports, "startUnhandledErrorCollection", { enumerable: true, get: function () { return tracekit_1.startUnhandledErrorCollection; } });
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/tracekit/index.ts"],"names":[],"mappings":";;;AACA,yDAAuD;AAA9C,sHAAA,iBAAiB,OAAA;AAC1B,uCAA0D;AAAjD,yHAAA,6BAA6B,OAAA"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { UnhandledErrorCallback } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Cross-browser collection of unhandled errors
|
|
4
|
-
*
|
|
5
|
-
* Supports:
|
|
6
|
-
* - Firefox: full stack trace with line numbers, plus column number
|
|
7
|
-
* on top frame; column number is not guaranteed
|
|
8
|
-
* - Opera: full stack trace with line and column numbers
|
|
9
|
-
* - Chrome: full stack trace with line and column numbers
|
|
10
|
-
* - Safari: line and column number for the top frame only; some frames
|
|
11
|
-
* may be missing, and column number is not guaranteed
|
|
12
|
-
* - IE: line and column number for the top frame only; some frames
|
|
13
|
-
* may be missing, and column number is not guaranteed
|
|
14
|
-
*
|
|
15
|
-
* In theory, TraceKit should work on all of the following versions:
|
|
16
|
-
* - IE5.5+ (only 8.0 tested)
|
|
17
|
-
* - Firefox 0.9+ (only 3.5+ tested)
|
|
18
|
-
* - Opera 7+ (only 10.50 tested; versions 9 and earlier may require
|
|
19
|
-
* Exceptions Have Stacktrace to be enabled in opera:config)
|
|
20
|
-
* - Safari 3+ (only 4+ tested)
|
|
21
|
-
* - Chrome 1+ (only 5+ tested)
|
|
22
|
-
* - Konqueror 3.5+ (untested)
|
|
23
|
-
*
|
|
24
|
-
* Tries to catch all unhandled errors and report them to the
|
|
25
|
-
* callback.
|
|
26
|
-
*
|
|
27
|
-
* Callbacks receive a StackTrace object as described in the
|
|
28
|
-
* computeStackTrace docs.
|
|
29
|
-
*
|
|
30
|
-
* @memberof TraceKit
|
|
31
|
-
* @namespace
|
|
32
|
-
*/
|
|
33
|
-
export declare function startUnhandledErrorCollection(callback: UnhandledErrorCallback): {
|
|
34
|
-
stop: () => void;
|
|
35
|
-
};
|