@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,244 @@
|
|
|
1
|
+
import { clearInterval, setInterval } from '../../tools/timer'
|
|
2
|
+
import { Observable } from '../../tools/observable'
|
|
3
|
+
import { ONE_SECOND, dateNow } from '../../tools/utils/timeUtils'
|
|
4
|
+
import { throttle } from '../../tools/utils/functionUtils'
|
|
5
|
+
import { generateUUID } from '../../tools/utils/stringUtils'
|
|
6
|
+
import type { InitConfiguration, Configuration } from '../configuration'
|
|
7
|
+
import { display } from '../../tools/display'
|
|
8
|
+
import { selectCookieStrategy, initCookieStrategy } from './storeStrategies/sessionInCookie'
|
|
9
|
+
import type { SessionStoreStrategy, SessionStoreStrategyType } from './storeStrategies/sessionStoreStrategy'
|
|
10
|
+
import type { SessionState } from './sessionState'
|
|
11
|
+
import {
|
|
12
|
+
getExpiredSessionState,
|
|
13
|
+
isSessionInExpiredState,
|
|
14
|
+
isSessionInNotStartedState,
|
|
15
|
+
isSessionStarted,
|
|
16
|
+
} from './sessionState'
|
|
17
|
+
import { initLocalStorageStrategy, selectLocalStorageStrategy } from './storeStrategies/sessionInLocalStorage'
|
|
18
|
+
import { processSessionStoreOperations } from './sessionStoreOperations'
|
|
19
|
+
import { SESSION_NOT_TRACKED, SessionPersistence } from './sessionConstants'
|
|
20
|
+
|
|
21
|
+
export interface SessionStore {
|
|
22
|
+
expandOrRenewSession: () => void
|
|
23
|
+
expandSession: () => void
|
|
24
|
+
getSession: () => SessionState
|
|
25
|
+
restartSession: () => void
|
|
26
|
+
renewObservable: Observable<void>
|
|
27
|
+
expireObservable: Observable<void>
|
|
28
|
+
sessionStateUpdateObservable: Observable<{ previousState: SessionState; newState: SessionState }>
|
|
29
|
+
expire: () => void
|
|
30
|
+
stop: () => void
|
|
31
|
+
updateSessionState: (state: Partial<SessionState>) => void
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Every second, the storage will be polled to check for any change that can occur
|
|
36
|
+
* to the session state in another browser tab, or another window.
|
|
37
|
+
* This value has been determined from our previous cookie-only implementation.
|
|
38
|
+
*/
|
|
39
|
+
export const STORAGE_POLL_DELAY = ONE_SECOND
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Selects the correct session store strategy type based on the configuration and storage
|
|
43
|
+
* availability.
|
|
44
|
+
*/
|
|
45
|
+
export function selectSessionStoreStrategyType(
|
|
46
|
+
initConfiguration: InitConfiguration
|
|
47
|
+
): SessionStoreStrategyType | undefined {
|
|
48
|
+
switch (initConfiguration.sessionPersistence) {
|
|
49
|
+
case SessionPersistence.COOKIE:
|
|
50
|
+
return selectCookieStrategy(initConfiguration)
|
|
51
|
+
|
|
52
|
+
case SessionPersistence.LOCAL_STORAGE:
|
|
53
|
+
return selectLocalStorageStrategy()
|
|
54
|
+
|
|
55
|
+
case undefined: {
|
|
56
|
+
let sessionStoreStrategyType = selectCookieStrategy(initConfiguration)
|
|
57
|
+
if (!sessionStoreStrategyType && initConfiguration.allowFallbackToLocalStorage) {
|
|
58
|
+
sessionStoreStrategyType = selectLocalStorageStrategy()
|
|
59
|
+
}
|
|
60
|
+
return sessionStoreStrategyType
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
default:
|
|
64
|
+
display.error(`Invalid session persistence '${String(initConfiguration.sessionPersistence)}'`)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function getSessionStoreStrategy(
|
|
69
|
+
sessionStoreStrategyType: SessionStoreStrategyType,
|
|
70
|
+
configuration: Configuration
|
|
71
|
+
) {
|
|
72
|
+
return sessionStoreStrategyType.type === SessionPersistence.COOKIE
|
|
73
|
+
? initCookieStrategy(configuration, sessionStoreStrategyType.cookieOptions)
|
|
74
|
+
: initLocalStorageStrategy(configuration)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Different session concepts:
|
|
79
|
+
* - tracked, the session has an id and is updated along the user navigation
|
|
80
|
+
* - not tracked, the session does not have an id but it is updated along the user navigation
|
|
81
|
+
* - inactive, no session in store or session expired, waiting for a renew session
|
|
82
|
+
*/
|
|
83
|
+
export function startSessionStore<TrackingType extends string>(
|
|
84
|
+
sessionStoreStrategyType: SessionStoreStrategyType,
|
|
85
|
+
configuration: Configuration,
|
|
86
|
+
productKey: string,
|
|
87
|
+
computeTrackingType: (rawTrackingType?: string) => TrackingType,
|
|
88
|
+
sessionStoreStrategy: SessionStoreStrategy = getSessionStoreStrategy(sessionStoreStrategyType, configuration)
|
|
89
|
+
): SessionStore {
|
|
90
|
+
const renewObservable = new Observable<void>()
|
|
91
|
+
const expireObservable = new Observable<void>()
|
|
92
|
+
const sessionStateUpdateObservable = new Observable<{ previousState: SessionState; newState: SessionState }>()
|
|
93
|
+
|
|
94
|
+
const watchSessionTimeoutId = setInterval(watchSession, STORAGE_POLL_DELAY)
|
|
95
|
+
let sessionCache: SessionState
|
|
96
|
+
|
|
97
|
+
startSession()
|
|
98
|
+
|
|
99
|
+
const { throttled: throttledExpandOrRenewSession, cancel: cancelExpandOrRenewSession } = throttle(() => {
|
|
100
|
+
processSessionStoreOperations(
|
|
101
|
+
{
|
|
102
|
+
process: (sessionState) => {
|
|
103
|
+
if (isSessionInNotStartedState(sessionState)) {
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const synchronizedSession = synchronizeSession(sessionState)
|
|
108
|
+
expandOrRenewSessionState(synchronizedSession)
|
|
109
|
+
return synchronizedSession
|
|
110
|
+
},
|
|
111
|
+
after: (sessionState) => {
|
|
112
|
+
if (isSessionStarted(sessionState) && !hasSessionInCache()) {
|
|
113
|
+
renewSessionInCache(sessionState)
|
|
114
|
+
}
|
|
115
|
+
sessionCache = sessionState
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
sessionStoreStrategy
|
|
119
|
+
)
|
|
120
|
+
}, STORAGE_POLL_DELAY)
|
|
121
|
+
|
|
122
|
+
function expandSession() {
|
|
123
|
+
processSessionStoreOperations(
|
|
124
|
+
{
|
|
125
|
+
process: (sessionState) => (hasSessionInCache() ? synchronizeSession(sessionState) : undefined),
|
|
126
|
+
},
|
|
127
|
+
sessionStoreStrategy
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* allows two behaviors:
|
|
133
|
+
* - if the session is active, synchronize the session cache without updating the session store
|
|
134
|
+
* - if the session is not active, clear the session store and expire the session cache
|
|
135
|
+
*/
|
|
136
|
+
function watchSession() {
|
|
137
|
+
const sessionState = sessionStoreStrategy.retrieveSession()
|
|
138
|
+
|
|
139
|
+
if (isSessionInExpiredState(sessionState)) {
|
|
140
|
+
processSessionStoreOperations(
|
|
141
|
+
{
|
|
142
|
+
process: (sessionState: SessionState) =>
|
|
143
|
+
isSessionInExpiredState(sessionState) ? getExpiredSessionState(sessionState, configuration) : undefined,
|
|
144
|
+
after: synchronizeSession,
|
|
145
|
+
},
|
|
146
|
+
sessionStoreStrategy
|
|
147
|
+
)
|
|
148
|
+
} else {
|
|
149
|
+
synchronizeSession(sessionState)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function synchronizeSession(sessionState: SessionState) {
|
|
154
|
+
if (isSessionInExpiredState(sessionState)) {
|
|
155
|
+
sessionState = getExpiredSessionState(sessionState, configuration)
|
|
156
|
+
}
|
|
157
|
+
if (hasSessionInCache()) {
|
|
158
|
+
if (isSessionInCacheOutdated(sessionState)) {
|
|
159
|
+
expireSessionInCache()
|
|
160
|
+
} else {
|
|
161
|
+
sessionStateUpdateObservable.notify({ previousState: sessionCache, newState: sessionState })
|
|
162
|
+
sessionCache = sessionState
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return sessionState
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function startSession() {
|
|
169
|
+
processSessionStoreOperations(
|
|
170
|
+
{
|
|
171
|
+
process: (sessionState) => {
|
|
172
|
+
if (isSessionInNotStartedState(sessionState)) {
|
|
173
|
+
return getExpiredSessionState(sessionState, configuration)
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
after: (sessionState) => {
|
|
177
|
+
sessionCache = sessionState
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
sessionStoreStrategy
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function expandOrRenewSessionState(sessionState: SessionState) {
|
|
185
|
+
if (isSessionInNotStartedState(sessionState)) {
|
|
186
|
+
return false
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const trackingType = computeTrackingType(sessionState[productKey])
|
|
190
|
+
sessionState[productKey] = trackingType
|
|
191
|
+
delete sessionState.isExpired
|
|
192
|
+
if (trackingType !== SESSION_NOT_TRACKED && !sessionState.id) {
|
|
193
|
+
sessionState.id = generateUUID()
|
|
194
|
+
sessionState.created = String(dateNow())
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function hasSessionInCache() {
|
|
199
|
+
return sessionCache?.[productKey] !== undefined
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function isSessionInCacheOutdated(sessionState: SessionState) {
|
|
203
|
+
return sessionCache.id !== sessionState.id || sessionCache[productKey] !== sessionState[productKey]
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function expireSessionInCache() {
|
|
207
|
+
sessionCache = getExpiredSessionState(sessionCache, configuration)
|
|
208
|
+
expireObservable.notify()
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function renewSessionInCache(sessionState: SessionState) {
|
|
212
|
+
sessionCache = sessionState
|
|
213
|
+
renewObservable.notify()
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function updateSessionState(partialSessionState: Partial<SessionState>) {
|
|
217
|
+
processSessionStoreOperations(
|
|
218
|
+
{
|
|
219
|
+
process: (sessionState) => ({ ...sessionState, ...partialSessionState }),
|
|
220
|
+
after: synchronizeSession,
|
|
221
|
+
},
|
|
222
|
+
sessionStoreStrategy
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
expandOrRenewSession: throttledExpandOrRenewSession,
|
|
228
|
+
expandSession,
|
|
229
|
+
getSession: () => sessionCache,
|
|
230
|
+
renewObservable,
|
|
231
|
+
expireObservable,
|
|
232
|
+
sessionStateUpdateObservable,
|
|
233
|
+
restartSession: startSession,
|
|
234
|
+
expire: () => {
|
|
235
|
+
cancelExpandOrRenewSession()
|
|
236
|
+
sessionStoreStrategy.expireSession(sessionCache)
|
|
237
|
+
synchronizeSession(getExpiredSessionState(sessionCache, configuration))
|
|
238
|
+
},
|
|
239
|
+
stop: () => {
|
|
240
|
+
clearInterval(watchSessionTimeoutId)
|
|
241
|
+
},
|
|
242
|
+
updateSessionState,
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { setTimeout } from '../../tools/timer'
|
|
2
|
+
import { generateUUID } from '../../tools/utils/stringUtils'
|
|
3
|
+
import type { TimeStamp } from '../../tools/utils/timeUtils'
|
|
4
|
+
import { elapsed, ONE_SECOND, timeStampNow } from '../../tools/utils/timeUtils'
|
|
5
|
+
import type { SessionStoreStrategy } from './storeStrategies/sessionStoreStrategy'
|
|
6
|
+
import type { SessionState } from './sessionState'
|
|
7
|
+
import { expandSessionState, isSessionInExpiredState } from './sessionState'
|
|
8
|
+
|
|
9
|
+
interface Operations {
|
|
10
|
+
process: (sessionState: SessionState) => SessionState | undefined
|
|
11
|
+
after?: (sessionState: SessionState) => void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const LOCK_RETRY_DELAY = 10
|
|
15
|
+
export const LOCK_MAX_TRIES = 100
|
|
16
|
+
|
|
17
|
+
// Locks should be hold for a few milliseconds top, just the time it takes to read and write a
|
|
18
|
+
// cookie. Using one second should be enough in most situations.
|
|
19
|
+
export const LOCK_EXPIRATION_DELAY = ONE_SECOND
|
|
20
|
+
const LOCK_SEPARATOR = '--'
|
|
21
|
+
|
|
22
|
+
const bufferedOperations: Operations[] = []
|
|
23
|
+
let ongoingOperations: Operations | undefined
|
|
24
|
+
|
|
25
|
+
export function processSessionStoreOperations(
|
|
26
|
+
operations: Operations,
|
|
27
|
+
sessionStoreStrategy: SessionStoreStrategy,
|
|
28
|
+
numberOfRetries = 0
|
|
29
|
+
) {
|
|
30
|
+
const { isLockEnabled, persistSession, expireSession } = sessionStoreStrategy
|
|
31
|
+
const persistWithLock = (session: SessionState) => persistSession({ ...session, lock: currentLock })
|
|
32
|
+
const retrieveStore = () => {
|
|
33
|
+
const { lock, ...session } = sessionStoreStrategy.retrieveSession()
|
|
34
|
+
return {
|
|
35
|
+
session,
|
|
36
|
+
lock: lock && !isLockExpired(lock) ? lock : undefined,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!ongoingOperations) {
|
|
41
|
+
ongoingOperations = operations
|
|
42
|
+
}
|
|
43
|
+
if (operations !== ongoingOperations) {
|
|
44
|
+
bufferedOperations.push(operations)
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
if (isLockEnabled && numberOfRetries >= LOCK_MAX_TRIES) {
|
|
48
|
+
next(sessionStoreStrategy)
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
let currentLock: string
|
|
52
|
+
let currentStore = retrieveStore()
|
|
53
|
+
if (isLockEnabled) {
|
|
54
|
+
// if someone has lock, retry later
|
|
55
|
+
if (currentStore.lock) {
|
|
56
|
+
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
// acquire lock
|
|
60
|
+
currentLock = createLock()
|
|
61
|
+
persistWithLock(currentStore.session)
|
|
62
|
+
// if lock is not acquired, retry later
|
|
63
|
+
currentStore = retrieveStore()
|
|
64
|
+
if (currentStore.lock !== currentLock) {
|
|
65
|
+
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
let processedSession = operations.process(currentStore.session)
|
|
70
|
+
if (isLockEnabled) {
|
|
71
|
+
// if lock corrupted after process, retry later
|
|
72
|
+
currentStore = retrieveStore()
|
|
73
|
+
if (currentStore.lock !== currentLock!) {
|
|
74
|
+
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (processedSession) {
|
|
79
|
+
if (isSessionInExpiredState(processedSession)) {
|
|
80
|
+
expireSession(processedSession)
|
|
81
|
+
} else {
|
|
82
|
+
expandSessionState(processedSession)
|
|
83
|
+
if (isLockEnabled) {
|
|
84
|
+
persistWithLock(processedSession)
|
|
85
|
+
} else {
|
|
86
|
+
persistSession(processedSession)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (isLockEnabled) {
|
|
91
|
+
// correctly handle lock around expiration would require to handle this case properly at several levels
|
|
92
|
+
// since we don't have evidence of lock issues around expiration, let's just not do the corruption check for it
|
|
93
|
+
if (!(processedSession && isSessionInExpiredState(processedSession))) {
|
|
94
|
+
// if lock corrupted after persist, retry later
|
|
95
|
+
currentStore = retrieveStore()
|
|
96
|
+
if (currentStore.lock !== currentLock!) {
|
|
97
|
+
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
persistSession(currentStore.session)
|
|
101
|
+
processedSession = currentStore.session
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// call after even if session is not persisted in order to perform operations on
|
|
105
|
+
// up-to-date session state value => the value could have been modified by another tab
|
|
106
|
+
operations.after?.(processedSession || currentStore.session)
|
|
107
|
+
next(sessionStoreStrategy)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function retryLater(operations: Operations, sessionStore: SessionStoreStrategy, currentNumberOfRetries: number) {
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
processSessionStoreOperations(operations, sessionStore, currentNumberOfRetries + 1)
|
|
113
|
+
}, LOCK_RETRY_DELAY)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function next(sessionStore: SessionStoreStrategy) {
|
|
117
|
+
ongoingOperations = undefined
|
|
118
|
+
const nextOperations = bufferedOperations.shift()
|
|
119
|
+
if (nextOperations) {
|
|
120
|
+
processSessionStoreOperations(nextOperations, sessionStore)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function createLock(): string {
|
|
125
|
+
return generateUUID() + LOCK_SEPARATOR + timeStampNow()
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function isLockExpired(lock: string) {
|
|
129
|
+
const [, timeStamp] = lock.split(LOCK_SEPARATOR)
|
|
130
|
+
return !timeStamp || elapsed(Number(timeStamp) as TimeStamp, timeStampNow()) > LOCK_EXPIRATION_DELAY
|
|
131
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isChromium } from '../../../tools/utils/browserDetection'
|
|
2
|
+
import type { CookieOptions } from '../../../browser/cookie'
|
|
3
|
+
import { getCurrentSite, areCookiesAuthorized, getCookie, setCookie } from '../../../browser/cookie'
|
|
4
|
+
import type { InitConfiguration, Configuration } from '../../configuration'
|
|
5
|
+
import { tryOldCookiesMigration } from '../oldCookiesMigration'
|
|
6
|
+
import {
|
|
7
|
+
SESSION_COOKIE_EXPIRATION_DELAY,
|
|
8
|
+
SESSION_EXPIRATION_DELAY,
|
|
9
|
+
SESSION_TIME_OUT_DELAY,
|
|
10
|
+
SessionPersistence,
|
|
11
|
+
} from '../sessionConstants'
|
|
12
|
+
import type { SessionState } from '../sessionState'
|
|
13
|
+
import { toSessionString, toSessionState, getExpiredSessionState } from '../sessionState'
|
|
14
|
+
import type { SessionStoreStrategy, SessionStoreStrategyType } from './sessionStoreStrategy'
|
|
15
|
+
import { SESSION_STORE_KEY } from './sessionStoreStrategy'
|
|
16
|
+
|
|
17
|
+
export function selectCookieStrategy(initConfiguration: InitConfiguration): SessionStoreStrategyType | undefined {
|
|
18
|
+
const cookieOptions = buildCookieOptions(initConfiguration)
|
|
19
|
+
return cookieOptions && areCookiesAuthorized(cookieOptions)
|
|
20
|
+
? { type: SessionPersistence.COOKIE, cookieOptions }
|
|
21
|
+
: undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function initCookieStrategy(configuration: Configuration, cookieOptions: CookieOptions): SessionStoreStrategy {
|
|
25
|
+
const cookieStore = {
|
|
26
|
+
/**
|
|
27
|
+
* Lock strategy allows mitigating issues due to concurrent access to cookie.
|
|
28
|
+
* This issue concerns only chromium browsers and enabling this on firefox increases cookie write failures.
|
|
29
|
+
*/
|
|
30
|
+
isLockEnabled: isChromium(),
|
|
31
|
+
persistSession: (sessionState: SessionState) =>
|
|
32
|
+
storeSessionCookie(cookieOptions, configuration, sessionState, SESSION_EXPIRATION_DELAY),
|
|
33
|
+
retrieveSession: retrieveSessionCookie,
|
|
34
|
+
expireSession: (sessionState: SessionState) =>
|
|
35
|
+
storeSessionCookie(
|
|
36
|
+
cookieOptions,
|
|
37
|
+
configuration,
|
|
38
|
+
getExpiredSessionState(sessionState, configuration),
|
|
39
|
+
SESSION_TIME_OUT_DELAY
|
|
40
|
+
),
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
tryOldCookiesMigration(cookieStore)
|
|
44
|
+
|
|
45
|
+
return cookieStore
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function storeSessionCookie(
|
|
49
|
+
options: CookieOptions,
|
|
50
|
+
configuration: Configuration,
|
|
51
|
+
sessionState: SessionState,
|
|
52
|
+
defaultTimeout: number
|
|
53
|
+
) {
|
|
54
|
+
setCookie(
|
|
55
|
+
SESSION_STORE_KEY,
|
|
56
|
+
toSessionString(sessionState),
|
|
57
|
+
configuration.trackAnonymousUser ? SESSION_COOKIE_EXPIRATION_DELAY : defaultTimeout,
|
|
58
|
+
options
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function retrieveSessionCookie(): SessionState {
|
|
63
|
+
const sessionString = getCookie(SESSION_STORE_KEY)
|
|
64
|
+
const sessionState = toSessionState(sessionString)
|
|
65
|
+
return sessionState
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function buildCookieOptions(initConfiguration: InitConfiguration): CookieOptions | undefined {
|
|
69
|
+
const cookieOptions: CookieOptions = {}
|
|
70
|
+
|
|
71
|
+
cookieOptions.secure =
|
|
72
|
+
!!initConfiguration.useSecureSessionCookie || !!initConfiguration.usePartitionedCrossSiteSessionCookie
|
|
73
|
+
cookieOptions.crossSite = !!initConfiguration.usePartitionedCrossSiteSessionCookie
|
|
74
|
+
cookieOptions.partitioned = !!initConfiguration.usePartitionedCrossSiteSessionCookie
|
|
75
|
+
|
|
76
|
+
if (initConfiguration.trackSessionAcrossSubdomains) {
|
|
77
|
+
const currentSite = getCurrentSite()
|
|
78
|
+
if (!currentSite) {
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
cookieOptions.domain = currentSite
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return cookieOptions
|
|
85
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { generateUUID } from '../../../tools/utils/stringUtils'
|
|
2
|
+
import type { Configuration } from '../../configuration'
|
|
3
|
+
import { SessionPersistence } from '../sessionConstants'
|
|
4
|
+
import type { SessionState } from '../sessionState'
|
|
5
|
+
import { toSessionString, toSessionState, getExpiredSessionState } from '../sessionState'
|
|
6
|
+
import type { SessionStoreStrategy, SessionStoreStrategyType } from './sessionStoreStrategy'
|
|
7
|
+
import { SESSION_STORE_KEY } from './sessionStoreStrategy'
|
|
8
|
+
|
|
9
|
+
const LOCAL_STORAGE_TEST_KEY = '_dd_test_'
|
|
10
|
+
|
|
11
|
+
export function selectLocalStorageStrategy(): SessionStoreStrategyType | undefined {
|
|
12
|
+
try {
|
|
13
|
+
const id = generateUUID()
|
|
14
|
+
const testKey = `${LOCAL_STORAGE_TEST_KEY}${id}`
|
|
15
|
+
localStorage.setItem(testKey, id)
|
|
16
|
+
const retrievedId = localStorage.getItem(testKey)
|
|
17
|
+
localStorage.removeItem(testKey)
|
|
18
|
+
return id === retrievedId ? { type: SessionPersistence.LOCAL_STORAGE } : undefined
|
|
19
|
+
} catch {
|
|
20
|
+
return undefined
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function initLocalStorageStrategy(configuration: Configuration): SessionStoreStrategy {
|
|
25
|
+
return {
|
|
26
|
+
isLockEnabled: false,
|
|
27
|
+
persistSession: persistInLocalStorage,
|
|
28
|
+
retrieveSession: retrieveSessionFromLocalStorage,
|
|
29
|
+
expireSession: (sessionState: SessionState) => expireSessionFromLocalStorage(sessionState, configuration),
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function persistInLocalStorage(sessionState: SessionState) {
|
|
34
|
+
localStorage.setItem(SESSION_STORE_KEY, toSessionString(sessionState))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function retrieveSessionFromLocalStorage(): SessionState {
|
|
38
|
+
const sessionString = localStorage.getItem(SESSION_STORE_KEY)
|
|
39
|
+
return toSessionState(sessionString)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function expireSessionFromLocalStorage(previousSessionState: SessionState, configuration: Configuration) {
|
|
43
|
+
persistInLocalStorage(getExpiredSessionState(previousSessionState, configuration))
|
|
44
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CookieOptions } from '../../../browser/cookie'
|
|
2
|
+
import type { SessionPersistence } from '../sessionConstants'
|
|
3
|
+
import type { SessionState } from '../sessionState'
|
|
4
|
+
|
|
5
|
+
export const SESSION_STORE_KEY = '_dd_s'
|
|
6
|
+
|
|
7
|
+
export type SessionStoreStrategyType =
|
|
8
|
+
| { type: typeof SessionPersistence.COOKIE; cookieOptions: CookieOptions }
|
|
9
|
+
| { type: typeof SessionPersistence.LOCAL_STORAGE }
|
|
10
|
+
|
|
11
|
+
export interface SessionStoreStrategy {
|
|
12
|
+
isLockEnabled: boolean
|
|
13
|
+
persistSession: (session: SessionState) => void
|
|
14
|
+
retrieveSession: () => SessionState
|
|
15
|
+
expireSession: (previousSessionState: SessionState) => void
|
|
16
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getInitCookie } from '../../browser/cookie'
|
|
2
|
+
import { globalObject, isWorkerEnvironment } from '../../tools/globalObject'
|
|
3
|
+
|
|
4
|
+
export const SYNTHETICS_TEST_ID_COOKIE_NAME = 'datadog-synthetics-public-id'
|
|
5
|
+
export const SYNTHETICS_RESULT_ID_COOKIE_NAME = 'datadog-synthetics-result-id'
|
|
6
|
+
export const SYNTHETICS_INJECTS_RUM_COOKIE_NAME = 'datadog-synthetics-injects-rum'
|
|
7
|
+
|
|
8
|
+
export interface BrowserWindow extends Window {
|
|
9
|
+
_DATADOG_SYNTHETICS_PUBLIC_ID?: unknown
|
|
10
|
+
_DATADOG_SYNTHETICS_RESULT_ID?: unknown
|
|
11
|
+
_DATADOG_SYNTHETICS_INJECTS_RUM?: unknown
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function willSyntheticsInjectRum(): boolean {
|
|
15
|
+
if (isWorkerEnvironment) {
|
|
16
|
+
// We don't expect to run synthetics tests in a worker environment
|
|
17
|
+
return false
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return Boolean(
|
|
21
|
+
(globalObject as BrowserWindow)._DATADOG_SYNTHETICS_INJECTS_RUM || getInitCookie(SYNTHETICS_INJECTS_RUM_COOKIE_NAME)
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getSyntheticsTestId(): string | undefined {
|
|
26
|
+
const value = (window as BrowserWindow)._DATADOG_SYNTHETICS_PUBLIC_ID || getInitCookie(SYNTHETICS_TEST_ID_COOKIE_NAME)
|
|
27
|
+
return typeof value === 'string' ? value : undefined
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getSyntheticsResultId(): string | undefined {
|
|
31
|
+
const value =
|
|
32
|
+
(window as BrowserWindow)._DATADOG_SYNTHETICS_RESULT_ID || getInitCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME)
|
|
33
|
+
return typeof value === 'string' ? value : undefined
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isSyntheticsTest(): boolean {
|
|
37
|
+
return Boolean(getSyntheticsTestId() && getSyntheticsResultId())
|
|
38
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { DOCS_ORIGIN, MORE_DETAILS, display } from '../tools/display'
|
|
2
|
+
import type { Configuration } from './configuration'
|
|
3
|
+
|
|
4
|
+
export const TAG_SIZE_LIMIT = 200
|
|
5
|
+
|
|
6
|
+
// replaced at build time
|
|
7
|
+
declare const __BUILD_ENV__SDK_VERSION__: string
|
|
8
|
+
|
|
9
|
+
export function buildTags(configuration: Configuration): string[] {
|
|
10
|
+
const { env, service, version, datacenter, sdkVersion, variant } = configuration
|
|
11
|
+
const tags = [buildTag('sdk_version', sdkVersion ?? __BUILD_ENV__SDK_VERSION__)]
|
|
12
|
+
|
|
13
|
+
if (env) {
|
|
14
|
+
tags.push(buildTag('env', env))
|
|
15
|
+
}
|
|
16
|
+
if (service) {
|
|
17
|
+
tags.push(buildTag('service', service))
|
|
18
|
+
}
|
|
19
|
+
if (version) {
|
|
20
|
+
tags.push(buildTag('version', version))
|
|
21
|
+
}
|
|
22
|
+
if (datacenter) {
|
|
23
|
+
tags.push(buildTag('datacenter', datacenter))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (variant) {
|
|
27
|
+
tags.push(buildTag('variant', variant))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return tags
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function buildTag(key: string, rawValue?: string) {
|
|
34
|
+
// See https://docs.datadoghq.com/getting_started/tagging/#defining-tags for tags syntax. Note
|
|
35
|
+
// that the backend may not follow the exact same rules, so we only want to display an informal
|
|
36
|
+
// warning.
|
|
37
|
+
const tag = rawValue ? `${key}:${rawValue}` : key
|
|
38
|
+
|
|
39
|
+
if (tag.length > TAG_SIZE_LIMIT || hasForbiddenCharacters(tag)) {
|
|
40
|
+
display.warn(
|
|
41
|
+
`Tag ${tag} doesn't meet tag requirements and will be sanitized. ${MORE_DETAILS} ${DOCS_ORIGIN}/getting_started/tagging/#defining-tags`
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Let the backend do most of the sanitization, but still make sure multiple tags can't be crafted
|
|
46
|
+
// by forging a value containing commas.
|
|
47
|
+
return sanitizeTag(tag)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function sanitizeTag(tag: string) {
|
|
51
|
+
return tag.replace(/,/g, '_')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function hasForbiddenCharacters(rawValue: string) {
|
|
55
|
+
// Unicode property escapes is not supported in all browsers, so we use a try/catch.
|
|
56
|
+
// Todo: Remove the try/catch when dropping support for Chrome 63 and Firefox 67
|
|
57
|
+
// see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape#browser_compatibility
|
|
58
|
+
if (!supportUnicodePropertyEscapes()) {
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// We use the Unicode property escapes to match any character that is a letter including other languages like Chinese, Japanese, etc.
|
|
63
|
+
// p{Ll} matches a lowercase letter.
|
|
64
|
+
// p{Lo} matches a letter that is neither uppercase nor lowercase (ex: Japanese characters).
|
|
65
|
+
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape#unicode_property_escapes_vs._character_classes
|
|
66
|
+
return new RegExp('[^\\p{Ll}\\p{Lo}0-9_:./-]', 'u').test(rawValue)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function supportUnicodePropertyEscapes() {
|
|
70
|
+
try {
|
|
71
|
+
new RegExp('[\\p{Ll}]', 'u')
|
|
72
|
+
return true
|
|
73
|
+
} catch {
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type { Telemetry } from './telemetry'
|
|
2
|
+
export {
|
|
3
|
+
TelemetryService,
|
|
4
|
+
TelemetryMetrics,
|
|
5
|
+
addTelemetryDebug,
|
|
6
|
+
addTelemetryError,
|
|
7
|
+
resetTelemetry,
|
|
8
|
+
startTelemetry,
|
|
9
|
+
addTelemetryConfiguration,
|
|
10
|
+
addTelemetryUsage,
|
|
11
|
+
addTelemetryMetrics,
|
|
12
|
+
getTelemetryObservable,
|
|
13
|
+
} from './telemetry'
|
|
14
|
+
|
|
15
|
+
export * from './rawTelemetryEvent.types'
|
|
16
|
+
export type {
|
|
17
|
+
TelemetryEvent,
|
|
18
|
+
TelemetryErrorEvent,
|
|
19
|
+
TelemetryDebugEvent,
|
|
20
|
+
TelemetryConfigurationEvent,
|
|
21
|
+
TelemetryUsageEvent,
|
|
22
|
+
} from './telemetryEvent.types'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TelemetryEvent, TelemetryConfigurationEvent, TelemetryUsageEvent } from './telemetryEvent.types'
|
|
2
|
+
|
|
3
|
+
export const TelemetryType = {
|
|
4
|
+
LOG: 'log',
|
|
5
|
+
CONFIGURATION: 'configuration',
|
|
6
|
+
USAGE: 'usage',
|
|
7
|
+
} as const
|
|
8
|
+
|
|
9
|
+
export const enum StatusType {
|
|
10
|
+
debug = 'debug',
|
|
11
|
+
error = 'error',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface RuntimeEnvInfo {
|
|
15
|
+
is_local_file: boolean
|
|
16
|
+
is_worker: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type RawTelemetryEvent = TelemetryEvent['telemetry']
|
|
20
|
+
export type RawTelemetryConfiguration = TelemetryConfigurationEvent['telemetry']['configuration']
|
|
21
|
+
export type RawTelemetryUsage = TelemetryUsageEvent['telemetry']['usage']
|
|
22
|
+
export type RawTelemetryUsageFeature = TelemetryUsageEvent['telemetry']['usage']['feature']
|