@cloudcare/browser-rum 3.0.27 → 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 +40 -87
- 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 +12 -26
- 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 +8 -12
- 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 +13 -42
- 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 +22 -24
- package/cjs/domain/replay/record/mutationBatch.js.map +1 -0
- package/cjs/domain/replay/record/mutationObserver.js +28 -87
- package/cjs/domain/replay/record/mutationObserver.js.map +1 -0
- package/cjs/domain/replay/record/observers.js +16 -90
- package/cjs/domain/replay/record/observers.js.map +1 -0
- package/cjs/domain/replay/record/privacy.js +58 -61
- 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 +65 -52
- package/cjs/domain/replay/record/serializationUtils.js.map +1 -0
- package/cjs/domain/replay/record/serialize.js +47 -189
- 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 +16 -48
- 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 +59 -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 +41 -82
- 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 +12 -23
- 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 +9 -10
- 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 +14 -39
- 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 +22 -21
- package/esm/domain/replay/record/mutationBatch.js.map +1 -0
- package/esm/domain/replay/record/mutationObserver.js +30 -81
- package/esm/domain/replay/record/mutationObserver.js.map +1 -0
- package/esm/domain/replay/record/observers.js +16 -73
- package/esm/domain/replay/record/observers.js.map +1 -0
- package/esm/domain/replay/record/privacy.js +58 -52
- 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 +59 -36
- package/esm/domain/replay/record/serializationUtils.js.map +1 -0
- package/esm/domain/replay/record/serialize.js +46 -175
- 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 +15 -43
- 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 +59 -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/boot/rumPublicApi.js +41 -38
- package/src/domain/assembly.js +9 -8
- 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/domMutationCollection.js +20 -17
- package/src/domain/performanceCollection.js +4 -3
- package/src/domain/replay/record/mutationBatch.js +21 -3
- package/src/domain/replay/record/mutationObserver.js +4 -2
- package/src/domain/replay/record/observers.js +7 -4
- package/src/domain/replay/record/privacy.js +25 -6
- package/src/domain/replay/record/record.js +2 -2
- package/src/domain/replay/record/serializationUtils.js +67 -3
- package/src/domain/replay/record/serialize.js +16 -82
- 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/getSelectorsFromElement.js +4 -4
- 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/resource/resourceUtils.js +4 -1
- 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
|
@@ -5,12 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE = void 0;
|
|
7
7
|
exports.getActionNameFromElement = getActionNameFromElement;
|
|
8
|
-
|
|
9
8
|
var _browserCore = require("@cloudcare/browser-core");
|
|
10
|
-
|
|
11
9
|
var DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE = 'data-guance-action-name';
|
|
12
10
|
exports.DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE = DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE;
|
|
13
|
-
|
|
14
11
|
function getActionNameFromElement(element, userProgrammaticAttribute) {
|
|
15
12
|
// Proceed to get the action name in two steps:
|
|
16
13
|
// * first, get the name programmatically, explicitly defined by the user.
|
|
@@ -20,37 +17,32 @@ function getActionNameFromElement(element, userProgrammaticAttribute) {
|
|
|
20
17
|
// Those are much likely to succeed.
|
|
21
18
|
return getActionNameFromElementProgrammatically(element, DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE) || userProgrammaticAttribute && getActionNameFromElementProgrammatically(element, userProgrammaticAttribute) || getActionNameFromElementForStrategies(element, userProgrammaticAttribute, priorityStrategies) || getActionNameFromElementForStrategies(element, userProgrammaticAttribute, fallbackStrategies) || '';
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
function getActionNameFromElementProgrammatically(targetElement, programmaticAttribute) {
|
|
25
|
-
var elementWithAttribute;
|
|
21
|
+
var elementWithAttribute;
|
|
22
|
+
// We don't use getActionNameFromElementForStrategies here, because we want to consider all parents,
|
|
26
23
|
// without limit. It is up to the user to declare a relevant naming strategy.
|
|
27
24
|
// If available, use element.closest() to match get the attribute from the element or any of its
|
|
28
25
|
// parent. Else fallback to a more traditional implementation.
|
|
29
|
-
|
|
30
26
|
if (supportsElementClosest()) {
|
|
31
27
|
elementWithAttribute = targetElement.closest('[' + programmaticAttribute + ']');
|
|
32
28
|
} else {
|
|
33
29
|
var element = targetElement;
|
|
34
|
-
|
|
35
30
|
while (element) {
|
|
36
31
|
if (element.hasAttribute(programmaticAttribute)) {
|
|
37
32
|
elementWithAttribute = element;
|
|
38
33
|
break;
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
element = element.parentElement;
|
|
42
36
|
}
|
|
43
37
|
}
|
|
44
|
-
|
|
45
38
|
if (!elementWithAttribute) {
|
|
46
39
|
return;
|
|
47
40
|
}
|
|
48
|
-
|
|
49
41
|
var name = elementWithAttribute.getAttribute(programmaticAttribute);
|
|
50
42
|
return truncate(normalizeWhitespace(name.trim()));
|
|
51
43
|
}
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
var priorityStrategies = [
|
|
45
|
+
// associated LABEL text
|
|
54
46
|
function (element, userProgrammaticAttribute) {
|
|
55
47
|
// IE does not support element.labels, so we fallback to a CSS selector based on the element id
|
|
56
48
|
// instead
|
|
@@ -64,27 +56,28 @@ function (element, userProgrammaticAttribute) {
|
|
|
64
56
|
});
|
|
65
57
|
return label && getTextualContent(label, userProgrammaticAttribute);
|
|
66
58
|
}
|
|
67
|
-
},
|
|
59
|
+
},
|
|
60
|
+
// INPUT button (and associated) value
|
|
68
61
|
function (element) {
|
|
69
62
|
if (element.nodeName === 'INPUT') {
|
|
70
63
|
var input = element;
|
|
71
64
|
var type = input.getAttribute('type');
|
|
72
|
-
|
|
73
65
|
if (type === 'button' || type === 'submit' || type === 'reset') {
|
|
74
66
|
return input.value;
|
|
75
67
|
}
|
|
76
68
|
}
|
|
77
|
-
},
|
|
69
|
+
},
|
|
70
|
+
// BUTTON, LABEL or button-like element text
|
|
78
71
|
function (element, userProgrammaticAttribute) {
|
|
79
72
|
if (element.nodeName === 'BUTTON' || element.nodeName === 'LABEL' || element.getAttribute('role') === 'button') {
|
|
80
73
|
return getTextualContent(element, userProgrammaticAttribute);
|
|
81
74
|
}
|
|
82
75
|
}, function (element) {
|
|
83
76
|
return element.getAttribute('aria-label');
|
|
84
|
-
},
|
|
77
|
+
},
|
|
78
|
+
// associated element text designated by the aria-labelledby attribute
|
|
85
79
|
function (element, userProgrammaticAttribute) {
|
|
86
80
|
var labelledByAttribute = element.getAttribute('aria-labelledby');
|
|
87
|
-
|
|
88
81
|
if (labelledByAttribute) {
|
|
89
82
|
labelledByAttribute = labelledByAttribute.split(/\s+/);
|
|
90
83
|
labelledByAttribute = (0, _browserCore.map)(labelledByAttribute, function (id) {
|
|
@@ -106,7 +99,8 @@ function (element, userProgrammaticAttribute) {
|
|
|
106
99
|
return element.getAttribute('title');
|
|
107
100
|
}, function (element) {
|
|
108
101
|
return element.getAttribute('placeholder');
|
|
109
|
-
},
|
|
102
|
+
},
|
|
103
|
+
// SELECT first OPTION text
|
|
110
104
|
function (element, userProgrammaticAttribute) {
|
|
111
105
|
if ('options' in element && element.options.length > 0) {
|
|
112
106
|
return getTextualContent(element.options[0], userProgrammaticAttribute);
|
|
@@ -115,98 +109,80 @@ function (element, userProgrammaticAttribute) {
|
|
|
115
109
|
var fallbackStrategies = [function (element, userProgrammaticAttribute) {
|
|
116
110
|
return getTextualContent(element, userProgrammaticAttribute);
|
|
117
111
|
}];
|
|
112
|
+
|
|
118
113
|
/**
|
|
119
114
|
* Iterates over the target element and its parent, using the strategies list to get an action name.
|
|
120
115
|
* Each strategies are applied on each element, stopping as soon as a non-empty value is returned.
|
|
121
116
|
*/
|
|
122
|
-
|
|
123
117
|
var MAX_PARENTS_TO_CONSIDER = 10;
|
|
124
|
-
|
|
125
118
|
function getActionNameFromElementForStrategies(targetElement, userProgrammaticAttribute, strategies) {
|
|
126
119
|
var element = targetElement;
|
|
127
120
|
var recursionCounter = 0;
|
|
128
|
-
|
|
129
121
|
while (recursionCounter <= MAX_PARENTS_TO_CONSIDER && element && element.nodeName !== 'BODY' && element.nodeName !== 'HTML' && element.nodeName !== 'HEAD') {
|
|
130
122
|
for (var i = 0; i < strategies.length; i++) {
|
|
131
123
|
var strategy = strategies[i];
|
|
132
124
|
var name = strategy(element, userProgrammaticAttribute);
|
|
133
|
-
|
|
134
125
|
if (typeof name === 'string') {
|
|
135
126
|
var trimmedName = name.trim();
|
|
136
|
-
|
|
137
127
|
if (trimmedName) {
|
|
138
128
|
return truncate(normalizeWhitespace(trimmedName));
|
|
139
129
|
}
|
|
140
130
|
}
|
|
141
|
-
}
|
|
131
|
+
}
|
|
132
|
+
// Consider a FORM as a contextual limit to get the action name. This is experimental and may
|
|
142
133
|
// be reconsidered in the future.
|
|
143
|
-
|
|
144
|
-
|
|
145
134
|
if (element.nodeName === 'FORM') {
|
|
146
135
|
break;
|
|
147
136
|
}
|
|
148
|
-
|
|
149
137
|
element = element.parentElement;
|
|
150
138
|
recursionCounter += 1;
|
|
151
139
|
}
|
|
152
140
|
}
|
|
153
|
-
|
|
154
141
|
function normalizeWhitespace(s) {
|
|
155
142
|
return s.replace(/\s+/g, ' ');
|
|
156
143
|
}
|
|
157
|
-
|
|
158
144
|
function truncate(s) {
|
|
159
145
|
return s.length > 100 ? (0, _browserCore.safeTruncate)(s, 100) + ' [...]' : s;
|
|
160
146
|
}
|
|
161
|
-
|
|
162
147
|
function getElementById(refElement, id) {
|
|
163
148
|
// Use the element ownerDocument here, because tests are executed in an iframe, so
|
|
164
149
|
// document.getElementById won't work.
|
|
165
150
|
return refElement.ownerDocument ? refElement.ownerDocument.getElementById(id) : null;
|
|
166
151
|
}
|
|
167
|
-
|
|
168
152
|
function getTextualContent(element, userProgrammaticAttribute) {
|
|
169
153
|
if (element.isContentEditable) {
|
|
170
154
|
return;
|
|
171
155
|
}
|
|
172
|
-
|
|
173
156
|
if ('innerText' in element) {
|
|
174
157
|
var text = element.innerText;
|
|
175
|
-
|
|
176
158
|
var removeTextFromElements = function removeTextFromElements(query) {
|
|
177
159
|
var list = element.querySelectorAll(query);
|
|
178
|
-
|
|
179
160
|
for (var index = 0; index < list.length; index += 1) {
|
|
180
161
|
var _element = list[index];
|
|
181
|
-
|
|
182
162
|
if ('innerText' in _element) {
|
|
183
163
|
var textToReplace = _element.innerText;
|
|
184
|
-
|
|
185
164
|
if (textToReplace && textToReplace.trim().length > 0) {
|
|
186
165
|
text = text.replace(textToReplace, '');
|
|
187
166
|
}
|
|
188
167
|
}
|
|
189
168
|
}
|
|
190
169
|
};
|
|
191
|
-
|
|
192
170
|
if (!supportsInnerTextScriptAndStyleRemoval()) {
|
|
193
171
|
// remove the inner text of SCRIPT and STYLES from the result. This is a bit dirty, but should
|
|
194
172
|
// be relatively fast and work in most cases.
|
|
195
173
|
removeTextFromElements('script, style');
|
|
196
|
-
}
|
|
197
|
-
|
|
174
|
+
}
|
|
198
175
|
|
|
176
|
+
// remove the text of elements with programmatic attribute value
|
|
199
177
|
removeTextFromElements('[' + DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE + ']');
|
|
200
|
-
|
|
201
178
|
if (userProgrammaticAttribute) {
|
|
202
179
|
removeTextFromElements('[' + userProgrammaticAttribute + ']');
|
|
203
180
|
}
|
|
204
|
-
|
|
205
181
|
return text;
|
|
206
182
|
}
|
|
207
|
-
|
|
208
183
|
return element.textContent;
|
|
209
184
|
}
|
|
185
|
+
|
|
210
186
|
/**
|
|
211
187
|
* Returns true if element.innerText excludes the text from inline SCRIPT and STYLE element. This
|
|
212
188
|
* should be the case everywhere except on Internet Explorer 10 and 11 (see [1])
|
|
@@ -223,42 +199,35 @@ function getTextualContent(element, userProgrammaticAttribute) {
|
|
|
223
199
|
*
|
|
224
200
|
* [1]: https://web.archive.org/web/20210602165716/http://perfectionkills.com/the-poor-misunderstood-innerText/#diff-with-textContent
|
|
225
201
|
*/
|
|
226
|
-
|
|
227
|
-
|
|
228
202
|
function supportsInnerTextScriptAndStyleRemoval() {
|
|
229
203
|
return !(0, _browserCore.isIE)();
|
|
230
204
|
}
|
|
205
|
+
|
|
231
206
|
/**
|
|
232
207
|
* Returns true if the browser supports the element.labels property. This should be the case
|
|
233
208
|
* everywhere except on Internet Explorer.
|
|
234
209
|
* Note: The result is computed lazily, because we don't want any DOM access when the SDK is
|
|
235
210
|
* evaluated.
|
|
236
211
|
*/
|
|
237
|
-
|
|
238
|
-
|
|
239
212
|
var supportsLabelPropertyResult;
|
|
240
|
-
|
|
241
213
|
function supportsLabelProperty() {
|
|
242
214
|
if (supportsLabelPropertyResult === undefined) {
|
|
243
215
|
supportsLabelPropertyResult = 'labels' in HTMLInputElement.prototype;
|
|
244
216
|
}
|
|
245
|
-
|
|
246
217
|
return supportsLabelPropertyResult;
|
|
247
218
|
}
|
|
219
|
+
|
|
248
220
|
/**
|
|
249
221
|
* Returns true if the browser supports the element.closest method. This should be the case
|
|
250
222
|
* everywhere except on Internet Explorer.
|
|
251
223
|
* Note: The result is computed lazily, because we don't want any DOM access when the SDK is
|
|
252
224
|
* evaluated.
|
|
253
225
|
*/
|
|
254
|
-
|
|
255
|
-
|
|
256
226
|
var supportsElementClosestResult;
|
|
257
|
-
|
|
258
227
|
function supportsElementClosest() {
|
|
259
228
|
if (supportsElementClosestResult === undefined) {
|
|
260
229
|
supportsElementClosestResult = 'closest' in HTMLElement.prototype;
|
|
261
230
|
}
|
|
262
|
-
|
|
263
231
|
return supportsElementClosestResult;
|
|
264
|
-
}
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=getActionNameFromElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getActionNameFromElement.js","names":["_browserCore","require","DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE","exports","getActionNameFromElement","element","userProgrammaticAttribute","getActionNameFromElementProgrammatically","getActionNameFromElementForStrategies","priorityStrategies","fallbackStrategies","targetElement","programmaticAttribute","elementWithAttribute","supportsElementClosest","closest","hasAttribute","parentElement","name","getAttribute","truncate","normalizeWhitespace","trim","supportsLabelProperty","labels","length","getTextualContent","id","label","ownerDocument","find","querySelectorAll","htmlFor","nodeName","input","type","value","labelledByAttribute","split","map","getElementById","filter","Boolean","ele","join","options","MAX_PARENTS_TO_CONSIDER","strategies","recursionCounter","i","strategy","trimmedName","s","replace","safeTruncate","refElement","isContentEditable","text","innerText","removeTextFromElements","query","list","index","_element","textToReplace","supportsInnerTextScriptAndStyleRemoval","textContent","isIE","supportsLabelPropertyResult","undefined","HTMLInputElement","prototype","supportsElementClosestResult","HTMLElement"],"sources":["../../../../src/domain/rumEventsCollection/actions/getActionNameFromElement.js"],"sourcesContent":["import { safeTruncate, isIE, find, map, filter } from '@cloudcare/browser-core'\n\nexport var DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE =\n 'data-guance-action-name'\n\nexport function getActionNameFromElement(element, userProgrammaticAttribute) {\n // Proceed to get the action name in two steps:\n // * first, get the name programmatically, explicitly defined by the user.\n // * then, use strategies that are known to return good results. Those strategies will be used on\n // the element and a few parents, but it's likely that they won't succeed at all.\n // * if no name is found this way, use strategies returning less accurate names as a fallback.\n // Those are much likely to succeed.\n return (\n getActionNameFromElementProgrammatically(\n element,\n DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE\n ) ||\n (userProgrammaticAttribute &&\n getActionNameFromElementProgrammatically(\n element,\n userProgrammaticAttribute\n )) ||\n getActionNameFromElementForStrategies(\n element,\n userProgrammaticAttribute,\n priorityStrategies\n ) ||\n getActionNameFromElementForStrategies(\n element,\n userProgrammaticAttribute,\n fallbackStrategies\n ) ||\n ''\n )\n}\n\nfunction getActionNameFromElementProgrammatically(\n targetElement,\n programmaticAttribute\n) {\n var elementWithAttribute\n // We don't use getActionNameFromElementForStrategies here, because we want to consider all parents,\n // without limit. It is up to the user to declare a relevant naming strategy.\n // If available, use element.closest() to match get the attribute from the element or any of its\n // parent. Else fallback to a more traditional implementation.\n if (supportsElementClosest()) {\n elementWithAttribute = targetElement.closest(\n '[' + programmaticAttribute + ']'\n )\n } else {\n var element = targetElement\n while (element) {\n if (element.hasAttribute(programmaticAttribute)) {\n elementWithAttribute = element\n break\n }\n element = element.parentElement\n }\n }\n\n if (!elementWithAttribute) {\n return\n }\n var name = elementWithAttribute.getAttribute(programmaticAttribute)\n return truncate(normalizeWhitespace(name.trim()))\n}\n\nvar priorityStrategies = [\n // associated LABEL text\n function (element, userProgrammaticAttribute) {\n // IE does not support element.labels, so we fallback to a CSS selector based on the element id\n // instead\n if (supportsLabelProperty()) {\n if ('labels' in element && element.labels && element.labels.length > 0) {\n return getTextualContent(element.labels[0], userProgrammaticAttribute)\n }\n } else if (element.id) {\n var label =\n element.ownerDocument &&\n find(element.ownerDocument.querySelectorAll('label'), function (label) {\n return label.htmlFor === element.id\n })\n return label && getTextualContent(label, userProgrammaticAttribute)\n }\n },\n // INPUT button (and associated) value\n function (element) {\n if (element.nodeName === 'INPUT') {\n var input = element\n var type = input.getAttribute('type')\n if (type === 'button' || type === 'submit' || type === 'reset') {\n return input.value\n }\n }\n },\n // BUTTON, LABEL or button-like element text\n function (element, userProgrammaticAttribute) {\n if (\n element.nodeName === 'BUTTON' ||\n element.nodeName === 'LABEL' ||\n element.getAttribute('role') === 'button'\n ) {\n return getTextualContent(element, userProgrammaticAttribute)\n }\n },\n function (element) {\n return element.getAttribute('aria-label')\n },\n // associated element text designated by the aria-labelledby attribute\n function (element, userProgrammaticAttribute) {\n var labelledByAttribute = element.getAttribute('aria-labelledby')\n if (labelledByAttribute) {\n labelledByAttribute = labelledByAttribute.split(/\\s+/)\n labelledByAttribute = map(labelledByAttribute, function (id) {\n return getElementById(element, id)\n })\n labelledByAttribute = filter(labelledByAttribute, function (label) {\n return Boolean(label)\n })\n labelledByAttribute = map(labelledByAttribute, function (ele) {\n return getTextualContent(ele, userProgrammaticAttribute)\n })\n return labelledByAttribute.join(' ')\n }\n },\n function (element) {\n return element.getAttribute('alt')\n },\n function (element) {\n return element.getAttribute('name')\n },\n function (element) {\n return element.getAttribute('title')\n },\n function (element) {\n return element.getAttribute('placeholder')\n },\n // SELECT first OPTION text\n function (element, userProgrammaticAttribute) {\n if ('options' in element && element.options.length > 0) {\n return getTextualContent(element.options[0], userProgrammaticAttribute)\n }\n }\n]\n\nvar fallbackStrategies = [\n function (element, userProgrammaticAttribute) {\n return getTextualContent(element, userProgrammaticAttribute)\n }\n]\n\n/**\n * Iterates over the target element and its parent, using the strategies list to get an action name.\n * Each strategies are applied on each element, stopping as soon as a non-empty value is returned.\n */\nvar MAX_PARENTS_TO_CONSIDER = 10\nfunction getActionNameFromElementForStrategies(\n targetElement,\n userProgrammaticAttribute,\n strategies\n) {\n var element = targetElement\n var recursionCounter = 0\n while (\n recursionCounter <= MAX_PARENTS_TO_CONSIDER &&\n element &&\n element.nodeName !== 'BODY' &&\n element.nodeName !== 'HTML' &&\n element.nodeName !== 'HEAD'\n ) {\n for (var i = 0; i < strategies.length; i++) {\n var strategy = strategies[i]\n var name = strategy(element, userProgrammaticAttribute)\n if (typeof name === 'string') {\n var trimmedName = name.trim()\n if (trimmedName) {\n return truncate(normalizeWhitespace(trimmedName))\n }\n }\n }\n // Consider a FORM as a contextual limit to get the action name. This is experimental and may\n // be reconsidered in the future.\n if (element.nodeName === 'FORM') {\n break\n }\n element = element.parentElement\n recursionCounter += 1\n }\n}\n\nfunction normalizeWhitespace(s) {\n return s.replace(/\\s+/g, ' ')\n}\n\nfunction truncate(s) {\n return s.length > 100 ? safeTruncate(s, 100) + ' [...]' : s\n}\n\nfunction getElementById(refElement, id) {\n // Use the element ownerDocument here, because tests are executed in an iframe, so\n // document.getElementById won't work.\n return refElement.ownerDocument\n ? refElement.ownerDocument.getElementById(id)\n : null\n}\n\nfunction getTextualContent(element, userProgrammaticAttribute) {\n if (element.isContentEditable) {\n return\n }\n\n if ('innerText' in element) {\n var text = element.innerText\n\n var removeTextFromElements = function (query) {\n var list = element.querySelectorAll(query)\n for (var index = 0; index < list.length; index += 1) {\n var _element = list[index]\n if ('innerText' in _element) {\n var textToReplace = _element.innerText\n if (textToReplace && textToReplace.trim().length > 0) {\n text = text.replace(textToReplace, '')\n }\n }\n }\n }\n\n if (!supportsInnerTextScriptAndStyleRemoval()) {\n // remove the inner text of SCRIPT and STYLES from the result. This is a bit dirty, but should\n // be relatively fast and work in most cases.\n removeTextFromElements('script, style')\n }\n\n // remove the text of elements with programmatic attribute value\n removeTextFromElements(\n '[' + DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE + ']'\n )\n\n if (userProgrammaticAttribute) {\n removeTextFromElements('[' + userProgrammaticAttribute + ']')\n }\n\n return text\n }\n\n return element.textContent\n}\n\n/**\n * Returns true if element.innerText excludes the text from inline SCRIPT and STYLE element. This\n * should be the case everywhere except on Internet Explorer 10 and 11 (see [1])\n *\n * The innerText property relies on what is actually rendered to compute its output, so to check if\n * it actually excludes SCRIPT and STYLE content, a solution would be to create a style element, set\n * its content to '*', inject it in the document body, and check if the style element innerText\n * property returns '*'. Using a new `document` instance won't work as it is not rendered.\n *\n * This solution requires specific CSP rules (see [2]) to be set by the customer. We want to avoid\n * this, so instead we rely on browser detection. In case of false negative, the impact should be\n * low, since we rely on this result to remove the SCRIPT and STYLE innerText (which will be empty)\n * from a parent element innerText.\n *\n * [1]: https://web.archive.org/web/20210602165716/http://perfectionkills.com/the-poor-misunderstood-innerText/#diff-with-textContent\n */\nfunction supportsInnerTextScriptAndStyleRemoval() {\n return !isIE()\n}\n\n/**\n * Returns true if the browser supports the element.labels property. This should be the case\n * everywhere except on Internet Explorer.\n * Note: The result is computed lazily, because we don't want any DOM access when the SDK is\n * evaluated.\n */\nvar supportsLabelPropertyResult\nfunction supportsLabelProperty() {\n if (supportsLabelPropertyResult === undefined) {\n supportsLabelPropertyResult = 'labels' in HTMLInputElement.prototype\n }\n return supportsLabelPropertyResult\n}\n\n/**\n * Returns true if the browser supports the element.closest method. This should be the case\n * everywhere except on Internet Explorer.\n * Note: The result is computed lazily, because we don't want any DOM access when the SDK is\n * evaluated.\n */\nvar supportsElementClosestResult\nfunction supportsElementClosest() {\n if (supportsElementClosestResult === undefined) {\n supportsElementClosestResult = 'closest' in HTMLElement.prototype\n }\n return supportsElementClosestResult\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,IAAIC,0CAA0C,GACnD,yBAAyB;AAAAC,OAAA,CAAAD,0CAAA,GAAAA,0CAAA;AAEpB,SAASE,wBAAwBA,CAACC,OAAO,EAAEC,yBAAyB,EAAE;EAC3E;EACA;EACA;EACA;EACA;EACA;EACA,OACEC,wCAAwC,CACtCF,OAAO,EACPH,0CACF,CAAC,IACAI,yBAAyB,IACxBC,wCAAwC,CACtCF,OAAO,EACPC,yBACF,CAAE,IACJE,qCAAqC,CACnCH,OAAO,EACPC,yBAAyB,EACzBG,kBACF,CAAC,IACDD,qCAAqC,CACnCH,OAAO,EACPC,yBAAyB,EACzBI,kBACF,CAAC,IACD,EAAE;AAEN;AAEA,SAASH,wCAAwCA,CAC/CI,aA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;AACA,IAAIC,2BAA2B;AAC/B,SAAS7C,qBAAqBA,CAAA,EAAG;EAC/B,IAAI6C,2BAA2B,KAAKC,SAAS,EAAE;IAC7CD,2BAA2B,GAAG,QAAQ,IAAIE,gBAAgB,CAACC,SAAS;EACtE;EACA,OAAOH,2BAA2B;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAII,4BAA4B;AAChC,SAAS1D,sBAAsBA,CAAA,EAAG;EAChC,IAAI0D,4BAA4B,KAAKH,SAAS,EAAE;IAC9CG,4BAA4B,GAAG,SAAS,IAAIC,WAAW,CAACF,SAAS;EACnE;EACA,OAAOC,4BAA4B;AACrC"}
|
|
@@ -6,48 +6,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.STABLE_ATTRIBUTES = void 0;
|
|
7
7
|
exports.getSelectorFromElement = getSelectorFromElement;
|
|
8
8
|
exports.supportScopeSelector = supportScopeSelector;
|
|
9
|
-
|
|
10
9
|
var _browserCore = require("@cloudcare/browser-core");
|
|
11
|
-
|
|
12
10
|
var _getActionNameFromElement = require("./getActionNameFromElement");
|
|
13
|
-
|
|
14
11
|
/**
|
|
15
12
|
* Stable attributes are attributes that are commonly used to identify parts of a UI (ex:
|
|
16
13
|
* component). Those attribute values should not be generated randomly (hardcoded most of the time)
|
|
17
14
|
* and stay the same across deploys. They are not necessarily unique across the document.
|
|
18
15
|
*/
|
|
19
|
-
var STABLE_ATTRIBUTES = [_getActionNameFromElement.DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE,
|
|
20
|
-
|
|
21
|
-
'data-
|
|
16
|
+
var STABLE_ATTRIBUTES = [_getActionNameFromElement.DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE,
|
|
17
|
+
// Common test attributes (list provided by google recorder)
|
|
18
|
+
'data-testid', 'data-test', 'data-qa', 'data-cy', 'data-test-id', 'data-qa-id', 'data-testing',
|
|
19
|
+
// FullStory decorator attributes:
|
|
20
|
+
'data-component', 'data-element', 'data-source-file'];
|
|
21
|
+
// Selectors to use if they target a single element on the whole document. Those selectors are
|
|
22
22
|
// considered as "stable" and uniquely identify an element regardless of the page state. If we find
|
|
23
23
|
// one, we should consider the selector "complete" and stop iterating over ancestors.
|
|
24
|
-
|
|
25
24
|
exports.STABLE_ATTRIBUTES = STABLE_ATTRIBUTES;
|
|
26
|
-
var GLOBALLY_UNIQUE_SELECTOR_GETTERS = [getStableAttributeSelector, getIDSelector];
|
|
25
|
+
var GLOBALLY_UNIQUE_SELECTOR_GETTERS = [getStableAttributeSelector, getIDSelector];
|
|
26
|
+
|
|
27
|
+
// Selectors to use if they target a single element among an element descendants. Those selectors
|
|
27
28
|
// are more brittle than "globally unique" selectors and should be combined with ancestor selectors
|
|
28
29
|
// to improve specificity.
|
|
29
|
-
|
|
30
30
|
var UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS = [getStableAttributeSelector, getClassSelector, getTagNameSelector];
|
|
31
|
-
|
|
32
31
|
function getSelectorFromElement(targetElement, actionNameAttribute) {
|
|
33
32
|
var targetElementSelector = '';
|
|
34
33
|
var element = targetElement;
|
|
35
|
-
|
|
36
34
|
while (element && element.nodeName !== 'HTML') {
|
|
37
35
|
var globallyUniqueSelector = findSelector(element, GLOBALLY_UNIQUE_SELECTOR_GETTERS, isSelectorUniqueGlobally, actionNameAttribute, targetElementSelector);
|
|
38
|
-
|
|
39
36
|
if (globallyUniqueSelector) {
|
|
40
37
|
return globallyUniqueSelector;
|
|
41
38
|
}
|
|
42
|
-
|
|
43
39
|
var uniqueSelectorAmongChildren = findSelector(element, UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS, isSelectorUniqueAmongSiblings, actionNameAttribute, targetElementSelector);
|
|
44
40
|
targetElementSelector = uniqueSelectorAmongChildren || combineSelector(getPositionSelector(element), targetElementSelector);
|
|
45
41
|
element = element.parentElement;
|
|
46
42
|
}
|
|
47
|
-
|
|
48
43
|
return targetElementSelector;
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
function isGeneratedValue(value) {
|
|
52
46
|
// To compute the "URL path group", the backend replaces every URL path parts as a question mark
|
|
53
47
|
// if it thinks the part is an identifier. The condition it uses is to checks whether a digit is
|
|
@@ -59,98 +53,77 @@ function isGeneratedValue(value) {
|
|
|
59
53
|
// provide their own `isGeneratedValue` at some point.
|
|
60
54
|
return /[0-9]/.test(value);
|
|
61
55
|
}
|
|
62
|
-
|
|
63
56
|
function getIDSelector(element) {
|
|
64
57
|
if (element.id && !isGeneratedValue(element.id)) {
|
|
65
58
|
return '#' + (0, _browserCore.cssEscape)(element.id);
|
|
66
59
|
}
|
|
67
60
|
}
|
|
68
|
-
|
|
69
61
|
function getClassSelector(element) {
|
|
70
62
|
if (element.tagName === 'BODY') {
|
|
71
63
|
return;
|
|
72
64
|
}
|
|
73
|
-
|
|
74
65
|
if (element.classList.length > 0) {
|
|
75
66
|
for (var i = 0; i < element.classList.length; i += 1) {
|
|
76
67
|
var className = element.classList[i];
|
|
77
|
-
|
|
78
68
|
if (isGeneratedValue(className)) {
|
|
79
69
|
continue;
|
|
80
70
|
}
|
|
81
|
-
|
|
82
|
-
return element.tagName + '.' + (0, _browserCore.cssEscape)(className);
|
|
71
|
+
return (0, _browserCore.cssEscape)(element.tagName) + '.' + (0, _browserCore.cssEscape)(className);
|
|
83
72
|
}
|
|
84
73
|
}
|
|
85
74
|
}
|
|
86
|
-
|
|
87
75
|
function getTagNameSelector(element) {
|
|
88
|
-
return element.tagName;
|
|
76
|
+
return (0, _browserCore.cssEscape)(element.tagName);
|
|
89
77
|
}
|
|
90
|
-
|
|
91
78
|
function getStableAttributeSelector(element, actionNameAttribute) {
|
|
92
79
|
if (actionNameAttribute) {
|
|
93
80
|
var selector = getAttributeSelector(actionNameAttribute);
|
|
94
|
-
|
|
95
81
|
if (selector) {
|
|
96
82
|
return selector;
|
|
97
83
|
}
|
|
98
84
|
}
|
|
99
|
-
|
|
100
85
|
for (var i = 0; i < STABLE_ATTRIBUTES.length; i++) {
|
|
101
86
|
var attributeName = STABLE_ATTRIBUTES[i];
|
|
102
87
|
var selector = getAttributeSelector(attributeName);
|
|
103
|
-
|
|
104
88
|
if (selector) {
|
|
105
89
|
return selector;
|
|
106
90
|
}
|
|
107
91
|
}
|
|
108
|
-
|
|
109
92
|
function getAttributeSelector(attributeName) {
|
|
110
93
|
if (element.hasAttribute(attributeName)) {
|
|
111
|
-
return element.tagName + '[' + attributeName + '="' + (0, _browserCore.cssEscape)(element.getAttribute(attributeName)) + '"]';
|
|
94
|
+
return (0, _browserCore.cssEscape)(element.tagName) + '[' + attributeName + '="' + (0, _browserCore.cssEscape)(element.getAttribute(attributeName)) + '"]';
|
|
112
95
|
}
|
|
113
96
|
}
|
|
114
97
|
}
|
|
115
|
-
|
|
116
98
|
function getPositionSelector(element) {
|
|
117
99
|
var sibling = element.parentElement && element.parentElement.firstElementChild;
|
|
118
100
|
var elementIndex = 1;
|
|
119
|
-
|
|
120
101
|
while (sibling && sibling !== element) {
|
|
121
102
|
if (sibling.tagName === element.tagName) {
|
|
122
103
|
elementIndex += 1;
|
|
123
104
|
}
|
|
124
|
-
|
|
125
105
|
sibling = sibling.nextElementSibling;
|
|
126
106
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
107
|
+
var tagName = (0, _browserCore.cssEscape)(element.tagName);
|
|
108
|
+
// 伪元素需要做特殊处理,没有nth-of-type选择器
|
|
130
109
|
if (/^::/.test(tagName)) {
|
|
131
110
|
return tagName;
|
|
132
111
|
}
|
|
133
|
-
|
|
134
112
|
return tagName + ':nth-of-type(' + elementIndex + ')';
|
|
135
113
|
}
|
|
136
|
-
|
|
137
114
|
function findSelector(element, selectorGetters, predicate, actionNameAttribute, childSelector) {
|
|
138
115
|
for (var i = 0; i < selectorGetters.length; i++) {
|
|
139
116
|
var selectorGetter = selectorGetters[i];
|
|
140
117
|
var elementSelector = selectorGetter(element, actionNameAttribute);
|
|
141
|
-
|
|
142
118
|
if (!elementSelector) {
|
|
143
119
|
continue;
|
|
144
120
|
}
|
|
145
|
-
|
|
146
121
|
var fullSelector = combineSelector(elementSelector, childSelector);
|
|
147
|
-
|
|
148
122
|
if (predicate(element, fullSelector)) {
|
|
149
123
|
return fullSelector;
|
|
150
124
|
}
|
|
151
125
|
}
|
|
152
126
|
}
|
|
153
|
-
|
|
154
127
|
function isSelectorUniqueGlobally(element, selector) {
|
|
155
128
|
return element.ownerDocument.body.querySelectorAll(selector).length === 1;
|
|
156
129
|
}
|
|
@@ -164,18 +137,13 @@ function isSelectorUniqueGlobally(element, selector) {
|
|
|
164
137
|
* direct descendent of the element parent. This should not impact results too much: if it
|
|
165
138
|
* inaccurately returns false, we'll just fall back to another strategy.
|
|
166
139
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
140
|
function isSelectorUniqueAmongSiblings(element, selector) {
|
|
170
141
|
return element.parentElement.querySelectorAll(supportScopeSelector() ? combineSelector(':scope', selector) : selector).length === 1;
|
|
171
142
|
}
|
|
172
|
-
|
|
173
143
|
function combineSelector(parent, child) {
|
|
174
144
|
return child ? parent + '>' + child : parent;
|
|
175
145
|
}
|
|
176
|
-
|
|
177
146
|
var supportScopeSelectorCache;
|
|
178
|
-
|
|
179
147
|
function supportScopeSelector() {
|
|
180
148
|
if (supportScopeSelectorCache === undefined) {
|
|
181
149
|
try {
|
|
@@ -185,6 +153,6 @@ function supportScopeSelector() {
|
|
|
185
153
|
supportScopeSelectorCache = false;
|
|
186
154
|
}
|
|
187
155
|
}
|
|
188
|
-
|
|
189
156
|
return supportScopeSelectorCache;
|
|
190
|
-
}
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=getSelectorsFromElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSelectorsFromElement.js","names":["_browserCore","require","_getActionNameFromElement","STABLE_ATTRIBUTES","DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE","exports","GLOBALLY_UNIQUE_SELECTOR_GETTERS","getStableAttributeSelector","getIDSelector","UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS","getClassSelector","getTagNameSelector","getSelectorFromElement","targetElement","actionNameAttribute","targetElementSelector","element","nodeName","globallyUniqueSelector","findSelector","isSelectorUniqueGlobally","uniqueSelectorAmongChildren","isSelectorUniqueAmongSiblings","combineSelector","getPositionSelector","parentElement","isGeneratedValue","value","test","id","cssEscape","tagName","classList","length","i","className","selector","getAttributeSelector","attributeName","hasAttribute","getAttribute","sibling","firstElementChild","elementIndex","nextElementSibling","selectorGetters","predicate","childSelector","selectorGetter","elementSelector","fullSelector","ownerDocument","body","querySelectorAll","supportScopeSelector","parent","child","supportScopeSelectorCache","undefined","document","querySelector","_unused"],"sources":["../../../../src/domain/rumEventsCollection/actions/getSelectorsFromElement.js"],"sourcesContent":["import { cssEscape } from '@cloudcare/browser-core'\nimport { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './getActionNameFromElement'\n/**\n * Stable attributes are attributes that are commonly used to identify parts of a UI (ex:\n * component). Those attribute values should not be generated randomly (hardcoded most of the time)\n * and stay the same across deploys. They are not necessarily unique across the document.\n */\nexport var STABLE_ATTRIBUTES = [\n DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE,\n // Common test attributes (list provided by google recorder)\n 'data-testid',\n 'data-test',\n 'data-qa',\n 'data-cy',\n 'data-test-id',\n 'data-qa-id',\n 'data-testing',\n // FullStory decorator attributes:\n 'data-component',\n 'data-element',\n 'data-source-file'\n]\n// Selectors to use if they target a single element on the whole document. Those selectors are\n// considered as \"stable\" and uniquely identify an element regardless of the page state. If we find\n// one, we should consider the selector \"complete\" and stop iterating over ancestors.\nvar GLOBALLY_UNIQUE_SELECTOR_GETTERS = [\n getStableAttributeSelector,\n getIDSelector\n]\n\n// Selectors to use if they target a single element among an element descendants. Those selectors\n// are more brittle than \"globally unique\" selectors and should be combined with ancestor selectors\n// to improve specificity.\nvar UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS = [\n getStableAttributeSelector,\n getClassSelector,\n getTagNameSelector\n]\n\nexport function getSelectorFromElement(targetElement, actionNameAttribute) {\n var targetElementSelector = ''\n var element = targetElement\n\n while (element && element.nodeName !== 'HTML') {\n var globallyUniqueSelector = findSelector(\n element,\n GLOBALLY_UNIQUE_SELECTOR_GETTERS,\n isSelectorUniqueGlobally,\n actionNameAttribute,\n targetElementSelector\n )\n if (globallyUniqueSelector) {\n return globallyUniqueSelector\n }\n\n var uniqueSelectorAmongChildren = findSelector(\n element,\n UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS,\n isSelectorUniqueAmongSiblings,\n actionNameAttribute,\n targetElementSelector\n )\n targetElementSelector =\n uniqueSelectorAmongChildren ||\n combineSelector(getPositionSelector(element), targetElementSelector)\n\n element = element.parentElement\n }\n\n return targetElementSelector\n}\nfunction isGeneratedValue(value) {\n // To compute the \"URL path group\", the backend replaces every URL path parts as a question mark\n // if it thinks the part is an identifier. The condition it uses is to checks whether a digit is\n // present.\n //\n // Here, we use the same strategy: if a the value contains a digit, we consider it generated. This\n // strategy might be a bit naive and fail in some cases, but there are many fallbacks to generate\n // CSS selectors so it should be fine most of the time. We might want to allow customers to\n // provide their own `isGeneratedValue` at some point.\n return /[0-9]/.test(value)\n}\nfunction getIDSelector(element) {\n if (element.id && !isGeneratedValue(element.id)) {\n return '#' + cssEscape(element.id)\n }\n}\n\nfunction getClassSelector(element) {\n if (element.tagName === 'BODY') {\n return\n }\n if (element.classList.length > 0) {\n for (var i = 0; i < element.classList.length; i += 1) {\n var className = element.classList[i]\n if (isGeneratedValue(className)) {\n continue\n }\n\n return cssEscape(element.tagName) + '.' + cssEscape(className)\n }\n }\n}\nfunction getTagNameSelector(element) {\n return cssEscape(element.tagName)\n}\nfunction getStableAttributeSelector(element, actionNameAttribute) {\n if (actionNameAttribute) {\n var selector = getAttributeSelector(actionNameAttribute)\n if (selector) {\n return selector\n }\n }\n\n for (var i = 0; i < STABLE_ATTRIBUTES.length; i++) {\n var attributeName = STABLE_ATTRIBUTES[i]\n var selector = getAttributeSelector(attributeName)\n if (selector) {\n return selector\n }\n }\n\n function getAttributeSelector(attributeName) {\n if (element.hasAttribute(attributeName)) {\n return (\n cssEscape(element.tagName) +\n '[' +\n attributeName +\n '=\"' +\n cssEscape(element.getAttribute(attributeName)) +\n '\"]'\n )\n }\n }\n}\n\nfunction getPositionSelector(element) {\n var sibling = element.parentElement && element.parentElement.firstElementChild\n var elementIndex = 1\n\n while (sibling && sibling !== element) {\n if (sibling.tagName === element.tagName) {\n elementIndex += 1\n }\n sibling = sibling.nextElementSibling\n }\n var tagName = cssEscape(element.tagName)\n // 伪元素需要做特殊处理,没有nth-of-type选择器\n if (/^::/.test(tagName)) {\n return tagName\n }\n return tagName + ':nth-of-type(' + elementIndex + ')'\n}\n\nfunction findSelector(\n element,\n selectorGetters,\n predicate,\n actionNameAttribute,\n childSelector\n) {\n for (var i = 0; i < selectorGetters.length; i++) {\n var selectorGetter = selectorGetters[i]\n var elementSelector = selectorGetter(element, actionNameAttribute)\n if (!elementSelector) {\n continue\n }\n var fullSelector = combineSelector(elementSelector, childSelector)\n if (predicate(element, fullSelector)) {\n return fullSelector\n }\n }\n}\n\nfunction isSelectorUniqueGlobally(element, selector) {\n return element.ownerDocument.body.querySelectorAll(selector).length === 1\n}\n/**\n * Check whether the selector is unique among the element siblings. In other words, it returns true\n * if \"ELEMENT_PARENT > SELECTOR\" returns a single element.\n *\n * The result will be less accurate on browsers that don't support :scope (i. e. IE): it will check\n * for any element matching the selector contained in the parent (in other words,\n * \"ELEMENT_PARENT SELECTOR\" returns a single element), regardless of whether the selector is a\n * direct descendent of the element parent. This should not impact results too much: if it\n * inaccurately returns false, we'll just fall back to another strategy.\n */\nfunction isSelectorUniqueAmongSiblings(element, selector) {\n return (\n element.parentElement.querySelectorAll(\n supportScopeSelector() ? combineSelector(':scope', selector) : selector\n ).length === 1\n )\n}\nfunction combineSelector(parent, child) {\n return child ? parent + '>' + child : parent\n}\nvar supportScopeSelectorCache\nexport function supportScopeSelector() {\n if (supportScopeSelectorCache === undefined) {\n try {\n document.querySelector(':scope')\n supportScopeSelectorCache = true\n } catch {\n supportScopeSelectorCache = false\n }\n }\n return supportScopeSelectorCache\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,yBAAA,GAAAD,OAAA;AACA;AACA;AACA;AACA;AACA;AACO,IAAIE,iBAAiB,GAAG,CAC7BC,oEAA0C;AAC1C;AACA,aAAa,EACb,WAAW,EACX,SAAS,EACT,SAAS,EACT,cAAc,EACd,YAAY,EACZ,cAAc;AACd;AACA,gBAAgB,EAChB,cAAc,EACd,kBAAkB,CACnB;AACD;AACA;AACA;AAAAC,OAAA,CAAAF,iBAAA,GAAAA,iBAAA;AACA,IAAIG,gCAAgC,GAAG,CACrCC,0BAA0B,EAC1BC,aAAa,CACd;;AAED;AACA;AACA;AACA,IAAIC,sCAAsC,GAAG,CAC3CF,0BAA0B,EAC1BG,gBAAgB,EAChBC,kBAAkB,CACnB;AAEM,SAASC,sBAAsBA,CAACC,aAAa,EAAEC,mBAAmB,EAAE;EACzE,IAAIC,qBAAqB,GAAG,EAAE;EAC9B,IAAIC,OAAO,GAAGH,aAAa;EAE3B,OAAOG,OAAO,IAAIA,OAAO,CAACC,QAAQ,KAAK,MAAM,EAAE;IAC7C,IAAIC,sBAAsB,GAAGC,YAAY,CACvCH,OAAO,EACPV,gCAAgC,EAChCc,wBAAwB,EACxBN,mBAAmB,EACnBC,qBACF,CAAC;IACD,IAAIG,sBAAsB,EAAE;MAC1B,OAAOA,sBAAsB;IAC/B;IAEA,IAAIG,2BAA2B,GAAGF,YAAY,CAC5CH,OAAO,EACPP,sCAAsC,EACtCa,6BAA6B,EAC7BR,mBAAmB,EACnBC,qBACF,CAAC;IACDA,qBAAqB,GACnBM,2BAA2B,IAC3BE,eAAe,CAACC,mBAAmB,CAACR,OAAO,CAAC,EAAED,qBAAqB,CAAC;IAEtEC,OAA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,KAAK;IACnC;EACF;EACA,OAAOA,yBAAyB;AAClC"}
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.listenActionEvents = listenActionEvents;
|
|
7
|
-
|
|
8
7
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
|
-
|
|
10
8
|
function listenActionEvents(events) {
|
|
11
9
|
var selectionEmptyAtPointerDown;
|
|
12
10
|
var userActivity = {
|
|
@@ -55,14 +53,14 @@ function listenActionEvents(events) {
|
|
|
55
53
|
}
|
|
56
54
|
};
|
|
57
55
|
}
|
|
58
|
-
|
|
59
56
|
function isSelectionEmpty() {
|
|
60
57
|
var selection = window.getSelection();
|
|
61
58
|
return !selection || selection.isCollapsed;
|
|
62
59
|
}
|
|
63
|
-
|
|
64
60
|
function isValidPointerEvent(event) {
|
|
65
|
-
return event.target instanceof Element &&
|
|
61
|
+
return event.target instanceof Element &&
|
|
62
|
+
// Only consider 'primary' pointer events for now. Multi-touch support could be implemented in
|
|
66
63
|
// the future.
|
|
67
64
|
event.isPrimary !== false;
|
|
68
|
-
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=listenActionEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listenActionEvents.js","names":["_browserCore","require","listenActionEvents","events","selectionEmptyAtPointerDown","userActivity","selection","input","clickContext","listeners","addEventListener","window","DOM_EVENT","POINTER_DOWN","event","isValidPointerEvent","isSelectionEmpty","onPointerDown","capture","SELECTION_CHANGE","POINTER_UP","localUserActivity","onPointerUp","undefined","INPUT","stop","each","listener","getSelection","isCollapsed","target","Element","isPrimary"],"sources":["../../../../src/domain/rumEventsCollection/actions/listenActionEvents.js"],"sourcesContent":["import { addEventListener, DOM_EVENT, each } from '@cloudcare/browser-core'\n\nexport function listenActionEvents(events) {\n var selectionEmptyAtPointerDown\n var userActivity = {\n selection: false,\n input: false\n }\n var clickContext\n var listeners = [\n addEventListener(\n window,\n DOM_EVENT.POINTER_DOWN,\n function (event) {\n if (isValidPointerEvent(event)) {\n selectionEmptyAtPointerDown = isSelectionEmpty()\n userActivity = {\n selection: false,\n input: false\n }\n clickContext = events.onPointerDown(event)\n }\n },\n { capture: true }\n ),\n\n addEventListener(\n window,\n DOM_EVENT.SELECTION_CHANGE,\n function () {\n if (!selectionEmptyAtPointerDown || !isSelectionEmpty()) {\n userActivity.selection = true\n }\n },\n { capture: true }\n ),\n\n addEventListener(\n window,\n DOM_EVENT.POINTER_UP,\n function (event) {\n if (isValidPointerEvent(event) && clickContext) {\n // Use a scoped variable to make sure the value is not changed by other clicks\n var localUserActivity = userActivity\n events.onPointerUp(clickContext, event, function () {\n return localUserActivity\n })\n clickContext = undefined\n }\n },\n { capture: true }\n ),\n\n addEventListener(\n window,\n DOM_EVENT.INPUT,\n function () {\n userActivity.input = true\n },\n { capture: true }\n )\n ]\n\n return {\n stop: function () {\n each(listeners, function (listener) {\n return listener.stop()\n })\n }\n }\n}\n\nfunction isSelectionEmpty() {\n var selection = window.getSelection()\n return !selection || selection.isCollapsed\n}\nfunction isValidPointerEvent(event) {\n return (\n event.target instanceof Element &&\n // Only consider 'primary' pointer events for now. Multi-touch support could be implemented in\n // the future.\n event.isPrimary !== false\n )\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,SAASC,kBAAkBA,CAACC,MAAM,EAAE;EACzC,IAAIC,2BAA2B;EAC/B,IAAIC,YAAY,GAAG;IACjBC,SAAS,EAAE,KAAK;IAChBC,KAAK,EAAE;EACT,CAAC;EACD,IAAIC,YAAY;EAChB,IAAIC,SAAS,GAAG,CACd,IAAAC,6BAAgB,EACdC,MAAM,EACNC,sBAAS,CAACC,YAAY,EACtB,UAAUC,KAAK,EAAE;IACf,IAAIC,mBAAmB,CAACD,KAAK,CAAC,EAAE;MAC9BV,2BAA2B,GAAGY,gBAAgB,CAAC,CAAC;MAChDX,YAAY,GAA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