@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,90 @@
|
|
|
1
|
+
import type { TimeStamp } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { dateNow, findCommaSeparatedValue, ONE_MINUTE } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import { isCommentNode, isTextNode } from '../../browser/htmlDomUtils'
|
|
4
|
+
|
|
5
|
+
interface DocumentTraceData {
|
|
6
|
+
traceId: string
|
|
7
|
+
traceTime: TimeStamp
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const INITIAL_DOCUMENT_OUTDATED_TRACE_ID_THRESHOLD = 2 * ONE_MINUTE
|
|
11
|
+
|
|
12
|
+
export function getDocumentTraceId(document: Document): string | undefined {
|
|
13
|
+
const data = getDocumentTraceDataFromMeta(document) || getDocumentTraceDataFromComment(document)
|
|
14
|
+
|
|
15
|
+
if (!data || data.traceTime <= dateNow() - INITIAL_DOCUMENT_OUTDATED_TRACE_ID_THRESHOLD) {
|
|
16
|
+
return undefined
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return data.traceId
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getDocumentTraceDataFromMeta(document: Document): DocumentTraceData | undefined {
|
|
23
|
+
const traceIdMeta = document.querySelector<HTMLMetaElement>('meta[name=kubesense-trace-id]')
|
|
24
|
+
const traceTimeMeta = document.querySelector<HTMLMetaElement>('meta[name=kubesense-trace-time]')
|
|
25
|
+
return createDocumentTraceData(traceIdMeta && traceIdMeta.content, traceTimeMeta && traceTimeMeta.content)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getDocumentTraceDataFromComment(document: Document): DocumentTraceData | undefined {
|
|
29
|
+
const comment = findTraceComment(document)
|
|
30
|
+
if (!comment) {
|
|
31
|
+
return undefined
|
|
32
|
+
}
|
|
33
|
+
return createDocumentTraceData(
|
|
34
|
+
findCommaSeparatedValue(comment, 'trace-id'),
|
|
35
|
+
findCommaSeparatedValue(comment, 'trace-time')
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function createDocumentTraceData(
|
|
40
|
+
traceId: string | undefined | null,
|
|
41
|
+
rawTraceTime: string | undefined | null
|
|
42
|
+
): DocumentTraceData | undefined {
|
|
43
|
+
const traceTime = rawTraceTime && (Number(rawTraceTime) as TimeStamp)
|
|
44
|
+
if (!traceId || !traceTime) {
|
|
45
|
+
return undefined
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
traceId,
|
|
50
|
+
traceTime,
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function findTraceComment(document: Document): string | undefined {
|
|
55
|
+
// 1. Try to find the comment as a direct child of the document
|
|
56
|
+
// Note: TSLint advises to use a 'for of', but TS doesn't allow to use 'for of' if the iterated
|
|
57
|
+
// value is not an array or string (here, a NodeList).
|
|
58
|
+
for (let i = 0; i < document.childNodes.length; i += 1) {
|
|
59
|
+
const comment = getTraceCommentFromNode(document.childNodes[i])
|
|
60
|
+
if (comment) {
|
|
61
|
+
return comment
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 2. If the comment is placed after the </html> tag, but have some space or new lines before or
|
|
66
|
+
// after, the DOM parser will lift it (and the surrounding text) at the end of the <body> tag.
|
|
67
|
+
// Try to look for the comment at the end of the <body> by by iterating over its child nodes in
|
|
68
|
+
// reverse order, stopping if we come across a non-text node.
|
|
69
|
+
if (document.body) {
|
|
70
|
+
for (let i = document.body.childNodes.length - 1; i >= 0; i -= 1) {
|
|
71
|
+
const node = document.body.childNodes[i]
|
|
72
|
+
const comment = getTraceCommentFromNode(node)
|
|
73
|
+
if (comment) {
|
|
74
|
+
return comment
|
|
75
|
+
}
|
|
76
|
+
if (!isTextNode(node)) {
|
|
77
|
+
break
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getTraceCommentFromNode(node: Node | null) {
|
|
84
|
+
if (node && isCommentNode(node)) {
|
|
85
|
+
const match = /^\s*KUBESENSE;(.*?)\s*$/.exec(node.data)
|
|
86
|
+
if (match) {
|
|
87
|
+
return match[1]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
interface BaseIdentifier {
|
|
2
|
+
toString(radix?: number): string
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface TraceIdentifier extends BaseIdentifier {
|
|
6
|
+
// We use a brand to distinguish between TraceIdentifier and SpanIdentifier, else TypeScript
|
|
7
|
+
// considers them as the same type
|
|
8
|
+
__brand: 'traceIdentifier'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface SpanIdentifier extends BaseIdentifier {
|
|
12
|
+
__brand: 'spanIdentifier'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createTraceIdentifier() {
|
|
16
|
+
return createIdentifier(64) as TraceIdentifier
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function createSpanIdentifier() {
|
|
20
|
+
return createIdentifier(63) as SpanIdentifier
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function createIdentifier(bits: 63 | 64): BaseIdentifier {
|
|
24
|
+
const buffer = crypto.getRandomValues(new Uint32Array(2))
|
|
25
|
+
if (bits === 63) {
|
|
26
|
+
// eslint-disable-next-line no-bitwise
|
|
27
|
+
buffer[buffer.length - 1] >>>= 1 // force 63-bit
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// The `.toString` function is intentionally similar to Number and BigInt `.toString` method.
|
|
31
|
+
//
|
|
32
|
+
// JavaScript numbers can represent integers up to 48 bits, this is why we need two of them to
|
|
33
|
+
// represent a 64 bits identifier. But BigInts don't have this limitation and can represent larger
|
|
34
|
+
// integer values.
|
|
35
|
+
//
|
|
36
|
+
// In the future, when we drop browsers without BigInts support, we could use BigInts directly
|
|
37
|
+
// represent identifiers by simply returning a BigInt from this function (as all we need is a
|
|
38
|
+
// value with a `.toString` method).
|
|
39
|
+
//
|
|
40
|
+
// Examples:
|
|
41
|
+
// const buffer = getCrypto().getRandomValues(new Uint32Array(2))
|
|
42
|
+
// return BigInt(buffer[0]) + BigInt(buffer[1]) << 32n
|
|
43
|
+
//
|
|
44
|
+
// // Alternative with BigUint64Array (different Browser support than plain bigints!):
|
|
45
|
+
// return crypto.getRandomValues(new BigUint64Array(1))[0]
|
|
46
|
+
//
|
|
47
|
+
// For now, let's keep using two plain numbers as having two different implementations (one for
|
|
48
|
+
// browsers with BigInt support and one for older browsers) don't bring much value.
|
|
49
|
+
return {
|
|
50
|
+
toString(radix = 10) {
|
|
51
|
+
let high = buffer[1]
|
|
52
|
+
let low = buffer[0]
|
|
53
|
+
let str = ''
|
|
54
|
+
|
|
55
|
+
do {
|
|
56
|
+
const mod = (high % radix) * 4294967296 + low
|
|
57
|
+
high = Math.floor(high / radix)
|
|
58
|
+
low = Math.floor(mod / radix)
|
|
59
|
+
str = (mod % radix).toString(radix) + str
|
|
60
|
+
} while (high || low)
|
|
61
|
+
|
|
62
|
+
return str
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function toPaddedHexadecimalString(id: BaseIdentifier) {
|
|
68
|
+
return id.toString(16).padStart(16, '0')
|
|
69
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { performDraw } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
|
|
3
|
+
let sampleDecisionCache: { sessionId: string; decision: boolean } | undefined
|
|
4
|
+
|
|
5
|
+
export function isTraceSampled(sessionId: string, sampleRate: number) {
|
|
6
|
+
// Shortcuts for common cases. This is not strictly necessary, but it makes the code faster for
|
|
7
|
+
// customers willing to ingest all traces.
|
|
8
|
+
if (sampleRate === 100) {
|
|
9
|
+
return true
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (sampleRate === 0) {
|
|
13
|
+
return false
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (sampleDecisionCache && sessionId === sampleDecisionCache.sessionId) {
|
|
17
|
+
return sampleDecisionCache.decision
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let decision: boolean
|
|
21
|
+
// @ts-expect-error BigInt might not be defined in every browser we support
|
|
22
|
+
if (window.BigInt) {
|
|
23
|
+
decision = sampleUsingKnuthFactor(BigInt(`0x${sessionId.split('-')[4]}`), sampleRate)
|
|
24
|
+
} else {
|
|
25
|
+
// For simplicity, we don't use consistent sampling for browser without BigInt support
|
|
26
|
+
// TODO: remove this when all browser we support have BigInt support
|
|
27
|
+
decision = performDraw(sampleRate)
|
|
28
|
+
}
|
|
29
|
+
sampleDecisionCache = { sessionId, decision }
|
|
30
|
+
return decision
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Exported for tests
|
|
34
|
+
export function resetSampleDecisionCache() {
|
|
35
|
+
sampleDecisionCache = undefined
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Perform sampling using the Knuth factor method. This method offer consistent sampling result
|
|
40
|
+
* based on the provided identifier.
|
|
41
|
+
*
|
|
42
|
+
* @param identifier The identifier to use for sampling.
|
|
43
|
+
* @param sampleRate The sample rate in percentage between 0 and 100.
|
|
44
|
+
*/
|
|
45
|
+
export function sampleUsingKnuthFactor(identifier: bigint, sampleRate: number) {
|
|
46
|
+
// The formula is:
|
|
47
|
+
//
|
|
48
|
+
// (identifier * knuthFactor) % 2^64 < sampleRate * 2^64
|
|
49
|
+
//
|
|
50
|
+
// Because JavaScript numbers are 64-bit floats, we can't represent 64-bit integers, and the
|
|
51
|
+
// modulo would be incorrect. Thus, we are using BigInts here.
|
|
52
|
+
//
|
|
53
|
+
// Implementation in other languages:
|
|
54
|
+
// * Go https://github.com/DataDog/kubesense-trace-go/blob/ec6fbb1f2d517b7b8e69961052adf7136f3af773/ddtrace/tracer/sampler.go#L86-L91
|
|
55
|
+
// * Python https://github.com/DataDog/kubesense-trace-py/blob/0cee2f066fb6e79aa15947c1514c0f406dea47c5/ddtrace/sampling_rule.py#L197
|
|
56
|
+
// * Ruby https://github.com/DataDog/kubesense-trace-rb/blob/1a6e255cdcb7e7e22235ea5955f90f6dfa91045d/lib/kubesense/tracing/sampling/rate_sampler.rb#L42
|
|
57
|
+
// * C++ https://github.com/DataDog/kubesense-trace-cpp/blob/159629edc438ae45f2bb318eb7bd51abd05e94b5/src/kubesense/trace_sampler.cpp#L58
|
|
58
|
+
// * Java https://github.com/DataDog/kubesense-trace-java/blob/896dd6b380533216e0bdee59614606c8272d313e/kubesense-trace-core/src/main/java/kubesense/trace/common/sampling/DeterministicSampler.java#L48
|
|
59
|
+
//
|
|
60
|
+
// Note: All implementations have slight variations. Some of them use '<=' instead of '<', and
|
|
61
|
+
// use `sampleRate * 2^64 - 1` instead of `sampleRate * 2^64`. The following implementation
|
|
62
|
+
// should adhere to the spec and is a bit simpler than using a 2^64-1 limit as there are less
|
|
63
|
+
// BigInt arithmetic to write. In practice this does not matter, as we are using floating point
|
|
64
|
+
// numbers in the end, and Number(2n**64n-1n) === Number(2n**64n).
|
|
65
|
+
const knuthFactor = BigInt('1111111111111111111')
|
|
66
|
+
const twoPow64 = BigInt('0x10000000000000000') // 2n ** 64n
|
|
67
|
+
const hash = (identifier * knuthFactor) % twoPow64
|
|
68
|
+
return Number(hash) <= (sampleRate / 100) * Number(twoPow64)
|
|
69
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import type { ContextManager } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import {
|
|
3
|
+
objectEntries,
|
|
4
|
+
shallowClone,
|
|
5
|
+
getType,
|
|
6
|
+
isMatchOption,
|
|
7
|
+
matchList,
|
|
8
|
+
TraceContextInjection,
|
|
9
|
+
} from '@kubesense/kubesense-browser-core'
|
|
10
|
+
import type { RumConfiguration } from '../configuration'
|
|
11
|
+
import type {
|
|
12
|
+
RumFetchResolveContext,
|
|
13
|
+
RumFetchStartContext,
|
|
14
|
+
RumXhrCompleteContext,
|
|
15
|
+
RumXhrStartContext,
|
|
16
|
+
} from '../requestCollection'
|
|
17
|
+
import type { RumSessionManager } from '../rumSessionManager'
|
|
18
|
+
import { isSampled } from '../sampler/sampler'
|
|
19
|
+
import type { PropagatorType, TracingOption } from './tracer.types'
|
|
20
|
+
import type { SpanIdentifier, TraceIdentifier } from './identifier'
|
|
21
|
+
import { createSpanIdentifier, createTraceIdentifier, toPaddedHexadecimalString } from './identifier'
|
|
22
|
+
|
|
23
|
+
export interface Tracer {
|
|
24
|
+
traceFetch: (context: Partial<RumFetchStartContext>) => void
|
|
25
|
+
traceXhr: (context: Partial<RumXhrStartContext>, xhr: XMLHttpRequest) => void
|
|
26
|
+
clearTracingIfNeeded: (context: RumFetchResolveContext | RumXhrCompleteContext) => void
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface TracingHeaders {
|
|
30
|
+
[key: string]: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function isTracingOption(item: unknown): item is TracingOption {
|
|
34
|
+
const expectedItem = item as TracingOption
|
|
35
|
+
return (
|
|
36
|
+
getType(expectedItem) === 'object' &&
|
|
37
|
+
isMatchOption(expectedItem.match) &&
|
|
38
|
+
Array.isArray(expectedItem.propagatorTypes)
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Clear tracing information to avoid incomplete traces. Ideally, we should do it when the
|
|
44
|
+
* request did not reach the server, but the browser does not expose this. So, we clear tracing
|
|
45
|
+
* information if the request ended with status 0 without being aborted by the application.
|
|
46
|
+
*
|
|
47
|
+
* Reasoning:
|
|
48
|
+
*
|
|
49
|
+
* * Applications are usually aborting requests after a bit of time, for example when the user is
|
|
50
|
+
* typing (autocompletion) or navigating away (in a SPA). With a performant device and good
|
|
51
|
+
* network conditions, the request is likely to reach the server before being canceled.
|
|
52
|
+
*
|
|
53
|
+
* * Requests aborted otherwise (ex: lack of internet, CORS issue, blocked by a privacy extension)
|
|
54
|
+
* are likely to finish quickly and without reaching the server.
|
|
55
|
+
*
|
|
56
|
+
* Of course, it might not be the case every time, but it should limit having incomplete traces a
|
|
57
|
+
* bit.
|
|
58
|
+
* */
|
|
59
|
+
export function clearTracingIfNeeded(context: RumFetchResolveContext | RumXhrCompleteContext) {
|
|
60
|
+
if (context.status === 0 && !context.isAborted) {
|
|
61
|
+
context.traceId = undefined
|
|
62
|
+
context.spanId = undefined
|
|
63
|
+
context.traceSampled = undefined
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function startTracer(
|
|
68
|
+
configuration: RumConfiguration,
|
|
69
|
+
sessionManager: RumSessionManager,
|
|
70
|
+
userContext: ContextManager,
|
|
71
|
+
accountContext: ContextManager
|
|
72
|
+
): Tracer {
|
|
73
|
+
return {
|
|
74
|
+
clearTracingIfNeeded,
|
|
75
|
+
traceFetch: (context) =>
|
|
76
|
+
injectHeadersIfTracingAllowed(
|
|
77
|
+
configuration,
|
|
78
|
+
context,
|
|
79
|
+
sessionManager,
|
|
80
|
+
userContext,
|
|
81
|
+
accountContext,
|
|
82
|
+
(tracingHeaders: TracingHeaders) => {
|
|
83
|
+
if (context.input instanceof Request && !context.init?.headers) {
|
|
84
|
+
context.input = new Request(context.input)
|
|
85
|
+
Object.keys(tracingHeaders).forEach((key) => {
|
|
86
|
+
;(context.input as Request).headers.append(key, tracingHeaders[key])
|
|
87
|
+
})
|
|
88
|
+
} else {
|
|
89
|
+
context.init = shallowClone(context.init)
|
|
90
|
+
const headers: Array<[string, string]> = []
|
|
91
|
+
if (context.init.headers instanceof Headers) {
|
|
92
|
+
context.init.headers.forEach((value, key) => {
|
|
93
|
+
headers.push([key, value])
|
|
94
|
+
})
|
|
95
|
+
} else if (Array.isArray(context.init.headers)) {
|
|
96
|
+
context.init.headers.forEach((header) => {
|
|
97
|
+
headers.push(header)
|
|
98
|
+
})
|
|
99
|
+
} else if (context.init.headers) {
|
|
100
|
+
Object.keys(context.init.headers).forEach((key) => {
|
|
101
|
+
headers.push([key, (context.init!.headers as Record<string, string>)[key]])
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
context.init.headers = headers.concat(objectEntries(tracingHeaders))
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
traceXhr: (context, xhr) =>
|
|
109
|
+
injectHeadersIfTracingAllowed(
|
|
110
|
+
configuration,
|
|
111
|
+
context,
|
|
112
|
+
sessionManager,
|
|
113
|
+
userContext,
|
|
114
|
+
accountContext,
|
|
115
|
+
(tracingHeaders: TracingHeaders) => {
|
|
116
|
+
Object.keys(tracingHeaders).forEach((name) => {
|
|
117
|
+
xhr.setRequestHeader(name, tracingHeaders[name])
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function injectHeadersIfTracingAllowed(
|
|
125
|
+
configuration: RumConfiguration,
|
|
126
|
+
context: Partial<RumFetchStartContext | RumXhrStartContext>,
|
|
127
|
+
sessionManager: RumSessionManager,
|
|
128
|
+
userContext: ContextManager,
|
|
129
|
+
accountContext: ContextManager,
|
|
130
|
+
inject: (tracingHeaders: TracingHeaders) => void
|
|
131
|
+
) {
|
|
132
|
+
const session = sessionManager.findTrackedSession()
|
|
133
|
+
if (!session) {
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const tracingOption = configuration.allowedTracingUrls.find((tracingOption) =>
|
|
138
|
+
matchList([tracingOption.match], context.url!, true)
|
|
139
|
+
)
|
|
140
|
+
if (!tracingOption) {
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const traceSampled = isSampled(session.id, configuration.traceSampleRate)
|
|
145
|
+
|
|
146
|
+
const shouldInjectHeaders = traceSampled || configuration.traceContextInjection === TraceContextInjection.ALL
|
|
147
|
+
if (!shouldInjectHeaders) {
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
context.traceSampled = traceSampled
|
|
152
|
+
context.traceId = createTraceIdentifier()
|
|
153
|
+
context.spanId = createSpanIdentifier()
|
|
154
|
+
|
|
155
|
+
inject(
|
|
156
|
+
makeTracingHeaders(
|
|
157
|
+
context.traceId,
|
|
158
|
+
context.spanId,
|
|
159
|
+
context.traceSampled,
|
|
160
|
+
session.id,
|
|
161
|
+
tracingOption.propagatorTypes,
|
|
162
|
+
userContext,
|
|
163
|
+
accountContext,
|
|
164
|
+
configuration
|
|
165
|
+
)
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* When trace is not sampled, set priority to '0' instead of not adding the tracing headers
|
|
171
|
+
* to prepare the implementation for sampling delegation.
|
|
172
|
+
*/
|
|
173
|
+
function makeTracingHeaders(
|
|
174
|
+
traceId: TraceIdentifier,
|
|
175
|
+
spanId: SpanIdentifier,
|
|
176
|
+
traceSampled: boolean,
|
|
177
|
+
sessionId: string,
|
|
178
|
+
propagatorTypes: PropagatorType[],
|
|
179
|
+
userContext: ContextManager,
|
|
180
|
+
accountContext: ContextManager,
|
|
181
|
+
configuration: RumConfiguration
|
|
182
|
+
): TracingHeaders {
|
|
183
|
+
const tracingHeaders: TracingHeaders = {}
|
|
184
|
+
|
|
185
|
+
propagatorTypes.forEach((propagatorType) => {
|
|
186
|
+
switch (propagatorType) {
|
|
187
|
+
case 'kubesense': {
|
|
188
|
+
Object.assign(tracingHeaders, {
|
|
189
|
+
'x-kubesense-origin': 'rum',
|
|
190
|
+
'x-kubesense-parent-id': spanId.toString(),
|
|
191
|
+
'x-kubesense-sampling-priority': traceSampled ? '1' : '0',
|
|
192
|
+
'x-kubesense-trace-id': traceId.toString(),
|
|
193
|
+
})
|
|
194
|
+
break
|
|
195
|
+
}
|
|
196
|
+
// https://www.w3.org/TR/trace-context/
|
|
197
|
+
case 'tracecontext': {
|
|
198
|
+
Object.assign(tracingHeaders, {
|
|
199
|
+
traceparent: `00-0000000000000000${toPaddedHexadecimalString(traceId)}-${toPaddedHexadecimalString(spanId)}-0${
|
|
200
|
+
traceSampled ? '1' : '0'
|
|
201
|
+
}`,
|
|
202
|
+
tracestate: `dd=s:${traceSampled ? '1' : '0'};o:rum`,
|
|
203
|
+
})
|
|
204
|
+
break
|
|
205
|
+
}
|
|
206
|
+
// https://github.com/openzipkin/b3-propagation
|
|
207
|
+
case 'b3': {
|
|
208
|
+
Object.assign(tracingHeaders, {
|
|
209
|
+
b3: `${toPaddedHexadecimalString(traceId)}-${toPaddedHexadecimalString(spanId)}-${traceSampled ? '1' : '0'}`,
|
|
210
|
+
})
|
|
211
|
+
break
|
|
212
|
+
}
|
|
213
|
+
case 'b3multi': {
|
|
214
|
+
Object.assign(tracingHeaders, {
|
|
215
|
+
'X-B3-TraceId': toPaddedHexadecimalString(traceId),
|
|
216
|
+
'X-B3-SpanId': toPaddedHexadecimalString(spanId),
|
|
217
|
+
'X-B3-Sampled': traceSampled ? '1' : '0',
|
|
218
|
+
})
|
|
219
|
+
break
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
if (configuration.propagateTraceBaggage) {
|
|
225
|
+
const baggageItems: Record<string, string> = {
|
|
226
|
+
'session.id': sessionId,
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const userId = userContext.getContext().id
|
|
230
|
+
if (typeof userId === 'string') {
|
|
231
|
+
baggageItems['user.id'] = userId
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const accountId = accountContext.getContext().id
|
|
235
|
+
if (typeof accountId === 'string') {
|
|
236
|
+
baggageItems['account.id'] = accountId
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const baggageHeader = Object.entries(baggageItems)
|
|
240
|
+
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
|
|
241
|
+
.join(',')
|
|
242
|
+
if (baggageHeader) {
|
|
243
|
+
tracingHeaders['baggage'] = baggageHeader
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return tracingHeaders
|
|
248
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MatchOption } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* kubesense: Kubsesense (x-kubesense-*)
|
|
5
|
+
* tracecontext: W3C Trace Context (traceparent, tracestate)
|
|
6
|
+
* b3: B3 Single Header (b3)
|
|
7
|
+
* b3multi: B3 Multiple Headers (X-B3-*)
|
|
8
|
+
*/
|
|
9
|
+
export type PropagatorType = 'kubesense' | 'b3' | 'b3multi' | 'tracecontext'
|
|
10
|
+
export interface TracingOption {
|
|
11
|
+
match: MatchOption
|
|
12
|
+
propagatorTypes: PropagatorType[]
|
|
13
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { noop } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { RumEventType } from '../rawRumEvent.types'
|
|
3
|
+
import type { RumActionEvent, RumErrorEvent, RumLongTaskEvent, RumResourceEvent } from '../rumEvent.types'
|
|
4
|
+
import type { LifeCycle } from './lifeCycle'
|
|
5
|
+
import { LifeCycleEventType } from './lifeCycle'
|
|
6
|
+
|
|
7
|
+
export interface EventCounts {
|
|
8
|
+
errorCount: number
|
|
9
|
+
actionCount: number
|
|
10
|
+
longTaskCount: number
|
|
11
|
+
resourceCount: number
|
|
12
|
+
frustrationCount: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function trackEventCounts({
|
|
16
|
+
lifeCycle,
|
|
17
|
+
isChildEvent,
|
|
18
|
+
onChange: callback = noop,
|
|
19
|
+
}: {
|
|
20
|
+
lifeCycle: LifeCycle
|
|
21
|
+
isChildEvent: (event: RumActionEvent | RumErrorEvent | RumLongTaskEvent | RumResourceEvent) => boolean
|
|
22
|
+
onChange?: () => void
|
|
23
|
+
}) {
|
|
24
|
+
const eventCounts: EventCounts = {
|
|
25
|
+
errorCount: 0,
|
|
26
|
+
longTaskCount: 0,
|
|
27
|
+
resourceCount: 0,
|
|
28
|
+
actionCount: 0,
|
|
29
|
+
frustrationCount: 0,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const subscription = lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, (event): void => {
|
|
33
|
+
if (event.type === 'view' || event.type === 'vital' || !isChildEvent(event)) {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
switch (event.type) {
|
|
37
|
+
case RumEventType.ERROR:
|
|
38
|
+
eventCounts.errorCount += 1
|
|
39
|
+
callback()
|
|
40
|
+
break
|
|
41
|
+
case RumEventType.ACTION:
|
|
42
|
+
eventCounts.actionCount += 1
|
|
43
|
+
if (event.action.frustration) {
|
|
44
|
+
eventCounts.frustrationCount += event.action.frustration.type.length
|
|
45
|
+
}
|
|
46
|
+
callback()
|
|
47
|
+
break
|
|
48
|
+
case RumEventType.LONG_TASK:
|
|
49
|
+
eventCounts.longTaskCount += 1
|
|
50
|
+
callback()
|
|
51
|
+
break
|
|
52
|
+
case RumEventType.RESOURCE:
|
|
53
|
+
if (!event._kubesense?.discarded) {
|
|
54
|
+
eventCounts.resourceCount += 1
|
|
55
|
+
callback()
|
|
56
|
+
}
|
|
57
|
+
break
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
stop: () => {
|
|
63
|
+
subscription.unsubscribe()
|
|
64
|
+
},
|
|
65
|
+
eventCounts,
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Configuration } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { addEventListener, DOM_EVENT } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
|
|
4
|
+
export function onBFCacheRestore(
|
|
5
|
+
configuration: Configuration,
|
|
6
|
+
callback: (event: PageTransitionEvent) => void
|
|
7
|
+
): () => void {
|
|
8
|
+
const { stop } = addEventListener(
|
|
9
|
+
configuration,
|
|
10
|
+
window,
|
|
11
|
+
DOM_EVENT.PAGE_SHOW,
|
|
12
|
+
(event: PageTransitionEvent) => {
|
|
13
|
+
if (event.persisted) {
|
|
14
|
+
callback(event)
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{ capture: true }
|
|
18
|
+
)
|
|
19
|
+
return stop
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LifeCycle } from '../lifeCycle'
|
|
2
|
+
import { trackEventCounts } from '../trackEventCounts'
|
|
3
|
+
|
|
4
|
+
export function trackViewEventCounts(lifeCycle: LifeCycle, viewId: string, onChange: () => void) {
|
|
5
|
+
const { stop, eventCounts } = trackEventCounts({
|
|
6
|
+
lifeCycle,
|
|
7
|
+
isChildEvent: (event) => event.view.id === viewId,
|
|
8
|
+
onChange,
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
stop,
|
|
13
|
+
eventCounts,
|
|
14
|
+
}
|
|
15
|
+
}
|