@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,255 @@
|
|
|
1
|
+
import { display } from '../display'
|
|
2
|
+
import { ONE_KIBI_BYTE } from '../utils/byteUtils'
|
|
3
|
+
import type { Context, ContextArray, ContextValue } from './context'
|
|
4
|
+
import type { ObjectWithToJsonMethod } from './jsonStringify'
|
|
5
|
+
import { detachToJsonMethod } from './jsonStringify'
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
8
|
+
type PrimitivesAndFunctions = string | number | boolean | undefined | null | symbol | bigint | Function
|
|
9
|
+
type ExtendedContextValue = PrimitivesAndFunctions | object | ExtendedContext | ExtendedContextArray
|
|
10
|
+
type ExtendedContext = { [key: string]: ExtendedContextValue }
|
|
11
|
+
type ExtendedContextArray = ExtendedContextValue[]
|
|
12
|
+
|
|
13
|
+
type ContainerElementToProcess = {
|
|
14
|
+
source: ExtendedContextArray | ExtendedContext
|
|
15
|
+
target: ContextArray | Context
|
|
16
|
+
path: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// The maximum size of a single event is 256KiB. By default, we ensure that user-provided data
|
|
20
|
+
// going through sanitize fits inside our events, while leaving room for other contexts, metadata, ...
|
|
21
|
+
const SANITIZE_DEFAULT_MAX_CHARACTER_COUNT = 220 * ONE_KIBI_BYTE
|
|
22
|
+
|
|
23
|
+
// Symbol for the root element of the JSONPath used for visited objects
|
|
24
|
+
const JSON_PATH_ROOT_ELEMENT = '$'
|
|
25
|
+
|
|
26
|
+
// When serializing (using JSON.stringify) a key of an object, { key: 42 } gets wrapped in quotes as "key".
|
|
27
|
+
// With the separator (:), we need to add 3 characters to the count.
|
|
28
|
+
const KEY_DECORATION_LENGTH = 3
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Ensures user-provided data is 'safe' for the SDK
|
|
32
|
+
* - Deep clones data
|
|
33
|
+
* - Removes cyclic references
|
|
34
|
+
* - Transforms unserializable types to a string representation
|
|
35
|
+
*
|
|
36
|
+
* LIMITATIONS:
|
|
37
|
+
* - Size is in characters, not byte count (may differ according to character encoding)
|
|
38
|
+
* - Size does not take into account indentation that can be applied to JSON.stringify
|
|
39
|
+
* - Non-numerical properties of Arrays are ignored. Same behavior as JSON.stringify
|
|
40
|
+
*
|
|
41
|
+
* @param source User-provided data meant to be serialized using JSON.stringify
|
|
42
|
+
* @param maxCharacterCount Maximum number of characters allowed in serialized form
|
|
43
|
+
*/
|
|
44
|
+
export function sanitize(source: string, maxCharacterCount?: number): string | undefined
|
|
45
|
+
export function sanitize(source: Context, maxCharacterCount?: number): Context
|
|
46
|
+
export function sanitize(source: unknown, maxCharacterCount?: number): ContextValue
|
|
47
|
+
export function sanitize(source: unknown, maxCharacterCount = SANITIZE_DEFAULT_MAX_CHARACTER_COUNT) {
|
|
48
|
+
// Unbind any toJSON function we may have on [] or {} prototypes
|
|
49
|
+
const restoreObjectPrototypeToJson = detachToJsonMethod(Object.prototype)
|
|
50
|
+
const restoreArrayPrototypeToJson = detachToJsonMethod(Array.prototype)
|
|
51
|
+
|
|
52
|
+
// Initial call to sanitizeProcessor - will populate containerQueue if source is an Array or a plain Object
|
|
53
|
+
const containerQueue: ContainerElementToProcess[] = []
|
|
54
|
+
const visitedObjectsWithPath = new WeakMap<object, string>()
|
|
55
|
+
const sanitizedData = sanitizeProcessor(
|
|
56
|
+
source as ExtendedContextValue,
|
|
57
|
+
JSON_PATH_ROOT_ELEMENT,
|
|
58
|
+
undefined,
|
|
59
|
+
containerQueue,
|
|
60
|
+
visitedObjectsWithPath
|
|
61
|
+
)
|
|
62
|
+
let accumulatedCharacterCount = JSON.stringify(sanitizedData)?.length || 0
|
|
63
|
+
if (accumulatedCharacterCount > maxCharacterCount) {
|
|
64
|
+
warnOverCharacterLimit(maxCharacterCount, 'discarded', source)
|
|
65
|
+
return undefined
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
while (containerQueue.length > 0 && accumulatedCharacterCount < maxCharacterCount) {
|
|
69
|
+
const containerToProcess = containerQueue.shift()!
|
|
70
|
+
let separatorLength = 0 // 0 for the first element, 1 for subsequent elements
|
|
71
|
+
|
|
72
|
+
// Arrays and Objects have to be handled distinctly to ensure
|
|
73
|
+
// we do not pick up non-numerical properties from Arrays
|
|
74
|
+
if (Array.isArray(containerToProcess.source)) {
|
|
75
|
+
for (let key = 0; key < containerToProcess.source.length; key++) {
|
|
76
|
+
const targetData = sanitizeProcessor(
|
|
77
|
+
containerToProcess.source[key],
|
|
78
|
+
containerToProcess.path,
|
|
79
|
+
key,
|
|
80
|
+
containerQueue,
|
|
81
|
+
visitedObjectsWithPath
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
if (targetData !== undefined) {
|
|
85
|
+
accumulatedCharacterCount += JSON.stringify(targetData).length
|
|
86
|
+
} else {
|
|
87
|
+
// When an element of an Array (targetData) is undefined, it is serialized as null:
|
|
88
|
+
// JSON.stringify([undefined]) => '[null]' - This accounts for 4 characters
|
|
89
|
+
accumulatedCharacterCount += 4
|
|
90
|
+
}
|
|
91
|
+
accumulatedCharacterCount += separatorLength
|
|
92
|
+
separatorLength = 1
|
|
93
|
+
if (accumulatedCharacterCount > maxCharacterCount) {
|
|
94
|
+
warnOverCharacterLimit(maxCharacterCount, 'truncated', source)
|
|
95
|
+
break
|
|
96
|
+
}
|
|
97
|
+
;(containerToProcess.target as ContextArray)[key] = targetData
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
for (const key in containerToProcess.source) {
|
|
101
|
+
if (Object.prototype.hasOwnProperty.call(containerToProcess.source, key)) {
|
|
102
|
+
const targetData = sanitizeProcessor(
|
|
103
|
+
containerToProcess.source[key],
|
|
104
|
+
containerToProcess.path,
|
|
105
|
+
key,
|
|
106
|
+
containerQueue,
|
|
107
|
+
visitedObjectsWithPath
|
|
108
|
+
)
|
|
109
|
+
// When a property of an object has an undefined value, it will be dropped during serialization:
|
|
110
|
+
// JSON.stringify({a:undefined}) => '{}'
|
|
111
|
+
if (targetData !== undefined) {
|
|
112
|
+
accumulatedCharacterCount +=
|
|
113
|
+
JSON.stringify(targetData).length + separatorLength + key.length + KEY_DECORATION_LENGTH
|
|
114
|
+
separatorLength = 1
|
|
115
|
+
}
|
|
116
|
+
if (accumulatedCharacterCount > maxCharacterCount) {
|
|
117
|
+
warnOverCharacterLimit(maxCharacterCount, 'truncated', source)
|
|
118
|
+
break
|
|
119
|
+
}
|
|
120
|
+
;(containerToProcess.target as Context)[key] = targetData
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Rebind detached toJSON functions
|
|
127
|
+
restoreObjectPrototypeToJson()
|
|
128
|
+
restoreArrayPrototypeToJson()
|
|
129
|
+
|
|
130
|
+
return sanitizedData
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Internal function to factorize the process common to the
|
|
135
|
+
* initial call to sanitize, and iterations for Arrays and Objects
|
|
136
|
+
*
|
|
137
|
+
*/
|
|
138
|
+
function sanitizeProcessor(
|
|
139
|
+
source: ExtendedContextValue,
|
|
140
|
+
parentPath: string,
|
|
141
|
+
key: string | number | undefined,
|
|
142
|
+
queue: ContainerElementToProcess[],
|
|
143
|
+
visitedObjectsWithPath: WeakMap<object, string>
|
|
144
|
+
) {
|
|
145
|
+
// Start by handling toJSON, as we want to sanitize its output
|
|
146
|
+
const sourceToSanitize = tryToApplyToJSON(source)
|
|
147
|
+
|
|
148
|
+
if (!sourceToSanitize || typeof sourceToSanitize !== 'object') {
|
|
149
|
+
return sanitizePrimitivesAndFunctions(sourceToSanitize)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const sanitizedSource = sanitizeObjects(sourceToSanitize)
|
|
153
|
+
if (sanitizedSource !== '[Object]' && sanitizedSource !== '[Array]' && sanitizedSource !== '[Error]') {
|
|
154
|
+
return sanitizedSource
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Handle potential cyclic references
|
|
158
|
+
// We need to use source as sourceToSanitize could be a reference to a new object
|
|
159
|
+
// At this stage, we know the source is an object type
|
|
160
|
+
const sourceAsObject = source as object
|
|
161
|
+
if (visitedObjectsWithPath.has(sourceAsObject)) {
|
|
162
|
+
return `[Reference seen at ${visitedObjectsWithPath.get(sourceAsObject)!}]`
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Add processed source to queue
|
|
166
|
+
const currentPath = key !== undefined ? `${parentPath}.${key}` : parentPath
|
|
167
|
+
const target = Array.isArray(sourceToSanitize) ? ([] as ContextArray) : ({} as Context)
|
|
168
|
+
visitedObjectsWithPath.set(sourceAsObject, currentPath)
|
|
169
|
+
queue.push({ source: sourceToSanitize as ExtendedContext | ExtendedContextArray, target, path: currentPath })
|
|
170
|
+
|
|
171
|
+
return target
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Handles sanitization of simple, non-object types
|
|
176
|
+
*
|
|
177
|
+
*/
|
|
178
|
+
function sanitizePrimitivesAndFunctions(value: PrimitivesAndFunctions) {
|
|
179
|
+
// BigInt cannot be serialized by JSON.stringify(), convert it to a string representation
|
|
180
|
+
if (typeof value === 'bigint') {
|
|
181
|
+
return `[BigInt] ${value.toString()}`
|
|
182
|
+
}
|
|
183
|
+
// Functions cannot be serialized by JSON.stringify(). Moreover, if a faulty toJSON is present, it needs to be converted
|
|
184
|
+
// so it won't prevent stringify from serializing later
|
|
185
|
+
if (typeof value === 'function') {
|
|
186
|
+
return `[Function] ${value.name || 'unknown'}`
|
|
187
|
+
}
|
|
188
|
+
// JSON.stringify() does not serialize symbols.
|
|
189
|
+
if (typeof value === 'symbol') {
|
|
190
|
+
// symbol.description is part of ES2019+
|
|
191
|
+
type symbolWithDescription = symbol & { description: string }
|
|
192
|
+
return `[Symbol] ${(value as symbolWithDescription).description || value.toString()}`
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return value
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Handles sanitization of object types
|
|
200
|
+
*
|
|
201
|
+
* LIMITATIONS
|
|
202
|
+
* - If a class defines a toStringTag Symbol, it will fall in the catch-all method and prevent enumeration of properties.
|
|
203
|
+
* To avoid this, a toJSON method can be defined.
|
|
204
|
+
* - IE11 does not return a distinct type for objects such as Map, WeakMap, ... These objects will pass through and their
|
|
205
|
+
* properties enumerated if any.
|
|
206
|
+
*
|
|
207
|
+
*/
|
|
208
|
+
function sanitizeObjects(value: object) {
|
|
209
|
+
try {
|
|
210
|
+
// Handle events - Keep a simple implementation to avoid breaking changes
|
|
211
|
+
if (value instanceof Event) {
|
|
212
|
+
return {
|
|
213
|
+
isTrusted: value.isTrusted,
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Handle all remaining object types in a generic way
|
|
218
|
+
const result = Object.prototype.toString.call(value)
|
|
219
|
+
const match = result.match(/\[object (.*)\]/)
|
|
220
|
+
if (match && match[1]) {
|
|
221
|
+
return `[${match[1]}]`
|
|
222
|
+
}
|
|
223
|
+
} catch {
|
|
224
|
+
// If the previous serialization attempts failed, and we cannot convert using
|
|
225
|
+
// Object.prototype.toString, declare the value unserializable
|
|
226
|
+
}
|
|
227
|
+
return '[Unserializable]'
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Checks if a toJSON function exists and tries to execute it
|
|
232
|
+
*
|
|
233
|
+
*/
|
|
234
|
+
function tryToApplyToJSON(value: ExtendedContextValue) {
|
|
235
|
+
const object = value as ObjectWithToJsonMethod
|
|
236
|
+
if (object && typeof object.toJSON === 'function') {
|
|
237
|
+
try {
|
|
238
|
+
return object.toJSON() as ExtendedContextValue
|
|
239
|
+
} catch {
|
|
240
|
+
// If toJSON fails, we continue by trying to serialize the value manually
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return value
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Helper function to display the warning when the accumulated character count is over the limit
|
|
249
|
+
*/
|
|
250
|
+
function warnOverCharacterLimit(maxCharacterCount: number, changeType: 'discarded' | 'truncated', source: unknown) {
|
|
251
|
+
display.warn(
|
|
252
|
+
`The data provided has been ${changeType} as it is over the limit of ${maxCharacterCount} characters:`,
|
|
253
|
+
source
|
|
254
|
+
)
|
|
255
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getZoneJsOriginalValue } from './getZoneJsOriginalValue'
|
|
2
|
+
import { monitor } from './monitor'
|
|
3
|
+
import { getGlobalObject } from './getGlobalObject'
|
|
4
|
+
|
|
5
|
+
export type TimeoutId = ReturnType<typeof globalThis.setTimeout>
|
|
6
|
+
|
|
7
|
+
export function setTimeout(callback: () => void, delay?: number): TimeoutId {
|
|
8
|
+
return getZoneJsOriginalValue(getGlobalObject(), 'setTimeout')(monitor(callback), delay)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function clearTimeout(timeoutId: TimeoutId | undefined) {
|
|
12
|
+
getZoneJsOriginalValue(getGlobalObject(), 'clearTimeout')(timeoutId)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function setInterval(callback: () => void, delay?: number): TimeoutId {
|
|
16
|
+
return getZoneJsOriginalValue(getGlobalObject(), 'setInterval')(monitor(callback), delay)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function clearInterval(timeoutId: TimeoutId | undefined) {
|
|
20
|
+
getZoneJsOriginalValue(getGlobalObject(), 'clearInterval')(timeoutId)
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const ONE_KIBI_BYTE = 1024
|
|
2
|
+
export const ONE_MEBI_BYTE = 1024 * ONE_KIBI_BYTE
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line no-control-regex
|
|
5
|
+
const HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/
|
|
6
|
+
|
|
7
|
+
export function computeBytesCount(candidate: string): number {
|
|
8
|
+
// Accurate bytes count computations can degrade performances when there is a lot of events to process
|
|
9
|
+
if (!HAS_MULTI_BYTES_CHARACTERS.test(candidate)) {
|
|
10
|
+
return candidate.length
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (window.TextEncoder !== undefined) {
|
|
14
|
+
return new TextEncoder().encode(candidate).length
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return new Blob([candidate]).size
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function concatBuffers(buffers: Uint8Array[]) {
|
|
21
|
+
const length = buffers.reduce((total, buffer) => total + buffer.length, 0)
|
|
22
|
+
const result = new Uint8Array(length)
|
|
23
|
+
let offset = 0
|
|
24
|
+
for (const buffer of buffers) {
|
|
25
|
+
result.set(buffer, offset)
|
|
26
|
+
offset += buffer.length
|
|
27
|
+
}
|
|
28
|
+
return result
|
|
29
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { TimeoutId } from '../timer'
|
|
2
|
+
import { setTimeout, clearTimeout } from '../timer'
|
|
3
|
+
|
|
4
|
+
// use lodash API
|
|
5
|
+
export function throttle<T extends (...args: any[]) => void>(
|
|
6
|
+
fn: T,
|
|
7
|
+
wait: number,
|
|
8
|
+
options?: { leading?: boolean; trailing?: boolean }
|
|
9
|
+
) {
|
|
10
|
+
const needLeadingExecution = options && options.leading !== undefined ? options.leading : true
|
|
11
|
+
const needTrailingExecution = options && options.trailing !== undefined ? options.trailing : true
|
|
12
|
+
let inWaitPeriod = false
|
|
13
|
+
let pendingExecutionWithParameters: Parameters<T> | undefined
|
|
14
|
+
let pendingTimeoutId: TimeoutId
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
throttled: (...parameters: Parameters<T>) => {
|
|
18
|
+
if (inWaitPeriod) {
|
|
19
|
+
pendingExecutionWithParameters = parameters
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
if (needLeadingExecution) {
|
|
23
|
+
fn(...parameters)
|
|
24
|
+
} else {
|
|
25
|
+
pendingExecutionWithParameters = parameters
|
|
26
|
+
}
|
|
27
|
+
inWaitPeriod = true
|
|
28
|
+
pendingTimeoutId = setTimeout(() => {
|
|
29
|
+
if (needTrailingExecution && pendingExecutionWithParameters) {
|
|
30
|
+
fn(...pendingExecutionWithParameters)
|
|
31
|
+
}
|
|
32
|
+
inWaitPeriod = false
|
|
33
|
+
pendingExecutionWithParameters = undefined
|
|
34
|
+
}, wait)
|
|
35
|
+
},
|
|
36
|
+
cancel: () => {
|
|
37
|
+
clearTimeout(pendingTimeoutId)
|
|
38
|
+
inWaitPeriod = false
|
|
39
|
+
pendingExecutionWithParameters = undefined
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
45
|
+
export function noop() {}
|
|
46
|
+
|
|
47
|
+
export type ListenerHandler = () => void
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return true if the draw is successful
|
|
3
|
+
* @param threshold between 0 and 100
|
|
4
|
+
*/
|
|
5
|
+
export function performDraw(threshold: number): boolean {
|
|
6
|
+
return threshold !== 0 && Math.random() * 100 <= threshold
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function round(num: number, decimals: 0 | 1 | 2 | 3 | 4) {
|
|
10
|
+
return +num.toFixed(decimals)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function isPercentage(value: unknown) {
|
|
14
|
+
return isNumber(value) && value >= 0 && value <= 100
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isNumber(value: unknown): value is number {
|
|
18
|
+
return typeof value === 'number'
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { assign } from './polyfills'
|
|
2
|
+
|
|
3
|
+
export function shallowClone<T>(object: T): T & Record<string, never> {
|
|
4
|
+
return assign({}, object)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function objectHasValue<T extends { [key: string]: unknown }>(object: T, value: unknown): value is T[keyof T] {
|
|
8
|
+
return Object.keys(object).some((key) => object[key] === value)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isEmptyObject(object: object) {
|
|
12
|
+
return Object.keys(object).length === 0
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function mapValues<A, B>(object: { [key: string]: A }, fn: (arg: A) => B) {
|
|
16
|
+
const newObject: { [key: string]: B } = {}
|
|
17
|
+
for (const key of Object.keys(object)) {
|
|
18
|
+
newObject[key] = fn(object[key])
|
|
19
|
+
}
|
|
20
|
+
return newObject
|
|
21
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export function includes(candidate: string, search: string): boolean
|
|
2
|
+
export function includes<T>(candidate: T[], search: T): boolean
|
|
3
|
+
export function includes(candidate: string | unknown[], search: any) {
|
|
4
|
+
return candidate.indexOf(search) !== -1
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function arrayFrom<T>(arrayLike: ArrayLike<T> | Set<T>): T[] {
|
|
8
|
+
if (Array.from) {
|
|
9
|
+
return Array.from(arrayLike)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const array = []
|
|
13
|
+
|
|
14
|
+
if (arrayLike instanceof Set) {
|
|
15
|
+
arrayLike.forEach((item) => array.push(item))
|
|
16
|
+
} else {
|
|
17
|
+
for (let i = 0; i < arrayLike.length; i++) {
|
|
18
|
+
array.push(arrayLike[i])
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return array
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function find<T, S extends T>(
|
|
26
|
+
array: ArrayLike<T>,
|
|
27
|
+
predicate: (item: T, index: number) => item is S
|
|
28
|
+
): S | undefined
|
|
29
|
+
export function find<T>(array: ArrayLike<T>, predicate: (item: T, index: number) => boolean): T | undefined
|
|
30
|
+
export function find(
|
|
31
|
+
array: ArrayLike<unknown>,
|
|
32
|
+
predicate: (item: unknown, index: number) => boolean
|
|
33
|
+
): unknown | undefined {
|
|
34
|
+
for (let i = 0; i < array.length; i += 1) {
|
|
35
|
+
const item = array[i]
|
|
36
|
+
if (predicate(item, i)) {
|
|
37
|
+
return item
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return undefined
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function findLast<T, S extends T>(
|
|
44
|
+
array: T[],
|
|
45
|
+
predicate: (item: T, index: number, array: T[]) => item is S
|
|
46
|
+
): S | undefined {
|
|
47
|
+
for (let i = array.length - 1; i >= 0; i -= 1) {
|
|
48
|
+
const item = array[i]
|
|
49
|
+
if (predicate(item, i, array)) {
|
|
50
|
+
return item
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return undefined
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function forEach<List extends { [index: number]: any }>(
|
|
57
|
+
list: List,
|
|
58
|
+
callback: (value: List[number], index: number, parent: List) => void
|
|
59
|
+
) {
|
|
60
|
+
Array.prototype.forEach.call(list, callback as any)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function objectValues<T = unknown>(object: { [key: string]: T }) {
|
|
64
|
+
return Object.keys(object).map((key) => object[key])
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function objectEntries<T = unknown>(object: { [key: string]: T }): Array<[string, T]> {
|
|
68
|
+
return Object.keys(object).map((key) => [key, object[key]])
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function startsWith(candidate: string, search: string) {
|
|
72
|
+
return candidate.slice(0, search.length) === search
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function endsWith(candidate: string, search: string) {
|
|
76
|
+
return candidate.slice(-search.length) === search
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function elementMatches(element: Element & { msMatchesSelector?(selector: string): boolean }, selector: string) {
|
|
80
|
+
if (element.matches) {
|
|
81
|
+
return element.matches(selector)
|
|
82
|
+
}
|
|
83
|
+
// IE11 support
|
|
84
|
+
if (element.msMatchesSelector) {
|
|
85
|
+
return element.msMatchesSelector(selector)
|
|
86
|
+
}
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// https://github.com/jquery/jquery/blob/a684e6ba836f7c553968d7d026ed7941e1a612d8/src/selector/escapeSelector.js
|
|
91
|
+
export function cssEscape(str: string) {
|
|
92
|
+
if (window.CSS && window.CSS.escape) {
|
|
93
|
+
return window.CSS.escape(str)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// eslint-disable-next-line no-control-regex
|
|
97
|
+
return str.replace(/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g, function (ch, asCodePoint) {
|
|
98
|
+
if (asCodePoint) {
|
|
99
|
+
// U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
|
|
100
|
+
if (ch === '\0') {
|
|
101
|
+
return '\uFFFD'
|
|
102
|
+
}
|
|
103
|
+
// Control characters and (dependent upon position) numbers get escaped as code points
|
|
104
|
+
return `${ch.slice(0, -1)}\\${ch.charCodeAt(ch.length - 1).toString(16)} `
|
|
105
|
+
}
|
|
106
|
+
// Other potentially-special ASCII characters get backslash-escaped
|
|
107
|
+
return `\\${ch}`
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface Assignable {
|
|
112
|
+
[key: string]: any
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function assign<T, U>(target: T, source: U): T & U
|
|
116
|
+
export function assign<T, U, V>(target: T, source1: U, source2: V): T & U & V
|
|
117
|
+
export function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W
|
|
118
|
+
export function assign(target: Assignable, ...toAssign: Assignable[]) {
|
|
119
|
+
toAssign.forEach((source: Assignable) => {
|
|
120
|
+
for (const key in source) {
|
|
121
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
122
|
+
target[key] = source[key]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
return target
|
|
127
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function isServerError(status: number) {
|
|
2
|
+
return status >= 500
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function tryToClone(response: Response): Response | undefined {
|
|
6
|
+
try {
|
|
7
|
+
return response.clone()
|
|
8
|
+
} catch (e) {
|
|
9
|
+
// clone can throw if the response has already been used by another instrumentation or is disturbed
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UUID v4
|
|
3
|
+
* from https://gist.github.com/jed/982883
|
|
4
|
+
*/
|
|
5
|
+
export function generateUUID(placeholder?: string): string {
|
|
6
|
+
return placeholder
|
|
7
|
+
? // eslint-disable-next-line no-bitwise
|
|
8
|
+
(parseInt(placeholder, 10) ^ ((Math.random() * 16) >> (parseInt(placeholder, 10) / 4))).toString(16)
|
|
9
|
+
: `${1e7}-${1e3}-${4e3}-${8e3}-${1e11}`.replace(/[018]/g, generateUUID)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function findCommaSeparatedValue(rawString: string, name: string) {
|
|
13
|
+
const regex = new RegExp(`(?:^|;)\\s*${name}\\s*=\\s*([^;]+)`)
|
|
14
|
+
const matches = regex.exec(rawString)
|
|
15
|
+
return matches ? matches[1] : undefined
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function safeTruncate(candidate: string, length: number, suffix = '') {
|
|
19
|
+
const lastChar = candidate.charCodeAt(length - 1)
|
|
20
|
+
const isLastCharSurrogatePair = lastChar >= 0xd800 && lastChar <= 0xdbff
|
|
21
|
+
const correctedLength = isLastCharSurrogatePair ? length + 1 : length
|
|
22
|
+
|
|
23
|
+
if (candidate.length <= correctedLength) {
|
|
24
|
+
return candidate
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return `${candidate.slice(0, correctedLength)}${suffix}`
|
|
28
|
+
}
|