@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,193 @@
|
|
|
1
|
+
import { elapsed, noop, ONE_MINUTE } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import type { Duration, RelativeTime } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import {
|
|
4
|
+
createPerformanceObservable,
|
|
5
|
+
RumPerformanceEntryType,
|
|
6
|
+
supportPerformanceTimingEvent,
|
|
7
|
+
} from '../../../browser/performanceObservable'
|
|
8
|
+
import type { RumFirstInputTiming, RumPerformanceEventTiming } from '../../../browser/performanceObservable'
|
|
9
|
+
import { ViewLoadingType } from '../../../rawRumEvent.types'
|
|
10
|
+
import { getSelectorFromElement } from '../../getSelectorFromElement'
|
|
11
|
+
import { isElementNode } from '../../../browser/htmlDomUtils'
|
|
12
|
+
import { getInteractionSelector } from '../../action/interactionSelectorCache'
|
|
13
|
+
import type { RumConfiguration } from '../../configuration'
|
|
14
|
+
import { getInteractionCount, initInteractionCountPolyfill } from './interactionCountPolyfill'
|
|
15
|
+
|
|
16
|
+
// Arbitrary value to prevent unnecessary memory usage on views with lots of interactions.
|
|
17
|
+
const MAX_INTERACTION_ENTRIES = 10
|
|
18
|
+
// Arbitrary value to cap INP outliers
|
|
19
|
+
export const MAX_INP_VALUE = (1 * ONE_MINUTE) as Duration
|
|
20
|
+
|
|
21
|
+
export interface InteractionToNextPaint {
|
|
22
|
+
value: Duration
|
|
23
|
+
targetSelector?: string
|
|
24
|
+
time?: Duration
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Track the interaction to next paint (INP).
|
|
28
|
+
* To avoid outliers, return the p98 worst interaction of the view.
|
|
29
|
+
* Documentation: https://web.dev/inp/
|
|
30
|
+
* Reference implementation: https://github.com/GoogleChrome/web-vitals/blob/main/src/onINP.ts
|
|
31
|
+
*/
|
|
32
|
+
export function trackInteractionToNextPaint(
|
|
33
|
+
configuration: RumConfiguration,
|
|
34
|
+
viewStart: RelativeTime,
|
|
35
|
+
viewLoadingType: ViewLoadingType
|
|
36
|
+
) {
|
|
37
|
+
if (!isInteractionToNextPaintSupported()) {
|
|
38
|
+
return {
|
|
39
|
+
getInteractionToNextPaint: () => undefined,
|
|
40
|
+
setViewEnd: noop,
|
|
41
|
+
stop: noop,
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const { getViewInteractionCount, stopViewInteractionCount } = trackViewInteractionCount(viewLoadingType)
|
|
46
|
+
|
|
47
|
+
let viewEnd = Infinity as RelativeTime
|
|
48
|
+
|
|
49
|
+
const longestInteractions = trackLongestInteractions(getViewInteractionCount)
|
|
50
|
+
let interactionToNextPaint = -1 as Duration
|
|
51
|
+
let interactionToNextPaintTargetSelector: string | undefined
|
|
52
|
+
let interactionToNextPaintStartTime: Duration | undefined
|
|
53
|
+
|
|
54
|
+
function handleEntries(entries: Array<RumPerformanceEventTiming | RumFirstInputTiming>) {
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
if (
|
|
57
|
+
entry.interactionId &&
|
|
58
|
+
// Check the entry start time is inside the view bounds because some view interactions can be reported after the view end (if long duration).
|
|
59
|
+
entry.startTime >= viewStart &&
|
|
60
|
+
entry.startTime <= viewEnd
|
|
61
|
+
) {
|
|
62
|
+
longestInteractions.process(entry)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const newInteraction = longestInteractions.estimateP98Interaction()
|
|
67
|
+
if (newInteraction && newInteraction.duration !== interactionToNextPaint) {
|
|
68
|
+
interactionToNextPaint = newInteraction.duration
|
|
69
|
+
interactionToNextPaintStartTime = elapsed(viewStart, newInteraction.startTime)
|
|
70
|
+
interactionToNextPaintTargetSelector = getInteractionSelector(newInteraction.startTime)
|
|
71
|
+
if (!interactionToNextPaintTargetSelector && newInteraction.target && isElementNode(newInteraction.target)) {
|
|
72
|
+
interactionToNextPaintTargetSelector = getSelectorFromElement(
|
|
73
|
+
newInteraction.target,
|
|
74
|
+
configuration.actionNameAttribute
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const firstInputSubscription = createPerformanceObservable(configuration, {
|
|
81
|
+
type: RumPerformanceEntryType.FIRST_INPUT,
|
|
82
|
+
buffered: true,
|
|
83
|
+
}).subscribe(handleEntries)
|
|
84
|
+
|
|
85
|
+
const eventSubscription = createPerformanceObservable(configuration, {
|
|
86
|
+
type: RumPerformanceEntryType.EVENT,
|
|
87
|
+
// durationThreshold only impact PerformanceEventTiming entries used for INP computation which requires a threshold at 40 (default is 104ms)
|
|
88
|
+
// cf: https://github.com/GoogleChrome/web-vitals/blob/3806160ffbc93c3c4abf210a167b81228172b31c/src/onINP.ts#L202-L210
|
|
89
|
+
durationThreshold: 40,
|
|
90
|
+
buffered: true,
|
|
91
|
+
}).subscribe(handleEntries)
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
getInteractionToNextPaint: (): InteractionToNextPaint | undefined => {
|
|
95
|
+
// If no INP duration where captured because of the performanceObserver 40ms threshold
|
|
96
|
+
// but the view interaction count > 0 then report 0
|
|
97
|
+
if (interactionToNextPaint >= 0) {
|
|
98
|
+
return {
|
|
99
|
+
value: Math.min(interactionToNextPaint, MAX_INP_VALUE) as Duration,
|
|
100
|
+
targetSelector: interactionToNextPaintTargetSelector,
|
|
101
|
+
time: interactionToNextPaintStartTime,
|
|
102
|
+
}
|
|
103
|
+
} else if (getViewInteractionCount()) {
|
|
104
|
+
return {
|
|
105
|
+
value: 0 as Duration,
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
setViewEnd: (viewEndTime: RelativeTime) => {
|
|
110
|
+
viewEnd = viewEndTime
|
|
111
|
+
stopViewInteractionCount()
|
|
112
|
+
},
|
|
113
|
+
stop: () => {
|
|
114
|
+
eventSubscription.unsubscribe()
|
|
115
|
+
firstInputSubscription.unsubscribe()
|
|
116
|
+
},
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function trackLongestInteractions(getViewInteractionCount: () => number) {
|
|
121
|
+
const longestInteractions: Array<RumPerformanceEventTiming | RumFirstInputTiming> = []
|
|
122
|
+
|
|
123
|
+
function sortAndTrimLongestInteractions() {
|
|
124
|
+
longestInteractions.sort((a, b) => b.duration - a.duration).splice(MAX_INTERACTION_ENTRIES)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
/**
|
|
129
|
+
* Process the performance entry:
|
|
130
|
+
* - if its duration is long enough, add the performance entry to the list of worst interactions
|
|
131
|
+
* - if an entry with the same interaction id exists and its duration is lower than the new one, then replace it in the list of worst interactions
|
|
132
|
+
*/
|
|
133
|
+
process(entry: RumPerformanceEventTiming | RumFirstInputTiming) {
|
|
134
|
+
const interactionIndex = longestInteractions.findIndex(
|
|
135
|
+
(interaction) => entry.interactionId === interaction.interactionId
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
const minLongestInteraction = longestInteractions[longestInteractions.length - 1]
|
|
139
|
+
|
|
140
|
+
if (interactionIndex !== -1) {
|
|
141
|
+
if (entry.duration > longestInteractions[interactionIndex].duration) {
|
|
142
|
+
longestInteractions[interactionIndex] = entry
|
|
143
|
+
sortAndTrimLongestInteractions()
|
|
144
|
+
}
|
|
145
|
+
} else if (
|
|
146
|
+
longestInteractions.length < MAX_INTERACTION_ENTRIES ||
|
|
147
|
+
entry.duration > minLongestInteraction.duration
|
|
148
|
+
) {
|
|
149
|
+
longestInteractions.push(entry)
|
|
150
|
+
sortAndTrimLongestInteractions()
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* Compute the p98 longest interaction.
|
|
155
|
+
* For better performance the computation is based on 10 longest interactions and the interaction count of the current view.
|
|
156
|
+
*/
|
|
157
|
+
estimateP98Interaction(): RumPerformanceEventTiming | RumFirstInputTiming | undefined {
|
|
158
|
+
const interactionIndex = Math.min(longestInteractions.length - 1, Math.floor(getViewInteractionCount() / 50))
|
|
159
|
+
return longestInteractions[interactionIndex]
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function trackViewInteractionCount(viewLoadingType: ViewLoadingType) {
|
|
165
|
+
initInteractionCountPolyfill()
|
|
166
|
+
const previousInteractionCount = viewLoadingType === ViewLoadingType.INITIAL_LOAD ? 0 : getInteractionCount()
|
|
167
|
+
let state: { stopped: false } | { stopped: true; interactionCount: number } = { stopped: false }
|
|
168
|
+
|
|
169
|
+
function computeViewInteractionCount() {
|
|
170
|
+
return getInteractionCount() - previousInteractionCount
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
getViewInteractionCount: () => {
|
|
175
|
+
if (state.stopped) {
|
|
176
|
+
return state.interactionCount
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return computeViewInteractionCount()
|
|
180
|
+
},
|
|
181
|
+
stopViewInteractionCount: () => {
|
|
182
|
+
state = { stopped: true, interactionCount: computeViewInteractionCount() }
|
|
183
|
+
},
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function isInteractionToNextPaintSupported() {
|
|
188
|
+
return (
|
|
189
|
+
supportPerformanceTimingEvent(RumPerformanceEntryType.EVENT) &&
|
|
190
|
+
window.PerformanceEventTiming &&
|
|
191
|
+
'interactionId' in PerformanceEventTiming.prototype
|
|
192
|
+
)
|
|
193
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { RelativeTime } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { DOM_EVENT, ONE_MINUTE, addEventListeners, findLast } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import type { RumConfiguration } from '../../configuration'
|
|
4
|
+
import { createPerformanceObservable, RumPerformanceEntryType } from '../../../browser/performanceObservable'
|
|
5
|
+
import type { RumLargestContentfulPaintTiming } from '../../../browser/performanceObservable'
|
|
6
|
+
import { getSelectorFromElement } from '../../getSelectorFromElement'
|
|
7
|
+
import type { FirstHidden } from './trackFirstHidden'
|
|
8
|
+
|
|
9
|
+
// Discard LCP timings above a certain delay to avoid incorrect data
|
|
10
|
+
// It happens in some cases like sleep mode or some browser implementations
|
|
11
|
+
export const LCP_MAXIMUM_DELAY = 10 * ONE_MINUTE
|
|
12
|
+
|
|
13
|
+
export interface LargestContentfulPaint {
|
|
14
|
+
value: RelativeTime
|
|
15
|
+
targetSelector?: string
|
|
16
|
+
resourceUrl?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Track the largest contentful paint (LCP) occurring during the initial View. This can yield
|
|
21
|
+
* multiple values, only the most recent one should be used.
|
|
22
|
+
* Documentation: https://web.dev/lcp/
|
|
23
|
+
* Reference implementation: https://github.com/GoogleChrome/web-vitals/blob/master/src/onLCP.ts
|
|
24
|
+
*/
|
|
25
|
+
export function trackLargestContentfulPaint(
|
|
26
|
+
configuration: RumConfiguration,
|
|
27
|
+
firstHidden: FirstHidden,
|
|
28
|
+
eventTarget: Window,
|
|
29
|
+
callback: (largestContentfulPaint: LargestContentfulPaint) => void
|
|
30
|
+
) {
|
|
31
|
+
// Ignore entries that come after the first user interaction. According to the documentation, the
|
|
32
|
+
// browser should not send largest-contentful-paint entries after a user interact with the page,
|
|
33
|
+
// but the web-vitals reference implementation uses this as a safeguard.
|
|
34
|
+
let firstInteractionTimestamp = Infinity
|
|
35
|
+
const { stop: stopEventListener } = addEventListeners(
|
|
36
|
+
configuration,
|
|
37
|
+
eventTarget,
|
|
38
|
+
[DOM_EVENT.POINTER_DOWN, DOM_EVENT.KEY_DOWN],
|
|
39
|
+
(event) => {
|
|
40
|
+
firstInteractionTimestamp = event.timeStamp
|
|
41
|
+
},
|
|
42
|
+
{ capture: true, once: true }
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
let biggestLcpSize = 0
|
|
46
|
+
const performanceLcpSubscription = createPerformanceObservable(configuration, {
|
|
47
|
+
type: RumPerformanceEntryType.LARGEST_CONTENTFUL_PAINT,
|
|
48
|
+
buffered: true,
|
|
49
|
+
}).subscribe((entries) => {
|
|
50
|
+
const lcpEntry = findLast(
|
|
51
|
+
entries,
|
|
52
|
+
(entry): entry is RumLargestContentfulPaintTiming =>
|
|
53
|
+
entry.entryType === RumPerformanceEntryType.LARGEST_CONTENTFUL_PAINT &&
|
|
54
|
+
entry.startTime < firstInteractionTimestamp &&
|
|
55
|
+
entry.startTime < firstHidden.timeStamp &&
|
|
56
|
+
entry.startTime < LCP_MAXIMUM_DELAY &&
|
|
57
|
+
// Ensure to get the LCP entry with the biggest size, see
|
|
58
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1516655
|
|
59
|
+
entry.size > biggestLcpSize
|
|
60
|
+
)
|
|
61
|
+
if (lcpEntry) {
|
|
62
|
+
let lcpTargetSelector
|
|
63
|
+
if (lcpEntry.element) {
|
|
64
|
+
lcpTargetSelector = getSelectorFromElement(lcpEntry.element, configuration.actionNameAttribute)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
callback({
|
|
68
|
+
value: lcpEntry.startTime,
|
|
69
|
+
targetSelector: lcpTargetSelector,
|
|
70
|
+
resourceUrl: computeLcpEntryUrl(lcpEntry),
|
|
71
|
+
})
|
|
72
|
+
biggestLcpSize = lcpEntry.size
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
stop: () => {
|
|
78
|
+
stopEventListener()
|
|
79
|
+
performanceLcpSubscription.unsubscribe()
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// The property url report an empty string if the value is not available, we shouldn't report it in this case.
|
|
85
|
+
function computeLcpEntryUrl(entry: RumLargestContentfulPaintTiming) {
|
|
86
|
+
return entry.url === '' ? undefined : entry.url
|
|
87
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ClocksState, Duration, Observable } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { elapsed } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import { waitPageActivityEnd } from '../../waitPageActivityEnd'
|
|
4
|
+
import type { RumConfiguration } from '../../configuration'
|
|
5
|
+
import type { LifeCycle } from '../../lifeCycle'
|
|
6
|
+
import { ViewLoadingType } from '../../../rawRumEvent.types'
|
|
7
|
+
import type { RumMutationRecord } from '../../../browser/domMutationObservable'
|
|
8
|
+
import { trackFirstHidden } from './trackFirstHidden'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* For non-initial views (such as route changes or BFCache restores), the regular load event does not fire
|
|
12
|
+
* In these cases, trackLoadingTime can only emit a loadingTime if waitPageActivityEnd detects some post-restore activity.
|
|
13
|
+
* If nothing happens after the view starts,no candidate is recorded and loadingTime stays undefined.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export function trackLoadingTime(
|
|
17
|
+
lifeCycle: LifeCycle,
|
|
18
|
+
domMutationObservable: Observable<RumMutationRecord[]>,
|
|
19
|
+
windowOpenObservable: Observable<void>,
|
|
20
|
+
configuration: RumConfiguration,
|
|
21
|
+
loadType: ViewLoadingType,
|
|
22
|
+
viewStart: ClocksState,
|
|
23
|
+
callback: (loadingTime: Duration) => void
|
|
24
|
+
) {
|
|
25
|
+
let isWaitingForLoadEvent = loadType === ViewLoadingType.INITIAL_LOAD
|
|
26
|
+
let isWaitingForActivityLoadingTime = true
|
|
27
|
+
const loadingTimeCandidates: Duration[] = []
|
|
28
|
+
const firstHidden = trackFirstHidden(configuration, viewStart)
|
|
29
|
+
|
|
30
|
+
function invokeCallbackIfAllCandidatesAreReceived() {
|
|
31
|
+
if (!isWaitingForActivityLoadingTime && !isWaitingForLoadEvent && loadingTimeCandidates.length > 0) {
|
|
32
|
+
const loadingTime = Math.max(...loadingTimeCandidates)
|
|
33
|
+
// firstHidden is a relative time from time origin, so we use the relative start time of the view to compare with the loading time
|
|
34
|
+
if (loadingTime < firstHidden.timeStamp - viewStart.relative) {
|
|
35
|
+
callback(loadingTime as Duration)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const { stop } = waitPageActivityEnd(
|
|
41
|
+
lifeCycle,
|
|
42
|
+
domMutationObservable,
|
|
43
|
+
windowOpenObservable,
|
|
44
|
+
configuration,
|
|
45
|
+
(event) => {
|
|
46
|
+
if (isWaitingForActivityLoadingTime) {
|
|
47
|
+
isWaitingForActivityLoadingTime = false
|
|
48
|
+
if (event.hadActivity) {
|
|
49
|
+
loadingTimeCandidates.push(elapsed(viewStart.timeStamp, event.end))
|
|
50
|
+
}
|
|
51
|
+
invokeCallbackIfAllCandidatesAreReceived()
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
stop: () => {
|
|
58
|
+
stop()
|
|
59
|
+
firstHidden.stop()
|
|
60
|
+
},
|
|
61
|
+
setLoadEvent: (loadEvent: Duration) => {
|
|
62
|
+
if (isWaitingForLoadEvent) {
|
|
63
|
+
isWaitingForLoadEvent = false
|
|
64
|
+
loadingTimeCandidates.push(loadEvent)
|
|
65
|
+
invokeCallbackIfAllCandidatesAreReceived()
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Duration, TimeoutId } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { setTimeout, relativeNow, runOnReadyState, clearTimeout } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import type { RumPerformanceNavigationTiming } from '../../../browser/performanceObservable'
|
|
4
|
+
import type { RumConfiguration } from '../../configuration'
|
|
5
|
+
import { getNavigationEntry } from '../../../browser/performanceUtils'
|
|
6
|
+
|
|
7
|
+
export interface NavigationTimings {
|
|
8
|
+
domComplete: Duration
|
|
9
|
+
domContentLoaded: Duration
|
|
10
|
+
domInteractive: Duration
|
|
11
|
+
loadEvent: Duration
|
|
12
|
+
firstByte: Duration | undefined
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// This is a subset of "RumPerformanceNavigationTiming" that only contains the relevant fields for
|
|
16
|
+
// computing navigation timings. This is useful to mock the navigation entry in tests.
|
|
17
|
+
export type RelevantNavigationTiming = Pick<
|
|
18
|
+
RumPerformanceNavigationTiming,
|
|
19
|
+
'domComplete' | 'domContentLoadedEventEnd' | 'domInteractive' | 'loadEventEnd' | 'responseStart'
|
|
20
|
+
>
|
|
21
|
+
|
|
22
|
+
export function trackNavigationTimings(
|
|
23
|
+
configuration: RumConfiguration,
|
|
24
|
+
callback: (timings: NavigationTimings) => void,
|
|
25
|
+
getNavigationEntryImpl: () => RelevantNavigationTiming = getNavigationEntry
|
|
26
|
+
) {
|
|
27
|
+
return waitAfterLoadEvent(configuration, () => {
|
|
28
|
+
const entry = getNavigationEntryImpl()
|
|
29
|
+
|
|
30
|
+
if (!isIncompleteNavigation(entry)) {
|
|
31
|
+
callback(processNavigationEntry(entry))
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function processNavigationEntry(entry: RelevantNavigationTiming): NavigationTimings {
|
|
37
|
+
return {
|
|
38
|
+
domComplete: entry.domComplete,
|
|
39
|
+
domContentLoaded: entry.domContentLoadedEventEnd,
|
|
40
|
+
domInteractive: entry.domInteractive,
|
|
41
|
+
loadEvent: entry.loadEventEnd,
|
|
42
|
+
// In some cases the value reported is negative, zero (meaning unavailable, e.g. cross-origin
|
|
43
|
+
// without Timing-Allow-Origin), or larger than the current page time. Ignore these cases:
|
|
44
|
+
// https://github.com/GoogleChrome/web-vitals/issues/137
|
|
45
|
+
// https://github.com/GoogleChrome/web-vitals/issues/162
|
|
46
|
+
firstByte: entry.responseStart > 0 && entry.responseStart <= relativeNow() ? entry.responseStart : undefined,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function isIncompleteNavigation(entry: RelevantNavigationTiming) {
|
|
51
|
+
return entry.loadEventEnd <= 0
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function waitAfterLoadEvent(configuration: RumConfiguration, callback: () => void) {
|
|
55
|
+
let timeoutId: TimeoutId | undefined
|
|
56
|
+
const { stop: stopOnReadyState } = runOnReadyState(configuration, 'complete', () => {
|
|
57
|
+
// Invoke the callback a bit after the actual load event, so the "loadEventEnd" timing is accurate
|
|
58
|
+
timeoutId = setTimeout(() => callback())
|
|
59
|
+
})
|
|
60
|
+
return {
|
|
61
|
+
stop: () => {
|
|
62
|
+
stopOnReadyState()
|
|
63
|
+
clearTimeout(timeoutId)
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { ClocksState, Duration } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import {
|
|
3
|
+
Observable,
|
|
4
|
+
ONE_SECOND,
|
|
5
|
+
elapsed,
|
|
6
|
+
relativeNow,
|
|
7
|
+
throttle,
|
|
8
|
+
addEventListener,
|
|
9
|
+
DOM_EVENT,
|
|
10
|
+
monitor,
|
|
11
|
+
} from '@kubesense/kubesense-browser-core'
|
|
12
|
+
import type { RumConfiguration } from '../../configuration'
|
|
13
|
+
import { getScrollY } from '../../../browser/scroll'
|
|
14
|
+
import { getViewportDimension } from '../../../browser/viewportObservable'
|
|
15
|
+
|
|
16
|
+
/** Arbitrary scroll throttle duration */
|
|
17
|
+
export const THROTTLE_SCROLL_DURATION = ONE_SECOND
|
|
18
|
+
|
|
19
|
+
export interface ScrollMetrics {
|
|
20
|
+
maxDepth: number
|
|
21
|
+
maxScrollHeight: number
|
|
22
|
+
maxDepthScrollTop: number
|
|
23
|
+
maxScrollHeightTime: Duration
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function trackScrollMetrics(
|
|
27
|
+
configuration: RumConfiguration,
|
|
28
|
+
viewStart: ClocksState,
|
|
29
|
+
callback: (scrollMetrics: ScrollMetrics) => void,
|
|
30
|
+
scrollValues = createScrollValuesObservable(configuration)
|
|
31
|
+
) {
|
|
32
|
+
let maxScrollDepth = 0
|
|
33
|
+
let maxScrollHeight = 0
|
|
34
|
+
let maxScrollHeightTime = 0 as Duration
|
|
35
|
+
|
|
36
|
+
const subscription = scrollValues.subscribe(({ scrollDepth, scrollTop, scrollHeight }) => {
|
|
37
|
+
let shouldUpdate = false
|
|
38
|
+
|
|
39
|
+
if (scrollDepth > maxScrollDepth) {
|
|
40
|
+
maxScrollDepth = scrollDepth
|
|
41
|
+
shouldUpdate = true
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (scrollHeight > maxScrollHeight) {
|
|
45
|
+
maxScrollHeight = scrollHeight
|
|
46
|
+
const now = relativeNow()
|
|
47
|
+
maxScrollHeightTime = elapsed(viewStart.relative, now)
|
|
48
|
+
shouldUpdate = true
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (shouldUpdate) {
|
|
52
|
+
callback({
|
|
53
|
+
maxDepth: Math.min(maxScrollDepth, maxScrollHeight),
|
|
54
|
+
maxDepthScrollTop: scrollTop,
|
|
55
|
+
maxScrollHeight,
|
|
56
|
+
maxScrollHeightTime,
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
stop: () => subscription.unsubscribe(),
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ScrollValues {
|
|
67
|
+
scrollDepth: number
|
|
68
|
+
scrollTop: number
|
|
69
|
+
scrollHeight: number
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function computeScrollValues() {
|
|
73
|
+
const scrollTop = getScrollY()
|
|
74
|
+
|
|
75
|
+
const { height } = getViewportDimension()
|
|
76
|
+
|
|
77
|
+
const scrollHeight = Math.round((document.scrollingElement || document.documentElement).scrollHeight)
|
|
78
|
+
|
|
79
|
+
const scrollDepth = Math.round(height + scrollTop)
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
scrollHeight,
|
|
83
|
+
scrollDepth,
|
|
84
|
+
scrollTop,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function createScrollValuesObservable(
|
|
89
|
+
configuration: RumConfiguration,
|
|
90
|
+
throttleDuration = THROTTLE_SCROLL_DURATION
|
|
91
|
+
): Observable<ScrollValues> {
|
|
92
|
+
return new Observable<ScrollValues>((observable) => {
|
|
93
|
+
function notify() {
|
|
94
|
+
observable.notify(computeScrollValues())
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (window.ResizeObserver) {
|
|
98
|
+
const throttledNotify = throttle(notify, throttleDuration, {
|
|
99
|
+
leading: false,
|
|
100
|
+
trailing: true,
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
const observerTarget = document.scrollingElement || document.documentElement
|
|
104
|
+
const resizeObserver = new ResizeObserver(monitor(throttledNotify.throttled))
|
|
105
|
+
if (observerTarget) {
|
|
106
|
+
resizeObserver.observe(observerTarget)
|
|
107
|
+
}
|
|
108
|
+
const eventListener = addEventListener(configuration, window, DOM_EVENT.SCROLL, throttledNotify.throttled, {
|
|
109
|
+
passive: true,
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
return () => {
|
|
113
|
+
throttledNotify.cancel()
|
|
114
|
+
resizeObserver.disconnect()
|
|
115
|
+
eventListener.stop()
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
}
|