@pratham.raval/browser-core 6.22.3
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/README.md +3 -0
- package/cjs/boot/displayAlreadyInitializedError.d.ts +2 -0
- package/cjs/boot/displayAlreadyInitializedError.js +10 -0
- package/cjs/boot/displayAlreadyInitializedError.js.map +1 -0
- package/cjs/boot/init.d.ts +14 -0
- package/cjs/boot/init.js +39 -0
- package/cjs/boot/init.js.map +1 -0
- package/cjs/browser/addEventListener.d.ts +87 -0
- package/cjs/browser/addEventListener.js +55 -0
- package/cjs/browser/addEventListener.js.map +1 -0
- package/cjs/browser/browser.types.d.ts +51 -0
- package/cjs/browser/browser.types.js +6 -0
- package/cjs/browser/browser.types.js.map +1 -0
- package/cjs/browser/cookie.d.ts +18 -0
- package/cjs/browser/cookie.js +101 -0
- package/cjs/browser/cookie.js.map +1 -0
- package/cjs/browser/fetchObservable.d.ts +25 -0
- package/cjs/browser/fetchObservable.js +79 -0
- package/cjs/browser/fetchObservable.js.map +1 -0
- package/cjs/browser/pageMayExitObservable.d.ts +14 -0
- package/cjs/browser/pageMayExitObservable.js +45 -0
- package/cjs/browser/pageMayExitObservable.js.map +1 -0
- package/cjs/browser/runOnReadyState.d.ts +5 -0
- package/cjs/browser/runOnReadyState.js +20 -0
- package/cjs/browser/runOnReadyState.js.map +1 -0
- package/cjs/browser/xhrObservable.d.ts +23 -0
- package/cjs/browser/xhrObservable.js +83 -0
- package/cjs/browser/xhrObservable.js.map +1 -0
- package/cjs/domain/allowedTrackingOrigins.d.ts +4 -0
- package/cjs/domain/allowedTrackingOrigins.js +25 -0
- package/cjs/domain/allowedTrackingOrigins.js.map +1 -0
- package/cjs/domain/bufferedData.d.ts +14 -0
- package/cjs/domain/bufferedData.js +22 -0
- package/cjs/domain/bufferedData.js.map +1 -0
- package/cjs/domain/configuration/configuration.d.ts +303 -0
- package/cjs/domain/configuration/configuration.js +152 -0
- package/cjs/domain/configuration/configuration.js.map +1 -0
- package/cjs/domain/configuration/endpointBuilder.d.ts +12 -0
- package/cjs/domain/configuration/endpointBuilder.js +78 -0
- package/cjs/domain/configuration/endpointBuilder.js.map +1 -0
- package/cjs/domain/configuration/index.d.ts +5 -0
- package/cjs/domain/configuration/index.js +16 -0
- package/cjs/domain/configuration/index.js.map +1 -0
- package/cjs/domain/configuration/transportConfiguration.d.ts +20 -0
- package/cjs/domain/configuration/transportConfiguration.js +54 -0
- package/cjs/domain/configuration/transportConfiguration.js.map +1 -0
- package/cjs/domain/connectivity/connectivity.d.ts +14 -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/connectivity/index.js +18 -0
- package/cjs/domain/connectivity/index.js.map +1 -0
- package/cjs/domain/console/consoleObservable.d.ts +21 -0
- package/cjs/domain/console/consoleObservable.js +84 -0
- package/cjs/domain/console/consoleObservable.js.map +1 -0
- package/cjs/domain/context/contextConstants.d.ts +21 -0
- package/cjs/domain/context/contextConstants.js +18 -0
- package/cjs/domain/context/contextConstants.js.map +1 -0
- package/cjs/domain/context/contextManager.d.ts +19 -0
- package/cjs/domain/context/contextManager.js +60 -0
- package/cjs/domain/context/contextManager.js.map +1 -0
- package/cjs/domain/context/contextUtils.d.ts +5 -0
- package/cjs/domain/context/contextUtils.js +16 -0
- package/cjs/domain/context/contextUtils.js.map +1 -0
- package/cjs/domain/context/defineContextMethod.d.ts +6 -0
- package/cjs/domain/context/defineContextMethod.js +21 -0
- package/cjs/domain/context/defineContextMethod.js.map +1 -0
- package/cjs/domain/context/storeContextManager.d.ts +6 -0
- package/cjs/domain/context/storeContextManager.js +40 -0
- package/cjs/domain/context/storeContextManager.js.map +1 -0
- package/cjs/domain/contexts/accountContext.d.ts +26 -0
- package/cjs/domain/contexts/accountContext.js +33 -0
- package/cjs/domain/contexts/accountContext.js.map +1 -0
- package/cjs/domain/contexts/globalContext.d.ts +18 -0
- package/cjs/domain/contexts/globalContext.js +21 -0
- package/cjs/domain/contexts/globalContext.js.map +1 -0
- package/cjs/domain/contexts/rumInternalContext.type.d.ts +14 -0
- package/cjs/domain/contexts/rumInternalContext.type.js +3 -0
- package/cjs/domain/contexts/rumInternalContext.type.js.map +1 -0
- package/cjs/domain/contexts/userContext.d.ts +29 -0
- package/cjs/domain/contexts/userContext.js +45 -0
- package/cjs/domain/contexts/userContext.js.map +1 -0
- package/cjs/domain/deflate/deflate.types.d.ts +40 -0
- package/cjs/domain/deflate/deflate.types.js +3 -0
- package/cjs/domain/deflate/deflate.types.js.map +1 -0
- package/cjs/domain/deflate/index.d.ts +1 -0
- package/cjs/domain/deflate/index.js +18 -0
- package/cjs/domain/deflate/index.js.map +1 -0
- package/cjs/domain/error/error.d.ts +23 -0
- package/cjs/domain/error/error.js +74 -0
- package/cjs/domain/error/error.js.map +1 -0
- package/cjs/domain/error/error.types.d.ts +47 -0
- package/cjs/domain/error/error.types.js +13 -0
- package/cjs/domain/error/error.types.js.map +1 -0
- package/cjs/domain/error/trackRuntimeError.d.ts +11 -0
- package/cjs/domain/error/trackRuntimeError.js +48 -0
- package/cjs/domain/error/trackRuntimeError.js.map +1 -0
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.d.ts +5 -0
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.js +39 -0
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -0
- package/cjs/domain/extension/extensionUtils.d.ts +10 -0
- package/cjs/domain/extension/extensionUtils.js +30 -0
- package/cjs/domain/extension/extensionUtils.js.map +1 -0
- package/cjs/domain/intakeSites.d.ts +8 -0
- package/cjs/domain/intakeSites.js +11 -0
- package/cjs/domain/intakeSites.js.map +1 -0
- package/cjs/domain/report/browser.types.d.ts +34 -0
- package/cjs/domain/report/browser.types.js +3 -0
- package/cjs/domain/report/browser.types.js.map +1 -0
- package/cjs/domain/report/reportObservable.d.ts +14 -0
- package/cjs/domain/report/reportObservable.js +99 -0
- package/cjs/domain/report/reportObservable.js.map +1 -0
- package/cjs/domain/resourceUtils.d.ts +18 -0
- package/cjs/domain/resourceUtils.js +20 -0
- package/cjs/domain/resourceUtils.js.map +1 -0
- package/cjs/domain/session/oldCookiesMigration.d.ts +11 -0
- package/cjs/domain/session/oldCookiesMigration.js +40 -0
- package/cjs/domain/session/oldCookiesMigration.js.map +1 -0
- package/cjs/domain/session/sessionConstants.d.ts +15 -0
- package/cjs/domain/session/sessionConstants.js +16 -0
- package/cjs/domain/session/sessionConstants.js.map +1 -0
- package/cjs/domain/session/sessionManager.d.ts +28 -0
- package/cjs/domain/session/sessionManager.js +185 -0
- package/cjs/domain/session/sessionManager.js.map +1 -0
- package/cjs/domain/session/sessionState.d.ts +16 -0
- package/cjs/domain/session/sessionState.js +76 -0
- package/cjs/domain/session/sessionState.js.map +1 -0
- package/cjs/domain/session/sessionStateValidation.d.ts +3 -0
- package/cjs/domain/session/sessionStateValidation.js +11 -0
- package/cjs/domain/session/sessionStateValidation.js.map +1 -0
- package/cjs/domain/session/sessionStore.d.ts +38 -0
- package/cjs/domain/session/sessionStore.js +181 -0
- package/cjs/domain/session/sessionStore.js.map +1 -0
- package/cjs/domain/session/sessionStoreOperations.d.ts +12 -0
- package/cjs/domain/session/sessionStoreOperations.js +119 -0
- package/cjs/domain/session/sessionStoreOperations.js.map +1 -0
- package/cjs/domain/session/storeStrategies/sessionInCookie.d.ts +8 -0
- package/cjs/domain/session/storeStrategies/sessionInCookie.js +56 -0
- package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +1 -0
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.d.ts +4 -0
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +41 -0
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -0
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.d.ts +16 -0
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.js +5 -0
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.js.map +1 -0
- package/cjs/domain/synthetics/syntheticsWorkerValues.d.ts +12 -0
- package/cjs/domain/synthetics/syntheticsWorkerValues.js +31 -0
- package/cjs/domain/synthetics/syntheticsWorkerValues.js.map +1 -0
- package/cjs/domain/tags.d.ts +6 -0
- package/cjs/domain/tags.js +67 -0
- package/cjs/domain/tags.js.map +1 -0
- package/cjs/domain/telemetry/index.d.ts +4 -0
- package/cjs/domain/telemetry/index.js +28 -0
- package/cjs/domain/telemetry/index.js.map +1 -0
- package/cjs/domain/telemetry/rawTelemetryEvent.types.d.ts +18 -0
- package/cjs/domain/telemetry/rawTelemetryEvent.types.js +9 -0
- package/cjs/domain/telemetry/rawTelemetryEvent.types.js.map +1 -0
- package/cjs/domain/telemetry/telemetry.d.ts +56 -0
- package/cjs/domain/telemetry/telemetry.js +248 -0
- package/cjs/domain/telemetry/telemetry.js.map +1 -0
- package/cjs/domain/telemetry/telemetryEvent.types.d.ts +858 -0
- package/cjs/domain/telemetry/telemetryEvent.types.js +7 -0
- package/cjs/domain/telemetry/telemetryEvent.types.js.map +1 -0
- package/cjs/domain/trackingConsent.d.ts +13 -0
- package/cjs/domain/trackingConsent.js +28 -0
- package/cjs/domain/trackingConsent.js.map +1 -0
- package/cjs/index.d.ts +100 -0
- package/cjs/index.js +193 -0
- package/cjs/index.js.map +1 -0
- package/cjs/tools/abstractHooks.d.ts +24 -0
- package/cjs/tools/abstractHooks.js +41 -0
- package/cjs/tools/abstractHooks.js.map +1 -0
- package/cjs/tools/abstractLifeCycle.d.ts +23 -0
- package/cjs/tools/abstractLifeCycle.js +28 -0
- package/cjs/tools/abstractLifeCycle.js.map +1 -0
- package/cjs/tools/boundedBuffer.d.ts +16 -0
- package/cjs/tools/boundedBuffer.js +32 -0
- package/cjs/tools/boundedBuffer.js.map +1 -0
- package/cjs/tools/catchUserErrors.d.ts +1 -0
- package/cjs/tools/catchUserErrors.js +15 -0
- package/cjs/tools/catchUserErrors.js.map +1 -0
- package/cjs/tools/display.d.ts +38 -0
- package/cjs/tools/display.js +44 -0
- package/cjs/tools/display.js.map +1 -0
- package/cjs/tools/encoder.d.ts +54 -0
- package/cjs/tools/encoder.js +40 -0
- package/cjs/tools/encoder.js.map +1 -0
- package/cjs/tools/experimentalFeatures.d.ts +20 -0
- package/cjs/tools/experimentalFeatures.js +49 -0
- package/cjs/tools/experimentalFeatures.js.map +1 -0
- package/cjs/tools/getZoneJsOriginalValue.d.ts +19 -0
- package/cjs/tools/getZoneJsOriginalValue.js +29 -0
- package/cjs/tools/getZoneJsOriginalValue.js.map +1 -0
- package/cjs/tools/globalObject.d.ts +19 -0
- package/cjs/tools/globalObject.js +44 -0
- package/cjs/tools/globalObject.js.map +1 -0
- package/cjs/tools/instrumentMethod.d.ts +75 -0
- package/cjs/tools/instrumentMethod.js +118 -0
- package/cjs/tools/instrumentMethod.js.map +1 -0
- package/cjs/tools/matchOption.d.ts +8 -0
- package/cjs/tools/matchOption.js +35 -0
- package/cjs/tools/matchOption.js.map +1 -0
- package/cjs/tools/mergeInto.d.ts +25 -0
- package/cjs/tools/mergeInto.js +98 -0
- package/cjs/tools/mergeInto.js.map +1 -0
- package/cjs/tools/monitor.d.ts +9 -0
- package/cjs/tools/monitor.js +62 -0
- package/cjs/tools/monitor.js.map +1 -0
- package/cjs/tools/observable.d.ts +30 -0
- package/cjs/tools/observable.js +89 -0
- package/cjs/tools/observable.js.map +1 -0
- package/cjs/tools/queueMicrotask.d.ts +1 -0
- package/cjs/tools/queueMicrotask.js +17 -0
- package/cjs/tools/queueMicrotask.js.map +1 -0
- package/cjs/tools/readBytesFromStream.d.ts +11 -0
- package/cjs/tools/readBytesFromStream.js +63 -0
- package/cjs/tools/readBytesFromStream.js.map +1 -0
- package/cjs/tools/requestIdleCallback.d.ts +12 -0
- package/cjs/tools/requestIdleCallback.js +35 -0
- package/cjs/tools/requestIdleCallback.js.map +1 -0
- package/cjs/tools/sendToExtension.d.ts +3 -0
- package/cjs/tools/sendToExtension.js +11 -0
- package/cjs/tools/sendToExtension.js.map +1 -0
- package/cjs/tools/serialisation/context.d.ts +9 -0
- package/cjs/tools/serialisation/context.js +3 -0
- package/cjs/tools/serialisation/context.js.map +1 -0
- package/cjs/tools/serialisation/jsonStringify.d.ts +13 -0
- package/cjs/tools/serialisation/jsonStringify.js +48 -0
- package/cjs/tools/serialisation/jsonStringify.js.map +1 -0
- package/cjs/tools/serialisation/sanitize.d.ts +18 -0
- package/cjs/tools/serialisation/sanitize.js +188 -0
- package/cjs/tools/serialisation/sanitize.js.map +1 -0
- package/cjs/tools/stackTrace/computeStackTrace.d.ts +25 -0
- package/cjs/tools/stackTrace/computeStackTrace.js +187 -0
- package/cjs/tools/stackTrace/computeStackTrace.js.map +1 -0
- package/cjs/tools/stackTrace/handlingStack.d.ts +10 -0
- package/cjs/tools/stackTrace/handlingStack.js +46 -0
- package/cjs/tools/stackTrace/handlingStack.js.map +1 -0
- package/cjs/tools/taskQueue.d.ts +15 -0
- package/cjs/tools/taskQueue.js +54 -0
- package/cjs/tools/taskQueue.js.map +1 -0
- package/cjs/tools/timer.d.ts +5 -0
- package/cjs/tools/timer.js +22 -0
- package/cjs/tools/timer.js.map +1 -0
- package/cjs/tools/utils/arrayUtils.d.ts +3 -0
- package/cjs/tools/utils/arrayUtils.js +20 -0
- package/cjs/tools/utils/arrayUtils.js.map +1 -0
- package/cjs/tools/utils/browserDetection.d.ts +8 -0
- package/cjs/tools/utils/browserDetection.js +33 -0
- package/cjs/tools/utils/browserDetection.js.map +1 -0
- package/cjs/tools/utils/byteUtils.d.ts +8 -0
- package/cjs/tools/utils/byteUtils.js +30 -0
- package/cjs/tools/utils/byteUtils.js.map +1 -0
- package/cjs/tools/utils/functionUtils.d.ts +8 -0
- package/cjs/tools/utils/functionUtils.js +43 -0
- package/cjs/tools/utils/functionUtils.js.map +1 -0
- package/cjs/tools/utils/numberUtils.d.ts +9 -0
- package/cjs/tools/utils/numberUtils.js +24 -0
- package/cjs/tools/utils/numberUtils.js.map +1 -0
- package/cjs/tools/utils/objectUtils.d.ts +10 -0
- package/cjs/tools/utils/objectUtils.js +23 -0
- package/cjs/tools/utils/objectUtils.js.map +1 -0
- package/cjs/tools/utils/polyfills.d.ts +7 -0
- package/cjs/tools/utils/polyfills.js +23 -0
- package/cjs/tools/utils/polyfills.js.map +1 -0
- package/cjs/tools/utils/responseUtils.d.ts +2 -0
- package/cjs/tools/utils/responseUtils.js +17 -0
- package/cjs/tools/utils/responseUtils.js.map +1 -0
- package/cjs/tools/utils/stringUtils.d.ts +8 -0
- package/cjs/tools/utils/stringUtils.js +55 -0
- package/cjs/tools/utils/stringUtils.js.map +1 -0
- package/cjs/tools/utils/timeUtils.d.ts +53 -0
- package/cjs/tools/utils/timeUtils.js +101 -0
- package/cjs/tools/utils/timeUtils.js.map +1 -0
- package/cjs/tools/utils/timezone.d.ts +1 -0
- package/cjs/tools/utils/timezone.js +13 -0
- package/cjs/tools/utils/timezone.js.map +1 -0
- package/cjs/tools/utils/typeUtils.d.ts +4 -0
- package/cjs/tools/utils/typeUtils.js +16 -0
- package/cjs/tools/utils/typeUtils.js.map +1 -0
- package/cjs/tools/utils/urlPolyfill.d.ts +5 -0
- package/cjs/tools/utils/urlPolyfill.js +59 -0
- package/cjs/tools/utils/urlPolyfill.js.map +1 -0
- package/cjs/tools/valueHistory.d.ts +27 -0
- package/cjs/tools/valueHistory.js +104 -0
- package/cjs/tools/valueHistory.js.map +1 -0
- package/cjs/transport/batch.d.ts +16 -0
- package/cjs/transport/batch.js +108 -0
- package/cjs/transport/batch.js.map +1 -0
- package/cjs/transport/eventBridge.d.ts +21 -0
- package/cjs/transport/eventBridge.js +46 -0
- package/cjs/transport/eventBridge.js.map +1 -0
- package/cjs/transport/flushController.d.ts +58 -0
- package/cjs/transport/flushController.js +109 -0
- package/cjs/transport/flushController.js.map +1 -0
- package/cjs/transport/httpRequest.d.ts +51 -0
- package/cjs/transport/httpRequest.js +80 -0
- package/cjs/transport/httpRequest.js.map +1 -0
- package/cjs/transport/index.d.ts +7 -0
- package/cjs/transport/index.js +14 -0
- package/cjs/transport/index.js.map +1 -0
- package/cjs/transport/sendWithRetryStrategy.d.ts +41 -0
- package/cjs/transport/sendWithRetryStrategy.js +163 -0
- package/cjs/transport/sendWithRetryStrategy.js.map +1 -0
- package/esm/boot/displayAlreadyInitializedError.d.ts +2 -0
- package/esm/boot/displayAlreadyInitializedError.js +7 -0
- package/esm/boot/displayAlreadyInitializedError.js.map +1 -0
- package/esm/boot/init.d.ts +14 -0
- package/esm/boot/init.js +35 -0
- package/esm/boot/init.js.map +1 -0
- package/esm/browser/addEventListener.d.ts +87 -0
- package/esm/browser/addEventListener.js +51 -0
- package/esm/browser/addEventListener.js.map +1 -0
- package/esm/browser/browser.types.d.ts +51 -0
- package/esm/browser/browser.types.js +5 -0
- package/esm/browser/browser.types.js.map +1 -0
- package/esm/browser/cookie.d.ts +18 -0
- package/esm/browser/cookie.js +91 -0
- package/esm/browser/cookie.js.map +1 -0
- package/esm/browser/fetchObservable.d.ts +25 -0
- package/esm/browser/fetchObservable.js +75 -0
- package/esm/browser/fetchObservable.js.map +1 -0
- package/esm/browser/pageMayExitObservable.d.ts +14 -0
- package/esm/browser/pageMayExitObservable.js +40 -0
- package/esm/browser/pageMayExitObservable.js.map +1 -0
- package/esm/browser/runOnReadyState.d.ts +5 -0
- package/esm/browser/runOnReadyState.js +16 -0
- package/esm/browser/runOnReadyState.js.map +1 -0
- package/esm/browser/xhrObservable.d.ts +23 -0
- package/esm/browser/xhrObservable.js +80 -0
- package/esm/browser/xhrObservable.js.map +1 -0
- package/esm/domain/allowedTrackingOrigins.d.ts +4 -0
- package/esm/domain/allowedTrackingOrigins.js +21 -0
- package/esm/domain/allowedTrackingOrigins.js.map +1 -0
- package/esm/domain/bufferedData.d.ts +14 -0
- package/esm/domain/bufferedData.js +19 -0
- package/esm/domain/bufferedData.js.map +1 -0
- package/esm/domain/configuration/configuration.d.ts +303 -0
- package/esm/domain/configuration/configuration.js +146 -0
- package/esm/domain/configuration/configuration.js.map +1 -0
- package/esm/domain/configuration/endpointBuilder.d.ts +12 -0
- package/esm/domain/configuration/endpointBuilder.js +74 -0
- package/esm/domain/configuration/endpointBuilder.js.map +1 -0
- package/esm/domain/configuration/index.d.ts +5 -0
- package/esm/domain/configuration/index.js +4 -0
- package/esm/domain/configuration/index.js.map +1 -0
- package/esm/domain/configuration/transportConfiguration.d.ts +20 -0
- package/esm/domain/configuration/transportConfiguration.js +50 -0
- package/esm/domain/configuration/transportConfiguration.js.map +1 -0
- package/esm/domain/connectivity/connectivity.d.ts +14 -0
- package/esm/domain/connectivity/connectivity.js +11 -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.d.ts +21 -0
- package/esm/domain/console/consoleObservable.js +80 -0
- package/esm/domain/console/consoleObservable.js.map +1 -0
- package/esm/domain/context/contextConstants.d.ts +21 -0
- package/esm/domain/context/contextConstants.js +15 -0
- package/esm/domain/context/contextConstants.js.map +1 -0
- package/esm/domain/context/contextManager.d.ts +19 -0
- package/esm/domain/context/contextManager.js +57 -0
- package/esm/domain/context/contextManager.js.map +1 -0
- package/esm/domain/context/contextUtils.d.ts +5 -0
- package/esm/domain/context/contextUtils.js +13 -0
- package/esm/domain/context/contextUtils.js.map +1 -0
- package/esm/domain/context/defineContextMethod.d.ts +6 -0
- package/esm/domain/context/defineContextMethod.js +17 -0
- package/esm/domain/context/defineContextMethod.js.map +1 -0
- package/esm/domain/context/storeContextManager.d.ts +6 -0
- package/esm/domain/context/storeContextManager.js +35 -0
- package/esm/domain/context/storeContextManager.js.map +1 -0
- package/esm/domain/contexts/accountContext.d.ts +26 -0
- package/esm/domain/contexts/accountContext.js +29 -0
- package/esm/domain/contexts/accountContext.js.map +1 -0
- package/esm/domain/contexts/globalContext.d.ts +18 -0
- package/esm/domain/contexts/globalContext.js +17 -0
- package/esm/domain/contexts/globalContext.js.map +1 -0
- package/esm/domain/contexts/rumInternalContext.type.d.ts +14 -0
- package/esm/domain/contexts/rumInternalContext.type.js +2 -0
- package/esm/domain/contexts/rumInternalContext.type.js.map +1 -0
- package/esm/domain/contexts/userContext.d.ts +29 -0
- package/esm/domain/contexts/userContext.js +41 -0
- package/esm/domain/contexts/userContext.js.map +1 -0
- package/esm/domain/deflate/deflate.types.d.ts +40 -0
- package/esm/domain/deflate/deflate.types.js +2 -0
- package/esm/domain/deflate/deflate.types.js.map +1 -0
- package/esm/domain/deflate/index.d.ts +1 -0
- package/esm/domain/deflate/index.js +2 -0
- package/esm/domain/deflate/index.js.map +1 -0
- package/esm/domain/error/error.d.ts +23 -0
- package/esm/domain/error/error.js +65 -0
- package/esm/domain/error/error.js.map +1 -0
- package/esm/domain/error/error.types.d.ts +47 -0
- package/esm/domain/error/error.types.js +10 -0
- package/esm/domain/error/error.types.js.map +1 -0
- package/esm/domain/error/trackRuntimeError.d.ts +11 -0
- package/esm/domain/error/trackRuntimeError.js +43 -0
- package/esm/domain/error/trackRuntimeError.js.map +1 -0
- package/esm/domain/eventRateLimiter/createEventRateLimiter.d.ts +5 -0
- package/esm/domain/eventRateLimiter/createEventRateLimiter.js +36 -0
- package/esm/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -0
- package/esm/domain/extension/extensionUtils.d.ts +10 -0
- package/esm/domain/extension/extensionUtils.js +25 -0
- package/esm/domain/extension/extensionUtils.js.map +1 -0
- package/esm/domain/intakeSites.d.ts +8 -0
- package/esm/domain/intakeSites.js +8 -0
- package/esm/domain/intakeSites.js.map +1 -0
- package/esm/domain/report/browser.types.d.ts +34 -0
- package/esm/domain/report/browser.types.js +2 -0
- package/esm/domain/report/browser.types.js.map +1 -0
- package/esm/domain/report/reportObservable.d.ts +14 -0
- package/esm/domain/report/reportObservable.js +95 -0
- package/esm/domain/report/reportObservable.js.map +1 -0
- package/esm/domain/resourceUtils.d.ts +18 -0
- package/esm/domain/resourceUtils.js +17 -0
- package/esm/domain/resourceUtils.js.map +1 -0
- package/esm/domain/session/oldCookiesMigration.d.ts +11 -0
- package/esm/domain/session/oldCookiesMigration.js +36 -0
- package/esm/domain/session/oldCookiesMigration.js.map +1 -0
- package/esm/domain/session/sessionConstants.d.ts +15 -0
- package/esm/domain/session/sessionConstants.js +13 -0
- package/esm/domain/session/sessionConstants.js.map +1 -0
- package/esm/domain/session/sessionManager.d.ts +28 -0
- package/esm/domain/session/sessionManager.js +180 -0
- package/esm/domain/session/sessionManager.js.map +1 -0
- package/esm/domain/session/sessionState.d.ts +16 -0
- package/esm/domain/session/sessionState.js +66 -0
- package/esm/domain/session/sessionState.js.map +1 -0
- package/esm/domain/session/sessionStateValidation.d.ts +3 -0
- package/esm/domain/session/sessionStateValidation.js +7 -0
- package/esm/domain/session/sessionStateValidation.js.map +1 -0
- package/esm/domain/session/sessionStore.d.ts +38 -0
- package/esm/domain/session/sessionStore.js +175 -0
- package/esm/domain/session/sessionStore.js.map +1 -0
- package/esm/domain/session/sessionStoreOperations.d.ts +12 -0
- package/esm/domain/session/sessionStoreOperations.js +114 -0
- package/esm/domain/session/sessionStoreOperations.js.map +1 -0
- package/esm/domain/session/storeStrategies/sessionInCookie.d.ts +8 -0
- package/esm/domain/session/storeStrategies/sessionInCookie.js +50 -0
- package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -0
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.d.ts +4 -0
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +37 -0
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -0
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +16 -0
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.js +2 -0
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.js.map +1 -0
- package/esm/domain/synthetics/syntheticsWorkerValues.d.ts +12 -0
- package/esm/domain/synthetics/syntheticsWorkerValues.js +24 -0
- package/esm/domain/synthetics/syntheticsWorkerValues.js.map +1 -0
- package/esm/domain/tags.d.ts +6 -0
- package/esm/domain/tags.js +60 -0
- package/esm/domain/tags.js.map +1 -0
- package/esm/domain/telemetry/index.d.ts +4 -0
- package/esm/domain/telemetry/index.js +3 -0
- package/esm/domain/telemetry/index.js.map +1 -0
- package/esm/domain/telemetry/rawTelemetryEvent.types.d.ts +18 -0
- package/esm/domain/telemetry/rawTelemetryEvent.types.js +6 -0
- package/esm/domain/telemetry/rawTelemetryEvent.types.js.map +1 -0
- package/esm/domain/telemetry/telemetry.d.ts +56 -0
- package/esm/domain/telemetry/telemetry.js +235 -0
- package/esm/domain/telemetry/telemetry.js.map +1 -0
- package/esm/domain/telemetry/telemetryEvent.types.d.ts +858 -0
- package/esm/domain/telemetry/telemetryEvent.types.js +6 -0
- package/esm/domain/telemetry/telemetryEvent.types.js.map +1 -0
- package/esm/domain/trackingConsent.d.ts +13 -0
- package/esm/domain/trackingConsent.js +24 -0
- package/esm/domain/trackingConsent.js.map +1 -0
- package/esm/index.d.ts +100 -0
- package/esm/index.js +76 -0
- package/esm/index.js.map +1 -0
- package/esm/tools/abstractHooks.d.ts +24 -0
- package/esm/tools/abstractHooks.js +37 -0
- package/esm/tools/abstractHooks.js.map +1 -0
- package/esm/tools/abstractLifeCycle.d.ts +23 -0
- package/esm/tools/abstractLifeCycle.js +24 -0
- package/esm/tools/abstractLifeCycle.js.map +1 -0
- package/esm/tools/boundedBuffer.d.ts +16 -0
- package/esm/tools/boundedBuffer.js +29 -0
- package/esm/tools/boundedBuffer.js.map +1 -0
- package/esm/tools/catchUserErrors.d.ts +1 -0
- package/esm/tools/catchUserErrors.js +12 -0
- package/esm/tools/catchUserErrors.js.map +1 -0
- package/esm/tools/display.d.ts +38 -0
- package/esm/tools/display.js +41 -0
- package/esm/tools/display.js.map +1 -0
- package/esm/tools/encoder.d.ts +54 -0
- package/esm/tools/encoder.js +37 -0
- package/esm/tools/encoder.js.map +1 -0
- package/esm/tools/experimentalFeatures.d.ts +20 -0
- package/esm/tools/experimentalFeatures.js +41 -0
- package/esm/tools/experimentalFeatures.js.map +1 -0
- package/esm/tools/getZoneJsOriginalValue.d.ts +19 -0
- package/esm/tools/getZoneJsOriginalValue.js +26 -0
- package/esm/tools/getZoneJsOriginalValue.js.map +1 -0
- package/esm/tools/globalObject.d.ts +19 -0
- package/esm/tools/globalObject.js +40 -0
- package/esm/tools/globalObject.js.map +1 -0
- package/esm/tools/instrumentMethod.d.ts +75 -0
- package/esm/tools/instrumentMethod.js +114 -0
- package/esm/tools/instrumentMethod.js.map +1 -0
- package/esm/tools/matchOption.d.ts +8 -0
- package/esm/tools/matchOption.js +31 -0
- package/esm/tools/matchOption.js.map +1 -0
- package/esm/tools/mergeInto.d.ts +25 -0
- package/esm/tools/mergeInto.js +93 -0
- package/esm/tools/mergeInto.js.map +1 -0
- package/esm/tools/monitor.d.ts +9 -0
- package/esm/tools/monitor.js +52 -0
- package/esm/tools/monitor.js.map +1 -0
- package/esm/tools/observable.d.ts +30 -0
- package/esm/tools/observable.js +83 -0
- package/esm/tools/observable.js.map +1 -0
- package/esm/tools/queueMicrotask.d.ts +1 -0
- package/esm/tools/queueMicrotask.js +14 -0
- package/esm/tools/queueMicrotask.js.map +1 -0
- package/esm/tools/readBytesFromStream.d.ts +11 -0
- package/esm/tools/readBytesFromStream.js +60 -0
- package/esm/tools/readBytesFromStream.js.map +1 -0
- package/esm/tools/requestIdleCallback.d.ts +12 -0
- package/esm/tools/requestIdleCallback.js +30 -0
- package/esm/tools/requestIdleCallback.js.map +1 -0
- package/esm/tools/sendToExtension.d.ts +3 -0
- package/esm/tools/sendToExtension.js +8 -0
- package/esm/tools/sendToExtension.js.map +1 -0
- package/esm/tools/serialisation/context.d.ts +9 -0
- package/esm/tools/serialisation/context.js +2 -0
- package/esm/tools/serialisation/context.js.map +1 -0
- package/esm/tools/serialisation/jsonStringify.d.ts +13 -0
- package/esm/tools/serialisation/jsonStringify.js +44 -0
- package/esm/tools/serialisation/jsonStringify.js.map +1 -0
- package/esm/tools/serialisation/sanitize.d.ts +18 -0
- package/esm/tools/serialisation/sanitize.js +185 -0
- package/esm/tools/serialisation/sanitize.js.map +1 -0
- package/esm/tools/stackTrace/computeStackTrace.d.ts +25 -0
- package/esm/tools/stackTrace/computeStackTrace.js +183 -0
- package/esm/tools/stackTrace/computeStackTrace.js.map +1 -0
- package/esm/tools/stackTrace/handlingStack.d.ts +10 -0
- package/esm/tools/stackTrace/handlingStack.js +41 -0
- package/esm/tools/stackTrace/handlingStack.js.map +1 -0
- package/esm/tools/taskQueue.d.ts +15 -0
- package/esm/tools/taskQueue.js +50 -0
- package/esm/tools/taskQueue.js.map +1 -0
- package/esm/tools/timer.d.ts +5 -0
- package/esm/tools/timer.js +16 -0
- package/esm/tools/timer.js.map +1 -0
- package/esm/tools/utils/arrayUtils.d.ts +3 -0
- package/esm/tools/utils/arrayUtils.js +15 -0
- package/esm/tools/utils/arrayUtils.js.map +1 -0
- package/esm/tools/utils/browserDetection.d.ts +8 -0
- package/esm/tools/utils/browserDetection.js +28 -0
- package/esm/tools/utils/browserDetection.js.map +1 -0
- package/esm/tools/utils/byteUtils.d.ts +8 -0
- package/esm/tools/utils/byteUtils.js +25 -0
- package/esm/tools/utils/byteUtils.js.map +1 -0
- package/esm/tools/utils/functionUtils.d.ts +8 -0
- package/esm/tools/utils/functionUtils.js +39 -0
- package/esm/tools/utils/functionUtils.js.map +1 -0
- package/esm/tools/utils/numberUtils.d.ts +9 -0
- package/esm/tools/utils/numberUtils.js +18 -0
- package/esm/tools/utils/numberUtils.js.map +1 -0
- package/esm/tools/utils/objectUtils.d.ts +10 -0
- package/esm/tools/utils/objectUtils.js +17 -0
- package/esm/tools/utils/objectUtils.js.map +1 -0
- package/esm/tools/utils/polyfills.d.ts +7 -0
- package/esm/tools/utils/polyfills.js +18 -0
- package/esm/tools/utils/polyfills.js.map +1 -0
- package/esm/tools/utils/responseUtils.d.ts +2 -0
- package/esm/tools/utils/responseUtils.js +13 -0
- package/esm/tools/utils/responseUtils.js.map +1 -0
- package/esm/tools/utils/stringUtils.d.ts +8 -0
- package/esm/tools/utils/stringUtils.js +49 -0
- package/esm/tools/utils/stringUtils.js.map +1 -0
- package/esm/tools/utils/timeUtils.d.ts +53 -0
- package/esm/tools/utils/timeUtils.js +84 -0
- package/esm/tools/utils/timeUtils.js.map +1 -0
- package/esm/tools/utils/timezone.d.ts +1 -0
- package/esm/tools/utils/timezone.js +10 -0
- package/esm/tools/utils/timezone.js.map +1 -0
- package/esm/tools/utils/typeUtils.d.ts +4 -0
- package/esm/tools/utils/typeUtils.js +13 -0
- package/esm/tools/utils/typeUtils.js.map +1 -0
- package/esm/tools/utils/urlPolyfill.d.ts +5 -0
- package/esm/tools/utils/urlPolyfill.js +52 -0
- package/esm/tools/utils/urlPolyfill.js.map +1 -0
- package/esm/tools/valueHistory.d.ts +27 -0
- package/esm/tools/valueHistory.js +100 -0
- package/esm/tools/valueHistory.js.map +1 -0
- package/esm/transport/batch.d.ts +16 -0
- package/esm/transport/batch.js +105 -0
- package/esm/transport/batch.js.map +1 -0
- package/esm/transport/eventBridge.d.ts +21 -0
- package/esm/transport/eventBridge.js +41 -0
- package/esm/transport/eventBridge.js.map +1 -0
- package/esm/transport/flushController.d.ts +58 -0
- package/esm/transport/flushController.js +106 -0
- package/esm/transport/flushController.js.map +1 -0
- package/esm/transport/httpRequest.d.ts +51 -0
- package/esm/transport/httpRequest.js +75 -0
- package/esm/transport/httpRequest.js.map +1 -0
- package/esm/transport/index.d.ts +7 -0
- package/esm/transport/index.js +5 -0
- package/esm/transport/index.js.map +1 -0
- package/esm/transport/sendWithRetryStrategy.d.ts +41 -0
- package/esm/transport/sendWithRetryStrategy.js +158 -0
- package/esm/transport/sendWithRetryStrategy.js.map +1 -0
- package/package.json +31 -0
- package/src/boot/displayAlreadyInitializedError.ts +8 -0
- package/src/boot/init.ts +55 -0
- package/src/browser/addEventListener.ts +145 -0
- package/src/browser/browser.types.ts +82 -0
- package/src/browser/cookie.ts +107 -0
- package/src/browser/fetchObservable.ts +127 -0
- package/src/browser/pageMayExitObservable.ts +56 -0
- package/src/browser/runOnReadyState.ts +25 -0
- package/src/browser/xhrObservable.ts +130 -0
- package/src/domain/allowedTrackingOrigins.ts +30 -0
- package/src/domain/bufferedData.ts +32 -0
- package/src/domain/configuration/configuration.ts +472 -0
- package/src/domain/configuration/endpointBuilder.ts +119 -0
- package/src/domain/configuration/index.ts +11 -0
- package/src/domain/configuration/transportConfiguration.ts +78 -0
- package/src/domain/connectivity/connectivity.ts +31 -0
- package/src/domain/connectivity/index.ts +1 -0
- package/src/domain/console/consoleObservable.ts +118 -0
- package/src/domain/context/contextConstants.ts +27 -0
- package/src/domain/context/contextManager.ts +85 -0
- package/src/domain/context/contextUtils.ts +14 -0
- package/src/domain/context/defineContextMethod.ts +31 -0
- package/src/domain/context/storeContextManager.ts +55 -0
- package/src/domain/contexts/accountContext.ts +47 -0
- package/src/domain/contexts/globalContext.ts +30 -0
- package/src/domain/contexts/rumInternalContext.type.ts +15 -0
- package/src/domain/contexts/userContext.ts +64 -0
- package/src/domain/deflate/deflate.types.ts +57 -0
- package/src/domain/deflate/index.ts +1 -0
- package/src/domain/error/error.ts +103 -0
- package/src/domain/error/error.types.ts +64 -0
- package/src/domain/error/trackRuntimeError.ts +50 -0
- package/src/domain/eventRateLimiter/createEventRateLimiter.ts +46 -0
- package/src/domain/extension/extensionUtils.ts +28 -0
- package/src/domain/intakeSites.ts +17 -0
- package/src/domain/report/browser.types.ts +38 -0
- package/src/domain/report/reportObservable.ts +133 -0
- package/src/domain/resourceUtils.ts +21 -0
- package/src/domain/session/README.md +193 -0
- package/src/domain/session/oldCookiesMigration.ts +42 -0
- package/src/domain/session/sessionConstants.ts +19 -0
- package/src/domain/session/sessionManager.ts +244 -0
- package/src/domain/session/sessionState.ts +88 -0
- package/src/domain/session/sessionStateValidation.ts +9 -0
- package/src/domain/session/sessionStore.ts +244 -0
- package/src/domain/session/sessionStoreOperations.ts +131 -0
- package/src/domain/session/storeStrategies/sessionInCookie.ts +85 -0
- package/src/domain/session/storeStrategies/sessionInLocalStorage.ts +44 -0
- package/src/domain/session/storeStrategies/sessionStoreStrategy.ts +16 -0
- package/src/domain/synthetics/syntheticsWorkerValues.ts +38 -0
- package/src/domain/tags.ts +76 -0
- package/src/domain/telemetry/index.ts +22 -0
- package/src/domain/telemetry/rawTelemetryEvent.types.ts +22 -0
- package/src/domain/telemetry/telemetry.ts +345 -0
- package/src/domain/telemetry/telemetryEvent.types.ts +899 -0
- package/src/domain/trackingConsent.ts +34 -0
- package/src/index.ts +164 -0
- package/src/tools/abstractHooks.ts +72 -0
- package/src/tools/abstractLifeCycle.ts +46 -0
- package/src/tools/boundedBuffer.ts +45 -0
- package/src/tools/catchUserErrors.ts +11 -0
- package/src/tools/display.ts +56 -0
- package/src/tools/encoder.ts +103 -0
- package/src/tools/experimentalFeatures.ts +51 -0
- package/src/tools/getZoneJsOriginalValue.ts +38 -0
- package/src/tools/globalObject.ts +51 -0
- package/src/tools/instrumentMethod.ts +170 -0
- package/src/tools/matchOption.ts +31 -0
- package/src/tools/mergeInto.ts +177 -0
- package/src/tools/monitor.ts +72 -0
- package/src/tools/observable.ts +104 -0
- package/src/tools/queueMicrotask.ts +13 -0
- package/src/tools/readBytesFromStream.ts +77 -0
- package/src/tools/requestIdleCallback.ts +40 -0
- package/src/tools/sendToExtension.ts +14 -0
- package/src/tools/serialisation/context.ts +11 -0
- package/src/tools/serialisation/jsonStringify.ts +53 -0
- package/src/tools/serialisation/sanitize.ts +273 -0
- package/src/tools/stackTrace/computeStackTrace.ts +250 -0
- package/src/tools/stackTrace/handlingStack.ts +48 -0
- package/src/tools/taskQueue.ts +63 -0
- package/src/tools/timer.ts +21 -0
- package/src/tools/utils/arrayUtils.ts +15 -0
- package/src/tools/utils/browserDetection.ts +39 -0
- package/src/tools/utils/byteUtils.ts +35 -0
- package/src/tools/utils/functionUtils.ts +45 -0
- package/src/tools/utils/numberUtils.ts +20 -0
- package/src/tools/utils/objectUtils.ts +19 -0
- package/src/tools/utils/polyfills.ts +23 -0
- package/src/tools/utils/responseUtils.ts +12 -0
- package/src/tools/utils/stringUtils.ts +52 -0
- package/src/tools/utils/timeUtils.ts +117 -0
- package/src/tools/utils/timezone.ts +9 -0
- package/src/tools/utils/typeUtils.ts +12 -0
- package/src/tools/utils/urlPolyfill.ts +56 -0
- package/src/tools/valueHistory.ts +151 -0
- package/src/transport/batch.ts +144 -0
- package/src/transport/eventBridge.ts +61 -0
- package/src/transport/flushController.ts +144 -0
- package/src/transport/httpRequest.ts +164 -0
- package/src/transport/index.ts +7 -0
- package/src/transport/sendWithRetryStrategy.ts +222 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Duration, RelativeTime } from './utils/timeUtils';
|
|
2
|
+
export interface ValueHistoryEntry<T> {
|
|
3
|
+
startTime: RelativeTime;
|
|
4
|
+
endTime: RelativeTime;
|
|
5
|
+
value: T;
|
|
6
|
+
remove(): void;
|
|
7
|
+
close(endTime: RelativeTime): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const CLEAR_OLD_VALUES_INTERVAL: number;
|
|
10
|
+
/**
|
|
11
|
+
* Store and keep track of values spans. This whole cache assumes that values are added in
|
|
12
|
+
* chronological order (i.e. all entries have an increasing start time).
|
|
13
|
+
*/
|
|
14
|
+
export interface ValueHistory<Value> {
|
|
15
|
+
add: (value: Value, startTime: RelativeTime) => ValueHistoryEntry<Value>;
|
|
16
|
+
find: (startTime?: RelativeTime, options?: {
|
|
17
|
+
returnInactive: boolean;
|
|
18
|
+
}) => Value | undefined;
|
|
19
|
+
closeActive: (endTime: RelativeTime) => void;
|
|
20
|
+
findAll: (startTime?: RelativeTime, duration?: Duration) => Value[];
|
|
21
|
+
reset: () => void;
|
|
22
|
+
stop: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function createValueHistory<Value>({ expireDelay, maxEntries, }: {
|
|
25
|
+
expireDelay: number;
|
|
26
|
+
maxEntries?: number;
|
|
27
|
+
}): ValueHistory<Value>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLEAR_OLD_VALUES_INTERVAL = void 0;
|
|
4
|
+
exports.createValueHistory = createValueHistory;
|
|
5
|
+
const timer_1 = require("./timer");
|
|
6
|
+
const arrayUtils_1 = require("./utils/arrayUtils");
|
|
7
|
+
const timeUtils_1 = require("./utils/timeUtils");
|
|
8
|
+
const END_OF_TIMES = Infinity;
|
|
9
|
+
exports.CLEAR_OLD_VALUES_INTERVAL = timeUtils_1.ONE_MINUTE;
|
|
10
|
+
let cleanupHistoriesInterval = null;
|
|
11
|
+
const cleanupTasks = new Set();
|
|
12
|
+
function cleanupHistories() {
|
|
13
|
+
cleanupTasks.forEach((task) => task());
|
|
14
|
+
}
|
|
15
|
+
function createValueHistory({ expireDelay, maxEntries, }) {
|
|
16
|
+
let entries = [];
|
|
17
|
+
if (!cleanupHistoriesInterval) {
|
|
18
|
+
cleanupHistoriesInterval = (0, timer_1.setInterval)(() => cleanupHistories(), exports.CLEAR_OLD_VALUES_INTERVAL);
|
|
19
|
+
}
|
|
20
|
+
const clearExpiredValues = () => {
|
|
21
|
+
const oldTimeThreshold = (0, timeUtils_1.relativeNow)() - expireDelay;
|
|
22
|
+
while (entries.length > 0 && entries[entries.length - 1].endTime < oldTimeThreshold) {
|
|
23
|
+
entries.pop();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
cleanupTasks.add(clearExpiredValues);
|
|
27
|
+
/**
|
|
28
|
+
* Add a value to the history associated with a start time. Returns a reference to this newly
|
|
29
|
+
* added entry that can be removed or closed.
|
|
30
|
+
*/
|
|
31
|
+
function add(value, startTime) {
|
|
32
|
+
const entry = {
|
|
33
|
+
value,
|
|
34
|
+
startTime,
|
|
35
|
+
endTime: END_OF_TIMES,
|
|
36
|
+
remove: () => {
|
|
37
|
+
(0, arrayUtils_1.removeItem)(entries, entry);
|
|
38
|
+
},
|
|
39
|
+
close: (endTime) => {
|
|
40
|
+
entry.endTime = endTime;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
if (maxEntries && entries.length >= maxEntries) {
|
|
44
|
+
entries.pop();
|
|
45
|
+
}
|
|
46
|
+
entries.unshift(entry);
|
|
47
|
+
return entry;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Return the latest value that was active during `startTime`, or the currently active value
|
|
51
|
+
* if no `startTime` is provided. This method assumes that entries are not overlapping.
|
|
52
|
+
*
|
|
53
|
+
* If `option.returnInactive` is true, returns the value at `startTime` (active or not).
|
|
54
|
+
*/
|
|
55
|
+
function find(startTime = END_OF_TIMES, options = { returnInactive: false }) {
|
|
56
|
+
for (const entry of entries) {
|
|
57
|
+
if (entry.startTime <= startTime) {
|
|
58
|
+
if (options.returnInactive || startTime <= entry.endTime) {
|
|
59
|
+
return entry.value;
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Helper function to close the currently active value, if any. This method assumes that entries
|
|
67
|
+
* are not overlapping.
|
|
68
|
+
*/
|
|
69
|
+
function closeActive(endTime) {
|
|
70
|
+
const latestEntry = entries[0];
|
|
71
|
+
if (latestEntry && latestEntry.endTime === END_OF_TIMES) {
|
|
72
|
+
latestEntry.close(endTime);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Return all values with an active period overlapping with the duration,
|
|
77
|
+
* or all values that were active during `startTime` if no duration is provided,
|
|
78
|
+
* or all currently active values if no `startTime` is provided.
|
|
79
|
+
*/
|
|
80
|
+
function findAll(startTime = END_OF_TIMES, duration = 0) {
|
|
81
|
+
const endTime = (0, timeUtils_1.addDuration)(startTime, duration);
|
|
82
|
+
return entries
|
|
83
|
+
.filter((entry) => entry.startTime <= endTime && startTime <= entry.endTime)
|
|
84
|
+
.map((entry) => entry.value);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Remove all entries from this collection.
|
|
88
|
+
*/
|
|
89
|
+
function reset() {
|
|
90
|
+
entries = [];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Stop internal garbage collection of past entries.
|
|
94
|
+
*/
|
|
95
|
+
function stop() {
|
|
96
|
+
cleanupTasks.delete(clearExpiredValues);
|
|
97
|
+
if (cleanupTasks.size === 0 && cleanupHistoriesInterval) {
|
|
98
|
+
(0, timer_1.clearInterval)(cleanupHistoriesInterval);
|
|
99
|
+
cleanupHistoriesInterval = null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return { add, find, closeActive, findAll, reset, stop };
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=valueHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueHistory.js","sourceRoot":"","sources":["../../src/tools/valueHistory.ts"],"names":[],"mappings":";;;AAwCA,gDA8GC;AAtJD,mCAAoD;AAEpD,mDAA+C;AAE/C,iDAAwE;AAExE,MAAM,YAAY,GAAG,QAAwB,CAAA;AAUhC,QAAA,yBAAyB,GAAG,sBAAU,CAAA;AAgBnD,IAAI,wBAAwB,GAAqB,IAAI,CAAA;AAErD,MAAM,YAAY,GAAoB,IAAI,GAAG,EAAE,CAAA;AAE/C,SAAS,gBAAgB;IACvB,YAAY,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAA;AACxC,CAAC;AAED,SAAgB,kBAAkB,CAAQ,EACxC,WAAW,EACX,UAAU,GAIX;IACC,IAAI,OAAO,GAAoC,EAAE,CAAA;IAEjD,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC9B,wBAAwB,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,EAAE,iCAAyB,CAAC,CAAA;IA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K;YACP,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,SAAS,WAAW,CAAC,OAAqB;QACxC,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;QAC9B,IAAI,WAAW,IAAI,WAAW,CAAC,OAAO,KAAK,YAAY,EAAE,CAAC;YACxD,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,SAAS,OAAO,CAAC,YAA0B,YAAY,EAAE,WAAW,CAAa;QAC/E,MAAM,OAAO,GAAG,IAAA,uBAAW,EAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;QAChD,OAAO,OAAO;aACX,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,IAAI,OAAO,IAAI,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC;aAC3E,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;IAED;;OAEG;IACH,SAAS,KAAK;QACZ,OAAO,GAAG,EAAE,CAAA;IACd,CAAC;IAED;;OAEG;IACH,SAAS,IAAI;QACX,YAAY,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAA;QACvC,IAAI,YAAY,CAAC,IAAI,KAAK,CAAC,IAAI,wBAAwB,EAAE,CAAC;YACxD,IAAA,qBAAa,EAAC,wBAAwB,CAAC,CAAA;YACvC,wBAAwB,GAAG,IAAI,CAAA;QACjC,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AACzD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Context } from '../tools/serialisation/context';
|
|
2
|
+
import type { Encoder } from '../tools/encoder';
|
|
3
|
+
import type { HttpRequest } from './httpRequest';
|
|
4
|
+
import type { FlushController } from './flushController';
|
|
5
|
+
export interface Batch {
|
|
6
|
+
flushController: FlushController;
|
|
7
|
+
add: (message: Context) => void;
|
|
8
|
+
upsert: (message: Context, key: string) => void;
|
|
9
|
+
stop: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function createBatch({ encoder, request, flushController, messageBytesLimit, }: {
|
|
12
|
+
encoder: Encoder;
|
|
13
|
+
request: HttpRequest;
|
|
14
|
+
flushController: FlushController;
|
|
15
|
+
messageBytesLimit: number;
|
|
16
|
+
}): Batch;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBatch = createBatch;
|
|
4
|
+
const display_1 = require("../tools/display");
|
|
5
|
+
const polyfills_1 = require("../tools/utils/polyfills");
|
|
6
|
+
const pageMayExitObservable_1 = require("../browser/pageMayExitObservable");
|
|
7
|
+
const jsonStringify_1 = require("../tools/serialisation/jsonStringify");
|
|
8
|
+
const byteUtils_1 = require("../tools/utils/byteUtils");
|
|
9
|
+
function createBatch({ encoder, request, flushController, messageBytesLimit, }) {
|
|
10
|
+
let upsertBuffer = {};
|
|
11
|
+
const flushSubscription = flushController.flushObservable.subscribe((event) => flush(event));
|
|
12
|
+
function push(serializedMessage, estimatedMessageBytesCount, key) {
|
|
13
|
+
flushController.notifyBeforeAddMessage(estimatedMessageBytesCount);
|
|
14
|
+
if (key !== undefined) {
|
|
15
|
+
upsertBuffer[key] = serializedMessage;
|
|
16
|
+
flushController.notifyAfterAddMessage();
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
encoder.write(encoder.isEmpty ? serializedMessage : `\n${serializedMessage}`, (realMessageBytesCount) => {
|
|
20
|
+
flushController.notifyAfterAddMessage(realMessageBytesCount - estimatedMessageBytesCount);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function hasMessageFor(key) {
|
|
25
|
+
return key !== undefined && upsertBuffer[key] !== undefined;
|
|
26
|
+
}
|
|
27
|
+
function remove(key) {
|
|
28
|
+
const removedMessage = upsertBuffer[key];
|
|
29
|
+
delete upsertBuffer[key];
|
|
30
|
+
const messageBytesCount = encoder.estimateEncodedBytesCount(removedMessage);
|
|
31
|
+
flushController.notifyAfterRemoveMessage(messageBytesCount);
|
|
32
|
+
}
|
|
33
|
+
function addOrUpdate(message, key) {
|
|
34
|
+
const serializedMessage = (0, jsonStringify_1.jsonStringify)(message);
|
|
35
|
+
const estimatedMessageBytesCount = encoder.estimateEncodedBytesCount(serializedMessage);
|
|
36
|
+
if (estimatedMessageBytesCount >= messageBytesLimit) {
|
|
37
|
+
display_1.display.warn(`Discarded a message whose size was bigger than the maximum allowed size ${messageBytesLimit}KB. ${display_1.MORE_DETAILS} ${display_1.DOCS_TROUBLESHOOTING}/#technical-limitations`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (hasMessageFor(key)) {
|
|
41
|
+
remove(key);
|
|
42
|
+
}
|
|
43
|
+
push(serializedMessage, estimatedMessageBytesCount, key);
|
|
44
|
+
}
|
|
45
|
+
function flush(event) {
|
|
46
|
+
const upsertMessages = (0, polyfills_1.objectValues)(upsertBuffer).join('\n');
|
|
47
|
+
upsertBuffer = {};
|
|
48
|
+
const pageMightExit = (0, pageMayExitObservable_1.isPageExitReason)(event.reason);
|
|
49
|
+
const send = pageMightExit ? request.sendOnExit : request.send;
|
|
50
|
+
if (pageMightExit &&
|
|
51
|
+
// Note: checking that the encoder is async is not strictly needed, but it's an optimization:
|
|
52
|
+
// if the encoder is async we need to send two requests in some cases (one for encoded data
|
|
53
|
+
// and the other for non-encoded data). But if it's not async, we don't have to worry about
|
|
54
|
+
// it and always send a single request.
|
|
55
|
+
encoder.isAsync) {
|
|
56
|
+
const encoderResult = encoder.finishSync();
|
|
57
|
+
// Send encoded messages
|
|
58
|
+
if (encoderResult.outputBytesCount) {
|
|
59
|
+
send(formatPayloadFromEncoder(encoderResult));
|
|
60
|
+
}
|
|
61
|
+
// Send messages that are not yet encoded at this point
|
|
62
|
+
const pendingMessages = [encoderResult.pendingData, upsertMessages].filter(Boolean).join('\n');
|
|
63
|
+
if (pendingMessages) {
|
|
64
|
+
send({
|
|
65
|
+
data: pendingMessages,
|
|
66
|
+
bytesCount: (0, byteUtils_1.computeBytesCount)(pendingMessages),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
if (upsertMessages) {
|
|
72
|
+
encoder.write(encoder.isEmpty ? upsertMessages : `\n${upsertMessages}`);
|
|
73
|
+
}
|
|
74
|
+
encoder.finish((encoderResult) => {
|
|
75
|
+
send(formatPayloadFromEncoder(encoderResult));
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
flushController,
|
|
81
|
+
add: addOrUpdate,
|
|
82
|
+
upsert: addOrUpdate,
|
|
83
|
+
stop: flushSubscription.unsubscribe,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function formatPayloadFromEncoder(encoderResult) {
|
|
87
|
+
let data;
|
|
88
|
+
if (typeof encoderResult.output === 'string') {
|
|
89
|
+
data = encoderResult.output;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
data = new Blob([encoderResult.output], {
|
|
93
|
+
// This will set the 'Content-Type: text/plain' header. Reasoning:
|
|
94
|
+
// * The intake rejects the request if there is no content type.
|
|
95
|
+
// * The browser will issue CORS preflight requests if we set it to 'application/json', which
|
|
96
|
+
// could induce higher intake load (and maybe has other impacts).
|
|
97
|
+
// * Also it's not quite JSON, since we are concatenating multiple JSON objects separated by
|
|
98
|
+
// new lines.
|
|
99
|
+
type: 'text/plain',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
data,
|
|
104
|
+
bytesCount: encoderResult.outputBytesCount,
|
|
105
|
+
encoding: encoderResult.encoding,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# s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AAC;IAED,OAAO;QACL,IAAI;QACJ,UAAU,EAAE,aAAa,CAAC,gBAAgB;QAC1C,QAAQ,EAAE,aAAa,CAAC,QAAQ;KACjC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DefaultPrivacyLevel } from '../domain/configuration';
|
|
2
|
+
export interface BrowserWindowWithEventBridge extends Window {
|
|
3
|
+
DatadogEventBridge?: DatadogEventBridge;
|
|
4
|
+
}
|
|
5
|
+
export interface DatadogEventBridge {
|
|
6
|
+
getCapabilities?(): string;
|
|
7
|
+
getPrivacyLevel?(): DefaultPrivacyLevel;
|
|
8
|
+
getAllowedWebViewHosts(): string;
|
|
9
|
+
send(msg: string): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const enum BridgeCapability {
|
|
12
|
+
RECORDS = "records"
|
|
13
|
+
}
|
|
14
|
+
export declare function getEventBridge<T, E>(): {
|
|
15
|
+
getCapabilities(): BridgeCapability[];
|
|
16
|
+
getPrivacyLevel(): DefaultPrivacyLevel | undefined;
|
|
17
|
+
getAllowedWebViewHosts(): string[];
|
|
18
|
+
send(eventType: T, event: E, viewId?: string): void;
|
|
19
|
+
} | undefined;
|
|
20
|
+
export declare function bridgeSupports(capability: BridgeCapability): boolean;
|
|
21
|
+
export declare function canUseEventBridge(currentHost?: string): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEventBridge = getEventBridge;
|
|
4
|
+
exports.bridgeSupports = bridgeSupports;
|
|
5
|
+
exports.canUseEventBridge = canUseEventBridge;
|
|
6
|
+
const globalObject_1 = require("../tools/globalObject");
|
|
7
|
+
function getEventBridge() {
|
|
8
|
+
const eventBridgeGlobal = getEventBridgeGlobal();
|
|
9
|
+
if (!eventBridgeGlobal) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
getCapabilities() {
|
|
14
|
+
var _a;
|
|
15
|
+
return JSON.parse(((_a = eventBridgeGlobal.getCapabilities) === null || _a === void 0 ? void 0 : _a.call(eventBridgeGlobal)) || '[]');
|
|
16
|
+
},
|
|
17
|
+
getPrivacyLevel() {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = eventBridgeGlobal.getPrivacyLevel) === null || _a === void 0 ? void 0 : _a.call(eventBridgeGlobal);
|
|
20
|
+
},
|
|
21
|
+
getAllowedWebViewHosts() {
|
|
22
|
+
return JSON.parse(eventBridgeGlobal.getAllowedWebViewHosts());
|
|
23
|
+
},
|
|
24
|
+
send(eventType, event, viewId) {
|
|
25
|
+
const view = viewId ? { id: viewId } : undefined;
|
|
26
|
+
eventBridgeGlobal.send(JSON.stringify({ eventType, event, view }));
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function bridgeSupports(capability) {
|
|
31
|
+
const bridge = getEventBridge();
|
|
32
|
+
return !!bridge && bridge.getCapabilities().includes(capability);
|
|
33
|
+
}
|
|
34
|
+
function canUseEventBridge(currentHost) {
|
|
35
|
+
var _a;
|
|
36
|
+
if (currentHost === void 0) { currentHost = (_a = (0, globalObject_1.getGlobalObject)().location) === null || _a === void 0 ? void 0 : _a.hostname; }
|
|
37
|
+
const bridge = getEventBridge();
|
|
38
|
+
return (!!bridge &&
|
|
39
|
+
bridge
|
|
40
|
+
.getAllowedWebViewHosts()
|
|
41
|
+
.some((allowedHost) => currentHost === allowedHost || currentHost.endsWith(`.${allowedHost}`)));
|
|
42
|
+
}
|
|
43
|
+
function getEventBridgeGlobal() {
|
|
44
|
+
return (0, globalObject_1.getGlobalObject)().DatadogEventBridge;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=eventBridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventBridge.js","sourceRoot":"","sources":["../../src/transport/eventBridge.ts"],"names":[],"mappings":";;AAkBA,wCAsBC;AAED,wCAGC;AAED,8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WAAW,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CACjG,CAAA;AACH,CAAC;AAED,SAAS,oBAAoB;IAC3B,OAAO,IAAA,8BAAe,GAAgC,CAAC,kBAAkB,CAAA;AAC3E,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { PageMayExitEvent, PageExitReason } from '../browser/pageMayExitObservable';
|
|
2
|
+
import { Observable } from '../tools/observable';
|
|
3
|
+
import type { Duration } from '../tools/utils/timeUtils';
|
|
4
|
+
export type FlushReason = PageExitReason | 'duration_limit' | 'bytes_limit' | 'messages_limit' | 'session_expire';
|
|
5
|
+
export type FlushController = ReturnType<typeof createFlushController>;
|
|
6
|
+
export interface FlushEvent {
|
|
7
|
+
reason: FlushReason;
|
|
8
|
+
bytesCount: number;
|
|
9
|
+
messagesCount: number;
|
|
10
|
+
}
|
|
11
|
+
interface FlushControllerOptions {
|
|
12
|
+
messagesLimit: number;
|
|
13
|
+
bytesLimit: number;
|
|
14
|
+
durationLimit: Duration;
|
|
15
|
+
pageMayExitObservable: Observable<PageMayExitEvent>;
|
|
16
|
+
sessionExpireObservable: Observable<void>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns a "flush controller", responsible of notifying when flushing a pool of pending data needs
|
|
20
|
+
* to happen. The implementation is designed to support both synchronous and asynchronous usages,
|
|
21
|
+
* but relies on invariants described in each method documentation to keep a coherent state.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createFlushController({ messagesLimit, bytesLimit, durationLimit, pageMayExitObservable, sessionExpireObservable, }: FlushControllerOptions): {
|
|
24
|
+
flushObservable: Observable<FlushEvent>;
|
|
25
|
+
readonly messagesCount: number;
|
|
26
|
+
/**
|
|
27
|
+
* Notifies that a message will be added to a pool of pending messages waiting to be flushed.
|
|
28
|
+
*
|
|
29
|
+
* This function needs to be called synchronously, right before adding the message, so no flush
|
|
30
|
+
* event can happen after `notifyBeforeAddMessage` and before adding the message.
|
|
31
|
+
*
|
|
32
|
+
* @param estimatedMessageBytesCount - an estimation of the message bytes count once it is
|
|
33
|
+
* actually added.
|
|
34
|
+
*/
|
|
35
|
+
notifyBeforeAddMessage(estimatedMessageBytesCount: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Notifies that a message *was* added to a pool of pending messages waiting to be flushed.
|
|
38
|
+
*
|
|
39
|
+
* This function can be called asynchronously after the message was added, but in this case it
|
|
40
|
+
* should not be called if a flush event occurred in between.
|
|
41
|
+
*
|
|
42
|
+
* @param messageBytesCountDiff - the difference between the estimated message bytes count and
|
|
43
|
+
* its actual bytes count once added to the pool.
|
|
44
|
+
*/
|
|
45
|
+
notifyAfterAddMessage(messageBytesCountDiff?: number): void;
|
|
46
|
+
/**
|
|
47
|
+
* Notifies that a message was removed from a pool of pending messages waiting to be flushed.
|
|
48
|
+
*
|
|
49
|
+
* This function needs to be called synchronously, right after removing the message, so no flush
|
|
50
|
+
* event can happen after removing the message and before `notifyAfterRemoveMessage`.
|
|
51
|
+
*
|
|
52
|
+
* @param messageBytesCount - the message bytes count that was added to the pool. Should
|
|
53
|
+
* correspond to the sum of bytes counts passed to `notifyBeforeAddMessage` and
|
|
54
|
+
* `notifyAfterAddMessage`.
|
|
55
|
+
*/
|
|
56
|
+
notifyAfterRemoveMessage(messageBytesCount: number): void;
|
|
57
|
+
};
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFlushController = createFlushController;
|
|
4
|
+
const observable_1 = require("../tools/observable");
|
|
5
|
+
const timer_1 = require("../tools/timer");
|
|
6
|
+
/**
|
|
7
|
+
* Returns a "flush controller", responsible of notifying when flushing a pool of pending data needs
|
|
8
|
+
* to happen. The implementation is designed to support both synchronous and asynchronous usages,
|
|
9
|
+
* but relies on invariants described in each method documentation to keep a coherent state.
|
|
10
|
+
*/
|
|
11
|
+
function createFlushController({ messagesLimit, bytesLimit, durationLimit, pageMayExitObservable, sessionExpireObservable, }) {
|
|
12
|
+
const pageMayExitSubscription = pageMayExitObservable.subscribe((event) => flush(event.reason));
|
|
13
|
+
const sessionExpireSubscription = sessionExpireObservable.subscribe(() => flush('session_expire'));
|
|
14
|
+
const flushObservable = new observable_1.Observable(() => () => {
|
|
15
|
+
pageMayExitSubscription.unsubscribe();
|
|
16
|
+
sessionExpireSubscription.unsubscribe();
|
|
17
|
+
});
|
|
18
|
+
let currentBytesCount = 0;
|
|
19
|
+
let currentMessagesCount = 0;
|
|
20
|
+
function flush(flushReason) {
|
|
21
|
+
if (currentMessagesCount === 0) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const messagesCount = currentMessagesCount;
|
|
25
|
+
const bytesCount = currentBytesCount;
|
|
26
|
+
currentMessagesCount = 0;
|
|
27
|
+
currentBytesCount = 0;
|
|
28
|
+
cancelDurationLimitTimeout();
|
|
29
|
+
flushObservable.notify({
|
|
30
|
+
reason: flushReason,
|
|
31
|
+
messagesCount,
|
|
32
|
+
bytesCount,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
let durationLimitTimeoutId;
|
|
36
|
+
function scheduleDurationLimitTimeout() {
|
|
37
|
+
if (durationLimitTimeoutId === undefined) {
|
|
38
|
+
durationLimitTimeoutId = (0, timer_1.setTimeout)(() => {
|
|
39
|
+
flush('duration_limit');
|
|
40
|
+
}, durationLimit);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function cancelDurationLimitTimeout() {
|
|
44
|
+
(0, timer_1.clearTimeout)(durationLimitTimeoutId);
|
|
45
|
+
durationLimitTimeoutId = undefined;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
flushObservable,
|
|
49
|
+
get messagesCount() {
|
|
50
|
+
return currentMessagesCount;
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* Notifies that a message will be added to a pool of pending messages waiting to be flushed.
|
|
54
|
+
*
|
|
55
|
+
* This function needs to be called synchronously, right before adding the message, so no flush
|
|
56
|
+
* event can happen after `notifyBeforeAddMessage` and before adding the message.
|
|
57
|
+
*
|
|
58
|
+
* @param estimatedMessageBytesCount - an estimation of the message bytes count once it is
|
|
59
|
+
* actually added.
|
|
60
|
+
*/
|
|
61
|
+
notifyBeforeAddMessage(estimatedMessageBytesCount) {
|
|
62
|
+
if (currentBytesCount + estimatedMessageBytesCount >= bytesLimit) {
|
|
63
|
+
flush('bytes_limit');
|
|
64
|
+
}
|
|
65
|
+
// Consider the message to be added now rather than in `notifyAfterAddMessage`, because if no
|
|
66
|
+
// message was added yet and `notifyAfterAddMessage` is called asynchronously, we still want
|
|
67
|
+
// to notify when a flush is needed (for example on page exit).
|
|
68
|
+
currentMessagesCount += 1;
|
|
69
|
+
currentBytesCount += estimatedMessageBytesCount;
|
|
70
|
+
scheduleDurationLimitTimeout();
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* Notifies that a message *was* added to a pool of pending messages waiting to be flushed.
|
|
74
|
+
*
|
|
75
|
+
* This function can be called asynchronously after the message was added, but in this case it
|
|
76
|
+
* should not be called if a flush event occurred in between.
|
|
77
|
+
*
|
|
78
|
+
* @param messageBytesCountDiff - the difference between the estimated message bytes count and
|
|
79
|
+
* its actual bytes count once added to the pool.
|
|
80
|
+
*/
|
|
81
|
+
notifyAfterAddMessage(messageBytesCountDiff = 0) {
|
|
82
|
+
currentBytesCount += messageBytesCountDiff;
|
|
83
|
+
if (currentMessagesCount >= messagesLimit) {
|
|
84
|
+
flush('messages_limit');
|
|
85
|
+
}
|
|
86
|
+
else if (currentBytesCount >= bytesLimit) {
|
|
87
|
+
flush('bytes_limit');
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Notifies that a message was removed from a pool of pending messages waiting to be flushed.
|
|
92
|
+
*
|
|
93
|
+
* This function needs to be called synchronously, right after removing the message, so no flush
|
|
94
|
+
* event can happen after removing the message and before `notifyAfterRemoveMessage`.
|
|
95
|
+
*
|
|
96
|
+
* @param messageBytesCount - the message bytes count that was added to the pool. Should
|
|
97
|
+
* correspond to the sum of bytes counts passed to `notifyBeforeAddMessage` and
|
|
98
|
+
* `notifyAfterAddMessage`.
|
|
99
|
+
*/
|
|
100
|
+
notifyAfterRemoveMessage(messageBytesCount) {
|
|
101
|
+
currentBytesCount -= messageBytesCount;
|
|
102
|
+
currentMessagesCount -= 1;
|
|
103
|
+
if (currentMessagesCount === 0) {
|
|
104
|
+
cancelDurationLimitTimeout();
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=flushController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flushController.js","sourceRoot":"","sources":["../../src/transport/flushController.ts"],"names":[],"mappings":";;AA4BA,sDAmHC;AA9ID,oDAAgD;AAEhD,0CAAyD;AAoBzD;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,EACpC,aAAa,EACb,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,uBAAuB,GACA;IACvB,MAAM,uBAAuB,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAC/F,MAAM,yBAAyB,GAAG,uBAAuB,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAElG,MAAM,eAAe,GAAG,IAAI,uBAAU,CAAa,GAAG,EAAE,CAAC,GAAG,EAAE;QAC5D,uBAAuB,CAAC,WAAW,EAAE,CAAA;QACrC,yBAAyB,CAAC,WAAW,EAAE,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,IAAI,iBAAiB,GAAG,CAAC,CAAA;IACzB,IAAI,oBAAoB,GAAG,CAAC,CAAA;IAE5B,SAAS,KAAK,CAAC,WAAwB;QACrC,I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C,gBAAgB,CAAC,CAAA;YACzB,CAAC;iBAAM,IAAI,iBAAiB,IAAI,UAAU,EAAE,CAAC;gBAC3C,KAAK,CAAC,aAAa,CAAC,CAAA;YACtB,CAAC;QACH,CAAC;QAED;;;;;;;;;WASG;QACH,wBAAwB,CAAC,iBAAyB;YAChD,iBAAiB,IAAI,iBAAiB,CAAA;YACtC,oBAAoB,IAAI,CAAC,CAAA;YACzB,IAAI,oBAAoB,KAAK,CAAC,EAAE,CAAC;gBAC/B,0BAA0B,EAAE,CAAA;YAC9B,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { EndpointBuilder } from '../domain/configuration';
|
|
2
|
+
import type { Context } from '../tools/serialisation/context';
|
|
3
|
+
import type { RawError } from '../domain/error/error.types';
|
|
4
|
+
import { Observable } from '../tools/observable';
|
|
5
|
+
/**
|
|
6
|
+
* Use POST request without content type to:
|
|
7
|
+
* - avoid CORS preflight requests
|
|
8
|
+
* - allow usage of sendBeacon
|
|
9
|
+
*
|
|
10
|
+
* multiple elements are sent separated by \n in order
|
|
11
|
+
* to be parsed correctly without content type header
|
|
12
|
+
*/
|
|
13
|
+
export interface HttpRequest<Body extends Payload = Payload> {
|
|
14
|
+
observable: Observable<HttpRequestEvent<Body>>;
|
|
15
|
+
send(this: void, payload: Body): void;
|
|
16
|
+
sendOnExit(this: void, payload: Body): void;
|
|
17
|
+
}
|
|
18
|
+
export interface HttpResponse extends Context {
|
|
19
|
+
status: number;
|
|
20
|
+
type?: ResponseType;
|
|
21
|
+
}
|
|
22
|
+
export interface BandwidthStats {
|
|
23
|
+
ongoingByteCount: number;
|
|
24
|
+
ongoingRequestCount: number;
|
|
25
|
+
}
|
|
26
|
+
export type HttpRequestEvent<Body extends Payload = Payload> = {
|
|
27
|
+
type: 'failure';
|
|
28
|
+
bandwidth: BandwidthStats;
|
|
29
|
+
payload: Body;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'queue-full';
|
|
32
|
+
bandwidth: BandwidthStats;
|
|
33
|
+
payload: Body;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'success';
|
|
36
|
+
bandwidth: BandwidthStats;
|
|
37
|
+
payload: Body;
|
|
38
|
+
};
|
|
39
|
+
export interface Payload {
|
|
40
|
+
data: string | FormData | Blob;
|
|
41
|
+
bytesCount: number;
|
|
42
|
+
retry?: RetryInfo;
|
|
43
|
+
encoding?: 'deflate';
|
|
44
|
+
}
|
|
45
|
+
export interface RetryInfo {
|
|
46
|
+
count: number;
|
|
47
|
+
lastFailureStatus: number;
|
|
48
|
+
}
|
|
49
|
+
export declare function createHttpRequest<Body extends Payload = Payload>(endpointBuilders: EndpointBuilder[], bytesLimit: number, reportError: (error: RawError) => void): HttpRequest<Body>;
|
|
50
|
+
export declare function fetchKeepAliveStrategy(endpointBuilder: EndpointBuilder, bytesLimit: number, payload: Payload, onResponse?: (r: HttpResponse) => void): void;
|
|
51
|
+
export declare function fetchStrategy(endpointBuilder: EndpointBuilder, payload: Payload, onResponse?: (r: HttpResponse) => void): void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createHttpRequest = createHttpRequest;
|
|
4
|
+
exports.fetchKeepAliveStrategy = fetchKeepAliveStrategy;
|
|
5
|
+
exports.fetchStrategy = fetchStrategy;
|
|
6
|
+
const monitor_1 = require("../tools/monitor");
|
|
7
|
+
const observable_1 = require("../tools/observable");
|
|
8
|
+
const sendWithRetryStrategy_1 = require("./sendWithRetryStrategy");
|
|
9
|
+
function createHttpRequest(endpointBuilders, bytesLimit, reportError) {
|
|
10
|
+
const observable = new observable_1.Observable();
|
|
11
|
+
const retryState = (0, sendWithRetryStrategy_1.newRetryState)();
|
|
12
|
+
return {
|
|
13
|
+
observable,
|
|
14
|
+
send: (payload) => {
|
|
15
|
+
for (const endpointBuilder of endpointBuilders) {
|
|
16
|
+
(0, sendWithRetryStrategy_1.sendWithRetryStrategy)(payload, retryState, (payload, onResponse) => fetchKeepAliveStrategy(endpointBuilder, bytesLimit, payload, onResponse), endpointBuilder.trackType, reportError, observable);
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* Since fetch keepalive behaves like regular fetch on Firefox,
|
|
21
|
+
* keep using sendBeaconStrategy on exit
|
|
22
|
+
*/
|
|
23
|
+
sendOnExit: (payload) => {
|
|
24
|
+
for (const endpointBuilder of endpointBuilders) {
|
|
25
|
+
sendBeaconStrategy(endpointBuilder, bytesLimit, payload);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function sendBeaconStrategy(endpointBuilder, bytesLimit, payload) {
|
|
31
|
+
const canUseBeacon = !!navigator.sendBeacon && payload.bytesCount < bytesLimit;
|
|
32
|
+
if (canUseBeacon) {
|
|
33
|
+
try {
|
|
34
|
+
const beaconUrl = endpointBuilder.build('beacon', payload);
|
|
35
|
+
const isQueued = navigator.sendBeacon(beaconUrl, payload.data);
|
|
36
|
+
if (isQueued) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
reportBeaconError(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
fetchStrategy(endpointBuilder, payload);
|
|
45
|
+
}
|
|
46
|
+
let hasReportedBeaconError = false;
|
|
47
|
+
function reportBeaconError(e) {
|
|
48
|
+
if (!hasReportedBeaconError) {
|
|
49
|
+
hasReportedBeaconError = true;
|
|
50
|
+
(0, monitor_1.monitorError)(e);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function fetchKeepAliveStrategy(endpointBuilder, bytesLimit, payload, onResponse) {
|
|
54
|
+
const canUseKeepAlive = isKeepAliveSupported() && payload.bytesCount < bytesLimit;
|
|
55
|
+
if (canUseKeepAlive) {
|
|
56
|
+
const fetchUrl = endpointBuilder.build('fetch-keepalive', payload);
|
|
57
|
+
fetch(fetchUrl, { method: 'POST', body: payload.data, keepalive: true, mode: 'cors' })
|
|
58
|
+
.then((0, monitor_1.monitor)((response) => onResponse === null || onResponse === void 0 ? void 0 : onResponse({ status: response.status, type: response.type })))
|
|
59
|
+
.catch((0, monitor_1.monitor)(() => fetchStrategy(endpointBuilder, payload, onResponse)));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
fetchStrategy(endpointBuilder, payload, onResponse);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function fetchStrategy(endpointBuilder, payload, onResponse) {
|
|
66
|
+
const fetchUrl = endpointBuilder.build('fetch', payload);
|
|
67
|
+
fetch(fetchUrl, { method: 'POST', body: payload.data, mode: 'cors' })
|
|
68
|
+
.then((0, monitor_1.monitor)((response) => onResponse === null || onResponse === void 0 ? void 0 : onResponse({ status: response.status, type: response.type })))
|
|
69
|
+
.catch((0, monitor_1.monitor)(() => onResponse === null || onResponse === void 0 ? void 0 : onResponse({ status: 0 })));
|
|
70
|
+
}
|
|
71
|
+
function isKeepAliveSupported() {
|
|
72
|
+
// Request can throw, cf https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#errors
|
|
73
|
+
try {
|
|
74
|
+
return window.Request && 'keepalive' in new Request('http://a');
|
|
75
|
+
}
|
|
76
|
+
catch (_a) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=httpRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpRequest.js","sourceRoot":"","sources":["../../src/transport/httpRequest.ts"],"names":[],"mappings":";;AAgEA,8CAgCC;AA6BD,wDAiBC;AAED,sCAUC;AAxJD,8CAAwD;AAExD,oDAAgD;AAChD,mEAA8E;AA2D9E,SAAgB,iBAAiB,CAC/B,gBAAmC,EACnC,UAAkB,EAClB,WAAsC;IAEtC,MAAM,UAAU,GAAG,IAAI,uBAAU,EAA0B,CA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