@openobserve/browser-core 0.2.11-rc1 → 0.2.12-beta.1
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/package.json +6 -5
- package/src/boot/displayAlreadyInitializedError.ts +8 -0
- package/src/boot/init.ts +29 -15
- package/src/browser/addEventListener.ts +13 -10
- package/src/browser/{types.ts → browser.types.ts} +42 -0
- package/src/browser/cookie.ts +49 -14
- package/src/browser/fetchObservable.ts +80 -21
- package/src/browser/{pageExitObservable.ts → pageMayExitObservable.ts} +11 -22
- package/src/browser/runOnReadyState.ts +14 -4
- package/src/browser/xhrObservable.ts +17 -4
- package/src/domain/allowedTrackingOrigins.ts +30 -0
- package/src/domain/bufferedData.ts +32 -0
- package/src/domain/configuration/configuration.ts +352 -83
- package/src/domain/configuration/endpointBuilder.ts +29 -32
- package/src/domain/configuration/index.ts +6 -5
- package/src/domain/configuration/transportConfiguration.ts +42 -35
- package/src/domain/connectivity/connectivity.ts +5 -1
- package/src/domain/console/consoleObservable.ts +57 -21
- package/src/domain/context/contextConstants.ts +22 -0
- package/src/domain/context/contextManager.ts +48 -11
- package/src/domain/context/contextUtils.ts +14 -0
- package/src/domain/context/defineContextMethod.ts +31 -0
- package/src/domain/context/storeContextManager.ts +7 -3
- 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/{types.ts → deflate.types.ts} +6 -4
- package/src/domain/deflate/index.ts +1 -1
- package/src/domain/error/error.ts +28 -84
- package/src/domain/error/error.types.ts +10 -2
- package/src/domain/error/trackRuntimeError.ts +29 -32
- package/src/domain/eventRateLimiter/createEventRateLimiter.ts +5 -2
- package/src/domain/extension/extensionUtils.ts +28 -0
- package/src/domain/intakeSites.ts +18 -0
- package/src/domain/report/reportObservable.ts +35 -30
- package/src/domain/resourceUtils.ts +20 -16
- package/src/domain/session/README.md +193 -0
- package/src/domain/session/oldCookiesMigration.ts +2 -2
- package/src/domain/session/sessionConstants.ts +16 -1
- package/src/domain/session/sessionManager.ts +179 -15
- package/src/domain/session/sessionState.ts +49 -17
- package/src/domain/session/sessionStateValidation.ts +9 -0
- package/src/domain/session/sessionStore.ts +118 -55
- package/src/domain/session/sessionStoreOperations.ts +47 -20
- package/src/domain/session/storeStrategies/sessionInCookie.ts +105 -26
- package/src/domain/session/storeStrategies/sessionInLocalStorage.ts +10 -8
- package/src/domain/session/storeStrategies/sessionStoreStrategy.ts +5 -2
- package/src/domain/synthetics/syntheticsWorkerValues.ts +13 -2
- package/src/domain/tags.ts +76 -0
- package/src/domain/telemetry/index.ts +12 -4
- package/src/domain/telemetry/rawTelemetryEvent.types.ts +6 -3
- package/src/domain/telemetry/telemetry.ts +235 -106
- package/src/domain/telemetry/telemetryEvent.types.ts +514 -5
- package/src/domain/trackingConsent.ts +34 -0
- package/src/index.ts +90 -59
- package/src/tools/abstractHooks.ts +72 -0
- package/src/tools/abstractLifeCycle.ts +1 -0
- package/src/tools/boundedBuffer.ts +36 -8
- package/src/tools/display.ts +4 -0
- package/src/tools/encoder.ts +3 -2
- package/src/tools/experimentalFeatures.ts +18 -7
- package/src/tools/getZoneJsOriginalValue.ts +1 -1
- package/src/tools/{getGlobalObject.ts → globalObject.ts} +20 -0
- package/src/tools/instrumentMethod.ts +58 -41
- package/src/tools/matchOption.ts +1 -2
- package/src/tools/monitor.ts +11 -7
- package/src/tools/observable.ts +78 -12
- package/src/tools/queueMicrotask.ts +13 -0
- package/src/tools/readBytesFromStream.ts +24 -64
- package/src/tools/requestIdleCallback.ts +40 -0
- package/src/tools/sendToExtension.ts +3 -1
- package/src/tools/serialisation/context.ts +4 -1
- package/src/tools/serialisation/sanitize.ts +32 -14
- package/src/{domain/error → tools/stackTrace}/computeStackTrace.ts +72 -8
- package/src/tools/stackTrace/handlingStack.ts +48 -0
- package/src/tools/taskQueue.ts +63 -0
- package/src/tools/timer.ts +1 -1
- package/src/tools/utils/arrayUtils.ts +11 -3
- package/src/tools/utils/browserDetection.ts +0 -9
- package/src/tools/utils/byteUtils.ts +13 -2
- package/src/tools/utils/functionUtils.ts +0 -2
- package/src/tools/utils/numberUtils.ts +2 -1
- package/src/tools/utils/objectUtils.ts +1 -3
- package/src/tools/utils/polyfills.ts +6 -107
- package/src/tools/utils/responseUtils.ts +1 -1
- package/src/tools/utils/stringUtils.ts +34 -2
- package/src/tools/utils/timeUtils.ts +18 -13
- package/src/tools/utils/timezone.ts +9 -0
- package/src/tools/utils/urlPolyfill.ts +29 -59
- package/src/tools/valueHistory.ts +66 -35
- package/src/transport/batch.ts +77 -80
- package/src/transport/eventBridge.ts +24 -5
- package/src/transport/flushController.ts +27 -21
- package/src/transport/httpRequest.ts +92 -71
- package/src/transport/index.ts +7 -4
- package/src/transport/sendWithRetryStrategy.ts +55 -36
- package/cjs/boot/init.d.ts +0 -5
- package/cjs/boot/init.js +0 -36
- package/cjs/boot/init.js.map +0 -1
- package/cjs/browser/addEventListener.d.ts +0 -84
- package/cjs/browser/addEventListener.js +0 -94
- package/cjs/browser/addEventListener.js.map +0 -1
- package/cjs/browser/cookie.d.ts +0 -17
- package/cjs/browser/cookie.js +0 -86
- package/cjs/browser/cookie.js.map +0 -1
- package/cjs/browser/fetchObservable.d.ts +0 -23
- package/cjs/browser/fetchObservable.js +0 -69
- package/cjs/browser/fetchObservable.js.map +0 -1
- package/cjs/browser/pageExitObservable.d.ts +0 -14
- package/cjs/browser/pageExitObservable.js +0 -57
- package/cjs/browser/pageExitObservable.js.map +0 -1
- package/cjs/browser/runOnReadyState.d.ts +0 -2
- package/cjs/browser/runOnReadyState.js +0 -15
- package/cjs/browser/runOnReadyState.js.map +0 -1
- package/cjs/browser/types.d.ts +0 -19
- package/cjs/browser/types.js +0 -6
- package/cjs/browser/types.js.map +0 -1
- package/cjs/browser/xhrObservable.d.ts +0 -21
- package/cjs/browser/xhrObservable.js +0 -85
- package/cjs/browser/xhrObservable.js.map +0 -1
- package/cjs/domain/configuration/configuration.d.ts +0 -72
- package/cjs/domain/configuration/configuration.js +0 -94
- package/cjs/domain/configuration/configuration.js.map +0 -1
- package/cjs/domain/configuration/endpointBuilder.d.ts +0 -10
- package/cjs/domain/configuration/endpointBuilder.js +0 -84
- package/cjs/domain/configuration/endpointBuilder.js.map +0 -1
- package/cjs/domain/configuration/index.d.ts +0 -4
- package/cjs/domain/configuration/index.js +0 -27
- package/cjs/domain/configuration/index.js.map +0 -1
- package/cjs/domain/configuration/intakeSites.d.ts +0 -5
- package/cjs/domain/configuration/intakeSites.js +0 -9
- package/cjs/domain/configuration/intakeSites.js.map +0 -1
- package/cjs/domain/configuration/tags.d.ts +0 -4
- package/cjs/domain/configuration/tags.js +0 -39
- package/cjs/domain/configuration/tags.js.map +0 -1
- package/cjs/domain/configuration/transportConfiguration.d.ts +0 -16
- package/cjs/domain/configuration/transportConfiguration.js +0 -42
- package/cjs/domain/configuration/transportConfiguration.js.map +0 -1
- package/cjs/domain/connectivity/connectivity.d.ts +0 -13
- package/cjs/domain/connectivity/connectivity.js +0 -14
- package/cjs/domain/connectivity/connectivity.js.map +0 -1
- package/cjs/domain/connectivity/index.d.ts +0 -1
- package/cjs/domain/connectivity/index.js +0 -18
- package/cjs/domain/connectivity/index.js.map +0 -1
- package/cjs/domain/console/consoleObservable.d.ts +0 -11
- package/cjs/domain/console/consoleObservable.js +0 -72
- package/cjs/domain/console/consoleObservable.js.map +0 -1
- package/cjs/domain/context/contextConstants.d.ts +0 -5
- package/cjs/domain/context/contextConstants.js +0 -3
- package/cjs/domain/context/contextConstants.js.map +0 -1
- package/cjs/domain/context/contextManager.d.ts +0 -12
- package/cjs/domain/context/contextManager.js +0 -43
- package/cjs/domain/context/contextManager.js.map +0 -1
- package/cjs/domain/context/customerDataTracker.d.ts +0 -45
- package/cjs/domain/context/customerDataTracker.js +0 -107
- package/cjs/domain/context/customerDataTracker.js.map +0 -1
- package/cjs/domain/context/storeContextManager.d.ts +0 -6
- package/cjs/domain/context/storeContextManager.js +0 -38
- package/cjs/domain/context/storeContextManager.js.map +0 -1
- package/cjs/domain/deflate/types.d.ts +0 -0
- package/cjs/domain/deflate/types.js +0 -3
- package/cjs/domain/deflate/types.js.map +0 -1
- package/cjs/domain/error/computeStackTrace.d.ts +0 -33
- package/cjs/domain/error/computeStackTrace.js +0 -142
- package/cjs/domain/error/computeStackTrace.js.map +0 -1
- package/cjs/domain/error/error.d.ts +0 -28
- package/cjs/domain/error/error.js +0 -131
- package/cjs/domain/error/error.js.map +0 -1
- package/cjs/domain/error/error.types.d.ts +0 -40
- package/cjs/domain/error/error.types.js +0 -13
- package/cjs/domain/error/error.types.js.map +0 -1
- package/cjs/domain/error/trackRuntimeError.d.ts +0 -13
- package/cjs/domain/error/trackRuntimeError.js +0 -54
- package/cjs/domain/error/trackRuntimeError.js.map +0 -1
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.d.ts +0 -5
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.js +0 -40
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.js.map +0 -1
- package/cjs/domain/report/browser.types.d.ts +0 -34
- package/cjs/domain/report/browser.types.js +0 -3
- package/cjs/domain/report/browser.types.js.map +0 -1
- package/cjs/domain/report/reportObservable.d.ts +0 -17
- package/cjs/domain/report/reportObservable.js +0 -94
- package/cjs/domain/report/reportObservable.js.map +0 -1
- package/cjs/domain/resourceUtils.d.ts +0 -16
- package/cjs/domain/resourceUtils.js +0 -3
- package/cjs/domain/resourceUtils.js.map +0 -1
- package/cjs/domain/session/oldCookiesMigration.d.ts +0 -11
- package/cjs/domain/session/oldCookiesMigration.js +0 -40
- package/cjs/domain/session/oldCookiesMigration.js.map +0 -1
- package/cjs/domain/session/sessionConstants.d.ts +0 -2
- package/cjs/domain/session/sessionConstants.js +0 -7
- package/cjs/domain/session/sessionConstants.js.map +0 -1
- package/cjs/domain/session/sessionManager.d.ts +0 -20
- package/cjs/domain/session/sessionManager.js +0 -65
- package/cjs/domain/session/sessionManager.js.map +0 -1
- package/cjs/domain/session/sessionState.d.ts +0 -11
- package/cjs/domain/session/sessionState.js +0 -45
- package/cjs/domain/session/sessionState.js.map +0 -1
- package/cjs/domain/session/sessionStore.d.ts +0 -34
- package/cjs/domain/session/sessionStore.js +0 -144
- package/cjs/domain/session/sessionStore.js.map +0 -1
- package/cjs/domain/session/sessionStoreOperations.d.ts +0 -10
- package/cjs/domain/session/sessionStoreOperations.js +0 -96
- package/cjs/domain/session/sessionStoreOperations.js.map +0 -1
- package/cjs/domain/session/storeStrategies/sessionInCookie.d.ts +0 -6
- package/cjs/domain/session/storeStrategies/sessionInCookie.js +0 -59
- package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +0 -1
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.d.ts +0 -3
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +0 -41
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js.map +0 -1
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -15
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.js +0 -5
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.js.map +0 -1
- package/cjs/domain/synthetics/syntheticsWorkerValues.d.ts +0 -11
- package/cjs/domain/synthetics/syntheticsWorkerValues.js +0 -22
- package/cjs/domain/synthetics/syntheticsWorkerValues.js.map +0 -1
- package/cjs/domain/telemetry/index.d.ts +0 -3
- package/cjs/domain/telemetry/index.js +0 -28
- package/cjs/domain/telemetry/index.js.map +0 -1
- package/cjs/domain/telemetry/rawTelemetryEvent.types.d.ts +0 -15
- package/cjs/domain/telemetry/rawTelemetryEvent.types.js +0 -8
- package/cjs/domain/telemetry/rawTelemetryEvent.types.js.map +0 -1
- package/cjs/domain/telemetry/telemetry.d.ts +0 -116
- package/cjs/domain/telemetry/telemetry.js +0 -157
- package/cjs/domain/telemetry/telemetry.js.map +0 -1
- package/cjs/domain/telemetry/telemetryEvent.types.d.ts +0 -391
- package/cjs/domain/telemetry/telemetryEvent.types.js +0 -7
- package/cjs/domain/telemetry/telemetryEvent.types.js.map +0 -1
- package/cjs/domain/user/index.d.ts +0 -2
- package/cjs/domain/user/index.js +0 -19
- package/cjs/domain/user/index.js.map +0 -1
- package/cjs/domain/user/user.d.ts +0 -12
- package/cjs/domain/user/user.js +0 -35
- package/cjs/domain/user/user.js.map +0 -1
- package/cjs/domain/user/user.types.d.ts +0 -6
- package/cjs/domain/user/user.types.js +0 -3
- package/cjs/domain/user/user.types.js.map +0 -1
- package/cjs/tools/abstractLifeCycle.d.ts +0 -23
- package/cjs/tools/abstractLifeCycle.js +0 -29
- package/cjs/tools/abstractLifeCycle.js.map +0 -1
- package/cjs/tools/boundedBuffer.d.ts +0 -5
- package/cjs/tools/boundedBuffer.js +0 -22
- package/cjs/tools/boundedBuffer.js.map +0 -1
- package/cjs/tools/catchUserErrors.d.ts +0 -1
- package/cjs/tools/catchUserErrors.js +0 -20
- package/cjs/tools/catchUserErrors.js.map +0 -1
- package/cjs/tools/display.d.ts +0 -35
- package/cjs/tools/display.js +0 -41
- package/cjs/tools/display.js.map +0 -1
- package/cjs/tools/encoder.d.ts +0 -53
- package/cjs/tools/encoder.js +0 -41
- package/cjs/tools/encoder.js.map +0 -1
- package/cjs/tools/experimentalFeatures.d.ts +0 -22
- package/cjs/tools/experimentalFeatures.js +0 -45
- package/cjs/tools/experimentalFeatures.js.map +0 -1
- package/cjs/tools/getGlobalObject.d.ts +0 -4
- package/cjs/tools/getGlobalObject.js +0 -37
- package/cjs/tools/getGlobalObject.js.map +0 -1
- package/cjs/tools/getZoneJsOriginalValue.d.ts +0 -19
- package/cjs/tools/getZoneJsOriginalValue.js +0 -30
- package/cjs/tools/getZoneJsOriginalValue.js.map +0 -1
- package/cjs/tools/instrumentMethod.d.ts +0 -59
- package/cjs/tools/instrumentMethod.js +0 -106
- package/cjs/tools/instrumentMethod.js.map +0 -1
- package/cjs/tools/matchOption.d.ts +0 -8
- package/cjs/tools/matchOption.js +0 -38
- package/cjs/tools/matchOption.js.map +0 -1
- package/cjs/tools/mergeInto.d.ts +0 -25
- package/cjs/tools/mergeInto.js +0 -105
- package/cjs/tools/mergeInto.js.map +0 -1
- package/cjs/tools/monitor.d.ts +0 -8
- package/cjs/tools/monitor.js +0 -76
- package/cjs/tools/monitor.js.map +0 -1
- package/cjs/tools/observable.d.ts +0 -12
- package/cjs/tools/observable.js +0 -43
- package/cjs/tools/observable.js.map +0 -1
- package/cjs/tools/readBytesFromStream.d.ts +0 -11
- package/cjs/tools/readBytesFromStream.js +0 -64
- package/cjs/tools/readBytesFromStream.js.map +0 -1
- package/cjs/tools/sendToExtension.d.ts +0 -3
- package/cjs/tools/sendToExtension.js +0 -11
- package/cjs/tools/sendToExtension.js.map +0 -1
- package/cjs/tools/serialisation/context.d.ts +0 -6
- package/cjs/tools/serialisation/context.js +0 -3
- package/cjs/tools/serialisation/context.js.map +0 -1
- package/cjs/tools/serialisation/jsonStringify.d.ts +0 -13
- package/cjs/tools/serialisation/jsonStringify.js +0 -49
- package/cjs/tools/serialisation/jsonStringify.js.map +0 -1
- package/cjs/tools/serialisation/sanitize.d.ts +0 -18
- package/cjs/tools/serialisation/sanitize.js +0 -185
- package/cjs/tools/serialisation/sanitize.js.map +0 -1
- package/cjs/tools/timer.d.ts +0 -5
- package/cjs/tools/timer.js +0 -23
- package/cjs/tools/timer.js.map +0 -1
- package/cjs/tools/utils/arrayUtils.d.ts +0 -1
- package/cjs/tools/utils/arrayUtils.js +0 -11
- package/cjs/tools/utils/arrayUtils.js.map +0 -1
- package/cjs/tools/utils/browserDetection.d.ts +0 -10
- package/cjs/tools/utils/browserDetection.js +0 -42
- package/cjs/tools/utils/browserDetection.js.map +0 -1
- package/cjs/tools/utils/byteUtils.d.ts +0 -4
- package/cjs/tools/utils/byteUtils.js +0 -31
- package/cjs/tools/utils/byteUtils.js.map +0 -1
- package/cjs/tools/utils/functionUtils.d.ts +0 -9
- package/cjs/tools/utils/functionUtils.js +0 -48
- package/cjs/tools/utils/functionUtils.js.map +0 -1
- package/cjs/tools/utils/numberUtils.d.ts +0 -8
- package/cjs/tools/utils/numberUtils.js +0 -24
- package/cjs/tools/utils/numberUtils.js.map +0 -1
- package/cjs/tools/utils/objectUtils.d.ts +0 -10
- package/cjs/tools/utils/objectUtils.js +0 -26
- package/cjs/tools/utils/objectUtils.js.map +0 -1
- package/cjs/tools/utils/polyfills.d.ts +0 -24
- package/cjs/tools/utils/polyfills.js +0 -110
- package/cjs/tools/utils/polyfills.js.map +0 -1
- package/cjs/tools/utils/responseUtils.d.ts +0 -2
- package/cjs/tools/utils/responseUtils.js +0 -18
- package/cjs/tools/utils/responseUtils.js.map +0 -1
- package/cjs/tools/utils/stringUtils.d.ts +0 -8
- package/cjs/tools/utils/stringUtils.js +0 -59
- package/cjs/tools/utils/stringUtils.js.map +0 -1
- package/cjs/tools/utils/timeUtils.d.ts +0 -57
- package/cjs/tools/utils/timeUtils.js +0 -99
- package/cjs/tools/utils/timeUtils.js.map +0 -1
- package/cjs/tools/utils/typeUtils.d.ts +0 -4
- package/cjs/tools/utils/typeUtils.js +0 -17
- package/cjs/tools/utils/typeUtils.js.map +0 -1
- package/cjs/tools/utils/urlPolyfill.d.ts +0 -14
- package/cjs/tools/utils/urlPolyfill.js +0 -92
- package/cjs/tools/utils/urlPolyfill.js.map +0 -1
- package/cjs/tools/valueHistory.d.ts +0 -50
- package/cjs/tools/valueHistory.js +0 -106
- package/cjs/tools/valueHistory.js.map +0 -1
- package/cjs/transport/batch.d.ts +0 -21
- package/cjs/transport/batch.js +0 -123
- package/cjs/transport/batch.js.map +0 -1
- package/cjs/transport/eventBridge.d.ts +0 -12
- package/cjs/transport/eventBridge.js +0 -34
- package/cjs/transport/eventBridge.js.map +0 -1
- package/cjs/transport/flushController.d.ts +0 -58
- package/cjs/transport/flushController.js +0 -112
- package/cjs/transport/flushController.js.map +0 -1
- package/cjs/transport/httpRequest.d.ts +0 -38
- package/cjs/transport/httpRequest.js +0 -95
- package/cjs/transport/httpRequest.js.map +0 -1
- package/cjs/transport/index.d.ts +0 -4
- package/cjs/transport/index.js +0 -13
- package/cjs/transport/index.js.map +0 -1
- package/cjs/transport/sendWithRetryStrategy.d.ts +0 -39
- package/cjs/transport/sendWithRetryStrategy.js +0 -151
- package/cjs/transport/sendWithRetryStrategy.js.map +0 -1
- package/cjs/transport/startBatchWithReplica.d.ts +0 -20
- package/cjs/transport/startBatchWithReplica.js +0 -42
- package/cjs/transport/startBatchWithReplica.js.map +0 -1
- package/esm/boot/init.d.ts +0 -5
- package/esm/boot/init.js +0 -31
- package/esm/boot/init.js.map +0 -1
- package/esm/browser/addEventListener.d.ts +0 -84
- package/esm/browser/addEventListener.js +0 -89
- package/esm/browser/addEventListener.js.map +0 -1
- package/esm/browser/cookie.d.ts +0 -17
- package/esm/browser/cookie.js +0 -76
- package/esm/browser/cookie.js.map +0 -1
- package/esm/browser/fetchObservable.d.ts +0 -23
- package/esm/browser/fetchObservable.js +0 -65
- package/esm/browser/fetchObservable.js.map +0 -1
- package/esm/browser/pageExitObservable.d.ts +0 -14
- package/esm/browser/pageExitObservable.js +0 -52
- package/esm/browser/pageExitObservable.js.map +0 -1
- package/esm/browser/runOnReadyState.d.ts +0 -2
- package/esm/browser/runOnReadyState.js +0 -11
- package/esm/browser/runOnReadyState.js.map +0 -1
- package/esm/browser/types.d.ts +0 -19
- package/esm/browser/types.js +0 -5
- package/esm/browser/types.js.map +0 -1
- package/esm/browser/xhrObservable.d.ts +0 -21
- package/esm/browser/xhrObservable.js +0 -81
- package/esm/browser/xhrObservable.js.map +0 -1
- package/esm/domain/configuration/configuration.d.ts +0 -72
- package/esm/domain/configuration/configuration.js +0 -89
- package/esm/domain/configuration/configuration.js.map +0 -1
- package/esm/domain/configuration/endpointBuilder.d.ts +0 -10
- package/esm/domain/configuration/endpointBuilder.js +0 -80
- package/esm/domain/configuration/endpointBuilder.js.map +0 -1
- package/esm/domain/configuration/index.d.ts +0 -4
- package/esm/domain/configuration/index.js +0 -5
- package/esm/domain/configuration/index.js.map +0 -1
- package/esm/domain/configuration/intakeSites.d.ts +0 -5
- package/esm/domain/configuration/intakeSites.js +0 -6
- package/esm/domain/configuration/intakeSites.js.map +0 -1
- package/esm/domain/configuration/tags.d.ts +0 -4
- package/esm/domain/configuration/tags.js +0 -34
- package/esm/domain/configuration/tags.js.map +0 -1
- package/esm/domain/configuration/transportConfiguration.d.ts +0 -16
- package/esm/domain/configuration/transportConfiguration.js +0 -38
- package/esm/domain/configuration/transportConfiguration.js.map +0 -1
- package/esm/domain/connectivity/connectivity.d.ts +0 -13
- package/esm/domain/connectivity/connectivity.js +0 -10
- package/esm/domain/connectivity/connectivity.js.map +0 -1
- package/esm/domain/connectivity/index.d.ts +0 -1
- package/esm/domain/connectivity/index.js +0 -2
- package/esm/domain/connectivity/index.js.map +0 -1
- package/esm/domain/console/consoleObservable.d.ts +0 -11
- package/esm/domain/console/consoleObservable.js +0 -67
- package/esm/domain/console/consoleObservable.js.map +0 -1
- package/esm/domain/context/contextConstants.d.ts +0 -5
- package/esm/domain/context/contextConstants.js +0 -2
- package/esm/domain/context/contextConstants.js.map +0 -1
- package/esm/domain/context/contextManager.d.ts +0 -12
- package/esm/domain/context/contextManager.js +0 -39
- package/esm/domain/context/contextManager.js.map +0 -1
- package/esm/domain/context/customerDataTracker.d.ts +0 -45
- package/esm/domain/context/customerDataTracker.js +0 -102
- package/esm/domain/context/customerDataTracker.js.map +0 -1
- package/esm/domain/context/storeContextManager.d.ts +0 -6
- package/esm/domain/context/storeContextManager.js +0 -32
- package/esm/domain/context/storeContextManager.js.map +0 -1
- package/esm/domain/deflate/index.d.ts +0 -1
- package/esm/domain/deflate/index.js +0 -2
- package/esm/domain/deflate/index.js.map +0 -1
- package/esm/domain/deflate/types.d.ts +0 -38
- package/esm/domain/deflate/types.js +0 -2
- package/esm/domain/deflate/types.js.map +0 -1
- package/esm/domain/error/computeStackTrace.d.ts +0 -33
- package/esm/domain/error/computeStackTrace.js +0 -137
- package/esm/domain/error/computeStackTrace.js.map +0 -1
- package/esm/domain/error/error.d.ts +0 -28
- package/esm/domain/error/error.js +0 -121
- package/esm/domain/error/error.js.map +0 -1
- package/esm/domain/error/error.types.d.ts +0 -40
- package/esm/domain/error/error.types.js +0 -10
- package/esm/domain/error/error.types.js.map +0 -1
- package/esm/domain/error/trackRuntimeError.d.ts +0 -13
- package/esm/domain/error/trackRuntimeError.js +0 -48
- package/esm/domain/error/trackRuntimeError.js.map +0 -1
- package/esm/domain/eventRateLimiter/createEventRateLimiter.d.ts +0 -5
- package/esm/domain/eventRateLimiter/createEventRateLimiter.js +0 -36
- package/esm/domain/eventRateLimiter/createEventRateLimiter.js.map +0 -1
- package/esm/domain/report/browser.types.d.ts +0 -34
- package/esm/domain/report/browser.types.js +0 -2
- package/esm/domain/report/browser.types.js.map +0 -1
- package/esm/domain/report/reportObservable.d.ts +0 -17
- package/esm/domain/report/reportObservable.js +0 -90
- package/esm/domain/report/reportObservable.js.map +0 -1
- package/esm/domain/resourceUtils.d.ts +0 -16
- package/esm/domain/resourceUtils.js +0 -2
- package/esm/domain/resourceUtils.js.map +0 -1
- package/esm/domain/session/oldCookiesMigration.d.ts +0 -11
- package/esm/domain/session/oldCookiesMigration.js +0 -36
- package/esm/domain/session/oldCookiesMigration.js.map +0 -1
- package/esm/domain/session/sessionConstants.d.ts +0 -2
- package/esm/domain/session/sessionConstants.js +0 -4
- package/esm/domain/session/sessionConstants.js.map +0 -1
- package/esm/domain/session/sessionManager.d.ts +0 -20
- package/esm/domain/session/sessionManager.js +0 -60
- package/esm/domain/session/sessionManager.js.map +0 -1
- package/esm/domain/session/sessionState.d.ts +0 -11
- package/esm/domain/session/sessionState.js +0 -38
- package/esm/domain/session/sessionState.js.map +0 -1
- package/esm/domain/session/sessionStore.d.ts +0 -34
- package/esm/domain/session/sessionStore.js +0 -139
- package/esm/domain/session/sessionStore.js.map +0 -1
- package/esm/domain/session/sessionStoreOperations.d.ts +0 -10
- package/esm/domain/session/sessionStoreOperations.js +0 -92
- package/esm/domain/session/sessionStoreOperations.js.map +0 -1
- package/esm/domain/session/storeStrategies/sessionInCookie.d.ts +0 -6
- package/esm/domain/session/storeStrategies/sessionInCookie.js +0 -53
- package/esm/domain/session/storeStrategies/sessionInCookie.js.map +0 -1
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.d.ts +0 -3
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +0 -36
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +0 -1
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -15
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.js +0 -2
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.js.map +0 -1
- package/esm/domain/synthetics/syntheticsWorkerValues.d.ts +0 -11
- package/esm/domain/synthetics/syntheticsWorkerValues.js +0 -16
- package/esm/domain/synthetics/syntheticsWorkerValues.js.map +0 -1
- package/esm/domain/telemetry/index.d.ts +0 -3
- package/esm/domain/telemetry/index.js +0 -4
- package/esm/domain/telemetry/index.js.map +0 -1
- package/esm/domain/telemetry/rawTelemetryEvent.types.d.ts +0 -15
- package/esm/domain/telemetry/rawTelemetryEvent.types.js +0 -5
- package/esm/domain/telemetry/rawTelemetryEvent.types.js.map +0 -1
- package/esm/domain/telemetry/telemetry.d.ts +0 -116
- package/esm/domain/telemetry/telemetry.js +0 -145
- package/esm/domain/telemetry/telemetry.js.map +0 -1
- package/esm/domain/telemetry/telemetryEvent.types.d.ts +0 -391
- package/esm/domain/telemetry/telemetryEvent.types.js +0 -6
- package/esm/domain/telemetry/telemetryEvent.types.js.map +0 -1
- package/esm/domain/user/index.d.ts +0 -2
- package/esm/domain/user/index.js +0 -3
- package/esm/domain/user/index.js.map +0 -1
- package/esm/domain/user/user.d.ts +0 -12
- package/esm/domain/user/user.js +0 -30
- package/esm/domain/user/user.js.map +0 -1
- package/esm/domain/user/user.types.d.ts +0 -6
- package/esm/domain/user/user.types.js +0 -2
- package/esm/domain/user/user.types.js.map +0 -1
- package/esm/index.d.ts +0 -67
- package/esm/index.js +0 -64
- package/esm/index.js.map +0 -1
- package/esm/tools/abstractLifeCycle.d.ts +0 -23
- package/esm/tools/abstractLifeCycle.js +0 -26
- package/esm/tools/abstractLifeCycle.js.map +0 -1
- package/esm/tools/boundedBuffer.d.ts +0 -5
- package/esm/tools/boundedBuffer.js +0 -19
- package/esm/tools/boundedBuffer.js.map +0 -1
- package/esm/tools/catchUserErrors.d.ts +0 -1
- package/esm/tools/catchUserErrors.js +0 -16
- package/esm/tools/catchUserErrors.js.map +0 -1
- package/esm/tools/display.d.ts +0 -35
- package/esm/tools/display.js +0 -38
- package/esm/tools/display.js.map +0 -1
- package/esm/tools/encoder.d.ts +0 -53
- package/esm/tools/encoder.js +0 -37
- package/esm/tools/encoder.js.map +0 -1
- package/esm/tools/experimentalFeatures.d.ts +0 -22
- package/esm/tools/experimentalFeatures.js +0 -38
- package/esm/tools/experimentalFeatures.js.map +0 -1
- package/esm/tools/getGlobalObject.d.ts +0 -4
- package/esm/tools/getGlobalObject.js +0 -33
- package/esm/tools/getGlobalObject.js.map +0 -1
- package/esm/tools/getZoneJsOriginalValue.d.ts +0 -19
- package/esm/tools/getZoneJsOriginalValue.js +0 -26
- package/esm/tools/getZoneJsOriginalValue.js.map +0 -1
- package/esm/tools/instrumentMethod.d.ts +0 -59
- package/esm/tools/instrumentMethod.js +0 -101
- package/esm/tools/instrumentMethod.js.map +0 -1
- package/esm/tools/matchOption.d.ts +0 -8
- package/esm/tools/matchOption.js +0 -33
- package/esm/tools/matchOption.js.map +0 -1
- package/esm/tools/mergeInto.d.ts +0 -25
- package/esm/tools/mergeInto.js +0 -99
- package/esm/tools/mergeInto.js.map +0 -1
- package/esm/tools/monitor.d.ts +0 -8
- package/esm/tools/monitor.js +0 -66
- package/esm/tools/monitor.js.map +0 -1
- package/esm/tools/observable.d.ts +0 -12
- package/esm/tools/observable.js +0 -39
- package/esm/tools/observable.js.map +0 -1
- package/esm/tools/readBytesFromStream.d.ts +0 -11
- package/esm/tools/readBytesFromStream.js +0 -60
- package/esm/tools/readBytesFromStream.js.map +0 -1
- package/esm/tools/sendToExtension.d.ts +0 -3
- package/esm/tools/sendToExtension.js +0 -7
- package/esm/tools/sendToExtension.js.map +0 -1
- package/esm/tools/serialisation/context.d.ts +0 -6
- package/esm/tools/serialisation/context.js +0 -2
- package/esm/tools/serialisation/context.js.map +0 -1
- package/esm/tools/serialisation/jsonStringify.d.ts +0 -13
- package/esm/tools/serialisation/jsonStringify.js +0 -44
- package/esm/tools/serialisation/jsonStringify.js.map +0 -1
- package/esm/tools/serialisation/sanitize.d.ts +0 -18
- package/esm/tools/serialisation/sanitize.js +0 -181
- package/esm/tools/serialisation/sanitize.js.map +0 -1
- package/esm/tools/timer.d.ts +0 -5
- package/esm/tools/timer.js +0 -16
- package/esm/tools/timer.js.map +0 -1
- package/esm/tools/utils/arrayUtils.d.ts +0 -1
- package/esm/tools/utils/arrayUtils.js +0 -7
- package/esm/tools/utils/arrayUtils.js.map +0 -1
- package/esm/tools/utils/browserDetection.d.ts +0 -10
- package/esm/tools/utils/browserDetection.js +0 -35
- package/esm/tools/utils/browserDetection.js.map +0 -1
- package/esm/tools/utils/byteUtils.d.ts +0 -4
- package/esm/tools/utils/byteUtils.js +0 -26
- package/esm/tools/utils/byteUtils.js.map +0 -1
- package/esm/tools/utils/functionUtils.d.ts +0 -9
- package/esm/tools/utils/functionUtils.js +0 -43
- package/esm/tools/utils/functionUtils.js.map +0 -1
- package/esm/tools/utils/numberUtils.d.ts +0 -8
- package/esm/tools/utils/numberUtils.js +0 -17
- package/esm/tools/utils/numberUtils.js.map +0 -1
- package/esm/tools/utils/objectUtils.d.ts +0 -10
- package/esm/tools/utils/objectUtils.js +0 -19
- package/esm/tools/utils/objectUtils.js.map +0 -1
- package/esm/tools/utils/polyfills.d.ts +0 -24
- package/esm/tools/utils/polyfills.js +0 -95
- package/esm/tools/utils/polyfills.js.map +0 -1
- package/esm/tools/utils/responseUtils.d.ts +0 -2
- package/esm/tools/utils/responseUtils.js +0 -13
- package/esm/tools/utils/responseUtils.js.map +0 -1
- package/esm/tools/utils/stringUtils.d.ts +0 -8
- package/esm/tools/utils/stringUtils.js +0 -52
- package/esm/tools/utils/stringUtils.js.map +0 -1
- package/esm/tools/utils/timeUtils.d.ts +0 -57
- package/esm/tools/utils/timeUtils.js +0 -82
- package/esm/tools/utils/timeUtils.js.map +0 -1
- package/esm/tools/utils/typeUtils.d.ts +0 -4
- package/esm/tools/utils/typeUtils.js +0 -13
- package/esm/tools/utils/typeUtils.js.map +0 -1
- package/esm/tools/utils/urlPolyfill.d.ts +0 -14
- package/esm/tools/utils/urlPolyfill.js +0 -80
- package/esm/tools/utils/urlPolyfill.js.map +0 -1
- package/esm/tools/valueHistory.d.ts +0 -50
- package/esm/tools/valueHistory.js +0 -103
- package/esm/tools/valueHistory.js.map +0 -1
- package/esm/transport/batch.d.ts +0 -21
- package/esm/transport/batch.js +0 -120
- package/esm/transport/batch.js.map +0 -1
- package/esm/transport/eventBridge.d.ts +0 -12
- package/esm/transport/eventBridge.js +0 -29
- package/esm/transport/eventBridge.js.map +0 -1
- package/esm/transport/flushController.d.ts +0 -58
- package/esm/transport/flushController.js +0 -108
- package/esm/transport/flushController.js.map +0 -1
- package/esm/transport/httpRequest.d.ts +0 -38
- package/esm/transport/httpRequest.js +0 -89
- package/esm/transport/httpRequest.js.map +0 -1
- package/esm/transport/index.d.ts +0 -4
- package/esm/transport/index.js +0 -5
- package/esm/transport/index.js.map +0 -1
- package/esm/transport/sendWithRetryStrategy.d.ts +0 -39
- package/esm/transport/sendWithRetryStrategy.js +0 -146
- package/esm/transport/sendWithRetryStrategy.js.map +0 -1
- package/esm/transport/startBatchWithReplica.d.ts +0 -20
- package/esm/transport/startBatchWithReplica.js +0 -38
- package/esm/transport/startBatchWithReplica.js.map +0 -1
- package/src/domain/configuration/intakeSites.ts +0 -5
- package/src/domain/configuration/tags.ts +0 -43
- package/src/domain/context/customerDataTracker.ts +0 -134
- package/src/domain/user/index.ts +0 -2
- package/src/domain/user/user.ts +0 -33
- package/src/domain/user/user.types.ts +0 -6
- package/src/transport/startBatchWithReplica.ts +0 -68
|
@@ -3,22 +3,32 @@ import { Observable } from '../../tools/observable'
|
|
|
3
3
|
import { ONE_SECOND, dateNow } from '../../tools/utils/timeUtils'
|
|
4
4
|
import { throttle } from '../../tools/utils/functionUtils'
|
|
5
5
|
import { generateUUID } from '../../tools/utils/stringUtils'
|
|
6
|
-
import type { InitConfiguration } from '../configuration'
|
|
7
|
-
import {
|
|
6
|
+
import type { InitConfiguration, Configuration } from '../configuration'
|
|
7
|
+
import { display } from '../../tools/display'
|
|
8
8
|
import { selectCookieStrategy, initCookieStrategy } from './storeStrategies/sessionInCookie'
|
|
9
|
-
import type { SessionStoreStrategyType } from './storeStrategies/sessionStoreStrategy'
|
|
9
|
+
import type { SessionStoreStrategy, SessionStoreStrategyType } from './storeStrategies/sessionStoreStrategy'
|
|
10
10
|
import type { SessionState } from './sessionState'
|
|
11
|
+
import {
|
|
12
|
+
getExpiredSessionState,
|
|
13
|
+
isSessionInExpiredState,
|
|
14
|
+
isSessionInNotStartedState,
|
|
15
|
+
isSessionStarted,
|
|
16
|
+
} from './sessionState'
|
|
11
17
|
import { initLocalStorageStrategy, selectLocalStorageStrategy } from './storeStrategies/sessionInLocalStorage'
|
|
12
18
|
import { processSessionStoreOperations } from './sessionStoreOperations'
|
|
19
|
+
import { SESSION_NOT_TRACKED, SessionPersistence } from './sessionConstants'
|
|
13
20
|
|
|
14
21
|
export interface SessionStore {
|
|
15
22
|
expandOrRenewSession: () => void
|
|
16
23
|
expandSession: () => void
|
|
17
24
|
getSession: () => SessionState
|
|
25
|
+
restartSession: () => void
|
|
18
26
|
renewObservable: Observable<void>
|
|
19
27
|
expireObservable: Observable<void>
|
|
20
|
-
|
|
28
|
+
sessionStateUpdateObservable: Observable<{ previousState: SessionState; newState: SessionState }>
|
|
29
|
+
expire: (hasConsent?: boolean) => void
|
|
21
30
|
stop: () => void
|
|
31
|
+
updateSessionState: (state: Partial<SessionState>) => void
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
/**
|
|
@@ -29,17 +39,39 @@ export interface SessionStore {
|
|
|
29
39
|
export const STORAGE_POLL_DELAY = ONE_SECOND
|
|
30
40
|
|
|
31
41
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
42
|
+
* Selects the correct session store strategy type based on the configuration and storage
|
|
43
|
+
* availability.
|
|
34
44
|
*/
|
|
35
45
|
export function selectSessionStoreStrategyType(
|
|
36
46
|
initConfiguration: InitConfiguration
|
|
37
47
|
): SessionStoreStrategyType | undefined {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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)}'`)
|
|
41
65
|
}
|
|
42
|
-
|
|
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)
|
|
43
75
|
}
|
|
44
76
|
|
|
45
77
|
/**
|
|
@@ -50,32 +82,34 @@ export function selectSessionStoreStrategyType(
|
|
|
50
82
|
*/
|
|
51
83
|
export function startSessionStore<TrackingType extends string>(
|
|
52
84
|
sessionStoreStrategyType: SessionStoreStrategyType,
|
|
85
|
+
configuration: Configuration,
|
|
53
86
|
productKey: string,
|
|
54
|
-
|
|
87
|
+
computeTrackingType: (rawTrackingType?: string) => TrackingType,
|
|
88
|
+
sessionStoreStrategy: SessionStoreStrategy = getSessionStoreStrategy(sessionStoreStrategyType, configuration)
|
|
55
89
|
): SessionStore {
|
|
56
90
|
const renewObservable = new Observable<void>()
|
|
57
91
|
const expireObservable = new Observable<void>()
|
|
58
|
-
|
|
59
|
-
const sessionStoreStrategy =
|
|
60
|
-
sessionStoreStrategyType.type === 'Cookie'
|
|
61
|
-
? initCookieStrategy(sessionStoreStrategyType.cookieOptions)
|
|
62
|
-
: initLocalStorageStrategy()
|
|
63
|
-
const { clearSession, retrieveSession } = sessionStoreStrategy
|
|
92
|
+
const sessionStateUpdateObservable = new Observable<{ previousState: SessionState; newState: SessionState }>()
|
|
64
93
|
|
|
65
94
|
const watchSessionTimeoutId = setInterval(watchSession, STORAGE_POLL_DELAY)
|
|
66
|
-
let sessionCache: SessionState
|
|
95
|
+
let sessionCache: SessionState
|
|
67
96
|
|
|
68
|
-
|
|
69
|
-
|
|
97
|
+
startSession()
|
|
98
|
+
|
|
99
|
+
const { throttled: throttledExpandOrRenewSession, cancel: cancelExpandOrRenewSession } = throttle(() => {
|
|
70
100
|
processSessionStoreOperations(
|
|
71
101
|
{
|
|
72
102
|
process: (sessionState) => {
|
|
103
|
+
if (isSessionInNotStartedState(sessionState)) {
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
73
107
|
const synchronizedSession = synchronizeSession(sessionState)
|
|
74
|
-
|
|
108
|
+
expandOrRenewSessionState(synchronizedSession)
|
|
75
109
|
return synchronizedSession
|
|
76
110
|
},
|
|
77
111
|
after: (sessionState) => {
|
|
78
|
-
if (
|
|
112
|
+
if (isSessionStarted(sessionState) && !hasSessionInCache()) {
|
|
79
113
|
renewSessionInCache(sessionState)
|
|
80
114
|
}
|
|
81
115
|
sessionCache = sessionState
|
|
@@ -83,7 +117,7 @@ export function startSessionStore<TrackingType extends string>(
|
|
|
83
117
|
},
|
|
84
118
|
sessionStoreStrategy
|
|
85
119
|
)
|
|
86
|
-
}
|
|
120
|
+
}, STORAGE_POLL_DELAY)
|
|
87
121
|
|
|
88
122
|
function expandSession() {
|
|
89
123
|
processSessionStoreOperations(
|
|
@@ -100,41 +134,70 @@ export function startSessionStore<TrackingType extends string>(
|
|
|
100
134
|
* - if the session is not active, clear the session store and expire the session cache
|
|
101
135
|
*/
|
|
102
136
|
function watchSession() {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
+
}
|
|
110
151
|
}
|
|
111
152
|
|
|
112
153
|
function synchronizeSession(sessionState: SessionState) {
|
|
113
|
-
if (
|
|
114
|
-
sessionState =
|
|
154
|
+
if (isSessionInExpiredState(sessionState)) {
|
|
155
|
+
sessionState = getExpiredSessionState(sessionState, configuration)
|
|
115
156
|
}
|
|
116
157
|
if (hasSessionInCache()) {
|
|
117
158
|
if (isSessionInCacheOutdated(sessionState)) {
|
|
118
159
|
expireSessionInCache()
|
|
119
160
|
} else {
|
|
161
|
+
sessionStateUpdateObservable.notify({ previousState: sessionCache, newState: sessionState })
|
|
120
162
|
sessionCache = sessionState
|
|
121
163
|
}
|
|
122
164
|
}
|
|
123
165
|
return sessionState
|
|
124
166
|
}
|
|
125
167
|
|
|
168
|
+
function startSession() {
|
|
169
|
+
processSessionStoreOperations(
|
|
170
|
+
{
|
|
171
|
+
process: (sessionState) => {
|
|
172
|
+
if (isSessionInNotStartedState(sessionState)) {
|
|
173
|
+
sessionState.anonymousId = generateUUID()
|
|
174
|
+
return getExpiredSessionState(sessionState, configuration)
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
after: (sessionState) => {
|
|
178
|
+
sessionCache = sessionState
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
sessionStoreStrategy
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
126
185
|
function expandOrRenewSessionState(sessionState: SessionState) {
|
|
127
|
-
|
|
186
|
+
if (isSessionInNotStartedState(sessionState)) {
|
|
187
|
+
return false
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const trackingType = computeTrackingType(sessionState[productKey])
|
|
128
191
|
sessionState[productKey] = trackingType
|
|
129
|
-
|
|
192
|
+
delete sessionState.isExpired
|
|
193
|
+
if (trackingType !== SESSION_NOT_TRACKED && !sessionState.id) {
|
|
130
194
|
sessionState.id = generateUUID()
|
|
131
195
|
sessionState.created = String(dateNow())
|
|
132
196
|
}
|
|
133
|
-
return isTracked
|
|
134
197
|
}
|
|
135
198
|
|
|
136
199
|
function hasSessionInCache() {
|
|
137
|
-
return sessionCache[productKey] !== undefined
|
|
200
|
+
return sessionCache?.[productKey] !== undefined
|
|
138
201
|
}
|
|
139
202
|
|
|
140
203
|
function isSessionInCacheOutdated(sessionState: SessionState) {
|
|
@@ -142,7 +205,7 @@ export function startSessionStore<TrackingType extends string>(
|
|
|
142
205
|
}
|
|
143
206
|
|
|
144
207
|
function expireSessionInCache() {
|
|
145
|
-
sessionCache =
|
|
208
|
+
sessionCache = getExpiredSessionState(sessionCache, configuration)
|
|
146
209
|
expireObservable.notify()
|
|
147
210
|
}
|
|
148
211
|
|
|
@@ -151,35 +214,35 @@ export function startSessionStore<TrackingType extends string>(
|
|
|
151
214
|
renewObservable.notify()
|
|
152
215
|
}
|
|
153
216
|
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
function isActiveSession(sessionState: SessionState) {
|
|
163
|
-
// created and expire can be undefined for versions which was not storing them
|
|
164
|
-
// these checks could be removed when older versions will not be available/live anymore
|
|
165
|
-
return (
|
|
166
|
-
(sessionState.created === undefined || dateNow() - Number(sessionState.created) < SESSION_TIME_OUT_DELAY) &&
|
|
167
|
-
(sessionState.expire === undefined || dateNow() < Number(sessionState.expire))
|
|
217
|
+
function updateSessionState(partialSessionState: Partial<SessionState>) {
|
|
218
|
+
processSessionStoreOperations(
|
|
219
|
+
{
|
|
220
|
+
process: (sessionState) => ({ ...sessionState, ...partialSessionState }),
|
|
221
|
+
after: synchronizeSession,
|
|
222
|
+
},
|
|
223
|
+
sessionStoreStrategy
|
|
168
224
|
)
|
|
169
225
|
}
|
|
170
226
|
|
|
171
227
|
return {
|
|
172
|
-
expandOrRenewSession:
|
|
228
|
+
expandOrRenewSession: throttledExpandOrRenewSession,
|
|
173
229
|
expandSession,
|
|
174
230
|
getSession: () => sessionCache,
|
|
175
231
|
renewObservable,
|
|
176
232
|
expireObservable,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
233
|
+
sessionStateUpdateObservable,
|
|
234
|
+
restartSession: startSession,
|
|
235
|
+
expire: (hasConsent?: boolean) => {
|
|
236
|
+
cancelExpandOrRenewSession()
|
|
237
|
+
if (hasConsent === false && sessionCache) {
|
|
238
|
+
delete sessionCache.anonymousId
|
|
239
|
+
}
|
|
240
|
+
sessionStoreStrategy.expireSession(sessionCache)
|
|
241
|
+
synchronizeSession(getExpiredSessionState(sessionCache, configuration))
|
|
180
242
|
},
|
|
181
243
|
stop: () => {
|
|
182
244
|
clearInterval(watchSessionTimeoutId)
|
|
183
245
|
},
|
|
246
|
+
updateSessionState,
|
|
184
247
|
}
|
|
185
248
|
}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { setTimeout } from '../../tools/timer'
|
|
2
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'
|
|
3
5
|
import type { SessionStoreStrategy } from './storeStrategies/sessionStoreStrategy'
|
|
4
6
|
import type { SessionState } from './sessionState'
|
|
5
7
|
import { expandSessionState, isSessionInExpiredState } from './sessionState'
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
interface Operations {
|
|
8
10
|
process: (sessionState: SessionState) => SessionState | undefined
|
|
9
11
|
after?: (sessionState: SessionState) => void
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export const LOCK_RETRY_DELAY = 10
|
|
13
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
|
+
|
|
14
22
|
const bufferedOperations: Operations[] = []
|
|
15
23
|
let ongoingOperations: Operations | undefined
|
|
16
24
|
|
|
@@ -19,7 +27,15 @@ export function processSessionStoreOperations(
|
|
|
19
27
|
sessionStoreStrategy: SessionStoreStrategy,
|
|
20
28
|
numberOfRetries = 0
|
|
21
29
|
) {
|
|
22
|
-
const { isLockEnabled,
|
|
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
|
+
}
|
|
23
39
|
|
|
24
40
|
if (!ongoingOperations) {
|
|
25
41
|
ongoingOperations = operations
|
|
@@ -33,39 +49,42 @@ export function processSessionStoreOperations(
|
|
|
33
49
|
return
|
|
34
50
|
}
|
|
35
51
|
let currentLock: string
|
|
36
|
-
let
|
|
52
|
+
let currentStore = retrieveStore()
|
|
37
53
|
if (isLockEnabled) {
|
|
38
54
|
// if someone has lock, retry later
|
|
39
|
-
if (
|
|
55
|
+
if (currentStore.lock) {
|
|
40
56
|
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
41
57
|
return
|
|
42
58
|
}
|
|
43
59
|
// acquire lock
|
|
44
|
-
currentLock =
|
|
45
|
-
|
|
46
|
-
persistSession(currentSession)
|
|
60
|
+
currentLock = createLock()
|
|
61
|
+
persistWithLock(currentStore.session)
|
|
47
62
|
// if lock is not acquired, retry later
|
|
48
|
-
|
|
49
|
-
if (
|
|
63
|
+
currentStore = retrieveStore()
|
|
64
|
+
if (currentStore.lock !== currentLock) {
|
|
50
65
|
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
51
66
|
return
|
|
52
67
|
}
|
|
53
68
|
}
|
|
54
|
-
let processedSession = operations.process(
|
|
69
|
+
let processedSession = operations.process(currentStore.session)
|
|
55
70
|
if (isLockEnabled) {
|
|
56
71
|
// if lock corrupted after process, retry later
|
|
57
|
-
|
|
58
|
-
if (
|
|
72
|
+
currentStore = retrieveStore()
|
|
73
|
+
if (currentStore.lock !== currentLock!) {
|
|
59
74
|
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
60
75
|
return
|
|
61
76
|
}
|
|
62
77
|
}
|
|
63
78
|
if (processedSession) {
|
|
64
79
|
if (isSessionInExpiredState(processedSession)) {
|
|
65
|
-
|
|
80
|
+
expireSession(processedSession)
|
|
66
81
|
} else {
|
|
67
82
|
expandSessionState(processedSession)
|
|
68
|
-
|
|
83
|
+
if (isLockEnabled) {
|
|
84
|
+
persistWithLock(processedSession)
|
|
85
|
+
} else {
|
|
86
|
+
persistSession(processedSession)
|
|
87
|
+
}
|
|
69
88
|
}
|
|
70
89
|
}
|
|
71
90
|
if (isLockEnabled) {
|
|
@@ -73,19 +92,18 @@ export function processSessionStoreOperations(
|
|
|
73
92
|
// since we don't have evidence of lock issues around expiration, let's just not do the corruption check for it
|
|
74
93
|
if (!(processedSession && isSessionInExpiredState(processedSession))) {
|
|
75
94
|
// if lock corrupted after persist, retry later
|
|
76
|
-
|
|
77
|
-
if (
|
|
95
|
+
currentStore = retrieveStore()
|
|
96
|
+
if (currentStore.lock !== currentLock!) {
|
|
78
97
|
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
79
98
|
return
|
|
80
99
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
processedSession = currentSession
|
|
100
|
+
persistSession(currentStore.session)
|
|
101
|
+
processedSession = currentStore.session
|
|
84
102
|
}
|
|
85
103
|
}
|
|
86
104
|
// call after even if session is not persisted in order to perform operations on
|
|
87
105
|
// up-to-date session state value => the value could have been modified by another tab
|
|
88
|
-
operations.after?.(processedSession ||
|
|
106
|
+
operations.after?.(processedSession || currentStore.session)
|
|
89
107
|
next(sessionStoreStrategy)
|
|
90
108
|
}
|
|
91
109
|
|
|
@@ -102,3 +120,12 @@ function next(sessionStore: SessionStoreStrategy) {
|
|
|
102
120
|
processSessionStoreOperations(nextOperations, sessionStore)
|
|
103
121
|
}
|
|
104
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
|
+
}
|
|
@@ -1,29 +1,46 @@
|
|
|
1
|
+
import { isEmptyObject } from '../../../tools/utils/objectUtils'
|
|
1
2
|
import { isChromium } from '../../../tools/utils/browserDetection'
|
|
2
3
|
import type { CookieOptions } from '../../../browser/cookie'
|
|
3
|
-
import { getCurrentSite, areCookiesAuthorized,
|
|
4
|
-
import type { InitConfiguration } from '../../configuration'
|
|
4
|
+
import { getCurrentSite, areCookiesAuthorized, getCookies, setCookie, getCookie } from '../../../browser/cookie'
|
|
5
|
+
import type { InitConfiguration, Configuration } from '../../configuration'
|
|
5
6
|
import { tryOldCookiesMigration } from '../oldCookiesMigration'
|
|
6
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
SESSION_COOKIE_EXPIRATION_DELAY,
|
|
9
|
+
SESSION_EXPIRATION_DELAY,
|
|
10
|
+
SESSION_TIME_OUT_DELAY,
|
|
11
|
+
SessionPersistence,
|
|
12
|
+
} from '../sessionConstants'
|
|
7
13
|
import type { SessionState } from '../sessionState'
|
|
8
|
-
import { toSessionString, toSessionState } from '../sessionState'
|
|
14
|
+
import { toSessionString, toSessionState, getExpiredSessionState } from '../sessionState'
|
|
9
15
|
import type { SessionStoreStrategy, SessionStoreStrategyType } from './sessionStoreStrategy'
|
|
10
16
|
import { SESSION_STORE_KEY } from './sessionStoreStrategy'
|
|
11
17
|
|
|
18
|
+
const SESSION_COOKIE_VERSION = 0
|
|
19
|
+
|
|
12
20
|
export function selectCookieStrategy(initConfiguration: InitConfiguration): SessionStoreStrategyType | undefined {
|
|
13
21
|
const cookieOptions = buildCookieOptions(initConfiguration)
|
|
14
|
-
return areCookiesAuthorized(cookieOptions)
|
|
22
|
+
return cookieOptions && areCookiesAuthorized(cookieOptions)
|
|
23
|
+
? { type: SessionPersistence.COOKIE, cookieOptions }
|
|
24
|
+
: undefined
|
|
15
25
|
}
|
|
16
26
|
|
|
17
|
-
export function initCookieStrategy(cookieOptions: CookieOptions): SessionStoreStrategy {
|
|
27
|
+
export function initCookieStrategy(configuration: Configuration, cookieOptions: CookieOptions): SessionStoreStrategy {
|
|
18
28
|
const cookieStore = {
|
|
19
29
|
/**
|
|
20
30
|
* Lock strategy allows mitigating issues due to concurrent access to cookie.
|
|
21
31
|
* This issue concerns only chromium browsers and enabling this on firefox increases cookie write failures.
|
|
22
32
|
*/
|
|
23
33
|
isLockEnabled: isChromium(),
|
|
24
|
-
persistSession:
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
persistSession: (sessionState: SessionState) =>
|
|
35
|
+
storeSessionCookie(cookieOptions, configuration, sessionState, SESSION_EXPIRATION_DELAY),
|
|
36
|
+
retrieveSession: () => retrieveSessionCookie(cookieOptions, configuration),
|
|
37
|
+
expireSession: (sessionState: SessionState) =>
|
|
38
|
+
storeSessionCookie(
|
|
39
|
+
cookieOptions,
|
|
40
|
+
configuration,
|
|
41
|
+
getExpiredSessionState(sessionState, configuration),
|
|
42
|
+
SESSION_TIME_OUT_DELAY
|
|
43
|
+
),
|
|
27
44
|
}
|
|
28
45
|
|
|
29
46
|
tryOldCookiesMigration(cookieStore)
|
|
@@ -31,37 +48,99 @@ export function initCookieStrategy(cookieOptions: CookieOptions): SessionStoreSt
|
|
|
31
48
|
return cookieStore
|
|
32
49
|
}
|
|
33
50
|
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
51
|
+
function storeSessionCookie(
|
|
52
|
+
options: CookieOptions,
|
|
53
|
+
configuration: Configuration,
|
|
54
|
+
sessionState: SessionState,
|
|
55
|
+
defaultTimeout: number
|
|
56
|
+
) {
|
|
57
|
+
let sessionStateString = toSessionString(sessionState)
|
|
58
|
+
|
|
59
|
+
if (configuration.betaEncodeCookieOptions) {
|
|
60
|
+
sessionStateString = toSessionString({
|
|
61
|
+
...sessionState,
|
|
62
|
+
// deleting a cookie is writing a new cookie with an empty value
|
|
63
|
+
// we don't want to store the cookie options in this case otherwise the cookie will not be deleted
|
|
64
|
+
...(!isEmptyObject(sessionState) ? { c: encodeCookieOptions(options) } : {}),
|
|
65
|
+
})
|
|
37
66
|
}
|
|
38
|
-
}
|
|
39
67
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
68
|
+
setCookie(
|
|
69
|
+
SESSION_STORE_KEY,
|
|
70
|
+
sessionStateString,
|
|
71
|
+
configuration.trackAnonymousUser ? SESSION_COOKIE_EXPIRATION_DELAY : defaultTimeout,
|
|
72
|
+
options
|
|
73
|
+
)
|
|
43
74
|
}
|
|
44
75
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Retrieve the session state from the cookie that was set with the same cookie options
|
|
78
|
+
* If there is no match, return the first cookie, because that's how `getCookie()` works
|
|
79
|
+
*/
|
|
80
|
+
export function retrieveSessionCookie(cookieOptions: CookieOptions, configuration: Configuration): SessionState {
|
|
81
|
+
if (configuration.betaEncodeCookieOptions) {
|
|
82
|
+
return retrieveSessionCookieFromEncodedCookie(cookieOptions)
|
|
48
83
|
}
|
|
84
|
+
|
|
85
|
+
const sessionString = getCookie(SESSION_STORE_KEY)
|
|
86
|
+
const sessionState = toSessionState(sessionString)
|
|
87
|
+
return sessionState
|
|
49
88
|
}
|
|
50
89
|
|
|
51
|
-
export function buildCookieOptions(initConfiguration: InitConfiguration) {
|
|
90
|
+
export function buildCookieOptions(initConfiguration: InitConfiguration): CookieOptions | undefined {
|
|
52
91
|
const cookieOptions: CookieOptions = {}
|
|
53
92
|
|
|
54
93
|
cookieOptions.secure =
|
|
55
|
-
!!initConfiguration.useSecureSessionCookie ||
|
|
56
|
-
|
|
57
|
-
!!initConfiguration.useCrossSiteSessionCookie
|
|
58
|
-
cookieOptions.crossSite =
|
|
59
|
-
!!initConfiguration.usePartitionedCrossSiteSessionCookie || !!initConfiguration.useCrossSiteSessionCookie
|
|
94
|
+
!!initConfiguration.useSecureSessionCookie || !!initConfiguration.usePartitionedCrossSiteSessionCookie
|
|
95
|
+
cookieOptions.crossSite = !!initConfiguration.usePartitionedCrossSiteSessionCookie
|
|
60
96
|
cookieOptions.partitioned = !!initConfiguration.usePartitionedCrossSiteSessionCookie
|
|
61
97
|
|
|
62
98
|
if (initConfiguration.trackSessionAcrossSubdomains) {
|
|
63
|
-
|
|
99
|
+
const currentSite = getCurrentSite()
|
|
100
|
+
if (!currentSite) {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
cookieOptions.domain = currentSite
|
|
64
104
|
}
|
|
65
105
|
|
|
66
106
|
return cookieOptions
|
|
67
107
|
}
|
|
108
|
+
|
|
109
|
+
function encodeCookieOptions(cookieOptions: CookieOptions): string {
|
|
110
|
+
const domainCount = cookieOptions.domain ? cookieOptions.domain.split('.').length - 1 : 0
|
|
111
|
+
|
|
112
|
+
/* eslint-disable no-bitwise */
|
|
113
|
+
let byte = 0
|
|
114
|
+
byte |= SESSION_COOKIE_VERSION << 5 // Store version in upper 3 bits
|
|
115
|
+
byte |= domainCount << 1 // Store domain count in next 4 bits
|
|
116
|
+
byte |= cookieOptions.crossSite ? 1 : 0 // Store useCrossSiteScripting in next bit
|
|
117
|
+
/* eslint-enable no-bitwise */
|
|
118
|
+
|
|
119
|
+
return byte.toString(16) // Convert to hex string
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Retrieve the session state from the cookie that was set with the same cookie options.
|
|
124
|
+
* If there is no match, fallback to the first cookie, (because that's how `getCookie()` works)
|
|
125
|
+
* and this allows to keep the current session id when we release this feature.
|
|
126
|
+
*/
|
|
127
|
+
function retrieveSessionCookieFromEncodedCookie(cookieOptions: CookieOptions): SessionState {
|
|
128
|
+
const cookies = getCookies(SESSION_STORE_KEY)
|
|
129
|
+
const opts = encodeCookieOptions(cookieOptions)
|
|
130
|
+
|
|
131
|
+
let sessionState: SessionState | undefined
|
|
132
|
+
|
|
133
|
+
// reverse the cookies so that if there is no match, the cookie returned is the first one
|
|
134
|
+
for (const cookie of cookies.reverse()) {
|
|
135
|
+
sessionState = toSessionState(cookie)
|
|
136
|
+
|
|
137
|
+
if (sessionState.c === opts) {
|
|
138
|
+
break
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// remove the cookie options from the session state as this is not part of the session state
|
|
143
|
+
delete sessionState?.c
|
|
144
|
+
|
|
145
|
+
return sessionState ?? {}
|
|
146
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { generateUUID } from '../../../tools/utils/stringUtils'
|
|
2
|
+
import type { Configuration } from '../../configuration'
|
|
3
|
+
import { SessionPersistence } from '../sessionConstants'
|
|
2
4
|
import type { SessionState } from '../sessionState'
|
|
3
|
-
import { toSessionString, toSessionState } from '../sessionState'
|
|
5
|
+
import { toSessionString, toSessionState, getExpiredSessionState } from '../sessionState'
|
|
4
6
|
import type { SessionStoreStrategy, SessionStoreStrategyType } from './sessionStoreStrategy'
|
|
5
7
|
import { SESSION_STORE_KEY } from './sessionStoreStrategy'
|
|
6
8
|
|
|
@@ -13,18 +15,18 @@ export function selectLocalStorageStrategy(): SessionStoreStrategyType | undefin
|
|
|
13
15
|
localStorage.setItem(testKey, id)
|
|
14
16
|
const retrievedId = localStorage.getItem(testKey)
|
|
15
17
|
localStorage.removeItem(testKey)
|
|
16
|
-
return id === retrievedId ? { type:
|
|
17
|
-
} catch
|
|
18
|
+
return id === retrievedId ? { type: SessionPersistence.LOCAL_STORAGE } : undefined
|
|
19
|
+
} catch {
|
|
18
20
|
return undefined
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
export function initLocalStorageStrategy(): SessionStoreStrategy {
|
|
24
|
+
export function initLocalStorageStrategy(configuration: Configuration): SessionStoreStrategy {
|
|
23
25
|
return {
|
|
24
26
|
isLockEnabled: false,
|
|
25
27
|
persistSession: persistInLocalStorage,
|
|
26
28
|
retrieveSession: retrieveSessionFromLocalStorage,
|
|
27
|
-
|
|
29
|
+
expireSession: (sessionState: SessionState) => expireSessionFromLocalStorage(sessionState, configuration),
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -32,11 +34,11 @@ function persistInLocalStorage(sessionState: SessionState) {
|
|
|
32
34
|
localStorage.setItem(SESSION_STORE_KEY, toSessionString(sessionState))
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
function retrieveSessionFromLocalStorage(): SessionState {
|
|
37
|
+
export function retrieveSessionFromLocalStorage(): SessionState {
|
|
36
38
|
const sessionString = localStorage.getItem(SESSION_STORE_KEY)
|
|
37
39
|
return toSessionState(sessionString)
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
+
function expireSessionFromLocalStorage(previousSessionState: SessionState, configuration: Configuration) {
|
|
43
|
+
persistInLocalStorage(getExpiredSessionState(previousSessionState, configuration))
|
|
42
44
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { CookieOptions } from '../../../browser/cookie'
|
|
2
|
+
import type { SessionPersistence } from '../sessionConstants'
|
|
2
3
|
import type { SessionState } from '../sessionState'
|
|
3
4
|
|
|
4
5
|
export const SESSION_STORE_KEY = '_oo_s'
|
|
5
6
|
|
|
6
|
-
export type SessionStoreStrategyType =
|
|
7
|
+
export type SessionStoreStrategyType =
|
|
8
|
+
| { type: typeof SessionPersistence.COOKIE; cookieOptions: CookieOptions }
|
|
9
|
+
| { type: typeof SessionPersistence.LOCAL_STORAGE }
|
|
7
10
|
|
|
8
11
|
export interface SessionStoreStrategy {
|
|
9
12
|
isLockEnabled: boolean
|
|
10
13
|
persistSession: (session: SessionState) => void
|
|
11
14
|
retrieveSession: () => SessionState
|
|
12
|
-
|
|
15
|
+
expireSession: (previousSessionState: SessionState) => void
|
|
13
16
|
}
|