@openobserve/browser-core 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +3 -0
- package/cjs/boot/init.d.ts +5 -0
- package/cjs/boot/init.js +36 -0
- package/cjs/boot/init.js.map +1 -0
- package/cjs/browser/addEventListener.d.ts +76 -0
- package/cjs/browser/addEventListener.js +52 -0
- package/cjs/browser/addEventListener.js.map +1 -0
- package/cjs/browser/cookie.d.ts +10 -0
- package/cjs/browser/cookie.js +69 -0
- package/cjs/browser/cookie.js.map +1 -0
- package/cjs/browser/fetchObservable.d.ts +23 -0
- package/cjs/browser/fetchObservable.js +74 -0
- package/cjs/browser/fetchObservable.js.map +1 -0
- package/cjs/browser/pageExitObservable.d.ts +14 -0
- package/cjs/browser/pageExitObservable.js +58 -0
- package/cjs/browser/pageExitObservable.js.map +1 -0
- package/cjs/browser/runOnReadyState.d.ts +2 -0
- package/cjs/browser/runOnReadyState.js +15 -0
- package/cjs/browser/runOnReadyState.js.map +1 -0
- package/cjs/browser/types.d.ts +19 -0
- package/cjs/browser/types.js +6 -0
- package/cjs/browser/types.js.map +1 -0
- package/cjs/browser/xhrObservable.d.ts +22 -0
- package/cjs/browser/xhrObservable.js +93 -0
- package/cjs/browser/xhrObservable.js.map +1 -0
- package/cjs/domain/configuration/configuration.d.ts +67 -0
- package/cjs/domain/configuration/configuration.js +95 -0
- package/cjs/domain/configuration/configuration.js.map +1 -0
- package/cjs/domain/configuration/endpointBuilder.d.ts +14 -0
- package/cjs/domain/configuration/endpointBuilder.js +94 -0
- package/cjs/domain/configuration/endpointBuilder.js.map +1 -0
- package/cjs/domain/configuration/index.d.ts +3 -0
- package/cjs/domain/configuration/index.js +25 -0
- package/cjs/domain/configuration/index.js.map +1 -0
- package/cjs/domain/configuration/intakeSites.d.ts +5 -0
- package/cjs/domain/configuration/intakeSites.js +9 -0
- package/cjs/domain/configuration/intakeSites.js.map +1 -0
- package/cjs/domain/configuration/tags.d.ts +4 -0
- package/cjs/domain/configuration/tags.js +39 -0
- package/cjs/domain/configuration/tags.js.map +1 -0
- package/cjs/domain/configuration/transportConfiguration.d.ts +16 -0
- package/cjs/domain/configuration/transportConfiguration.js +42 -0
- package/cjs/domain/configuration/transportConfiguration.js.map +1 -0
- package/cjs/domain/console/consoleObservable.d.ts +11 -0
- package/cjs/domain/console/consoleObservable.js +75 -0
- package/cjs/domain/console/consoleObservable.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/deflate/types.d.ts +26 -0
- package/cjs/domain/deflate/types.js +3 -0
- package/cjs/domain/deflate/types.js.map +1 -0
- package/cjs/domain/error/error.d.ts +28 -0
- package/cjs/domain/error/error.js +131 -0
- package/cjs/domain/error/error.js.map +1 -0
- package/cjs/domain/error/error.types.d.ts +40 -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 +5 -0
- package/cjs/domain/error/trackRuntimeError.js +21 -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 +40 -0
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -0
- package/cjs/domain/report/browser.types.d.ts +24 -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 +15 -0
- package/cjs/domain/report/reportObservable.js +94 -0
- package/cjs/domain/report/reportObservable.js.map +1 -0
- package/cjs/domain/resourceUtils.d.ts +16 -0
- package/cjs/domain/resourceUtils.js +3 -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 +2 -0
- package/cjs/domain/session/sessionConstants.js +7 -0
- package/cjs/domain/session/sessionConstants.js.map +1 -0
- package/cjs/domain/session/sessionManager.d.ts +20 -0
- package/cjs/domain/session/sessionManager.js +65 -0
- package/cjs/domain/session/sessionManager.js.map +1 -0
- package/cjs/domain/session/sessionState.d.ts +11 -0
- package/cjs/domain/session/sessionState.js +45 -0
- package/cjs/domain/session/sessionState.js.map +1 -0
- package/cjs/domain/session/sessionStore.d.ts +34 -0
- package/cjs/domain/session/sessionStore.js +144 -0
- package/cjs/domain/session/sessionStore.js.map +1 -0
- package/cjs/domain/session/sessionStoreOperations.d.ts +15 -0
- package/cjs/domain/session/sessionStoreOperations.js +104 -0
- package/cjs/domain/session/sessionStoreOperations.js.map +1 -0
- package/cjs/domain/session/storeStrategies/sessionInCookie.d.ts +6 -0
- package/cjs/domain/session/storeStrategies/sessionInCookie.js +48 -0
- package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +1 -0
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.d.ts +3 -0
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +40 -0
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -0
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.d.ts +14 -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 +11 -0
- package/cjs/domain/synthetics/syntheticsWorkerValues.js +22 -0
- package/cjs/domain/synthetics/syntheticsWorkerValues.js.map +1 -0
- package/cjs/domain/telemetry/index.d.ts +3 -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 +11 -0
- package/cjs/domain/telemetry/rawTelemetryEvent.types.js +8 -0
- package/cjs/domain/telemetry/rawTelemetryEvent.types.js.map +1 -0
- package/cjs/domain/telemetry/telemetry.d.ts +112 -0
- package/cjs/domain/telemetry/telemetry.js +146 -0
- package/cjs/domain/telemetry/telemetry.js.map +1 -0
- package/cjs/domain/telemetry/telemetryEvent.types.d.ts +375 -0
- package/cjs/domain/telemetry/telemetryEvent.types.js +7 -0
- package/cjs/domain/telemetry/telemetryEvent.types.js.map +1 -0
- package/cjs/domain/tracekit/computeStackTrace.d.ts +5 -0
- package/cjs/domain/tracekit/computeStackTrace.js +118 -0
- package/cjs/domain/tracekit/computeStackTrace.js.map +1 -0
- package/cjs/domain/tracekit/index.d.ts +3 -0
- package/cjs/domain/tracekit/index.js +8 -0
- package/cjs/domain/tracekit/index.js.map +1 -0
- package/cjs/domain/tracekit/tracekit.d.ts +35 -0
- package/cjs/domain/tracekit/tracekit.js +95 -0
- package/cjs/domain/tracekit/tracekit.js.map +1 -0
- package/cjs/domain/tracekit/types.d.ts +44 -0
- package/cjs/domain/tracekit/types.js +3 -0
- package/cjs/domain/tracekit/types.js.map +1 -0
- package/cjs/domain/user/index.d.ts +2 -0
- package/cjs/domain/user/index.js +19 -0
- package/cjs/domain/user/index.js.map +1 -0
- package/cjs/domain/user/user.d.ts +12 -0
- package/cjs/domain/user/user.js +35 -0
- package/cjs/domain/user/user.js.map +1 -0
- package/cjs/domain/user/user.types.d.ts +6 -0
- package/cjs/domain/user/user.types.js +3 -0
- package/cjs/domain/user/user.types.js.map +1 -0
- package/cjs/index.d.ts +63 -0
- package/cjs/index.js +155 -0
- package/cjs/index.js.map +1 -0
- package/cjs/tools/abstractLifeCycle.d.ts +23 -0
- package/cjs/tools/abstractLifeCycle.js +29 -0
- package/cjs/tools/abstractLifeCycle.js.map +1 -0
- package/cjs/tools/boundedBuffer.d.ts +5 -0
- package/cjs/tools/boundedBuffer.js +22 -0
- package/cjs/tools/boundedBuffer.js.map +1 -0
- package/cjs/tools/catchUserErrors.d.ts +1 -0
- package/cjs/tools/catchUserErrors.js +20 -0
- package/cjs/tools/catchUserErrors.js.map +1 -0
- package/cjs/tools/display.d.ts +35 -0
- package/cjs/tools/display.js +45 -0
- package/cjs/tools/display.js.map +1 -0
- package/cjs/tools/experimentalFeatures.d.ts +24 -0
- package/cjs/tools/experimentalFeatures.js +47 -0
- package/cjs/tools/experimentalFeatures.js.map +1 -0
- package/cjs/tools/getGlobalObject.d.ts +4 -0
- package/cjs/tools/getGlobalObject.js +37 -0
- package/cjs/tools/getGlobalObject.js.map +1 -0
- package/cjs/tools/getZoneJsOriginalValue.d.ts +19 -0
- package/cjs/tools/getZoneJsOriginalValue.js +30 -0
- package/cjs/tools/getZoneJsOriginalValue.js.map +1 -0
- package/cjs/tools/instrumentMethod.d.ts +19 -0
- package/cjs/tools/instrumentMethod.js +83 -0
- package/cjs/tools/instrumentMethod.js.map +1 -0
- package/cjs/tools/matchOption.d.ts +8 -0
- package/cjs/tools/matchOption.js +38 -0
- package/cjs/tools/matchOption.js.map +1 -0
- package/cjs/tools/mergeInto.d.ts +25 -0
- package/cjs/tools/mergeInto.js +105 -0
- package/cjs/tools/mergeInto.js.map +1 -0
- package/cjs/tools/monitor.d.ts +9 -0
- package/cjs/tools/monitor.js +76 -0
- package/cjs/tools/monitor.js.map +1 -0
- package/cjs/tools/observable.d.ts +12 -0
- package/cjs/tools/observable.js +44 -0
- package/cjs/tools/observable.js.map +1 -0
- package/cjs/tools/readBytesFromStream.d.ts +11 -0
- package/cjs/tools/readBytesFromStream.js +64 -0
- package/cjs/tools/readBytesFromStream.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 +6 -0
- package/cjs/tools/serialisation/context.js +3 -0
- package/cjs/tools/serialisation/context.js.map +1 -0
- package/cjs/tools/serialisation/contextManager.d.ts +21 -0
- package/cjs/tools/serialisation/contextManager.js +70 -0
- package/cjs/tools/serialisation/contextManager.js.map +1 -0
- package/cjs/tools/serialisation/heavyCustomerDataWarning.d.ts +8 -0
- package/cjs/tools/serialisation/heavyCustomerDataWarning.js +18 -0
- package/cjs/tools/serialisation/heavyCustomerDataWarning.js.map +1 -0
- package/cjs/tools/serialisation/jsonStringify.d.ts +14 -0
- package/cjs/tools/serialisation/jsonStringify.js +49 -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 +185 -0
- package/cjs/tools/serialisation/sanitize.js.map +1 -0
- package/cjs/tools/timer.d.ts +5 -0
- package/cjs/tools/timer.js +23 -0
- package/cjs/tools/timer.js.map +1 -0
- package/cjs/tools/utils/arrayUtils.d.ts +1 -0
- package/cjs/tools/utils/arrayUtils.js +11 -0
- package/cjs/tools/utils/arrayUtils.js.map +1 -0
- package/cjs/tools/utils/browserDetection.d.ts +2 -0
- package/cjs/tools/utils/browserDetection.js +12 -0
- package/cjs/tools/utils/browserDetection.js.map +1 -0
- package/cjs/tools/utils/byteUtils.d.ts +4 -0
- package/cjs/tools/utils/byteUtils.js +31 -0
- package/cjs/tools/utils/byteUtils.js.map +1 -0
- package/cjs/tools/utils/functionUtils.d.ts +9 -0
- package/cjs/tools/utils/functionUtils.js +48 -0
- package/cjs/tools/utils/functionUtils.js.map +1 -0
- package/cjs/tools/utils/numberUtils.d.ts +8 -0
- package/cjs/tools/utils/numberUtils.js +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 +26 -0
- package/cjs/tools/utils/objectUtils.js.map +1 -0
- package/cjs/tools/utils/polyfills.d.ts +24 -0
- package/cjs/tools/utils/polyfills.js +110 -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 +18 -0
- package/cjs/tools/utils/responseUtils.js.map +1 -0
- package/cjs/tools/utils/stringUtils.d.ts +7 -0
- package/cjs/tools/utils/stringUtils.js +32 -0
- package/cjs/tools/utils/stringUtils.js.map +1 -0
- package/cjs/tools/utils/timeUtils.d.ts +57 -0
- package/cjs/tools/utils/timeUtils.js +99 -0
- package/cjs/tools/utils/timeUtils.js.map +1 -0
- package/cjs/tools/utils/typeUtils.d.ts +4 -0
- package/cjs/tools/utils/typeUtils.js +17 -0
- package/cjs/tools/utils/typeUtils.js.map +1 -0
- package/cjs/tools/utils/urlPolyfill.d.ts +14 -0
- package/cjs/tools/utils/urlPolyfill.js +92 -0
- package/cjs/tools/utils/urlPolyfill.js.map +1 -0
- package/cjs/tools/valueHistory.d.ts +50 -0
- package/cjs/tools/valueHistory.js +106 -0
- package/cjs/tools/valueHistory.js.map +1 -0
- package/cjs/transport/batch.d.ts +19 -0
- package/cjs/transport/batch.js +79 -0
- package/cjs/transport/batch.js.map +1 -0
- package/cjs/transport/eventBridge.d.ts +12 -0
- package/cjs/transport/eventBridge.js +34 -0
- package/cjs/transport/eventBridge.js.map +1 -0
- package/cjs/transport/flushController.d.ts +48 -0
- package/cjs/transport/flushController.js +97 -0
- package/cjs/transport/flushController.js.map +1 -0
- package/cjs/transport/httpRequest.d.ts +37 -0
- package/cjs/transport/httpRequest.js +91 -0
- package/cjs/transport/httpRequest.js.map +1 -0
- package/cjs/transport/index.d.ts +4 -0
- package/cjs/transport/index.js +13 -0
- package/cjs/transport/index.js.map +1 -0
- package/cjs/transport/sendWithRetryStrategy.d.ts +39 -0
- package/cjs/transport/sendWithRetryStrategy.js +151 -0
- package/cjs/transport/sendWithRetryStrategy.js.map +1 -0
- package/cjs/transport/startBatchWithReplica.d.ts +15 -0
- package/cjs/transport/startBatchWithReplica.js +37 -0
- package/cjs/transport/startBatchWithReplica.js.map +1 -0
- package/esm/boot/init.d.ts +5 -0
- package/esm/boot/init.js +31 -0
- package/esm/boot/init.js.map +1 -0
- package/esm/browser/addEventListener.d.ts +76 -0
- package/esm/browser/addEventListener.js +47 -0
- package/esm/browser/addEventListener.js.map +1 -0
- package/esm/browser/cookie.d.ts +10 -0
- package/esm/browser/cookie.js +61 -0
- package/esm/browser/cookie.js.map +1 -0
- package/esm/browser/fetchObservable.d.ts +23 -0
- package/esm/browser/fetchObservable.js +70 -0
- package/esm/browser/fetchObservable.js.map +1 -0
- package/esm/browser/pageExitObservable.d.ts +14 -0
- package/esm/browser/pageExitObservable.js +53 -0
- package/esm/browser/pageExitObservable.js.map +1 -0
- package/esm/browser/runOnReadyState.d.ts +2 -0
- package/esm/browser/runOnReadyState.js +11 -0
- package/esm/browser/runOnReadyState.js.map +1 -0
- package/esm/browser/types.d.ts +19 -0
- package/esm/browser/types.js +5 -0
- package/esm/browser/types.js.map +1 -0
- package/esm/browser/xhrObservable.d.ts +22 -0
- package/esm/browser/xhrObservable.js +89 -0
- package/esm/browser/xhrObservable.js.map +1 -0
- package/esm/domain/configuration/configuration.d.ts +67 -0
- package/esm/domain/configuration/configuration.js +90 -0
- package/esm/domain/configuration/configuration.js.map +1 -0
- package/esm/domain/configuration/endpointBuilder.d.ts +14 -0
- package/esm/domain/configuration/endpointBuilder.js +90 -0
- package/esm/domain/configuration/endpointBuilder.js.map +1 -0
- package/esm/domain/configuration/index.d.ts +3 -0
- package/esm/domain/configuration/index.js +4 -0
- package/esm/domain/configuration/index.js.map +1 -0
- package/esm/domain/configuration/intakeSites.d.ts +5 -0
- package/esm/domain/configuration/intakeSites.js +6 -0
- package/esm/domain/configuration/intakeSites.js.map +1 -0
- package/esm/domain/configuration/tags.d.ts +4 -0
- package/esm/domain/configuration/tags.js +34 -0
- package/esm/domain/configuration/tags.js.map +1 -0
- package/esm/domain/configuration/transportConfiguration.d.ts +16 -0
- package/esm/domain/configuration/transportConfiguration.js +38 -0
- package/esm/domain/configuration/transportConfiguration.js.map +1 -0
- package/esm/domain/console/consoleObservable.d.ts +11 -0
- package/esm/domain/console/consoleObservable.js +70 -0
- package/esm/domain/console/consoleObservable.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/deflate/types.d.ts +26 -0
- package/esm/domain/deflate/types.js +2 -0
- package/esm/domain/deflate/types.js.map +1 -0
- package/esm/domain/error/error.d.ts +28 -0
- package/esm/domain/error/error.js +121 -0
- package/esm/domain/error/error.js.map +1 -0
- package/esm/domain/error/error.types.d.ts +40 -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 +5 -0
- package/esm/domain/error/trackRuntimeError.js +17 -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/report/browser.types.d.ts +24 -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 +15 -0
- package/esm/domain/report/reportObservable.js +90 -0
- package/esm/domain/report/reportObservable.js.map +1 -0
- package/esm/domain/resourceUtils.d.ts +16 -0
- package/esm/domain/resourceUtils.js +2 -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 +2 -0
- package/esm/domain/session/sessionConstants.js +4 -0
- package/esm/domain/session/sessionConstants.js.map +1 -0
- package/esm/domain/session/sessionManager.d.ts +20 -0
- package/esm/domain/session/sessionManager.js +60 -0
- package/esm/domain/session/sessionManager.js.map +1 -0
- package/esm/domain/session/sessionState.d.ts +11 -0
- package/esm/domain/session/sessionState.js +38 -0
- package/esm/domain/session/sessionState.js.map +1 -0
- package/esm/domain/session/sessionStore.d.ts +34 -0
- package/esm/domain/session/sessionStore.js +139 -0
- package/esm/domain/session/sessionStore.js.map +1 -0
- package/esm/domain/session/sessionStoreOperations.d.ts +15 -0
- package/esm/domain/session/sessionStoreOperations.js +99 -0
- package/esm/domain/session/sessionStoreOperations.js.map +1 -0
- package/esm/domain/session/storeStrategies/sessionInCookie.d.ts +6 -0
- package/esm/domain/session/storeStrategies/sessionInCookie.js +42 -0
- package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -0
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.d.ts +3 -0
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +35 -0
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -0
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +14 -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 +11 -0
- package/esm/domain/synthetics/syntheticsWorkerValues.js +16 -0
- package/esm/domain/synthetics/syntheticsWorkerValues.js.map +1 -0
- package/esm/domain/telemetry/index.d.ts +3 -0
- package/esm/domain/telemetry/index.js +4 -0
- package/esm/domain/telemetry/index.js.map +1 -0
- package/esm/domain/telemetry/rawTelemetryEvent.types.d.ts +11 -0
- package/esm/domain/telemetry/rawTelemetryEvent.types.js +5 -0
- package/esm/domain/telemetry/rawTelemetryEvent.types.js.map +1 -0
- package/esm/domain/telemetry/telemetry.d.ts +112 -0
- package/esm/domain/telemetry/telemetry.js +134 -0
- package/esm/domain/telemetry/telemetry.js.map +1 -0
- package/esm/domain/telemetry/telemetryEvent.types.d.ts +375 -0
- package/esm/domain/telemetry/telemetryEvent.types.js +6 -0
- package/esm/domain/telemetry/telemetryEvent.types.js.map +1 -0
- package/esm/domain/tracekit/computeStackTrace.d.ts +5 -0
- package/esm/domain/tracekit/computeStackTrace.js +114 -0
- package/esm/domain/tracekit/computeStackTrace.js.map +1 -0
- package/esm/domain/tracekit/index.d.ts +3 -0
- package/esm/domain/tracekit/index.js +3 -0
- package/esm/domain/tracekit/index.js.map +1 -0
- package/esm/domain/tracekit/tracekit.d.ts +35 -0
- package/esm/domain/tracekit/tracekit.js +91 -0
- package/esm/domain/tracekit/tracekit.js.map +1 -0
- package/esm/domain/tracekit/types.d.ts +44 -0
- package/esm/domain/tracekit/types.js +2 -0
- package/esm/domain/tracekit/types.js.map +1 -0
- package/esm/domain/user/index.d.ts +2 -0
- package/esm/domain/user/index.js +3 -0
- package/esm/domain/user/index.js.map +1 -0
- package/esm/domain/user/user.d.ts +12 -0
- package/esm/domain/user/user.js +30 -0
- package/esm/domain/user/user.js.map +1 -0
- package/esm/domain/user/user.types.d.ts +6 -0
- package/esm/domain/user/user.types.js +2 -0
- package/esm/domain/user/user.types.js.map +1 -0
- package/esm/index.d.ts +63 -0
- package/esm/index.js +61 -0
- package/esm/index.js.map +1 -0
- package/esm/tools/abstractLifeCycle.d.ts +23 -0
- package/esm/tools/abstractLifeCycle.js +26 -0
- package/esm/tools/abstractLifeCycle.js.map +1 -0
- package/esm/tools/boundedBuffer.d.ts +5 -0
- package/esm/tools/boundedBuffer.js +19 -0
- package/esm/tools/boundedBuffer.js.map +1 -0
- package/esm/tools/catchUserErrors.d.ts +1 -0
- package/esm/tools/catchUserErrors.js +16 -0
- package/esm/tools/catchUserErrors.js.map +1 -0
- package/esm/tools/display.d.ts +35 -0
- package/esm/tools/display.js +41 -0
- package/esm/tools/display.js.map +1 -0
- package/esm/tools/experimentalFeatures.d.ts +24 -0
- package/esm/tools/experimentalFeatures.js +40 -0
- package/esm/tools/experimentalFeatures.js.map +1 -0
- package/esm/tools/getGlobalObject.d.ts +4 -0
- package/esm/tools/getGlobalObject.js +33 -0
- package/esm/tools/getGlobalObject.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/instrumentMethod.d.ts +19 -0
- package/esm/tools/instrumentMethod.js +77 -0
- package/esm/tools/instrumentMethod.js.map +1 -0
- package/esm/tools/matchOption.d.ts +8 -0
- package/esm/tools/matchOption.js +33 -0
- package/esm/tools/matchOption.js.map +1 -0
- package/esm/tools/mergeInto.d.ts +25 -0
- package/esm/tools/mergeInto.js +99 -0
- package/esm/tools/mergeInto.js.map +1 -0
- package/esm/tools/monitor.d.ts +9 -0
- package/esm/tools/monitor.js +66 -0
- package/esm/tools/monitor.js.map +1 -0
- package/esm/tools/observable.d.ts +12 -0
- package/esm/tools/observable.js +40 -0
- package/esm/tools/observable.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/sendToExtension.d.ts +3 -0
- package/esm/tools/sendToExtension.js +7 -0
- package/esm/tools/sendToExtension.js.map +1 -0
- package/esm/tools/serialisation/context.d.ts +6 -0
- package/esm/tools/serialisation/context.js +2 -0
- package/esm/tools/serialisation/context.js.map +1 -0
- package/esm/tools/serialisation/contextManager.d.ts +21 -0
- package/esm/tools/serialisation/contextManager.js +66 -0
- package/esm/tools/serialisation/contextManager.js.map +1 -0
- package/esm/tools/serialisation/heavyCustomerDataWarning.d.ts +8 -0
- package/esm/tools/serialisation/heavyCustomerDataWarning.js +14 -0
- package/esm/tools/serialisation/heavyCustomerDataWarning.js.map +1 -0
- package/esm/tools/serialisation/jsonStringify.d.ts +14 -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 +181 -0
- package/esm/tools/serialisation/sanitize.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 +1 -0
- package/esm/tools/utils/arrayUtils.js +7 -0
- package/esm/tools/utils/arrayUtils.js.map +1 -0
- package/esm/tools/utils/browserDetection.d.ts +2 -0
- package/esm/tools/utils/browserDetection.js +7 -0
- package/esm/tools/utils/browserDetection.js.map +1 -0
- package/esm/tools/utils/byteUtils.d.ts +4 -0
- package/esm/tools/utils/byteUtils.js +26 -0
- package/esm/tools/utils/byteUtils.js.map +1 -0
- package/esm/tools/utils/functionUtils.d.ts +9 -0
- package/esm/tools/utils/functionUtils.js +43 -0
- package/esm/tools/utils/functionUtils.js.map +1 -0
- package/esm/tools/utils/numberUtils.d.ts +8 -0
- package/esm/tools/utils/numberUtils.js +17 -0
- package/esm/tools/utils/numberUtils.js.map +1 -0
- package/esm/tools/utils/objectUtils.d.ts +10 -0
- package/esm/tools/utils/objectUtils.js +19 -0
- package/esm/tools/utils/objectUtils.js.map +1 -0
- package/esm/tools/utils/polyfills.d.ts +24 -0
- package/esm/tools/utils/polyfills.js +95 -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 +7 -0
- package/esm/tools/utils/stringUtils.js +26 -0
- package/esm/tools/utils/stringUtils.js.map +1 -0
- package/esm/tools/utils/timeUtils.d.ts +57 -0
- package/esm/tools/utils/timeUtils.js +82 -0
- package/esm/tools/utils/timeUtils.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 +14 -0
- package/esm/tools/utils/urlPolyfill.js +80 -0
- package/esm/tools/utils/urlPolyfill.js.map +1 -0
- package/esm/tools/valueHistory.d.ts +50 -0
- package/esm/tools/valueHistory.js +103 -0
- package/esm/tools/valueHistory.js.map +1 -0
- package/esm/transport/batch.d.ts +19 -0
- package/esm/transport/batch.js +76 -0
- package/esm/transport/batch.js.map +1 -0
- package/esm/transport/eventBridge.d.ts +12 -0
- package/esm/transport/eventBridge.js +29 -0
- package/esm/transport/eventBridge.js.map +1 -0
- package/esm/transport/flushController.d.ts +48 -0
- package/esm/transport/flushController.js +93 -0
- package/esm/transport/flushController.js.map +1 -0
- package/esm/transport/httpRequest.d.ts +37 -0
- package/esm/transport/httpRequest.js +85 -0
- package/esm/transport/httpRequest.js.map +1 -0
- package/esm/transport/index.d.ts +4 -0
- package/esm/transport/index.js +5 -0
- package/esm/transport/index.js.map +1 -0
- package/esm/transport/sendWithRetryStrategy.d.ts +39 -0
- package/esm/transport/sendWithRetryStrategy.js +146 -0
- package/esm/transport/sendWithRetryStrategy.js.map +1 -0
- package/esm/transport/startBatchWithReplica.d.ts +15 -0
- package/esm/transport/startBatchWithReplica.js +33 -0
- package/esm/transport/startBatchWithReplica.js.map +1 -0
- package/package.json +26 -0
- package/src/boot/init.ts +41 -0
- package/src/browser/addEventListener.ts +136 -0
- package/src/browser/cookie.ts +71 -0
- package/src/browser/fetchObservable.ts +112 -0
- package/src/browser/pageExitObservable.ts +69 -0
- package/src/browser/runOnReadyState.ts +15 -0
- package/src/browser/types.ts +40 -0
- package/src/browser/xhrObservable.ts +127 -0
- package/src/domain/configuration/configuration.ts +191 -0
- package/src/domain/configuration/endpointBuilder.ts +134 -0
- package/src/domain/configuration/index.ts +9 -0
- package/src/domain/configuration/intakeSites.ts +5 -0
- package/src/domain/configuration/tags.ts +43 -0
- package/src/domain/configuration/transportConfiguration.ts +71 -0
- package/src/domain/console/consoleObservable.ts +86 -0
- package/src/domain/deflate/index.ts +1 -0
- package/src/domain/deflate/types.ts +41 -0
- package/src/domain/error/error.ts +159 -0
- package/src/domain/error/error.types.ts +47 -0
- package/src/domain/error/trackRuntimeError.ts +21 -0
- package/src/domain/eventRateLimiter/createEventRateLimiter.ts +46 -0
- package/src/domain/report/browser.types.ts +26 -0
- package/src/domain/report/reportObservable.ts +126 -0
- package/src/domain/resourceUtils.ts +17 -0
- package/src/domain/session/oldCookiesMigration.ts +42 -0
- package/src/domain/session/sessionConstants.ts +4 -0
- package/src/domain/session/sessionManager.ts +98 -0
- package/src/domain/session/sessionState.ts +51 -0
- package/src/domain/session/sessionStore.ts +185 -0
- package/src/domain/session/sessionStoreOperations.ts +112 -0
- package/src/domain/session/storeStrategies/sessionInCookie.ts +56 -0
- package/src/domain/session/storeStrategies/sessionInLocalStorage.ts +41 -0
- package/src/domain/session/storeStrategies/sessionStoreStrategy.ts +12 -0
- package/src/domain/synthetics/syntheticsWorkerValues.ts +27 -0
- package/src/domain/telemetry/index.ts +14 -0
- package/src/domain/telemetry/rawTelemetryEvent.types.ts +14 -0
- package/src/domain/telemetry/telemetry.ts +195 -0
- package/src/domain/telemetry/telemetryEvent.types.ts +382 -0
- package/src/domain/tracekit/computeStackTrace.ts +141 -0
- package/src/domain/tracekit/index.ts +3 -0
- package/src/domain/tracekit/tracekit.ts +96 -0
- package/src/domain/tracekit/types.ts +47 -0
- package/src/domain/user/index.ts +2 -0
- package/src/domain/user/user.ts +33 -0
- package/src/domain/user/user.types.ts +6 -0
- package/src/index.ts +128 -0
- package/src/tools/abstractLifeCycle.ts +45 -0
- package/src/tools/boundedBuffer.ts +17 -0
- package/src/tools/catchUserErrors.ts +11 -0
- package/src/tools/display.ts +51 -0
- package/src/tools/experimentalFeatures.ts +43 -0
- package/src/tools/getGlobalObject.ts +31 -0
- package/src/tools/getZoneJsOriginalValue.ts +38 -0
- package/src/tools/instrumentMethod.ts +109 -0
- package/src/tools/matchOption.ts +32 -0
- package/src/tools/mergeInto.ts +177 -0
- package/src/tools/monitor.ts +68 -0
- package/src/tools/observable.ts +40 -0
- package/src/tools/readBytesFromStream.ts +77 -0
- package/src/tools/sendToExtension.ts +12 -0
- package/src/tools/serialisation/context.ts +8 -0
- package/src/tools/serialisation/contextManager.ts +79 -0
- package/src/tools/serialisation/heavyCustomerDataWarning.ts +26 -0
- package/src/tools/serialisation/jsonStringify.ts +53 -0
- package/src/tools/serialisation/sanitize.ts +255 -0
- package/src/tools/timer.ts +21 -0
- package/src/tools/utils/arrayUtils.ts +7 -0
- package/src/tools/utils/browserDetection.ts +7 -0
- package/src/tools/utils/byteUtils.ts +29 -0
- package/src/tools/utils/functionUtils.ts +47 -0
- package/src/tools/utils/numberUtils.ts +19 -0
- package/src/tools/utils/objectUtils.ts +21 -0
- package/src/tools/utils/polyfills.ts +127 -0
- package/src/tools/utils/responseUtils.ts +12 -0
- package/src/tools/utils/stringUtils.ts +28 -0
- package/src/tools/utils/timeUtils.ts +112 -0
- package/src/tools/utils/typeUtils.ts +12 -0
- package/src/tools/utils/urlPolyfill.ts +86 -0
- package/src/tools/valueHistory.ts +120 -0
- package/src/transport/batch.ts +92 -0
- package/src/transport/eventBridge.ts +42 -0
- package/src/transport/flushController.ts +129 -0
- package/src/transport/httpRequest.ts +150 -0
- package/src/transport/index.ts +4 -0
- package/src/transport/sendWithRetryStrategy.ts +203 -0
- package/src/transport/startBatchWithReplica.ts +52 -0
|
@@ -0,0 +1,185 @@
|
|
|
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 } from '../configuration'
|
|
7
|
+
import { SESSION_TIME_OUT_DELAY } from './sessionConstants'
|
|
8
|
+
import { selectCookieStrategy, initCookieStrategy } from './storeStrategies/sessionInCookie'
|
|
9
|
+
import type { SessionStoreStrategyType } from './storeStrategies/sessionStoreStrategy'
|
|
10
|
+
import type { SessionState } from './sessionState'
|
|
11
|
+
import { initLocalStorageStrategy, selectLocalStorageStrategy } from './storeStrategies/sessionInLocalStorage'
|
|
12
|
+
import { processSessionStoreOperations } from './sessionStoreOperations'
|
|
13
|
+
|
|
14
|
+
export interface SessionStore {
|
|
15
|
+
expandOrRenewSession: () => void
|
|
16
|
+
expandSession: () => void
|
|
17
|
+
getSession: () => SessionState
|
|
18
|
+
renewObservable: Observable<void>
|
|
19
|
+
expireObservable: Observable<void>
|
|
20
|
+
expire: () => void
|
|
21
|
+
stop: () => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Every second, the storage will be polled to check for any change that can occur
|
|
26
|
+
* to the session state in another browser tab, or another window.
|
|
27
|
+
* This value has been determined from our previous cookie-only implementation.
|
|
28
|
+
*/
|
|
29
|
+
export const STORAGE_POLL_DELAY = ONE_SECOND
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Checks if cookies are available as the preferred storage
|
|
33
|
+
* Else, checks if LocalStorage is allowed and available
|
|
34
|
+
*/
|
|
35
|
+
export function selectSessionStoreStrategyType(
|
|
36
|
+
initConfiguration: InitConfiguration
|
|
37
|
+
): SessionStoreStrategyType | undefined {
|
|
38
|
+
let sessionStoreStrategyType = selectCookieStrategy(initConfiguration)
|
|
39
|
+
if (!sessionStoreStrategyType && initConfiguration.allowFallbackToLocalStorage) {
|
|
40
|
+
sessionStoreStrategyType = selectLocalStorageStrategy()
|
|
41
|
+
}
|
|
42
|
+
return sessionStoreStrategyType
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Different session concepts:
|
|
47
|
+
* - tracked, the session has an id and is updated along the user navigation
|
|
48
|
+
* - not tracked, the session does not have an id but it is updated along the user navigation
|
|
49
|
+
* - inactive, no session in store or session expired, waiting for a renew session
|
|
50
|
+
*/
|
|
51
|
+
export function startSessionStore<TrackingType extends string>(
|
|
52
|
+
sessionStoreStrategyType: SessionStoreStrategyType,
|
|
53
|
+
productKey: string,
|
|
54
|
+
computeSessionState: (rawTrackingType?: string) => { trackingType: TrackingType; isTracked: boolean }
|
|
55
|
+
): SessionStore {
|
|
56
|
+
const renewObservable = new Observable<void>()
|
|
57
|
+
const expireObservable = new Observable<void>()
|
|
58
|
+
|
|
59
|
+
const sessionStoreStrategy =
|
|
60
|
+
sessionStoreStrategyType.type === 'Cookie'
|
|
61
|
+
? initCookieStrategy(sessionStoreStrategyType.cookieOptions)
|
|
62
|
+
: initLocalStorageStrategy()
|
|
63
|
+
const { clearSession, retrieveSession } = sessionStoreStrategy
|
|
64
|
+
|
|
65
|
+
const watchSessionTimeoutId = setInterval(watchSession, STORAGE_POLL_DELAY)
|
|
66
|
+
let sessionCache: SessionState = retrieveActiveSession()
|
|
67
|
+
|
|
68
|
+
function expandOrRenewSession() {
|
|
69
|
+
let isTracked: boolean
|
|
70
|
+
processSessionStoreOperations(
|
|
71
|
+
{
|
|
72
|
+
process: (sessionState) => {
|
|
73
|
+
const synchronizedSession = synchronizeSession(sessionState)
|
|
74
|
+
isTracked = expandOrRenewSessionState(synchronizedSession)
|
|
75
|
+
return synchronizedSession
|
|
76
|
+
},
|
|
77
|
+
after: (sessionState) => {
|
|
78
|
+
if (isTracked && !hasSessionInCache()) {
|
|
79
|
+
renewSessionInCache(sessionState)
|
|
80
|
+
}
|
|
81
|
+
sessionCache = sessionState
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
sessionStoreStrategy
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function expandSession() {
|
|
89
|
+
processSessionStoreOperations(
|
|
90
|
+
{
|
|
91
|
+
process: (sessionState) => (hasSessionInCache() ? synchronizeSession(sessionState) : undefined),
|
|
92
|
+
},
|
|
93
|
+
sessionStoreStrategy
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* allows two behaviors:
|
|
99
|
+
* - if the session is active, synchronize the session cache without updating the session store
|
|
100
|
+
* - if the session is not active, clear the session store and expire the session cache
|
|
101
|
+
*/
|
|
102
|
+
function watchSession() {
|
|
103
|
+
processSessionStoreOperations(
|
|
104
|
+
{
|
|
105
|
+
process: (sessionState) => (!isActiveSession(sessionState) ? {} : undefined),
|
|
106
|
+
after: synchronizeSession,
|
|
107
|
+
},
|
|
108
|
+
sessionStoreStrategy
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function synchronizeSession(sessionState: SessionState) {
|
|
113
|
+
if (!isActiveSession(sessionState)) {
|
|
114
|
+
sessionState = {}
|
|
115
|
+
}
|
|
116
|
+
if (hasSessionInCache()) {
|
|
117
|
+
if (isSessionInCacheOutdated(sessionState)) {
|
|
118
|
+
expireSessionInCache()
|
|
119
|
+
} else {
|
|
120
|
+
sessionCache = sessionState
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return sessionState
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function expandOrRenewSessionState(sessionState: SessionState) {
|
|
127
|
+
const { trackingType, isTracked } = computeSessionState(sessionState[productKey])
|
|
128
|
+
sessionState[productKey] = trackingType
|
|
129
|
+
if (isTracked && !sessionState.id) {
|
|
130
|
+
sessionState.id = generateUUID()
|
|
131
|
+
sessionState.created = String(dateNow())
|
|
132
|
+
}
|
|
133
|
+
return isTracked
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function hasSessionInCache() {
|
|
137
|
+
return sessionCache[productKey] !== undefined
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function isSessionInCacheOutdated(sessionState: SessionState) {
|
|
141
|
+
return sessionCache.id !== sessionState.id || sessionCache[productKey] !== sessionState[productKey]
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function expireSessionInCache() {
|
|
145
|
+
sessionCache = {}
|
|
146
|
+
expireObservable.notify()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function renewSessionInCache(sessionState: SessionState) {
|
|
150
|
+
sessionCache = sessionState
|
|
151
|
+
renewObservable.notify()
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function retrieveActiveSession(): SessionState {
|
|
155
|
+
const session = retrieveSession()
|
|
156
|
+
if (isActiveSession(session)) {
|
|
157
|
+
return session
|
|
158
|
+
}
|
|
159
|
+
return {}
|
|
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))
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
expandOrRenewSession: throttle(expandOrRenewSession, STORAGE_POLL_DELAY).throttled,
|
|
173
|
+
expandSession,
|
|
174
|
+
getSession: () => sessionCache,
|
|
175
|
+
renewObservable,
|
|
176
|
+
expireObservable,
|
|
177
|
+
expire: () => {
|
|
178
|
+
clearSession()
|
|
179
|
+
synchronizeSession({})
|
|
180
|
+
},
|
|
181
|
+
stop: () => {
|
|
182
|
+
clearInterval(watchSessionTimeoutId)
|
|
183
|
+
},
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { setTimeout } from '../../tools/timer'
|
|
2
|
+
import { generateUUID } from '../../tools/utils/stringUtils'
|
|
3
|
+
import { isChromium } from '../../tools/utils/browserDetection'
|
|
4
|
+
import type { SessionStoreStrategy } from './storeStrategies/sessionStoreStrategy'
|
|
5
|
+
import type { SessionState } from './sessionState'
|
|
6
|
+
import { expandSessionState, isSessionInExpiredState } from './sessionState'
|
|
7
|
+
|
|
8
|
+
type Operations = {
|
|
9
|
+
process: (sessionState: SessionState) => SessionState | undefined
|
|
10
|
+
after?: (sessionState: SessionState) => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const LOCK_RETRY_DELAY = 10
|
|
14
|
+
export const LOCK_MAX_TRIES = 100
|
|
15
|
+
const bufferedOperations: Operations[] = []
|
|
16
|
+
let ongoingOperations: Operations | undefined
|
|
17
|
+
|
|
18
|
+
export function processSessionStoreOperations(
|
|
19
|
+
operations: Operations,
|
|
20
|
+
sessionStoreStrategy: SessionStoreStrategy,
|
|
21
|
+
numberOfRetries = 0
|
|
22
|
+
) {
|
|
23
|
+
const { retrieveSession, persistSession, clearSession } = sessionStoreStrategy
|
|
24
|
+
const lockEnabled = isLockEnabled()
|
|
25
|
+
|
|
26
|
+
if (!ongoingOperations) {
|
|
27
|
+
ongoingOperations = operations
|
|
28
|
+
}
|
|
29
|
+
if (operations !== ongoingOperations) {
|
|
30
|
+
bufferedOperations.push(operations)
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
if (lockEnabled && numberOfRetries >= LOCK_MAX_TRIES) {
|
|
34
|
+
next(sessionStoreStrategy)
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
let currentLock: string
|
|
38
|
+
let currentSession = retrieveSession()
|
|
39
|
+
if (lockEnabled) {
|
|
40
|
+
// if someone has lock, retry later
|
|
41
|
+
if (currentSession.lock) {
|
|
42
|
+
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
// acquire lock
|
|
46
|
+
currentLock = generateUUID()
|
|
47
|
+
currentSession.lock = currentLock
|
|
48
|
+
persistSession(currentSession)
|
|
49
|
+
// if lock is not acquired, retry later
|
|
50
|
+
currentSession = retrieveSession()
|
|
51
|
+
if (currentSession.lock !== currentLock) {
|
|
52
|
+
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
let processedSession = operations.process(currentSession)
|
|
57
|
+
if (lockEnabled) {
|
|
58
|
+
// if lock corrupted after process, retry later
|
|
59
|
+
currentSession = retrieveSession()
|
|
60
|
+
if (currentSession.lock !== currentLock!) {
|
|
61
|
+
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (processedSession) {
|
|
66
|
+
if (isSessionInExpiredState(processedSession)) {
|
|
67
|
+
clearSession()
|
|
68
|
+
} else {
|
|
69
|
+
expandSessionState(processedSession)
|
|
70
|
+
persistSession(processedSession)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (lockEnabled) {
|
|
74
|
+
// correctly handle lock around expiration would require to handle this case properly at several levels
|
|
75
|
+
// since we don't have evidence of lock issues around expiration, let's just not do the corruption check for it
|
|
76
|
+
if (!(processedSession && isSessionInExpiredState(processedSession))) {
|
|
77
|
+
// if lock corrupted after persist, retry later
|
|
78
|
+
currentSession = retrieveSession()
|
|
79
|
+
if (currentSession.lock !== currentLock!) {
|
|
80
|
+
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
delete currentSession.lock
|
|
84
|
+
persistSession(currentSession)
|
|
85
|
+
processedSession = currentSession
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// call after even if session is not persisted in order to perform operations on
|
|
89
|
+
// up-to-date session state value => the value could have been modified by another tab
|
|
90
|
+
operations.after?.(processedSession || currentSession)
|
|
91
|
+
next(sessionStoreStrategy)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Lock strategy allows mitigating issues due to concurrent access to cookie.
|
|
96
|
+
* This issue concerns only chromium browsers and enabling this on firefox increases cookie write failures.
|
|
97
|
+
*/
|
|
98
|
+
export const isLockEnabled = () => isChromium()
|
|
99
|
+
|
|
100
|
+
function retryLater(operations: Operations, sessionStore: SessionStoreStrategy, currentNumberOfRetries: number) {
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
processSessionStoreOperations(operations, sessionStore, currentNumberOfRetries + 1)
|
|
103
|
+
}, LOCK_RETRY_DELAY)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function next(sessionStore: SessionStoreStrategy) {
|
|
107
|
+
ongoingOperations = undefined
|
|
108
|
+
const nextOperations = bufferedOperations.shift()
|
|
109
|
+
if (nextOperations) {
|
|
110
|
+
processSessionStoreOperations(nextOperations, sessionStore)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CookieOptions } from '../../../browser/cookie'
|
|
2
|
+
import { getCurrentSite, areCookiesAuthorized, deleteCookie, getCookie, setCookie } from '../../../browser/cookie'
|
|
3
|
+
import type { InitConfiguration } from '../../configuration'
|
|
4
|
+
import { tryOldCookiesMigration } from '../oldCookiesMigration'
|
|
5
|
+
import { SESSION_EXPIRATION_DELAY } from '../sessionConstants'
|
|
6
|
+
import type { SessionState } from '../sessionState'
|
|
7
|
+
import { toSessionString, toSessionState } from '../sessionState'
|
|
8
|
+
import type { SessionStoreStrategy, SessionStoreStrategyType } from './sessionStoreStrategy'
|
|
9
|
+
import { SESSION_STORE_KEY } from './sessionStoreStrategy'
|
|
10
|
+
|
|
11
|
+
export function selectCookieStrategy(initConfiguration: InitConfiguration): SessionStoreStrategyType | undefined {
|
|
12
|
+
const cookieOptions = buildCookieOptions(initConfiguration)
|
|
13
|
+
return areCookiesAuthorized(cookieOptions) ? { type: 'Cookie', cookieOptions } : undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function initCookieStrategy(cookieOptions: CookieOptions): SessionStoreStrategy {
|
|
17
|
+
const cookieStore = {
|
|
18
|
+
persistSession: persistSessionCookie(cookieOptions),
|
|
19
|
+
retrieveSession: retrieveSessionCookie,
|
|
20
|
+
clearSession: deleteSessionCookie(cookieOptions),
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
tryOldCookiesMigration(cookieStore)
|
|
24
|
+
|
|
25
|
+
return cookieStore
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function persistSessionCookie(options: CookieOptions) {
|
|
29
|
+
return (session: SessionState) => {
|
|
30
|
+
setCookie(SESSION_STORE_KEY, toSessionString(session), SESSION_EXPIRATION_DELAY, options)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function retrieveSessionCookie(): SessionState {
|
|
35
|
+
const sessionString = getCookie(SESSION_STORE_KEY)
|
|
36
|
+
return toSessionState(sessionString)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function deleteSessionCookie(options: CookieOptions) {
|
|
40
|
+
return () => {
|
|
41
|
+
deleteCookie(SESSION_STORE_KEY, options)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function buildCookieOptions(initConfiguration: InitConfiguration) {
|
|
46
|
+
const cookieOptions: CookieOptions = {}
|
|
47
|
+
|
|
48
|
+
cookieOptions.secure = !!initConfiguration.useSecureSessionCookie || !!initConfiguration.useCrossSiteSessionCookie
|
|
49
|
+
cookieOptions.crossSite = !!initConfiguration.useCrossSiteSessionCookie
|
|
50
|
+
|
|
51
|
+
if (initConfiguration.trackSessionAcrossSubdomains) {
|
|
52
|
+
cookieOptions.domain = getCurrentSite()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return cookieOptions
|
|
56
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { generateUUID } from '../../../tools/utils/stringUtils'
|
|
2
|
+
import type { SessionState } from '../sessionState'
|
|
3
|
+
import { toSessionString, toSessionState } from '../sessionState'
|
|
4
|
+
import type { SessionStoreStrategy, SessionStoreStrategyType } from './sessionStoreStrategy'
|
|
5
|
+
import { SESSION_STORE_KEY } from './sessionStoreStrategy'
|
|
6
|
+
|
|
7
|
+
const LOCAL_STORAGE_TEST_KEY = '_oo_test_'
|
|
8
|
+
|
|
9
|
+
export function selectLocalStorageStrategy(): SessionStoreStrategyType | undefined {
|
|
10
|
+
try {
|
|
11
|
+
const id = generateUUID()
|
|
12
|
+
const testKey = `${LOCAL_STORAGE_TEST_KEY}${id}`
|
|
13
|
+
localStorage.setItem(testKey, id)
|
|
14
|
+
const retrievedId = localStorage.getItem(testKey)
|
|
15
|
+
localStorage.removeItem(testKey)
|
|
16
|
+
return id === retrievedId ? { type: 'LocalStorage' } : undefined
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return undefined
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function initLocalStorageStrategy(): SessionStoreStrategy {
|
|
23
|
+
return {
|
|
24
|
+
persistSession: persistInLocalStorage,
|
|
25
|
+
retrieveSession: retrieveSessionFromLocalStorage,
|
|
26
|
+
clearSession: clearSessionFromLocalStorage,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function persistInLocalStorage(sessionState: SessionState) {
|
|
31
|
+
localStorage.setItem(SESSION_STORE_KEY, toSessionString(sessionState))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function retrieveSessionFromLocalStorage(): SessionState {
|
|
35
|
+
const sessionString = localStorage.getItem(SESSION_STORE_KEY)
|
|
36
|
+
return toSessionState(sessionString)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function clearSessionFromLocalStorage() {
|
|
40
|
+
localStorage.removeItem(SESSION_STORE_KEY)
|
|
41
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CookieOptions } from '../../../browser/cookie'
|
|
2
|
+
import type { SessionState } from '../sessionState'
|
|
3
|
+
|
|
4
|
+
export const SESSION_STORE_KEY = '_oo_s'
|
|
5
|
+
|
|
6
|
+
export type SessionStoreStrategyType = { type: 'Cookie'; cookieOptions: CookieOptions } | { type: 'LocalStorage' }
|
|
7
|
+
|
|
8
|
+
export interface SessionStoreStrategy {
|
|
9
|
+
persistSession: (session: SessionState) => void
|
|
10
|
+
retrieveSession: () => SessionState
|
|
11
|
+
clearSession: () => void
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getCookie } from '../../browser/cookie'
|
|
2
|
+
|
|
3
|
+
export const SYNTHETICS_TEST_ID_COOKIE_NAME = 'openobserve-synthetics-public-id'
|
|
4
|
+
export const SYNTHETICS_RESULT_ID_COOKIE_NAME = 'openobserve-synthetics-result-id'
|
|
5
|
+
export const SYNTHETICS_INJECTS_RUM_COOKIE_NAME = 'openobserve-synthetics-injects-rum'
|
|
6
|
+
|
|
7
|
+
export interface BrowserWindow extends Window {
|
|
8
|
+
_OO_SYNTHETICS_PUBLIC_ID?: unknown
|
|
9
|
+
_OO_SYNTHETICS_RESULT_ID?: unknown
|
|
10
|
+
_OO_SYNTHETICS_INJECTS_RUM?: unknown
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function willSyntheticsInjectRum(): boolean {
|
|
14
|
+
return Boolean(
|
|
15
|
+
(window as BrowserWindow)._OO_SYNTHETICS_INJECTS_RUM || getCookie(SYNTHETICS_INJECTS_RUM_COOKIE_NAME)
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getSyntheticsTestId(): string | undefined {
|
|
20
|
+
const value = (window as BrowserWindow)._OO_SYNTHETICS_PUBLIC_ID || getCookie(SYNTHETICS_TEST_ID_COOKIE_NAME)
|
|
21
|
+
return typeof value === 'string' ? value : undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getSyntheticsResultId(): string | undefined {
|
|
25
|
+
const value = (window as BrowserWindow)._OO_SYNTHETICS_RESULT_ID || getCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME)
|
|
26
|
+
return typeof value === 'string' ? value : undefined
|
|
27
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Telemetry,
|
|
3
|
+
TelemetryService,
|
|
4
|
+
addTelemetryDebug,
|
|
5
|
+
addTelemetryError,
|
|
6
|
+
startFakeTelemetry,
|
|
7
|
+
resetTelemetry,
|
|
8
|
+
startTelemetry,
|
|
9
|
+
isTelemetryReplicationAllowed,
|
|
10
|
+
addTelemetryConfiguration,
|
|
11
|
+
} from './telemetry'
|
|
12
|
+
|
|
13
|
+
export * from './rawTelemetryEvent.types'
|
|
14
|
+
export * from './telemetryEvent.types'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TelemetryEvent, TelemetryConfigurationEvent } from './telemetryEvent.types'
|
|
2
|
+
|
|
3
|
+
export const TelemetryType = {
|
|
4
|
+
log: 'log',
|
|
5
|
+
configuration: 'configuration',
|
|
6
|
+
} as const
|
|
7
|
+
|
|
8
|
+
export const enum StatusType {
|
|
9
|
+
debug = 'debug',
|
|
10
|
+
error = 'error',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type RawTelemetryEvent = TelemetryEvent['telemetry']
|
|
14
|
+
export type RawTelemetryConfiguration = TelemetryConfigurationEvent['telemetry']['configuration']
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import type { Context } from '../../tools/serialisation/context'
|
|
2
|
+
import { ConsoleApiName } from '../../tools/display'
|
|
3
|
+
import { toStackTraceString, NO_ERROR_STACK_PRESENT_MESSAGE } from '../error/error'
|
|
4
|
+
import { getExperimentalFeatures } from '../../tools/experimentalFeatures'
|
|
5
|
+
import type { Configuration } from '../configuration'
|
|
6
|
+
import { INTAKE_SITE_STAGING, INTAKE_SITE_US1_FED } from '../configuration'
|
|
7
|
+
import type { StackTrace } from '../tracekit'
|
|
8
|
+
import { computeStackTrace } from '../tracekit'
|
|
9
|
+
import { Observable } from '../../tools/observable'
|
|
10
|
+
import { timeStampNow } from '../../tools/utils/timeUtils'
|
|
11
|
+
import { displayIfDebugEnabled, startMonitorErrorCollection } from '../../tools/monitor'
|
|
12
|
+
import { sendToExtension } from '../../tools/sendToExtension'
|
|
13
|
+
import { startsWith, arrayFrom, includes, assign } from '../../tools/utils/polyfills'
|
|
14
|
+
import { performDraw } from '../../tools/utils/numberUtils'
|
|
15
|
+
import { jsonStringify } from '../../tools/serialisation/jsonStringify'
|
|
16
|
+
import { combine } from '../../tools/mergeInto'
|
|
17
|
+
import { NonErrorPrefix } from '../error/error.types'
|
|
18
|
+
import type { TelemetryEvent } from './telemetryEvent.types'
|
|
19
|
+
import type { RawTelemetryConfiguration, RawTelemetryEvent } from './rawTelemetryEvent.types'
|
|
20
|
+
import { StatusType, TelemetryType } from './rawTelemetryEvent.types'
|
|
21
|
+
|
|
22
|
+
// replaced at build time
|
|
23
|
+
declare const __BUILD_ENV__SDK_VERSION__: string
|
|
24
|
+
|
|
25
|
+
const ALLOWED_FRAME_URLS = [
|
|
26
|
+
'http://localhost',
|
|
27
|
+
'<anonymous>',
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
export const enum TelemetryService {
|
|
31
|
+
LOGS = 'browser-logs-sdk',
|
|
32
|
+
RUM = 'browser-rum-sdk',
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface Telemetry {
|
|
36
|
+
setContextProvider: (provider: () => Context) => void
|
|
37
|
+
observable: Observable<TelemetryEvent & Context>
|
|
38
|
+
enabled: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const TELEMETRY_EXCLUDED_SITES: string[] = [INTAKE_SITE_US1_FED]
|
|
42
|
+
|
|
43
|
+
const telemetryConfiguration: {
|
|
44
|
+
maxEventsPerPage: number
|
|
45
|
+
sentEventCount: number
|
|
46
|
+
telemetryEnabled: boolean
|
|
47
|
+
telemetryConfigurationEnabled: boolean
|
|
48
|
+
} = { maxEventsPerPage: 0, sentEventCount: 0, telemetryEnabled: false, telemetryConfigurationEnabled: false }
|
|
49
|
+
|
|
50
|
+
let onRawTelemetryEventCollected: ((event: RawTelemetryEvent) => void) | undefined
|
|
51
|
+
|
|
52
|
+
export function startTelemetry(telemetryService: TelemetryService, configuration: Configuration): Telemetry {
|
|
53
|
+
let contextProvider: () => Context
|
|
54
|
+
const observable = new Observable<TelemetryEvent & Context>()
|
|
55
|
+
|
|
56
|
+
telemetryConfiguration.telemetryEnabled =
|
|
57
|
+
!includes(TELEMETRY_EXCLUDED_SITES, configuration.site) && performDraw(configuration.telemetrySampleRate)
|
|
58
|
+
telemetryConfiguration.telemetryConfigurationEnabled =
|
|
59
|
+
telemetryConfiguration.telemetryEnabled && performDraw(configuration.telemetryConfigurationSampleRate)
|
|
60
|
+
|
|
61
|
+
onRawTelemetryEventCollected = (rawEvent: RawTelemetryEvent) => {
|
|
62
|
+
if (telemetryConfiguration.telemetryEnabled) {
|
|
63
|
+
const event = toTelemetryEvent(telemetryService, rawEvent)
|
|
64
|
+
observable.notify(event)
|
|
65
|
+
sendToExtension('telemetry', event)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
startMonitorErrorCollection(addTelemetryError)
|
|
69
|
+
|
|
70
|
+
assign(telemetryConfiguration, {
|
|
71
|
+
maxEventsPerPage: configuration.maxTelemetryEventsPerPage,
|
|
72
|
+
sentEventCount: 0,
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
function toTelemetryEvent(telemetryService: TelemetryService, event: RawTelemetryEvent): TelemetryEvent & Context {
|
|
76
|
+
return combine(
|
|
77
|
+
{
|
|
78
|
+
type: 'telemetry' as const,
|
|
79
|
+
date: timeStampNow(),
|
|
80
|
+
service: telemetryService,
|
|
81
|
+
version: __BUILD_ENV__SDK_VERSION__,
|
|
82
|
+
source: 'browser' as const,
|
|
83
|
+
_oo: {
|
|
84
|
+
format_version: 2 as const,
|
|
85
|
+
},
|
|
86
|
+
telemetry: event as any, // https://github.com/microsoft/TypeScript/issues/48457
|
|
87
|
+
experimental_features: arrayFrom(getExperimentalFeatures()),
|
|
88
|
+
},
|
|
89
|
+
contextProvider !== undefined ? contextProvider() : {}
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
setContextProvider: (provider: () => Context) => {
|
|
95
|
+
contextProvider = provider
|
|
96
|
+
},
|
|
97
|
+
observable,
|
|
98
|
+
enabled: telemetryConfiguration.telemetryEnabled,
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function startFakeTelemetry() {
|
|
103
|
+
const events: RawTelemetryEvent[] = []
|
|
104
|
+
assign(telemetryConfiguration, {
|
|
105
|
+
maxEventsPerPage: Infinity,
|
|
106
|
+
sentEventCount: 0,
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
onRawTelemetryEventCollected = (event: RawTelemetryEvent) => {
|
|
110
|
+
events.push(event)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return events
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function resetTelemetry() {
|
|
117
|
+
onRawTelemetryEventCollected = undefined
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Avoid mixing telemetry events from different data centers
|
|
122
|
+
* but keep replicating staging events for reliability
|
|
123
|
+
*/
|
|
124
|
+
export function isTelemetryReplicationAllowed(configuration: Configuration) {
|
|
125
|
+
return configuration.site === INTAKE_SITE_STAGING
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function addTelemetryDebug(message: string, context?: Context) {
|
|
129
|
+
displayIfDebugEnabled(ConsoleApiName.debug, message, context)
|
|
130
|
+
addTelemetry(
|
|
131
|
+
assign(
|
|
132
|
+
{
|
|
133
|
+
type: TelemetryType.log,
|
|
134
|
+
message,
|
|
135
|
+
status: StatusType.debug,
|
|
136
|
+
},
|
|
137
|
+
context
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function addTelemetryError(e: unknown, context?: Context) {
|
|
143
|
+
addTelemetry(
|
|
144
|
+
assign(
|
|
145
|
+
{
|
|
146
|
+
type: TelemetryType.log,
|
|
147
|
+
status: StatusType.error,
|
|
148
|
+
},
|
|
149
|
+
formatError(e),
|
|
150
|
+
context
|
|
151
|
+
)
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function addTelemetryConfiguration(configuration: RawTelemetryConfiguration) {
|
|
156
|
+
if (telemetryConfiguration.telemetryConfigurationEnabled) {
|
|
157
|
+
addTelemetry({
|
|
158
|
+
type: TelemetryType.configuration,
|
|
159
|
+
configuration,
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function addTelemetry(event: RawTelemetryEvent) {
|
|
165
|
+
if (onRawTelemetryEventCollected && telemetryConfiguration.sentEventCount < telemetryConfiguration.maxEventsPerPage) {
|
|
166
|
+
telemetryConfiguration.sentEventCount += 1
|
|
167
|
+
onRawTelemetryEventCollected(event)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function formatError(e: unknown) {
|
|
172
|
+
if (e instanceof Error) {
|
|
173
|
+
const stackTrace = computeStackTrace(e)
|
|
174
|
+
return {
|
|
175
|
+
error: {
|
|
176
|
+
kind: stackTrace.name,
|
|
177
|
+
stack: toStackTraceString(scrubCustomerFrames(stackTrace)),
|
|
178
|
+
},
|
|
179
|
+
message: stackTrace.message!,
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
error: {
|
|
184
|
+
stack: NO_ERROR_STACK_PRESENT_MESSAGE,
|
|
185
|
+
},
|
|
186
|
+
message: `${NonErrorPrefix.UNCAUGHT} ${jsonStringify(e)!}`,
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function scrubCustomerFrames(stackTrace: StackTrace) {
|
|
191
|
+
stackTrace.stack = stackTrace.stack.filter(
|
|
192
|
+
(frame) => !frame.url || ALLOWED_FRAME_URLS.some((allowedFrameUrl) => startsWith(frame.url!, allowedFrameUrl))
|
|
193
|
+
)
|
|
194
|
+
return stackTrace
|
|
195
|
+
}
|