@kubesense/kubesense-browser-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- 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 +13 -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 +26 -0
- package/cjs/browser/cookie.js +112 -0
- package/cjs/browser/cookie.js.map +1 -0
- package/cjs/browser/fetchObservable.d.ts +38 -0
- package/cjs/browser/fetchObservable.js +103 -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 +24 -0
- package/cjs/browser/xhrObservable.js +86 -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 +284 -0
- package/cjs/domain/configuration/configuration.js +135 -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 +66 -0
- package/cjs/domain/configuration/endpointBuilder.js.map +1 -0
- package/cjs/domain/configuration/index.d.ts +6 -0
- package/cjs/domain/configuration/index.js +31 -0
- package/cjs/domain/configuration/index.js.map +1 -0
- package/cjs/domain/configuration/transportConfiguration.d.ts +21 -0
- package/cjs/domain/configuration/transportConfiguration.js +58 -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 +59 -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 +31 -0
- package/cjs/domain/contexts/userContext.js +120 -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 +81 -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 +41 -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 +4 -0
- package/cjs/domain/intakeSites.js +7 -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 +201 -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 +70 -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 +186 -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 +12 -0
- package/cjs/domain/session/storeStrategies/sessionInCookie.js +104 -0
- package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +1 -0
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.d.ts +6 -0
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +42 -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 +66 -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 +245 -0
- package/cjs/domain/telemetry/telemetry.js.map +1 -0
- package/cjs/domain/telemetry/telemetryEvent.types.d.ts +866 -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/domain/userAgentData/index.d.ts +1 -0
- package/cjs/domain/userAgentData/index.js +18 -0
- package/cjs/domain/userAgentData/index.js.map +1 -0
- package/cjs/domain/userAgentData/userAgentData.d.ts +22 -0
- package/cjs/domain/userAgentData/userAgentData.js +109 -0
- package/cjs/domain/userAgentData/userAgentData.js.map +1 -0
- package/cjs/index.d.ts +101 -0
- package/cjs/index.js +199 -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 +21 -0
- package/cjs/tools/experimentalFeatures.js +50 -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 +61 -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 +10 -0
- package/cjs/tools/readBytesFromStream.js +28 -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 +34 -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 +8 -0
- package/cjs/tools/utils/numberUtils.js +23 -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 +23 -0
- package/cjs/tools/utils/stringUtils.js +91 -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 +110 -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 +65 -0
- package/cjs/transport/flushController.js +123 -0
- package/cjs/transport/flushController.js.map +1 -0
- package/cjs/transport/httpRequest.d.ts +57 -0
- package/cjs/transport/httpRequest.js +107 -0
- package/cjs/transport/httpRequest.js.map +1 -0
- package/cjs/transport/index.d.ts +7 -0
- package/cjs/transport/index.js +15 -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 +13 -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 +26 -0
- package/esm/browser/cookie.js +101 -0
- package/esm/browser/cookie.js.map +1 -0
- package/esm/browser/fetchObservable.d.ts +38 -0
- package/esm/browser/fetchObservable.js +99 -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 +24 -0
- package/esm/browser/xhrObservable.js +83 -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 +284 -0
- package/esm/domain/configuration/configuration.js +129 -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 +62 -0
- package/esm/domain/configuration/endpointBuilder.js.map +1 -0
- package/esm/domain/configuration/index.d.ts +6 -0
- package/esm/domain/configuration/index.js +5 -0
- package/esm/domain/configuration/index.js.map +1 -0
- package/esm/domain/configuration/transportConfiguration.d.ts +21 -0
- package/esm/domain/configuration/transportConfiguration.js +54 -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 +56 -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 +31 -0
- package/esm/domain/contexts/userContext.js +116 -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 +72 -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 +38 -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 +4 -0
- package/esm/domain/intakeSites.js +4 -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 +196 -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 +60 -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 +180 -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 +12 -0
- package/esm/domain/session/storeStrategies/sessionInCookie.js +98 -0
- package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -0
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.d.ts +6 -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 +59 -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 +232 -0
- package/esm/domain/telemetry/telemetry.js.map +1 -0
- package/esm/domain/telemetry/telemetryEvent.types.d.ts +866 -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/domain/userAgentData/index.d.ts +1 -0
- package/esm/domain/userAgentData/index.js +2 -0
- package/esm/domain/userAgentData/index.js.map +1 -0
- package/esm/domain/userAgentData/userAgentData.d.ts +22 -0
- package/esm/domain/userAgentData/userAgentData.js +105 -0
- package/esm/domain/userAgentData/userAgentData.js.map +1 -0
- package/esm/index.d.ts +101 -0
- package/esm/index.js +77 -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 +21 -0
- package/esm/tools/experimentalFeatures.js +42 -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 +51 -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 +10 -0
- package/esm/tools/readBytesFromStream.js +25 -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 +29 -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 +8 -0
- package/esm/tools/utils/numberUtils.js +17 -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 +23 -0
- package/esm/tools/utils/stringUtils.js +84 -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 +106 -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 +65 -0
- package/esm/transport/flushController.js +119 -0
- package/esm/transport/flushController.js.map +1 -0
- package/esm/transport/httpRequest.d.ts +57 -0
- package/esm/transport/httpRequest.js +101 -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 +28 -0
- package/src/boot/displayAlreadyInitializedError.ts +8 -0
- package/src/boot/init.ts +54 -0
- package/src/browser/addEventListener.ts +145 -0
- package/src/browser/browser.types.ts +84 -0
- package/src/browser/cookie.ts +122 -0
- package/src/browser/fetchObservable.ts +167 -0
- package/src/browser/pageMayExitObservable.ts +56 -0
- package/src/browser/runOnReadyState.ts +25 -0
- package/src/browser/xhrObservable.ts +134 -0
- package/src/domain/allowedTrackingOrigins.ts +29 -0
- package/src/domain/bufferedData.ts +32 -0
- package/src/domain/configuration/configuration.ts +409 -0
- package/src/domain/configuration/endpointBuilder.ts +105 -0
- package/src/domain/configuration/index.ts +12 -0
- package/src/domain/configuration/transportConfiguration.ts +86 -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 +81 -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 +148 -0
- package/src/domain/deflate/deflate.types.ts +57 -0
- package/src/domain/deflate/index.ts +1 -0
- package/src/domain/error/error.ts +127 -0
- package/src/domain/error/error.types.ts +64 -0
- package/src/domain/error/trackRuntimeError.ts +50 -0
- package/src/domain/eventRateLimiter/createEventRateLimiter.ts +49 -0
- package/src/domain/extension/extensionUtils.ts +28 -0
- package/src/domain/intakeSites.ts +6 -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 +262 -0
- package/src/domain/session/sessionState.ts +83 -0
- package/src/domain/session/sessionStateValidation.ts +9 -0
- package/src/domain/session/sessionStore.ts +250 -0
- package/src/domain/session/sessionStoreOperations.ts +131 -0
- package/src/domain/session/storeStrategies/sessionInCookie.ts +146 -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 +75 -0
- package/src/domain/telemetry/index.ts +22 -0
- package/src/domain/telemetry/rawTelemetryEvent.types.ts +22 -0
- package/src/domain/telemetry/telemetry.ts +344 -0
- package/src/domain/telemetry/telemetryEvent.types.ts +907 -0
- package/src/domain/trackingConsent.ts +34 -0
- package/src/domain/userAgentData/index.ts +1 -0
- package/src/domain/userAgentData/userAgentData.ts +163 -0
- package/src/index.ts +169 -0
- package/src/tools/abstractHooks.ts +72 -0
- package/src/tools/abstractLifeCycle.ts +46 -0
- package/src/tools/boundedBuffer.ts +44 -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 +52 -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 +71 -0
- package/src/tools/observable.ts +103 -0
- package/src/tools/queueMicrotask.ts +13 -0
- package/src/tools/readBytesFromStream.ts +37 -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 +251 -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 +16 -0
- package/src/tools/utils/browserDetection.ts +39 -0
- package/src/tools/utils/byteUtils.ts +40 -0
- package/src/tools/utils/functionUtils.ts +45 -0
- package/src/tools/utils/numberUtils.ts +19 -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 +86 -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 +55 -0
- package/src/tools/valueHistory.ts +151 -0
- package/src/transport/batch.ts +144 -0
- package/src/transport/eventBridge.ts +60 -0
- package/src/transport/flushController.ts +150 -0
- package/src/transport/httpRequest.ts +191 -0
- package/src/transport/index.ts +7 -0
- package/src/transport/sendWithRetryStrategy.ts +222 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { setInterval, clearInterval } from './timer';
|
|
2
|
+
import { removeItem } from './utils/arrayUtils';
|
|
3
|
+
import { addDuration, relativeNow, ONE_MINUTE } from './utils/timeUtils';
|
|
4
|
+
const END_OF_TIMES = Infinity;
|
|
5
|
+
export const CLEAR_OLD_VALUES_INTERVAL = ONE_MINUTE;
|
|
6
|
+
let cleanupHistoriesInterval = null;
|
|
7
|
+
const cleanupTasks = new Set();
|
|
8
|
+
function cleanupHistories() {
|
|
9
|
+
cleanupTasks.forEach((task) => task());
|
|
10
|
+
}
|
|
11
|
+
export function createValueHistory({ expireDelay, maxEntries, }) {
|
|
12
|
+
let entries = [];
|
|
13
|
+
if (!cleanupHistoriesInterval) {
|
|
14
|
+
cleanupHistoriesInterval = setInterval(() => cleanupHistories(), CLEAR_OLD_VALUES_INTERVAL);
|
|
15
|
+
}
|
|
16
|
+
const clearExpiredValues = () => {
|
|
17
|
+
const oldTimeThreshold = relativeNow() - expireDelay;
|
|
18
|
+
while (entries.length > 0 && entries[entries.length - 1].endTime < oldTimeThreshold) {
|
|
19
|
+
entries.pop();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
cleanupTasks.add(clearExpiredValues);
|
|
23
|
+
/**
|
|
24
|
+
* Add a value to the history associated with a start time. Returns a reference to this newly
|
|
25
|
+
* added entry that can be removed or closed.
|
|
26
|
+
*/
|
|
27
|
+
function add(value, startTime) {
|
|
28
|
+
const entry = {
|
|
29
|
+
value,
|
|
30
|
+
startTime,
|
|
31
|
+
endTime: END_OF_TIMES,
|
|
32
|
+
remove: () => {
|
|
33
|
+
removeItem(entries, entry);
|
|
34
|
+
},
|
|
35
|
+
close: (endTime) => {
|
|
36
|
+
entry.endTime = endTime;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
if (maxEntries && entries.length >= maxEntries) {
|
|
40
|
+
entries.pop();
|
|
41
|
+
}
|
|
42
|
+
entries.unshift(entry);
|
|
43
|
+
return entry;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Return the latest value that was active during `startTime`, or the currently active value
|
|
47
|
+
* if no `startTime` is provided. This method assumes that entries are not overlapping.
|
|
48
|
+
*
|
|
49
|
+
* If `option.returnInactive` is true, returns the value at `startTime` (active or not).
|
|
50
|
+
*/
|
|
51
|
+
function find(startTime = END_OF_TIMES, options = { returnInactive: false }) {
|
|
52
|
+
for (const entry of entries) {
|
|
53
|
+
if (entry.startTime <= startTime) {
|
|
54
|
+
if (options.returnInactive || startTime <= entry.endTime) {
|
|
55
|
+
return entry.value;
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Helper function to close the currently active value, if any. This method assumes that entries
|
|
63
|
+
* are not overlapping.
|
|
64
|
+
*/
|
|
65
|
+
function closeActive(endTime) {
|
|
66
|
+
const latestEntry = entries[0];
|
|
67
|
+
if (latestEntry && latestEntry.endTime === END_OF_TIMES) {
|
|
68
|
+
latestEntry.close(endTime);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Return all values with an active period overlapping with the duration,
|
|
73
|
+
* or all values that were active during `startTime` if no duration is provided,
|
|
74
|
+
* or all currently active values if no `startTime` is provided.
|
|
75
|
+
*/
|
|
76
|
+
function findAll(startTime = END_OF_TIMES, duration = 0) {
|
|
77
|
+
const endTime = addDuration(startTime, duration);
|
|
78
|
+
return entries
|
|
79
|
+
.filter((entry) => entry.startTime <= endTime && startTime <= entry.endTime)
|
|
80
|
+
.map((entry) => entry.value);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Remove all entries from this collection.
|
|
84
|
+
*/
|
|
85
|
+
function reset() {
|
|
86
|
+
entries = [];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Stop internal garbage collection of past entries.
|
|
90
|
+
*/
|
|
91
|
+
function stop() {
|
|
92
|
+
cleanupTasks.delete(clearExpiredValues);
|
|
93
|
+
if (cleanupTasks.size === 0 && cleanupHistoriesInterval) {
|
|
94
|
+
clearInterval(cleanupHistoriesInterval);
|
|
95
|
+
cleanupHistoriesInterval = null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return { add, find, closeActive, findAll, reset, stop };
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=valueHistory.js.map
|
|
@@ -0,0 +1 @@
|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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,aAAa,CAAC,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 declare const MESSAGE_BYTES_LIMIT: number;
|
|
6
|
+
export interface Batch {
|
|
7
|
+
flushController: FlushController;
|
|
8
|
+
add: (message: Context) => void;
|
|
9
|
+
upsert: (message: Context, key: string) => void;
|
|
10
|
+
stop: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function createBatch({ encoder, request, flushController, }: {
|
|
13
|
+
encoder: Encoder;
|
|
14
|
+
request: HttpRequest;
|
|
15
|
+
flushController: FlushController;
|
|
16
|
+
}): Batch;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { DOCS_TROUBLESHOOTING, MORE_DETAILS, display } from '../tools/display';
|
|
2
|
+
import { objectValues } from '../tools/utils/polyfills';
|
|
3
|
+
import { isPageExitReason } from '../browser/pageMayExitObservable';
|
|
4
|
+
import { jsonStringify } from '../tools/serialisation/jsonStringify';
|
|
5
|
+
import { computeBytesCount, ONE_KIBI_BYTE } from '../tools/utils/byteUtils';
|
|
6
|
+
export const MESSAGE_BYTES_LIMIT = 256 * ONE_KIBI_BYTE;
|
|
7
|
+
export function createBatch({ encoder, request, flushController, }) {
|
|
8
|
+
let upsertBuffer = {};
|
|
9
|
+
const flushSubscription = flushController.flushObservable.subscribe((event) => flush(event));
|
|
10
|
+
function push(serializedMessage, estimatedMessageBytesCount, key) {
|
|
11
|
+
flushController.notifyBeforeAddMessage(estimatedMessageBytesCount);
|
|
12
|
+
if (key !== undefined) {
|
|
13
|
+
upsertBuffer[key] = serializedMessage;
|
|
14
|
+
flushController.notifyAfterAddMessage();
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
encoder.write(encoder.isEmpty ? serializedMessage : `\n${serializedMessage}`, (realMessageBytesCount) => {
|
|
18
|
+
flushController.notifyAfterAddMessage(realMessageBytesCount - estimatedMessageBytesCount);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function hasMessageFor(key) {
|
|
23
|
+
return key !== undefined && upsertBuffer[key] !== undefined;
|
|
24
|
+
}
|
|
25
|
+
function remove(key) {
|
|
26
|
+
const removedMessage = upsertBuffer[key];
|
|
27
|
+
delete upsertBuffer[key];
|
|
28
|
+
const messageBytesCount = encoder.estimateEncodedBytesCount(removedMessage);
|
|
29
|
+
flushController.notifyAfterRemoveMessage(messageBytesCount);
|
|
30
|
+
}
|
|
31
|
+
function addOrUpdate(message, key) {
|
|
32
|
+
const serializedMessage = jsonStringify(message);
|
|
33
|
+
const estimatedMessageBytesCount = encoder.estimateEncodedBytesCount(serializedMessage);
|
|
34
|
+
if (estimatedMessageBytesCount >= MESSAGE_BYTES_LIMIT) {
|
|
35
|
+
display.warn(`Discarded a message whose size was bigger than the maximum allowed size ${MESSAGE_BYTES_LIMIT / ONE_KIBI_BYTE}KiB. ${MORE_DETAILS} ${DOCS_TROUBLESHOOTING}/#technical-limitations`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (hasMessageFor(key)) {
|
|
39
|
+
remove(key);
|
|
40
|
+
}
|
|
41
|
+
push(serializedMessage, estimatedMessageBytesCount, key);
|
|
42
|
+
}
|
|
43
|
+
function flush(event) {
|
|
44
|
+
const upsertMessages = objectValues(upsertBuffer).join('\n');
|
|
45
|
+
upsertBuffer = {};
|
|
46
|
+
const pageMightExit = isPageExitReason(event.reason);
|
|
47
|
+
const send = pageMightExit ? request.sendOnExit : request.send;
|
|
48
|
+
if (pageMightExit &&
|
|
49
|
+
// Note: checking that the encoder is async is not strictly needed, but it's an optimization:
|
|
50
|
+
// if the encoder is async we need to send two requests in some cases (one for encoded data
|
|
51
|
+
// and the other for non-encoded data). But if it's not async, we don't have to worry about
|
|
52
|
+
// it and always send a single request.
|
|
53
|
+
encoder.isAsync) {
|
|
54
|
+
const encoderResult = encoder.finishSync();
|
|
55
|
+
// Send encoded messages
|
|
56
|
+
if (encoderResult.outputBytesCount) {
|
|
57
|
+
send(formatPayloadFromEncoder(encoderResult));
|
|
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
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (upsertMessages) {
|
|
70
|
+
encoder.write(encoder.isEmpty ? upsertMessages : `\n${upsertMessages}`);
|
|
71
|
+
}
|
|
72
|
+
encoder.finish((encoderResult) => {
|
|
73
|
+
send(formatPayloadFromEncoder(encoderResult));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
flushController,
|
|
79
|
+
add: addOrUpdate,
|
|
80
|
+
upsert: addOrUpdate,
|
|
81
|
+
stop: flushSubscription.unsubscribe,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function formatPayloadFromEncoder(encoderResult) {
|
|
85
|
+
let data;
|
|
86
|
+
if (typeof encoderResult.output === 'string') {
|
|
87
|
+
data = encoderResult.output;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
data = new Blob([encoderResult.output], {
|
|
91
|
+
// This will set the 'Content-Type: text/plain' header. Reasoning:
|
|
92
|
+
// * The intake rejects the request if there is no content type.
|
|
93
|
+
// * The browser will issue CORS preflight requests if we set it to 'application/json', which
|
|
94
|
+
// could induce higher intake load (and maybe has other impacts).
|
|
95
|
+
// * Also it's not quite JSON, since we are concatenating multiple JSON objects separated by
|
|
96
|
+
// new lines.
|
|
97
|
+
type: 'text/plain',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
data,
|
|
102
|
+
bytesCount: encoderResult.outputBytesCount,
|
|
103
|
+
encoding: encoderResult.encoding,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.js","sourceRoot":"","sources":["../../src/transport/batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AAEpE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAI3E,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,GAAG,aAAa,CAAA;AAStD,MAAM,U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AAI,CAAC;oBACH,IAAI,EAAE,eAAe;oBACrB,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAAC;iBAC/C,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,cAAc,EAAE,CAAC;gBACnB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,cAAc,EAAE,CAAC,CAAA;YACzE,CAAC;YACD,OAAO,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE;gBAC/B,IAAI,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAC,CAAA;YAC/C,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,eAAe;QACf,GAAG,EAAE,WAAW;QAChB,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE,iBAAiB,CAAC,WAAW;KACpC,CAAA;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,aAA4B;IAC5D,IAAI,IAAmB,CAAA;IACvB,IAAI,OAAO,aAAa,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC7C,IAAI,GAAG,aAAa,CAAC,MAAM,CAAA;IAC7B,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;YACtC,kEAAkE;YAClE,gEAAgE;YAChE,6FAA6F;YAC7F,iEAAiE;YACjE,4FAA4F;YAC5F,aAAa;YACb,IAAI,EAAE,YAAY;SACnB,CAAC,CAAA;IACJ,CAAC;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
|
+
KubsesenseEventBridge?: KubsesenseEventBridge;
|
|
4
|
+
}
|
|
5
|
+
export interface KubsesenseEventBridge {
|
|
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,41 @@
|
|
|
1
|
+
import { getGlobalObject } from '../tools/globalObject';
|
|
2
|
+
export function getEventBridge() {
|
|
3
|
+
const eventBridgeGlobal = getEventBridgeGlobal();
|
|
4
|
+
if (!eventBridgeGlobal) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
getCapabilities() {
|
|
9
|
+
var _a;
|
|
10
|
+
return JSON.parse(((_a = eventBridgeGlobal.getCapabilities) === null || _a === void 0 ? void 0 : _a.call(eventBridgeGlobal)) || '[]');
|
|
11
|
+
},
|
|
12
|
+
getPrivacyLevel() {
|
|
13
|
+
var _a;
|
|
14
|
+
return (_a = eventBridgeGlobal.getPrivacyLevel) === null || _a === void 0 ? void 0 : _a.call(eventBridgeGlobal);
|
|
15
|
+
},
|
|
16
|
+
getAllowedWebViewHosts() {
|
|
17
|
+
return JSON.parse(eventBridgeGlobal.getAllowedWebViewHosts());
|
|
18
|
+
},
|
|
19
|
+
send(eventType, event, viewId) {
|
|
20
|
+
const view = viewId ? { id: viewId } : undefined;
|
|
21
|
+
eventBridgeGlobal.send(JSON.stringify({ eventType, event, view }));
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function bridgeSupports(capability) {
|
|
26
|
+
const bridge = getEventBridge();
|
|
27
|
+
return !!bridge && bridge.getCapabilities().includes(capability);
|
|
28
|
+
}
|
|
29
|
+
export function canUseEventBridge(currentHost) {
|
|
30
|
+
var _a;
|
|
31
|
+
if (currentHost === void 0) { currentHost = (_a = getGlobalObject().location) === null || _a === void 0 ? void 0 : _a.hostname; }
|
|
32
|
+
const bridge = getEventBridge();
|
|
33
|
+
return (!!bridge &&
|
|
34
|
+
bridge
|
|
35
|
+
.getAllowedWebViewHosts()
|
|
36
|
+
.some((allowedHost) => currentHost === allowedHost || currentHost.endsWith(`.${allowedHost}`)));
|
|
37
|
+
}
|
|
38
|
+
function getEventBridgeGlobal() {
|
|
39
|
+
return getGlobalObject().KubsesenseEventBridge;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=eventBridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventBridge.js","sourceRoot":"","sources":["../../src/transport/eventBridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAkBvD,MAAM,UAAU,cAAc;IAC5B,MAAM,iBAAiB,GAAG,oBAAoB,EAAE,CAAA;IAEhD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,OAAM;IACR,CAAC;IAED,OAAO;QACL,eAAe;;YACb,OAAO,IAAI,CAAC,KAAK,CAAC,CAAA,MAAA,iBAAiB,CAAC,eAAe,iEAAI,KAAI,IAAI,CAAuB,CAAA;QACxF,CAAC;QACD,eAAe;;YACb,OAAO,MAAA,iBAAiB,CAAC,eAAe,iEAAI,CAAA;QAC9C,CAAC;QACD,sBAAsB;YACpB,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAa,CAAA;QAC3E,CAAC;QACD,IAAI,CAAC,SAAY,EAAE,KAAQ,EAAE,MAAe;YAC1C,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;YAChD,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QACpE,CAAC;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,UAA4B;IACzD,MAAM,MAAM,GAAG,cAAc,EAAE,CAAA;IAC/B,OAAO,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;AAClE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,WAA0D;;gCAA1D,EAAA,oBAAc,eAAe,EAAU,CAAC,QAAQ,0CAAE,QAAQ;IAC1F,MAAM,MAAM,GAAG,cAAc,EAAE,CAAA;IAC/B,OAAO,CACL,CAAC,CAAC,MAAM;QACR,MAAM;aACH,sBAAsB,EAAE;aACxB,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,KAAK,WAAW,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CACjG,CAAA;AACH,CAAC;AAED,SAAS,oBAAoB;IAC3B,OAAO,eAAe,EAAgC,CAAC,qBAAqB,CAAA;AAC9E,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* flush automatically, aim to be lower than ALB connection timeout
|
|
7
|
+
* to maximize connection reuse.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FLUSH_DURATION_LIMIT: Duration;
|
|
10
|
+
/**
|
|
11
|
+
* When using the SDK in a Worker Environment, we limit the batch size to 1 to ensure it can be sent
|
|
12
|
+
* in a single event.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MESSAGES_LIMIT: number;
|
|
15
|
+
export type FlushController = ReturnType<typeof createFlushController>;
|
|
16
|
+
export interface FlushEvent {
|
|
17
|
+
reason: FlushReason;
|
|
18
|
+
bytesCount: number;
|
|
19
|
+
messagesCount: number;
|
|
20
|
+
}
|
|
21
|
+
interface FlushControllerOptions {
|
|
22
|
+
pageMayExitObservable: Observable<PageMayExitEvent>;
|
|
23
|
+
sessionExpireObservable: Observable<void>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns a "flush controller", responsible of notifying when flushing a pool of pending data needs
|
|
27
|
+
* to happen. The implementation is designed to support both synchronous and asynchronous usages,
|
|
28
|
+
* but relies on invariants described in each method documentation to keep a coherent state.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createFlushController({ pageMayExitObservable, sessionExpireObservable }: FlushControllerOptions): {
|
|
31
|
+
flushObservable: Observable<FlushEvent>;
|
|
32
|
+
readonly messagesCount: number;
|
|
33
|
+
/**
|
|
34
|
+
* Notifies that a message will be added to a pool of pending messages waiting to be flushed.
|
|
35
|
+
*
|
|
36
|
+
* This function needs to be called synchronously, right before adding the message, so no flush
|
|
37
|
+
* event can happen after `notifyBeforeAddMessage` and before adding the message.
|
|
38
|
+
*
|
|
39
|
+
* @param estimatedMessageBytesCount - an estimation of the message bytes count once it is
|
|
40
|
+
* actually added.
|
|
41
|
+
*/
|
|
42
|
+
notifyBeforeAddMessage(estimatedMessageBytesCount: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Notifies that a message *was* added to a pool of pending messages waiting to be flushed.
|
|
45
|
+
*
|
|
46
|
+
* This function can be called asynchronously after the message was added, but in this case it
|
|
47
|
+
* should not be called if a flush event occurred in between.
|
|
48
|
+
*
|
|
49
|
+
* @param messageBytesCountDiff - the difference between the estimated message bytes count and
|
|
50
|
+
* its actual bytes count once added to the pool.
|
|
51
|
+
*/
|
|
52
|
+
notifyAfterAddMessage(messageBytesCountDiff?: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* Notifies that a message was removed from a pool of pending messages waiting to be flushed.
|
|
55
|
+
*
|
|
56
|
+
* This function needs to be called synchronously, right after removing the message, so no flush
|
|
57
|
+
* event can happen after removing the message and before `notifyAfterRemoveMessage`.
|
|
58
|
+
*
|
|
59
|
+
* @param messageBytesCount - the message bytes count that was added to the pool. Should
|
|
60
|
+
* correspond to the sum of bytes counts passed to `notifyBeforeAddMessage` and
|
|
61
|
+
* `notifyAfterAddMessage`.
|
|
62
|
+
*/
|
|
63
|
+
notifyAfterRemoveMessage(messageBytesCount: number): void;
|
|
64
|
+
};
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { isWorkerEnvironment } from '../tools/globalObject';
|
|
2
|
+
import { Observable } from '../tools/observable';
|
|
3
|
+
import { clearTimeout, setTimeout } from '../tools/timer';
|
|
4
|
+
import { ONE_SECOND } from '../tools/utils/timeUtils';
|
|
5
|
+
import { RECOMMENDED_REQUEST_BYTES_LIMIT } from './httpRequest';
|
|
6
|
+
/**
|
|
7
|
+
* flush automatically, aim to be lower than ALB connection timeout
|
|
8
|
+
* to maximize connection reuse.
|
|
9
|
+
*/
|
|
10
|
+
export const FLUSH_DURATION_LIMIT = (30 * ONE_SECOND);
|
|
11
|
+
/**
|
|
12
|
+
* When using the SDK in a Worker Environment, we limit the batch size to 1 to ensure it can be sent
|
|
13
|
+
* in a single event.
|
|
14
|
+
*/
|
|
15
|
+
export const MESSAGES_LIMIT = isWorkerEnvironment ? 1 : 50;
|
|
16
|
+
/**
|
|
17
|
+
* Returns a "flush controller", responsible of notifying when flushing a pool of pending data needs
|
|
18
|
+
* to happen. The implementation is designed to support both synchronous and asynchronous usages,
|
|
19
|
+
* but relies on invariants described in each method documentation to keep a coherent state.
|
|
20
|
+
*/
|
|
21
|
+
export function createFlushController({ pageMayExitObservable, sessionExpireObservable }) {
|
|
22
|
+
const pageMayExitSubscription = pageMayExitObservable.subscribe((event) => flush(event.reason));
|
|
23
|
+
const sessionExpireSubscription = sessionExpireObservable.subscribe(() => flush('session_expire'));
|
|
24
|
+
const flushObservable = new Observable(() => () => {
|
|
25
|
+
pageMayExitSubscription.unsubscribe();
|
|
26
|
+
sessionExpireSubscription.unsubscribe();
|
|
27
|
+
});
|
|
28
|
+
let currentBytesCount = 0;
|
|
29
|
+
let currentMessagesCount = 0;
|
|
30
|
+
function flush(flushReason) {
|
|
31
|
+
if (currentMessagesCount === 0) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const messagesCount = currentMessagesCount;
|
|
35
|
+
const bytesCount = currentBytesCount;
|
|
36
|
+
currentMessagesCount = 0;
|
|
37
|
+
currentBytesCount = 0;
|
|
38
|
+
cancelDurationLimitTimeout();
|
|
39
|
+
flushObservable.notify({
|
|
40
|
+
reason: flushReason,
|
|
41
|
+
messagesCount,
|
|
42
|
+
bytesCount,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
let durationLimitTimeoutId;
|
|
46
|
+
function scheduleDurationLimitTimeout() {
|
|
47
|
+
if (durationLimitTimeoutId === undefined) {
|
|
48
|
+
durationLimitTimeoutId = setTimeout(() => {
|
|
49
|
+
flush('duration_limit');
|
|
50
|
+
}, FLUSH_DURATION_LIMIT);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function cancelDurationLimitTimeout() {
|
|
54
|
+
clearTimeout(durationLimitTimeoutId);
|
|
55
|
+
durationLimitTimeoutId = undefined;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
flushObservable,
|
|
59
|
+
get messagesCount() {
|
|
60
|
+
return currentMessagesCount;
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Notifies that a message will be added to a pool of pending messages waiting to be flushed.
|
|
64
|
+
*
|
|
65
|
+
* This function needs to be called synchronously, right before adding the message, so no flush
|
|
66
|
+
* event can happen after `notifyBeforeAddMessage` and before adding the message.
|
|
67
|
+
*
|
|
68
|
+
* @param estimatedMessageBytesCount - an estimation of the message bytes count once it is
|
|
69
|
+
* actually added.
|
|
70
|
+
*/
|
|
71
|
+
notifyBeforeAddMessage(estimatedMessageBytesCount) {
|
|
72
|
+
if (currentBytesCount + estimatedMessageBytesCount >= RECOMMENDED_REQUEST_BYTES_LIMIT) {
|
|
73
|
+
flush('bytes_limit');
|
|
74
|
+
}
|
|
75
|
+
// Consider the message to be added now rather than in `notifyAfterAddMessage`, because if no
|
|
76
|
+
// message was added yet and `notifyAfterAddMessage` is called asynchronously, we still want
|
|
77
|
+
// to notify when a flush is needed (for example on page exit).
|
|
78
|
+
currentMessagesCount += 1;
|
|
79
|
+
currentBytesCount += estimatedMessageBytesCount;
|
|
80
|
+
scheduleDurationLimitTimeout();
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* Notifies that a message *was* added to a pool of pending messages waiting to be flushed.
|
|
84
|
+
*
|
|
85
|
+
* This function can be called asynchronously after the message was added, but in this case it
|
|
86
|
+
* should not be called if a flush event occurred in between.
|
|
87
|
+
*
|
|
88
|
+
* @param messageBytesCountDiff - the difference between the estimated message bytes count and
|
|
89
|
+
* its actual bytes count once added to the pool.
|
|
90
|
+
*/
|
|
91
|
+
notifyAfterAddMessage(messageBytesCountDiff = 0) {
|
|
92
|
+
currentBytesCount += messageBytesCountDiff;
|
|
93
|
+
if (currentMessagesCount >= MESSAGES_LIMIT) {
|
|
94
|
+
flush('messages_limit');
|
|
95
|
+
}
|
|
96
|
+
else if (currentBytesCount >= RECOMMENDED_REQUEST_BYTES_LIMIT) {
|
|
97
|
+
flush('bytes_limit');
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* Notifies that a message was removed from a pool of pending messages waiting to be flushed.
|
|
102
|
+
*
|
|
103
|
+
* This function needs to be called synchronously, right after removing the message, so no flush
|
|
104
|
+
* event can happen after removing the message and before `notifyAfterRemoveMessage`.
|
|
105
|
+
*
|
|
106
|
+
* @param messageBytesCount - the message bytes count that was added to the pool. Should
|
|
107
|
+
* correspond to the sum of bytes counts passed to `notifyBeforeAddMessage` and
|
|
108
|
+
* `notifyAfterAddMessage`.
|
|
109
|
+
*/
|
|
110
|
+
notifyAfterRemoveMessage(messageBytesCount) {
|
|
111
|
+
currentBytesCount -= messageBytesCount;
|
|
112
|
+
currentMessagesCount -= 1;
|
|
113
|
+
if (currentMessagesCount === 0) {
|
|
114
|
+
cancelDurationLimitTimeout();
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=flushController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flushController.js","sourceRoot":"","sources":["../../src/transport/flushController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAErD,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAI/D;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,GAAG,UAAU,CAAa,CAAA;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAc1D;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,EAAE,qBAAqB,EAAE,uBAAuB,EAA0B;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;QACf,IAAI,aAAa;YACf,OAAO,oBAAoB,CAAA;QAC7B,CAAC;QAED;;;;;;;;WAQG;QACH,sBAAsB,CAAC,0BAAkC;YACvD,IAAI,iBAAiB,GAAG,0BAA0B,IAAI,+BAA+B,EAAE,CAAC;gBACtF,KAAK,CAAC,aAAa,CAAC,CAAA;YACtB,CAAC;YACD,6FAA6F;YAC7F,4FAA4F;YAC5F,+DAA+D;YAC/D,oBAAoB,IAAI,CAAC,CAAA;YACzB,iBAAiB,IAAI,0BAA0B,CAAA;YAC/C,4BAA4B,EAAE,CAAA;QAChC,CAAC;QAED;;;;;;;;WAQG;QACH,qBAAqB,CAAC,qBAAqB,GAAG,CAAC;YAC7C,iBAAiB,IAAI,qBAAqB,CAAA;YAE1C,IAAI,oBAAoB,IAAI,cAAc,EAAE,CAAC;gBAC3C,KAAK,CAAC,gBAAgB,CAAC,CAAA;YACzB,CAAC;iBAAM,IAAI,iBAAiB,IAAI,+BAA+B,EAAE,CAAC;gBAChE,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,57 @@
|
|
|
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
|
+
* beacon payload max queue size implementation is 64kb
|
|
7
|
+
* ensure that we leave room for logs, rum and potential other users
|
|
8
|
+
*/
|
|
9
|
+
export declare const RECOMMENDED_REQUEST_BYTES_LIMIT: number;
|
|
10
|
+
/**
|
|
11
|
+
* Use POST request without content type to:
|
|
12
|
+
* - avoid CORS preflight requests
|
|
13
|
+
* - allow usage of sendBeacon
|
|
14
|
+
*
|
|
15
|
+
* multiple elements are sent separated by \n in order
|
|
16
|
+
* to be parsed correctly without content type header
|
|
17
|
+
*/
|
|
18
|
+
export interface HttpRequest<Body extends Payload = Payload> {
|
|
19
|
+
observable: Observable<HttpRequestEvent<Body>>;
|
|
20
|
+
send(this: void, payload: Body): void;
|
|
21
|
+
sendOnExit(this: void, payload: Body): void;
|
|
22
|
+
sendQueuedOnExit(this: void): void;
|
|
23
|
+
}
|
|
24
|
+
export interface HttpResponse extends Context {
|
|
25
|
+
status: number;
|
|
26
|
+
type?: ResponseType;
|
|
27
|
+
}
|
|
28
|
+
export interface BandwidthStats {
|
|
29
|
+
ongoingByteCount: number;
|
|
30
|
+
ongoingRequestCount: number;
|
|
31
|
+
}
|
|
32
|
+
export type HttpRequestEvent<Body extends Payload = Payload> = {
|
|
33
|
+
type: 'failure';
|
|
34
|
+
bandwidth: BandwidthStats;
|
|
35
|
+
payload: Body;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'queue-full';
|
|
38
|
+
bandwidth: BandwidthStats;
|
|
39
|
+
payload: Body;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'success';
|
|
42
|
+
bandwidth: BandwidthStats;
|
|
43
|
+
payload: Body;
|
|
44
|
+
};
|
|
45
|
+
export interface Payload {
|
|
46
|
+
data: string | FormData | Blob;
|
|
47
|
+
bytesCount: number;
|
|
48
|
+
retry?: RetryInfo;
|
|
49
|
+
encoding?: 'deflate';
|
|
50
|
+
}
|
|
51
|
+
export interface RetryInfo {
|
|
52
|
+
count: number;
|
|
53
|
+
lastFailureStatus: number;
|
|
54
|
+
}
|
|
55
|
+
export declare function createHttpRequest<Body extends Payload = Payload>(endpointBuilders: EndpointBuilder[], reportError: (error: RawError) => void, bytesLimit?: number): HttpRequest<Body>;
|
|
56
|
+
export declare function fetchKeepAliveStrategy(endpointBuilder: EndpointBuilder, bytesLimit: number, payload: Payload, onResponse?: (r: HttpResponse) => void): void;
|
|
57
|
+
export declare function fetchStrategy(endpointBuilder: EndpointBuilder, payload: Payload, onResponse?: (r: HttpResponse) => void): void;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { monitor, monitorError } from '../tools/monitor';
|
|
2
|
+
import { isExperimentalFeatureEnabled, ExperimentalFeature } from '../tools/experimentalFeatures';
|
|
3
|
+
import { Observable } from '../tools/observable';
|
|
4
|
+
import { ONE_KIBI_BYTE } from '../tools/utils/byteUtils';
|
|
5
|
+
import { newRetryState, sendWithRetryStrategy } from './sendWithRetryStrategy';
|
|
6
|
+
/**
|
|
7
|
+
* beacon payload max queue size implementation is 64kb
|
|
8
|
+
* ensure that we leave room for logs, rum and potential other users
|
|
9
|
+
*/
|
|
10
|
+
export const RECOMMENDED_REQUEST_BYTES_LIMIT = 16 * ONE_KIBI_BYTE;
|
|
11
|
+
export function createHttpRequest(endpointBuilders, reportError, bytesLimit = RECOMMENDED_REQUEST_BYTES_LIMIT) {
|
|
12
|
+
const observable = new Observable();
|
|
13
|
+
const retryState = newRetryState();
|
|
14
|
+
return {
|
|
15
|
+
observable,
|
|
16
|
+
send: (payload) => {
|
|
17
|
+
for (const endpointBuilder of endpointBuilders) {
|
|
18
|
+
sendWithRetryStrategy(payload, retryState, (payload, onResponse) => {
|
|
19
|
+
if (isExperimentalFeatureEnabled(ExperimentalFeature.AVOID_FETCH_KEEPALIVE)) {
|
|
20
|
+
fetchStrategy(endpointBuilder, payload, onResponse);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
fetchKeepAliveStrategy(endpointBuilder, bytesLimit, payload, onResponse);
|
|
24
|
+
}
|
|
25
|
+
}, endpointBuilder.trackType, reportError, observable);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* Since fetch keepalive behaves like regular fetch on Firefox,
|
|
30
|
+
* keep using sendBeaconStrategy on exit
|
|
31
|
+
*/
|
|
32
|
+
sendOnExit: (payload) => {
|
|
33
|
+
for (const endpointBuilder of endpointBuilders) {
|
|
34
|
+
sendBeaconStrategy(endpointBuilder, bytesLimit, payload);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Drains any payloads queued for retry by sending them via sendBeacon.
|
|
39
|
+
* This prevents data loss when the page exits while events are pending retry.
|
|
40
|
+
*/
|
|
41
|
+
sendQueuedOnExit: () => {
|
|
42
|
+
let payload;
|
|
43
|
+
while ((payload = retryState.queuedPayloads.dequeue()) !== undefined) {
|
|
44
|
+
for (const endpointBuilder of endpointBuilders) {
|
|
45
|
+
sendBeaconStrategy(endpointBuilder, bytesLimit, payload);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function sendBeaconStrategy(endpointBuilder, bytesLimit, payload) {
|
|
52
|
+
const canUseBeacon = !!navigator.sendBeacon && payload.bytesCount < bytesLimit;
|
|
53
|
+
if (canUseBeacon) {
|
|
54
|
+
try {
|
|
55
|
+
const beaconUrl = endpointBuilder.build('beacon', payload);
|
|
56
|
+
const isQueued = navigator.sendBeacon(beaconUrl, payload.data);
|
|
57
|
+
if (isQueued) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
reportBeaconError(e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
fetchStrategy(endpointBuilder, payload);
|
|
66
|
+
}
|
|
67
|
+
let hasReportedBeaconError = false;
|
|
68
|
+
function reportBeaconError(e) {
|
|
69
|
+
if (!hasReportedBeaconError) {
|
|
70
|
+
hasReportedBeaconError = true;
|
|
71
|
+
monitorError(e);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function fetchKeepAliveStrategy(endpointBuilder, bytesLimit, payload, onResponse) {
|
|
75
|
+
const canUseKeepAlive = isKeepAliveSupported() && payload.bytesCount < bytesLimit;
|
|
76
|
+
if (canUseKeepAlive) {
|
|
77
|
+
const fetchUrl = endpointBuilder.build('fetch-keepalive', payload);
|
|
78
|
+
fetch(fetchUrl, { method: 'POST', body: payload.data, keepalive: true, mode: 'cors' })
|
|
79
|
+
.then(monitor((response) => onResponse === null || onResponse === void 0 ? void 0 : onResponse({ status: response.status, type: response.type })))
|
|
80
|
+
.catch(monitor(() => fetchStrategy(endpointBuilder, payload, onResponse)));
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
fetchStrategy(endpointBuilder, payload, onResponse);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function fetchStrategy(endpointBuilder, payload, onResponse) {
|
|
87
|
+
const fetchUrl = endpointBuilder.build('fetch', payload);
|
|
88
|
+
fetch(fetchUrl, { method: 'POST', body: payload.data, mode: 'cors' })
|
|
89
|
+
.then(monitor((response) => onResponse === null || onResponse === void 0 ? void 0 : onResponse({ status: response.status, type: response.type })))
|
|
90
|
+
.catch(monitor(() => onResponse === null || onResponse === void 0 ? void 0 : onResponse({ status: 0 })));
|
|
91
|
+
}
|
|
92
|
+
function isKeepAliveSupported() {
|
|
93
|
+
// Request can throw, cf https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#errors
|
|
94
|
+
try {
|
|
95
|
+
return window.Request && 'keepalive' in new Request('http://a');
|
|
96
|
+
}
|
|
97
|
+
catch (_a) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=httpRequest.js.map
|