@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,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* performance.interactionCount polyfill
|
|
3
|
+
*
|
|
4
|
+
* The interactionCount is an integer which counts the total number of distinct user interactions,
|
|
5
|
+
* for which there was a unique interactionId.
|
|
6
|
+
*
|
|
7
|
+
* The interactionCount polyfill is an estimate based on a convention specific to Chrome. Cf: https://github.com/GoogleChrome/web-vitals/pull/213
|
|
8
|
+
* This is currently not an issue as the polyfill is only used for INP which is currently only supported on Chrome.
|
|
9
|
+
* Hopefully when/if other browsers will support INP, they will also implement performance.interactionCount at the same time, so we won't need that polyfill.
|
|
10
|
+
*
|
|
11
|
+
* Reference implementation: https://github.com/GoogleChrome/web-vitals/blob/main/src/lib/polyfills/interactionCountPolyfill.ts
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { monitor } from '@kubesense/kubesense-browser-core'
|
|
15
|
+
import type {
|
|
16
|
+
BrowserWindow,
|
|
17
|
+
RumPerformanceEventTiming,
|
|
18
|
+
RumPerformanceObserver,
|
|
19
|
+
} from '../../../browser/performanceObservable'
|
|
20
|
+
|
|
21
|
+
let observer: RumPerformanceObserver | undefined
|
|
22
|
+
|
|
23
|
+
let interactionCountEstimate = 0
|
|
24
|
+
let minKnownInteractionId = Infinity
|
|
25
|
+
let maxKnownInteractionId = 0
|
|
26
|
+
|
|
27
|
+
export function initInteractionCountPolyfill() {
|
|
28
|
+
if ('interactionCount' in performance || observer) {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
observer = new (window as BrowserWindow).PerformanceObserver(
|
|
33
|
+
monitor((entries: PerformanceObserverEntryList) => {
|
|
34
|
+
entries.getEntries().forEach((e) => {
|
|
35
|
+
const entry = e as unknown as RumPerformanceEventTiming
|
|
36
|
+
|
|
37
|
+
if (entry.interactionId) {
|
|
38
|
+
minKnownInteractionId = Math.min(minKnownInteractionId, entry.interactionId)
|
|
39
|
+
maxKnownInteractionId = Math.max(maxKnownInteractionId, entry.interactionId)
|
|
40
|
+
|
|
41
|
+
interactionCountEstimate = (maxKnownInteractionId - minKnownInteractionId) / 7 + 1
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
observer.observe({ type: 'event', buffered: true, durationThreshold: 0 })
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns the `interactionCount` value using the native API (if available)
|
|
52
|
+
* or the polyfill estimate in this module.
|
|
53
|
+
*/
|
|
54
|
+
export const getInteractionCount = () =>
|
|
55
|
+
observer ? interactionCountEstimate : (window as BrowserWindow).performance.interactionCount! || 0
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Context, Telemetry } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { addTelemetryMetrics, noop, TelemetryMetrics } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import type { LifeCycle } from '../../lifeCycle'
|
|
4
|
+
import { LifeCycleEventType } from '../../lifeCycle'
|
|
5
|
+
import type { LargestContentfulPaint } from './trackLargestContentfulPaint'
|
|
6
|
+
import type { NavigationTimings } from './trackNavigationTimings'
|
|
7
|
+
|
|
8
|
+
interface CoreInitialViewMetrics extends Context {
|
|
9
|
+
lcp: {
|
|
10
|
+
value: number
|
|
11
|
+
}
|
|
12
|
+
navigation: {
|
|
13
|
+
domComplete: number
|
|
14
|
+
domContentLoaded: number
|
|
15
|
+
domInteractive: number
|
|
16
|
+
firstByte: number | undefined
|
|
17
|
+
loadEvent: number
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function startInitialViewMetricsTelemetry(lifeCycle: LifeCycle, telemetry: Telemetry) {
|
|
22
|
+
if (!telemetry.metricsEnabled) {
|
|
23
|
+
return { stop: noop }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { unsubscribe } = lifeCycle.subscribe(LifeCycleEventType.VIEW_UPDATED, ({ initialViewMetrics }) => {
|
|
27
|
+
if (!initialViewMetrics.largestContentfulPaint || !initialViewMetrics.navigationTimings) {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// The navigation timings become available shortly after the load event fires, so
|
|
32
|
+
// we're snapshotting the LCP value available at that point. However, more LCP values
|
|
33
|
+
// can be emitted until the page is scrolled or interacted with, so it's possible that
|
|
34
|
+
// the final LCP value may differ. These metrics are intended to help diagnose
|
|
35
|
+
// performance issues early in the page load process, and using LCP-at-page-load is a
|
|
36
|
+
// good fit for that use case, but it's important to be aware that this is not
|
|
37
|
+
// necessarily equivalent to the normal LCP metric.
|
|
38
|
+
// monitor-until: 2026-07-01
|
|
39
|
+
addTelemetryMetrics(TelemetryMetrics.INITIAL_VIEW_METRICS_TELEMETRY_NAME, {
|
|
40
|
+
metrics: createCoreInitialViewMetrics(
|
|
41
|
+
initialViewMetrics.largestContentfulPaint,
|
|
42
|
+
initialViewMetrics.navigationTimings
|
|
43
|
+
),
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
unsubscribe()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
stop: unsubscribe,
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function createCoreInitialViewMetrics(
|
|
55
|
+
lcp: LargestContentfulPaint,
|
|
56
|
+
navigation: NavigationTimings
|
|
57
|
+
): CoreInitialViewMetrics {
|
|
58
|
+
return {
|
|
59
|
+
lcp: {
|
|
60
|
+
value: lcp.value,
|
|
61
|
+
},
|
|
62
|
+
navigation: {
|
|
63
|
+
domComplete: navigation.domComplete,
|
|
64
|
+
domContentLoaded: navigation.domContentLoaded,
|
|
65
|
+
domInteractive: navigation.domInteractive,
|
|
66
|
+
firstByte: navigation.firstByte,
|
|
67
|
+
loadEvent: navigation.loadEvent,
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RelativeTime, ClocksState } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import type { InitialViewMetrics } from './trackInitialViewMetrics'
|
|
3
|
+
import { trackRestoredFirstContentfulPaint } from './trackFirstContentfulPaint'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* BFCache keeps a full in-memory snapshot of the DOM. When the page is restored, nothing needs to be fetched, so the whole
|
|
7
|
+
* viewport repaints in a single frame. Consequently, LCP almost always equals FCP.
|
|
8
|
+
* (See: https://github.com/GoogleChrome/web-vitals/pull/87)
|
|
9
|
+
*/
|
|
10
|
+
export function trackBfcacheMetrics(
|
|
11
|
+
viewStart: ClocksState,
|
|
12
|
+
metrics: InitialViewMetrics,
|
|
13
|
+
scheduleViewUpdate: () => void
|
|
14
|
+
) {
|
|
15
|
+
trackRestoredFirstContentfulPaint(viewStart.relative, (paintTime) => {
|
|
16
|
+
metrics.firstContentfulPaint = paintTime
|
|
17
|
+
metrics.largestContentfulPaint = { value: paintTime as RelativeTime }
|
|
18
|
+
scheduleViewUpdate()
|
|
19
|
+
})
|
|
20
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ClocksState, Duration, Observable } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import type { ViewLoadingType } from '../../../rawRumEvent.types'
|
|
3
|
+
import type { RumConfiguration } from '../../configuration'
|
|
4
|
+
import type { LifeCycle } from '../../lifeCycle'
|
|
5
|
+
import type { RumMutationRecord } from '../../../browser/domMutationObservable'
|
|
6
|
+
import type { CumulativeLayoutShift } from './trackCumulativeLayoutShift'
|
|
7
|
+
import { trackCumulativeLayoutShift } from './trackCumulativeLayoutShift'
|
|
8
|
+
import type { InteractionToNextPaint } from './trackInteractionToNextPaint'
|
|
9
|
+
import { trackInteractionToNextPaint } from './trackInteractionToNextPaint'
|
|
10
|
+
import { trackLoadingTime } from './trackLoadingTime'
|
|
11
|
+
import type { ScrollMetrics } from './trackScrollMetrics'
|
|
12
|
+
import { trackScrollMetrics } from './trackScrollMetrics'
|
|
13
|
+
|
|
14
|
+
export interface CommonViewMetrics {
|
|
15
|
+
loadingTime?: Duration
|
|
16
|
+
cumulativeLayoutShift?: CumulativeLayoutShift
|
|
17
|
+
interactionToNextPaint?: InteractionToNextPaint
|
|
18
|
+
scroll?: ScrollMetrics
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function trackCommonViewMetrics(
|
|
22
|
+
lifeCycle: LifeCycle,
|
|
23
|
+
domMutationObservable: Observable<RumMutationRecord[]>,
|
|
24
|
+
windowOpenObservable: Observable<void>,
|
|
25
|
+
configuration: RumConfiguration,
|
|
26
|
+
scheduleViewUpdate: () => void,
|
|
27
|
+
loadingType: ViewLoadingType,
|
|
28
|
+
viewStart: ClocksState
|
|
29
|
+
) {
|
|
30
|
+
const commonViewMetrics: CommonViewMetrics = {}
|
|
31
|
+
|
|
32
|
+
const { stop: stopLoadingTimeTracking, setLoadEvent } = trackLoadingTime(
|
|
33
|
+
lifeCycle,
|
|
34
|
+
domMutationObservable,
|
|
35
|
+
windowOpenObservable,
|
|
36
|
+
configuration,
|
|
37
|
+
loadingType,
|
|
38
|
+
viewStart,
|
|
39
|
+
(newLoadingTime) => {
|
|
40
|
+
commonViewMetrics.loadingTime = newLoadingTime
|
|
41
|
+
scheduleViewUpdate()
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
const { stop: stopScrollMetricsTracking } = trackScrollMetrics(configuration, viewStart, (newScrollMetrics) => {
|
|
46
|
+
commonViewMetrics.scroll = newScrollMetrics
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const { stop: stopCLSTracking } = trackCumulativeLayoutShift(
|
|
50
|
+
configuration,
|
|
51
|
+
viewStart.relative,
|
|
52
|
+
(cumulativeLayoutShift) => {
|
|
53
|
+
commonViewMetrics.cumulativeLayoutShift = cumulativeLayoutShift
|
|
54
|
+
scheduleViewUpdate()
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
const {
|
|
59
|
+
stop: stopINPTracking,
|
|
60
|
+
getInteractionToNextPaint,
|
|
61
|
+
setViewEnd,
|
|
62
|
+
} = trackInteractionToNextPaint(configuration, viewStart.relative, loadingType)
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
stop: () => {
|
|
66
|
+
stopLoadingTimeTracking()
|
|
67
|
+
stopCLSTracking()
|
|
68
|
+
stopScrollMetricsTracking()
|
|
69
|
+
},
|
|
70
|
+
stopINPTracking,
|
|
71
|
+
setLoadEvent,
|
|
72
|
+
setViewEnd,
|
|
73
|
+
getCommonViewMetrics: () => {
|
|
74
|
+
commonViewMetrics.interactionToNextPaint = getInteractionToNextPaint()
|
|
75
|
+
return commonViewMetrics
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { round, ONE_SECOND, noop, elapsed } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import type { Duration, RelativeTime, WeakRef, WeakRefConstructor } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import { isElementNode } from '../../../browser/htmlDomUtils'
|
|
4
|
+
import type { RumLayoutShiftAttribution, RumLayoutShiftTiming } from '../../../browser/performanceObservable'
|
|
5
|
+
import {
|
|
6
|
+
supportPerformanceTimingEvent,
|
|
7
|
+
RumPerformanceEntryType,
|
|
8
|
+
createPerformanceObservable,
|
|
9
|
+
} from '../../../browser/performanceObservable'
|
|
10
|
+
import { getSelectorFromElement } from '../../getSelectorFromElement'
|
|
11
|
+
import type { RumConfiguration } from '../../configuration'
|
|
12
|
+
import type { RumRect } from '../../../rumEvent.types'
|
|
13
|
+
import { getClsAttributionImpactedArea } from './getClsAttributionImpactedArea'
|
|
14
|
+
|
|
15
|
+
declare const WeakRef: WeakRefConstructor
|
|
16
|
+
|
|
17
|
+
export interface CumulativeLayoutShift {
|
|
18
|
+
value: number
|
|
19
|
+
targetSelector?: string
|
|
20
|
+
time?: Duration
|
|
21
|
+
previousRect?: RumRect
|
|
22
|
+
currentRect?: RumRect
|
|
23
|
+
devicePixelRatio?: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface LayoutShiftInstance {
|
|
27
|
+
target: WeakRef<Element> | undefined
|
|
28
|
+
time: Duration
|
|
29
|
+
previousRect: DOMRectReadOnly | undefined
|
|
30
|
+
currentRect: DOMRectReadOnly | undefined
|
|
31
|
+
devicePixelRatio: number
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Track the cumulative layout shifts (CLS).
|
|
36
|
+
* Layout shifts are grouped into session windows.
|
|
37
|
+
* The minimum gap between session windows is 1 second.
|
|
38
|
+
* The maximum duration of a session window is 5 second.
|
|
39
|
+
* The session window layout shift value is the sum of layout shifts inside it.
|
|
40
|
+
* The CLS value is the max of session windows values.
|
|
41
|
+
*
|
|
42
|
+
* This yields a new value whenever the CLS value is updated (a higher session window value is computed).
|
|
43
|
+
*
|
|
44
|
+
* See isLayoutShiftSupported to check for browser support.
|
|
45
|
+
*
|
|
46
|
+
* Documentation:
|
|
47
|
+
* https://web.dev/cls/
|
|
48
|
+
* https://web.dev/evolving-cls/
|
|
49
|
+
* Reference implementation: https://github.com/GoogleChrome/web-vitals/blob/master/src/getCLS.ts
|
|
50
|
+
*/
|
|
51
|
+
export function trackCumulativeLayoutShift(
|
|
52
|
+
configuration: RumConfiguration,
|
|
53
|
+
viewStart: RelativeTime,
|
|
54
|
+
callback: (cumulativeLayoutShift: CumulativeLayoutShift) => void
|
|
55
|
+
) {
|
|
56
|
+
if (!isLayoutShiftSupported()) {
|
|
57
|
+
return {
|
|
58
|
+
stop: noop,
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let maxClsValue = 0
|
|
63
|
+
let biggestShift: LayoutShiftInstance | undefined
|
|
64
|
+
|
|
65
|
+
// if no layout shift happen the value should be reported as 0
|
|
66
|
+
callback({
|
|
67
|
+
value: 0,
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const slidingWindow = slidingSessionWindow()
|
|
71
|
+
const performanceSubscription = createPerformanceObservable(configuration, {
|
|
72
|
+
type: RumPerformanceEntryType.LAYOUT_SHIFT,
|
|
73
|
+
buffered: true,
|
|
74
|
+
}).subscribe((entries) => {
|
|
75
|
+
for (const entry of entries) {
|
|
76
|
+
if (entry.hadRecentInput || entry.startTime < viewStart) {
|
|
77
|
+
continue
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const { cumulatedValue, isMaxValue } = slidingWindow.update(entry)
|
|
81
|
+
|
|
82
|
+
if (isMaxValue) {
|
|
83
|
+
const attribution = getTopImpactedElement(entry.sources)
|
|
84
|
+
biggestShift = {
|
|
85
|
+
target: attribution?.node ? new WeakRef(attribution.node) : undefined,
|
|
86
|
+
time: elapsed(viewStart, entry.startTime),
|
|
87
|
+
previousRect: attribution?.previousRect,
|
|
88
|
+
currentRect: attribution?.currentRect,
|
|
89
|
+
devicePixelRatio: window.devicePixelRatio,
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (cumulatedValue > maxClsValue) {
|
|
94
|
+
maxClsValue = cumulatedValue
|
|
95
|
+
const target = biggestShift?.target?.deref()
|
|
96
|
+
|
|
97
|
+
callback({
|
|
98
|
+
value: round(maxClsValue, 4),
|
|
99
|
+
targetSelector: target && getSelectorFromElement(target, configuration.actionNameAttribute),
|
|
100
|
+
time: biggestShift?.time,
|
|
101
|
+
previousRect: biggestShift?.previousRect ? asRumRect(biggestShift.previousRect) : undefined,
|
|
102
|
+
currentRect: biggestShift?.currentRect ? asRumRect(biggestShift.currentRect) : undefined,
|
|
103
|
+
devicePixelRatio: biggestShift?.devicePixelRatio,
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
stop: () => {
|
|
111
|
+
performanceSubscription.unsubscribe()
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function getTopImpactedElement(
|
|
117
|
+
sources: RumLayoutShiftAttribution[]
|
|
118
|
+
): (RumLayoutShiftAttribution & { node: Element }) | undefined {
|
|
119
|
+
let topImpactedSource: (RumLayoutShiftAttribution & { node: Element }) | undefined
|
|
120
|
+
for (const source of sources) {
|
|
121
|
+
if (source.node && isElementNode(source.node)) {
|
|
122
|
+
const currentImpactedArea = getClsAttributionImpactedArea(source)
|
|
123
|
+
if (!topImpactedSource || getClsAttributionImpactedArea(topImpactedSource) < currentImpactedArea) {
|
|
124
|
+
topImpactedSource = source as RumLayoutShiftAttribution & { node: Element }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return topImpactedSource
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function asRumRect({ x, y, width, height }: DOMRectReadOnly): RumRect {
|
|
132
|
+
return { x, y, width, height }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export const MAX_WINDOW_DURATION = 5 * ONE_SECOND
|
|
136
|
+
const MAX_UPDATE_GAP = ONE_SECOND
|
|
137
|
+
|
|
138
|
+
function slidingSessionWindow() {
|
|
139
|
+
let cumulatedValue = 0
|
|
140
|
+
let startTime: RelativeTime
|
|
141
|
+
let endTime: RelativeTime
|
|
142
|
+
let maxValue = 0
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
update: (entry: RumLayoutShiftTiming) => {
|
|
146
|
+
const shouldCreateNewWindow =
|
|
147
|
+
startTime === undefined ||
|
|
148
|
+
entry.startTime - endTime >= MAX_UPDATE_GAP ||
|
|
149
|
+
entry.startTime - startTime >= MAX_WINDOW_DURATION
|
|
150
|
+
|
|
151
|
+
let isMaxValue: boolean
|
|
152
|
+
|
|
153
|
+
if (shouldCreateNewWindow) {
|
|
154
|
+
startTime = endTime = entry.startTime
|
|
155
|
+
maxValue = cumulatedValue = entry.value
|
|
156
|
+
isMaxValue = true
|
|
157
|
+
} else {
|
|
158
|
+
cumulatedValue += entry.value
|
|
159
|
+
endTime = entry.startTime
|
|
160
|
+
isMaxValue = entry.value > maxValue
|
|
161
|
+
|
|
162
|
+
if (isMaxValue) {
|
|
163
|
+
maxValue = entry.value
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
cumulatedValue,
|
|
169
|
+
isMaxValue,
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Check whether `layout-shift` is supported by the browser.
|
|
177
|
+
*/
|
|
178
|
+
export function isLayoutShiftSupported() {
|
|
179
|
+
return supportPerformanceTimingEvent(RumPerformanceEntryType.LAYOUT_SHIFT) && 'WeakRef' in window
|
|
180
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Duration, RelativeTime } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { ONE_MINUTE, elapsed, relativeNow } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import type { RumPerformancePaintTiming } from '../../../browser/performanceObservable'
|
|
4
|
+
import { createPerformanceObservable, RumPerformanceEntryType } from '../../../browser/performanceObservable'
|
|
5
|
+
import type { RumConfiguration } from '../../configuration'
|
|
6
|
+
import type { FirstHidden } from './trackFirstHidden'
|
|
7
|
+
|
|
8
|
+
// Discard FCP timings above a certain delay to avoid incorrect data
|
|
9
|
+
// It happens in some cases like sleep mode or some browser implementations
|
|
10
|
+
export const FCP_MAXIMUM_DELAY = 10 * ONE_MINUTE
|
|
11
|
+
|
|
12
|
+
export function trackFirstContentfulPaint(
|
|
13
|
+
configuration: RumConfiguration,
|
|
14
|
+
firstHidden: FirstHidden,
|
|
15
|
+
callback: (fcpTiming: RelativeTime) => void
|
|
16
|
+
) {
|
|
17
|
+
const performanceSubscription = createPerformanceObservable(configuration, {
|
|
18
|
+
type: RumPerformanceEntryType.PAINT,
|
|
19
|
+
buffered: true,
|
|
20
|
+
}).subscribe((entries) => {
|
|
21
|
+
const fcpEntry = entries.find(
|
|
22
|
+
(entry): entry is RumPerformancePaintTiming =>
|
|
23
|
+
entry.name === 'first-contentful-paint' &&
|
|
24
|
+
entry.startTime < firstHidden.timeStamp &&
|
|
25
|
+
entry.startTime < FCP_MAXIMUM_DELAY
|
|
26
|
+
)
|
|
27
|
+
if (fcpEntry) {
|
|
28
|
+
callback(fcpEntry.startTime)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
return {
|
|
32
|
+
stop: performanceSubscription.unsubscribe,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Measure the First Contentful Paint after a BFCache restoration.
|
|
38
|
+
* The DOM is restored synchronously, so we approximate the FCP with the first frame
|
|
39
|
+
* rendered just after the pageshow event, using two nested requestAnimationFrame calls.
|
|
40
|
+
*/
|
|
41
|
+
export function trackRestoredFirstContentfulPaint(viewStartRelative: RelativeTime, callback: (fcp: Duration) => void) {
|
|
42
|
+
requestAnimationFrame(() => {
|
|
43
|
+
requestAnimationFrame(() => {
|
|
44
|
+
callback(elapsed(viewStartRelative, relativeNow()))
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ClocksState, RelativeTime } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { addEventListeners, DOM_EVENT, noop } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import type { RumConfiguration } from '../../configuration'
|
|
4
|
+
import { supportPerformanceTimingEvent, RumPerformanceEntryType } from '../../../browser/performanceObservable'
|
|
5
|
+
|
|
6
|
+
export type FirstHidden = ReturnType<typeof trackFirstHidden>
|
|
7
|
+
|
|
8
|
+
export interface Options {
|
|
9
|
+
viewStart: ClocksState
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function trackFirstHidden(
|
|
13
|
+
configuration: RumConfiguration,
|
|
14
|
+
viewStart: ClocksState,
|
|
15
|
+
eventTarget: Window = window
|
|
16
|
+
) {
|
|
17
|
+
if (document.visibilityState === 'hidden') {
|
|
18
|
+
return { timeStamp: 0 as RelativeTime, stop: noop }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (supportPerformanceTimingEvent(RumPerformanceEntryType.VISIBILITY_STATE)) {
|
|
22
|
+
const firstHiddenEntry = performance
|
|
23
|
+
.getEntriesByType(RumPerformanceEntryType.VISIBILITY_STATE)
|
|
24
|
+
.filter((entry) => entry.name === 'hidden')
|
|
25
|
+
.find((entry) => entry.startTime >= viewStart.relative)
|
|
26
|
+
|
|
27
|
+
if (firstHiddenEntry) {
|
|
28
|
+
return { timeStamp: firstHiddenEntry.startTime as RelativeTime, stop: noop }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let timeStamp: RelativeTime = Infinity as RelativeTime
|
|
33
|
+
|
|
34
|
+
const { stop } = addEventListeners(
|
|
35
|
+
configuration,
|
|
36
|
+
eventTarget,
|
|
37
|
+
[DOM_EVENT.PAGE_HIDE, DOM_EVENT.VISIBILITY_CHANGE],
|
|
38
|
+
(event) => {
|
|
39
|
+
if (event.type === DOM_EVENT.PAGE_HIDE || document.visibilityState === 'hidden') {
|
|
40
|
+
timeStamp = event.timeStamp as RelativeTime
|
|
41
|
+
stop()
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{ capture: true }
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
get timeStamp() {
|
|
49
|
+
return timeStamp
|
|
50
|
+
},
|
|
51
|
+
stop,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Duration, RelativeTime } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { elapsed } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import { isElementNode } from '../../../browser/htmlDomUtils'
|
|
4
|
+
import type { RumConfiguration } from '../../configuration'
|
|
5
|
+
import { createPerformanceObservable, RumPerformanceEntryType } from '../../../browser/performanceObservable'
|
|
6
|
+
import type { RumFirstInputTiming } from '../../../browser/performanceObservable'
|
|
7
|
+
import { getSelectorFromElement } from '../../getSelectorFromElement'
|
|
8
|
+
import type { FirstHidden } from './trackFirstHidden'
|
|
9
|
+
|
|
10
|
+
export interface FirstInput {
|
|
11
|
+
delay: Duration
|
|
12
|
+
time: RelativeTime
|
|
13
|
+
targetSelector?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Track the first input occurring during the initial View to return:
|
|
18
|
+
* - First Input Delay
|
|
19
|
+
* - First Input Time
|
|
20
|
+
* Callback is called at most one time.
|
|
21
|
+
* Documentation: https://web.dev/fid/
|
|
22
|
+
* Reference implementation: https://github.com/GoogleChrome/web-vitals/blob/master/src/getFID.ts
|
|
23
|
+
*/
|
|
24
|
+
export function trackFirstInput(
|
|
25
|
+
configuration: RumConfiguration,
|
|
26
|
+
firstHidden: FirstHidden,
|
|
27
|
+
callback: (firstInput: FirstInput) => void
|
|
28
|
+
) {
|
|
29
|
+
const performanceFirstInputSubscription = createPerformanceObservable(configuration, {
|
|
30
|
+
type: RumPerformanceEntryType.FIRST_INPUT,
|
|
31
|
+
buffered: true,
|
|
32
|
+
}).subscribe((entries) => {
|
|
33
|
+
const firstInputEntry = entries.find(
|
|
34
|
+
(entry): entry is RumFirstInputTiming => entry.startTime < firstHidden.timeStamp
|
|
35
|
+
)
|
|
36
|
+
if (firstInputEntry) {
|
|
37
|
+
const firstInputDelay = elapsed(firstInputEntry.startTime, firstInputEntry.processingStart)
|
|
38
|
+
let firstInputTargetSelector
|
|
39
|
+
|
|
40
|
+
if (firstInputEntry.target && isElementNode(firstInputEntry.target)) {
|
|
41
|
+
firstInputTargetSelector = getSelectorFromElement(firstInputEntry.target, configuration.actionNameAttribute)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
callback({
|
|
45
|
+
// Ensure firstInputDelay to be positive, see
|
|
46
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1185815
|
|
47
|
+
delay: firstInputDelay >= 0 ? firstInputDelay : (0 as Duration),
|
|
48
|
+
time: firstInputEntry.startTime,
|
|
49
|
+
targetSelector: firstInputTargetSelector,
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
stop: () => {
|
|
56
|
+
performanceFirstInputSubscription.unsubscribe()
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ClocksState, Duration } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import type { RumConfiguration } from '../../configuration'
|
|
3
|
+
import { trackFirstContentfulPaint } from './trackFirstContentfulPaint'
|
|
4
|
+
import type { FirstInput } from './trackFirstInput'
|
|
5
|
+
import { trackFirstInput } from './trackFirstInput'
|
|
6
|
+
import type { NavigationTimings } from './trackNavigationTimings'
|
|
7
|
+
import { trackNavigationTimings } from './trackNavigationTimings'
|
|
8
|
+
import type { LargestContentfulPaint } from './trackLargestContentfulPaint'
|
|
9
|
+
import { trackLargestContentfulPaint } from './trackLargestContentfulPaint'
|
|
10
|
+
import { trackFirstHidden } from './trackFirstHidden'
|
|
11
|
+
|
|
12
|
+
export interface InitialViewMetrics {
|
|
13
|
+
firstContentfulPaint?: Duration
|
|
14
|
+
navigationTimings?: NavigationTimings
|
|
15
|
+
largestContentfulPaint?: LargestContentfulPaint
|
|
16
|
+
firstInput?: FirstInput
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function trackInitialViewMetrics(
|
|
20
|
+
configuration: RumConfiguration,
|
|
21
|
+
viewStart: ClocksState,
|
|
22
|
+
setLoadEvent: (loadEnd: Duration) => void,
|
|
23
|
+
scheduleViewUpdate: () => void
|
|
24
|
+
) {
|
|
25
|
+
const initialViewMetrics: InitialViewMetrics = {}
|
|
26
|
+
|
|
27
|
+
const { stop: stopNavigationTracking } = trackNavigationTimings(configuration, (navigationTimings) => {
|
|
28
|
+
setLoadEvent(navigationTimings.loadEvent)
|
|
29
|
+
initialViewMetrics.navigationTimings = navigationTimings
|
|
30
|
+
scheduleViewUpdate()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const firstHidden = trackFirstHidden(configuration, viewStart)
|
|
34
|
+
const { stop: stopFCPTracking } = trackFirstContentfulPaint(configuration, firstHidden, (firstContentfulPaint) => {
|
|
35
|
+
initialViewMetrics.firstContentfulPaint = firstContentfulPaint
|
|
36
|
+
scheduleViewUpdate()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const { stop: stopLCPTracking } = trackLargestContentfulPaint(
|
|
40
|
+
configuration,
|
|
41
|
+
firstHidden,
|
|
42
|
+
window,
|
|
43
|
+
(largestContentfulPaint) => {
|
|
44
|
+
initialViewMetrics.largestContentfulPaint = largestContentfulPaint
|
|
45
|
+
scheduleViewUpdate()
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
const { stop: stopFIDTracking } = trackFirstInput(configuration, firstHidden, (firstInput) => {
|
|
50
|
+
initialViewMetrics.firstInput = firstInput
|
|
51
|
+
scheduleViewUpdate()
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
function stop() {
|
|
55
|
+
stopNavigationTracking()
|
|
56
|
+
stopFCPTracking()
|
|
57
|
+
stopLCPTracking()
|
|
58
|
+
stopFIDTracking()
|
|
59
|
+
firstHidden.stop()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
stop,
|
|
64
|
+
initialViewMetrics,
|
|
65
|
+
}
|
|
66
|
+
}
|