@cloudcare/browser-rum 3.0.29 → 3.1.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/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +3 -2
- package/cjs/boot/buildEnv.js.map +1 -0
- package/cjs/boot/recorderApi.js +5 -25
- package/cjs/boot/recorderApi.js.map +1 -0
- package/cjs/boot/rum.entry.js +2 -7
- package/cjs/boot/rum.entry.js.map +1 -0
- package/cjs/boot/rum.js +40 -43
- package/cjs/boot/rum.js.map +1 -0
- package/cjs/boot/rumPublicApi.js +3 -49
- package/cjs/boot/rumPublicApi.js.map +1 -0
- package/cjs/boot/startRecording.js +2 -9
- package/cjs/boot/startRecording.js.map +1 -0
- package/cjs/constants.js +8 -6
- package/cjs/constants.js.map +1 -0
- package/cjs/domain/assembly.js +8 -20
- package/cjs/domain/assembly.js.map +1 -0
- package/cjs/domain/configuration.js +15 -52
- package/cjs/domain/configuration.js.map +1 -0
- package/cjs/domain/contexts/commonContext.js +2 -2
- package/cjs/domain/contexts/commonContext.js.map +1 -0
- package/cjs/domain/contexts/displayContext.js +28 -0
- package/cjs/domain/contexts/displayContext.js.map +1 -0
- package/cjs/domain/contexts/foregroundContexts.js +4 -29
- package/cjs/domain/contexts/foregroundContexts.js.map +1 -0
- package/cjs/domain/contexts/internalContext.js +5 -4
- package/cjs/domain/contexts/internalContext.js.map +1 -0
- package/cjs/domain/contexts/pageStateHistory.js +106 -0
- package/cjs/domain/contexts/pageStateHistory.js.map +1 -0
- package/cjs/domain/contexts/urlContexts.js +3 -9
- package/cjs/domain/contexts/urlContexts.js.map +1 -0
- package/cjs/domain/contexts/viewContexts.js +2 -6
- package/cjs/domain/contexts/viewContexts.js.map +1 -0
- package/cjs/domain/domMutationCollection.js +6 -10
- package/cjs/domain/domMutationCollection.js.map +1 -0
- package/cjs/domain/initViewportObservable.js +4 -11
- package/cjs/domain/initViewportObservable.js.map +1 -0
- package/cjs/domain/locationChangeObservable.js +2 -11
- package/cjs/domain/locationChangeObservable.js.map +1 -0
- package/cjs/domain/performanceCollection.js +11 -39
- package/cjs/domain/performanceCollection.js.map +1 -0
- package/cjs/domain/replay/record/elementsScrollPositions.js +2 -3
- package/cjs/domain/replay/record/elementsScrollPositions.js.map +1 -0
- package/cjs/domain/replay/record/index.js +2 -4
- package/cjs/domain/replay/record/index.js.map +1 -0
- package/cjs/domain/replay/record/mutationBatch.js +4 -11
- package/cjs/domain/replay/record/mutationBatch.js.map +1 -0
- package/cjs/domain/replay/record/mutationObserver.js +27 -86
- package/cjs/domain/replay/record/mutationObserver.js.map +1 -0
- package/cjs/domain/replay/record/observers.js +15 -89
- package/cjs/domain/replay/record/observers.js.map +1 -0
- package/cjs/domain/replay/record/privacy.js +57 -75
- package/cjs/domain/replay/record/privacy.js.map +1 -0
- package/cjs/domain/replay/record/record.js +6 -29
- package/cjs/domain/replay/record/record.js.map +1 -0
- package/cjs/domain/replay/record/serializationUtils.js +8 -68
- package/cjs/domain/replay/record/serializationUtils.js.map +1 -0
- package/cjs/domain/replay/record/serialize.js +43 -118
- package/cjs/domain/replay/record/serialize.js.map +1 -0
- package/cjs/domain/replay/record/shadowRootsController.js +4 -11
- package/cjs/domain/replay/record/shadowRootsController.js.map +1 -0
- package/cjs/domain/replay/record/utils.js +4 -12
- package/cjs/domain/replay/record/utils.js.map +1 -0
- package/cjs/domain/replay/record/viewports.js +4 -42
- package/cjs/domain/replay/record/viewports.js.map +1 -0
- package/cjs/domain/replay/replayStats.js +2 -14
- package/cjs/domain/replay/replayStats.js.map +1 -0
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js +3 -8
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -0
- package/cjs/domain/replay/segmentCollection/index.js +2 -3
- package/cjs/domain/replay/segmentCollection/index.js.map +1 -0
- package/cjs/domain/replay/segmentCollection/segment.js +7 -23
- package/cjs/domain/replay/segmentCollection/segment.js.map +1 -0
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +5 -24
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -0
- package/cjs/domain/replay/segmentCollection/startDeflateWorker.js +5 -24
- package/cjs/domain/replay/segmentCollection/startDeflateWorker.js.map +1 -0
- package/cjs/domain/requestCollection.js +2 -17
- package/cjs/domain/requestCollection.js.map +1 -0
- package/cjs/domain/rumEventsCollection/actions/actionCollection.js +12 -22
- package/cjs/domain/rumEventsCollection/actions/actionCollection.js.map +1 -0
- package/cjs/domain/rumEventsCollection/actions/clickChain.js +3 -14
- package/cjs/domain/rumEventsCollection/actions/clickChain.js.map +1 -0
- package/cjs/domain/rumEventsCollection/actions/computeFrustration.js +12 -20
- package/cjs/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -0
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js +22 -53
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -0
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +13 -45
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -0
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js +4 -6
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -0
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +15 -45
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -0
- package/cjs/domain/rumEventsCollection/error/errorCollection.js +13 -23
- package/cjs/domain/rumEventsCollection/error/errorCollection.js.map +1 -0
- package/cjs/domain/rumEventsCollection/error/trackConsoleError.js +2 -3
- package/cjs/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -0
- package/cjs/domain/rumEventsCollection/error/trackReportError.js +4 -5
- package/cjs/domain/rumEventsCollection/error/trackReportError.js.map +1 -0
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js +2 -7
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -0
- package/cjs/domain/rumEventsCollection/resource/matchRequestTiming.js +2 -13
- package/cjs/domain/rumEventsCollection/resource/matchRequestTiming.js.map +1 -0
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +2 -18
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -0
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +58 -69
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/interactionCountPolyfill.js +55 -0
- package/cjs/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js +62 -0
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +74 -0
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +26 -0
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js +2 -8
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackFirstInputTimings.js +38 -0
- package/cjs/domain/rumEventsCollection/view/trackFirstInputTimings.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +26 -179
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +120 -0
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +49 -0
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js +39 -0
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js +37 -0
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js +61 -0
- package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js +3 -6
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackViews.js +26 -58
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +43 -48
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -0
- package/cjs/domain/rumSessionManager.js +3 -13
- package/cjs/domain/rumSessionManager.js.map +1 -0
- package/cjs/domain/tracing/ddtraceTracer.js +2 -4
- package/cjs/domain/tracing/ddtraceTracer.js.map +1 -0
- package/cjs/domain/tracing/getDocumentTraceId.js +5 -22
- package/cjs/domain/tracing/getDocumentTraceId.js.map +1 -0
- package/cjs/domain/tracing/jaegerTracer.js +2 -4
- package/cjs/domain/tracing/jaegerTracer.js.map +1 -0
- package/cjs/domain/tracing/skywalkingTracer.js +6 -13
- package/cjs/domain/tracing/skywalkingTracer.js.map +1 -0
- package/cjs/domain/tracing/traceIdentifier.js +2 -7
- package/cjs/domain/tracing/traceIdentifier.js.map +1 -0
- package/cjs/domain/tracing/tracer.js +5 -30
- package/cjs/domain/tracing/tracer.js.map +1 -0
- package/cjs/domain/tracing/w3cTraceParentTracer.js +2 -11
- package/cjs/domain/tracing/w3cTraceParentTracer.js.map +1 -0
- package/cjs/domain/tracing/zipkinMultiTracer.js +4 -6
- package/cjs/domain/tracing/zipkinMultiTracer.js.map +1 -0
- package/cjs/domain/tracing/zipkinSingleTracer.js +2 -4
- package/cjs/domain/tracing/zipkinSingleTracer.js.map +1 -0
- package/cjs/domain/trackEventCounts.js +2 -10
- package/cjs/domain/trackEventCounts.js.map +1 -0
- package/cjs/domain/usr/index.js +2 -7
- package/cjs/domain/usr/index.js.map +1 -0
- package/cjs/domain/waitPageActivityEnd.js +7 -23
- package/cjs/domain/waitPageActivityEnd.js.map +1 -0
- package/cjs/index.js +2 -2
- package/cjs/index.js.map +1 -0
- package/cjs/transport/startRumBatch.js +7 -8
- package/cjs/transport/startRumBatch.js.map +1 -0
- package/cjs/transport/startRumEventBridge.js +2 -3
- package/cjs/transport/startRumEventBridge.js.map +1 -0
- package/cjs/types/index.js +2 -3
- package/cjs/types/index.js.map +1 -0
- package/cjs/types/sessionReplayConstants.js +4 -3
- package/cjs/types/sessionReplayConstants.js.map +1 -0
- package/esm/boot/buildEnv.js +3 -2
- package/esm/boot/buildEnv.js.map +1 -0
- package/esm/boot/recorderApi.js +5 -19
- package/esm/boot/recorderApi.js.map +1 -0
- package/esm/boot/rum.entry.js +2 -1
- package/esm/boot/rum.entry.js.map +1 -0
- package/esm/boot/rum.js +41 -23
- package/esm/boot/rum.js.map +1 -0
- package/esm/boot/rumPublicApi.js +3 -43
- package/esm/boot/rumPublicApi.js.map +1 -0
- package/esm/boot/startRecording.js +2 -4
- package/esm/boot/startRecording.js.map +1 -0
- package/esm/constants.js +8 -4
- package/esm/constants.js.map +1 -0
- package/esm/domain/assembly.js +8 -17
- package/esm/domain/assembly.js.map +1 -0
- package/esm/domain/configuration.js +15 -38
- package/esm/domain/configuration.js.map +1 -0
- package/esm/domain/contexts/commonContext.js +2 -1
- package/esm/domain/contexts/commonContext.js.map +1 -0
- package/esm/domain/contexts/displayContext.js +21 -0
- package/esm/domain/contexts/displayContext.js.map +1 -0
- package/esm/domain/contexts/foregroundContexts.js +6 -25
- package/esm/domain/contexts/foregroundContexts.js.map +1 -0
- package/esm/domain/contexts/internalContext.js +5 -3
- package/esm/domain/contexts/internalContext.js.map +1 -0
- package/esm/domain/contexts/pageStateHistory.js +96 -0
- package/esm/domain/contexts/pageStateHistory.js.map +1 -0
- package/esm/domain/contexts/urlContexts.js +3 -6
- package/esm/domain/contexts/urlContexts.js.map +1 -0
- package/esm/domain/contexts/viewContexts.js +2 -3
- package/esm/domain/contexts/viewContexts.js.map +1 -0
- package/esm/domain/domMutationCollection.js +6 -7
- package/esm/domain/domMutationCollection.js.map +1 -0
- package/esm/domain/initViewportObservable.js +4 -6
- package/esm/domain/initViewportObservable.js.map +1 -0
- package/esm/domain/locationChangeObservable.js +2 -9
- package/esm/domain/locationChangeObservable.js.map +1 -0
- package/esm/domain/performanceCollection.js +11 -35
- package/esm/domain/performanceCollection.js.map +1 -0
- package/esm/domain/replay/record/elementsScrollPositions.js +2 -2
- package/esm/domain/replay/record/elementsScrollPositions.js.map +1 -0
- package/esm/domain/replay/record/index.js +2 -1
- package/esm/domain/replay/record/index.js.map +1 -0
- package/esm/domain/replay/record/mutationBatch.js +5 -9
- package/esm/domain/replay/record/mutationBatch.js.map +1 -0
- package/esm/domain/replay/record/mutationObserver.js +29 -80
- package/esm/domain/replay/record/mutationObserver.js.map +1 -0
- package/esm/domain/replay/record/observers.js +15 -72
- package/esm/domain/replay/record/observers.js.map +1 -0
- package/esm/domain/replay/record/privacy.js +57 -65
- package/esm/domain/replay/record/privacy.js.map +1 -0
- package/esm/domain/replay/record/record.js +6 -19
- package/esm/domain/replay/record/record.js.map +1 -0
- package/esm/domain/replay/record/serializationUtils.js +8 -46
- package/esm/domain/replay/record/serializationUtils.js.map +1 -0
- package/esm/domain/replay/record/serialize.js +45 -107
- package/esm/domain/replay/record/serialize.js.map +1 -0
- package/esm/domain/replay/record/shadowRootsController.js +4 -6
- package/esm/domain/replay/record/shadowRootsController.js.map +1 -0
- package/esm/domain/replay/record/utils.js +4 -6
- package/esm/domain/replay/record/utils.js.map +1 -0
- package/esm/domain/replay/record/viewports.js +3 -32
- package/esm/domain/replay/record/viewports.js.map +1 -0
- package/esm/domain/replay/replayStats.js +2 -8
- package/esm/domain/replay/replayStats.js.map +1 -0
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js +3 -5
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -0
- package/esm/domain/replay/segmentCollection/index.js +2 -1
- package/esm/domain/replay/segmentCollection/index.js.map +1 -0
- package/esm/domain/replay/segmentCollection/segment.js +4 -12
- package/esm/domain/replay/segmentCollection/segment.js.map +1 -0
- package/esm/domain/replay/segmentCollection/segmentCollection.js +4 -13
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -0
- package/esm/domain/replay/segmentCollection/startDeflateWorker.js +5 -16
- package/esm/domain/replay/segmentCollection/startDeflateWorker.js.map +1 -0
- package/esm/domain/requestCollection.js +2 -10
- package/esm/domain/requestCollection.js.map +1 -0
- package/esm/domain/rumEventsCollection/actions/actionCollection.js +12 -19
- package/esm/domain/rumEventsCollection/actions/actionCollection.js.map +1 -0
- package/esm/domain/rumEventsCollection/actions/clickChain.js +3 -10
- package/esm/domain/rumEventsCollection/actions/clickChain.js.map +1 -0
- package/esm/domain/rumEventsCollection/actions/computeFrustration.js +12 -14
- package/esm/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -0
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js +22 -50
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -0
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +12 -40
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -0
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js +4 -4
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -0
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js +18 -37
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -0
- package/esm/domain/rumEventsCollection/error/errorCollection.js +14 -19
- package/esm/domain/rumEventsCollection/error/errorCollection.js.map +1 -0
- package/esm/domain/rumEventsCollection/error/trackConsoleError.js +2 -1
- package/esm/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -0
- package/esm/domain/rumEventsCollection/error/trackReportError.js +4 -3
- package/esm/domain/rumEventsCollection/error/trackReportError.js.map +1 -0
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js +2 -5
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -0
- package/esm/domain/rumEventsCollection/resource/matchRequestTiming.js +3 -11
- package/esm/domain/rumEventsCollection/resource/matchRequestTiming.js.map +1 -0
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +2 -13
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -0
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +58 -57
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/interactionCountPolyfill.js +47 -0
- package/esm/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js +56 -0
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +67 -0
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +18 -0
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js +2 -4
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackFirstInputTimings.js +32 -0
- package/esm/domain/rumEventsCollection/view/trackFirstInputTimings.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +25 -164
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +113 -0
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +41 -0
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js +33 -0
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js +31 -0
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js +53 -0
- package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js +5 -3
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackViews.js +28 -54
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/viewCollection.js +43 -44
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -0
- package/esm/domain/rumSessionManager.js +3 -9
- package/esm/domain/rumSessionManager.js.map +1 -0
- package/esm/domain/tracing/ddtraceTracer.js +2 -2
- package/esm/domain/tracing/ddtraceTracer.js.map +1 -0
- package/esm/domain/tracing/getDocumentTraceId.js +5 -15
- package/esm/domain/tracing/getDocumentTraceId.js.map +1 -0
- package/esm/domain/tracing/jaegerTracer.js +3 -2
- package/esm/domain/tracing/jaegerTracer.js.map +1 -0
- package/esm/domain/tracing/skywalkingTracer.js +8 -12
- package/esm/domain/tracing/skywalkingTracer.js.map +1 -0
- package/esm/domain/tracing/traceIdentifier.js +2 -4
- package/esm/domain/tracing/traceIdentifier.js.map +1 -0
- package/esm/domain/tracing/tracer.js +5 -19
- package/esm/domain/tracing/tracer.js.map +1 -0
- package/esm/domain/tracing/w3cTraceParentTracer.js +4 -8
- package/esm/domain/tracing/w3cTraceParentTracer.js.map +1 -0
- package/esm/domain/tracing/zipkinMultiTracer.js +5 -4
- package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -0
- package/esm/domain/tracing/zipkinSingleTracer.js +3 -2
- package/esm/domain/tracing/zipkinSingleTracer.js.map +1 -0
- package/esm/domain/trackEventCounts.js +2 -8
- package/esm/domain/trackEventCounts.js.map +1 -0
- package/esm/domain/usr/index.js +2 -3
- package/esm/domain/usr/index.js.map +1 -0
- package/esm/domain/waitPageActivityEnd.js +9 -19
- package/esm/domain/waitPageActivityEnd.js.map +1 -0
- package/esm/index.js +2 -1
- package/esm/index.js.map +1 -0
- package/esm/transport/startRumBatch.js +7 -6
- package/esm/transport/startRumBatch.js.map +1 -0
- package/esm/transport/startRumEventBridge.js +2 -1
- package/esm/transport/startRumEventBridge.js.map +1 -0
- package/esm/types/index.js.map +1 -0
- package/esm/types/sessionReplayConstants.js +5 -3
- package/esm/types/sessionReplayConstants.js.map +1 -0
- package/package.json +6 -5
- package/src/boot/rum.js +45 -10
- package/src/domain/assembly.js +5 -2
- package/src/domain/configuration.js +0 -1
- package/src/domain/contexts/displayContext.js +29 -0
- package/src/domain/contexts/internalContext.js +3 -1
- package/src/domain/contexts/pageStateHistory.js +139 -0
- package/src/domain/replay/record/mutationObserver.js +2 -1
- package/src/domain/replay/record/observers.js +3 -3
- package/src/domain/replay/record/privacy.js +20 -23
- package/src/domain/replay/record/record.js +2 -2
- package/src/domain/replay/record/serializationUtils.js +4 -2
- package/src/domain/replay/record/serialize.js +11 -14
- package/src/domain/replay/record/shadowRootsController.js +0 -1
- package/src/domain/replay/record/viewports.js +0 -26
- package/src/domain/rumEventsCollection/actions/actionCollection.js +12 -12
- package/src/domain/rumEventsCollection/actions/trackClickActions.js +8 -6
- package/src/domain/rumEventsCollection/error/errorCollection.js +20 -15
- package/src/domain/rumEventsCollection/error/trackReportError.js +22 -16
- package/src/domain/rumEventsCollection/view/interactionCountPolyfill.js +59 -0
- package/src/domain/rumEventsCollection/view/trackCommonViewMetrics.js +87 -0
- package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +73 -0
- package/src/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +23 -0
- package/src/domain/rumEventsCollection/view/trackFirstInputTimings.js +40 -0
- package/src/domain/rumEventsCollection/view/trackInitialViewTimings.js +29 -199
- package/src/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +144 -0
- package/src/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +57 -0
- package/src/domain/rumEventsCollection/view/trackLoadingTime.js +50 -0
- package/src/domain/rumEventsCollection/view/trackNavigationTimings.js +35 -0
- package/src/domain/rumEventsCollection/view/trackScrollMetrics.js +74 -0
- package/src/domain/rumEventsCollection/view/trackViews.js +32 -37
- package/src/domain/rumEventsCollection/view/viewCollection.js +51 -22
- package/src/transport/startRumBatch.js +5 -1
- package/cjs/domain/rumEventsCollection/view/trackViewMetrics.js +0 -156
- package/esm/domain/rumEventsCollection/view/trackViewMetrics.js +0 -146
- package/src/domain/rumEventsCollection/view/trackViewMetrics.js +0 -176
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { elapsed, find, LifeCycleEventType } from '@cloudcare/browser-core'
|
|
2
|
+
import { trackFirstHidden } from './trackFirstHidden'
|
|
3
|
+
/**
|
|
4
|
+
* Track the first input occurring during the initial View to return:
|
|
5
|
+
* - First Input Delay
|
|
6
|
+
* - First Input Time
|
|
7
|
+
* Callback is called at most one time.
|
|
8
|
+
* Documentation: https://web.dev/fid/
|
|
9
|
+
* Reference implementation: https://github.com/GoogleChrome/web-vitals/blob/master/src/getFID.ts
|
|
10
|
+
*/
|
|
11
|
+
export function trackFirstInputTimings(lifeCycle, callback) {
|
|
12
|
+
var firstHidden = trackFirstHidden()
|
|
13
|
+
var subscribe = lifeCycle.subscribe(
|
|
14
|
+
LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,
|
|
15
|
+
function (entries) {
|
|
16
|
+
var firstInputEntry = find(entries, function (entry) {
|
|
17
|
+
return (
|
|
18
|
+
entry.entryType === 'first-input' &&
|
|
19
|
+
entry.startTime < firstHidden.timeStamp
|
|
20
|
+
)
|
|
21
|
+
})
|
|
22
|
+
if (firstInputEntry) {
|
|
23
|
+
var firstInputDelay = elapsed(
|
|
24
|
+
firstInputEntry.startTime,
|
|
25
|
+
firstInputEntry.processingStart
|
|
26
|
+
)
|
|
27
|
+
callback({
|
|
28
|
+
// Ensure firstInputDelay to be positive, see
|
|
29
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1185815
|
|
30
|
+
firstInputDelay: firstInputDelay >= 0 ? firstInputDelay : 0,
|
|
31
|
+
firstInputTime: firstInputEntry.startTime,
|
|
32
|
+
firstInputTarget: firstInputEntry.target
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
return {
|
|
38
|
+
stop: subscribe.unsubscribe
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,78 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
find,
|
|
7
|
-
findLast,
|
|
8
|
-
LifeCycleEventType,
|
|
9
|
-
ONE_MINUTE,
|
|
10
|
-
setTimeout,
|
|
11
|
-
relativeNow
|
|
12
|
-
} from '@cloudcare/browser-core'
|
|
13
|
-
import { trackFirstHidden } from './trackFirstHidden'
|
|
1
|
+
import { setTimeout, assign, ONE_MINUTE } from '@cloudcare/browser-core'
|
|
2
|
+
import { trackFirstContentfulPaint } from './trackFirstContentfulPaint'
|
|
3
|
+
import { trackFirstInputTimings } from './trackFirstInputTimings'
|
|
4
|
+
import { trackNavigationTimings } from './trackNavigationTimings'
|
|
5
|
+
import { trackLargestContentfulPaint } from './trackLargestContentfulPaint'
|
|
14
6
|
import { getSelectorFromElement } from '../actions/getSelectorsFromElement'
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
/**
|
|
19
|
-
* The initial view can finish quickly, before some metrics can be produced (ex: before the page load
|
|
20
|
-
* event, or the first input). Also, we don't want to trigger a view update indefinitely, to avoid
|
|
21
|
-
* updates on views that ended a long time ago. Keep watching for metrics after the view ends for a
|
|
22
|
-
* limited amount of time.
|
|
23
|
-
*/
|
|
24
|
-
export const KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY = 5 * ONE_MINUTE
|
|
25
|
-
export function trackInitialViewTimings(
|
|
7
|
+
|
|
8
|
+
export var KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY = 5 * ONE_MINUTE
|
|
9
|
+
export function trackInitialViewMetrics(
|
|
26
10
|
lifeCycle,
|
|
27
11
|
setLoadEvent,
|
|
28
12
|
scheduleViewUpdate
|
|
29
13
|
) {
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
timings = extend(timings, newTimings)
|
|
34
|
-
if (timingSelectors) {
|
|
35
|
-
timingsElementSelector = extend(timingsElementSelector, timingSelectors)
|
|
36
|
-
}
|
|
14
|
+
var initialViewMetrics = {}
|
|
15
|
+
function setMetrics(newMetrics) {
|
|
16
|
+
assign(initialViewMetrics, newMetrics)
|
|
37
17
|
scheduleViewUpdate()
|
|
38
18
|
}
|
|
19
|
+
|
|
39
20
|
var _trackNavigationTimings = trackNavigationTimings(
|
|
40
21
|
lifeCycle,
|
|
41
|
-
function (
|
|
42
|
-
setLoadEvent(
|
|
43
|
-
|
|
22
|
+
function (navigationTimings) {
|
|
23
|
+
setLoadEvent(navigationTimings.loadEvent)
|
|
24
|
+
setMetrics(navigationTimings)
|
|
44
25
|
}
|
|
45
26
|
)
|
|
46
27
|
var stopNavigationTracking = _trackNavigationTimings.stop
|
|
47
|
-
|
|
48
|
-
var _trackFirstContentfulPaintTiming = trackFirstContentfulPaintTiming(
|
|
28
|
+
var _trackFirstContentfulPaint = trackFirstContentfulPaint(
|
|
49
29
|
lifeCycle,
|
|
50
30
|
function (firstContentfulPaint) {
|
|
51
|
-
|
|
31
|
+
setMetrics({ firstContentfulPaint: firstContentfulPaint })
|
|
52
32
|
}
|
|
53
33
|
)
|
|
54
|
-
var stopFCPTracking =
|
|
55
|
-
var
|
|
34
|
+
var stopFCPTracking = _trackFirstContentfulPaint.stop
|
|
35
|
+
var _trackLargestContentfulPaint = trackLargestContentfulPaint(
|
|
56
36
|
lifeCycle,
|
|
57
37
|
window,
|
|
58
|
-
function (largestContentfulPaint,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
largestContentfulPaintElement
|
|
62
|
-
?
|
|
63
|
-
largestContentfulPaint: getSelectorFromElement(
|
|
64
|
-
largestContentfulPaintElement
|
|
65
|
-
)
|
|
66
|
-
}
|
|
38
|
+
function (largestContentfulPaint, lcpElement) {
|
|
39
|
+
setMetrics({
|
|
40
|
+
largestContentfulPaint: largestContentfulPaint,
|
|
41
|
+
largestContentfulPaintElement: lcpElement
|
|
42
|
+
? getSelectorFromElement(lcpElement)
|
|
67
43
|
: undefined
|
|
68
|
-
)
|
|
44
|
+
})
|
|
69
45
|
}
|
|
70
46
|
)
|
|
71
|
-
var stopLCPTracking =
|
|
47
|
+
var stopLCPTracking = _trackLargestContentfulPaint.stop
|
|
72
48
|
var _trackFirstInputTimings = trackFirstInputTimings(
|
|
73
49
|
lifeCycle,
|
|
74
50
|
function (firttime) {
|
|
75
|
-
|
|
51
|
+
setMetrics({
|
|
76
52
|
firstInputDelay: firttime.firstInputDelay,
|
|
77
53
|
firstInputTime: firttime.firstInputTime
|
|
78
54
|
})
|
|
@@ -85,158 +61,12 @@ export function trackInitialViewTimings(
|
|
|
85
61
|
stopLCPTracking()
|
|
86
62
|
stopFIDTracking()
|
|
87
63
|
}
|
|
64
|
+
|
|
88
65
|
return {
|
|
89
66
|
stop: stop,
|
|
90
|
-
|
|
91
|
-
timingsElementSelector: timingsElementSelector,
|
|
67
|
+
initialViewMetrics: initialViewMetrics,
|
|
92
68
|
scheduleStop: function () {
|
|
93
69
|
setTimeout(stop, KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY)
|
|
94
70
|
}
|
|
95
71
|
}
|
|
96
72
|
}
|
|
97
|
-
|
|
98
|
-
export function trackNavigationTimings(lifeCycle, callback) {
|
|
99
|
-
var subscribe = lifeCycle.subscribe(
|
|
100
|
-
LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,
|
|
101
|
-
function (entries) {
|
|
102
|
-
for (var i = 0; i < entries.length; i++) {
|
|
103
|
-
var entry = entries[i]
|
|
104
|
-
if (entry.entryType === 'navigation') {
|
|
105
|
-
callback({
|
|
106
|
-
fetchStart: entry.fetchStart,
|
|
107
|
-
responseEnd: entry.responseEnd,
|
|
108
|
-
domComplete: entry.domComplete,
|
|
109
|
-
domContentLoaded: entry.domContentLoadedEventEnd,
|
|
110
|
-
domInteractive: entry.domInteractive,
|
|
111
|
-
loadEvent: entry.loadEventEnd,
|
|
112
|
-
loadEventEnd: entry.loadEventEnd,
|
|
113
|
-
loadEventStart: entry.loadEventStart,
|
|
114
|
-
domContentLoadedEventEnd: entry.domContentLoadedEventEnd,
|
|
115
|
-
domContentLoadedEventStart: entry.domContentLoadedEventStart,
|
|
116
|
-
// In some cases the value reported is negative or is larger
|
|
117
|
-
// than the current page time. Ignore these cases:
|
|
118
|
-
// https://github.com/GoogleChrome/web-vitals/issues/137
|
|
119
|
-
// https://github.com/GoogleChrome/web-vitals/issues/162
|
|
120
|
-
firstByte:
|
|
121
|
-
entry.responseStart >= 0 && entry.responseStart <= relativeNow()
|
|
122
|
-
? entry.responseStart
|
|
123
|
-
: undefined
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
return { stop: subscribe.unsubscribe }
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export function trackFirstContentfulPaintTiming(lifeCycle, callback) {
|
|
134
|
-
var firstHidden = trackFirstHidden()
|
|
135
|
-
var subscribe = lifeCycle.subscribe(
|
|
136
|
-
LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,
|
|
137
|
-
function (entries) {
|
|
138
|
-
var fcpEntry = find(entries, function (entry) {
|
|
139
|
-
return (
|
|
140
|
-
entry.entryType === 'paint' &&
|
|
141
|
-
entry.name === 'first-contentful-paint' &&
|
|
142
|
-
entry.startTime < firstHidden.timeStamp &&
|
|
143
|
-
entry.startTime < TIMING_MAXIMUM_DELAY
|
|
144
|
-
)
|
|
145
|
-
})
|
|
146
|
-
if (fcpEntry) {
|
|
147
|
-
callback(fcpEntry.startTime)
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
)
|
|
151
|
-
return { stop: subscribe.unsubscribe }
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Track the largest contentful paint (LCP) occurring during the initial View. This can yield
|
|
156
|
-
* multiple values, only the most recent one should be used.
|
|
157
|
-
* Documentation: https://web.dev/lcp/
|
|
158
|
-
* Reference implementation: https://github.com/GoogleChrome/web-vitals/blob/master/src/getLCP.ts
|
|
159
|
-
*/
|
|
160
|
-
export function trackLargestContentfulPaintTiming(
|
|
161
|
-
lifeCycle,
|
|
162
|
-
emitter,
|
|
163
|
-
callback
|
|
164
|
-
) {
|
|
165
|
-
var firstHidden = trackFirstHidden()
|
|
166
|
-
|
|
167
|
-
// Ignore entries that come after the first user interaction. According to the documentation, the
|
|
168
|
-
// browser should not send largest-contentful-paint entries after a user interact with the page,
|
|
169
|
-
// but the web-vitals reference implementation uses this as a safeguard.
|
|
170
|
-
var firstInteractionTimestamp = Infinity
|
|
171
|
-
var _addEventListeners = addEventListeners(
|
|
172
|
-
emitter,
|
|
173
|
-
[DOM_EVENT.POINTER_DOWN, DOM_EVENT.KEY_DOWN],
|
|
174
|
-
function (event) {
|
|
175
|
-
firstInteractionTimestamp = event.timeStamp
|
|
176
|
-
},
|
|
177
|
-
{ capture: true, once: true }
|
|
178
|
-
)
|
|
179
|
-
var stopEventListener = _addEventListeners.stop
|
|
180
|
-
var subscribe = lifeCycle.subscribe(
|
|
181
|
-
LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,
|
|
182
|
-
function (entries) {
|
|
183
|
-
var lcpEntry = findLast(entries, function (entry) {
|
|
184
|
-
return (
|
|
185
|
-
entry.entryType === 'largest-contentful-paint' &&
|
|
186
|
-
entry.startTime < firstInteractionTimestamp &&
|
|
187
|
-
entry.startTime < firstHidden.timeStamp &&
|
|
188
|
-
entry.startTime < TIMING_MAXIMUM_DELAY
|
|
189
|
-
)
|
|
190
|
-
})
|
|
191
|
-
if (lcpEntry) {
|
|
192
|
-
callback(lcpEntry.startTime, lcpEntry.element)
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
)
|
|
196
|
-
var unsubscribeLifeCycle = subscribe.unsubscribe
|
|
197
|
-
|
|
198
|
-
return {
|
|
199
|
-
stop: function () {
|
|
200
|
-
stopEventListener()
|
|
201
|
-
unsubscribeLifeCycle()
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Track the first input occurring during the initial View to return:
|
|
208
|
-
* - First Input Delay
|
|
209
|
-
* - First Input Time
|
|
210
|
-
* Callback is called at most one time.
|
|
211
|
-
* Documentation: https://web.dev/fid/
|
|
212
|
-
* Reference implementation: https://github.com/GoogleChrome/web-vitals/blob/master/src/getFID.ts
|
|
213
|
-
*/
|
|
214
|
-
export function trackFirstInputTimings(lifeCycle, callback) {
|
|
215
|
-
var firstHidden = trackFirstHidden()
|
|
216
|
-
var subscribe = lifeCycle.subscribe(
|
|
217
|
-
LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,
|
|
218
|
-
function (entries) {
|
|
219
|
-
var firstInputEntry = find(entries, function (entry) {
|
|
220
|
-
return (
|
|
221
|
-
entry.entryType === 'first-input' &&
|
|
222
|
-
entry.startTime < firstHidden.timeStamp
|
|
223
|
-
)
|
|
224
|
-
})
|
|
225
|
-
if (firstInputEntry) {
|
|
226
|
-
var firstInputDelay = elapsed(
|
|
227
|
-
firstInputEntry.startTime,
|
|
228
|
-
firstInputEntry.processingStart
|
|
229
|
-
)
|
|
230
|
-
callback({
|
|
231
|
-
// Ensure firstInputDelay to be positive, see
|
|
232
|
-
// https://bugs.chromium.org/p/chromium/issues/detail?id=1185815
|
|
233
|
-
firstInputDelay: firstInputDelay >= 0 ? firstInputDelay : 0,
|
|
234
|
-
firstInputTime: firstInputEntry.startTime
|
|
235
|
-
})
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
)
|
|
239
|
-
return {
|
|
240
|
-
stop: subscribe.unsubscribe
|
|
241
|
-
}
|
|
242
|
-
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {
|
|
2
|
+
noop,
|
|
3
|
+
LifeCycleEventType,
|
|
4
|
+
ViewLoadingType
|
|
5
|
+
} from '@cloudcare/browser-core'
|
|
6
|
+
import { supportPerformanceTimingEvent } from '../../performanceCollection'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
getInteractionCount,
|
|
10
|
+
initInteractionCountPolyfill
|
|
11
|
+
} from './interactionCountPolyfill'
|
|
12
|
+
|
|
13
|
+
// Arbitrary value to prevent unnecessary memory usage on views with lots of interactions.
|
|
14
|
+
var MAX_INTERACTION_ENTRIES = 10
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Track the interaction to next paint (INP).
|
|
18
|
+
* To avoid outliers, return the p98 worst interaction of the view.
|
|
19
|
+
* Documentation: https://web.dev/inp/
|
|
20
|
+
* Reference implementation: https://github.com/GoogleChrome/web-vitals/blob/main/src/onINP.ts
|
|
21
|
+
*/
|
|
22
|
+
export function trackInteractionToNextPaint(viewLoadingType, lifeCycle) {
|
|
23
|
+
if (!isInteractionToNextPaintSupported()) {
|
|
24
|
+
return {
|
|
25
|
+
getInteractionToNextPaint: function () {
|
|
26
|
+
return undefined
|
|
27
|
+
},
|
|
28
|
+
stop: noop
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var _trackViewInteractionCount = trackViewInteractionCount(viewLoadingType)
|
|
33
|
+
var getViewInteractionCount =
|
|
34
|
+
_trackViewInteractionCount.getViewInteractionCount
|
|
35
|
+
var longestInteractions = trackLongestInteractions(getViewInteractionCount)
|
|
36
|
+
var inpDuration = -1
|
|
37
|
+
|
|
38
|
+
var subscribe = lifeCycle.subscribe(
|
|
39
|
+
LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,
|
|
40
|
+
function (entries) {
|
|
41
|
+
for (var entry of entries) {
|
|
42
|
+
if (
|
|
43
|
+
(entry.entryType === 'event' || entry.entryType === 'first-input') &&
|
|
44
|
+
entry.interactionId
|
|
45
|
+
) {
|
|
46
|
+
longestInteractions.process(entry)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var newInpDuration = longestInteractions.estimateP98Duration()
|
|
51
|
+
if (newInpDuration) {
|
|
52
|
+
inpDuration = newInpDuration
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
getInteractionToNextPaint: function () {
|
|
59
|
+
// If no INP duration where captured because of the performanceObserver 40ms threshold
|
|
60
|
+
// but the view interaction count > 0 then report 0
|
|
61
|
+
if (inpDuration >= 0) {
|
|
62
|
+
return inpDuration
|
|
63
|
+
} else if (getViewInteractionCount()) {
|
|
64
|
+
return 0
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
stop: subscribe.unsubscribe
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function trackLongestInteractions(getViewInteractionCount) {
|
|
72
|
+
var longestInteractions = []
|
|
73
|
+
|
|
74
|
+
function sortAndTrimLongestInteractions() {
|
|
75
|
+
longestInteractions
|
|
76
|
+
.sort(function (a, b) {
|
|
77
|
+
return b.duration - a.duration
|
|
78
|
+
})
|
|
79
|
+
.splice(MAX_INTERACTION_ENTRIES)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
/**
|
|
84
|
+
* Process the performance entry:
|
|
85
|
+
* - if its duration is long enough, add the performance entry to the list of worst interactions
|
|
86
|
+
* - 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
|
|
87
|
+
*/
|
|
88
|
+
process: function (entry) {
|
|
89
|
+
var interactionIndex = longestInteractions.findIndex(function (
|
|
90
|
+
interaction
|
|
91
|
+
) {
|
|
92
|
+
return entry.interactionId === interaction.interactionId
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
var minLongestInteraction =
|
|
96
|
+
longestInteractions[longestInteractions.length - 1]
|
|
97
|
+
|
|
98
|
+
if (interactionIndex !== -1) {
|
|
99
|
+
if (entry.duration > longestInteractions[interactionIndex].duration) {
|
|
100
|
+
longestInteractions[interactionIndex] = entry
|
|
101
|
+
sortAndTrimLongestInteractions()
|
|
102
|
+
}
|
|
103
|
+
} else if (
|
|
104
|
+
longestInteractions.length < MAX_INTERACTION_ENTRIES ||
|
|
105
|
+
entry.duration > minLongestInteraction.duration
|
|
106
|
+
) {
|
|
107
|
+
longestInteractions.push(entry)
|
|
108
|
+
sortAndTrimLongestInteractions()
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* Compute the p98 longest interaction.
|
|
113
|
+
* For better performance the computation is based on 10 longest interactions and the interaction count of the current view.
|
|
114
|
+
*/
|
|
115
|
+
estimateP98Duration: function () {
|
|
116
|
+
var interactionIndex = Math.min(
|
|
117
|
+
longestInteractions.length - 1,
|
|
118
|
+
Math.floor(getViewInteractionCount() / 50)
|
|
119
|
+
)
|
|
120
|
+
return longestInteractions[interactionIndex]
|
|
121
|
+
? longestInteractions[interactionIndex].duration
|
|
122
|
+
: undefined
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function trackViewInteractionCount(viewLoadingType) {
|
|
128
|
+
initInteractionCountPolyfill()
|
|
129
|
+
var previousInteractionCount =
|
|
130
|
+
viewLoadingType === ViewLoadingType.INITIAL_LOAD ? 0 : getInteractionCount()
|
|
131
|
+
return {
|
|
132
|
+
getViewInteractionCount: function () {
|
|
133
|
+
return getInteractionCount() - previousInteractionCount
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function isInteractionToNextPaintSupported() {
|
|
139
|
+
return (
|
|
140
|
+
supportPerformanceTimingEvent('event') &&
|
|
141
|
+
window.PerformanceEventTiming &&
|
|
142
|
+
'interactionId' in PerformanceEventTiming.prototype
|
|
143
|
+
)
|
|
144
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addEventListeners,
|
|
3
|
+
DOM_EVENT,
|
|
4
|
+
findLast,
|
|
5
|
+
LifeCycleEventType,
|
|
6
|
+
ONE_MINUTE
|
|
7
|
+
} from '@cloudcare/browser-core'
|
|
8
|
+
import { trackFirstHidden } from './trackFirstHidden'
|
|
9
|
+
/**
|
|
10
|
+
* Track the largest contentful paint (LCP) occurring during the initial View. This can yield
|
|
11
|
+
* multiple values, only the most recent one should be used.
|
|
12
|
+
* Documentation: https://web.dev/lcp/
|
|
13
|
+
* Reference implementation: https://github.com/GoogleChrome/web-vitals/blob/master/src/getLCP.ts
|
|
14
|
+
*/
|
|
15
|
+
// It happens in some cases like sleep mode or some browser implementations
|
|
16
|
+
export var LCP_MAXIMUM_DELAY = 10 * ONE_MINUTE
|
|
17
|
+
export function trackLargestContentfulPaint(lifeCycle, eventTarget, callback) {
|
|
18
|
+
var firstHidden = trackFirstHidden()
|
|
19
|
+
|
|
20
|
+
// Ignore entries that come after the first user interaction. According to the documentation, the
|
|
21
|
+
// browser should not send largest-contentful-paint entries after a user interact with the page,
|
|
22
|
+
// but the web-vitals reference implementation uses this as a safeguard.
|
|
23
|
+
var firstInteractionTimestamp = Infinity
|
|
24
|
+
var _addEventListeners = addEventListeners(
|
|
25
|
+
eventTarget,
|
|
26
|
+
[DOM_EVENT.POINTER_DOWN, DOM_EVENT.KEY_DOWN],
|
|
27
|
+
function (event) {
|
|
28
|
+
firstInteractionTimestamp = event.timeStamp
|
|
29
|
+
},
|
|
30
|
+
{ capture: true, once: true }
|
|
31
|
+
)
|
|
32
|
+
var stopEventListener = _addEventListeners.stop
|
|
33
|
+
var subscribe = lifeCycle.subscribe(
|
|
34
|
+
LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,
|
|
35
|
+
function (entries) {
|
|
36
|
+
var lcpEntry = findLast(entries, function (entry) {
|
|
37
|
+
return (
|
|
38
|
+
entry.entryType === 'largest-contentful-paint' &&
|
|
39
|
+
entry.startTime < firstInteractionTimestamp &&
|
|
40
|
+
entry.startTime < firstHidden.timeStamp &&
|
|
41
|
+
entry.startTime < LCP_MAXIMUM_DELAY
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
if (lcpEntry) {
|
|
45
|
+
callback(lcpEntry.startTime, lcpEntry.element)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
var unsubscribeLifeCycle = subscribe.unsubscribe
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
stop: function () {
|
|
53
|
+
stopEventListener()
|
|
54
|
+
unsubscribeLifeCycle()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { elapsed, ViewLoadingType } from '@cloudcare/browser-core'
|
|
2
|
+
import { waitPageActivityEnd } from '../../waitPageActivityEnd'
|
|
3
|
+
export function trackLoadingTime(
|
|
4
|
+
lifeCycle,
|
|
5
|
+
domMutationObservable,
|
|
6
|
+
configuration,
|
|
7
|
+
loadType,
|
|
8
|
+
viewStart,
|
|
9
|
+
callback
|
|
10
|
+
) {
|
|
11
|
+
var isWaitingForLoadEvent = loadType === ViewLoadingType.INITIAL_LOAD
|
|
12
|
+
var isWaitingForActivityLoadingTime = true
|
|
13
|
+
var loadingTimeCandidates = []
|
|
14
|
+
|
|
15
|
+
function invokeCallbackIfAllCandidatesAreReceived() {
|
|
16
|
+
if (
|
|
17
|
+
!isWaitingForActivityLoadingTime &&
|
|
18
|
+
!isWaitingForLoadEvent &&
|
|
19
|
+
loadingTimeCandidates.length > 0
|
|
20
|
+
) {
|
|
21
|
+
callback(Math.max.apply(Math, loadingTimeCandidates))
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var _waitPageActivityEnd = waitPageActivityEnd(
|
|
26
|
+
lifeCycle,
|
|
27
|
+
domMutationObservable,
|
|
28
|
+
configuration,
|
|
29
|
+
function (event) {
|
|
30
|
+
if (isWaitingForActivityLoadingTime) {
|
|
31
|
+
isWaitingForActivityLoadingTime = false
|
|
32
|
+
if (event.hadActivity) {
|
|
33
|
+
loadingTimeCandidates.push(elapsed(viewStart.timeStamp, event.end))
|
|
34
|
+
}
|
|
35
|
+
invokeCallbackIfAllCandidatesAreReceived()
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
var stop = _waitPageActivityEnd.stop
|
|
40
|
+
return {
|
|
41
|
+
setLoadEvent: function (loadEvent) {
|
|
42
|
+
if (isWaitingForLoadEvent) {
|
|
43
|
+
isWaitingForLoadEvent = false
|
|
44
|
+
loadingTimeCandidates.push(loadEvent)
|
|
45
|
+
invokeCallbackIfAllCandidatesAreReceived()
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
stop: stop
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LifeCycleEventType, relativeNow } from '@cloudcare/browser-core'
|
|
2
|
+
export function trackNavigationTimings(lifeCycle, callback) {
|
|
3
|
+
var subscribe = lifeCycle.subscribe(
|
|
4
|
+
LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,
|
|
5
|
+
function (entries) {
|
|
6
|
+
for (var i = 0; i < entries.length; i++) {
|
|
7
|
+
var entry = entries[i]
|
|
8
|
+
if (entry.entryType === 'navigation') {
|
|
9
|
+
callback({
|
|
10
|
+
fetchStart: entry.fetchStart,
|
|
11
|
+
responseEnd: entry.responseEnd,
|
|
12
|
+
domComplete: entry.domComplete,
|
|
13
|
+
domContentLoaded: entry.domContentLoadedEventEnd,
|
|
14
|
+
domInteractive: entry.domInteractive,
|
|
15
|
+
loadEvent: entry.loadEventEnd,
|
|
16
|
+
loadEventEnd: entry.loadEventEnd,
|
|
17
|
+
loadEventStart: entry.loadEventStart,
|
|
18
|
+
domContentLoadedEventEnd: entry.domContentLoadedEventEnd,
|
|
19
|
+
domContentLoadedEventStart: entry.domContentLoadedEventStart,
|
|
20
|
+
// In some cases the value reported is negative or is larger
|
|
21
|
+
// than the current page time. Ignore these cases:
|
|
22
|
+
// https://github.com/GoogleChrome/web-vitals/issues/137
|
|
23
|
+
// https://github.com/GoogleChrome/web-vitals/issues/162
|
|
24
|
+
firstByte:
|
|
25
|
+
entry.responseStart >= 0 && entry.responseStart <= relativeNow()
|
|
26
|
+
? entry.responseStart
|
|
27
|
+
: undefined
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
return { stop: subscribe.unsubscribe }
|
|
35
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ONE_SECOND,
|
|
3
|
+
elapsed,
|
|
4
|
+
relativeNow,
|
|
5
|
+
throttle,
|
|
6
|
+
addEventListener,
|
|
7
|
+
DOM_EVENT,
|
|
8
|
+
getScrollY
|
|
9
|
+
} from '@cloudcare/browser-core'
|
|
10
|
+
import { getViewportDimension } from '../../initViewportObservable'
|
|
11
|
+
|
|
12
|
+
/** Arbitrary scroll throttle duration */
|
|
13
|
+
export var THROTTLE_SCROLL_DURATION = ONE_SECOND
|
|
14
|
+
|
|
15
|
+
export function trackScrollMetrics(viewStart, callback, getScrollValues) {
|
|
16
|
+
if (getScrollValues === undefined) {
|
|
17
|
+
getScrollValues = computeScrollValues
|
|
18
|
+
}
|
|
19
|
+
var maxDepth = 0
|
|
20
|
+
var handleScrollEvent = throttle(
|
|
21
|
+
function () {
|
|
22
|
+
var _scrollValues = getScrollValues()
|
|
23
|
+
var scrollHeight = _scrollValues._scrollValues
|
|
24
|
+
var scrollDepth = _scrollValues.scrollDepth
|
|
25
|
+
var scrollTop = _scrollValues.scrollTop
|
|
26
|
+
if (scrollDepth > maxDepth) {
|
|
27
|
+
var now = relativeNow()
|
|
28
|
+
var maxDepthTime = elapsed(viewStart.relative, now)
|
|
29
|
+
maxDepth = scrollDepth
|
|
30
|
+
callback({
|
|
31
|
+
maxDepth: maxDepth,
|
|
32
|
+
maxDepthScrollHeight: scrollHeight,
|
|
33
|
+
maxDepthTime: maxDepthTime,
|
|
34
|
+
maxDepthScrollTop: scrollTop
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
THROTTLE_SCROLL_DURATION,
|
|
39
|
+
{ leading: false, trailing: true }
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
var _addEventListener = addEventListener(
|
|
43
|
+
window,
|
|
44
|
+
DOM_EVENT.SCROLL,
|
|
45
|
+
handleScrollEvent.throttled,
|
|
46
|
+
{
|
|
47
|
+
passive: true
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
stop: function () {
|
|
53
|
+
handleScrollEvent.cancel()
|
|
54
|
+
_addEventListener.stop()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function computeScrollValues() {
|
|
60
|
+
var scrollTop = getScrollY()
|
|
61
|
+
|
|
62
|
+
var viewport = getViewportDimension()
|
|
63
|
+
var height = viewport.height
|
|
64
|
+
var scrollHeight = Math.round(
|
|
65
|
+
(document.scrollingElement || document.documentElement).scrollHeight
|
|
66
|
+
)
|
|
67
|
+
var scrollDepth = Math.round(height + scrollTop)
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
scrollHeight: scrollHeight,
|
|
71
|
+
scrollDepth: scrollDepth,
|
|
72
|
+
scrollTop: scrollTop
|
|
73
|
+
}
|
|
74
|
+
}
|