@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,112 @@
|
|
|
1
|
+
import { isNumber, round } from './numberUtils'
|
|
2
|
+
|
|
3
|
+
export const ONE_SECOND = 1000
|
|
4
|
+
export const ONE_MINUTE = 60 * ONE_SECOND
|
|
5
|
+
export const ONE_HOUR = 60 * ONE_MINUTE
|
|
6
|
+
export const ONE_DAY = 24 * ONE_HOUR
|
|
7
|
+
export const ONE_YEAR = 365 * ONE_DAY
|
|
8
|
+
|
|
9
|
+
export type Duration = number & { d: 'Duration in ms' }
|
|
10
|
+
export type ServerDuration = number & { s: 'Duration in ns' }
|
|
11
|
+
export type TimeStamp = number & { t: 'Epoch time' }
|
|
12
|
+
export type RelativeTime = number & { r: 'Time relative to navigation start' } & { d: 'Duration in ms' }
|
|
13
|
+
export type ClocksState = { relative: RelativeTime; timeStamp: TimeStamp }
|
|
14
|
+
|
|
15
|
+
export function relativeToClocks(relative: RelativeTime) {
|
|
16
|
+
return { relative, timeStamp: getCorrectedTimeStamp(relative) }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getCorrectedTimeStamp(relativeTime: RelativeTime) {
|
|
20
|
+
const correctedOrigin = (dateNow() - performance.now()) as TimeStamp
|
|
21
|
+
// apply correction only for positive drift
|
|
22
|
+
if (correctedOrigin > getNavigationStart()) {
|
|
23
|
+
return Math.round(addDuration(correctedOrigin, relativeTime)) as TimeStamp
|
|
24
|
+
}
|
|
25
|
+
return getTimeStamp(relativeTime)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function currentDrift() {
|
|
29
|
+
return Math.round(dateNow() - addDuration(getNavigationStart(), performance.now() as Duration))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function toServerDuration(duration: Duration): ServerDuration
|
|
33
|
+
export function toServerDuration(duration: Duration | undefined): ServerDuration | undefined
|
|
34
|
+
export function toServerDuration(duration: Duration | undefined) {
|
|
35
|
+
if (!isNumber(duration)) {
|
|
36
|
+
return duration
|
|
37
|
+
}
|
|
38
|
+
return round(duration * 1e6, 0) as ServerDuration
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function dateNow() {
|
|
42
|
+
// Do not use `Date.now` because sometimes websites are wrongly "polyfilling" it. For example, we
|
|
43
|
+
// had some users using a very old version of `datejs`, which patched `Date.now` to return a Date
|
|
44
|
+
// instance instead of a timestamp[1]. Those users are unlikely to fix this, so let's handle this
|
|
45
|
+
// case ourselves.
|
|
46
|
+
// [1]: https://github.com/datejs/Datejs/blob/97f5c7c58c5bc5accdab8aa7602b6ac56462d778/src/core-debug.js#L14-L16
|
|
47
|
+
return new Date().getTime()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function timeStampNow() {
|
|
51
|
+
return dateNow() as TimeStamp
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function relativeNow() {
|
|
55
|
+
return performance.now() as RelativeTime
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function clocksNow() {
|
|
59
|
+
return { relative: relativeNow(), timeStamp: timeStampNow() }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function clocksOrigin() {
|
|
63
|
+
return { relative: 0 as RelativeTime, timeStamp: getNavigationStart() }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function elapsed(start: TimeStamp, end: TimeStamp): Duration
|
|
67
|
+
export function elapsed(start: RelativeTime, end: RelativeTime): Duration
|
|
68
|
+
export function elapsed(start: number, end: number) {
|
|
69
|
+
return (end - start) as Duration
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function addDuration(a: TimeStamp, b: Duration): TimeStamp
|
|
73
|
+
export function addDuration(a: RelativeTime, b: Duration): RelativeTime
|
|
74
|
+
export function addDuration(a: Duration, b: Duration): Duration
|
|
75
|
+
export function addDuration(a: number, b: number) {
|
|
76
|
+
return a + b
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get the time since the navigation was started.
|
|
81
|
+
*
|
|
82
|
+
* Note: this does not use `performance.timeOrigin` because it doesn't seem to reflect the actual
|
|
83
|
+
* time on which the navigation has started: it may be much farther in the past, at least in Firefox 71.
|
|
84
|
+
* Related issue in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1429926
|
|
85
|
+
*/
|
|
86
|
+
export function getRelativeTime(timestamp: TimeStamp) {
|
|
87
|
+
return (timestamp - getNavigationStart()) as RelativeTime
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function getTimeStamp(relativeTime: RelativeTime) {
|
|
91
|
+
return Math.round(addDuration(getNavigationStart(), relativeTime)) as TimeStamp
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function looksLikeRelativeTime(time: RelativeTime | TimeStamp): time is RelativeTime {
|
|
95
|
+
return time < ONE_YEAR
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Navigation start slightly change on some rare cases
|
|
100
|
+
*/
|
|
101
|
+
let navigationStart: TimeStamp | undefined
|
|
102
|
+
|
|
103
|
+
function getNavigationStart() {
|
|
104
|
+
if (navigationStart === undefined) {
|
|
105
|
+
navigationStart = performance.timing.navigationStart as TimeStamp
|
|
106
|
+
}
|
|
107
|
+
return navigationStart
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function resetNavigationStart() {
|
|
111
|
+
navigationStart = undefined
|
|
112
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsonStringify } from '../serialisation/jsonStringify'
|
|
2
|
+
|
|
3
|
+
export function normalizeUrl(url: string) {
|
|
4
|
+
return buildUrl(url, getLocationOrigin()).href
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function isValidUrl(url: string) {
|
|
8
|
+
try {
|
|
9
|
+
return !!buildUrl(url)
|
|
10
|
+
} catch {
|
|
11
|
+
return false
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getOrigin(url: string) {
|
|
16
|
+
return getLinkElementOrigin(buildUrl(url))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getPathName(url: string) {
|
|
20
|
+
const pathname = buildUrl(url).pathname
|
|
21
|
+
return pathname[0] === '/' ? pathname : `/${pathname}`
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getSearch(url: string) {
|
|
25
|
+
return buildUrl(url).search
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getHash(url: string) {
|
|
29
|
+
return buildUrl(url).hash
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function buildUrl(url: string, base?: string) {
|
|
33
|
+
const supportedURL = getSupportedUrl()
|
|
34
|
+
if (supportedURL) {
|
|
35
|
+
try {
|
|
36
|
+
return base !== undefined ? new supportedURL(url, base) : new supportedURL(url)
|
|
37
|
+
} catch (error) {
|
|
38
|
+
throw new Error(`Failed to construct URL: ${String(error)} ${jsonStringify({ url, base })!}`)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (base === undefined && !/:/.test(url)) {
|
|
42
|
+
throw new Error(`Invalid URL: '${url}'`)
|
|
43
|
+
}
|
|
44
|
+
let doc = document
|
|
45
|
+
const anchorElement = doc.createElement('a')
|
|
46
|
+
if (base !== undefined) {
|
|
47
|
+
doc = document.implementation.createHTMLDocument('')
|
|
48
|
+
const baseElement = doc.createElement('base')
|
|
49
|
+
baseElement.href = base
|
|
50
|
+
doc.head.appendChild(baseElement)
|
|
51
|
+
doc.body.appendChild(anchorElement)
|
|
52
|
+
}
|
|
53
|
+
anchorElement.href = url
|
|
54
|
+
return anchorElement
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const originalURL = URL
|
|
58
|
+
let isURLSupported: boolean | undefined
|
|
59
|
+
function getSupportedUrl(): typeof URL | undefined {
|
|
60
|
+
if (isURLSupported === undefined) {
|
|
61
|
+
try {
|
|
62
|
+
const url = new originalURL('http://test/path')
|
|
63
|
+
isURLSupported = url.href === 'http://test/path'
|
|
64
|
+
} catch {
|
|
65
|
+
isURLSupported = false
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return isURLSupported ? originalURL : undefined
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getLocationOrigin() {
|
|
72
|
+
return getLinkElementOrigin(window.location)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Fallback
|
|
77
|
+
* On IE HTMLAnchorElement origin is not supported: https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/origin
|
|
78
|
+
* On Firefox window.location.origin is "null" for file: URIs: https://bugzilla.mozilla.org/show_bug.cgi?id=878297
|
|
79
|
+
*/
|
|
80
|
+
export function getLinkElementOrigin(element: Location | HTMLAnchorElement | URL) {
|
|
81
|
+
if (element.origin && element.origin !== 'null') {
|
|
82
|
+
return element.origin
|
|
83
|
+
}
|
|
84
|
+
const sanitizedHost = element.host.replace(/(:80|:443)$/, '')
|
|
85
|
+
return `${element.protocol}//${sanitizedHost}`
|
|
86
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { setInterval, clearInterval } from './timer'
|
|
2
|
+
import type { TimeoutId } from './timer'
|
|
3
|
+
import type { Duration, RelativeTime } from './utils/timeUtils'
|
|
4
|
+
import { addDuration, relativeNow, ONE_MINUTE } from './utils/timeUtils'
|
|
5
|
+
|
|
6
|
+
const END_OF_TIMES = Infinity as RelativeTime
|
|
7
|
+
|
|
8
|
+
export interface ValueHistoryEntry<T> {
|
|
9
|
+
startTime: RelativeTime
|
|
10
|
+
endTime: RelativeTime
|
|
11
|
+
value: T
|
|
12
|
+
remove(): void
|
|
13
|
+
close(endTime: RelativeTime): void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const CLEAR_OLD_VALUES_INTERVAL = ONE_MINUTE
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Store and keep track of values spans. This whole class assumes that values are added in
|
|
20
|
+
* chronological order (i.e. all entries have an increasing start time).
|
|
21
|
+
*/
|
|
22
|
+
export class ValueHistory<Value> {
|
|
23
|
+
private entries: Array<ValueHistoryEntry<Value>> = []
|
|
24
|
+
private clearOldValuesInterval: TimeoutId
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
private expireDelay: number,
|
|
28
|
+
private maxEntries?: number
|
|
29
|
+
) {
|
|
30
|
+
this.clearOldValuesInterval = setInterval(() => this.clearOldValues(), CLEAR_OLD_VALUES_INTERVAL)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Add a value to the history associated with a start time. Returns a reference to this newly
|
|
35
|
+
* added entry that can be removed or closed.
|
|
36
|
+
*/
|
|
37
|
+
add(value: Value, startTime: RelativeTime): ValueHistoryEntry<Value> {
|
|
38
|
+
const entry: ValueHistoryEntry<Value> = {
|
|
39
|
+
value,
|
|
40
|
+
startTime,
|
|
41
|
+
endTime: END_OF_TIMES,
|
|
42
|
+
remove: () => {
|
|
43
|
+
const index = this.entries.indexOf(entry)
|
|
44
|
+
if (index >= 0) {
|
|
45
|
+
this.entries.splice(index, 1)
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
close: (endTime: RelativeTime) => {
|
|
49
|
+
entry.endTime = endTime
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (this.maxEntries && this.entries.length >= this.maxEntries) {
|
|
54
|
+
this.entries.pop()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.entries.unshift(entry)
|
|
58
|
+
|
|
59
|
+
return entry
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Return the latest value that was active during `startTime`, or the currently active value
|
|
64
|
+
* if no `startTime` is provided. This method assumes that entries are not overlapping.
|
|
65
|
+
*/
|
|
66
|
+
find(startTime: RelativeTime = END_OF_TIMES): Value | undefined {
|
|
67
|
+
for (const entry of this.entries) {
|
|
68
|
+
if (entry.startTime <= startTime) {
|
|
69
|
+
if (startTime <= entry.endTime) {
|
|
70
|
+
return entry.value
|
|
71
|
+
}
|
|
72
|
+
break
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Helper function to close the currently active value, if any. This method assumes that entries
|
|
79
|
+
* are not overlapping.
|
|
80
|
+
*/
|
|
81
|
+
closeActive(endTime: RelativeTime) {
|
|
82
|
+
const latestEntry = this.entries[0]
|
|
83
|
+
if (latestEntry && latestEntry.endTime === END_OF_TIMES) {
|
|
84
|
+
latestEntry.close(endTime)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Return all values with an active period overlapping with the duration,
|
|
90
|
+
* or all values that were active during `startTime` if no duration is provided,
|
|
91
|
+
* or all currently active values if no `startTime` is provided.
|
|
92
|
+
*/
|
|
93
|
+
findAll(startTime: RelativeTime = END_OF_TIMES, duration = 0 as Duration): Value[] {
|
|
94
|
+
const endTime = addDuration(startTime, duration)
|
|
95
|
+
return this.entries
|
|
96
|
+
.filter((entry) => entry.startTime <= endTime && startTime <= entry.endTime)
|
|
97
|
+
.map((entry) => entry.value)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Remove all entries from this collection.
|
|
102
|
+
*/
|
|
103
|
+
reset() {
|
|
104
|
+
this.entries = []
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Stop internal garbage collection of past entries.
|
|
109
|
+
*/
|
|
110
|
+
stop() {
|
|
111
|
+
clearInterval(this.clearOldValuesInterval)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private clearOldValues() {
|
|
115
|
+
const oldTimeThreshold = relativeNow() - this.expireDelay
|
|
116
|
+
while (this.entries.length > 0 && this.entries[this.entries.length - 1].endTime < oldTimeThreshold) {
|
|
117
|
+
this.entries.pop()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { display } from '../tools/display'
|
|
2
|
+
import type { Context } from '../tools/serialisation/context'
|
|
3
|
+
import { objectValues } from '../tools/utils/polyfills'
|
|
4
|
+
import { isPageExitReason } from '../browser/pageExitObservable'
|
|
5
|
+
import { computeBytesCount } from '../tools/utils/byteUtils'
|
|
6
|
+
import { jsonStringify } from '../tools/serialisation/jsonStringify'
|
|
7
|
+
import type { HttpRequest } from './httpRequest'
|
|
8
|
+
import type { FlushController, FlushEvent } from './flushController'
|
|
9
|
+
|
|
10
|
+
export class Batch {
|
|
11
|
+
private pushOnlyBuffer: string[] = []
|
|
12
|
+
private upsertBuffer: { [key: string]: string } = {}
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
private request: HttpRequest,
|
|
16
|
+
public flushController: FlushController,
|
|
17
|
+
private messageBytesLimit: number
|
|
18
|
+
) {
|
|
19
|
+
this.flushController.flushObservable.subscribe((event) => this.flush(event))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
add(message: Context) {
|
|
23
|
+
this.addOrUpdate(message)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
upsert(message: Context, key: string) {
|
|
27
|
+
this.addOrUpdate(message, key)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private flush(event: FlushEvent) {
|
|
31
|
+
const messages = this.pushOnlyBuffer.concat(objectValues(this.upsertBuffer))
|
|
32
|
+
|
|
33
|
+
this.pushOnlyBuffer = []
|
|
34
|
+
this.upsertBuffer = {}
|
|
35
|
+
|
|
36
|
+
const payload = { data: messages.join('\n'), bytesCount: event.bytesCount, flushReason: event.reason }
|
|
37
|
+
if (isPageExitReason(event.reason)) {
|
|
38
|
+
this.request.sendOnExit(payload)
|
|
39
|
+
} else {
|
|
40
|
+
this.request.send(payload)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private addOrUpdate(message: Context, key?: string) {
|
|
45
|
+
const { processedMessage, messageBytesCount } = this.process(message)
|
|
46
|
+
|
|
47
|
+
if (messageBytesCount >= this.messageBytesLimit) {
|
|
48
|
+
display.warn(
|
|
49
|
+
`Discarded a message whose size was bigger than the maximum allowed size ${this.messageBytesLimit}KB.`
|
|
50
|
+
)
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (this.hasMessageFor(key)) {
|
|
55
|
+
this.remove(key)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
this.push(processedMessage, messageBytesCount, key)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private process(message: Context) {
|
|
62
|
+
const processedMessage = jsonStringify(message)!
|
|
63
|
+
const messageBytesCount = computeBytesCount(processedMessage)
|
|
64
|
+
return { processedMessage, messageBytesCount }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private push(processedMessage: string, messageBytesCount: number, key?: string) {
|
|
68
|
+
// If there are other messages, a '\n' will be added at serialization
|
|
69
|
+
const separatorBytesCount = this.flushController.messagesCount > 0 ? 1 : 0
|
|
70
|
+
|
|
71
|
+
this.flushController.notifyBeforeAddMessage(messageBytesCount + separatorBytesCount)
|
|
72
|
+
if (key !== undefined) {
|
|
73
|
+
this.upsertBuffer[key] = processedMessage
|
|
74
|
+
} else {
|
|
75
|
+
this.pushOnlyBuffer.push(processedMessage)
|
|
76
|
+
}
|
|
77
|
+
this.flushController.notifyAfterAddMessage()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private remove(key: string) {
|
|
81
|
+
const removedMessage = this.upsertBuffer[key]
|
|
82
|
+
delete this.upsertBuffer[key]
|
|
83
|
+
const messageBytesCount = computeBytesCount(removedMessage)
|
|
84
|
+
// If there are other messages, a '\n' will be added at serialization
|
|
85
|
+
const separatorBytesCount = this.flushController.messagesCount > 1 ? 1 : 0
|
|
86
|
+
this.flushController.notifyAfterRemoveMessage(messageBytesCount + separatorBytesCount)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private hasMessageFor(key?: string): key is string {
|
|
90
|
+
return key !== undefined && this.upsertBuffer[key] !== undefined
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { endsWith } from '../tools/utils/polyfills'
|
|
2
|
+
import { getGlobalObject } from '../tools/getGlobalObject'
|
|
3
|
+
|
|
4
|
+
export interface BrowserWindowWithEventBridge extends Window {
|
|
5
|
+
DatadogEventBridge?: DatadogEventBridge
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface DatadogEventBridge {
|
|
9
|
+
getAllowedWebViewHosts(): string
|
|
10
|
+
send(msg: string): void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getEventBridge<T, E>() {
|
|
14
|
+
const eventBridgeGlobal = getEventBridgeGlobal()
|
|
15
|
+
|
|
16
|
+
if (!eventBridgeGlobal) {
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
getAllowedWebViewHosts() {
|
|
22
|
+
return JSON.parse(eventBridgeGlobal.getAllowedWebViewHosts()) as string[]
|
|
23
|
+
},
|
|
24
|
+
send(eventType: T, event: E) {
|
|
25
|
+
eventBridgeGlobal.send(JSON.stringify({ eventType, event }))
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function canUseEventBridge(currentHost = getGlobalObject<Window>().location?.hostname): boolean {
|
|
31
|
+
const bridge = getEventBridge()
|
|
32
|
+
return (
|
|
33
|
+
!!bridge &&
|
|
34
|
+
bridge
|
|
35
|
+
.getAllowedWebViewHosts()
|
|
36
|
+
.some((allowedHost) => currentHost === allowedHost || endsWith(currentHost, `.${allowedHost}`))
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getEventBridgeGlobal() {
|
|
41
|
+
return getGlobalObject<BrowserWindowWithEventBridge>().DatadogEventBridge
|
|
42
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { PageExitEvent, PageExitReason } from '../browser/pageExitObservable'
|
|
2
|
+
import { Observable } from '../tools/observable'
|
|
3
|
+
import type { TimeoutId } from '../tools/timer'
|
|
4
|
+
import { clearTimeout, setTimeout } from '../tools/timer'
|
|
5
|
+
import type { Duration } from '../tools/utils/timeUtils'
|
|
6
|
+
|
|
7
|
+
export type FlushReason = PageExitReason | 'duration_limit' | 'bytes_limit' | 'messages_limit' | 'session_expire'
|
|
8
|
+
|
|
9
|
+
export type FlushController = ReturnType<typeof createFlushController>
|
|
10
|
+
export interface FlushEvent {
|
|
11
|
+
reason: FlushReason
|
|
12
|
+
bytesCount: number
|
|
13
|
+
messagesCount: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface FlushControllerOptions {
|
|
17
|
+
messagesLimit: number
|
|
18
|
+
bytesLimit: number
|
|
19
|
+
durationLimit: Duration
|
|
20
|
+
pageExitObservable: Observable<PageExitEvent>
|
|
21
|
+
sessionExpireObservable: Observable<void>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns a "flush controller", responsible of notifying when flushing a pool of pending data needs
|
|
26
|
+
* to happen. The implementation is designed to support both synchronous and asynchronous usages,
|
|
27
|
+
* but relies on invariants described in each method documentation to keep a coherent state.
|
|
28
|
+
*/
|
|
29
|
+
export function createFlushController({
|
|
30
|
+
messagesLimit,
|
|
31
|
+
bytesLimit,
|
|
32
|
+
durationLimit,
|
|
33
|
+
pageExitObservable,
|
|
34
|
+
sessionExpireObservable,
|
|
35
|
+
}: FlushControllerOptions) {
|
|
36
|
+
const flushObservable = new Observable<FlushEvent>()
|
|
37
|
+
|
|
38
|
+
pageExitObservable.subscribe((event) => flush(event.reason))
|
|
39
|
+
sessionExpireObservable.subscribe(() => flush('session_expire'))
|
|
40
|
+
|
|
41
|
+
let currentBytesCount = 0
|
|
42
|
+
let currentMessagesCount = 0
|
|
43
|
+
|
|
44
|
+
function flush(flushReason: FlushReason) {
|
|
45
|
+
if (currentMessagesCount === 0) {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const messagesCount = currentMessagesCount
|
|
50
|
+
const bytesCount = currentBytesCount
|
|
51
|
+
|
|
52
|
+
currentMessagesCount = 0
|
|
53
|
+
currentBytesCount = 0
|
|
54
|
+
cancelDurationLimitTimeout()
|
|
55
|
+
|
|
56
|
+
flushObservable.notify({
|
|
57
|
+
reason: flushReason,
|
|
58
|
+
messagesCount,
|
|
59
|
+
bytesCount,
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let durationLimitTimeoutId: TimeoutId | undefined
|
|
64
|
+
function scheduleDurationLimitTimeout() {
|
|
65
|
+
if (durationLimitTimeoutId === undefined) {
|
|
66
|
+
durationLimitTimeoutId = setTimeout(() => {
|
|
67
|
+
flush('duration_limit')
|
|
68
|
+
}, durationLimit)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function cancelDurationLimitTimeout() {
|
|
73
|
+
clearTimeout(durationLimitTimeoutId)
|
|
74
|
+
durationLimitTimeoutId = undefined
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
flushObservable,
|
|
79
|
+
get messagesCount() {
|
|
80
|
+
return currentMessagesCount
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Notifies that a message will be added to a pool of pending messages waiting to be flushed.
|
|
85
|
+
*
|
|
86
|
+
* This function needs to be called synchronously, right before adding the message, so no flush
|
|
87
|
+
* event can happen after `notifyBeforeAddMessage` and before adding the message.
|
|
88
|
+
*/
|
|
89
|
+
notifyBeforeAddMessage(messageBytesCount: number) {
|
|
90
|
+
if (currentBytesCount + messageBytesCount >= bytesLimit) {
|
|
91
|
+
flush('bytes_limit')
|
|
92
|
+
}
|
|
93
|
+
// Consider the message to be added now rather than in `notifyAfterAddMessage`, because if no
|
|
94
|
+
// message was added yet and `notifyAfterAddMessage` is called asynchronously, we still want
|
|
95
|
+
// to notify when a flush is needed (for example on page exit).
|
|
96
|
+
currentMessagesCount += 1
|
|
97
|
+
currentBytesCount += messageBytesCount
|
|
98
|
+
scheduleDurationLimitTimeout()
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Notifies that a message *was* added to a pool of pending messages waiting to be flushed.
|
|
103
|
+
*
|
|
104
|
+
* This function can be called asynchronously after the message was added, but in this case it
|
|
105
|
+
* should not be called if a flush event occurred in between.
|
|
106
|
+
*/
|
|
107
|
+
notifyAfterAddMessage() {
|
|
108
|
+
if (currentMessagesCount >= messagesLimit) {
|
|
109
|
+
flush('messages_limit')
|
|
110
|
+
} else if (currentBytesCount >= bytesLimit) {
|
|
111
|
+
flush('bytes_limit')
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Notifies that a message was removed from a pool of pending messages waiting to be flushed.
|
|
117
|
+
*
|
|
118
|
+
* This function needs to be called synchronously, right after removing the message, so no flush
|
|
119
|
+
* event can happen after removing the message and before `notifyAfterRemoveMessage`.
|
|
120
|
+
*/
|
|
121
|
+
notifyAfterRemoveMessage(messageBytesCount: number) {
|
|
122
|
+
currentBytesCount -= messageBytesCount
|
|
123
|
+
currentMessagesCount -= 1
|
|
124
|
+
if (currentMessagesCount === 0) {
|
|
125
|
+
cancelDurationLimitTimeout()
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
}
|
|
129
|
+
}
|