@openobserve/browser-core 0.2.11-rc1 → 0.2.12-beta.1
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/package.json +6 -5
- package/src/boot/displayAlreadyInitializedError.ts +8 -0
- package/src/boot/init.ts +29 -15
- package/src/browser/addEventListener.ts +13 -10
- package/src/browser/{types.ts → browser.types.ts} +42 -0
- package/src/browser/cookie.ts +49 -14
- package/src/browser/fetchObservable.ts +80 -21
- package/src/browser/{pageExitObservable.ts → pageMayExitObservable.ts} +11 -22
- package/src/browser/runOnReadyState.ts +14 -4
- package/src/browser/xhrObservable.ts +17 -4
- package/src/domain/allowedTrackingOrigins.ts +30 -0
- package/src/domain/bufferedData.ts +32 -0
- package/src/domain/configuration/configuration.ts +352 -83
- package/src/domain/configuration/endpointBuilder.ts +29 -32
- package/src/domain/configuration/index.ts +6 -5
- package/src/domain/configuration/transportConfiguration.ts +42 -35
- package/src/domain/connectivity/connectivity.ts +5 -1
- package/src/domain/console/consoleObservable.ts +57 -21
- package/src/domain/context/contextConstants.ts +22 -0
- package/src/domain/context/contextManager.ts +48 -11
- package/src/domain/context/contextUtils.ts +14 -0
- package/src/domain/context/defineContextMethod.ts +31 -0
- package/src/domain/context/storeContextManager.ts +7 -3
- package/src/domain/contexts/accountContext.ts +47 -0
- package/src/domain/contexts/globalContext.ts +30 -0
- package/src/domain/contexts/rumInternalContext.type.ts +15 -0
- package/src/domain/contexts/userContext.ts +64 -0
- package/src/domain/deflate/{types.ts → deflate.types.ts} +6 -4
- package/src/domain/deflate/index.ts +1 -1
- package/src/domain/error/error.ts +28 -84
- package/src/domain/error/error.types.ts +10 -2
- package/src/domain/error/trackRuntimeError.ts +29 -32
- package/src/domain/eventRateLimiter/createEventRateLimiter.ts +5 -2
- package/src/domain/extension/extensionUtils.ts +28 -0
- package/src/domain/intakeSites.ts +18 -0
- package/src/domain/report/reportObservable.ts +35 -30
- package/src/domain/resourceUtils.ts +20 -16
- package/src/domain/session/README.md +193 -0
- package/src/domain/session/oldCookiesMigration.ts +2 -2
- package/src/domain/session/sessionConstants.ts +16 -1
- package/src/domain/session/sessionManager.ts +179 -15
- package/src/domain/session/sessionState.ts +49 -17
- package/src/domain/session/sessionStateValidation.ts +9 -0
- package/src/domain/session/sessionStore.ts +118 -55
- package/src/domain/session/sessionStoreOperations.ts +47 -20
- package/src/domain/session/storeStrategies/sessionInCookie.ts +105 -26
- package/src/domain/session/storeStrategies/sessionInLocalStorage.ts +10 -8
- package/src/domain/session/storeStrategies/sessionStoreStrategy.ts +5 -2
- package/src/domain/synthetics/syntheticsWorkerValues.ts +13 -2
- package/src/domain/tags.ts +76 -0
- package/src/domain/telemetry/index.ts +12 -4
- package/src/domain/telemetry/rawTelemetryEvent.types.ts +6 -3
- package/src/domain/telemetry/telemetry.ts +235 -106
- package/src/domain/telemetry/telemetryEvent.types.ts +514 -5
- package/src/domain/trackingConsent.ts +34 -0
- package/src/index.ts +90 -59
- package/src/tools/abstractHooks.ts +72 -0
- package/src/tools/abstractLifeCycle.ts +1 -0
- package/src/tools/boundedBuffer.ts +36 -8
- package/src/tools/display.ts +4 -0
- package/src/tools/encoder.ts +3 -2
- package/src/tools/experimentalFeatures.ts +18 -7
- package/src/tools/getZoneJsOriginalValue.ts +1 -1
- package/src/tools/{getGlobalObject.ts → globalObject.ts} +20 -0
- package/src/tools/instrumentMethod.ts +58 -41
- package/src/tools/matchOption.ts +1 -2
- package/src/tools/monitor.ts +11 -7
- package/src/tools/observable.ts +78 -12
- package/src/tools/queueMicrotask.ts +13 -0
- package/src/tools/readBytesFromStream.ts +24 -64
- package/src/tools/requestIdleCallback.ts +40 -0
- package/src/tools/sendToExtension.ts +3 -1
- package/src/tools/serialisation/context.ts +4 -1
- package/src/tools/serialisation/sanitize.ts +32 -14
- package/src/{domain/error → tools/stackTrace}/computeStackTrace.ts +72 -8
- package/src/tools/stackTrace/handlingStack.ts +48 -0
- package/src/tools/taskQueue.ts +63 -0
- package/src/tools/timer.ts +1 -1
- package/src/tools/utils/arrayUtils.ts +11 -3
- package/src/tools/utils/browserDetection.ts +0 -9
- package/src/tools/utils/byteUtils.ts +13 -2
- package/src/tools/utils/functionUtils.ts +0 -2
- package/src/tools/utils/numberUtils.ts +2 -1
- package/src/tools/utils/objectUtils.ts +1 -3
- package/src/tools/utils/polyfills.ts +6 -107
- package/src/tools/utils/responseUtils.ts +1 -1
- package/src/tools/utils/stringUtils.ts +34 -2
- package/src/tools/utils/timeUtils.ts +18 -13
- package/src/tools/utils/timezone.ts +9 -0
- package/src/tools/utils/urlPolyfill.ts +29 -59
- package/src/tools/valueHistory.ts +66 -35
- package/src/transport/batch.ts +77 -80
- package/src/transport/eventBridge.ts +24 -5
- package/src/transport/flushController.ts +27 -21
- package/src/transport/httpRequest.ts +92 -71
- package/src/transport/index.ts +7 -4
- package/src/transport/sendWithRetryStrategy.ts +55 -36
- package/cjs/boot/init.d.ts +0 -5
- package/cjs/boot/init.js +0 -36
- package/cjs/boot/init.js.map +0 -1
- package/cjs/browser/addEventListener.d.ts +0 -84
- package/cjs/browser/addEventListener.js +0 -94
- package/cjs/browser/addEventListener.js.map +0 -1
- package/cjs/browser/cookie.d.ts +0 -17
- package/cjs/browser/cookie.js +0 -86
- package/cjs/browser/cookie.js.map +0 -1
- package/cjs/browser/fetchObservable.d.ts +0 -23
- package/cjs/browser/fetchObservable.js +0 -69
- package/cjs/browser/fetchObservable.js.map +0 -1
- package/cjs/browser/pageExitObservable.d.ts +0 -14
- package/cjs/browser/pageExitObservable.js +0 -57
- package/cjs/browser/pageExitObservable.js.map +0 -1
- package/cjs/browser/runOnReadyState.d.ts +0 -2
- package/cjs/browser/runOnReadyState.js +0 -15
- package/cjs/browser/runOnReadyState.js.map +0 -1
- package/cjs/browser/types.d.ts +0 -19
- package/cjs/browser/types.js +0 -6
- package/cjs/browser/types.js.map +0 -1
- package/cjs/browser/xhrObservable.d.ts +0 -21
- package/cjs/browser/xhrObservable.js +0 -85
- package/cjs/browser/xhrObservable.js.map +0 -1
- package/cjs/domain/configuration/configuration.d.ts +0 -72
- package/cjs/domain/configuration/configuration.js +0 -94
- package/cjs/domain/configuration/configuration.js.map +0 -1
- package/cjs/domain/configuration/endpointBuilder.d.ts +0 -10
- package/cjs/domain/configuration/endpointBuilder.js +0 -84
- package/cjs/domain/configuration/endpointBuilder.js.map +0 -1
- package/cjs/domain/configuration/index.d.ts +0 -4
- package/cjs/domain/configuration/index.js +0 -27
- package/cjs/domain/configuration/index.js.map +0 -1
- package/cjs/domain/configuration/intakeSites.d.ts +0 -5
- package/cjs/domain/configuration/intakeSites.js +0 -9
- package/cjs/domain/configuration/intakeSites.js.map +0 -1
- package/cjs/domain/configuration/tags.d.ts +0 -4
- package/cjs/domain/configuration/tags.js +0 -39
- package/cjs/domain/configuration/tags.js.map +0 -1
- package/cjs/domain/configuration/transportConfiguration.d.ts +0 -16
- package/cjs/domain/configuration/transportConfiguration.js +0 -42
- package/cjs/domain/configuration/transportConfiguration.js.map +0 -1
- 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 +0 -18
- package/cjs/domain/connectivity/index.js.map +0 -1
- package/cjs/domain/console/consoleObservable.d.ts +0 -11
- package/cjs/domain/console/consoleObservable.js +0 -72
- package/cjs/domain/console/consoleObservable.js.map +0 -1
- package/cjs/domain/context/contextConstants.d.ts +0 -5
- package/cjs/domain/context/contextConstants.js +0 -3
- 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/deflate/types.d.ts +0 -0
- package/cjs/domain/deflate/types.js +0 -3
- package/cjs/domain/deflate/types.js.map +0 -1
- package/cjs/domain/error/computeStackTrace.d.ts +0 -33
- package/cjs/domain/error/computeStackTrace.js +0 -142
- package/cjs/domain/error/computeStackTrace.js.map +0 -1
- package/cjs/domain/error/error.d.ts +0 -28
- package/cjs/domain/error/error.js +0 -131
- package/cjs/domain/error/error.js.map +0 -1
- package/cjs/domain/error/error.types.d.ts +0 -40
- package/cjs/domain/error/error.types.js +0 -13
- package/cjs/domain/error/error.types.js.map +0 -1
- package/cjs/domain/error/trackRuntimeError.d.ts +0 -13
- package/cjs/domain/error/trackRuntimeError.js +0 -54
- package/cjs/domain/error/trackRuntimeError.js.map +0 -1
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.d.ts +0 -5
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.js +0 -40
- package/cjs/domain/eventRateLimiter/createEventRateLimiter.js.map +0 -1
- package/cjs/domain/report/browser.types.d.ts +0 -34
- package/cjs/domain/report/browser.types.js +0 -3
- package/cjs/domain/report/browser.types.js.map +0 -1
- package/cjs/domain/report/reportObservable.d.ts +0 -17
- package/cjs/domain/report/reportObservable.js +0 -94
- package/cjs/domain/report/reportObservable.js.map +0 -1
- package/cjs/domain/resourceUtils.d.ts +0 -16
- package/cjs/domain/resourceUtils.js +0 -3
- package/cjs/domain/resourceUtils.js.map +0 -1
- package/cjs/domain/session/oldCookiesMigration.d.ts +0 -11
- package/cjs/domain/session/oldCookiesMigration.js +0 -40
- package/cjs/domain/session/oldCookiesMigration.js.map +0 -1
- package/cjs/domain/session/sessionConstants.d.ts +0 -2
- package/cjs/domain/session/sessionConstants.js +0 -7
- package/cjs/domain/session/sessionConstants.js.map +0 -1
- package/cjs/domain/session/sessionManager.d.ts +0 -20
- package/cjs/domain/session/sessionManager.js +0 -65
- package/cjs/domain/session/sessionManager.js.map +0 -1
- package/cjs/domain/session/sessionState.d.ts +0 -11
- package/cjs/domain/session/sessionState.js +0 -45
- package/cjs/domain/session/sessionState.js.map +0 -1
- package/cjs/domain/session/sessionStore.d.ts +0 -34
- package/cjs/domain/session/sessionStore.js +0 -144
- package/cjs/domain/session/sessionStore.js.map +0 -1
- package/cjs/domain/session/sessionStoreOperations.d.ts +0 -10
- package/cjs/domain/session/sessionStoreOperations.js +0 -96
- package/cjs/domain/session/sessionStoreOperations.js.map +0 -1
- package/cjs/domain/session/storeStrategies/sessionInCookie.d.ts +0 -6
- package/cjs/domain/session/storeStrategies/sessionInCookie.js +0 -59
- package/cjs/domain/session/storeStrategies/sessionInCookie.js.map +0 -1
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.d.ts +0 -3
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js +0 -41
- package/cjs/domain/session/storeStrategies/sessionInLocalStorage.js.map +0 -1
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -15
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.js +0 -5
- package/cjs/domain/session/storeStrategies/sessionStoreStrategy.js.map +0 -1
- package/cjs/domain/synthetics/syntheticsWorkerValues.d.ts +0 -11
- package/cjs/domain/synthetics/syntheticsWorkerValues.js +0 -22
- package/cjs/domain/synthetics/syntheticsWorkerValues.js.map +0 -1
- package/cjs/domain/telemetry/index.d.ts +0 -3
- package/cjs/domain/telemetry/index.js +0 -28
- package/cjs/domain/telemetry/index.js.map +0 -1
- package/cjs/domain/telemetry/rawTelemetryEvent.types.d.ts +0 -15
- package/cjs/domain/telemetry/rawTelemetryEvent.types.js +0 -8
- package/cjs/domain/telemetry/rawTelemetryEvent.types.js.map +0 -1
- package/cjs/domain/telemetry/telemetry.d.ts +0 -116
- package/cjs/domain/telemetry/telemetry.js +0 -157
- package/cjs/domain/telemetry/telemetry.js.map +0 -1
- package/cjs/domain/telemetry/telemetryEvent.types.d.ts +0 -391
- package/cjs/domain/telemetry/telemetryEvent.types.js +0 -7
- package/cjs/domain/telemetry/telemetryEvent.types.js.map +0 -1
- package/cjs/domain/user/index.d.ts +0 -2
- package/cjs/domain/user/index.js +0 -19
- package/cjs/domain/user/index.js.map +0 -1
- package/cjs/domain/user/user.d.ts +0 -12
- package/cjs/domain/user/user.js +0 -35
- package/cjs/domain/user/user.js.map +0 -1
- package/cjs/domain/user/user.types.d.ts +0 -6
- package/cjs/domain/user/user.types.js +0 -3
- package/cjs/domain/user/user.types.js.map +0 -1
- package/cjs/tools/abstractLifeCycle.d.ts +0 -23
- package/cjs/tools/abstractLifeCycle.js +0 -29
- package/cjs/tools/abstractLifeCycle.js.map +0 -1
- package/cjs/tools/boundedBuffer.d.ts +0 -5
- package/cjs/tools/boundedBuffer.js +0 -22
- package/cjs/tools/boundedBuffer.js.map +0 -1
- package/cjs/tools/catchUserErrors.d.ts +0 -1
- package/cjs/tools/catchUserErrors.js +0 -20
- package/cjs/tools/catchUserErrors.js.map +0 -1
- package/cjs/tools/display.d.ts +0 -35
- package/cjs/tools/display.js +0 -41
- package/cjs/tools/display.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/cjs/tools/experimentalFeatures.d.ts +0 -22
- package/cjs/tools/experimentalFeatures.js +0 -45
- package/cjs/tools/experimentalFeatures.js.map +0 -1
- package/cjs/tools/getGlobalObject.d.ts +0 -4
- package/cjs/tools/getGlobalObject.js +0 -37
- package/cjs/tools/getGlobalObject.js.map +0 -1
- package/cjs/tools/getZoneJsOriginalValue.d.ts +0 -19
- package/cjs/tools/getZoneJsOriginalValue.js +0 -30
- package/cjs/tools/getZoneJsOriginalValue.js.map +0 -1
- package/cjs/tools/instrumentMethod.d.ts +0 -59
- package/cjs/tools/instrumentMethod.js +0 -106
- package/cjs/tools/instrumentMethod.js.map +0 -1
- package/cjs/tools/matchOption.d.ts +0 -8
- package/cjs/tools/matchOption.js +0 -38
- package/cjs/tools/matchOption.js.map +0 -1
- package/cjs/tools/mergeInto.d.ts +0 -25
- package/cjs/tools/mergeInto.js +0 -105
- package/cjs/tools/mergeInto.js.map +0 -1
- package/cjs/tools/monitor.d.ts +0 -8
- package/cjs/tools/monitor.js +0 -76
- package/cjs/tools/monitor.js.map +0 -1
- package/cjs/tools/observable.d.ts +0 -12
- package/cjs/tools/observable.js +0 -43
- package/cjs/tools/observable.js.map +0 -1
- package/cjs/tools/readBytesFromStream.d.ts +0 -11
- package/cjs/tools/readBytesFromStream.js +0 -64
- package/cjs/tools/readBytesFromStream.js.map +0 -1
- package/cjs/tools/sendToExtension.d.ts +0 -3
- package/cjs/tools/sendToExtension.js +0 -11
- package/cjs/tools/sendToExtension.js.map +0 -1
- package/cjs/tools/serialisation/context.d.ts +0 -6
- package/cjs/tools/serialisation/context.js +0 -3
- package/cjs/tools/serialisation/context.js.map +0 -1
- package/cjs/tools/serialisation/jsonStringify.d.ts +0 -13
- package/cjs/tools/serialisation/jsonStringify.js +0 -49
- package/cjs/tools/serialisation/jsonStringify.js.map +0 -1
- package/cjs/tools/serialisation/sanitize.d.ts +0 -18
- package/cjs/tools/serialisation/sanitize.js +0 -185
- package/cjs/tools/serialisation/sanitize.js.map +0 -1
- package/cjs/tools/timer.d.ts +0 -5
- package/cjs/tools/timer.js +0 -23
- package/cjs/tools/timer.js.map +0 -1
- package/cjs/tools/utils/arrayUtils.d.ts +0 -1
- package/cjs/tools/utils/arrayUtils.js +0 -11
- package/cjs/tools/utils/arrayUtils.js.map +0 -1
- package/cjs/tools/utils/browserDetection.d.ts +0 -10
- package/cjs/tools/utils/browserDetection.js +0 -42
- package/cjs/tools/utils/browserDetection.js.map +0 -1
- package/cjs/tools/utils/byteUtils.d.ts +0 -4
- package/cjs/tools/utils/byteUtils.js +0 -31
- package/cjs/tools/utils/byteUtils.js.map +0 -1
- package/cjs/tools/utils/functionUtils.d.ts +0 -9
- package/cjs/tools/utils/functionUtils.js +0 -48
- package/cjs/tools/utils/functionUtils.js.map +0 -1
- package/cjs/tools/utils/numberUtils.d.ts +0 -8
- package/cjs/tools/utils/numberUtils.js +0 -24
- package/cjs/tools/utils/numberUtils.js.map +0 -1
- package/cjs/tools/utils/objectUtils.d.ts +0 -10
- package/cjs/tools/utils/objectUtils.js +0 -26
- package/cjs/tools/utils/objectUtils.js.map +0 -1
- package/cjs/tools/utils/polyfills.d.ts +0 -24
- package/cjs/tools/utils/polyfills.js +0 -110
- package/cjs/tools/utils/polyfills.js.map +0 -1
- package/cjs/tools/utils/responseUtils.d.ts +0 -2
- package/cjs/tools/utils/responseUtils.js +0 -18
- package/cjs/tools/utils/responseUtils.js.map +0 -1
- package/cjs/tools/utils/stringUtils.d.ts +0 -8
- package/cjs/tools/utils/stringUtils.js +0 -59
- package/cjs/tools/utils/stringUtils.js.map +0 -1
- package/cjs/tools/utils/timeUtils.d.ts +0 -57
- package/cjs/tools/utils/timeUtils.js +0 -99
- package/cjs/tools/utils/timeUtils.js.map +0 -1
- package/cjs/tools/utils/typeUtils.d.ts +0 -4
- package/cjs/tools/utils/typeUtils.js +0 -17
- package/cjs/tools/utils/typeUtils.js.map +0 -1
- package/cjs/tools/utils/urlPolyfill.d.ts +0 -14
- package/cjs/tools/utils/urlPolyfill.js +0 -92
- package/cjs/tools/utils/urlPolyfill.js.map +0 -1
- package/cjs/tools/valueHistory.d.ts +0 -50
- package/cjs/tools/valueHistory.js +0 -106
- package/cjs/tools/valueHistory.js.map +0 -1
- package/cjs/transport/batch.d.ts +0 -21
- package/cjs/transport/batch.js +0 -123
- package/cjs/transport/batch.js.map +0 -1
- package/cjs/transport/eventBridge.d.ts +0 -12
- package/cjs/transport/eventBridge.js +0 -34
- package/cjs/transport/eventBridge.js.map +0 -1
- package/cjs/transport/flushController.d.ts +0 -58
- package/cjs/transport/flushController.js +0 -112
- package/cjs/transport/flushController.js.map +0 -1
- package/cjs/transport/httpRequest.d.ts +0 -38
- package/cjs/transport/httpRequest.js +0 -95
- package/cjs/transport/httpRequest.js.map +0 -1
- package/cjs/transport/index.d.ts +0 -4
- package/cjs/transport/index.js +0 -13
- package/cjs/transport/index.js.map +0 -1
- package/cjs/transport/sendWithRetryStrategy.d.ts +0 -39
- package/cjs/transport/sendWithRetryStrategy.js +0 -151
- package/cjs/transport/sendWithRetryStrategy.js.map +0 -1
- package/cjs/transport/startBatchWithReplica.d.ts +0 -20
- package/cjs/transport/startBatchWithReplica.js +0 -42
- package/cjs/transport/startBatchWithReplica.js.map +0 -1
- package/esm/boot/init.d.ts +0 -5
- package/esm/boot/init.js +0 -31
- package/esm/boot/init.js.map +0 -1
- package/esm/browser/addEventListener.d.ts +0 -84
- package/esm/browser/addEventListener.js +0 -89
- package/esm/browser/addEventListener.js.map +0 -1
- package/esm/browser/cookie.d.ts +0 -17
- package/esm/browser/cookie.js +0 -76
- package/esm/browser/cookie.js.map +0 -1
- package/esm/browser/fetchObservable.d.ts +0 -23
- package/esm/browser/fetchObservable.js +0 -65
- package/esm/browser/fetchObservable.js.map +0 -1
- package/esm/browser/pageExitObservable.d.ts +0 -14
- package/esm/browser/pageExitObservable.js +0 -52
- package/esm/browser/pageExitObservable.js.map +0 -1
- package/esm/browser/runOnReadyState.d.ts +0 -2
- package/esm/browser/runOnReadyState.js +0 -11
- package/esm/browser/runOnReadyState.js.map +0 -1
- package/esm/browser/types.d.ts +0 -19
- package/esm/browser/types.js +0 -5
- package/esm/browser/types.js.map +0 -1
- package/esm/browser/xhrObservable.d.ts +0 -21
- package/esm/browser/xhrObservable.js +0 -81
- package/esm/browser/xhrObservable.js.map +0 -1
- package/esm/domain/configuration/configuration.d.ts +0 -72
- package/esm/domain/configuration/configuration.js +0 -89
- package/esm/domain/configuration/configuration.js.map +0 -1
- package/esm/domain/configuration/endpointBuilder.d.ts +0 -10
- package/esm/domain/configuration/endpointBuilder.js +0 -80
- package/esm/domain/configuration/endpointBuilder.js.map +0 -1
- package/esm/domain/configuration/index.d.ts +0 -4
- package/esm/domain/configuration/index.js +0 -5
- package/esm/domain/configuration/index.js.map +0 -1
- package/esm/domain/configuration/intakeSites.d.ts +0 -5
- package/esm/domain/configuration/intakeSites.js +0 -6
- package/esm/domain/configuration/intakeSites.js.map +0 -1
- package/esm/domain/configuration/tags.d.ts +0 -4
- package/esm/domain/configuration/tags.js +0 -34
- package/esm/domain/configuration/tags.js.map +0 -1
- package/esm/domain/configuration/transportConfiguration.d.ts +0 -16
- package/esm/domain/configuration/transportConfiguration.js +0 -38
- package/esm/domain/configuration/transportConfiguration.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/console/consoleObservable.d.ts +0 -11
- package/esm/domain/console/consoleObservable.js +0 -67
- package/esm/domain/console/consoleObservable.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/deflate/index.d.ts +0 -1
- package/esm/domain/deflate/index.js +0 -2
- package/esm/domain/deflate/index.js.map +0 -1
- package/esm/domain/deflate/types.d.ts +0 -38
- package/esm/domain/deflate/types.js +0 -2
- package/esm/domain/deflate/types.js.map +0 -1
- package/esm/domain/error/computeStackTrace.d.ts +0 -33
- package/esm/domain/error/computeStackTrace.js +0 -137
- package/esm/domain/error/computeStackTrace.js.map +0 -1
- package/esm/domain/error/error.d.ts +0 -28
- package/esm/domain/error/error.js +0 -121
- package/esm/domain/error/error.js.map +0 -1
- package/esm/domain/error/error.types.d.ts +0 -40
- package/esm/domain/error/error.types.js +0 -10
- package/esm/domain/error/error.types.js.map +0 -1
- package/esm/domain/error/trackRuntimeError.d.ts +0 -13
- package/esm/domain/error/trackRuntimeError.js +0 -48
- package/esm/domain/error/trackRuntimeError.js.map +0 -1
- package/esm/domain/eventRateLimiter/createEventRateLimiter.d.ts +0 -5
- package/esm/domain/eventRateLimiter/createEventRateLimiter.js +0 -36
- package/esm/domain/eventRateLimiter/createEventRateLimiter.js.map +0 -1
- package/esm/domain/report/browser.types.d.ts +0 -34
- package/esm/domain/report/browser.types.js +0 -2
- package/esm/domain/report/browser.types.js.map +0 -1
- package/esm/domain/report/reportObservable.d.ts +0 -17
- package/esm/domain/report/reportObservable.js +0 -90
- package/esm/domain/report/reportObservable.js.map +0 -1
- package/esm/domain/resourceUtils.d.ts +0 -16
- package/esm/domain/resourceUtils.js +0 -2
- package/esm/domain/resourceUtils.js.map +0 -1
- package/esm/domain/session/oldCookiesMigration.d.ts +0 -11
- package/esm/domain/session/oldCookiesMigration.js +0 -36
- package/esm/domain/session/oldCookiesMigration.js.map +0 -1
- package/esm/domain/session/sessionConstants.d.ts +0 -2
- package/esm/domain/session/sessionConstants.js +0 -4
- package/esm/domain/session/sessionConstants.js.map +0 -1
- package/esm/domain/session/sessionManager.d.ts +0 -20
- package/esm/domain/session/sessionManager.js +0 -60
- package/esm/domain/session/sessionManager.js.map +0 -1
- package/esm/domain/session/sessionState.d.ts +0 -11
- package/esm/domain/session/sessionState.js +0 -38
- package/esm/domain/session/sessionState.js.map +0 -1
- package/esm/domain/session/sessionStore.d.ts +0 -34
- package/esm/domain/session/sessionStore.js +0 -139
- package/esm/domain/session/sessionStore.js.map +0 -1
- package/esm/domain/session/sessionStoreOperations.d.ts +0 -10
- package/esm/domain/session/sessionStoreOperations.js +0 -92
- package/esm/domain/session/sessionStoreOperations.js.map +0 -1
- package/esm/domain/session/storeStrategies/sessionInCookie.d.ts +0 -6
- package/esm/domain/session/storeStrategies/sessionInCookie.js +0 -53
- package/esm/domain/session/storeStrategies/sessionInCookie.js.map +0 -1
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.d.ts +0 -3
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js +0 -36
- package/esm/domain/session/storeStrategies/sessionInLocalStorage.js.map +0 -1
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.d.ts +0 -15
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.js +0 -2
- package/esm/domain/session/storeStrategies/sessionStoreStrategy.js.map +0 -1
- package/esm/domain/synthetics/syntheticsWorkerValues.d.ts +0 -11
- package/esm/domain/synthetics/syntheticsWorkerValues.js +0 -16
- package/esm/domain/synthetics/syntheticsWorkerValues.js.map +0 -1
- package/esm/domain/telemetry/index.d.ts +0 -3
- package/esm/domain/telemetry/index.js +0 -4
- package/esm/domain/telemetry/index.js.map +0 -1
- package/esm/domain/telemetry/rawTelemetryEvent.types.d.ts +0 -15
- package/esm/domain/telemetry/rawTelemetryEvent.types.js +0 -5
- package/esm/domain/telemetry/rawTelemetryEvent.types.js.map +0 -1
- package/esm/domain/telemetry/telemetry.d.ts +0 -116
- package/esm/domain/telemetry/telemetry.js +0 -145
- package/esm/domain/telemetry/telemetry.js.map +0 -1
- package/esm/domain/telemetry/telemetryEvent.types.d.ts +0 -391
- package/esm/domain/telemetry/telemetryEvent.types.js +0 -6
- package/esm/domain/telemetry/telemetryEvent.types.js.map +0 -1
- package/esm/domain/user/index.d.ts +0 -2
- package/esm/domain/user/index.js +0 -3
- package/esm/domain/user/index.js.map +0 -1
- package/esm/domain/user/user.d.ts +0 -12
- package/esm/domain/user/user.js +0 -30
- package/esm/domain/user/user.js.map +0 -1
- package/esm/domain/user/user.types.d.ts +0 -6
- package/esm/domain/user/user.types.js +0 -2
- package/esm/domain/user/user.types.js.map +0 -1
- package/esm/index.d.ts +0 -67
- package/esm/index.js +0 -64
- package/esm/index.js.map +0 -1
- package/esm/tools/abstractLifeCycle.d.ts +0 -23
- package/esm/tools/abstractLifeCycle.js +0 -26
- package/esm/tools/abstractLifeCycle.js.map +0 -1
- package/esm/tools/boundedBuffer.d.ts +0 -5
- package/esm/tools/boundedBuffer.js +0 -19
- package/esm/tools/boundedBuffer.js.map +0 -1
- package/esm/tools/catchUserErrors.d.ts +0 -1
- package/esm/tools/catchUserErrors.js +0 -16
- package/esm/tools/catchUserErrors.js.map +0 -1
- package/esm/tools/display.d.ts +0 -35
- package/esm/tools/display.js +0 -38
- package/esm/tools/display.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/esm/tools/experimentalFeatures.d.ts +0 -22
- package/esm/tools/experimentalFeatures.js +0 -38
- package/esm/tools/experimentalFeatures.js.map +0 -1
- package/esm/tools/getGlobalObject.d.ts +0 -4
- package/esm/tools/getGlobalObject.js +0 -33
- package/esm/tools/getGlobalObject.js.map +0 -1
- package/esm/tools/getZoneJsOriginalValue.d.ts +0 -19
- package/esm/tools/getZoneJsOriginalValue.js +0 -26
- package/esm/tools/getZoneJsOriginalValue.js.map +0 -1
- package/esm/tools/instrumentMethod.d.ts +0 -59
- package/esm/tools/instrumentMethod.js +0 -101
- package/esm/tools/instrumentMethod.js.map +0 -1
- package/esm/tools/matchOption.d.ts +0 -8
- package/esm/tools/matchOption.js +0 -33
- package/esm/tools/matchOption.js.map +0 -1
- package/esm/tools/mergeInto.d.ts +0 -25
- package/esm/tools/mergeInto.js +0 -99
- package/esm/tools/mergeInto.js.map +0 -1
- package/esm/tools/monitor.d.ts +0 -8
- package/esm/tools/monitor.js +0 -66
- package/esm/tools/monitor.js.map +0 -1
- package/esm/tools/observable.d.ts +0 -12
- package/esm/tools/observable.js +0 -39
- package/esm/tools/observable.js.map +0 -1
- package/esm/tools/readBytesFromStream.d.ts +0 -11
- package/esm/tools/readBytesFromStream.js +0 -60
- package/esm/tools/readBytesFromStream.js.map +0 -1
- package/esm/tools/sendToExtension.d.ts +0 -3
- package/esm/tools/sendToExtension.js +0 -7
- package/esm/tools/sendToExtension.js.map +0 -1
- package/esm/tools/serialisation/context.d.ts +0 -6
- package/esm/tools/serialisation/context.js +0 -2
- package/esm/tools/serialisation/context.js.map +0 -1
- package/esm/tools/serialisation/jsonStringify.d.ts +0 -13
- package/esm/tools/serialisation/jsonStringify.js +0 -44
- package/esm/tools/serialisation/jsonStringify.js.map +0 -1
- package/esm/tools/serialisation/sanitize.d.ts +0 -18
- package/esm/tools/serialisation/sanitize.js +0 -181
- package/esm/tools/serialisation/sanitize.js.map +0 -1
- package/esm/tools/timer.d.ts +0 -5
- package/esm/tools/timer.js +0 -16
- package/esm/tools/timer.js.map +0 -1
- package/esm/tools/utils/arrayUtils.d.ts +0 -1
- package/esm/tools/utils/arrayUtils.js +0 -7
- package/esm/tools/utils/arrayUtils.js.map +0 -1
- package/esm/tools/utils/browserDetection.d.ts +0 -10
- package/esm/tools/utils/browserDetection.js +0 -35
- package/esm/tools/utils/browserDetection.js.map +0 -1
- package/esm/tools/utils/byteUtils.d.ts +0 -4
- package/esm/tools/utils/byteUtils.js +0 -26
- package/esm/tools/utils/byteUtils.js.map +0 -1
- package/esm/tools/utils/functionUtils.d.ts +0 -9
- package/esm/tools/utils/functionUtils.js +0 -43
- package/esm/tools/utils/functionUtils.js.map +0 -1
- package/esm/tools/utils/numberUtils.d.ts +0 -8
- package/esm/tools/utils/numberUtils.js +0 -17
- package/esm/tools/utils/numberUtils.js.map +0 -1
- package/esm/tools/utils/objectUtils.d.ts +0 -10
- package/esm/tools/utils/objectUtils.js +0 -19
- package/esm/tools/utils/objectUtils.js.map +0 -1
- package/esm/tools/utils/polyfills.d.ts +0 -24
- package/esm/tools/utils/polyfills.js +0 -95
- package/esm/tools/utils/polyfills.js.map +0 -1
- package/esm/tools/utils/responseUtils.d.ts +0 -2
- package/esm/tools/utils/responseUtils.js +0 -13
- package/esm/tools/utils/responseUtils.js.map +0 -1
- package/esm/tools/utils/stringUtils.d.ts +0 -8
- package/esm/tools/utils/stringUtils.js +0 -52
- package/esm/tools/utils/stringUtils.js.map +0 -1
- package/esm/tools/utils/timeUtils.d.ts +0 -57
- package/esm/tools/utils/timeUtils.js +0 -82
- package/esm/tools/utils/timeUtils.js.map +0 -1
- package/esm/tools/utils/typeUtils.d.ts +0 -4
- package/esm/tools/utils/typeUtils.js +0 -13
- package/esm/tools/utils/typeUtils.js.map +0 -1
- package/esm/tools/utils/urlPolyfill.d.ts +0 -14
- package/esm/tools/utils/urlPolyfill.js +0 -80
- package/esm/tools/utils/urlPolyfill.js.map +0 -1
- package/esm/tools/valueHistory.d.ts +0 -50
- package/esm/tools/valueHistory.js +0 -103
- package/esm/tools/valueHistory.js.map +0 -1
- package/esm/transport/batch.d.ts +0 -21
- package/esm/transport/batch.js +0 -120
- package/esm/transport/batch.js.map +0 -1
- package/esm/transport/eventBridge.d.ts +0 -12
- package/esm/transport/eventBridge.js +0 -29
- package/esm/transport/eventBridge.js.map +0 -1
- package/esm/transport/flushController.d.ts +0 -58
- package/esm/transport/flushController.js +0 -108
- package/esm/transport/flushController.js.map +0 -1
- package/esm/transport/httpRequest.d.ts +0 -38
- package/esm/transport/httpRequest.js +0 -89
- package/esm/transport/httpRequest.js.map +0 -1
- package/esm/transport/index.d.ts +0 -4
- package/esm/transport/index.js +0 -5
- package/esm/transport/index.js.map +0 -1
- package/esm/transport/sendWithRetryStrategy.d.ts +0 -39
- package/esm/transport/sendWithRetryStrategy.js +0 -146
- package/esm/transport/sendWithRetryStrategy.js.map +0 -1
- package/esm/transport/startBatchWithReplica.d.ts +0 -20
- package/esm/transport/startBatchWithReplica.js +0 -38
- package/esm/transport/startBatchWithReplica.js.map +0 -1
- package/src/domain/configuration/intakeSites.ts +0 -5
- package/src/domain/configuration/tags.ts +0 -43
- package/src/domain/context/customerDataTracker.ts +0 -134
- package/src/domain/user/index.ts +0 -2
- package/src/domain/user/user.ts +0 -33
- package/src/domain/user/user.types.ts +0 -6
- package/src/transport/startBatchWithReplica.ts +0 -68
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getInitCookie } from '../../browser/cookie'
|
|
2
|
+
import { globalObject, isWorkerEnvironment } from '../../tools/globalObject'
|
|
2
3
|
|
|
3
4
|
export const SYNTHETICS_TEST_ID_COOKIE_NAME = 'openobserve-synthetics-public-id'
|
|
4
5
|
export const SYNTHETICS_RESULT_ID_COOKIE_NAME = 'openobserve-synthetics-result-id'
|
|
@@ -11,8 +12,13 @@ export interface BrowserWindow extends Window {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export function willSyntheticsInjectRum(): boolean {
|
|
15
|
+
if (isWorkerEnvironment) {
|
|
16
|
+
// We don't expect to run synthetics tests in a worker environment
|
|
17
|
+
return false
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
return Boolean(
|
|
15
|
-
(
|
|
21
|
+
(globalObject as BrowserWindow)._OO_SYNTHETICS_INJECTS_RUM || getInitCookie(SYNTHETICS_INJECTS_RUM_COOKIE_NAME)
|
|
16
22
|
)
|
|
17
23
|
}
|
|
18
24
|
|
|
@@ -22,6 +28,11 @@ export function getSyntheticsTestId(): string | undefined {
|
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
export function getSyntheticsResultId(): string | undefined {
|
|
25
|
-
const value =
|
|
31
|
+
const value =
|
|
32
|
+
(window as BrowserWindow)._OO_SYNTHETICS_RESULT_ID || getInitCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME)
|
|
26
33
|
return typeof value === 'string' ? value : undefined
|
|
27
34
|
}
|
|
35
|
+
|
|
36
|
+
export function isSyntheticsTest(): boolean {
|
|
37
|
+
return Boolean(getSyntheticsTestId() && getSyntheticsResultId())
|
|
38
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { DOCS_ORIGIN, MORE_DETAILS, display } from '../tools/display'
|
|
2
|
+
import type { Configuration } from './configuration'
|
|
3
|
+
|
|
4
|
+
export const TAG_SIZE_LIMIT = 200
|
|
5
|
+
|
|
6
|
+
// replaced at build time
|
|
7
|
+
declare const __BUILD_ENV__SDK_VERSION__: string
|
|
8
|
+
|
|
9
|
+
export function buildTags(configuration: Configuration): string[] {
|
|
10
|
+
const { env, service, version, datacenter, sdkVersion, variant } = configuration
|
|
11
|
+
const tags = [buildTag('sdk_version', sdkVersion ?? __BUILD_ENV__SDK_VERSION__)]
|
|
12
|
+
|
|
13
|
+
if (env) {
|
|
14
|
+
tags.push(buildTag('env', env))
|
|
15
|
+
}
|
|
16
|
+
if (service) {
|
|
17
|
+
tags.push(buildTag('service', service))
|
|
18
|
+
}
|
|
19
|
+
if (version) {
|
|
20
|
+
tags.push(buildTag('version', version))
|
|
21
|
+
}
|
|
22
|
+
if (datacenter) {
|
|
23
|
+
tags.push(buildTag('datacenter', datacenter))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (variant) {
|
|
27
|
+
tags.push(buildTag('variant', variant))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return tags
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function buildTag(key: string, rawValue?: string) {
|
|
34
|
+
// See https://docs.datadoghq.com/getting_started/tagging/#defining-tags for tags syntax. Note
|
|
35
|
+
// that the backend may not follow the exact same rules, so we only want to display an informal
|
|
36
|
+
// warning.
|
|
37
|
+
const tag = rawValue ? `${key}:${rawValue}` : key
|
|
38
|
+
|
|
39
|
+
if (tag.length > TAG_SIZE_LIMIT || hasForbiddenCharacters(tag)) {
|
|
40
|
+
display.warn(
|
|
41
|
+
`Tag ${tag} doesn't meet tag requirements and will be sanitized. ${MORE_DETAILS} ${DOCS_ORIGIN}/getting_started/tagging/#defining-tags`
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Let the backend do most of the sanitization, but still make sure multiple tags can't be crafted
|
|
46
|
+
// by forging a value containing commas.
|
|
47
|
+
return sanitizeTag(tag)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function sanitizeTag(tag: string) {
|
|
51
|
+
return tag.replace(/,/g, '_')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function hasForbiddenCharacters(rawValue: string) {
|
|
55
|
+
// Unicode property escapes is not supported in all browsers, so we use a try/catch.
|
|
56
|
+
// Todo: Remove the try/catch when dropping support for Chrome 63 and Firefox 67
|
|
57
|
+
// see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape#browser_compatibility
|
|
58
|
+
if (!supportUnicodePropertyEscapes()) {
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// We use the Unicode property escapes to match any character that is a letter including other languages like Chinese, Japanese, etc.
|
|
63
|
+
// p{Ll} matches a lowercase letter.
|
|
64
|
+
// p{Lo} matches a letter that is neither uppercase nor lowercase (ex: Japanese characters).
|
|
65
|
+
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape#unicode_property_escapes_vs._character_classes
|
|
66
|
+
return new RegExp('[^\\p{Ll}\\p{Lo}0-9_:./-]', 'u').test(rawValue)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function supportUnicodePropertyEscapes() {
|
|
70
|
+
try {
|
|
71
|
+
new RegExp('[\\p{Ll}]', 'u')
|
|
72
|
+
return true
|
|
73
|
+
} catch {
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
+
export type { Telemetry } from './telemetry'
|
|
1
2
|
export {
|
|
2
|
-
Telemetry,
|
|
3
3
|
TelemetryService,
|
|
4
|
+
TelemetryMetrics,
|
|
4
5
|
addTelemetryDebug,
|
|
5
6
|
addTelemetryError,
|
|
6
|
-
startFakeTelemetry,
|
|
7
7
|
resetTelemetry,
|
|
8
8
|
startTelemetry,
|
|
9
|
-
isTelemetryReplicationAllowed,
|
|
10
9
|
addTelemetryConfiguration,
|
|
10
|
+
addTelemetryUsage,
|
|
11
|
+
addTelemetryMetrics,
|
|
12
|
+
getTelemetryObservable,
|
|
11
13
|
} from './telemetry'
|
|
12
14
|
|
|
13
15
|
export * from './rawTelemetryEvent.types'
|
|
14
|
-
export
|
|
16
|
+
export type {
|
|
17
|
+
TelemetryEvent,
|
|
18
|
+
TelemetryErrorEvent,
|
|
19
|
+
TelemetryDebugEvent,
|
|
20
|
+
TelemetryConfigurationEvent,
|
|
21
|
+
TelemetryUsageEvent,
|
|
22
|
+
} from './telemetryEvent.types'
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { TelemetryEvent, TelemetryConfigurationEvent } from './telemetryEvent.types'
|
|
1
|
+
import type { TelemetryEvent, TelemetryConfigurationEvent, TelemetryUsageEvent } from './telemetryEvent.types'
|
|
2
2
|
|
|
3
3
|
export const TelemetryType = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
LOG: 'log',
|
|
5
|
+
CONFIGURATION: 'configuration',
|
|
6
|
+
USAGE: 'usage',
|
|
6
7
|
} as const
|
|
7
8
|
|
|
8
9
|
export const enum StatusType {
|
|
@@ -17,3 +18,5 @@ export interface RuntimeEnvInfo {
|
|
|
17
18
|
|
|
18
19
|
export type RawTelemetryEvent = TelemetryEvent['telemetry']
|
|
19
20
|
export type RawTelemetryConfiguration = TelemetryConfigurationEvent['telemetry']['configuration']
|
|
21
|
+
export type RawTelemetryUsage = TelemetryUsageEvent['telemetry']['usage']
|
|
22
|
+
export type RawTelemetryUsageFeature = TelemetryUsageEvent['telemetry']['usage']['feature']
|
|
@@ -1,27 +1,48 @@
|
|
|
1
1
|
import type { Context } from '../../tools/serialisation/context'
|
|
2
2
|
import { ConsoleApiName } from '../../tools/display'
|
|
3
|
-
import {
|
|
3
|
+
import { NO_ERROR_STACK_PRESENT_MESSAGE, isError } from '../error/error'
|
|
4
|
+
import { toStackTraceString } from '../../tools/stackTrace/handlingStack'
|
|
4
5
|
import { getExperimentalFeatures } from '../../tools/experimentalFeatures'
|
|
5
6
|
import type { Configuration } from '../configuration'
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { buildTags } from '../tags'
|
|
8
|
+
import { INTAKE_SITE_STAGING, INTAKE_SITE_US1_FED } from '../intakeSites'
|
|
9
|
+
import { BufferedObservable, Observable } from '../../tools/observable'
|
|
10
|
+
import { clocksNow } from '../../tools/utils/timeUtils'
|
|
9
11
|
import { displayIfDebugEnabled, startMonitorErrorCollection } from '../../tools/monitor'
|
|
10
12
|
import { sendToExtension } from '../../tools/sendToExtension'
|
|
11
|
-
import { startsWith, arrayFrom, includes, assign } from '../../tools/utils/polyfills'
|
|
12
13
|
import { performDraw } from '../../tools/utils/numberUtils'
|
|
13
14
|
import { jsonStringify } from '../../tools/serialisation/jsonStringify'
|
|
14
15
|
import { combine } from '../../tools/mergeInto'
|
|
16
|
+
import type { RawError } from '../error/error.types'
|
|
15
17
|
import { NonErrorPrefix } from '../error/error.types'
|
|
16
|
-
import type { StackTrace } from '
|
|
17
|
-
import { computeStackTrace } from '
|
|
18
|
+
import type { StackTrace } from '../../tools/stackTrace/computeStackTrace'
|
|
19
|
+
import { computeStackTrace } from '../../tools/stackTrace/computeStackTrace'
|
|
18
20
|
import { getConnectivity } from '../connectivity'
|
|
21
|
+
import {
|
|
22
|
+
canUseEventBridge,
|
|
23
|
+
createFlushController,
|
|
24
|
+
createHttpRequest,
|
|
25
|
+
getEventBridge,
|
|
26
|
+
createBatch,
|
|
27
|
+
} from '../../transport'
|
|
28
|
+
import type { Encoder } from '../../tools/encoder'
|
|
29
|
+
import type { PageMayExitEvent } from '../../browser/pageMayExitObservable'
|
|
30
|
+
import { DeflateEncoderStreamId } from '../deflate'
|
|
31
|
+
import type { AbstractHooks, RecursivePartial } from '../../tools/abstractHooks'
|
|
32
|
+
import { HookNames, DISCARDED } from '../../tools/abstractHooks'
|
|
33
|
+
import { globalObject, isWorkerEnvironment } from '../../tools/globalObject'
|
|
19
34
|
import type { TelemetryEvent } from './telemetryEvent.types'
|
|
20
|
-
import type {
|
|
35
|
+
import type {
|
|
36
|
+
RawTelemetryConfiguration,
|
|
37
|
+
RawTelemetryEvent,
|
|
38
|
+
RuntimeEnvInfo,
|
|
39
|
+
RawTelemetryUsage,
|
|
40
|
+
} from './rawTelemetryEvent.types'
|
|
21
41
|
import { StatusType, TelemetryType } from './rawTelemetryEvent.types'
|
|
22
42
|
|
|
23
43
|
// replaced at build time
|
|
24
44
|
declare const __BUILD_ENV__SDK_VERSION__: string
|
|
45
|
+
declare const __BUILD_ENV__SDK_SETUP__: string
|
|
25
46
|
|
|
26
47
|
const ALLOWED_FRAME_URLS = [
|
|
27
48
|
'http://localhost',
|
|
@@ -34,157 +55,265 @@ export const enum TelemetryService {
|
|
|
34
55
|
}
|
|
35
56
|
|
|
36
57
|
export interface Telemetry {
|
|
37
|
-
|
|
38
|
-
observable: Observable<TelemetryEvent & Context>
|
|
58
|
+
stop: () => void
|
|
39
59
|
enabled: boolean
|
|
60
|
+
metricsEnabled: boolean
|
|
40
61
|
}
|
|
41
62
|
|
|
63
|
+
export const enum TelemetryMetrics {
|
|
64
|
+
CUSTOMER_DATA_METRIC_NAME = 'Customer data measures',
|
|
65
|
+
REMOTE_CONFIGURATION_METRIC_NAME = 'remote configuration metrics',
|
|
66
|
+
RECORDER_INIT_METRICS_TELEMETRY_NAME = 'Recorder init metrics',
|
|
67
|
+
SEGMENT_METRICS_TELEMETRY_NAME = 'Segment network request metrics',
|
|
68
|
+
INITIAL_VIEW_METRICS_TELEMETRY_NAME = 'Initial view metrics',
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const METRIC_SAMPLE_RATE = 1
|
|
72
|
+
|
|
42
73
|
const TELEMETRY_EXCLUDED_SITES: string[] = [INTAKE_SITE_US1_FED]
|
|
74
|
+
const MAX_TELEMETRY_EVENTS_PER_PAGE = 15
|
|
43
75
|
|
|
44
|
-
|
|
45
|
-
maxEventsPerPage: number
|
|
46
|
-
sentEventCount: number
|
|
47
|
-
telemetryEnabled: boolean
|
|
48
|
-
telemetryConfigurationEnabled: boolean
|
|
49
|
-
} = { maxEventsPerPage: 0, sentEventCount: 0, telemetryEnabled: false, telemetryConfigurationEnabled: false }
|
|
76
|
+
let telemetryObservable: BufferedObservable<{ rawEvent: RawTelemetryEvent; metricName?: string }> | undefined
|
|
50
77
|
|
|
51
|
-
|
|
78
|
+
export function getTelemetryObservable() {
|
|
79
|
+
if (!telemetryObservable) {
|
|
80
|
+
telemetryObservable = new BufferedObservable(100)
|
|
81
|
+
}
|
|
82
|
+
return telemetryObservable
|
|
83
|
+
}
|
|
52
84
|
|
|
53
|
-
export function startTelemetry(
|
|
54
|
-
|
|
85
|
+
export function startTelemetry(
|
|
86
|
+
telemetryService: TelemetryService,
|
|
87
|
+
configuration: Configuration,
|
|
88
|
+
hooks: AbstractHooks,
|
|
89
|
+
reportError: (error: RawError) => void,
|
|
90
|
+
pageMayExitObservable: Observable<PageMayExitEvent>,
|
|
91
|
+
createEncoder: (streamId: DeflateEncoderStreamId) => Encoder
|
|
92
|
+
): Telemetry {
|
|
55
93
|
const observable = new Observable<TelemetryEvent & Context>()
|
|
56
94
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
95
|
+
const { stop } = startTelemetryTransport(configuration, reportError, pageMayExitObservable, createEncoder, observable)
|
|
96
|
+
|
|
97
|
+
const { enabled, metricsEnabled } = startTelemetryCollection(telemetryService, configuration, hooks, observable)
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
stop,
|
|
101
|
+
enabled,
|
|
102
|
+
metricsEnabled,
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function startTelemetryCollection(
|
|
107
|
+
telemetryService: TelemetryService,
|
|
108
|
+
configuration: Configuration,
|
|
109
|
+
hooks: AbstractHooks,
|
|
110
|
+
observable: Observable<TelemetryEvent & Context>,
|
|
111
|
+
metricSampleRate = METRIC_SAMPLE_RATE,
|
|
112
|
+
maxTelemetryEventsPerPage = MAX_TELEMETRY_EVENTS_PER_PAGE
|
|
113
|
+
) {
|
|
114
|
+
const alreadySentEventsByKind: Record<string, Set<string>> = {}
|
|
115
|
+
|
|
116
|
+
const telemetryEnabled =
|
|
117
|
+
!TELEMETRY_EXCLUDED_SITES.includes(configuration.site) && performDraw(configuration.telemetrySampleRate)
|
|
118
|
+
|
|
119
|
+
const telemetryEnabledPerType = {
|
|
120
|
+
[TelemetryType.LOG]: telemetryEnabled,
|
|
121
|
+
[TelemetryType.CONFIGURATION]: telemetryEnabled && performDraw(configuration.telemetryConfigurationSampleRate),
|
|
122
|
+
[TelemetryType.USAGE]: telemetryEnabled && performDraw(configuration.telemetryUsageSampleRate),
|
|
123
|
+
// not an actual "type" but using a single draw for all metrics
|
|
124
|
+
metric: telemetryEnabled && performDraw(metricSampleRate),
|
|
125
|
+
}
|
|
61
126
|
|
|
62
127
|
const runtimeEnvInfo = getRuntimeEnvInfo()
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
128
|
+
const telemetryObservable = getTelemetryObservable()
|
|
129
|
+
telemetryObservable.subscribe(({ rawEvent, metricName }) => {
|
|
130
|
+
if ((metricName && !telemetryEnabledPerType['metric']) || !telemetryEnabledPerType[rawEvent.type!]) {
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const kind = metricName || (rawEvent.status as string | undefined) || rawEvent.type!
|
|
135
|
+
let alreadySentEvents = alreadySentEventsByKind[kind]
|
|
136
|
+
if (!alreadySentEvents) {
|
|
137
|
+
alreadySentEvents = alreadySentEventsByKind[kind] = new Set()
|
|
68
138
|
}
|
|
69
|
-
}
|
|
70
|
-
startMonitorErrorCollection(addTelemetryError)
|
|
71
139
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
140
|
+
if (alreadySentEvents.size >= maxTelemetryEventsPerPage) {
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const stringifiedEvent = jsonStringify(rawEvent)!
|
|
145
|
+
if (alreadySentEvents.has(stringifiedEvent)) {
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const defaultTelemetryEventAttributes = hooks.triggerHook(HookNames.AssembleTelemetry, {
|
|
150
|
+
startTime: clocksNow().relative,
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
if (defaultTelemetryEventAttributes === DISCARDED) {
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
const event = toTelemetryEvent(
|
|
157
|
+
defaultTelemetryEventAttributes as RecursivePartial<TelemetryEvent>,
|
|
158
|
+
telemetryService,
|
|
159
|
+
rawEvent,
|
|
160
|
+
runtimeEnvInfo
|
|
161
|
+
)
|
|
162
|
+
observable.notify(event)
|
|
163
|
+
sendToExtension('telemetry', event)
|
|
164
|
+
alreadySentEvents.add(stringifiedEvent)
|
|
75
165
|
})
|
|
166
|
+
telemetryObservable.unbuffer()
|
|
167
|
+
|
|
168
|
+
startMonitorErrorCollection(addTelemetryError)
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
enabled: telemetryEnabled,
|
|
172
|
+
metricsEnabled: telemetryEnabledPerType['metric'],
|
|
173
|
+
}
|
|
76
174
|
|
|
77
175
|
function toTelemetryEvent(
|
|
176
|
+
defaultTelemetryEventAttributes: RecursivePartial<TelemetryEvent>,
|
|
78
177
|
telemetryService: TelemetryService,
|
|
79
|
-
|
|
178
|
+
rawEvent: RawTelemetryEvent,
|
|
80
179
|
runtimeEnvInfo: RuntimeEnvInfo
|
|
81
180
|
): TelemetryEvent & Context {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
telemetry: combine(event, {
|
|
93
|
-
runtime_env: runtimeEnvInfo,
|
|
94
|
-
connectivity: getConnectivity(),
|
|
95
|
-
}),
|
|
96
|
-
experimental_features: arrayFrom(getExperimentalFeatures()),
|
|
181
|
+
const clockNow = clocksNow()
|
|
182
|
+
|
|
183
|
+
const event = {
|
|
184
|
+
type: 'telemetry' as const,
|
|
185
|
+
date: clockNow.timeStamp,
|
|
186
|
+
service: telemetryService,
|
|
187
|
+
version: __BUILD_ENV__SDK_VERSION__,
|
|
188
|
+
source: 'browser' as const,
|
|
189
|
+
_oo: {
|
|
190
|
+
format_version: 2 as const,
|
|
97
191
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
192
|
+
telemetry: combine(rawEvent, {
|
|
193
|
+
runtime_env: runtimeEnvInfo,
|
|
194
|
+
connectivity: getConnectivity(),
|
|
195
|
+
sdk_setup: __BUILD_ENV__SDK_SETUP__,
|
|
196
|
+
}) as TelemetryEvent['telemetry'],
|
|
197
|
+
ootags: buildTags(configuration).join(','),
|
|
198
|
+
experimental_features: Array.from(getExperimentalFeatures()),
|
|
199
|
+
}
|
|
101
200
|
|
|
102
|
-
|
|
103
|
-
setContextProvider: (provider: () => Context) => {
|
|
104
|
-
contextProvider = provider
|
|
105
|
-
},
|
|
106
|
-
observable,
|
|
107
|
-
enabled: telemetryConfiguration.telemetryEnabled,
|
|
201
|
+
return combine(event, defaultTelemetryEventAttributes) as TelemetryEvent & Context
|
|
108
202
|
}
|
|
109
203
|
}
|
|
110
|
-
|
|
204
|
+
|
|
205
|
+
function startTelemetryTransport(
|
|
206
|
+
configuration: Configuration,
|
|
207
|
+
reportError: (error: RawError) => void,
|
|
208
|
+
pageMayExitObservable: Observable<PageMayExitEvent>,
|
|
209
|
+
createEncoder: (streamId: DeflateEncoderStreamId) => Encoder,
|
|
210
|
+
telemetryObservable: Observable<TelemetryEvent & Context>
|
|
211
|
+
) {
|
|
212
|
+
const cleanupTasks: Array<() => void> = []
|
|
213
|
+
if (canUseEventBridge()) {
|
|
214
|
+
const bridge = getEventBridge<'internal_telemetry', TelemetryEvent>()!
|
|
215
|
+
const telemetrySubscription = telemetryObservable.subscribe((event) => bridge.send('internal_telemetry', event))
|
|
216
|
+
cleanupTasks.push(telemetrySubscription.unsubscribe)
|
|
217
|
+
} else {
|
|
218
|
+
const endpoints = [configuration.rumEndpointBuilder]
|
|
219
|
+
if (configuration.replica && isTelemetryReplicationAllowed(configuration)) {
|
|
220
|
+
endpoints.push(configuration.replica.rumEndpointBuilder)
|
|
221
|
+
}
|
|
222
|
+
const telemetryBatch = createBatch({
|
|
223
|
+
encoder: createEncoder(DeflateEncoderStreamId.TELEMETRY),
|
|
224
|
+
request: createHttpRequest(endpoints, reportError),
|
|
225
|
+
flushController: createFlushController({
|
|
226
|
+
pageMayExitObservable,
|
|
227
|
+
|
|
228
|
+
// We don't use an actual session expire observable here, to make telemetry collection
|
|
229
|
+
// independent of the session. This allows to start and send telemetry events earlier.
|
|
230
|
+
sessionExpireObservable: new Observable(),
|
|
231
|
+
}),
|
|
232
|
+
})
|
|
233
|
+
cleanupTasks.push(telemetryBatch.stop)
|
|
234
|
+
const telemetrySubscription = telemetryObservable.subscribe(telemetryBatch.add)
|
|
235
|
+
cleanupTasks.push(telemetrySubscription.unsubscribe)
|
|
236
|
+
}
|
|
237
|
+
|
|
111
238
|
return {
|
|
112
|
-
|
|
113
|
-
is_worker: 'WorkerGlobalScope' in self,
|
|
239
|
+
stop: () => cleanupTasks.forEach((task) => task()),
|
|
114
240
|
}
|
|
115
241
|
}
|
|
116
242
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
sentEventCount: 0,
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
onRawTelemetryEventCollected = (event: RawTelemetryEvent) => {
|
|
125
|
-
events.push(event)
|
|
243
|
+
function getRuntimeEnvInfo(): RuntimeEnvInfo {
|
|
244
|
+
return {
|
|
245
|
+
is_local_file: globalObject.location?.protocol === 'file:',
|
|
246
|
+
is_worker: isWorkerEnvironment,
|
|
126
247
|
}
|
|
127
|
-
|
|
128
|
-
return events
|
|
129
248
|
}
|
|
130
249
|
|
|
131
250
|
export function resetTelemetry() {
|
|
132
|
-
|
|
251
|
+
telemetryObservable = undefined
|
|
133
252
|
}
|
|
134
253
|
|
|
135
254
|
/**
|
|
136
255
|
* Avoid mixing telemetry events from different data centers
|
|
137
256
|
* but keep replicating staging events for reliability
|
|
138
257
|
*/
|
|
139
|
-
|
|
258
|
+
function isTelemetryReplicationAllowed(configuration: Configuration) {
|
|
140
259
|
return configuration.site === INTAKE_SITE_STAGING
|
|
141
260
|
}
|
|
142
261
|
|
|
143
262
|
export function addTelemetryDebug(message: string, context?: Context) {
|
|
144
263
|
displayIfDebugEnabled(ConsoleApiName.debug, message, context)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
)
|
|
154
|
-
)
|
|
264
|
+
getTelemetryObservable().notify({
|
|
265
|
+
rawEvent: {
|
|
266
|
+
type: TelemetryType.LOG,
|
|
267
|
+
message,
|
|
268
|
+
status: StatusType.debug,
|
|
269
|
+
...context,
|
|
270
|
+
},
|
|
271
|
+
})
|
|
155
272
|
}
|
|
156
273
|
|
|
157
274
|
export function addTelemetryError(e: unknown, context?: Context) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
)
|
|
167
|
-
)
|
|
275
|
+
getTelemetryObservable().notify({
|
|
276
|
+
rawEvent: {
|
|
277
|
+
type: TelemetryType.LOG,
|
|
278
|
+
status: StatusType.error,
|
|
279
|
+
...formatError(e),
|
|
280
|
+
...context,
|
|
281
|
+
},
|
|
282
|
+
})
|
|
168
283
|
}
|
|
169
284
|
|
|
170
285
|
export function addTelemetryConfiguration(configuration: RawTelemetryConfiguration) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
type: TelemetryType.
|
|
286
|
+
getTelemetryObservable().notify({
|
|
287
|
+
rawEvent: {
|
|
288
|
+
type: TelemetryType.CONFIGURATION,
|
|
174
289
|
configuration,
|
|
175
|
-
}
|
|
176
|
-
}
|
|
290
|
+
},
|
|
291
|
+
})
|
|
177
292
|
}
|
|
178
293
|
|
|
179
|
-
function
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
294
|
+
export function addTelemetryMetrics(metricName: TelemetryMetrics, context?: Context) {
|
|
295
|
+
getTelemetryObservable().notify({
|
|
296
|
+
rawEvent: {
|
|
297
|
+
type: TelemetryType.LOG,
|
|
298
|
+
message: metricName,
|
|
299
|
+
status: StatusType.debug,
|
|
300
|
+
...context,
|
|
301
|
+
},
|
|
302
|
+
metricName,
|
|
303
|
+
})
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export function addTelemetryUsage(usage: RawTelemetryUsage) {
|
|
307
|
+
getTelemetryObservable().notify({
|
|
308
|
+
rawEvent: {
|
|
309
|
+
type: TelemetryType.USAGE,
|
|
310
|
+
usage,
|
|
311
|
+
},
|
|
312
|
+
})
|
|
184
313
|
}
|
|
185
314
|
|
|
186
315
|
export function formatError(e: unknown) {
|
|
187
|
-
if (e
|
|
316
|
+
if (isError(e)) {
|
|
188
317
|
const stackTrace = computeStackTrace(e)
|
|
189
318
|
return {
|
|
190
319
|
error: {
|
|
@@ -204,7 +333,7 @@ export function formatError(e: unknown) {
|
|
|
204
333
|
|
|
205
334
|
export function scrubCustomerFrames(stackTrace: StackTrace) {
|
|
206
335
|
stackTrace.stack = stackTrace.stack.filter(
|
|
207
|
-
(frame) => !frame.url || ALLOWED_FRAME_URLS.some((allowedFrameUrl) =>
|
|
336
|
+
(frame) => !frame.url || ALLOWED_FRAME_URLS.some((allowedFrameUrl) => frame.url!.startsWith(allowedFrameUrl))
|
|
208
337
|
)
|
|
209
338
|
return stackTrace
|
|
210
339
|
}
|