@kubesense/kubesense-browser-rum-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +3 -0
- package/cjs/boot/preStartRum.d.ts +7 -0
- package/cjs/boot/preStartRum.js +190 -0
- package/cjs/boot/preStartRum.js.map +1 -0
- package/cjs/boot/rumPublicApi.d.ts +409 -0
- package/cjs/boot/rumPublicApi.js +168 -0
- package/cjs/boot/rumPublicApi.js.map +1 -0
- package/cjs/boot/startRum.d.ts +109 -0
- package/cjs/boot/startRum.js +153 -0
- package/cjs/boot/startRum.js.map +1 -0
- package/cjs/browser/cookieObservable.d.ts +8 -0
- package/cjs/browser/cookieObservable.js +39 -0
- package/cjs/browser/cookieObservable.js.map +1 -0
- package/cjs/browser/domMutationObservable.d.ts +27 -0
- package/cjs/browser/domMutationObservable.js +58 -0
- package/cjs/browser/domMutationObservable.js.map +1 -0
- package/cjs/browser/firstInputPolyfill.d.ts +8 -0
- package/cjs/browser/firstInputPolyfill.js +68 -0
- package/cjs/browser/firstInputPolyfill.js.map +1 -0
- package/cjs/browser/htmlDomUtils.d.ts +13 -0
- package/cjs/browser/htmlDomUtils.js +46 -0
- package/cjs/browser/htmlDomUtils.js.map +1 -0
- package/cjs/browser/locationChangeObservable.d.ts +7 -0
- package/cjs/browser/locationChangeObservable.js +51 -0
- package/cjs/browser/locationChangeObservable.js.map +1 -0
- package/cjs/browser/performanceObservable.d.ts +174 -0
- package/cjs/browser/performanceObservable.js +126 -0
- package/cjs/browser/performanceObservable.js.map +1 -0
- package/cjs/browser/performanceUtils.d.ts +7 -0
- package/cjs/browser/performanceUtils.js +42 -0
- package/cjs/browser/performanceUtils.js.map +1 -0
- package/cjs/browser/scroll.d.ts +2 -0
- package/cjs/browser/scroll.js +33 -0
- package/cjs/browser/scroll.js.map +1 -0
- package/cjs/browser/viewportObservable.d.ts +10 -0
- package/cjs/browser/viewportObservable.js +37 -0
- package/cjs/browser/viewportObservable.js.map +1 -0
- package/cjs/browser/windowOpenObservable.d.ts +5 -0
- package/cjs/browser/windowOpenObservable.js +10 -0
- package/cjs/browser/windowOpenObservable.js.map +1 -0
- package/cjs/domain/action/actionCollection.d.ts +21 -0
- package/cjs/domain/action/actionCollection.js +96 -0
- package/cjs/domain/action/actionCollection.js.map +1 -0
- package/cjs/domain/action/actionNameConstants.d.ts +18 -0
- package/cjs/domain/action/actionNameConstants.js +11 -0
- package/cjs/domain/action/actionNameConstants.js.map +1 -0
- package/cjs/domain/action/clickChain.d.ts +8 -0
- package/cjs/domain/action/clickChain.js +61 -0
- package/cjs/domain/action/clickChain.js.map +1 -0
- package/cjs/domain/action/computeFrustration.d.ts +6 -0
- package/cjs/domain/action/computeFrustration.js +70 -0
- package/cjs/domain/action/computeFrustration.js.map +1 -0
- package/cjs/domain/action/getActionNameFromElement.d.ts +4 -0
- package/cjs/domain/action/getActionNameFromElement.js +239 -0
- package/cjs/domain/action/getActionNameFromElement.js.map +1 -0
- package/cjs/domain/action/interactionSelectorCache.d.ts +5 -0
- package/cjs/domain/action/interactionSelectorCache.js +23 -0
- package/cjs/domain/action/interactionSelectorCache.js.map +1 -0
- package/cjs/domain/action/listenActionEvents.d.ts +19 -0
- package/cjs/domain/action/listenActionEvents.js +61 -0
- package/cjs/domain/action/listenActionEvents.js.map +1 -0
- package/cjs/domain/action/trackClickActions.d.ts +81 -0
- package/cjs/domain/action/trackClickActions.js +237 -0
- package/cjs/domain/action/trackClickActions.js.map +1 -0
- package/cjs/domain/assembly.d.ts +5 -0
- package/cjs/domain/assembly.js +102 -0
- package/cjs/domain/assembly.js.map +1 -0
- package/cjs/domain/configuration/configuration.d.ts +325 -0
- package/cjs/domain/configuration/configuration.js +205 -0
- package/cjs/domain/configuration/configuration.js.map +1 -0
- package/cjs/domain/configuration/index.d.ts +2 -0
- package/cjs/domain/configuration/index.js +19 -0
- package/cjs/domain/configuration/index.js.map +1 -0
- package/cjs/domain/configuration/jsonPathParser.d.ts +28 -0
- package/cjs/domain/configuration/jsonPathParser.js +159 -0
- package/cjs/domain/configuration/jsonPathParser.js.map +1 -0
- package/cjs/domain/configuration/remoteConfiguration.d.ts +39 -0
- package/cjs/domain/configuration/remoteConfiguration.js +243 -0
- package/cjs/domain/configuration/remoteConfiguration.js.map +1 -0
- package/cjs/domain/configuration/remoteConfiguration.types.d.ts +138 -0
- package/cjs/domain/configuration/remoteConfiguration.types.js +7 -0
- package/cjs/domain/configuration/remoteConfiguration.types.js.map +1 -0
- package/cjs/domain/contexts/ciVisibilityContext.d.ts +12 -0
- package/cjs/domain/contexts/ciVisibilityContext.js +34 -0
- package/cjs/domain/contexts/ciVisibilityContext.js.map +1 -0
- package/cjs/domain/contexts/connectivityContext.d.ts +2 -0
- package/cjs/domain/contexts/connectivityContext.js +11 -0
- package/cjs/domain/contexts/connectivityContext.js.map +1 -0
- package/cjs/domain/contexts/defaultContext.d.ts +4 -0
- package/cjs/domain/contexts/defaultContext.js +34 -0
- package/cjs/domain/contexts/defaultContext.js.map +1 -0
- package/cjs/domain/contexts/displayContext.d.ts +6 -0
- package/cjs/domain/contexts/displayContext.js +28 -0
- package/cjs/domain/contexts/displayContext.js.map +1 -0
- package/cjs/domain/contexts/featureFlagContext.d.ts +19 -0
- package/cjs/domain/contexts/featureFlagContext.js +53 -0
- package/cjs/domain/contexts/featureFlagContext.js.map +1 -0
- package/cjs/domain/contexts/internalContext.d.ts +12 -0
- package/cjs/domain/contexts/internalContext.js +26 -0
- package/cjs/domain/contexts/internalContext.js.map +1 -0
- package/cjs/domain/contexts/pageStateHistory.d.ts +23 -0
- package/cjs/domain/contexts/pageStateHistory.js +104 -0
- package/cjs/domain/contexts/pageStateHistory.js.map +1 -0
- package/cjs/domain/contexts/sessionContext.d.ts +5 -0
- package/cjs/domain/contexts/sessionContext.js +47 -0
- package/cjs/domain/contexts/sessionContext.js.map +1 -0
- package/cjs/domain/contexts/syntheticsContext.d.ts +2 -0
- package/cjs/domain/contexts/syntheticsContext.js +25 -0
- package/cjs/domain/contexts/syntheticsContext.js.map +1 -0
- package/cjs/domain/contexts/trackingConsentContext.d.ts +3 -0
- package/cjs/domain/contexts/trackingConsentContext.js +14 -0
- package/cjs/domain/contexts/trackingConsentContext.js.map +1 -0
- package/cjs/domain/contexts/urlContexts.d.ts +22 -0
- package/cjs/domain/contexts/urlContexts.js +64 -0
- package/cjs/domain/contexts/urlContexts.js.map +1 -0
- package/cjs/domain/contexts/userAgentDataContext.d.ts +2 -0
- package/cjs/domain/contexts/userAgentDataContext.js +31 -0
- package/cjs/domain/contexts/userAgentDataContext.js.map +1 -0
- package/cjs/domain/contexts/viewHistory.d.ts +17 -0
- package/cjs/domain/contexts/viewHistory.js +48 -0
- package/cjs/domain/contexts/viewHistory.js.map +1 -0
- package/cjs/domain/discardNegativeDuration.d.ts +2 -0
- package/cjs/domain/discardNegativeDuration.js +8 -0
- package/cjs/domain/discardNegativeDuration.js.map +1 -0
- package/cjs/domain/error/errorCollection.d.ts +17 -0
- package/cjs/domain/error/errorCollection.js +74 -0
- package/cjs/domain/error/errorCollection.js.map +1 -0
- package/cjs/domain/error/trackConsoleError.d.ts +4 -0
- package/cjs/domain/error/trackConsoleError.js +13 -0
- package/cjs/domain/error/trackConsoleError.js.map +1 -0
- package/cjs/domain/error/trackReportError.d.ts +5 -0
- package/cjs/domain/error/trackReportError.js +16 -0
- package/cjs/domain/error/trackReportError.js.map +1 -0
- package/cjs/domain/event/eventCollection.d.ts +10 -0
- package/cjs/domain/event/eventCollection.js +27 -0
- package/cjs/domain/event/eventCollection.js.map +1 -0
- package/cjs/domain/getSelectorFromElement.d.ts +64 -0
- package/cjs/domain/getSelectorFromElement.js +218 -0
- package/cjs/domain/getSelectorFromElement.js.map +1 -0
- package/cjs/domain/getSessionReplayUrl.d.ts +9 -0
- package/cjs/domain/getSessionReplayUrl.js +34 -0
- package/cjs/domain/getSessionReplayUrl.js.map +1 -0
- package/cjs/domain/hooks.d.ts +23 -0
- package/cjs/domain/hooks.js +6 -0
- package/cjs/domain/hooks.js.map +1 -0
- package/cjs/domain/lifeCycle.d.ts +73 -0
- package/cjs/domain/lifeCycle.js +6 -0
- package/cjs/domain/lifeCycle.js.map +1 -0
- package/cjs/domain/limitModification.d.ts +8 -0
- package/cjs/domain/limitModification.js +46 -0
- package/cjs/domain/limitModification.js.map +1 -0
- package/cjs/domain/longTask/longTaskCollection.d.ts +18 -0
- package/cjs/domain/longTask/longTaskCollection.js +91 -0
- package/cjs/domain/longTask/longTaskCollection.js.map +1 -0
- package/cjs/domain/plugins.d.ts +40 -0
- package/cjs/domain/plugins.js +15 -0
- package/cjs/domain/plugins.js.map +1 -0
- package/cjs/domain/privacy.d.ts +44 -0
- package/cjs/domain/privacy.js +313 -0
- package/cjs/domain/privacy.js.map +1 -0
- package/cjs/domain/privacyConstants.d.ts +23 -0
- package/cjs/domain/privacyConstants.js +39 -0
- package/cjs/domain/privacyConstants.js.map +1 -0
- package/cjs/domain/requestCollection.d.ts +54 -0
- package/cjs/domain/requestCollection.js +111 -0
- package/cjs/domain/requestCollection.js.map +1 -0
- package/cjs/domain/resource/graphql.d.ts +23 -0
- package/cjs/domain/resource/graphql.js +97 -0
- package/cjs/domain/resource/graphql.js.map +1 -0
- package/cjs/domain/resource/matchRequestResourceEntry.d.ts +16 -0
- package/cjs/domain/resource/matchRequestResourceEntry.js +49 -0
- package/cjs/domain/resource/matchRequestResourceEntry.js.map +1 -0
- package/cjs/domain/resource/requestRegistry.d.ts +9 -0
- package/cjs/domain/resource/requestRegistry.js +41 -0
- package/cjs/domain/resource/requestRegistry.js.map +1 -0
- package/cjs/domain/resource/resourceCollection.d.ts +7 -0
- package/cjs/domain/resource/resourceCollection.js +190 -0
- package/cjs/domain/resource/resourceCollection.js.map +1 -0
- package/cjs/domain/resource/resourceUtils.d.ts +55 -0
- package/cjs/domain/resource/resourceUtils.js +259 -0
- package/cjs/domain/resource/resourceUtils.js.map +1 -0
- package/cjs/domain/resource/retrieveInitialDocumentResourceTiming.d.ts +4 -0
- package/cjs/domain/resource/retrieveInitialDocumentResourceTiming.js +24 -0
- package/cjs/domain/resource/retrieveInitialDocumentResourceTiming.js.map +1 -0
- package/cjs/domain/rumSessionManager.d.ts +36 -0
- package/cjs/domain/rumSessionManager.js +77 -0
- package/cjs/domain/rumSessionManager.js.map +1 -0
- package/cjs/domain/sampler/sampler.d.ts +10 -0
- package/cjs/domain/sampler/sampler.js +63 -0
- package/cjs/domain/sampler/sampler.js.map +1 -0
- package/cjs/domain/startCustomerDataTelemetry.d.ts +4 -0
- package/cjs/domain/startCustomerDataTelemetry.js +56 -0
- package/cjs/domain/startCustomerDataTelemetry.js.map +1 -0
- package/cjs/domain/tracing/getDocumentTraceId.d.ts +12 -0
- package/cjs/domain/tracing/getDocumentTraceId.js +76 -0
- package/cjs/domain/tracing/getDocumentTraceId.js.map +1 -0
- package/cjs/domain/tracing/identifier.d.ts +13 -0
- package/cjs/domain/tracing/identifier.js +55 -0
- package/cjs/domain/tracing/identifier.js.map +1 -0
- package/cjs/domain/tracing/sampler.d.ts +10 -0
- package/cjs/domain/tracing/sampler.js +69 -0
- package/cjs/domain/tracing/sampler.js.map +1 -0
- package/cjs/domain/tracing/tracer.d.ts +30 -0
- package/cjs/domain/tracing/tracer.js +161 -0
- package/cjs/domain/tracing/tracer.js.map +1 -0
- package/cjs/domain/tracing/tracer.types.d.ts +12 -0
- package/cjs/domain/tracing/tracer.types.js +3 -0
- package/cjs/domain/tracing/tracer.types.js.map +1 -0
- package/cjs/domain/trackEventCounts.d.ts +17 -0
- package/cjs/domain/trackEventCounts.js +50 -0
- package/cjs/domain/trackEventCounts.js.map +1 -0
- package/cjs/domain/view/bfCacheSupport.d.ts +2 -0
- package/cjs/domain/view/bfCacheSupport.js +13 -0
- package/cjs/domain/view/bfCacheSupport.js.map +1 -0
- package/cjs/domain/view/trackViewEventCounts.d.ts +5 -0
- package/cjs/domain/view/trackViewEventCounts.js +16 -0
- package/cjs/domain/view/trackViewEventCounts.js.map +1 -0
- package/cjs/domain/view/trackViews.d.ts +65 -0
- package/cjs/domain/view/trackViews.js +275 -0
- package/cjs/domain/view/trackViews.js.map +1 -0
- package/cjs/domain/view/viewCollection.d.ts +18 -0
- package/cjs/domain/view/viewCollection.js +153 -0
- package/cjs/domain/view/viewCollection.js.map +1 -0
- package/cjs/domain/view/viewMetrics/getClsAttributionImpactedArea.d.ts +6 -0
- package/cjs/domain/view/viewMetrics/getClsAttributionImpactedArea.js +32 -0
- package/cjs/domain/view/viewMetrics/getClsAttributionImpactedArea.js.map +1 -0
- package/cjs/domain/view/viewMetrics/interactionCountPolyfill.d.ts +18 -0
- package/cjs/domain/view/viewMetrics/interactionCountPolyfill.js +44 -0
- package/cjs/domain/view/viewMetrics/interactionCountPolyfill.js.map +1 -0
- package/cjs/domain/view/viewMetrics/startInitialViewMetricsTelemetry.d.ts +6 -0
- package/cjs/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js +44 -0
- package/cjs/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackBfcacheMetrics.d.ts +8 -0
- package/cjs/domain/view/viewMetrics/trackBfcacheMetrics.js +17 -0
- package/cjs/domain/view/viewMetrics/trackBfcacheMetrics.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackCommonViewMetrics.d.ts +21 -0
- package/cjs/domain/view/viewMetrics/trackCommonViewMetrics.js +37 -0
- package/cjs/domain/view/viewMetrics/trackCommonViewMetrics.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackCumulativeLayoutShift.d.ts +37 -0
- package/cjs/domain/view/viewMetrics/trackCumulativeLayoutShift.js +135 -0
- package/cjs/domain/view/viewMetrics/trackCumulativeLayoutShift.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackFirstContentfulPaint.d.ts +13 -0
- package/cjs/domain/view/viewMetrics/trackFirstContentfulPaint.js +39 -0
- package/cjs/domain/view/viewMetrics/trackFirstContentfulPaint.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackFirstHidden.d.ts +10 -0
- package/cjs/domain/view/viewMetrics/trackFirstHidden.js +33 -0
- package/cjs/domain/view/viewMetrics/trackFirstHidden.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackFirstInput.d.ts +19 -0
- package/cjs/domain/view/viewMetrics/trackFirstInput.js +43 -0
- package/cjs/domain/view/viewMetrics/trackFirstInput.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackInitialViewMetrics.d.ts +15 -0
- package/cjs/domain/view/viewMetrics/trackInitialViewMetrics.js +41 -0
- package/cjs/domain/view/viewMetrics/trackInitialViewMetrics.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackInteractionToNextPaint.d.ts +25 -0
- package/cjs/domain/view/viewMetrics/trackInteractionToNextPaint.js +155 -0
- package/cjs/domain/view/viewMetrics/trackInteractionToNextPaint.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackLargestContentfulPaint.d.ts +18 -0
- package/cjs/domain/view/viewMetrics/trackLargestContentfulPaint.js +61 -0
- package/cjs/domain/view/viewMetrics/trackLargestContentfulPaint.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackLoadingTime.d.ts +14 -0
- package/cjs/domain/view/viewMetrics/trackLoadingTime.js +50 -0
- package/cjs/domain/view/viewMetrics/trackLoadingTime.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackNavigationTimings.d.ts +14 -0
- package/cjs/domain/view/viewMetrics/trackNavigationTimings.js +43 -0
- package/cjs/domain/view/viewMetrics/trackNavigationTimings.js.map +1 -0
- package/cjs/domain/view/viewMetrics/trackScrollMetrics.d.ts +25 -0
- package/cjs/domain/view/viewMetrics/trackScrollMetrics.js +78 -0
- package/cjs/domain/view/viewMetrics/trackScrollMetrics.js.map +1 -0
- package/cjs/domain/vital/vitalCollection.d.ts +55 -0
- package/cjs/domain/vital/vitalCollection.js +113 -0
- package/cjs/domain/vital/vitalCollection.js.map +1 -0
- package/cjs/domain/waitPageActivityEnd.d.ts +54 -0
- package/cjs/domain/waitPageActivityEnd.js +129 -0
- package/cjs/domain/waitPageActivityEnd.js.map +1 -0
- package/cjs/domainContext.types.d.ts +39 -0
- package/cjs/domainContext.types.js +6 -0
- package/cjs/domainContext.types.js.map +1 -0
- package/cjs/index.d.ts +41 -0
- package/cjs/index.js +59 -0
- package/cjs/index.js.map +1 -0
- package/cjs/rawRumEvent.types.d.ts +326 -0
- package/cjs/rawRumEvent.types.js +34 -0
- package/cjs/rawRumEvent.types.js.map +1 -0
- package/cjs/rumEvent.types.d.ts +2026 -0
- package/cjs/rumEvent.types.js +7 -0
- package/cjs/rumEvent.types.js.map +1 -0
- package/cjs/transport/formDataTransport.d.ts +16 -0
- package/cjs/transport/formDataTransport.js +46 -0
- package/cjs/transport/formDataTransport.js.map +1 -0
- package/cjs/transport/startRumBatch.d.ts +5 -0
- package/cjs/transport/startRumBatch.js +33 -0
- package/cjs/transport/startRumBatch.js.map +1 -0
- package/cjs/transport/startRumEventBridge.d.ts +2 -0
- package/cjs/transport/startRumEventBridge.js +11 -0
- package/cjs/transport/startRumEventBridge.js.map +1 -0
- package/esm/boot/preStartRum.d.ts +7 -0
- package/esm/boot/preStartRum.js +187 -0
- package/esm/boot/preStartRum.js.map +1 -0
- package/esm/boot/rumPublicApi.d.ts +409 -0
- package/esm/boot/rumPublicApi.js +165 -0
- package/esm/boot/rumPublicApi.js.map +1 -0
- package/esm/boot/startRum.d.ts +109 -0
- package/esm/boot/startRum.js +149 -0
- package/esm/boot/startRum.js.map +1 -0
- package/esm/browser/cookieObservable.d.ts +8 -0
- package/esm/browser/cookieObservable.js +35 -0
- package/esm/browser/cookieObservable.js.map +1 -0
- package/esm/browser/domMutationObservable.d.ts +27 -0
- package/esm/browser/domMutationObservable.js +54 -0
- package/esm/browser/domMutationObservable.js.map +1 -0
- package/esm/browser/firstInputPolyfill.d.ts +8 -0
- package/esm/browser/firstInputPolyfill.js +65 -0
- package/esm/browser/firstInputPolyfill.js.map +1 -0
- package/esm/browser/htmlDomUtils.d.ts +13 -0
- package/esm/browser/htmlDomUtils.js +36 -0
- package/esm/browser/htmlDomUtils.js.map +1 -0
- package/esm/browser/locationChangeObservable.d.ts +7 -0
- package/esm/browser/locationChangeObservable.js +48 -0
- package/esm/browser/locationChangeObservable.js.map +1 -0
- package/esm/browser/performanceObservable.d.ts +174 -0
- package/esm/browser/performanceObservable.js +121 -0
- package/esm/browser/performanceObservable.js.map +1 -0
- package/esm/browser/performanceUtils.d.ts +7 -0
- package/esm/browser/performanceUtils.js +38 -0
- package/esm/browser/performanceUtils.js.map +1 -0
- package/esm/browser/scroll.d.ts +2 -0
- package/esm/browser/scroll.js +29 -0
- package/esm/browser/scroll.js.map +1 -0
- package/esm/browser/viewportObservable.d.ts +10 -0
- package/esm/browser/viewportObservable.js +32 -0
- package/esm/browser/viewportObservable.js.map +1 -0
- package/esm/browser/windowOpenObservable.d.ts +5 -0
- package/esm/browser/windowOpenObservable.js +7 -0
- package/esm/browser/windowOpenObservable.js.map +1 -0
- package/esm/domain/action/actionCollection.d.ts +21 -0
- package/esm/domain/action/actionCollection.js +93 -0
- package/esm/domain/action/actionCollection.js.map +1 -0
- package/esm/domain/action/actionNameConstants.d.ts +18 -0
- package/esm/domain/action/actionNameConstants.js +8 -0
- package/esm/domain/action/actionNameConstants.js.map +1 -0
- package/esm/domain/action/clickChain.d.ts +8 -0
- package/esm/domain/action/clickChain.js +57 -0
- package/esm/domain/action/clickChain.js.map +1 -0
- package/esm/domain/action/computeFrustration.d.ts +6 -0
- package/esm/domain/action/computeFrustration.js +65 -0
- package/esm/domain/action/computeFrustration.js.map +1 -0
- package/esm/domain/action/getActionNameFromElement.d.ts +4 -0
- package/esm/domain/action/getActionNameFromElement.js +236 -0
- package/esm/domain/action/getActionNameFromElement.js.map +1 -0
- package/esm/domain/action/interactionSelectorCache.d.ts +5 -0
- package/esm/domain/action/interactionSelectorCache.js +18 -0
- package/esm/domain/action/interactionSelectorCache.js.map +1 -0
- package/esm/domain/action/listenActionEvents.d.ts +19 -0
- package/esm/domain/action/listenActionEvents.js +58 -0
- package/esm/domain/action/listenActionEvents.js.map +1 -0
- package/esm/domain/action/trackClickActions.d.ts +81 -0
- package/esm/domain/action/trackClickActions.js +232 -0
- package/esm/domain/action/trackClickActions.js.map +1 -0
- package/esm/domain/assembly.d.ts +5 -0
- package/esm/domain/assembly.js +99 -0
- package/esm/domain/assembly.js.map +1 -0
- package/esm/domain/configuration/configuration.d.ts +325 -0
- package/esm/domain/configuration/configuration.js +200 -0
- package/esm/domain/configuration/configuration.js.map +1 -0
- package/esm/domain/configuration/index.d.ts +2 -0
- package/esm/domain/configuration/index.js +3 -0
- package/esm/domain/configuration/index.js.map +1 -0
- package/esm/domain/configuration/jsonPathParser.d.ts +28 -0
- package/esm/domain/configuration/jsonPathParser.js +156 -0
- package/esm/domain/configuration/jsonPathParser.js.map +1 -0
- package/esm/domain/configuration/remoteConfiguration.d.ts +39 -0
- package/esm/domain/configuration/remoteConfiguration.js +236 -0
- package/esm/domain/configuration/remoteConfiguration.js.map +1 -0
- package/esm/domain/configuration/remoteConfiguration.types.d.ts +138 -0
- package/esm/domain/configuration/remoteConfiguration.types.js +6 -0
- package/esm/domain/configuration/remoteConfiguration.types.js.map +1 -0
- package/esm/domain/contexts/ciVisibilityContext.d.ts +12 -0
- package/esm/domain/contexts/ciVisibilityContext.js +30 -0
- package/esm/domain/contexts/ciVisibilityContext.js.map +1 -0
- package/esm/domain/contexts/connectivityContext.d.ts +2 -0
- package/esm/domain/contexts/connectivityContext.js +8 -0
- package/esm/domain/contexts/connectivityContext.js.map +1 -0
- package/esm/domain/contexts/defaultContext.d.ts +4 -0
- package/esm/domain/contexts/defaultContext.js +31 -0
- package/esm/domain/contexts/defaultContext.js.map +1 -0
- package/esm/domain/contexts/displayContext.d.ts +6 -0
- package/esm/domain/contexts/displayContext.js +25 -0
- package/esm/domain/contexts/displayContext.js.map +1 -0
- package/esm/domain/contexts/featureFlagContext.d.ts +19 -0
- package/esm/domain/contexts/featureFlagContext.js +49 -0
- package/esm/domain/contexts/featureFlagContext.js.map +1 -0
- package/esm/domain/contexts/internalContext.d.ts +12 -0
- package/esm/domain/contexts/internalContext.js +23 -0
- package/esm/domain/contexts/internalContext.js.map +1 -0
- package/esm/domain/contexts/pageStateHistory.d.ts +23 -0
- package/esm/domain/contexts/pageStateHistory.js +100 -0
- package/esm/domain/contexts/pageStateHistory.js.map +1 -0
- package/esm/domain/contexts/sessionContext.d.ts +5 -0
- package/esm/domain/contexts/sessionContext.js +44 -0
- package/esm/domain/contexts/sessionContext.js.map +1 -0
- package/esm/domain/contexts/syntheticsContext.d.ts +2 -0
- package/esm/domain/contexts/syntheticsContext.js +22 -0
- package/esm/domain/contexts/syntheticsContext.js.map +1 -0
- package/esm/domain/contexts/trackingConsentContext.d.ts +3 -0
- package/esm/domain/contexts/trackingConsentContext.js +11 -0
- package/esm/domain/contexts/trackingConsentContext.js.map +1 -0
- package/esm/domain/contexts/urlContexts.d.ts +22 -0
- package/esm/domain/contexts/urlContexts.js +60 -0
- package/esm/domain/contexts/urlContexts.js.map +1 -0
- package/esm/domain/contexts/userAgentDataContext.d.ts +2 -0
- package/esm/domain/contexts/userAgentDataContext.js +28 -0
- package/esm/domain/contexts/userAgentDataContext.js.map +1 -0
- package/esm/domain/contexts/viewHistory.d.ts +17 -0
- package/esm/domain/contexts/viewHistory.js +44 -0
- package/esm/domain/contexts/viewHistory.js.map +1 -0
- package/esm/domain/discardNegativeDuration.d.ts +2 -0
- package/esm/domain/discardNegativeDuration.js +5 -0
- package/esm/domain/discardNegativeDuration.js.map +1 -0
- package/esm/domain/error/errorCollection.d.ts +17 -0
- package/esm/domain/error/errorCollection.js +70 -0
- package/esm/domain/error/errorCollection.js.map +1 -0
- package/esm/domain/error/trackConsoleError.d.ts +4 -0
- package/esm/domain/error/trackConsoleError.js +10 -0
- package/esm/domain/error/trackConsoleError.js.map +1 -0
- package/esm/domain/error/trackReportError.d.ts +5 -0
- package/esm/domain/error/trackReportError.js +13 -0
- package/esm/domain/error/trackReportError.js.map +1 -0
- package/esm/domain/event/eventCollection.d.ts +10 -0
- package/esm/domain/event/eventCollection.js +24 -0
- package/esm/domain/event/eventCollection.js.map +1 -0
- package/esm/domain/getSelectorFromElement.d.ts +64 -0
- package/esm/domain/getSelectorFromElement.js +213 -0
- package/esm/domain/getSelectorFromElement.js.map +1 -0
- package/esm/domain/getSessionReplayUrl.d.ts +9 -0
- package/esm/domain/getSessionReplayUrl.js +30 -0
- package/esm/domain/getSessionReplayUrl.js.map +1 -0
- package/esm/domain/hooks.d.ts +23 -0
- package/esm/domain/hooks.js +3 -0
- package/esm/domain/hooks.js.map +1 -0
- package/esm/domain/lifeCycle.d.ts +73 -0
- package/esm/domain/lifeCycle.js +3 -0
- package/esm/domain/lifeCycle.js.map +1 -0
- package/esm/domain/limitModification.d.ts +8 -0
- package/esm/domain/limitModification.js +43 -0
- package/esm/domain/limitModification.js.map +1 -0
- package/esm/domain/longTask/longTaskCollection.d.ts +18 -0
- package/esm/domain/longTask/longTaskCollection.js +87 -0
- package/esm/domain/longTask/longTaskCollection.js.map +1 -0
- package/esm/domain/plugins.d.ts +40 -0
- package/esm/domain/plugins.js +12 -0
- package/esm/domain/plugins.js.map +1 -0
- package/esm/domain/privacy.d.ts +44 -0
- package/esm/domain/privacy.js +302 -0
- package/esm/domain/privacy.js.map +1 -0
- package/esm/domain/privacyConstants.d.ts +23 -0
- package/esm/domain/privacyConstants.js +35 -0
- package/esm/domain/privacyConstants.js.map +1 -0
- package/esm/domain/requestCollection.d.ts +54 -0
- package/esm/domain/requestCollection.js +106 -0
- package/esm/domain/requestCollection.js.map +1 -0
- package/esm/domain/resource/graphql.d.ts +23 -0
- package/esm/domain/resource/graphql.js +91 -0
- package/esm/domain/resource/graphql.js.map +1 -0
- package/esm/domain/resource/matchRequestResourceEntry.d.ts +16 -0
- package/esm/domain/resource/matchRequestResourceEntry.js +46 -0
- package/esm/domain/resource/matchRequestResourceEntry.js.map +1 -0
- package/esm/domain/resource/requestRegistry.d.ts +9 -0
- package/esm/domain/resource/requestRegistry.js +37 -0
- package/esm/domain/resource/requestRegistry.js.map +1 -0
- package/esm/domain/resource/resourceCollection.d.ts +7 -0
- package/esm/domain/resource/resourceCollection.js +187 -0
- package/esm/domain/resource/resourceCollection.js.map +1 -0
- package/esm/domain/resource/resourceUtils.d.ts +55 -0
- package/esm/domain/resource/resourceUtils.js +244 -0
- package/esm/domain/resource/resourceUtils.js.map +1 -0
- package/esm/domain/resource/retrieveInitialDocumentResourceTiming.d.ts +4 -0
- package/esm/domain/resource/retrieveInitialDocumentResourceTiming.js +21 -0
- package/esm/domain/resource/retrieveInitialDocumentResourceTiming.js.map +1 -0
- package/esm/domain/rumSessionManager.d.ts +36 -0
- package/esm/domain/rumSessionManager.js +72 -0
- package/esm/domain/rumSessionManager.js.map +1 -0
- package/esm/domain/sampler/sampler.d.ts +10 -0
- package/esm/domain/sampler/sampler.js +58 -0
- package/esm/domain/sampler/sampler.js.map +1 -0
- package/esm/domain/startCustomerDataTelemetry.d.ts +4 -0
- package/esm/domain/startCustomerDataTelemetry.js +52 -0
- package/esm/domain/startCustomerDataTelemetry.js.map +1 -0
- package/esm/domain/tracing/getDocumentTraceId.d.ts +12 -0
- package/esm/domain/tracing/getDocumentTraceId.js +68 -0
- package/esm/domain/tracing/getDocumentTraceId.js.map +1 -0
- package/esm/domain/tracing/identifier.d.ts +13 -0
- package/esm/domain/tracing/identifier.js +50 -0
- package/esm/domain/tracing/identifier.js.map +1 -0
- package/esm/domain/tracing/sampler.d.ts +10 -0
- package/esm/domain/tracing/sampler.js +64 -0
- package/esm/domain/tracing/sampler.js.map +1 -0
- package/esm/domain/tracing/tracer.d.ts +30 -0
- package/esm/domain/tracing/tracer.js +156 -0
- package/esm/domain/tracing/tracer.js.map +1 -0
- package/esm/domain/tracing/tracer.types.d.ts +12 -0
- package/esm/domain/tracing/tracer.types.js +2 -0
- package/esm/domain/tracing/tracer.types.js.map +1 -0
- package/esm/domain/trackEventCounts.d.ts +17 -0
- package/esm/domain/trackEventCounts.js +47 -0
- package/esm/domain/trackEventCounts.js.map +1 -0
- package/esm/domain/view/bfCacheSupport.d.ts +2 -0
- package/esm/domain/view/bfCacheSupport.js +10 -0
- package/esm/domain/view/bfCacheSupport.js.map +1 -0
- package/esm/domain/view/trackViewEventCounts.d.ts +5 -0
- package/esm/domain/view/trackViewEventCounts.js +13 -0
- package/esm/domain/view/trackViewEventCounts.js.map +1 -0
- package/esm/domain/view/trackViews.d.ts +65 -0
- package/esm/domain/view/trackViews.js +271 -0
- package/esm/domain/view/trackViews.js.map +1 -0
- package/esm/domain/view/viewCollection.d.ts +18 -0
- package/esm/domain/view/viewCollection.js +150 -0
- package/esm/domain/view/viewCollection.js.map +1 -0
- package/esm/domain/view/viewMetrics/getClsAttributionImpactedArea.d.ts +6 -0
- package/esm/domain/view/viewMetrics/getClsAttributionImpactedArea.js +28 -0
- package/esm/domain/view/viewMetrics/getClsAttributionImpactedArea.js.map +1 -0
- package/esm/domain/view/viewMetrics/interactionCountPolyfill.d.ts +18 -0
- package/esm/domain/view/viewMetrics/interactionCountPolyfill.js +39 -0
- package/esm/domain/view/viewMetrics/interactionCountPolyfill.js.map +1 -0
- package/esm/domain/view/viewMetrics/startInitialViewMetricsTelemetry.d.ts +6 -0
- package/esm/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js +41 -0
- package/esm/domain/view/viewMetrics/startInitialViewMetricsTelemetry.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackBfcacheMetrics.d.ts +8 -0
- package/esm/domain/view/viewMetrics/trackBfcacheMetrics.js +14 -0
- package/esm/domain/view/viewMetrics/trackBfcacheMetrics.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackCommonViewMetrics.d.ts +21 -0
- package/esm/domain/view/viewMetrics/trackCommonViewMetrics.js +34 -0
- package/esm/domain/view/viewMetrics/trackCommonViewMetrics.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackCumulativeLayoutShift.d.ts +37 -0
- package/esm/domain/view/viewMetrics/trackCumulativeLayoutShift.js +130 -0
- package/esm/domain/view/viewMetrics/trackCumulativeLayoutShift.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackFirstContentfulPaint.d.ts +13 -0
- package/esm/domain/view/viewMetrics/trackFirstContentfulPaint.js +34 -0
- package/esm/domain/view/viewMetrics/trackFirstContentfulPaint.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackFirstHidden.d.ts +10 -0
- package/esm/domain/view/viewMetrics/trackFirstHidden.js +30 -0
- package/esm/domain/view/viewMetrics/trackFirstHidden.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackFirstInput.d.ts +19 -0
- package/esm/domain/view/viewMetrics/trackFirstInput.js +40 -0
- package/esm/domain/view/viewMetrics/trackFirstInput.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackInitialViewMetrics.d.ts +15 -0
- package/esm/domain/view/viewMetrics/trackInitialViewMetrics.js +38 -0
- package/esm/domain/view/viewMetrics/trackInitialViewMetrics.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackInteractionToNextPaint.d.ts +25 -0
- package/esm/domain/view/viewMetrics/trackInteractionToNextPaint.js +149 -0
- package/esm/domain/view/viewMetrics/trackInteractionToNextPaint.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackLargestContentfulPaint.d.ts +18 -0
- package/esm/domain/view/viewMetrics/trackLargestContentfulPaint.js +57 -0
- package/esm/domain/view/viewMetrics/trackLargestContentfulPaint.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackLoadingTime.d.ts +14 -0
- package/esm/domain/view/viewMetrics/trackLoadingTime.js +47 -0
- package/esm/domain/view/viewMetrics/trackLoadingTime.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackNavigationTimings.d.ts +14 -0
- package/esm/domain/view/viewMetrics/trackNavigationTimings.js +40 -0
- package/esm/domain/view/viewMetrics/trackNavigationTimings.js.map +1 -0
- package/esm/domain/view/viewMetrics/trackScrollMetrics.d.ts +25 -0
- package/esm/domain/view/viewMetrics/trackScrollMetrics.js +72 -0
- package/esm/domain/view/viewMetrics/trackScrollMetrics.js.map +1 -0
- package/esm/domain/vital/vitalCollection.d.ts +55 -0
- package/esm/domain/vital/vitalCollection.js +107 -0
- package/esm/domain/vital/vitalCollection.js.map +1 -0
- package/esm/domain/waitPageActivityEnd.d.ts +54 -0
- package/esm/domain/waitPageActivityEnd.js +123 -0
- package/esm/domain/waitPageActivityEnd.js.map +1 -0
- package/esm/domainContext.types.d.ts +39 -0
- package/esm/domainContext.types.js +5 -0
- package/esm/domainContext.types.js.map +1 -0
- package/esm/index.d.ts +41 -0
- package/esm/index.js +21 -0
- package/esm/index.js.map +1 -0
- package/esm/rawRumEvent.types.d.ts +326 -0
- package/esm/rawRumEvent.types.js +31 -0
- package/esm/rawRumEvent.types.js.map +1 -0
- package/esm/rumEvent.types.d.ts +2026 -0
- package/esm/rumEvent.types.js +6 -0
- package/esm/rumEvent.types.js.map +1 -0
- package/esm/transport/formDataTransport.d.ts +16 -0
- package/esm/transport/formDataTransport.js +43 -0
- package/esm/transport/formDataTransport.js.map +1 -0
- package/esm/transport/startRumBatch.d.ts +5 -0
- package/esm/transport/startRumBatch.js +30 -0
- package/esm/transport/startRumBatch.js.map +1 -0
- package/esm/transport/startRumEventBridge.d.ts +2 -0
- package/esm/transport/startRumEventBridge.js +8 -0
- package/esm/transport/startRumEventBridge.js.map +1 -0
- package/package.json +29 -0
- package/src/boot/preStartRum.ts +298 -0
- package/src/boot/rumPublicApi.ts +830 -0
- package/src/boot/startRum.ts +280 -0
- package/src/browser/cookieObservable.ts +63 -0
- package/src/browser/domMutationObservable.ts +98 -0
- package/src/browser/firstInputPolyfill.ts +87 -0
- package/src/browser/htmlDomUtils.ts +45 -0
- package/src/browser/locationChangeObservable.ts +69 -0
- package/src/browser/performanceObservable.ts +324 -0
- package/src/browser/performanceUtils.ts +50 -0
- package/src/browser/scroll.ts +25 -0
- package/src/browser/viewportObservable.ts +44 -0
- package/src/browser/windowOpenObservable.ts +7 -0
- package/src/domain/action/actionCollection.ts +146 -0
- package/src/domain/action/actionNameConstants.ts +20 -0
- package/src/domain/action/clickChain.ts +83 -0
- package/src/domain/action/computeFrustration.ts +77 -0
- package/src/domain/action/getActionNameFromElement.ts +337 -0
- package/src/domain/action/interactionSelectorCache.ts +21 -0
- package/src/domain/action/listenActionEvents.ts +119 -0
- package/src/domain/action/trackClickActions.ts +388 -0
- package/src/domain/assembly.ts +141 -0
- package/src/domain/configuration/configuration.ts +548 -0
- package/src/domain/configuration/index.ts +2 -0
- package/src/domain/configuration/jsonPathParser.ts +214 -0
- package/src/domain/configuration/remoteConfiguration.ts +304 -0
- package/src/domain/configuration/remoteConfiguration.types.ts +147 -0
- package/src/domain/contexts/ciVisibilityContext.ts +50 -0
- package/src/domain/contexts/connectivityContext.ts +12 -0
- package/src/domain/contexts/defaultContext.ts +43 -0
- package/src/domain/contexts/displayContext.ts +38 -0
- package/src/domain/contexts/featureFlagContext.ts +71 -0
- package/src/domain/contexts/internalContext.ts +34 -0
- package/src/domain/contexts/pageStateHistory.ts +171 -0
- package/src/domain/contexts/sessionContext.ts +59 -0
- package/src/domain/contexts/syntheticsContext.ts +33 -0
- package/src/domain/contexts/trackingConsentContext.ts +15 -0
- package/src/domain/contexts/urlContexts.ts +97 -0
- package/src/domain/contexts/userAgentDataContext.ts +36 -0
- package/src/domain/contexts/viewHistory.ts +70 -0
- package/src/domain/discardNegativeDuration.ts +6 -0
- package/src/domain/error/errorCollection.ts +107 -0
- package/src/domain/error/trackConsoleError.ts +14 -0
- package/src/domain/error/trackReportError.ts +16 -0
- package/src/domain/event/eventCollection.ts +53 -0
- package/src/domain/getSelectorFromElement.ts +268 -0
- package/src/domain/getSessionReplayUrl.ts +47 -0
- package/src/domain/hooks.ts +31 -0
- package/src/domain/lifeCycle.ts +103 -0
- package/src/domain/limitModification.ts +66 -0
- package/src/domain/longTask/longTaskCollection.ts +133 -0
- package/src/domain/plugins.ts +59 -0
- package/src/domain/privacy.ts +355 -0
- package/src/domain/privacyConstants.ts +43 -0
- package/src/domain/requestCollection.ts +179 -0
- package/src/domain/resource/graphql.ts +135 -0
- package/src/domain/resource/matchRequestResourceEntry.ts +68 -0
- package/src/domain/resource/requestRegistry.ts +52 -0
- package/src/domain/resource/resourceCollection.ts +273 -0
- package/src/domain/resource/resourceUtils.ts +355 -0
- package/src/domain/resource/retrieveInitialDocumentResourceTiming.ts +27 -0
- package/src/domain/rumSessionManager.ts +134 -0
- package/src/domain/sampler/sampler.ts +63 -0
- package/src/domain/startCustomerDataTelemetry.ts +83 -0
- package/src/domain/tracing/getDocumentTraceId.ts +90 -0
- package/src/domain/tracing/identifier.ts +69 -0
- package/src/domain/tracing/sampler.ts +69 -0
- package/src/domain/tracing/tracer.ts +248 -0
- package/src/domain/tracing/tracer.types.ts +13 -0
- package/src/domain/trackEventCounts.ts +67 -0
- package/src/domain/view/bfCacheSupport.ts +20 -0
- package/src/domain/view/trackViewEventCounts.ts +15 -0
- package/src/domain/view/trackViews.ts +431 -0
- package/src/domain/view/viewCollection.ts +203 -0
- package/src/domain/view/viewMetrics/getClsAttributionImpactedArea.ts +34 -0
- package/src/domain/view/viewMetrics/interactionCountPolyfill.ts +55 -0
- package/src/domain/view/viewMetrics/startInitialViewMetricsTelemetry.ts +70 -0
- package/src/domain/view/viewMetrics/trackBfcacheMetrics.ts +20 -0
- package/src/domain/view/viewMetrics/trackCommonViewMetrics.ts +78 -0
- package/src/domain/view/viewMetrics/trackCumulativeLayoutShift.ts +180 -0
- package/src/domain/view/viewMetrics/trackFirstContentfulPaint.ts +47 -0
- package/src/domain/view/viewMetrics/trackFirstHidden.ts +53 -0
- package/src/domain/view/viewMetrics/trackFirstInput.ts +59 -0
- package/src/domain/view/viewMetrics/trackInitialViewMetrics.ts +66 -0
- package/src/domain/view/viewMetrics/trackInteractionToNextPaint.ts +193 -0
- package/src/domain/view/viewMetrics/trackLargestContentfulPaint.ts +87 -0
- package/src/domain/view/viewMetrics/trackLoadingTime.ts +69 -0
- package/src/domain/view/viewMetrics/trackNavigationTimings.ts +66 -0
- package/src/domain/view/viewMetrics/trackScrollMetrics.ts +119 -0
- package/src/domain/vital/vitalCollection.ts +207 -0
- package/src/domain/waitPageActivityEnd.ts +189 -0
- package/src/domainContext.types.ts +61 -0
- package/src/index.ts +76 -0
- package/src/rawRumEvent.types.ts +409 -0
- package/src/rumEvent.types.ts +2151 -0
- package/src/transport/formDataTransport.ts +85 -0
- package/src/transport/startRumBatch.ts +46 -0
- package/src/transport/startRumEventBridge.ts +12 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Observable, SESSION_NOT_TRACKED, bridgeSupports, noop, performDraw, startSessionManager, } from '@kubesense/kubesense-browser-core';
|
|
2
|
+
export const RUM_SESSION_KEY = 'rum';
|
|
3
|
+
export function startRumSessionManager(configuration, lifeCycle, trackingConsentState) {
|
|
4
|
+
const sessionManager = startSessionManager(configuration, RUM_SESSION_KEY, (rawTrackingType) => computeTrackingType(configuration, rawTrackingType), trackingConsentState);
|
|
5
|
+
sessionManager.expireObservable.subscribe(() => {
|
|
6
|
+
lifeCycle.notify(9 /* LifeCycleEventType.SESSION_EXPIRED */);
|
|
7
|
+
});
|
|
8
|
+
sessionManager.renewObservable.subscribe(() => {
|
|
9
|
+
lifeCycle.notify(10 /* LifeCycleEventType.SESSION_RENEWED */);
|
|
10
|
+
});
|
|
11
|
+
sessionManager.sessionStateUpdateObservable.subscribe(({ previousState, newState }) => {
|
|
12
|
+
if (!previousState.forcedReplay && newState.forcedReplay) {
|
|
13
|
+
const sessionEntity = sessionManager.findSession();
|
|
14
|
+
if (sessionEntity) {
|
|
15
|
+
sessionEntity.isReplayForced = true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
findTrackedSession: (startTime) => {
|
|
21
|
+
const session = sessionManager.findSession(startTime);
|
|
22
|
+
if (!session || session.trackingType === "0" /* RumTrackingType.NOT_TRACKED */) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
id: session.id,
|
|
27
|
+
sessionReplay: session.trackingType === "1" /* RumTrackingType.TRACKED_WITH_SESSION_REPLAY */
|
|
28
|
+
? 1 /* SessionReplayState.SAMPLED */
|
|
29
|
+
: session.isReplayForced
|
|
30
|
+
? 2 /* SessionReplayState.FORCED */
|
|
31
|
+
: 0 /* SessionReplayState.OFF */,
|
|
32
|
+
anonymousId: session.anonymousId,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
expire: sessionManager.expire,
|
|
36
|
+
expireObservable: sessionManager.expireObservable,
|
|
37
|
+
setForcedReplay: () => sessionManager.updateSessionState({ forcedReplay: '1' }),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Start a tracked replay session stub
|
|
42
|
+
*/
|
|
43
|
+
export function startRumSessionManagerStub() {
|
|
44
|
+
const session = {
|
|
45
|
+
id: '00000000-aaaa-0000-aaaa-000000000000',
|
|
46
|
+
sessionReplay: bridgeSupports("records" /* BridgeCapability.RECORDS */) ? 1 /* SessionReplayState.SAMPLED */ : 0 /* SessionReplayState.OFF */,
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
findTrackedSession: () => session,
|
|
50
|
+
expire: noop,
|
|
51
|
+
expireObservable: new Observable(),
|
|
52
|
+
setForcedReplay: noop,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function computeTrackingType(configuration, rawTrackingType) {
|
|
56
|
+
if (hasValidRumSession(rawTrackingType)) {
|
|
57
|
+
return rawTrackingType;
|
|
58
|
+
}
|
|
59
|
+
if (!performDraw(configuration.sessionSampleRate)) {
|
|
60
|
+
return "0" /* RumTrackingType.NOT_TRACKED */;
|
|
61
|
+
}
|
|
62
|
+
if (!performDraw(configuration.sessionReplaySampleRate)) {
|
|
63
|
+
return "2" /* RumTrackingType.TRACKED_WITHOUT_SESSION_REPLAY */;
|
|
64
|
+
}
|
|
65
|
+
return "1" /* RumTrackingType.TRACKED_WITH_SESSION_REPLAY */;
|
|
66
|
+
}
|
|
67
|
+
function hasValidRumSession(trackingType) {
|
|
68
|
+
return (trackingType === "0" /* RumTrackingType.NOT_TRACKED */ ||
|
|
69
|
+
trackingType === "1" /* RumTrackingType.TRACKED_WITH_SESSION_REPLAY */ ||
|
|
70
|
+
trackingType === "2" /* RumTrackingType.TRACKED_WITHOUT_SESSION_REPLAY */);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=rumSessionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rumSessionManager.js","sourceRoot":"","sources":["../../src/domain/rumSessionManager.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function isSampled(sessionId: string, sampleRate: number): boolean;
|
|
2
|
+
export declare function resetSampleDecisionCache(): void;
|
|
3
|
+
/**
|
|
4
|
+
* Perform sampling using the Knuth factor method. This method offer consistent sampling result
|
|
5
|
+
* based on the provided identifier.
|
|
6
|
+
*
|
|
7
|
+
* @param identifier - The identifier to use for sampling.
|
|
8
|
+
* @param sampleRate - The sample rate in percentage between 0 and 100.
|
|
9
|
+
*/
|
|
10
|
+
export declare function sampleUsingKnuthFactor(identifier: bigint, sampleRate: number): boolean;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { performDraw } from '@kubesense/kubesense-browser-core';
|
|
2
|
+
const sampleDecisionCache = new Map();
|
|
3
|
+
export function isSampled(sessionId, sampleRate) {
|
|
4
|
+
// Shortcuts for common cases. This is not strictly necessary, but it makes the code faster for
|
|
5
|
+
// customers willing to ingest all traces.
|
|
6
|
+
if (sampleRate === 100) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (sampleRate === 0) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const cachedDecision = sampleDecisionCache.get(sampleRate);
|
|
13
|
+
if (cachedDecision && sessionId === cachedDecision.sessionId) {
|
|
14
|
+
return cachedDecision.decision;
|
|
15
|
+
}
|
|
16
|
+
let decision;
|
|
17
|
+
// @ts-expect-error BigInt might not be defined in every browser we support
|
|
18
|
+
if (window.BigInt) {
|
|
19
|
+
decision = sampleUsingKnuthFactor(BigInt(`0x${sessionId.split('-')[4]}`), sampleRate);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// For simplicity, we don't use consistent sampling for browser without BigInt support
|
|
23
|
+
// TODO: remove this when all browser we support have BigInt support
|
|
24
|
+
decision = performDraw(sampleRate);
|
|
25
|
+
}
|
|
26
|
+
sampleDecisionCache.set(sampleRate, { sessionId, decision });
|
|
27
|
+
return decision;
|
|
28
|
+
}
|
|
29
|
+
// Exported for tests
|
|
30
|
+
export function resetSampleDecisionCache() {
|
|
31
|
+
sampleDecisionCache.clear();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Perform sampling using the Knuth factor method. This method offer consistent sampling result
|
|
35
|
+
* based on the provided identifier.
|
|
36
|
+
*
|
|
37
|
+
* @param identifier - The identifier to use for sampling.
|
|
38
|
+
* @param sampleRate - The sample rate in percentage between 0 and 100.
|
|
39
|
+
*/
|
|
40
|
+
export function sampleUsingKnuthFactor(identifier, sampleRate) {
|
|
41
|
+
// The formula is:
|
|
42
|
+
//
|
|
43
|
+
// (identifier * knuthFactor) % 2^64 < sampleRate * 2^64
|
|
44
|
+
//
|
|
45
|
+
// Because JavaScript numbers are 64-bit floats, we can't represent 64-bit integers, and the
|
|
46
|
+
// modulo would be incorrect. Thus, we are using BigInts here.
|
|
47
|
+
//
|
|
48
|
+
// Note: All implementations have slight variations. Some of them use '<=' instead of '<', and
|
|
49
|
+
// use `sampleRate * 2^64 - 1` instead of `sampleRate * 2^64`. The following implementation
|
|
50
|
+
// should adhere to the spec and is a bit simpler than using a 2^64-1 limit as there are less
|
|
51
|
+
// BigInt arithmetic to write. In practice this does not matter, as we are using floating point
|
|
52
|
+
// numbers in the end, and Number(2n**64n-1n) === Number(2n**64n).
|
|
53
|
+
const knuthFactor = BigInt('1111111111111111111');
|
|
54
|
+
const twoPow64 = BigInt('0x10000000000000000'); // 2n ** 64n
|
|
55
|
+
const hash = (identifier * knuthFactor) % twoPow64;
|
|
56
|
+
return Number(hash) <= (sampleRate / 100) * Number(twoPow64);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=sampler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampler.js","sourceRoot":"","sources":["../../../src/domain/sampler/sampler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAE/D,MAAM,mBAAmB,GAA0D,IAAI,GAAG,EAAE,CAAA;AAE5F,MAAM,UAAU,SAAS,CAAC,SAAiB,EAAE,UAAkB;IAC7D,+FAA+F;IAC/F,0CAA0C;IAC1C,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,cAAc,GAAG,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IAC1D,IAAI,cAAc,IAAI,SAAS,KAAK,cAAc,CAAC,SAAS,EAAE,CAAC;QAC7D,OAAO,cAAc,CAAC,QAAQ,CAAA;IAChC,CAAC;IAED,IAAI,QAAiB,CAAA;IACrB,2EAA2E;IAC3E,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,QAAQ,GAAG,sBAAsB,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,CAAA;IACvF,CAAC;SAAM,CAAC;QACN,sFAAsF;QACtF,oEAAoE;QACpE,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC,CAAA;IACpC,CAAC;IACD,mBAAmB,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC5D,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,qBAAqB;AACrB,MAAM,UAAU,wBAAwB;IACtC,mBAAmB,CAAC,KAAK,EAAE,CAAA;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAkB,EAAE,UAAkB;IAC3E,kBAAkB;IAClB,EAAE;IACF,0DAA0D;IAC1D,EAAE;IACF,4FAA4F;IAC5F,8DAA8D;IAC9D,EAAE;IACF,8FAA8F;IAC9F,2FAA2F;IAC3F,6FAA6F;IAC7F,+FAA+F;IAC/F,kEAAkE;IAClE,MAAM,WAAW,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAA;IACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAA,CAAC,YAAY;IAC3D,MAAM,IAAI,GAAG,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,QAAQ,CAAA;IAClD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;AAC9D,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FlushEvent, Observable, Telemetry } from '@kubesense/kubesense-browser-core';
|
|
2
|
+
import type { LifeCycle } from './lifeCycle';
|
|
3
|
+
export declare const MEASURES_PERIOD_DURATION: number;
|
|
4
|
+
export declare function startCustomerDataTelemetry(telemetry: Telemetry, lifeCycle: LifeCycle, batchFlushObservable: Observable<FlushEvent>): void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ONE_SECOND, addTelemetryMetrics, setInterval } from '@kubesense/kubesense-browser-core';
|
|
2
|
+
export const MEASURES_PERIOD_DURATION = 10 * ONE_SECOND;
|
|
3
|
+
let currentPeriodMeasures;
|
|
4
|
+
let batchHasRumEvent;
|
|
5
|
+
export function startCustomerDataTelemetry(telemetry, lifeCycle, batchFlushObservable) {
|
|
6
|
+
if (!telemetry.metricsEnabled) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
initCurrentPeriodMeasures();
|
|
10
|
+
batchHasRumEvent = false;
|
|
11
|
+
// We measure the data of every view updates even if there could only be one per batch due to the upsert
|
|
12
|
+
// It means that contexts bytes count sums can be higher than it really is
|
|
13
|
+
lifeCycle.subscribe(13 /* LifeCycleEventType.RUM_EVENT_COLLECTED */, () => {
|
|
14
|
+
batchHasRumEvent = true;
|
|
15
|
+
});
|
|
16
|
+
batchFlushObservable.subscribe(({ bytesCount, messagesCount }) => {
|
|
17
|
+
// Don't measure batch that only contains telemetry events to avoid batch sending loop
|
|
18
|
+
// It could happen because after each batch we are adding a customer data measures telemetry event to the next one
|
|
19
|
+
if (!batchHasRumEvent) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
batchHasRumEvent = false;
|
|
23
|
+
currentPeriodMeasures.batchCount += 1;
|
|
24
|
+
updateMeasure(currentPeriodMeasures.batchBytesCount, bytesCount);
|
|
25
|
+
updateMeasure(currentPeriodMeasures.batchMessagesCount, messagesCount);
|
|
26
|
+
});
|
|
27
|
+
setInterval(sendCurrentPeriodMeasures, MEASURES_PERIOD_DURATION);
|
|
28
|
+
}
|
|
29
|
+
function sendCurrentPeriodMeasures() {
|
|
30
|
+
if (currentPeriodMeasures.batchCount === 0) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// monitor-until: forever
|
|
34
|
+
addTelemetryMetrics("Customer data measures" /* TelemetryMetrics.CUSTOMER_DATA_METRIC_NAME */, currentPeriodMeasures);
|
|
35
|
+
initCurrentPeriodMeasures();
|
|
36
|
+
}
|
|
37
|
+
function createMeasure() {
|
|
38
|
+
return { min: Infinity, max: 0, sum: 0 };
|
|
39
|
+
}
|
|
40
|
+
function updateMeasure(measure, value) {
|
|
41
|
+
measure.sum += value;
|
|
42
|
+
measure.min = Math.min(measure.min, value);
|
|
43
|
+
measure.max = Math.max(measure.max, value);
|
|
44
|
+
}
|
|
45
|
+
function initCurrentPeriodMeasures() {
|
|
46
|
+
currentPeriodMeasures = {
|
|
47
|
+
batchCount: 0,
|
|
48
|
+
batchBytesCount: createMeasure(),
|
|
49
|
+
batchMessagesCount: createMeasure(),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=startCustomerDataTelemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startCustomerDataTelemetry.js","sourceRoot":"","sources":["../../src/domain/startCustomerDataTelemetry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,WAAW,EAAoB,MAAM,mCAAmC,CAAA;AAKlH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,GAAG,UAAU,CAAA;AAcvD,IAAI,qBAA4C,CAAA;AAChD,IAAI,gBAAyB,CAAA;AAE7B,MAAM,UAAU,0BAA0B,CACxC,SAAoB,EACpB,SAAoB,EACpB,oBAA4C;IAE5C,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;QAC9B,OAAM;IACR,CAAC;IAED,yBAAyB,EAAE,CAAA;IAC3B,gBAAgB,GAAG,KAAK,CAAA;IACxB,wGAAwG;IACxG,0EAA0E;IAC1E,SAAS,CAAC,SAAS,kDAAyC,GAAG,EAAE;QAC/D,gBAAgB,GAAG,IAAI,CAAA;IACzB,CAAC,CAAC,CAAA;IAEF,oBAAoB,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,EAAE;QAC/D,sFAAsF;QACtF,kHAAkH;QAClH,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,OAAM;QACR,CAAC;QACD,gBAAgB,GAAG,KAAK,CAAA;QAExB,qBAAqB,CAAC,UAAU,IAAI,CAAC,CAAA;QACrC,aAAa,CAAC,qBAAqB,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;QAChE,aAAa,CAAC,qBAAqB,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;IAEF,WAAW,CAAC,yBAAyB,EAAE,wBAAwB,CAAC,CAAA;AAClE,CAAC;AAED,SAAS,yBAAyB;IAChC,IAAI,qBAAqB,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAM;IACR,CAAC;IAED,yBAAyB;IACzB,mBAAmB,4EAA6C,qBAAqB,CAAC,CAAA;IACtF,yBAAyB,EAAE,CAAA;AAC7B,CAAC;AAED,SAAS,aAAa;IACpB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAA;AAC1C,CAAC;AAED,SAAS,aAAa,CAAC,OAAgB,EAAE,KAAa;IACpD,OAAO,CAAC,GAAG,IAAI,KAAK,CAAA;IACpB,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAC1C,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AAC5C,CAAC;AAED,SAAS,yBAAyB;IAChC,qBAAqB,GAAG;QACtB,UAAU,EAAE,CAAC;QACb,eAAe,EAAE,aAAa,EAAE;QAChC,kBAAkB,EAAE,aAAa,EAAE;KACpC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TimeStamp } from '@kubesense/kubesense-browser-core';
|
|
2
|
+
interface DocumentTraceData {
|
|
3
|
+
traceId: string;
|
|
4
|
+
traceTime: TimeStamp;
|
|
5
|
+
}
|
|
6
|
+
export declare const INITIAL_DOCUMENT_OUTDATED_TRACE_ID_THRESHOLD: number;
|
|
7
|
+
export declare function getDocumentTraceId(document: Document): string | undefined;
|
|
8
|
+
export declare function getDocumentTraceDataFromMeta(document: Document): DocumentTraceData | undefined;
|
|
9
|
+
export declare function getDocumentTraceDataFromComment(document: Document): DocumentTraceData | undefined;
|
|
10
|
+
export declare function createDocumentTraceData(traceId: string | undefined | null, rawTraceTime: string | undefined | null): DocumentTraceData | undefined;
|
|
11
|
+
export declare function findTraceComment(document: Document): string | undefined;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { dateNow, findCommaSeparatedValue, ONE_MINUTE } from '@kubesense/kubesense-browser-core';
|
|
2
|
+
import { isCommentNode, isTextNode } from '../../browser/htmlDomUtils';
|
|
3
|
+
export const INITIAL_DOCUMENT_OUTDATED_TRACE_ID_THRESHOLD = 2 * ONE_MINUTE;
|
|
4
|
+
export function getDocumentTraceId(document) {
|
|
5
|
+
const data = getDocumentTraceDataFromMeta(document) || getDocumentTraceDataFromComment(document);
|
|
6
|
+
if (!data || data.traceTime <= dateNow() - INITIAL_DOCUMENT_OUTDATED_TRACE_ID_THRESHOLD) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return data.traceId;
|
|
10
|
+
}
|
|
11
|
+
export function getDocumentTraceDataFromMeta(document) {
|
|
12
|
+
const traceIdMeta = document.querySelector('meta[name=kubesense-trace-id]');
|
|
13
|
+
const traceTimeMeta = document.querySelector('meta[name=kubesense-trace-time]');
|
|
14
|
+
return createDocumentTraceData(traceIdMeta && traceIdMeta.content, traceTimeMeta && traceTimeMeta.content);
|
|
15
|
+
}
|
|
16
|
+
export function getDocumentTraceDataFromComment(document) {
|
|
17
|
+
const comment = findTraceComment(document);
|
|
18
|
+
if (!comment) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return createDocumentTraceData(findCommaSeparatedValue(comment, 'trace-id'), findCommaSeparatedValue(comment, 'trace-time'));
|
|
22
|
+
}
|
|
23
|
+
export function createDocumentTraceData(traceId, rawTraceTime) {
|
|
24
|
+
const traceTime = rawTraceTime && Number(rawTraceTime);
|
|
25
|
+
if (!traceId || !traceTime) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
traceId,
|
|
30
|
+
traceTime,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function findTraceComment(document) {
|
|
34
|
+
// 1. Try to find the comment as a direct child of the document
|
|
35
|
+
// Note: TSLint advises to use a 'for of', but TS doesn't allow to use 'for of' if the iterated
|
|
36
|
+
// value is not an array or string (here, a NodeList).
|
|
37
|
+
for (let i = 0; i < document.childNodes.length; i += 1) {
|
|
38
|
+
const comment = getTraceCommentFromNode(document.childNodes[i]);
|
|
39
|
+
if (comment) {
|
|
40
|
+
return comment;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// 2. If the comment is placed after the </html> tag, but have some space or new lines before or
|
|
44
|
+
// after, the DOM parser will lift it (and the surrounding text) at the end of the <body> tag.
|
|
45
|
+
// Try to look for the comment at the end of the <body> by by iterating over its child nodes in
|
|
46
|
+
// reverse order, stopping if we come across a non-text node.
|
|
47
|
+
if (document.body) {
|
|
48
|
+
for (let i = document.body.childNodes.length - 1; i >= 0; i -= 1) {
|
|
49
|
+
const node = document.body.childNodes[i];
|
|
50
|
+
const comment = getTraceCommentFromNode(node);
|
|
51
|
+
if (comment) {
|
|
52
|
+
return comment;
|
|
53
|
+
}
|
|
54
|
+
if (!isTextNode(node)) {
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function getTraceCommentFromNode(node) {
|
|
61
|
+
if (node && isCommentNode(node)) {
|
|
62
|
+
const match = /^\s*KUBESENSE;(.*?)\s*$/.exec(node.data);
|
|
63
|
+
if (match) {
|
|
64
|
+
return match[1];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=getDocumentTraceId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDocumentTraceId.js","sourceRoot":"","sources":["../../../src/domain/tracing/getDocumentTraceId.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface BaseIdentifier {
|
|
2
|
+
toString(radix?: number): string;
|
|
3
|
+
}
|
|
4
|
+
export interface TraceIdentifier extends BaseIdentifier {
|
|
5
|
+
__brand: 'traceIdentifier';
|
|
6
|
+
}
|
|
7
|
+
export interface SpanIdentifier extends BaseIdentifier {
|
|
8
|
+
__brand: 'spanIdentifier';
|
|
9
|
+
}
|
|
10
|
+
export declare function createTraceIdentifier(): TraceIdentifier;
|
|
11
|
+
export declare function createSpanIdentifier(): SpanIdentifier;
|
|
12
|
+
export declare function toPaddedHexadecimalString(id: BaseIdentifier): string;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export function createTraceIdentifier() {
|
|
2
|
+
return createIdentifier(64);
|
|
3
|
+
}
|
|
4
|
+
export function createSpanIdentifier() {
|
|
5
|
+
return createIdentifier(63);
|
|
6
|
+
}
|
|
7
|
+
function createIdentifier(bits) {
|
|
8
|
+
const buffer = crypto.getRandomValues(new Uint32Array(2));
|
|
9
|
+
if (bits === 63) {
|
|
10
|
+
// eslint-disable-next-line no-bitwise
|
|
11
|
+
buffer[buffer.length - 1] >>>= 1; // force 63-bit
|
|
12
|
+
}
|
|
13
|
+
// The `.toString` function is intentionally similar to Number and BigInt `.toString` method.
|
|
14
|
+
//
|
|
15
|
+
// JavaScript numbers can represent integers up to 48 bits, this is why we need two of them to
|
|
16
|
+
// represent a 64 bits identifier. But BigInts don't have this limitation and can represent larger
|
|
17
|
+
// integer values.
|
|
18
|
+
//
|
|
19
|
+
// In the future, when we drop browsers without BigInts support, we could use BigInts directly
|
|
20
|
+
// represent identifiers by simply returning a BigInt from this function (as all we need is a
|
|
21
|
+
// value with a `.toString` method).
|
|
22
|
+
//
|
|
23
|
+
// Examples:
|
|
24
|
+
// const buffer = getCrypto().getRandomValues(new Uint32Array(2))
|
|
25
|
+
// return BigInt(buffer[0]) + BigInt(buffer[1]) << 32n
|
|
26
|
+
//
|
|
27
|
+
// // Alternative with BigUint64Array (different Browser support than plain bigints!):
|
|
28
|
+
// return crypto.getRandomValues(new BigUint64Array(1))[0]
|
|
29
|
+
//
|
|
30
|
+
// For now, let's keep using two plain numbers as having two different implementations (one for
|
|
31
|
+
// browsers with BigInt support and one for older browsers) don't bring much value.
|
|
32
|
+
return {
|
|
33
|
+
toString(radix = 10) {
|
|
34
|
+
let high = buffer[1];
|
|
35
|
+
let low = buffer[0];
|
|
36
|
+
let str = '';
|
|
37
|
+
do {
|
|
38
|
+
const mod = (high % radix) * 4294967296 + low;
|
|
39
|
+
high = Math.floor(high / radix);
|
|
40
|
+
low = Math.floor(mod / radix);
|
|
41
|
+
str = (mod % radix).toString(radix) + str;
|
|
42
|
+
} while (high || low);
|
|
43
|
+
return str;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function toPaddedHexadecimalString(id) {
|
|
48
|
+
return id.toString(16).padStart(16, '0');
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=identifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../src/domain/tracing/identifier.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,qBAAqB;IACnC,OAAO,gBAAgB,CAAC,EAAE,CAAoB,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,gBAAgB,CAAC,EAAE,CAAmB,CAAA;AAC/C,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAa;IACrC,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;IACzD,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChB,sCAAsC;QACtC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAA,CAAC,eAAe;IAClD,CAAC;IAED,6FAA6F;IAC7F,EAAE;IACF,8FAA8F;IAC9F,kGAAkG;IAClG,kBAAkB;IAClB,EAAE;IACF,8FAA8F;IAC9F,6FAA6F;IAC7F,oCAAoC;IACpC,EAAE;IACF,YAAY;IACZ,mEAAmE;IACnE,wDAAwD;IACxD,EAAE;IACF,wFAAwF;IACxF,4DAA4D;IAC5D,EAAE;IACF,+FAA+F;IAC/F,mFAAmF;IACnF,OAAO;QACL,QAAQ,CAAC,KAAK,GAAG,EAAE;YACjB,IAAI,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;YACpB,IAAI,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;YACnB,IAAI,GAAG,GAAG,EAAE,CAAA;YAEZ,GAAG,CAAC;gBACF,MAAM,GAAG,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,UAAU,GAAG,GAAG,CAAA;gBAC7C,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,CAAA;gBAC/B,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,CAAA;gBAC7B,GAAG,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,GAAG,CAAA;YAC3C,CAAC,QAAQ,IAAI,IAAI,GAAG,EAAC;YAErB,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,EAAkB;IAC1D,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function isTraceSampled(sessionId: string, sampleRate: number): boolean;
|
|
2
|
+
export declare function resetSampleDecisionCache(): void;
|
|
3
|
+
/**
|
|
4
|
+
* Perform sampling using the Knuth factor method. This method offer consistent sampling result
|
|
5
|
+
* based on the provided identifier.
|
|
6
|
+
*
|
|
7
|
+
* @param identifier The identifier to use for sampling.
|
|
8
|
+
* @param sampleRate The sample rate in percentage between 0 and 100.
|
|
9
|
+
*/
|
|
10
|
+
export declare function sampleUsingKnuthFactor(identifier: bigint, sampleRate: number): boolean;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { performDraw } from '@kubesense/kubesense-browser-core';
|
|
2
|
+
let sampleDecisionCache;
|
|
3
|
+
export function isTraceSampled(sessionId, sampleRate) {
|
|
4
|
+
// Shortcuts for common cases. This is not strictly necessary, but it makes the code faster for
|
|
5
|
+
// customers willing to ingest all traces.
|
|
6
|
+
if (sampleRate === 100) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (sampleRate === 0) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (sampleDecisionCache && sessionId === sampleDecisionCache.sessionId) {
|
|
13
|
+
return sampleDecisionCache.decision;
|
|
14
|
+
}
|
|
15
|
+
let decision;
|
|
16
|
+
// @ts-expect-error BigInt might not be defined in every browser we support
|
|
17
|
+
if (window.BigInt) {
|
|
18
|
+
decision = sampleUsingKnuthFactor(BigInt(`0x${sessionId.split('-')[4]}`), sampleRate);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
// For simplicity, we don't use consistent sampling for browser without BigInt support
|
|
22
|
+
// TODO: remove this when all browser we support have BigInt support
|
|
23
|
+
decision = performDraw(sampleRate);
|
|
24
|
+
}
|
|
25
|
+
sampleDecisionCache = { sessionId, decision };
|
|
26
|
+
return decision;
|
|
27
|
+
}
|
|
28
|
+
// Exported for tests
|
|
29
|
+
export function resetSampleDecisionCache() {
|
|
30
|
+
sampleDecisionCache = undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Perform sampling using the Knuth factor method. This method offer consistent sampling result
|
|
34
|
+
* based on the provided identifier.
|
|
35
|
+
*
|
|
36
|
+
* @param identifier The identifier to use for sampling.
|
|
37
|
+
* @param sampleRate The sample rate in percentage between 0 and 100.
|
|
38
|
+
*/
|
|
39
|
+
export function sampleUsingKnuthFactor(identifier, sampleRate) {
|
|
40
|
+
// The formula is:
|
|
41
|
+
//
|
|
42
|
+
// (identifier * knuthFactor) % 2^64 < sampleRate * 2^64
|
|
43
|
+
//
|
|
44
|
+
// Because JavaScript numbers are 64-bit floats, we can't represent 64-bit integers, and the
|
|
45
|
+
// modulo would be incorrect. Thus, we are using BigInts here.
|
|
46
|
+
//
|
|
47
|
+
// Implementation in other languages:
|
|
48
|
+
// * Go https://github.com/DataDog/kubesense-trace-go/blob/ec6fbb1f2d517b7b8e69961052adf7136f3af773/ddtrace/tracer/sampler.go#L86-L91
|
|
49
|
+
// * Python https://github.com/DataDog/kubesense-trace-py/blob/0cee2f066fb6e79aa15947c1514c0f406dea47c5/ddtrace/sampling_rule.py#L197
|
|
50
|
+
// * Ruby https://github.com/DataDog/kubesense-trace-rb/blob/1a6e255cdcb7e7e22235ea5955f90f6dfa91045d/lib/kubesense/tracing/sampling/rate_sampler.rb#L42
|
|
51
|
+
// * C++ https://github.com/DataDog/kubesense-trace-cpp/blob/159629edc438ae45f2bb318eb7bd51abd05e94b5/src/kubesense/trace_sampler.cpp#L58
|
|
52
|
+
// * Java https://github.com/DataDog/kubesense-trace-java/blob/896dd6b380533216e0bdee59614606c8272d313e/kubesense-trace-core/src/main/java/kubesense/trace/common/sampling/DeterministicSampler.java#L48
|
|
53
|
+
//
|
|
54
|
+
// Note: All implementations have slight variations. Some of them use '<=' instead of '<', and
|
|
55
|
+
// use `sampleRate * 2^64 - 1` instead of `sampleRate * 2^64`. The following implementation
|
|
56
|
+
// should adhere to the spec and is a bit simpler than using a 2^64-1 limit as there are less
|
|
57
|
+
// BigInt arithmetic to write. In practice this does not matter, as we are using floating point
|
|
58
|
+
// numbers in the end, and Number(2n**64n-1n) === Number(2n**64n).
|
|
59
|
+
const knuthFactor = BigInt('1111111111111111111');
|
|
60
|
+
const twoPow64 = BigInt('0x10000000000000000'); // 2n ** 64n
|
|
61
|
+
const hash = (identifier * knuthFactor) % twoPow64;
|
|
62
|
+
return Number(hash) <= (sampleRate / 100) * Number(twoPow64);
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=sampler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampler.js","sourceRoot":"","sources":["../../../src/domain/tracing/sampler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAE/D,IAAI,mBAAyE,CAAA;AAE7E,MAAM,UAAU,cAAc,CAAC,SAAiB,EAAE,UAAkB;IAClE,+FAA+F;IAC/F,0CAA0C;IAC1C,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,mBAAmB,IAAI,SAAS,KAAK,mBAAmB,CAAC,SAAS,EAAE,CAAC;QACvE,OAAO,mBAAmB,CAAC,QAAQ,CAAA;IACrC,CAAC;IAED,IAAI,QAAiB,CAAA;IACrB,2EAA2E;IAC3E,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,QAAQ,GAAG,sBAAsB,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,CAAA;IACvF,CAAC;SAAM,CAAC;QACN,sFAAsF;QACtF,oEAAoE;QACpE,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC,CAAA;IACpC,CAAC;IACD,mBAAmB,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAA;IAC7C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,qBAAqB;AACrB,MAAM,UAAU,wBAAwB;IACtC,mBAAmB,GAAG,SAAS,CAAA;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAkB,EAAE,UAAkB;IAC3E,kBAAkB;IAClB,EAAE;IACF,0DAA0D;IAC1D,EAAE;IACF,4FAA4F;IAC5F,8DAA8D;IAC9D,EAAE;IACF,qCAAqC;IACrC,yIAAyI;IACzI,qIAAqI;IACrI,0JAA0J;IAC1J,4IAA4I;IAC5I,0MAA0M;IAC1M,EAAE;IACF,8FAA8F;IAC9F,2FAA2F;IAC3F,6FAA6F;IAC7F,+FAA+F;IAC/F,kEAAkE;IAClE,MAAM,WAAW,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAA;IACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAA,CAAC,YAAY;IAC3D,MAAM,IAAI,GAAG,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,QAAQ,CAAA;IAClD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;AAC9D,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ContextManager } from '@kubesense/kubesense-browser-core';
|
|
2
|
+
import type { RumConfiguration } from '../configuration';
|
|
3
|
+
import type { RumFetchResolveContext, RumFetchStartContext, RumXhrCompleteContext, RumXhrStartContext } from '../requestCollection';
|
|
4
|
+
import type { RumSessionManager } from '../rumSessionManager';
|
|
5
|
+
import type { TracingOption } from './tracer.types';
|
|
6
|
+
export interface Tracer {
|
|
7
|
+
traceFetch: (context: Partial<RumFetchStartContext>) => void;
|
|
8
|
+
traceXhr: (context: Partial<RumXhrStartContext>, xhr: XMLHttpRequest) => void;
|
|
9
|
+
clearTracingIfNeeded: (context: RumFetchResolveContext | RumXhrCompleteContext) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function isTracingOption(item: unknown): item is TracingOption;
|
|
12
|
+
/**
|
|
13
|
+
* Clear tracing information to avoid incomplete traces. Ideally, we should do it when the
|
|
14
|
+
* request did not reach the server, but the browser does not expose this. So, we clear tracing
|
|
15
|
+
* information if the request ended with status 0 without being aborted by the application.
|
|
16
|
+
*
|
|
17
|
+
* Reasoning:
|
|
18
|
+
*
|
|
19
|
+
* * Applications are usually aborting requests after a bit of time, for example when the user is
|
|
20
|
+
* typing (autocompletion) or navigating away (in a SPA). With a performant device and good
|
|
21
|
+
* network conditions, the request is likely to reach the server before being canceled.
|
|
22
|
+
*
|
|
23
|
+
* * Requests aborted otherwise (ex: lack of internet, CORS issue, blocked by a privacy extension)
|
|
24
|
+
* are likely to finish quickly and without reaching the server.
|
|
25
|
+
*
|
|
26
|
+
* Of course, it might not be the case every time, but it should limit having incomplete traces a
|
|
27
|
+
* bit.
|
|
28
|
+
* */
|
|
29
|
+
export declare function clearTracingIfNeeded(context: RumFetchResolveContext | RumXhrCompleteContext): void;
|
|
30
|
+
export declare function startTracer(configuration: RumConfiguration, sessionManager: RumSessionManager, userContext: ContextManager, accountContext: ContextManager): Tracer;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { objectEntries, shallowClone, getType, isMatchOption, matchList, TraceContextInjection, } from '@kubesense/kubesense-browser-core';
|
|
2
|
+
import { isSampled } from '../sampler/sampler';
|
|
3
|
+
import { createSpanIdentifier, createTraceIdentifier, toPaddedHexadecimalString } from './identifier';
|
|
4
|
+
export function isTracingOption(item) {
|
|
5
|
+
const expectedItem = item;
|
|
6
|
+
return (getType(expectedItem) === 'object' &&
|
|
7
|
+
isMatchOption(expectedItem.match) &&
|
|
8
|
+
Array.isArray(expectedItem.propagatorTypes));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Clear tracing information to avoid incomplete traces. Ideally, we should do it when the
|
|
12
|
+
* request did not reach the server, but the browser does not expose this. So, we clear tracing
|
|
13
|
+
* information if the request ended with status 0 without being aborted by the application.
|
|
14
|
+
*
|
|
15
|
+
* Reasoning:
|
|
16
|
+
*
|
|
17
|
+
* * Applications are usually aborting requests after a bit of time, for example when the user is
|
|
18
|
+
* typing (autocompletion) or navigating away (in a SPA). With a performant device and good
|
|
19
|
+
* network conditions, the request is likely to reach the server before being canceled.
|
|
20
|
+
*
|
|
21
|
+
* * Requests aborted otherwise (ex: lack of internet, CORS issue, blocked by a privacy extension)
|
|
22
|
+
* are likely to finish quickly and without reaching the server.
|
|
23
|
+
*
|
|
24
|
+
* Of course, it might not be the case every time, but it should limit having incomplete traces a
|
|
25
|
+
* bit.
|
|
26
|
+
* */
|
|
27
|
+
export function clearTracingIfNeeded(context) {
|
|
28
|
+
if (context.status === 0 && !context.isAborted) {
|
|
29
|
+
context.traceId = undefined;
|
|
30
|
+
context.spanId = undefined;
|
|
31
|
+
context.traceSampled = undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function startTracer(configuration, sessionManager, userContext, accountContext) {
|
|
35
|
+
return {
|
|
36
|
+
clearTracingIfNeeded,
|
|
37
|
+
traceFetch: (context) => injectHeadersIfTracingAllowed(configuration, context, sessionManager, userContext, accountContext, (tracingHeaders) => {
|
|
38
|
+
var _a;
|
|
39
|
+
if (context.input instanceof Request && !((_a = context.init) === null || _a === void 0 ? void 0 : _a.headers)) {
|
|
40
|
+
context.input = new Request(context.input);
|
|
41
|
+
Object.keys(tracingHeaders).forEach((key) => {
|
|
42
|
+
;
|
|
43
|
+
context.input.headers.append(key, tracingHeaders[key]);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
context.init = shallowClone(context.init);
|
|
48
|
+
const headers = [];
|
|
49
|
+
if (context.init.headers instanceof Headers) {
|
|
50
|
+
context.init.headers.forEach((value, key) => {
|
|
51
|
+
headers.push([key, value]);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else if (Array.isArray(context.init.headers)) {
|
|
55
|
+
context.init.headers.forEach((header) => {
|
|
56
|
+
headers.push(header);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else if (context.init.headers) {
|
|
60
|
+
Object.keys(context.init.headers).forEach((key) => {
|
|
61
|
+
headers.push([key, context.init.headers[key]]);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
context.init.headers = headers.concat(objectEntries(tracingHeaders));
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
traceXhr: (context, xhr) => injectHeadersIfTracingAllowed(configuration, context, sessionManager, userContext, accountContext, (tracingHeaders) => {
|
|
68
|
+
Object.keys(tracingHeaders).forEach((name) => {
|
|
69
|
+
xhr.setRequestHeader(name, tracingHeaders[name]);
|
|
70
|
+
});
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function injectHeadersIfTracingAllowed(configuration, context, sessionManager, userContext, accountContext, inject) {
|
|
75
|
+
const session = sessionManager.findTrackedSession();
|
|
76
|
+
if (!session) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const tracingOption = configuration.allowedTracingUrls.find((tracingOption) => matchList([tracingOption.match], context.url, true));
|
|
80
|
+
if (!tracingOption) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const traceSampled = isSampled(session.id, configuration.traceSampleRate);
|
|
84
|
+
const shouldInjectHeaders = traceSampled || configuration.traceContextInjection === TraceContextInjection.ALL;
|
|
85
|
+
if (!shouldInjectHeaders) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
context.traceSampled = traceSampled;
|
|
89
|
+
context.traceId = createTraceIdentifier();
|
|
90
|
+
context.spanId = createSpanIdentifier();
|
|
91
|
+
inject(makeTracingHeaders(context.traceId, context.spanId, context.traceSampled, session.id, tracingOption.propagatorTypes, userContext, accountContext, configuration));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* When trace is not sampled, set priority to '0' instead of not adding the tracing headers
|
|
95
|
+
* to prepare the implementation for sampling delegation.
|
|
96
|
+
*/
|
|
97
|
+
function makeTracingHeaders(traceId, spanId, traceSampled, sessionId, propagatorTypes, userContext, accountContext, configuration) {
|
|
98
|
+
const tracingHeaders = {};
|
|
99
|
+
propagatorTypes.forEach((propagatorType) => {
|
|
100
|
+
switch (propagatorType) {
|
|
101
|
+
case 'kubesense': {
|
|
102
|
+
Object.assign(tracingHeaders, {
|
|
103
|
+
'x-kubesense-origin': 'rum',
|
|
104
|
+
'x-kubesense-parent-id': spanId.toString(),
|
|
105
|
+
'x-kubesense-sampling-priority': traceSampled ? '1' : '0',
|
|
106
|
+
'x-kubesense-trace-id': traceId.toString(),
|
|
107
|
+
});
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
// https://www.w3.org/TR/trace-context/
|
|
111
|
+
case 'tracecontext': {
|
|
112
|
+
Object.assign(tracingHeaders, {
|
|
113
|
+
traceparent: `00-0000000000000000${toPaddedHexadecimalString(traceId)}-${toPaddedHexadecimalString(spanId)}-0${traceSampled ? '1' : '0'}`,
|
|
114
|
+
tracestate: `dd=s:${traceSampled ? '1' : '0'};o:rum`,
|
|
115
|
+
});
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
// https://github.com/openzipkin/b3-propagation
|
|
119
|
+
case 'b3': {
|
|
120
|
+
Object.assign(tracingHeaders, {
|
|
121
|
+
b3: `${toPaddedHexadecimalString(traceId)}-${toPaddedHexadecimalString(spanId)}-${traceSampled ? '1' : '0'}`,
|
|
122
|
+
});
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case 'b3multi': {
|
|
126
|
+
Object.assign(tracingHeaders, {
|
|
127
|
+
'X-B3-TraceId': toPaddedHexadecimalString(traceId),
|
|
128
|
+
'X-B3-SpanId': toPaddedHexadecimalString(spanId),
|
|
129
|
+
'X-B3-Sampled': traceSampled ? '1' : '0',
|
|
130
|
+
});
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
if (configuration.propagateTraceBaggage) {
|
|
136
|
+
const baggageItems = {
|
|
137
|
+
'session.id': sessionId,
|
|
138
|
+
};
|
|
139
|
+
const userId = userContext.getContext().id;
|
|
140
|
+
if (typeof userId === 'string') {
|
|
141
|
+
baggageItems['user.id'] = userId;
|
|
142
|
+
}
|
|
143
|
+
const accountId = accountContext.getContext().id;
|
|
144
|
+
if (typeof accountId === 'string') {
|
|
145
|
+
baggageItems['account.id'] = accountId;
|
|
146
|
+
}
|
|
147
|
+
const baggageHeader = Object.entries(baggageItems)
|
|
148
|
+
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
|
|
149
|
+
.join(',');
|
|
150
|
+
if (baggageHeader) {
|
|
151
|
+
tracingHeaders['baggage'] = baggageHeader;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return tracingHeaders;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=tracer.js.map
|