@openobserve/browser-core 0.2.11-rc1 → 0.2.11
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 +4 -12
- package/cjs/browser/addEventListener.js +8 -50
- package/cjs/browser/addEventListener.js.map +1 -1
- package/cjs/browser/cookie.d.ts +0 -7
- package/cjs/browser/cookie.js +2 -19
- package/cjs/browser/cookie.js.map +1 -1
- package/cjs/browser/fetchObservable.js +19 -14
- package/cjs/browser/fetchObservable.js.map +1 -1
- package/cjs/browser/pageExitObservable.js +7 -6
- 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 +2 -1
- package/cjs/browser/xhrObservable.js +34 -26
- package/cjs/browser/xhrObservable.js.map +1 -1
- package/cjs/domain/configuration/configuration.d.ts +12 -17
- package/cjs/domain/configuration/configuration.js +9 -8
- package/cjs/domain/configuration/configuration.js.map +1 -1
- package/cjs/domain/configuration/endpointBuilder.d.ts +10 -6
- package/cjs/domain/configuration/endpointBuilder.js +33 -23
- package/cjs/domain/configuration/endpointBuilder.js.map +1 -1
- package/cjs/domain/configuration/index.d.ts +1 -2
- package/cjs/domain/configuration/index.js +1 -3
- 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/console/consoleObservable.js +7 -4
- package/cjs/domain/console/consoleObservable.js.map +1 -1
- package/cjs/domain/deflate/index.d.ts +1 -0
- package/cjs/domain/{connectivity → deflate}/index.js +1 -1
- package/cjs/domain/deflate/index.js.map +1 -0
- package/cjs/domain/deflate/types.d.ts +26 -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 +0 -8
- package/cjs/domain/error/trackRuntimeError.js +6 -39
- 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 +0 -10
- package/cjs/domain/report/reportObservable.d.ts +0 -2
- 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 +5 -0
- package/cjs/domain/session/sessionStoreOperations.js +14 -6
- package/cjs/domain/session/sessionStoreOperations.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionInCookie.js +2 -13
- package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +0 -1
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -1
- 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 +0 -4
- package/cjs/domain/telemetry/telemetry.d.ts +1 -5
- package/cjs/domain/telemetry/telemetry.js +6 -17
- package/cjs/domain/telemetry/telemetry.js.map +1 -1
- package/cjs/domain/telemetry/telemetryEvent.types.d.ts +2 -18
- package/cjs/domain/tracekit/computeStackTrace.d.ts +5 -0
- package/cjs/domain/{error → tracekit}/computeStackTrace.js +4 -28
- 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/{context/contextConstants.js → tracekit/types.js} +1 -1
- package/cjs/domain/tracekit/types.js.map +1 -0
- package/cjs/domain/user/user.js.map +1 -1
- package/cjs/index.d.ts +63 -0
- package/cjs/index.js +155 -0
- package/cjs/index.js.map +1 -0
- 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 +17 -13
- package/cjs/tools/display.js.map +1 -1
- package/cjs/tools/experimentalFeatures.d.ts +5 -3
- package/cjs/tools/experimentalFeatures.js +4 -2
- 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 +10 -50
- package/cjs/tools/instrumentMethod.js +36 -59
- 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 +2 -1
- 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 +3 -2
- 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/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 +2 -1
- 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 +0 -8
- package/cjs/tools/utils/browserDetection.js +3 -33
- 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 +0 -1
- package/cjs/tools/utils/stringUtils.js +4 -31
- 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 +3 -5
- package/cjs/transport/batch.js +29 -73
- package/cjs/transport/batch.js.map +1 -1
- package/cjs/transport/eventBridge.js.map +1 -1
- package/cjs/transport/flushController.d.ts +2 -12
- package/cjs/transport/flushController.js +7 -22
- package/cjs/transport/flushController.js.map +1 -1
- package/cjs/transport/httpRequest.d.ts +2 -3
- package/cjs/transport/httpRequest.js +17 -21
- 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 +4 -9
- package/cjs/transport/startBatchWithReplica.js +4 -9
- 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 +4 -12
- package/esm/browser/addEventListener.js +7 -49
- package/esm/browser/addEventListener.js.map +1 -1
- package/esm/browser/cookie.d.ts +0 -7
- package/esm/browser/cookie.js +2 -17
- package/esm/browser/cookie.js.map +1 -1
- package/esm/browser/fetchObservable.js +20 -15
- package/esm/browser/fetchObservable.js.map +1 -1
- package/esm/browser/pageExitObservable.js +8 -7
- 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 +2 -1
- package/esm/browser/xhrObservable.js +36 -28
- package/esm/browser/xhrObservable.js.map +1 -1
- package/esm/domain/configuration/configuration.d.ts +12 -17
- package/esm/domain/configuration/configuration.js +9 -8
- package/esm/domain/configuration/configuration.js.map +1 -1
- package/esm/domain/configuration/endpointBuilder.d.ts +10 -6
- package/esm/domain/configuration/endpointBuilder.js +32 -22
- package/esm/domain/configuration/endpointBuilder.js.map +1 -1
- package/esm/domain/configuration/index.d.ts +1 -2
- package/esm/domain/configuration/index.js +0 -1
- 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/console/consoleObservable.js +5 -2
- package/esm/domain/console/consoleObservable.js.map +1 -1
- package/esm/domain/deflate/types.d.ts +0 -12
- 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 +0 -8
- package/esm/domain/error/trackRuntimeError.js +4 -35
- 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 +0 -10
- package/esm/domain/report/reportObservable.d.ts +0 -2
- 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 +5 -0
- package/esm/domain/session/sessionStoreOperations.js +12 -5
- package/esm/domain/session/sessionStoreOperations.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionInCookie.js +2 -13
- package/esm/domain/session/storeStrategies/sessionInCookie.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +0 -1
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +1 -1
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -1
- 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 +0 -4
- package/esm/domain/telemetry/telemetry.d.ts +1 -5
- package/esm/domain/telemetry/telemetry.js +5 -16
- package/esm/domain/telemetry/telemetry.js.map +1 -1
- package/esm/domain/telemetry/telemetryEvent.types.d.ts +2 -18
- package/esm/domain/tracekit/computeStackTrace.d.ts +5 -0
- package/esm/domain/{error → tracekit}/computeStackTrace.js +3 -26
- 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/user.js.map +1 -1
- package/esm/index.d.ts +5 -9
- package/esm/index.js +5 -8
- 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 +15 -12
- package/esm/tools/display.js.map +1 -1
- package/esm/tools/experimentalFeatures.d.ts +5 -3
- package/esm/tools/experimentalFeatures.js +4 -2
- 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 +10 -50
- package/esm/tools/instrumentMethod.js +34 -58
- 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 +2 -1
- 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 +3 -2
- 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/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 +2 -1
- 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 +0 -8
- package/esm/tools/utils/browserDetection.js +2 -30
- 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 +0 -1
- package/esm/tools/utils/stringUtils.js +3 -29
- 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 +3 -5
- package/esm/transport/batch.js +29 -73
- package/esm/transport/batch.js.map +1 -1
- package/esm/transport/eventBridge.js.map +1 -1
- package/esm/transport/flushController.d.ts +2 -12
- package/esm/transport/flushController.js +7 -22
- package/esm/transport/flushController.js.map +1 -1
- package/esm/transport/httpRequest.d.ts +2 -3
- package/esm/transport/httpRequest.js +17 -21
- 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 +4 -9
- package/esm/transport/startBatchWithReplica.js +4 -9
- package/esm/transport/startBatchWithReplica.js.map +1 -1
- package/package.json +1 -1
- package/src/browser/addEventListener.ts +31 -37
- package/src/browser/cookie.ts +2 -21
- package/src/browser/fetchObservable.ts +25 -21
- package/src/browser/pageExitObservable.ts +3 -1
- package/src/browser/xhrObservable.ts +37 -31
- package/src/domain/configuration/configuration.ts +22 -24
- package/src/domain/configuration/endpointBuilder.ts +46 -33
- package/src/domain/configuration/index.ts +1 -2
- package/src/domain/configuration/transportConfiguration.ts +1 -1
- package/src/domain/console/consoleObservable.ts +7 -3
- package/src/domain/deflate/types.ts +0 -14
- package/src/domain/error/error.ts +2 -2
- package/src/domain/error/error.types.ts +2 -11
- package/src/domain/error/trackRuntimeError.ts +12 -44
- package/src/domain/report/browser.types.ts +0 -12
- package/src/domain/report/reportObservable.ts +6 -8
- package/src/domain/session/oldCookiesMigration.ts +5 -5
- package/src/domain/session/sessionStoreOperations.ts +13 -5
- package/src/domain/session/storeStrategies/sessionInCookie.ts +2 -13
- package/src/domain/session/storeStrategies/sessionInLocalStorage.ts +0 -1
- package/src/domain/session/storeStrategies/sessionStoreStrategy.ts +0 -1
- package/src/domain/synthetics/syntheticsWorkerValues.ts +4 -4
- package/src/domain/telemetry/rawTelemetryEvent.types.ts +0 -5
- package/src/domain/telemetry/telemetry.ts +7 -22
- package/src/domain/telemetry/telemetryEvent.types.ts +2 -18
- package/src/domain/{error → tracekit}/computeStackTrace.ts +4 -49
- 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/index.ts +7 -13
- package/src/tools/display.ts +13 -14
- package/src/tools/experimentalFeatures.ts +4 -2
- package/src/tools/instrumentMethod.ts +59 -103
- package/src/tools/mergeInto.ts +16 -16
- package/src/tools/monitor.ts +5 -5
- package/src/tools/observable.ts +5 -3
- package/src/tools/serialisation/contextManager.ts +79 -0
- package/src/tools/serialisation/heavyCustomerDataWarning.ts +26 -0
- package/src/tools/utils/browserDetection.ts +2 -43
- package/src/tools/utils/polyfills.ts +4 -1
- package/src/tools/utils/stringUtils.ts +4 -30
- package/src/transport/batch.ts +31 -86
- package/src/transport/flushController.ts +7 -22
- package/src/transport/httpRequest.ts +16 -23
- package/src/transport/sendWithRetryStrategy.ts +10 -10
- package/src/transport/startBatchWithReplica.ts +6 -22
- package/cjs/domain/connectivity/connectivity.d.ts +0 -13
- package/cjs/domain/connectivity/connectivity.js +0 -14
- package/cjs/domain/connectivity/connectivity.js.map +0 -1
- package/cjs/domain/connectivity/index.d.ts +0 -1
- package/cjs/domain/connectivity/index.js.map +0 -1
- package/cjs/domain/context/contextConstants.d.ts +0 -5
- package/cjs/domain/context/contextConstants.js.map +0 -1
- package/cjs/domain/context/contextManager.d.ts +0 -12
- package/cjs/domain/context/contextManager.js +0 -43
- package/cjs/domain/context/contextManager.js.map +0 -1
- package/cjs/domain/context/customerDataTracker.d.ts +0 -45
- package/cjs/domain/context/customerDataTracker.js +0 -107
- package/cjs/domain/context/customerDataTracker.js.map +0 -1
- package/cjs/domain/context/storeContextManager.d.ts +0 -6
- package/cjs/domain/context/storeContextManager.js +0 -38
- package/cjs/domain/context/storeContextManager.js.map +0 -1
- package/cjs/domain/error/computeStackTrace.d.ts +0 -33
- package/cjs/domain/error/computeStackTrace.js.map +0 -1
- package/cjs/tools/encoder.d.ts +0 -53
- package/cjs/tools/encoder.js +0 -41
- package/cjs/tools/encoder.js.map +0 -1
- package/esm/domain/connectivity/connectivity.d.ts +0 -13
- package/esm/domain/connectivity/connectivity.js +0 -10
- package/esm/domain/connectivity/connectivity.js.map +0 -1
- package/esm/domain/connectivity/index.d.ts +0 -1
- package/esm/domain/connectivity/index.js +0 -2
- package/esm/domain/connectivity/index.js.map +0 -1
- package/esm/domain/context/contextConstants.d.ts +0 -5
- package/esm/domain/context/contextConstants.js +0 -2
- package/esm/domain/context/contextConstants.js.map +0 -1
- package/esm/domain/context/contextManager.d.ts +0 -12
- package/esm/domain/context/contextManager.js +0 -39
- package/esm/domain/context/contextManager.js.map +0 -1
- package/esm/domain/context/customerDataTracker.d.ts +0 -45
- package/esm/domain/context/customerDataTracker.js +0 -102
- package/esm/domain/context/customerDataTracker.js.map +0 -1
- package/esm/domain/context/storeContextManager.d.ts +0 -6
- package/esm/domain/context/storeContextManager.js +0 -32
- package/esm/domain/context/storeContextManager.js.map +0 -1
- package/esm/domain/error/computeStackTrace.d.ts +0 -33
- package/esm/domain/error/computeStackTrace.js.map +0 -1
- package/esm/tools/encoder.d.ts +0 -53
- package/esm/tools/encoder.js +0 -37
- package/esm/tools/encoder.js.map +0 -1
- package/src/domain/connectivity/connectivity.ts +0 -27
- package/src/domain/connectivity/index.ts +0 -1
- package/src/domain/context/contextConstants.ts +0 -5
- package/src/domain/context/contextManager.ts +0 -48
- package/src/domain/context/customerDataTracker.ts +0 -134
- package/src/domain/context/storeContextManager.ts +0 -51
- package/src/tools/encoder.ts +0 -102
|
@@ -2,77 +2,30 @@ import { setTimeout } from './timer'
|
|
|
2
2
|
import { callMonitored } from './monitor'
|
|
3
3
|
import { noop } from './utils/functionUtils'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
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,
|
|
5
|
+
export function instrumentMethod<OBJECT extends { [key: string]: any }, METHOD extends keyof OBJECT>(
|
|
6
|
+
object: OBJECT,
|
|
56
7
|
method: METHOD,
|
|
57
|
-
|
|
8
|
+
instrumentationFactory: (
|
|
9
|
+
original: OBJECT[METHOD]
|
|
10
|
+
) => (this: OBJECT, ...args: Parameters<OBJECT[METHOD]>) => ReturnType<OBJECT[METHOD]>
|
|
58
11
|
) {
|
|
59
|
-
const original =
|
|
12
|
+
const original = object[method]
|
|
60
13
|
|
|
61
|
-
let instrumentation =
|
|
14
|
+
let instrumentation = instrumentationFactory(original)
|
|
62
15
|
|
|
63
|
-
const instrumentationWrapper = function (this:
|
|
16
|
+
const instrumentationWrapper = function (this: OBJECT): ReturnType<OBJECT[METHOD]> | undefined {
|
|
64
17
|
if (typeof instrumentation !== 'function') {
|
|
65
18
|
return undefined
|
|
66
19
|
}
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
68
|
-
return instrumentation.apply(this, arguments as unknown as Parameters<
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
21
|
+
return instrumentation.apply(this, arguments as unknown as Parameters<OBJECT[METHOD]>)
|
|
69
22
|
}
|
|
70
|
-
|
|
23
|
+
object[method] = instrumentationWrapper as OBJECT[METHOD]
|
|
71
24
|
|
|
72
25
|
return {
|
|
73
26
|
stop: () => {
|
|
74
|
-
if (
|
|
75
|
-
|
|
27
|
+
if (object[method] === instrumentationWrapper) {
|
|
28
|
+
object[method] = original
|
|
76
29
|
} else {
|
|
77
30
|
instrumentation = original
|
|
78
31
|
}
|
|
@@ -80,71 +33,74 @@ export function instrumentMethod<TARGET extends { [key: string]: any }, METHOD e
|
|
|
80
33
|
}
|
|
81
34
|
}
|
|
82
35
|
|
|
83
|
-
function
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
36
|
+
export function instrumentMethodAndCallOriginal<OBJECT extends { [key: string]: any }, METHOD extends keyof OBJECT>(
|
|
37
|
+
object: OBJECT,
|
|
38
|
+
method: METHOD,
|
|
39
|
+
{
|
|
40
|
+
before,
|
|
41
|
+
after,
|
|
42
|
+
}: {
|
|
43
|
+
before?: (this: OBJECT, ...args: Parameters<OBJECT[METHOD]>) => void
|
|
44
|
+
after?: (this: OBJECT, ...args: Parameters<OBJECT[METHOD]>) => void
|
|
45
|
+
}
|
|
46
|
+
) {
|
|
47
|
+
return instrumentMethod(
|
|
48
|
+
object,
|
|
49
|
+
method,
|
|
50
|
+
(original) =>
|
|
51
|
+
function () {
|
|
52
|
+
const args = arguments as unknown as Parameters<OBJECT[METHOD]>
|
|
53
|
+
let result
|
|
54
|
+
|
|
55
|
+
if (before) {
|
|
56
|
+
callMonitored(before, this, args)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (typeof original === 'function') {
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
61
|
+
result = original.apply(this, args)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (after) {
|
|
65
|
+
callMonitored(after, this, args)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
69
|
+
return result
|
|
70
|
+
}
|
|
71
|
+
)
|
|
116
72
|
}
|
|
117
73
|
|
|
118
|
-
export function instrumentSetter<
|
|
119
|
-
|
|
74
|
+
export function instrumentSetter<OBJECT extends { [key: string]: any }, PROPERTY extends keyof OBJECT>(
|
|
75
|
+
object: OBJECT,
|
|
120
76
|
property: PROPERTY,
|
|
121
|
-
after: (
|
|
77
|
+
after: (thisObject: OBJECT, value: OBJECT[PROPERTY]) => void
|
|
122
78
|
) {
|
|
123
|
-
const originalDescriptor = Object.getOwnPropertyDescriptor(
|
|
79
|
+
const originalDescriptor = Object.getOwnPropertyDescriptor(object, property)
|
|
124
80
|
if (!originalDescriptor || !originalDescriptor.set || !originalDescriptor.configurable) {
|
|
125
81
|
return { stop: noop }
|
|
126
82
|
}
|
|
127
83
|
|
|
128
|
-
let instrumentation = (
|
|
84
|
+
let instrumentation = (thisObject: OBJECT, value: OBJECT[PROPERTY]) => {
|
|
129
85
|
// put hooked setter into event loop to avoid of set latency
|
|
130
86
|
setTimeout(() => {
|
|
131
|
-
after(
|
|
87
|
+
after(thisObject, value)
|
|
132
88
|
}, 0)
|
|
133
89
|
}
|
|
134
90
|
|
|
135
|
-
const instrumentationWrapper = function (this:
|
|
91
|
+
const instrumentationWrapper = function (this: OBJECT, value: OBJECT[PROPERTY]) {
|
|
136
92
|
originalDescriptor.set!.call(this, value)
|
|
137
93
|
instrumentation(this, value)
|
|
138
94
|
}
|
|
139
95
|
|
|
140
|
-
Object.defineProperty(
|
|
96
|
+
Object.defineProperty(object, property, {
|
|
141
97
|
set: instrumentationWrapper,
|
|
142
98
|
})
|
|
143
99
|
|
|
144
100
|
return {
|
|
145
101
|
stop: () => {
|
|
146
|
-
if (Object.getOwnPropertyDescriptor(
|
|
147
|
-
Object.defineProperty(
|
|
102
|
+
if (Object.getOwnPropertyDescriptor(object, property)?.set === instrumentationWrapper) {
|
|
103
|
+
Object.defineProperty(object, property, originalDescriptor)
|
|
148
104
|
} else {
|
|
149
105
|
instrumentation = noop
|
|
150
106
|
}
|
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 { display } from './display'
|
|
1
|
+
import { ConsoleApiName, 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(e)
|
|
53
|
+
displayIfDebugEnabled(ConsoleApiName.error, e)
|
|
54
54
|
if (onMonitorErrorCollected) {
|
|
55
55
|
try {
|
|
56
56
|
onMonitorErrorCollected(e)
|
|
57
57
|
} catch (e) {
|
|
58
|
-
displayIfDebugEnabled(e)
|
|
58
|
+
displayIfDebugEnabled(ConsoleApiName.error, e)
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export function displayIfDebugEnabled(...args: any[]) {
|
|
64
|
+
export function displayIfDebugEnabled(api: ConsoleApiName, ...args: any[]) {
|
|
65
65
|
if (debugMode) {
|
|
66
|
-
display
|
|
66
|
+
display(api, '[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?: (
|
|
9
|
+
constructor(private onFirstSubscribe?: () => (() => 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(
|
|
13
|
+
this.onLastUnsubscribe = this.onFirstSubscribe() || undefined
|
|
14
14
|
}
|
|
15
15
|
this.observers.push(f)
|
|
16
16
|
return {
|
|
@@ -29,10 +29,12 @@ export class Observable<T> {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function mergeObservables<T>(...observables: Array<Observable<T>>) {
|
|
32
|
-
|
|
32
|
+
const globalObservable = new Observable<T>(() => {
|
|
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
|
|
38
40
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { computeBytesCount } from '../utils/byteUtils'
|
|
2
|
+
import { throttle } from '../utils/functionUtils'
|
|
3
|
+
import { deepClone } from '../mergeInto'
|
|
4
|
+
import { getType } from '../utils/typeUtils'
|
|
5
|
+
import { jsonStringify } from './jsonStringify'
|
|
6
|
+
import { sanitize } from './sanitize'
|
|
7
|
+
import { warnIfCustomerDataLimitReached } from './heavyCustomerDataWarning'
|
|
8
|
+
import type { CustomerDataType } from './heavyCustomerDataWarning'
|
|
9
|
+
import type { Context, ContextValue } from './context'
|
|
10
|
+
|
|
11
|
+
export const BYTES_COMPUTATION_THROTTLING_DELAY = 200
|
|
12
|
+
|
|
13
|
+
export type ContextManager = ReturnType<typeof createContextManager>
|
|
14
|
+
|
|
15
|
+
export function createContextManager(customerDataType: CustomerDataType, computeBytesCountImpl = computeBytesCount) {
|
|
16
|
+
let context: Context = {}
|
|
17
|
+
let bytesCountCache: number
|
|
18
|
+
let alreadyWarned = false
|
|
19
|
+
|
|
20
|
+
// Throttle the bytes computation to minimize the impact on performance.
|
|
21
|
+
// Especially useful if the user call context APIs synchronously multiple times in a row
|
|
22
|
+
const { throttled: computeBytesCountThrottled } = throttle((context: Context) => {
|
|
23
|
+
bytesCountCache = computeBytesCountImpl(jsonStringify(context)!)
|
|
24
|
+
if (!alreadyWarned) {
|
|
25
|
+
alreadyWarned = warnIfCustomerDataLimitReached(bytesCountCache, customerDataType)
|
|
26
|
+
}
|
|
27
|
+
}, BYTES_COMPUTATION_THROTTLING_DELAY)
|
|
28
|
+
|
|
29
|
+
const contextManager = {
|
|
30
|
+
getBytesCount: () => bytesCountCache,
|
|
31
|
+
/** @deprecated use getContext instead */
|
|
32
|
+
get: () => context,
|
|
33
|
+
|
|
34
|
+
/** @deprecated use setContextProperty instead */
|
|
35
|
+
add: (key: string, value: any) => {
|
|
36
|
+
context[key] = value as ContextValue
|
|
37
|
+
computeBytesCountThrottled(context)
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/** @deprecated renamed to removeContextProperty */
|
|
41
|
+
remove: (key: string) => {
|
|
42
|
+
delete context[key]
|
|
43
|
+
computeBytesCountThrottled(context)
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
/** @deprecated use setContext instead */
|
|
47
|
+
set: (newContext: object) => {
|
|
48
|
+
context = newContext as Context
|
|
49
|
+
computeBytesCountThrottled(context)
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
getContext: () => deepClone(context),
|
|
53
|
+
|
|
54
|
+
setContext: (newContext: Context) => {
|
|
55
|
+
if (getType(newContext) === 'object') {
|
|
56
|
+
context = sanitize(newContext)
|
|
57
|
+
computeBytesCountThrottled(context)
|
|
58
|
+
} else {
|
|
59
|
+
contextManager.clearContext()
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
setContextProperty: (key: string, property: any) => {
|
|
64
|
+
context[key] = sanitize(property)
|
|
65
|
+
computeBytesCountThrottled(context)
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
removeContextProperty: (key: string) => {
|
|
69
|
+
delete context[key]
|
|
70
|
+
computeBytesCountThrottled(context)
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
clearContext: () => {
|
|
74
|
+
context = {}
|
|
75
|
+
bytesCountCache = 0
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
return contextManager
|
|
79
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ONE_KIBI_BYTE } from '../utils/byteUtils'
|
|
2
|
+
import { display } from '../display'
|
|
3
|
+
|
|
4
|
+
// RUM and logs batch bytes limit is 16KB
|
|
5
|
+
// ensure that we leave room for other event attributes and maintain a decent amount of event per batch
|
|
6
|
+
// (3KB (customer data) + 1KB (other attributes)) * 4 (events per batch) = 16KB
|
|
7
|
+
export const CUSTOMER_DATA_BYTES_LIMIT = 3 * ONE_KIBI_BYTE
|
|
8
|
+
|
|
9
|
+
export const enum CustomerDataType {
|
|
10
|
+
FeatureFlag = 'feature flag evaluation',
|
|
11
|
+
User = 'user',
|
|
12
|
+
GlobalContext = 'global context',
|
|
13
|
+
LoggerContext = 'logger context',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function warnIfCustomerDataLimitReached(bytesCount: number, customerDataType: CustomerDataType): boolean {
|
|
17
|
+
if (bytesCount > CUSTOMER_DATA_BYTES_LIMIT) {
|
|
18
|
+
display.warn(
|
|
19
|
+
`The ${customerDataType} data exceeds the recommended ${
|
|
20
|
+
CUSTOMER_DATA_BYTES_LIMIT / ONE_KIBI_BYTE
|
|
21
|
+
}KiB threshold. More details: https://docs.datadoghq.com/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-3kib-warning`
|
|
22
|
+
)
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
return false
|
|
26
|
+
}
|
|
@@ -1,48 +1,7 @@
|
|
|
1
|
-
// Exported only for tests
|
|
2
|
-
export const enum Browser {
|
|
3
|
-
IE,
|
|
4
|
-
CHROMIUM,
|
|
5
|
-
SAFARI,
|
|
6
|
-
OTHER,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
1
|
export function isIE() {
|
|
10
|
-
return
|
|
2
|
+
return Boolean((document as any).documentMode)
|
|
11
3
|
}
|
|
12
4
|
|
|
13
5
|
export function isChromium() {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function isSafari() {
|
|
18
|
-
return detectBrowserCached() === Browser.SAFARI
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let browserCache: Browser | undefined
|
|
22
|
-
function detectBrowserCached() {
|
|
23
|
-
return browserCache ?? (browserCache = detectBrowser())
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Exported only for tests
|
|
27
|
-
export function detectBrowser(browserWindow: Window = window) {
|
|
28
|
-
const userAgent = browserWindow.navigator.userAgent
|
|
29
|
-
if ((browserWindow as any).chrome || /HeadlessChrome/.test(userAgent)) {
|
|
30
|
-
return Browser.CHROMIUM
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
// navigator.vendor is deprecated, but it is the most resilient way we found to detect
|
|
35
|
-
// "Apple maintained browsers" (AKA Safari). If one day it gets removed, we still have the
|
|
36
|
-
// useragent test as a semi-working fallback.
|
|
37
|
-
browserWindow.navigator.vendor?.indexOf('Apple') === 0 ||
|
|
38
|
-
(/safari/i.test(userAgent) && !/chrome|android/i.test(userAgent))
|
|
39
|
-
) {
|
|
40
|
-
return Browser.SAFARI
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if ((browserWindow.document as any).documentMode) {
|
|
44
|
-
return Browser.IE
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return Browser.OTHER
|
|
6
|
+
return !!(window as any).chrome || /HeadlessChrome/.test(window.navigator.userAgent)
|
|
48
7
|
}
|
|
@@ -27,7 +27,10 @@ export function find<T, S extends T>(
|
|
|
27
27
|
predicate: (item: T, index: number) => item is S
|
|
28
28
|
): S | undefined
|
|
29
29
|
export function find<T>(array: ArrayLike<T>, predicate: (item: T, index: number) => boolean): T | undefined
|
|
30
|
-
export function find(
|
|
30
|
+
export function find(
|
|
31
|
+
array: ArrayLike<unknown>,
|
|
32
|
+
predicate: (item: unknown, index: number) => boolean
|
|
33
|
+
): unknown | undefined {
|
|
31
34
|
for (let i = 0; i < array.length; i += 1) {
|
|
32
35
|
const item = array[i]
|
|
33
36
|
if (predicate(item, i)) {
|
|
@@ -9,36 +9,10 @@ export function generateUUID(placeholder?: string): string {
|
|
|
9
9
|
: `${1e7}-${1e3}-${4e3}-${8e3}-${1e11}`.replace(/[018]/g, generateUUID)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line no-constant-condition
|
|
17
|
-
while (true) {
|
|
18
|
-
const match = COMMA_SEPARATED_KEY_VALUE.exec(rawString)
|
|
19
|
-
if (match) {
|
|
20
|
-
if (match[1] === name) {
|
|
21
|
-
return match[2]
|
|
22
|
-
}
|
|
23
|
-
} else {
|
|
24
|
-
break
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function findCommaSeparatedValues(rawString: string): Map<string, string> {
|
|
30
|
-
const result = new Map<string, string>()
|
|
31
|
-
COMMA_SEPARATED_KEY_VALUE.lastIndex = 0
|
|
32
|
-
// eslint-disable-next-line no-constant-condition
|
|
33
|
-
while (true) {
|
|
34
|
-
const match = COMMA_SEPARATED_KEY_VALUE.exec(rawString)
|
|
35
|
-
if (match) {
|
|
36
|
-
result.set(match[1], match[2])
|
|
37
|
-
} else {
|
|
38
|
-
break
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return result
|
|
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
|
|
42
16
|
}
|
|
43
17
|
|
|
44
18
|
export function safeTruncate(candidate: string, length: number, suffix = '') {
|