@openobserve/browser-core 0.2.9 → 0.2.11-rc1
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/cjs/boot/init.js +1 -1
- package/cjs/boot/init.js.map +1 -1
- package/cjs/browser/addEventListener.d.ts +12 -4
- package/cjs/browser/addEventListener.js +50 -8
- package/cjs/browser/addEventListener.js.map +1 -1
- package/cjs/browser/cookie.d.ts +7 -0
- package/cjs/browser/cookie.js +19 -2
- package/cjs/browser/cookie.js.map +1 -1
- package/cjs/browser/fetchObservable.js +14 -19
- package/cjs/browser/fetchObservable.js.map +1 -1
- package/cjs/browser/pageExitObservable.js +6 -7
- package/cjs/browser/pageExitObservable.js.map +1 -1
- package/cjs/browser/runOnReadyState.js +1 -1
- package/cjs/browser/runOnReadyState.js.map +1 -1
- package/cjs/browser/xhrObservable.d.ts +1 -2
- package/cjs/browser/xhrObservable.js +26 -34
- package/cjs/browser/xhrObservable.js.map +1 -1
- package/cjs/domain/configuration/configuration.d.ts +17 -12
- package/cjs/domain/configuration/configuration.js +8 -9
- package/cjs/domain/configuration/configuration.js.map +1 -1
- package/cjs/domain/configuration/endpointBuilder.d.ts +6 -10
- package/cjs/domain/configuration/endpointBuilder.js +28 -38
- package/cjs/domain/configuration/endpointBuilder.js.map +1 -1
- package/cjs/domain/configuration/index.d.ts +2 -1
- package/cjs/domain/configuration/index.js +3 -1
- package/cjs/domain/configuration/index.js.map +1 -1
- package/cjs/domain/configuration/tags.js.map +1 -1
- package/cjs/domain/configuration/transportConfiguration.js +1 -1
- package/cjs/domain/configuration/transportConfiguration.js.map +1 -1
- package/cjs/domain/connectivity/connectivity.d.ts +13 -0
- package/cjs/domain/connectivity/connectivity.js +14 -0
- package/cjs/domain/connectivity/connectivity.js.map +1 -0
- package/cjs/domain/connectivity/index.d.ts +1 -0
- package/cjs/domain/{deflate → connectivity}/index.js +1 -1
- package/cjs/domain/connectivity/index.js.map +1 -0
- package/cjs/domain/console/consoleObservable.js +4 -7
- package/cjs/domain/console/consoleObservable.js.map +1 -1
- package/cjs/domain/context/contextConstants.d.ts +5 -0
- package/cjs/domain/{tracekit/types.js → context/contextConstants.js} +1 -1
- package/cjs/domain/context/contextConstants.js.map +1 -0
- package/cjs/domain/context/contextManager.d.ts +12 -0
- package/cjs/domain/context/contextManager.js +43 -0
- package/cjs/domain/context/contextManager.js.map +1 -0
- package/cjs/domain/context/customerDataTracker.d.ts +45 -0
- package/cjs/domain/context/customerDataTracker.js +107 -0
- package/cjs/domain/context/customerDataTracker.js.map +1 -0
- package/cjs/domain/context/storeContextManager.d.ts +6 -0
- package/cjs/domain/context/storeContextManager.js +38 -0
- package/cjs/domain/context/storeContextManager.js.map +1 -0
- package/cjs/domain/deflate/types.d.ts +0 -26
- package/cjs/domain/error/computeStackTrace.d.ts +33 -0
- package/cjs/domain/{tracekit → error}/computeStackTrace.js +28 -4
- package/cjs/domain/error/computeStackTrace.js.map +1 -0
- package/cjs/domain/error/error.d.ts +1 -1
- package/cjs/domain/error/error.js +3 -3
- package/cjs/domain/error/error.js.map +1 -1
- package/cjs/domain/error/error.types.d.ts +2 -2
- package/cjs/domain/error/error.types.js.map +1 -1
- package/cjs/domain/error/trackRuntimeError.d.ts +8 -0
- package/cjs/domain/error/trackRuntimeError.js +39 -6
- package/cjs/domain/error/trackRuntimeError.js.map +1 -1
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -1
- package/cjs/domain/report/browser.types.d.ts +10 -0
- package/cjs/domain/report/reportObservable.d.ts +2 -0
- package/cjs/domain/report/reportObservable.js +7 -7
- package/cjs/domain/report/reportObservable.js.map +1 -1
- package/cjs/domain/session/oldCookiesMigration.js +4 -4
- package/cjs/domain/session/oldCookiesMigration.js.map +1 -1
- package/cjs/domain/session/sessionManager.js +2 -2
- package/cjs/domain/session/sessionManager.js.map +1 -1
- package/cjs/domain/session/sessionState.js.map +1 -1
- package/cjs/domain/session/sessionStore.js.map +1 -1
- package/cjs/domain/session/sessionStoreOperations.d.ts +0 -5
- package/cjs/domain/session/sessionStoreOperations.js +6 -14
- package/cjs/domain/session/sessionStoreOperations.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionInCookie.js +13 -2
- package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +1 -0
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.d.ts +1 -0
- package/cjs/domain/synthetics/syntheticsWorkerValues.js +3 -3
- package/cjs/domain/synthetics/syntheticsWorkerValues.js.map +1 -1
- package/cjs/domain/telemetry/rawTelemetryEvent.types.d.ts +4 -0
- package/cjs/domain/telemetry/telemetry.d.ts +5 -1
- package/cjs/domain/telemetry/telemetry.js +17 -6
- package/cjs/domain/telemetry/telemetry.js.map +1 -1
- package/cjs/domain/telemetry/telemetryEvent.types.d.ts +18 -2
- package/cjs/domain/user/user.js.map +1 -1
- package/cjs/tools/abstractLifeCycle.js.map +1 -1
- package/cjs/tools/boundedBuffer.js.map +1 -1
- package/cjs/tools/catchUserErrors.js.map +1 -1
- package/cjs/tools/display.d.ts +2 -2
- package/cjs/tools/display.js +13 -17
- package/cjs/tools/display.js.map +1 -1
- package/cjs/tools/encoder.d.ts +53 -0
- package/cjs/tools/encoder.js +41 -0
- package/cjs/tools/encoder.js.map +1 -0
- package/cjs/tools/experimentalFeatures.d.ts +3 -5
- package/cjs/tools/experimentalFeatures.js +2 -4
- package/cjs/tools/experimentalFeatures.js.map +1 -1
- package/cjs/tools/getGlobalObject.js.map +1 -1
- package/cjs/tools/getZoneJsOriginalValue.js.map +1 -1
- package/cjs/tools/instrumentMethod.d.ts +50 -10
- package/cjs/tools/instrumentMethod.js +59 -36
- package/cjs/tools/instrumentMethod.js.map +1 -1
- package/cjs/tools/matchOption.js.map +1 -1
- package/cjs/tools/mergeInto.js.map +1 -1
- package/cjs/tools/monitor.d.ts +1 -2
- package/cjs/tools/monitor.js +6 -6
- package/cjs/tools/monitor.js.map +1 -1
- package/cjs/tools/observable.d.ts +1 -1
- package/cjs/tools/observable.js +2 -3
- package/cjs/tools/observable.js.map +1 -1
- package/cjs/tools/readBytesFromStream.js.map +1 -1
- package/cjs/tools/sendToExtension.js.map +1 -1
- package/cjs/tools/serialisation/jsonStringify.d.ts +1 -2
- package/cjs/tools/serialisation/jsonStringify.js.map +1 -1
- package/cjs/tools/serialisation/sanitize.js.map +1 -1
- package/cjs/tools/utils/browserDetection.d.ts +8 -0
- package/cjs/tools/utils/browserDetection.js +33 -3
- package/cjs/tools/utils/browserDetection.js.map +1 -1
- package/cjs/tools/utils/byteUtils.js.map +1 -1
- package/cjs/tools/utils/functionUtils.js.map +1 -1
- package/cjs/tools/utils/objectUtils.js.map +1 -1
- package/cjs/tools/utils/polyfills.js.map +1 -1
- package/cjs/tools/utils/responseUtils.js.map +1 -1
- package/cjs/tools/utils/stringUtils.d.ts +1 -0
- package/cjs/tools/utils/stringUtils.js +31 -4
- package/cjs/tools/utils/stringUtils.js.map +1 -1
- package/cjs/tools/utils/timeUtils.js.map +1 -1
- package/cjs/tools/utils/typeUtils.js.map +1 -1
- package/cjs/tools/utils/urlPolyfill.js.map +1 -1
- package/cjs/tools/valueHistory.js.map +1 -1
- package/cjs/transport/batch.d.ts +5 -3
- package/cjs/transport/batch.js +73 -29
- package/cjs/transport/batch.js.map +1 -1
- package/cjs/transport/eventBridge.js.map +1 -1
- package/cjs/transport/flushController.d.ts +12 -2
- package/cjs/transport/flushController.js +22 -7
- package/cjs/transport/flushController.js.map +1 -1
- package/cjs/transport/httpRequest.d.ts +3 -2
- package/cjs/transport/httpRequest.js +21 -17
- package/cjs/transport/httpRequest.js.map +1 -1
- package/cjs/transport/sendWithRetryStrategy.d.ts +2 -2
- package/cjs/transport/sendWithRetryStrategy.js +9 -9
- package/cjs/transport/sendWithRetryStrategy.js.map +1 -1
- package/cjs/transport/startBatchWithReplica.d.ts +9 -4
- package/cjs/transport/startBatchWithReplica.js +9 -4
- package/cjs/transport/startBatchWithReplica.js.map +1 -1
- package/esm/boot/init.js +1 -1
- package/esm/boot/init.js.map +1 -1
- package/esm/browser/addEventListener.d.ts +12 -4
- package/esm/browser/addEventListener.js +49 -7
- package/esm/browser/addEventListener.js.map +1 -1
- package/esm/browser/cookie.d.ts +7 -0
- package/esm/browser/cookie.js +17 -2
- package/esm/browser/cookie.js.map +1 -1
- package/esm/browser/fetchObservable.js +15 -20
- package/esm/browser/fetchObservable.js.map +1 -1
- package/esm/browser/pageExitObservable.js +7 -8
- package/esm/browser/pageExitObservable.js.map +1 -1
- package/esm/browser/runOnReadyState.js +2 -2
- package/esm/browser/runOnReadyState.js.map +1 -1
- package/esm/browser/xhrObservable.d.ts +1 -2
- package/esm/browser/xhrObservable.js +28 -36
- package/esm/browser/xhrObservable.js.map +1 -1
- package/esm/domain/configuration/configuration.d.ts +17 -12
- package/esm/domain/configuration/configuration.js +8 -9
- package/esm/domain/configuration/configuration.js.map +1 -1
- package/esm/domain/configuration/endpointBuilder.d.ts +6 -10
- package/esm/domain/configuration/endpointBuilder.js +27 -37
- package/esm/domain/configuration/endpointBuilder.js.map +1 -1
- package/esm/domain/configuration/index.d.ts +2 -1
- package/esm/domain/configuration/index.js +1 -0
- package/esm/domain/configuration/index.js.map +1 -1
- package/esm/domain/configuration/tags.js.map +1 -1
- package/esm/domain/configuration/transportConfiguration.js +1 -1
- package/esm/domain/configuration/transportConfiguration.js.map +1 -1
- package/esm/domain/connectivity/connectivity.d.ts +13 -0
- package/esm/domain/connectivity/connectivity.js +10 -0
- package/esm/domain/connectivity/connectivity.js.map +1 -0
- package/esm/domain/connectivity/index.d.ts +1 -0
- package/esm/domain/connectivity/index.js +2 -0
- package/esm/domain/connectivity/index.js.map +1 -0
- package/esm/domain/console/consoleObservable.js +2 -5
- package/esm/domain/console/consoleObservable.js.map +1 -1
- package/esm/domain/context/contextConstants.d.ts +5 -0
- package/esm/domain/context/contextConstants.js +2 -0
- package/esm/domain/context/contextConstants.js.map +1 -0
- package/esm/domain/context/contextManager.d.ts +12 -0
- package/esm/domain/context/contextManager.js +39 -0
- package/esm/domain/context/contextManager.js.map +1 -0
- package/esm/domain/context/customerDataTracker.d.ts +45 -0
- package/esm/domain/context/customerDataTracker.js +102 -0
- package/esm/domain/context/customerDataTracker.js.map +1 -0
- package/esm/domain/context/storeContextManager.d.ts +6 -0
- package/esm/domain/context/storeContextManager.js +32 -0
- package/esm/domain/context/storeContextManager.js.map +1 -0
- package/esm/domain/deflate/types.d.ts +12 -0
- package/esm/domain/error/computeStackTrace.d.ts +33 -0
- package/esm/domain/{tracekit → error}/computeStackTrace.js +26 -3
- package/esm/domain/error/computeStackTrace.js.map +1 -0
- package/esm/domain/error/error.d.ts +1 -1
- package/esm/domain/error/error.js +1 -1
- package/esm/domain/error/error.js.map +1 -1
- package/esm/domain/error/error.types.d.ts +2 -2
- package/esm/domain/error/error.types.js.map +1 -1
- package/esm/domain/error/trackRuntimeError.d.ts +8 -0
- package/esm/domain/error/trackRuntimeError.js +35 -4
- package/esm/domain/error/trackRuntimeError.js.map +1 -1
- package/esm/domain/eventRateLimiter/createEventRateLimiter.js.map +1 -1
- package/esm/domain/report/browser.types.d.ts +10 -0
- package/esm/domain/report/reportObservable.d.ts +2 -0
- package/esm/domain/report/reportObservable.js +8 -8
- package/esm/domain/report/reportObservable.js.map +1 -1
- package/esm/domain/session/oldCookiesMigration.js +5 -5
- package/esm/domain/session/oldCookiesMigration.js.map +1 -1
- package/esm/domain/session/sessionManager.js +3 -3
- package/esm/domain/session/sessionManager.js.map +1 -1
- package/esm/domain/session/sessionState.js.map +1 -1
- package/esm/domain/session/sessionStore.js.map +1 -1
- package/esm/domain/session/sessionStoreOperations.d.ts +0 -5
- package/esm/domain/session/sessionStoreOperations.js +5 -12
- package/esm/domain/session/sessionStoreOperations.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionInCookie.js +13 -2
- package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +1 -0
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +1 -0
- package/esm/domain/synthetics/syntheticsWorkerValues.js +4 -4
- package/esm/domain/synthetics/syntheticsWorkerValues.js.map +1 -1
- package/esm/domain/telemetry/rawTelemetryEvent.types.d.ts +4 -0
- package/esm/domain/telemetry/telemetry.d.ts +5 -1
- package/esm/domain/telemetry/telemetry.js +16 -5
- package/esm/domain/telemetry/telemetry.js.map +1 -1
- package/esm/domain/telemetry/telemetryEvent.types.d.ts +18 -2
- package/esm/domain/user/user.js.map +1 -1
- package/esm/index.d.ts +9 -5
- package/esm/index.js +8 -5
- package/esm/index.js.map +1 -1
- package/esm/tools/abstractLifeCycle.js.map +1 -1
- package/esm/tools/boundedBuffer.js.map +1 -1
- package/esm/tools/catchUserErrors.js.map +1 -1
- package/esm/tools/display.d.ts +2 -2
- package/esm/tools/display.js +12 -15
- package/esm/tools/display.js.map +1 -1
- package/esm/tools/encoder.d.ts +53 -0
- package/esm/tools/encoder.js +37 -0
- package/esm/tools/encoder.js.map +1 -0
- package/esm/tools/experimentalFeatures.d.ts +3 -5
- package/esm/tools/experimentalFeatures.js +2 -4
- package/esm/tools/experimentalFeatures.js.map +1 -1
- package/esm/tools/getGlobalObject.js.map +1 -1
- package/esm/tools/getZoneJsOriginalValue.js.map +1 -1
- package/esm/tools/instrumentMethod.d.ts +50 -10
- package/esm/tools/instrumentMethod.js +58 -34
- package/esm/tools/instrumentMethod.js.map +1 -1
- package/esm/tools/matchOption.js.map +1 -1
- package/esm/tools/mergeInto.js.map +1 -1
- package/esm/tools/monitor.d.ts +1 -2
- package/esm/tools/monitor.js +7 -7
- package/esm/tools/monitor.js.map +1 -1
- package/esm/tools/observable.d.ts +1 -1
- package/esm/tools/observable.js +2 -3
- package/esm/tools/observable.js.map +1 -1
- package/esm/tools/readBytesFromStream.js.map +1 -1
- package/esm/tools/sendToExtension.js.map +1 -1
- package/esm/tools/serialisation/jsonStringify.d.ts +1 -2
- package/esm/tools/serialisation/jsonStringify.js.map +1 -1
- package/esm/tools/serialisation/sanitize.js.map +1 -1
- package/esm/tools/utils/browserDetection.d.ts +8 -0
- package/esm/tools/utils/browserDetection.js +30 -2
- package/esm/tools/utils/browserDetection.js.map +1 -1
- package/esm/tools/utils/byteUtils.js.map +1 -1
- package/esm/tools/utils/functionUtils.js.map +1 -1
- package/esm/tools/utils/objectUtils.js.map +1 -1
- package/esm/tools/utils/polyfills.js.map +1 -1
- package/esm/tools/utils/responseUtils.js.map +1 -1
- package/esm/tools/utils/stringUtils.d.ts +1 -0
- package/esm/tools/utils/stringUtils.js +29 -3
- package/esm/tools/utils/stringUtils.js.map +1 -1
- package/esm/tools/utils/timeUtils.js.map +1 -1
- package/esm/tools/utils/typeUtils.js.map +1 -1
- package/esm/tools/utils/urlPolyfill.js.map +1 -1
- package/esm/tools/valueHistory.js.map +1 -1
- package/esm/transport/batch.d.ts +5 -3
- package/esm/transport/batch.js +73 -29
- package/esm/transport/batch.js.map +1 -1
- package/esm/transport/eventBridge.js.map +1 -1
- package/esm/transport/flushController.d.ts +12 -2
- package/esm/transport/flushController.js +22 -7
- package/esm/transport/flushController.js.map +1 -1
- package/esm/transport/httpRequest.d.ts +3 -2
- package/esm/transport/httpRequest.js +21 -17
- package/esm/transport/httpRequest.js.map +1 -1
- package/esm/transport/sendWithRetryStrategy.d.ts +2 -2
- package/esm/transport/sendWithRetryStrategy.js +9 -9
- package/esm/transport/sendWithRetryStrategy.js.map +1 -1
- package/esm/transport/startBatchWithReplica.d.ts +9 -4
- package/esm/transport/startBatchWithReplica.js +9 -4
- package/esm/transport/startBatchWithReplica.js.map +1 -1
- package/package.json +1 -1
- package/src/browser/addEventListener.ts +37 -31
- package/src/browser/cookie.ts +21 -2
- package/src/browser/fetchObservable.ts +21 -25
- package/src/browser/pageExitObservable.ts +1 -3
- package/src/browser/xhrObservable.ts +31 -37
- package/src/domain/configuration/configuration.ts +24 -22
- package/src/domain/configuration/endpointBuilder.ts +40 -53
- package/src/domain/configuration/index.ts +2 -1
- package/src/domain/configuration/transportConfiguration.ts +1 -1
- package/src/domain/connectivity/connectivity.ts +27 -0
- package/src/domain/connectivity/index.ts +1 -0
- package/src/domain/console/consoleObservable.ts +3 -7
- package/src/domain/context/contextConstants.ts +5 -0
- package/src/domain/context/contextManager.ts +48 -0
- package/src/domain/context/customerDataTracker.ts +134 -0
- package/src/domain/context/storeContextManager.ts +51 -0
- package/src/domain/deflate/types.ts +14 -0
- package/src/domain/{tracekit → error}/computeStackTrace.ts +49 -4
- package/src/domain/error/error.ts +2 -2
- package/src/domain/error/error.types.ts +11 -2
- package/src/domain/error/trackRuntimeError.ts +44 -12
- package/src/domain/report/browser.types.ts +12 -0
- package/src/domain/report/reportObservable.ts +8 -6
- package/src/domain/session/oldCookiesMigration.ts +5 -5
- package/src/domain/session/sessionStoreOperations.ts +5 -13
- package/src/domain/session/storeStrategies/sessionInCookie.ts +13 -2
- package/src/domain/session/storeStrategies/sessionInLocalStorage.ts +1 -0
- package/src/domain/session/storeStrategies/sessionStoreStrategy.ts +1 -0
- package/src/domain/synthetics/syntheticsWorkerValues.ts +4 -4
- package/src/domain/telemetry/rawTelemetryEvent.types.ts +5 -0
- package/src/domain/telemetry/telemetry.ts +22 -7
- package/src/domain/telemetry/telemetryEvent.types.ts +18 -2
- package/src/index.ts +13 -7
- package/src/tools/display.ts +14 -13
- package/src/tools/encoder.ts +102 -0
- package/src/tools/experimentalFeatures.ts +2 -4
- package/src/tools/instrumentMethod.ts +103 -59
- package/src/tools/mergeInto.ts +16 -16
- package/src/tools/monitor.ts +5 -5
- package/src/tools/observable.ts +3 -5
- package/src/tools/utils/browserDetection.ts +43 -2
- package/src/tools/utils/polyfills.ts +1 -4
- package/src/tools/utils/stringUtils.ts +30 -4
- package/src/transport/batch.ts +86 -31
- package/src/transport/flushController.ts +22 -7
- package/src/transport/httpRequest.ts +23 -16
- package/src/transport/sendWithRetryStrategy.ts +10 -10
- package/src/transport/startBatchWithReplica.ts +22 -6
- package/cjs/domain/deflate/index.d.ts +0 -1
- package/cjs/domain/deflate/index.js.map +0 -1
- package/cjs/domain/tracekit/computeStackTrace.d.ts +0 -5
- package/cjs/domain/tracekit/computeStackTrace.js.map +0 -1
- package/cjs/domain/tracekit/index.d.ts +0 -3
- package/cjs/domain/tracekit/index.js +0 -8
- package/cjs/domain/tracekit/index.js.map +0 -1
- package/cjs/domain/tracekit/tracekit.d.ts +0 -35
- package/cjs/domain/tracekit/tracekit.js +0 -95
- package/cjs/domain/tracekit/tracekit.js.map +0 -1
- package/cjs/domain/tracekit/types.d.ts +0 -44
- package/cjs/domain/tracekit/types.js.map +0 -1
- package/cjs/index.d.ts +0 -63
- package/cjs/index.js +0 -155
- package/cjs/index.js.map +0 -1
- package/cjs/tools/serialisation/contextManager.d.ts +0 -21
- package/cjs/tools/serialisation/contextManager.js +0 -70
- package/cjs/tools/serialisation/contextManager.js.map +0 -1
- package/cjs/tools/serialisation/heavyCustomerDataWarning.d.ts +0 -8
- package/cjs/tools/serialisation/heavyCustomerDataWarning.js +0 -18
- package/cjs/tools/serialisation/heavyCustomerDataWarning.js.map +0 -1
- package/esm/domain/tracekit/computeStackTrace.d.ts +0 -5
- package/esm/domain/tracekit/computeStackTrace.js.map +0 -1
- package/esm/domain/tracekit/index.d.ts +0 -3
- package/esm/domain/tracekit/index.js +0 -3
- package/esm/domain/tracekit/index.js.map +0 -1
- package/esm/domain/tracekit/tracekit.d.ts +0 -35
- package/esm/domain/tracekit/tracekit.js +0 -91
- package/esm/domain/tracekit/tracekit.js.map +0 -1
- package/esm/domain/tracekit/types.d.ts +0 -44
- package/esm/domain/tracekit/types.js +0 -2
- package/esm/domain/tracekit/types.js.map +0 -1
- package/esm/tools/serialisation/contextManager.d.ts +0 -21
- package/esm/tools/serialisation/contextManager.js +0 -66
- package/esm/tools/serialisation/contextManager.js.map +0 -1
- package/esm/tools/serialisation/heavyCustomerDataWarning.d.ts +0 -8
- package/esm/tools/serialisation/heavyCustomerDataWarning.js +0 -14
- package/esm/tools/serialisation/heavyCustomerDataWarning.js.map +0 -1
- package/src/domain/tracekit/index.ts +0 -3
- package/src/domain/tracekit/tracekit.ts +0 -96
- package/src/domain/tracekit/types.ts +0 -47
- package/src/tools/serialisation/contextManager.ts +0 -79
- package/src/tools/serialisation/heavyCustomerDataWarning.ts +0 -26
|
@@ -4,8 +4,6 @@ import { toStackTraceString, NO_ERROR_STACK_PRESENT_MESSAGE } from '../error/err
|
|
|
4
4
|
import { getExperimentalFeatures } from '../../tools/experimentalFeatures'
|
|
5
5
|
import type { Configuration } from '../configuration'
|
|
6
6
|
import { INTAKE_SITE_STAGING, INTAKE_SITE_US1_FED } from '../configuration'
|
|
7
|
-
import type { StackTrace } from '../tracekit'
|
|
8
|
-
import { computeStackTrace } from '../tracekit'
|
|
9
7
|
import { Observable } from '../../tools/observable'
|
|
10
8
|
import { timeStampNow } from '../../tools/utils/timeUtils'
|
|
11
9
|
import { displayIfDebugEnabled, startMonitorErrorCollection } from '../../tools/monitor'
|
|
@@ -15,8 +13,11 @@ import { performDraw } from '../../tools/utils/numberUtils'
|
|
|
15
13
|
import { jsonStringify } from '../../tools/serialisation/jsonStringify'
|
|
16
14
|
import { combine } from '../../tools/mergeInto'
|
|
17
15
|
import { NonErrorPrefix } from '../error/error.types'
|
|
16
|
+
import type { StackTrace } from '../error/computeStackTrace'
|
|
17
|
+
import { computeStackTrace } from '../error/computeStackTrace'
|
|
18
|
+
import { getConnectivity } from '../connectivity'
|
|
18
19
|
import type { TelemetryEvent } from './telemetryEvent.types'
|
|
19
|
-
import type { RawTelemetryConfiguration, RawTelemetryEvent } from './rawTelemetryEvent.types'
|
|
20
|
+
import type { RawTelemetryConfiguration, RawTelemetryEvent, RuntimeEnvInfo } from './rawTelemetryEvent.types'
|
|
20
21
|
import { StatusType, TelemetryType } from './rawTelemetryEvent.types'
|
|
21
22
|
|
|
22
23
|
// replaced at build time
|
|
@@ -58,9 +59,10 @@ export function startTelemetry(telemetryService: TelemetryService, configuration
|
|
|
58
59
|
telemetryConfiguration.telemetryConfigurationEnabled =
|
|
59
60
|
telemetryConfiguration.telemetryEnabled && performDraw(configuration.telemetryConfigurationSampleRate)
|
|
60
61
|
|
|
62
|
+
const runtimeEnvInfo = getRuntimeEnvInfo()
|
|
61
63
|
onRawTelemetryEventCollected = (rawEvent: RawTelemetryEvent) => {
|
|
62
64
|
if (telemetryConfiguration.telemetryEnabled) {
|
|
63
|
-
const event = toTelemetryEvent(telemetryService, rawEvent)
|
|
65
|
+
const event = toTelemetryEvent(telemetryService, rawEvent, runtimeEnvInfo)
|
|
64
66
|
observable.notify(event)
|
|
65
67
|
sendToExtension('telemetry', event)
|
|
66
68
|
}
|
|
@@ -72,7 +74,11 @@ export function startTelemetry(telemetryService: TelemetryService, configuration
|
|
|
72
74
|
sentEventCount: 0,
|
|
73
75
|
})
|
|
74
76
|
|
|
75
|
-
function toTelemetryEvent(
|
|
77
|
+
function toTelemetryEvent(
|
|
78
|
+
telemetryService: TelemetryService,
|
|
79
|
+
event: RawTelemetryEvent,
|
|
80
|
+
runtimeEnvInfo: RuntimeEnvInfo
|
|
81
|
+
): TelemetryEvent & Context {
|
|
76
82
|
return combine(
|
|
77
83
|
{
|
|
78
84
|
type: 'telemetry' as const,
|
|
@@ -83,11 +89,14 @@ export function startTelemetry(telemetryService: TelemetryService, configuration
|
|
|
83
89
|
_oo: {
|
|
84
90
|
format_version: 2 as const,
|
|
85
91
|
},
|
|
86
|
-
telemetry: event
|
|
92
|
+
telemetry: combine(event, {
|
|
93
|
+
runtime_env: runtimeEnvInfo,
|
|
94
|
+
connectivity: getConnectivity(),
|
|
95
|
+
}),
|
|
87
96
|
experimental_features: arrayFrom(getExperimentalFeatures()),
|
|
88
97
|
},
|
|
89
98
|
contextProvider !== undefined ? contextProvider() : {}
|
|
90
|
-
)
|
|
99
|
+
) as TelemetryEvent & Context
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
return {
|
|
@@ -98,6 +107,12 @@ export function startTelemetry(telemetryService: TelemetryService, configuration
|
|
|
98
107
|
enabled: telemetryConfiguration.telemetryEnabled,
|
|
99
108
|
}
|
|
100
109
|
}
|
|
110
|
+
function getRuntimeEnvInfo(): RuntimeEnvInfo {
|
|
111
|
+
return {
|
|
112
|
+
is_local_file: window.location.protocol === 'file:',
|
|
113
|
+
is_worker: 'WorkerGlobalScope' in self,
|
|
114
|
+
}
|
|
115
|
+
}
|
|
101
116
|
|
|
102
117
|
export function startFakeTelemetry() {
|
|
103
118
|
const events: RawTelemetryEvent[] = []
|
|
@@ -142,9 +142,13 @@ export type TelemetryConfigurationEvent = CommonTelemetryProperties & {
|
|
|
142
142
|
*/
|
|
143
143
|
track_long_task?: boolean
|
|
144
144
|
/**
|
|
145
|
-
* Whether a secure cross-site session cookie is used
|
|
145
|
+
* Whether a secure cross-site session cookie is used (deprecated)
|
|
146
146
|
*/
|
|
147
147
|
use_cross_site_session_cookie?: boolean
|
|
148
|
+
/**
|
|
149
|
+
* Whether a partitioned secure cross-site session cookie is used
|
|
150
|
+
*/
|
|
151
|
+
use_partitioned_cross_site_session_cookie?: boolean
|
|
148
152
|
/**
|
|
149
153
|
* Whether a secure session cookie is used
|
|
150
154
|
*/
|
|
@@ -153,6 +157,10 @@ export type TelemetryConfigurationEvent = CommonTelemetryProperties & {
|
|
|
153
157
|
* Whether it is allowed to use LocalStorage when cookies are not available
|
|
154
158
|
*/
|
|
155
159
|
allow_fallback_to_local_storage?: boolean
|
|
160
|
+
/**
|
|
161
|
+
* Whether contexts are stored in local storage
|
|
162
|
+
*/
|
|
163
|
+
store_contexts_across_pages?: boolean
|
|
156
164
|
/**
|
|
157
165
|
* Whether untrusted events are allowed
|
|
158
166
|
*/
|
|
@@ -281,6 +289,14 @@ export type TelemetryConfigurationEvent = CommonTelemetryProperties & {
|
|
|
281
289
|
* The upload frequency of batches (in milliseconds)
|
|
282
290
|
*/
|
|
283
291
|
batch_upload_frequency?: number
|
|
292
|
+
/**
|
|
293
|
+
* Maximum number of batches processed sequencially without a delay
|
|
294
|
+
*/
|
|
295
|
+
batch_processing_level?: number
|
|
296
|
+
/**
|
|
297
|
+
* Whether UIApplication background tasks are enabled
|
|
298
|
+
*/
|
|
299
|
+
background_tasks_enabled?: boolean
|
|
284
300
|
/**
|
|
285
301
|
* The version of React used in a ReactNative application
|
|
286
302
|
*/
|
|
@@ -329,7 +345,7 @@ export interface CommonTelemetryProperties {
|
|
|
329
345
|
/**
|
|
330
346
|
* The source of this event
|
|
331
347
|
*/
|
|
332
|
-
readonly source: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native'
|
|
348
|
+
readonly source: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'unity'
|
|
333
349
|
/**
|
|
334
350
|
* The version of the SDK generating the telemetry event
|
|
335
351
|
*/
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,6 @@ export {
|
|
|
5
5
|
DefaultPrivacyLevel,
|
|
6
6
|
EndpointBuilder,
|
|
7
7
|
serializeConfiguration,
|
|
8
|
-
INTAKE_SITE_AP1,
|
|
9
8
|
INTAKE_SITE_STAGING,
|
|
10
9
|
INTAKE_SITE_US1,
|
|
11
10
|
INTAKE_SITE_US1_FED,
|
|
@@ -19,7 +18,7 @@ export {
|
|
|
19
18
|
ExperimentalFeature,
|
|
20
19
|
} from './tools/experimentalFeatures'
|
|
21
20
|
export { trackRuntimeError } from './domain/error/trackRuntimeError'
|
|
22
|
-
export { computeStackTrace, StackTrace } from './domain/
|
|
21
|
+
export { computeStackTrace, StackTrace } from './domain/error/computeStackTrace'
|
|
23
22
|
export { defineGlobal, makePublicApi } from './boot/init'
|
|
24
23
|
export { initReportObservable, RawReport, RawReportType } from './domain/report/reportObservable'
|
|
25
24
|
export {
|
|
@@ -62,6 +61,7 @@ export {
|
|
|
62
61
|
FlushReason,
|
|
63
62
|
} from './transport'
|
|
64
63
|
export * from './tools/display'
|
|
64
|
+
export { Encoder, EncoderResult, createIdentityEncoder } from './tools/encoder'
|
|
65
65
|
export * from './tools/utils/urlPolyfill'
|
|
66
66
|
export * from './tools/utils/timeUtils'
|
|
67
67
|
export * from './tools/utils/arrayUtils'
|
|
@@ -73,7 +73,7 @@ export * from './tools/utils/browserDetection'
|
|
|
73
73
|
export { sendToExtension } from './tools/sendToExtension'
|
|
74
74
|
export { runOnReadyState } from './browser/runOnReadyState'
|
|
75
75
|
export { getZoneJsOriginalValue } from './tools/getZoneJsOriginalValue'
|
|
76
|
-
export { instrumentMethod,
|
|
76
|
+
export { instrumentMethod, instrumentSetter, InstrumentedMethodCall } from './tools/instrumentMethod'
|
|
77
77
|
export {
|
|
78
78
|
computeRawError,
|
|
79
79
|
createHandlingStack,
|
|
@@ -92,12 +92,17 @@ export * from './tools/timer'
|
|
|
92
92
|
export { initConsoleObservable, resetConsoleObservable, ConsoleLog } from './domain/console/consoleObservable'
|
|
93
93
|
export { BoundedBuffer } from './tools/boundedBuffer'
|
|
94
94
|
export { catchUserErrors } from './tools/catchUserErrors'
|
|
95
|
-
export { createContextManager, ContextManager } from './
|
|
95
|
+
export { createContextManager, ContextManager } from './domain/context/contextManager'
|
|
96
|
+
export { storeContextManager, removeStorageListeners } from './domain/context/storeContextManager'
|
|
96
97
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
createCustomerDataTrackerManager,
|
|
99
|
+
createCustomerDataTracker,
|
|
100
|
+
CustomerDataTracker,
|
|
101
|
+
CustomerDataTrackerManager,
|
|
99
102
|
CUSTOMER_DATA_BYTES_LIMIT,
|
|
100
|
-
|
|
103
|
+
CustomerDataCompressionStatus,
|
|
104
|
+
} from './domain/context/customerDataTracker'
|
|
105
|
+
export { CustomerDataType } from './domain/context/contextConstants'
|
|
101
106
|
export { ValueHistory, ValueHistoryEntry, CLEAR_OLD_VALUES_INTERVAL } from './tools/valueHistory'
|
|
102
107
|
export { readBytesFromStream } from './tools/readBytesFromStream'
|
|
103
108
|
export { STORAGE_POLL_DELAY } from './domain/session/sessionStore'
|
|
@@ -126,3 +131,4 @@ export { RawError } from './domain/error/error.types'
|
|
|
126
131
|
export { RawErrorCause } from './domain/error/error.types'
|
|
127
132
|
export { ErrorWithCause } from './domain/error/error.types'
|
|
128
133
|
export * from './domain/deflate'
|
|
134
|
+
export * from './domain/connectivity'
|
package/src/tools/display.ts
CHANGED
|
@@ -18,7 +18,6 @@ export const ConsoleApiName = {
|
|
|
18
18
|
export type ConsoleApiName = (typeof ConsoleApiName)[keyof typeof ConsoleApiName]
|
|
19
19
|
|
|
20
20
|
interface Display {
|
|
21
|
-
(api: ConsoleApiName, ...args: any[]): void
|
|
22
21
|
debug: typeof console.debug
|
|
23
22
|
log: typeof console.log
|
|
24
23
|
info: typeof console.info
|
|
@@ -26,13 +25,6 @@ interface Display {
|
|
|
26
25
|
error: typeof console.error
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
export const display: Display = (api, ...args) => {
|
|
30
|
-
if (!Object.prototype.hasOwnProperty.call(ConsoleApiName, api)) {
|
|
31
|
-
api = ConsoleApiName.log
|
|
32
|
-
}
|
|
33
|
-
display[api](...args)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
28
|
/**
|
|
37
29
|
* When building JS bundles, some users might use a plugin[1] or configuration[2] to remove
|
|
38
30
|
* "console.*" references. This causes some issue as we expect `console.*` to be defined.
|
|
@@ -44,8 +36,17 @@ export const display: Display = (api, ...args) => {
|
|
|
44
36
|
*/
|
|
45
37
|
export const globalConsole = console
|
|
46
38
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
export const originalConsoleMethods = {} as Display
|
|
40
|
+
Object.keys(ConsoleApiName).forEach((name) => {
|
|
41
|
+
originalConsoleMethods[name as ConsoleApiName] = globalConsole[name as ConsoleApiName]
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const PREFIX = 'Datadog Browser SDK:'
|
|
45
|
+
|
|
46
|
+
export const display: Display = {
|
|
47
|
+
debug: originalConsoleMethods.debug.bind(globalConsole, PREFIX),
|
|
48
|
+
log: originalConsoleMethods.log.bind(globalConsole, PREFIX),
|
|
49
|
+
info: originalConsoleMethods.info.bind(globalConsole, PREFIX),
|
|
50
|
+
warn: originalConsoleMethods.warn.bind(globalConsole, PREFIX),
|
|
51
|
+
error: originalConsoleMethods.error.bind(globalConsole, PREFIX),
|
|
52
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { computeBytesCount } from './utils/byteUtils'
|
|
2
|
+
|
|
3
|
+
export interface Encoder<Output extends string | Uint8Array = string | Uint8Array> {
|
|
4
|
+
/**
|
|
5
|
+
* Whether this encoder might call the provided callbacks asynchronously
|
|
6
|
+
*/
|
|
7
|
+
isAsync: boolean
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Whether some data has been written since the last finish() or finishSync() call
|
|
11
|
+
*/
|
|
12
|
+
isEmpty: boolean
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Write a string to be encoded.
|
|
16
|
+
*
|
|
17
|
+
* This operation can be synchronous or asynchronous depending on the encoder implementation.
|
|
18
|
+
*
|
|
19
|
+
* If specified, the callback will be invoked when the operation finishes, unless the operation is
|
|
20
|
+
* asynchronous and finish() or finishSync() is called in the meantime.
|
|
21
|
+
*/
|
|
22
|
+
write(data: string, callback?: (additionalEncodedBytesCount: number) => void): void
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Waits for pending data to be encoded and resets the encoder state.
|
|
26
|
+
*
|
|
27
|
+
* This operation can be synchronous or asynchronous depending on the encoder implementation.
|
|
28
|
+
*
|
|
29
|
+
* The callback will be invoked when the operation finishes, unless the operation is asynchronous
|
|
30
|
+
* and another call to finish() or finishSync() occurs in the meantime.
|
|
31
|
+
*/
|
|
32
|
+
finish(callback: (result: EncoderResult<Output>) => void): void
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Resets the encoder state then returns the encoded data and any potential pending data directly,
|
|
36
|
+
* discarding all pending write operations and finish() callbacks.
|
|
37
|
+
*/
|
|
38
|
+
finishSync(): EncoderResult<Output> & { pendingData: string }
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns a rough estimation of the bytes count if the data was encoded.
|
|
42
|
+
*/
|
|
43
|
+
estimateEncodedBytesCount(data: string): number
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface EncoderResult<Output extends string | Uint8Array = string | Uint8Array> {
|
|
47
|
+
output: Output
|
|
48
|
+
outputBytesCount: number
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* An encoding type supported by HTTP Content-Encoding, if applicable.
|
|
52
|
+
* See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding#directives
|
|
53
|
+
*/
|
|
54
|
+
encoding?: 'deflate'
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Total bytes count of the input strings encoded to UTF-8.
|
|
58
|
+
*/
|
|
59
|
+
rawBytesCount: number
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function createIdentityEncoder(): Encoder<string> {
|
|
63
|
+
let output = ''
|
|
64
|
+
let outputBytesCount = 0
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
isAsync: false,
|
|
68
|
+
|
|
69
|
+
get isEmpty() {
|
|
70
|
+
return !output
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
write(data, callback) {
|
|
74
|
+
const additionalEncodedBytesCount = computeBytesCount(data)
|
|
75
|
+
outputBytesCount += additionalEncodedBytesCount
|
|
76
|
+
output += data
|
|
77
|
+
if (callback) {
|
|
78
|
+
callback(additionalEncodedBytesCount)
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
finish(callback) {
|
|
83
|
+
callback(this.finishSync())
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
finishSync() {
|
|
87
|
+
const result = {
|
|
88
|
+
output,
|
|
89
|
+
outputBytesCount,
|
|
90
|
+
rawBytesCount: outputBytesCount,
|
|
91
|
+
pendingData: '',
|
|
92
|
+
}
|
|
93
|
+
output = ''
|
|
94
|
+
outputBytesCount = 0
|
|
95
|
+
return result
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
estimateEncodedBytesCount(data) {
|
|
99
|
+
return data.length
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -14,12 +14,10 @@ export enum ExperimentalFeature {
|
|
|
14
14
|
PAGEHIDE = 'pagehide',
|
|
15
15
|
FEATURE_FLAGS = 'feature_flags',
|
|
16
16
|
RESOURCE_PAGE_STATES = 'resource_page_states',
|
|
17
|
-
PAGE_STATES = 'page_states',
|
|
18
17
|
COLLECT_FLUSH_REASON = 'collect_flush_reason',
|
|
19
|
-
|
|
20
|
-
SCROLLMAP = 'scrollmap',
|
|
21
|
-
INTERACTION_TO_NEXT_PAINT = 'interaction_to_next_paint',
|
|
18
|
+
ZERO_LCP_TELEMETRY = 'zero_lcp_telemetry',
|
|
22
19
|
DISABLE_REPLAY_INLINE_CSS = 'disable_replay_inline_css',
|
|
20
|
+
WRITABLE_RESOURCE_GRAPHQL = 'writable_resource_graphql',
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
const enabledExperimentalFeatures: Set<ExperimentalFeature> = new Set()
|
|
@@ -2,30 +2,77 @@ import { setTimeout } from './timer'
|
|
|
2
2
|
import { callMonitored } from './monitor'
|
|
3
3
|
import { noop } from './utils/functionUtils'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Object passed to the callback of an instrumented method call. See `instrumentMethod` for more
|
|
7
|
+
* info.
|
|
8
|
+
*/
|
|
9
|
+
export type InstrumentedMethodCall<TARGET extends { [key: string]: any }, METHOD extends keyof TARGET> = {
|
|
10
|
+
/**
|
|
11
|
+
* The target object on which the method was called.
|
|
12
|
+
*/
|
|
13
|
+
target: TARGET
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The parameters with which the method was called. To avoid having to clone the argument list
|
|
17
|
+
* every time, this property is actually an instance of Argument, not Array, so not all methods
|
|
18
|
+
* are available (like .forEach).
|
|
19
|
+
*
|
|
20
|
+
* Note: if needed, parameters can be mutated by the instrumentation
|
|
21
|
+
*/
|
|
22
|
+
parameters: Parameters<TARGET[METHOD]>
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Registers a callback that will be called after the original method is called, with the method
|
|
26
|
+
* result passed as argument.
|
|
27
|
+
*/
|
|
28
|
+
onPostCall: (callback: PostCallCallback<TARGET, METHOD>) => void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type PostCallCallback<TARGET extends { [key: string]: any }, METHOD extends keyof TARGET> = (
|
|
32
|
+
result: ReturnType<TARGET[METHOD]>
|
|
33
|
+
) => void
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Instruments a method on a object, calling the given callback before the original method is
|
|
37
|
+
* invoked. The callback receives an object with information about the method call.
|
|
38
|
+
*
|
|
39
|
+
* Note: it is generally better to instrument methods that are "owned" by the object instead of ones
|
|
40
|
+
* that are inherited from the prototype chain. Example:
|
|
41
|
+
* * do: `instrumentMethod(Array.prototype, 'push', ...)`
|
|
42
|
+
* * don't: `instrumentMethod([], 'push', ...)`
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
*
|
|
46
|
+
* instrumentMethod(window, 'fetch', ({ target, parameters, onPostCall }) => {
|
|
47
|
+
* console.log('Before calling fetch on', target, 'with parameters', parameters)
|
|
48
|
+
*
|
|
49
|
+
* onPostCall((result) => {
|
|
50
|
+
* console.log('After fetch calling on', target, 'with parameters', parameters, 'and result', result)
|
|
51
|
+
* })
|
|
52
|
+
* })
|
|
53
|
+
*/
|
|
54
|
+
export function instrumentMethod<TARGET extends { [key: string]: any }, METHOD extends keyof TARGET>(
|
|
55
|
+
targetPrototype: TARGET,
|
|
7
56
|
method: METHOD,
|
|
8
|
-
|
|
9
|
-
original: OBJECT[METHOD]
|
|
10
|
-
) => (this: OBJECT, ...args: Parameters<OBJECT[METHOD]>) => ReturnType<OBJECT[METHOD]>
|
|
57
|
+
onPreCall: (this: null, callInfos: InstrumentedMethodCall<TARGET, METHOD>) => void
|
|
11
58
|
) {
|
|
12
|
-
const original =
|
|
59
|
+
const original = targetPrototype[method]
|
|
13
60
|
|
|
14
|
-
let instrumentation =
|
|
61
|
+
let instrumentation = createInstrumentedMethod(original, onPreCall)
|
|
15
62
|
|
|
16
|
-
const instrumentationWrapper = function (this:
|
|
63
|
+
const instrumentationWrapper = function (this: TARGET): ReturnType<TARGET[METHOD]> | undefined {
|
|
17
64
|
if (typeof instrumentation !== 'function') {
|
|
18
65
|
return undefined
|
|
19
66
|
}
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
21
|
-
return instrumentation.apply(this, arguments as unknown as Parameters<
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
68
|
+
return instrumentation.apply(this, arguments as unknown as Parameters<TARGET[METHOD]>)
|
|
22
69
|
}
|
|
23
|
-
|
|
70
|
+
targetPrototype[method] = instrumentationWrapper as TARGET[METHOD]
|
|
24
71
|
|
|
25
72
|
return {
|
|
26
73
|
stop: () => {
|
|
27
|
-
if (
|
|
28
|
-
|
|
74
|
+
if (targetPrototype[method] === instrumentationWrapper) {
|
|
75
|
+
targetPrototype[method] = original
|
|
29
76
|
} else {
|
|
30
77
|
instrumentation = original
|
|
31
78
|
}
|
|
@@ -33,74 +80,71 @@ export function instrumentMethod<OBJECT extends { [key: string]: any }, METHOD e
|
|
|
33
80
|
}
|
|
34
81
|
}
|
|
35
82
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return result
|
|
70
|
-
}
|
|
71
|
-
)
|
|
83
|
+
function createInstrumentedMethod<TARGET extends { [key: string]: any }, METHOD extends keyof TARGET>(
|
|
84
|
+
original: TARGET[METHOD],
|
|
85
|
+
onPreCall: (this: null, callInfos: InstrumentedMethodCall<TARGET, METHOD>) => void
|
|
86
|
+
): TARGET[METHOD] {
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
88
|
+
return function (this: TARGET) {
|
|
89
|
+
const parameters = arguments as unknown as Parameters<TARGET[METHOD]>
|
|
90
|
+
let result
|
|
91
|
+
|
|
92
|
+
let postCallCallback: PostCallCallback<TARGET, METHOD> | undefined
|
|
93
|
+
|
|
94
|
+
callMonitored(onPreCall, null, [
|
|
95
|
+
{
|
|
96
|
+
target: this,
|
|
97
|
+
parameters,
|
|
98
|
+
onPostCall: (callback) => {
|
|
99
|
+
postCallCallback = callback
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
])
|
|
103
|
+
|
|
104
|
+
if (typeof original === 'function') {
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
106
|
+
result = original.apply(this, parameters)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (postCallCallback) {
|
|
110
|
+
callMonitored(postCallCallback, null, [result])
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
114
|
+
return result
|
|
115
|
+
} as TARGET[METHOD]
|
|
72
116
|
}
|
|
73
117
|
|
|
74
|
-
export function instrumentSetter<
|
|
75
|
-
|
|
118
|
+
export function instrumentSetter<TARGET extends { [key: string]: any }, PROPERTY extends keyof TARGET>(
|
|
119
|
+
targetPrototype: TARGET,
|
|
76
120
|
property: PROPERTY,
|
|
77
|
-
after: (
|
|
121
|
+
after: (target: TARGET, value: TARGET[PROPERTY]) => void
|
|
78
122
|
) {
|
|
79
|
-
const originalDescriptor = Object.getOwnPropertyDescriptor(
|
|
123
|
+
const originalDescriptor = Object.getOwnPropertyDescriptor(targetPrototype, property)
|
|
80
124
|
if (!originalDescriptor || !originalDescriptor.set || !originalDescriptor.configurable) {
|
|
81
125
|
return { stop: noop }
|
|
82
126
|
}
|
|
83
127
|
|
|
84
|
-
let instrumentation = (
|
|
128
|
+
let instrumentation = (target: TARGET, value: TARGET[PROPERTY]) => {
|
|
85
129
|
// put hooked setter into event loop to avoid of set latency
|
|
86
130
|
setTimeout(() => {
|
|
87
|
-
after(
|
|
131
|
+
after(target, value)
|
|
88
132
|
}, 0)
|
|
89
133
|
}
|
|
90
134
|
|
|
91
|
-
const instrumentationWrapper = function (this:
|
|
135
|
+
const instrumentationWrapper = function (this: TARGET, value: TARGET[PROPERTY]) {
|
|
92
136
|
originalDescriptor.set!.call(this, value)
|
|
93
137
|
instrumentation(this, value)
|
|
94
138
|
}
|
|
95
139
|
|
|
96
|
-
Object.defineProperty(
|
|
140
|
+
Object.defineProperty(targetPrototype, property, {
|
|
97
141
|
set: instrumentationWrapper,
|
|
98
142
|
})
|
|
99
143
|
|
|
100
144
|
return {
|
|
101
145
|
stop: () => {
|
|
102
|
-
if (Object.getOwnPropertyDescriptor(
|
|
103
|
-
Object.defineProperty(
|
|
146
|
+
if (Object.getOwnPropertyDescriptor(targetPrototype, property)?.set === instrumentationWrapper) {
|
|
147
|
+
Object.defineProperty(targetPrototype, property, originalDescriptor)
|
|
104
148
|
} else {
|
|
105
149
|
instrumentation = noop
|
|
106
150
|
}
|
package/src/tools/mergeInto.ts
CHANGED
|
@@ -5,22 +5,22 @@ type Merged<TDestination, TSource> =
|
|
|
5
5
|
TSource extends undefined
|
|
6
6
|
? TDestination
|
|
7
7
|
: // case 2 - destination is undefined - return source
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
TDestination extends undefined
|
|
9
|
+
? TSource
|
|
10
|
+
: // case 3 - source is an array - see if it merges or overwrites
|
|
11
|
+
TSource extends any[]
|
|
12
|
+
? TDestination extends any[]
|
|
13
|
+
? TDestination & TSource
|
|
14
|
+
: TSource
|
|
15
|
+
: // case 4 - source is an object - see if it merges or overwrites
|
|
16
|
+
TSource extends object
|
|
17
|
+
? TDestination extends object
|
|
18
|
+
? TDestination extends any[]
|
|
19
|
+
? TSource
|
|
20
|
+
: TDestination & TSource
|
|
21
|
+
: TSource
|
|
22
|
+
: // case 5 - cannot merge - return source
|
|
23
|
+
TSource
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Iterate over source and affect its sub values into destination, recursively.
|
package/src/tools/monitor.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { display } from './display'
|
|
2
2
|
|
|
3
3
|
let onMonitorErrorCollected: undefined | ((error: unknown) => void)
|
|
4
4
|
let debugMode = false
|
|
@@ -50,19 +50,19 @@ export function callMonitored<T extends (...args: any[]) => any>(
|
|
|
50
50
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
51
51
|
return fn.apply(context, args)
|
|
52
52
|
} catch (e) {
|
|
53
|
-
displayIfDebugEnabled(
|
|
53
|
+
displayIfDebugEnabled(e)
|
|
54
54
|
if (onMonitorErrorCollected) {
|
|
55
55
|
try {
|
|
56
56
|
onMonitorErrorCollected(e)
|
|
57
57
|
} catch (e) {
|
|
58
|
-
displayIfDebugEnabled(
|
|
58
|
+
displayIfDebugEnabled(e)
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export function displayIfDebugEnabled(
|
|
64
|
+
export function displayIfDebugEnabled(...args: any[]) {
|
|
65
65
|
if (debugMode) {
|
|
66
|
-
display(
|
|
66
|
+
display.error('[MONITOR]', ...args)
|
|
67
67
|
}
|
|
68
68
|
}
|
package/src/tools/observable.ts
CHANGED
|
@@ -6,11 +6,11 @@ export class Observable<T> {
|
|
|
6
6
|
private observers: Array<(data: T) => void> = []
|
|
7
7
|
private onLastUnsubscribe?: () => void
|
|
8
8
|
|
|
9
|
-
constructor(private onFirstSubscribe?: () => (() => void) | void) {}
|
|
9
|
+
constructor(private onFirstSubscribe?: (observable: Observable<T>) => (() => void) | void) {}
|
|
10
10
|
|
|
11
11
|
subscribe(f: (data: T) => void): Subscription {
|
|
12
12
|
if (!this.observers.length && this.onFirstSubscribe) {
|
|
13
|
-
this.onLastUnsubscribe = this.onFirstSubscribe() || undefined
|
|
13
|
+
this.onLastUnsubscribe = this.onFirstSubscribe(this) || undefined
|
|
14
14
|
}
|
|
15
15
|
this.observers.push(f)
|
|
16
16
|
return {
|
|
@@ -29,12 +29,10 @@ export class Observable<T> {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function mergeObservables<T>(...observables: Array<Observable<T>>) {
|
|
32
|
-
|
|
32
|
+
return new Observable<T>((globalObservable) => {
|
|
33
33
|
const subscriptions: Subscription[] = observables.map((observable) =>
|
|
34
34
|
observable.subscribe((data) => globalObservable.notify(data))
|
|
35
35
|
)
|
|
36
36
|
return () => subscriptions.forEach((subscription) => subscription.unsubscribe())
|
|
37
37
|
})
|
|
38
|
-
|
|
39
|
-
return globalObservable
|
|
40
38
|
}
|