@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadowRootsController.js","names":["_mutationObserver","require","_observers","initShadowRootsController","configuration","data","mutationCb","inputCb","controllerByShadowRoot","Map","shadowRootsController","addShadowRoot","shadowRoot","_startMutaionObserve","startMutationObserver","flush","stopMutationObserver","stop","stopInputObserver","initInputObserver","defaultPrivacyLevel","set","removeShadowRoot","entry","get","forEach","event","exports"],"sources":["../../../../src/domain/replay/record/shadowRootsController.js"],"sourcesContent":["import { startMutationObserver } from './mutationObserver'\nimport { initInputObserver } from './observers'\n\nexport var initShadowRootsController = function (configuration, data) {\n var mutationCb = data.mutationCb\n var inputCb = data.inputCb\n var controllerByShadowRoot = new Map()\n\n var shadowRootsController = {\n addShadowRoot: function (shadowRoot) {\n var _startMutaionObserve = startMutationObserver(\n mutationCb,\n configuration,\n shadowRootsController,\n shadowRoot\n )\n var flush = _startMutaionObserve.flush\n var stopMutationObserver = _startMutaionObserve.stop\n\n // the change event no do bubble up across the shadow root, we have to listen on the shadow root\n var stopInputObserver = initInputObserver(\n inputCb,\n configuration.defaultPrivacyLevel,\n shadowRoot\n )\n controllerByShadowRoot.set(shadowRoot, {\n flush: flush,\n stop: function () {\n stopMutationObserver()\n stopInputObserver()\n }\n })\n },\n removeShadowRoot: function (shadowRoot) {\n var entry = controllerByShadowRoot.get(shadowRoot)\n if (!entry) {\n return\n }\n entry.stop()\n controllerByShadowRoot.delete(shadowRoot)\n },\n stop: function () {\n controllerByShadowRoot.forEach(function (event) {\n event.stop()\n })\n },\n flush: function () {\n controllerByShadowRoot.forEach(function (event) {\n event.flush()\n })\n }\n }\n return shadowRootsController\n}\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEO,IAAIE,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAaC,aAAa,EAAEC,IAAI,EAAE;EACpE,IAAIC,UAAU,GAAGD,IAAI,CAACC,UAAU;EAChC,IAAIC,OAAO,GAAGF,IAAI,CAACE,OAAO;EAC1B,IAAIC,sBAAsB,GAAG,IAAIC,GAAG,CAAC,CAAC;EAEtC,IAAIC,qBAAqB,GAAG;IAC1BC,aAAa,EAAE,SAAAA,cAAUC,UAAU,EAAE;MACnC,IAAIC,oBAAoB,GAAG,IAAAC,uCAAqB,EAC9CR,UAAU,EACVF,aAAa,EACbM,qBAAqB,EACrBE,UACF,CAAC;MACD,IAAIG,KAAK,GAAGF,oBAAoB,CAACE,KAAK;MACtC,IAAIC,oBAAoB,GAAGH,oBAAoB,CAACI,IAAI;;MAEpD;MACA,IAAIC,iBAAiB,GAAG,IAAAC,4BAAiB,EACvCZ,OAAO,EACPH,aAAa,CAACgB,mBAAmB,EACjCR,UACF,CAAC;MACDJ,sBAAsB,CAACa,GAAG,CAACT,UAAU,EAAE;QACrCG,KAAK,EAAEA,KAAK;QACZE,IAAI,EAAE,SAAAA,KAAA,EAAY;UAChBD,oBAAoB,CAAC,CAAC;UACtBE,iBAAiB,CAAC,CAAC;QACrB;MACF,CAAC,CAAC;IACJ,CAAC;IACDI,gBAAgB,EAAE,SAAAA,iBAAUV,UAAU,EAAE;MACtC,IAAIW,KAAK,GAAGf,sBAAsB,CAACgB,GAAG,CAACZ,UAAU,CAAC;MAClD,IAAI,CAACW,KAAK,EAAE;QACV;MACF;MACAA,KAAK,CAACN,IAAI,CAAC,CAAC;MACZT,sBAAsB,UAAO,CAACI,UAAU,CAAC;IAC3C,CAAC;IACDK,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBT,sBAAsB,CAACiB,OAAO,CAAC,UAAUC,KAAK,EAAE;QAC9CA,KAAK,CAACT,IAAI,CAAC,CAAC;MACd,CAAC,CAAC;IACJ,CAAC;IACDF,KAAK,EAAE,SAAAA,MAAA,EAAY;MACjBP,sBAAsB,CAACiB,OAAO,CAAC,UAAUC,KAAK,EAAE;QAC9CA,KAAK,CAACX,KAAK,CAAC,CAAC;MACf,CAAC,CAAC;IACJ;EACF,CAAC;EACD,OAAOL,qBAAqB;AAC9B,CAAC;AAAAiB,OAAA,CAAAxB,yBAAA,GAAAA,yBAAA"}
|
|
@@ -7,19 +7,14 @@ exports.assembleIncrementalSnapshot = assembleIncrementalSnapshot;
|
|
|
7
7
|
exports.forEach = forEach;
|
|
8
8
|
exports.getPathToNestedCSSRule = getPathToNestedCSSRule;
|
|
9
9
|
exports.isTouchEvent = isTouchEvent;
|
|
10
|
-
|
|
11
10
|
var _browserCore = require("@cloudcare/browser-core");
|
|
12
|
-
|
|
13
11
|
var _types = require("../../../types");
|
|
14
|
-
|
|
15
12
|
function isTouchEvent(event) {
|
|
16
13
|
return Boolean(event.changedTouches);
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
function forEach(list, callback) {
|
|
20
16
|
Array.prototype.forEach.call(list, callback);
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
function assembleIncrementalSnapshot(source, data) {
|
|
24
19
|
return {
|
|
25
20
|
data: (0, _browserCore.assign)({
|
|
@@ -29,25 +24,22 @@ function assembleIncrementalSnapshot(source, data) {
|
|
|
29
24
|
timestamp: (0, _browserCore.timeStampNow)()
|
|
30
25
|
};
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
function getPathToNestedCSSRule(rule) {
|
|
34
28
|
var path = [];
|
|
35
29
|
var currentRule = rule;
|
|
36
|
-
|
|
37
30
|
while (currentRule.parentRule) {
|
|
38
31
|
var rules = Array.from(currentRule.parentRule.cssRules);
|
|
39
32
|
var index = rules.indexOf(currentRule);
|
|
40
33
|
path.unshift(index);
|
|
41
34
|
currentRule = currentRule.parentRule;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
}
|
|
36
|
+
// A rule may not be attached to a stylesheet
|
|
45
37
|
if (!currentRule.parentStyleSheet) {
|
|
46
38
|
return;
|
|
47
39
|
}
|
|
48
|
-
|
|
49
40
|
var rules = Array.from(currentRule.parentStyleSheet.cssRules);
|
|
50
41
|
var index = rules.indexOf(currentRule);
|
|
51
42
|
path.unshift(index);
|
|
52
43
|
return path;
|
|
53
|
-
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_browserCore","require","_types","isTouchEvent","event","Boolean","changedTouches","forEach","list","callback","Array","prototype","call","assembleIncrementalSnapshot","source","data","assign","type","RecordType","IncrementalSnapshot","timestamp","timeStampNow","getPathToNestedCSSRule","rule","path","currentRule","parentRule","rules","from","cssRules","index","indexOf","unshift","parentStyleSheet"],"sources":["../../../../src/domain/replay/record/utils.js"],"sourcesContent":["import { assign, timeStampNow } from '@cloudcare/browser-core'\nimport { RecordType } from '../../../types'\n\nexport function isTouchEvent(event) {\n return Boolean(event.changedTouches)\n}\n\nexport function forEach(list, callback) {\n Array.prototype.forEach.call(list, callback)\n}\n\nexport function assembleIncrementalSnapshot(source, data) {\n return {\n data: assign(\n {\n source: source\n },\n data\n ),\n type: RecordType.IncrementalSnapshot,\n timestamp: timeStampNow()\n }\n}\n\nexport function getPathToNestedCSSRule(rule) {\n var path = []\n var currentRule = rule\n while (currentRule.parentRule) {\n var rules = Array.from(currentRule.parentRule.cssRules)\n var index = rules.indexOf(currentRule)\n path.unshift(index)\n currentRule = currentRule.parentRule\n }\n // A rule may not be attached to a stylesheet\n if (!currentRule.parentStyleSheet) {\n return\n }\n\n var rules = Array.from(currentRule.parentStyleSheet.cssRules)\n var index = rules.indexOf(currentRule)\n path.unshift(index)\n\n return path\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,SAASE,YAAYA,CAACC,KAAK,EAAE;EAClC,OAAOC,OAAO,CAACD,KAAK,CAACE,cAAc,CAAC;AACtC;AAEO,SAASC,OAAOA,CAACC,IAAI,EAAEC,QAAQ,EAAE;EACtCC,KAAK,CAACC,SAAS,CAACJ,OAAO,CAACK,IAAI,CAACJ,IAAI,EAAEC,QAAQ,CAAC;AAC9C;AAEO,SAASI,2BAA2BA,CAACC,MAAM,EAAEC,IAAI,EAAE;EACxD,OAAO;IACLA,IAAI,EAAE,IAAAC,mBAAM,EACV;MACEF,MAAM,EAAEA;IACV,CAAC,EACDC,IACF,CAAC;IACDE,IAAI,EAAEC,iBAAU,CAACC,mBAAmB;IACpCC,SAAS,EAAE,IAAAC,yBAAY,EAAC;EAC1B,CAAC;AACH;AAEO,SAASC,sBAAsBA,CAACC,IAAI,EAAE;EAC3C,IAAIC,IAAI,GAAG,EAAE;EACb,IAAIC,WAAW,GAAGF,IAAI;EACtB,OAAOE,WAAW,CAACC,UAAU,EAAE;IAC7B,IAAIC,KAAK,GAAGjB,KAAK,CAACkB,IAAI,CAACH,WAAW,CAACC,UAAU,CAACG,QAAQ,CAAC;IACvD,IAAIC,KAAK,GAAGH,KAAK,CAACI,OAAO,CAACN,WAAW,CAAC;IACtCD,IAAI,CAACQ,OAAO,CAACF,KAAK,CAAC;IACnBL,WAAW,GAAGA,WAAW,CAACC,UAAU;EACtC;EACA;EACA,IAAI,CAACD,WAAW,CAACQ,gBAAgB,EAAE;IACjC;EACF;EAEA,IAAIN,KAAK,GAAGjB,KAAK,CAACkB,IAAI,CAACH,WAAW,CAACQ,gBAAgB,CAACJ,QAAQ,CAAC;EAC7D,IAAIC,KAAK,GAAGH,KAAK,CAACI,OAAO,CAACN,WAAW,CAAC;EACtCD,IAAI,CAACQ,OAAO,CAACF,KAAK,CAAC;EAEnB,OAAON,IAAI;AACb"}
|
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.convertMouseEventToLayoutCoordinates = void 0;
|
|
7
|
-
exports.getScrollX = getScrollX;
|
|
8
|
-
exports.getScrollY = getScrollY;
|
|
9
|
-
exports.getVisualViewport = void 0;
|
|
10
|
-
|
|
6
|
+
exports.getVisualViewport = exports.convertMouseEventToLayoutCoordinates = void 0;
|
|
11
7
|
/**
|
|
12
8
|
* Browsers have not standardized various dimension properties. Mobile devices typically report
|
|
13
9
|
* dimensions in reference to the visual viewport, while desktop uses the layout viewport. For example,
|
|
@@ -18,19 +14,19 @@ exports.getVisualViewport = void 0;
|
|
|
18
14
|
* which viewport is being measured. Therefore these exported functions will fallback to assuming that the layout
|
|
19
15
|
* viewport is being measured by the browser
|
|
20
16
|
*/
|
|
17
|
+
|
|
21
18
|
// Scrollbar widths vary across properties on different devices and browsers
|
|
22
19
|
var TOLERANCE = 25;
|
|
20
|
+
|
|
23
21
|
/**
|
|
24
22
|
* Use the Visual Viewport API's properties to measure scrollX/Y in reference to the layout viewport
|
|
25
23
|
* in order to determine if window.scrollX/Y is measuring the layout or visual viewport.
|
|
26
24
|
* This finding corresponds to which viewport mouseEvent.clientX/Y and window.innerWidth/Height measures.
|
|
27
25
|
*/
|
|
28
|
-
|
|
29
26
|
function isVisualViewportFactoredIn() {
|
|
30
27
|
var visual = window.visualViewport;
|
|
31
28
|
return Math.abs(visual.pageTop - visual.offsetTop - window.scrollY) > TOLERANCE || Math.abs(visual.pageLeft - visual.offsetLeft - window.scrollX) > TOLERANCE;
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
var convertMouseEventToLayoutCoordinates = function convertMouseEventToLayoutCoordinates(clientX, clientY) {
|
|
35
31
|
var visual = window.visualViewport;
|
|
36
32
|
var normalised = {
|
|
@@ -39,7 +35,6 @@ var convertMouseEventToLayoutCoordinates = function convertMouseEventToLayoutCoo
|
|
|
39
35
|
visualViewportX: clientX,
|
|
40
36
|
visualViewportY: clientY
|
|
41
37
|
};
|
|
42
|
-
|
|
43
38
|
if (!visual) {
|
|
44
39
|
// On old browsers, we cannot normalise, so fallback to clientX/Y
|
|
45
40
|
return normalised;
|
|
@@ -52,12 +47,9 @@ var convertMouseEventToLayoutCoordinates = function convertMouseEventToLayoutCoo
|
|
|
52
47
|
normalised.visualViewportX = Math.round(clientX - visual.offsetLeft);
|
|
53
48
|
normalised.visualViewportY = Math.round(clientY - visual.offsetTop);
|
|
54
49
|
}
|
|
55
|
-
|
|
56
50
|
return normalised;
|
|
57
51
|
};
|
|
58
|
-
|
|
59
52
|
exports.convertMouseEventToLayoutCoordinates = convertMouseEventToLayoutCoordinates;
|
|
60
|
-
|
|
61
53
|
var getVisualViewport = function getVisualViewport() {
|
|
62
54
|
var visual = window.visualViewport;
|
|
63
55
|
return {
|
|
@@ -70,35 +62,5 @@ var getVisualViewport = function getVisualViewport() {
|
|
|
70
62
|
width: visual.width
|
|
71
63
|
};
|
|
72
64
|
};
|
|
73
|
-
|
|
74
65
|
exports.getVisualViewport = getVisualViewport;
|
|
75
|
-
|
|
76
|
-
function getScrollX() {
|
|
77
|
-
var scrollX;
|
|
78
|
-
var visual = window.visualViewport;
|
|
79
|
-
|
|
80
|
-
if (visual) {
|
|
81
|
-
scrollX = visual.pageLeft - visual.offsetLeft;
|
|
82
|
-
} else if (window.scrollX !== undefined) {
|
|
83
|
-
scrollX = window.scrollX;
|
|
84
|
-
} else {
|
|
85
|
-
scrollX = window.pageXOffset || 0;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return Math.round(scrollX);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function getScrollY() {
|
|
92
|
-
var scrollY;
|
|
93
|
-
var visual = window.visualViewport;
|
|
94
|
-
|
|
95
|
-
if (visual) {
|
|
96
|
-
scrollY = visual.pageTop - visual.offsetTop;
|
|
97
|
-
} else if (window.scrollY !== undefined) {
|
|
98
|
-
scrollY = window.scrollY;
|
|
99
|
-
} else {
|
|
100
|
-
scrollY = window.pageYOffset || 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return Math.round(scrollY);
|
|
104
|
-
}
|
|
66
|
+
//# sourceMappingURL=viewports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewports.js","names":["TOLERANCE","isVisualViewportFactoredIn","visual","window","visualViewport","Math","abs","pageTop","offsetTop","scrollY","pageLeft","offsetLeft","scrollX","convertMouseEventToLayoutCoordinates","clientX","clientY","normalised","layoutViewportX","layoutViewportY","visualViewportX","visualViewportY","round","exports","getVisualViewport","scale","height","width"],"sources":["../../../../src/domain/replay/record/viewports.js"],"sourcesContent":["/**\n * Browsers have not standardized various dimension properties. Mobile devices typically report\n * dimensions in reference to the visual viewport, while desktop uses the layout viewport. For example,\n * Mobile Chrome will change innerWidth when a pinch zoom takes place, while Chrome Desktop (mac) will not.\n *\n * With the new Viewport API, we now calculate and normalize dimension properties to the layout viewport.\n * If the VisualViewport API is not supported by a browser, it isn't reasonably possible to detect or normalize\n * which viewport is being measured. Therefore these exported functions will fallback to assuming that the layout\n * viewport is being measured by the browser\n */\n\n// Scrollbar widths vary across properties on different devices and browsers\nvar TOLERANCE = 25\n\n/**\n * Use the Visual Viewport API's properties to measure scrollX/Y in reference to the layout viewport\n * in order to determine if window.scrollX/Y is measuring the layout or visual viewport.\n * This finding corresponds to which viewport mouseEvent.clientX/Y and window.innerWidth/Height measures.\n */\nfunction isVisualViewportFactoredIn() {\n var visual = window.visualViewport\n return (\n Math.abs(visual.pageTop - visual.offsetTop - window.scrollY) > TOLERANCE ||\n Math.abs(visual.pageLeft - visual.offsetLeft - window.scrollX) > TOLERANCE\n )\n}\n\nexport var convertMouseEventToLayoutCoordinates = function (clientX, clientY) {\n var visual = window.visualViewport\n var normalised = {\n layoutViewportX: clientX,\n layoutViewportY: clientY,\n visualViewportX: clientX,\n visualViewportY: clientY\n }\n\n if (!visual) {\n // On old browsers, we cannot normalise, so fallback to clientX/Y\n return normalised\n } else if (isVisualViewportFactoredIn()) {\n // Typically Mobile Devices\n normalised.layoutViewportX = Math.round(clientX + visual.offsetLeft)\n normalised.layoutViewportY = Math.round(clientY + visual.offsetTop)\n } else {\n // Typically Desktop Devices\n normalised.visualViewportX = Math.round(clientX - visual.offsetLeft)\n normalised.visualViewportY = Math.round(clientY - visual.offsetTop)\n }\n return normalised\n}\n\nexport var getVisualViewport = function () {\n var visual = window.visualViewport\n return {\n scale: visual.scale,\n offsetLeft: visual.offsetLeft,\n offsetTop: visual.offsetTop,\n pageLeft: visual.pageLeft,\n pageTop: visual.pageTop,\n height: visual.height,\n width: visual.width\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAIA,SAAS,GAAG,EAAE;;AAElB;AACA;AACA;AACA;AACA;AACA,SAASC,0BAA0BA,CAAA,EAAG;EACpC,IAAIC,MAAM,GAAGC,MAAM,CAACC,cAAc;EAClC,OACEC,IAAI,CAACC,GAAG,CAACJ,MAAM,CAACK,OAAO,GAAGL,MAAM,CAACM,SAAS,GAAGL,MAAM,CAACM,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AACM,SAAS;IAC3BE,QAAQ,EAAER,MAAM,CAACQ,QAAQ;IACzBH,OAAO,EAAEL,MAAM,CAACK,OAAO;IACvBkB,MAAM,EAAEvB,MAAM,CAACuB,MAAM;IACrBC,KAAK,EAAExB,MAAM,CAACwB;EAChB,CAAC;AACH,CAAC;AAAAJ,OAAA,CAAAC,iBAAA,GAAAA,iBAAA"}
|
|
@@ -13,38 +13,29 @@ exports.resetReplayStats = resetReplayStats;
|
|
|
13
13
|
var MAX_STATS_HISTORY = 10;
|
|
14
14
|
exports.MAX_STATS_HISTORY = MAX_STATS_HISTORY;
|
|
15
15
|
var statsPerView;
|
|
16
|
-
|
|
17
16
|
function getSegmentsCount(viewId) {
|
|
18
17
|
return getOrCreateReplayStats(viewId).segments_count;
|
|
19
18
|
}
|
|
20
|
-
|
|
21
19
|
function addSegment(viewId) {
|
|
22
20
|
getOrCreateReplayStats(viewId).segments_count += 1;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
function addRecord(viewId) {
|
|
26
23
|
getOrCreateReplayStats(viewId).records_count += 1;
|
|
27
24
|
}
|
|
28
|
-
|
|
29
25
|
function addWroteData(viewId, additionalBytesCount) {
|
|
30
26
|
getOrCreateReplayStats(viewId).segments_total_raw_size += additionalBytesCount;
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
function getReplayStats(viewId) {
|
|
34
29
|
return statsPerView && statsPerView.get(viewId);
|
|
35
30
|
}
|
|
36
|
-
|
|
37
31
|
function resetReplayStats() {
|
|
38
32
|
statsPerView = undefined;
|
|
39
33
|
}
|
|
40
|
-
|
|
41
34
|
function getOrCreateReplayStats(viewId) {
|
|
42
35
|
if (!statsPerView) {
|
|
43
36
|
statsPerView = new Map();
|
|
44
37
|
}
|
|
45
|
-
|
|
46
38
|
var replayStats;
|
|
47
|
-
|
|
48
39
|
if (statsPerView.has(viewId)) {
|
|
49
40
|
replayStats = statsPerView.get(viewId);
|
|
50
41
|
} else {
|
|
@@ -54,20 +45,16 @@ function getOrCreateReplayStats(viewId) {
|
|
|
54
45
|
segments_total_raw_size: 0
|
|
55
46
|
};
|
|
56
47
|
statsPerView.set(viewId, replayStats);
|
|
57
|
-
|
|
58
48
|
if (statsPerView.size > MAX_STATS_HISTORY) {
|
|
59
49
|
deleteOldestStats();
|
|
60
50
|
}
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
return replayStats;
|
|
64
53
|
}
|
|
65
|
-
|
|
66
54
|
function deleteOldestStats() {
|
|
67
55
|
if (!statsPerView) {
|
|
68
56
|
return;
|
|
69
57
|
}
|
|
70
|
-
|
|
71
58
|
if (statsPerView.keys) {
|
|
72
59
|
statsPerView["delete"](statsPerView.keys().next().value);
|
|
73
60
|
} else {
|
|
@@ -80,4 +67,5 @@ function deleteOldestStats() {
|
|
|
80
67
|
}
|
|
81
68
|
});
|
|
82
69
|
}
|
|
83
|
-
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=replayStats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replayStats.js","names":["MAX_STATS_HISTORY","exports","statsPerView","getSegmentsCount","viewId","getOrCreateReplayStats","segments_count","addSegment","addRecord","records_count","addWroteData","additionalBytesCount","segments_total_raw_size","getReplayStats","get","resetReplayStats","undefined","Map","replayStats","has","set","size","deleteOldestStats","keys","next","value","isFirst","forEach","_value","key"],"sources":["../../../src/domain/replay/replayStats.js"],"sourcesContent":["export var MAX_STATS_HISTORY = 10\nvar statsPerView\n\nexport function getSegmentsCount(viewId) {\n return getOrCreateReplayStats(viewId).segments_count\n}\n\nexport function addSegment(viewId) {\n getOrCreateReplayStats(viewId).segments_count += 1\n}\n\nexport function addRecord(viewId) {\n getOrCreateReplayStats(viewId).records_count += 1\n}\n\nexport function addWroteData(viewId, additionalBytesCount) {\n getOrCreateReplayStats(viewId).segments_total_raw_size += additionalBytesCount\n}\n\nexport function getReplayStats(viewId) {\n return statsPerView && statsPerView.get(viewId)\n}\n\nexport function resetReplayStats() {\n statsPerView = undefined\n}\n\nfunction getOrCreateReplayStats(viewId) {\n if (!statsPerView) {\n statsPerView = new Map()\n }\n\n var replayStats\n if (statsPerView.has(viewId)) {\n replayStats = statsPerView.get(viewId)\n } else {\n replayStats = {\n records_count: 0,\n segments_count: 0,\n segments_total_raw_size: 0\n }\n statsPerView.set(viewId, replayStats)\n if (statsPerView.size > MAX_STATS_HISTORY) {\n deleteOldestStats()\n }\n }\n\n return replayStats\n}\n\nfunction deleteOldestStats() {\n if (!statsPerView) {\n return\n }\n if (statsPerView.keys) {\n statsPerView.delete(statsPerView.keys().next().value)\n } else {\n // IE11 doesn't support map.keys\n var isFirst = true\n statsPerView.forEach(function (_value, key) {\n if (isFirst) {\n statsPerView.delete(key)\n isFirst = false\n }\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAO,IAAIA,iBAAiB,GAAG,EAAE;AAAAC,OAAA,CAAAD,iBAAA,GAAAA,iBAAA;AACjC,IAAIE,YAAY;AAET,SAASC,gBAAgBA,CAACC,MAAM,EAAE;EACvC,OAAOC,sBAAsB,CAACD,MAAM,CAAC,CAACE,cAAc;AACtD;AAEO,SAASC,UAAUA,CAACH,MAAM,EAAE;EACjCC,sBAAsB,CAACD,MAAM,CAAC,CAACE,cAAc,IAAI,CAAC;AACpD;AAEO,SAASE,SAASA,CAACJ,MAAM,EAAE;EAChCC,sBAAsB,CAACD,MAAM,CAAC,CAACK,aAAa,IAAI,CAAC;AACnD;AAEO,SAASC,YAAYA,CAACN,MAAM,EAAEO,oBAAoB,EAAE;EACzDN,sBAAsB,CAACD,MAAM,CAAC,CAACQ,uBAAuB,IAAID,oBAAoB;AAChF;AAEO,SAASE,cAAcA,CAACT,MAAM,EAAE;EACrC,OAAOF,YAAY,IAAIA,YAAY,CAACY,GAAG,CAACV,MAAM,CAAC;AACjD;AAEO,SAASW,gBAAgBA,CAAA,EAAG;EACjCb,YAAY,GAAGc,SAAS;AAC1B;AAEA,SAASX,sBAAsBA,CAACD,MAAM,EAAE;EACtC,IAAI,CAACF,YAAY,EAAE;IACjBA,YAAY,GAAG,IAAIe,GAAG,CAAC,CAAC;EAC1B;EAEA,IAAIC,WAAW;EACf,IAAIhB,YAAY,CAACiB,GAAG,CAACf,MAAM,CAAC,EAAE;IAC5Bc,WAAW,GAAGhB,YAAY,CAACY,GAAG,CAACV,MAAM,CAAC;EACxC,CAAC,MAAM;IACLc,WAAW,GAAG;MACZT,aAAa,EAAE,CAAC;MAChBH,cAAc,EAAE,CAAC;MACjBM,uBAAuB,EAAE;IAC3B,CAAC;IACDV,YAAY,CAACkB,GAAG,CAAChB,MAAM,EAAEc,WAAW,CAAC;IACrC,IAAIhB,YAAY,CAACmB,IAAI,GAAGrB,iBAAiB,EAAE;MACzCsB,iBAAiB,CAAC,CAAC;IACrB;EACF;EAEA,OAAOJ,WAAW;AACpB;AAEA,SAASI,iBAAiBA,CAAA,EAAG;EAC3B,IAAI,CAACpB,YAAY,EAAE;IACjB;EACF;EACA,IAAIA,YAAY,CAACqB,IAAI,EAAE;IACrBrB,YAAY,UAAO,CAACA,YAAY,CAACqB,IAAI,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC;EACvD,CAAC,MAAM;IACL;IACA,IAAIC,OAAO,GAAG,IAAI;IAClBxB,YAAY,CAACyB,OAAO,CAAC,UAAUC,MAAM,EAAEC,GAAG,EAAE;MAC1C,IAAIH,OAAO,EAAE;QACXxB,YAAY,UAAO,CAAC2B,GAAG,CAAC;QACxBH,OAAO,GAAG,KAAK;MACjB;IACF,CAAC,CAAC;EACJ;AACF"}
|
|
@@ -5,11 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.buildReplayPayload = buildReplayPayload;
|
|
7
7
|
exports.toFormEntries = toFormEntries;
|
|
8
|
-
|
|
9
8
|
var _browserCore = require("@cloudcare/browser-core");
|
|
10
|
-
|
|
11
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
12
|
-
|
|
9
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
13
10
|
function buildReplayPayload(data, metadata, rawSegmentBytesCount) {
|
|
14
11
|
var formData = new FormData();
|
|
15
12
|
formData.append('segment', new Blob([data], {
|
|
@@ -24,20 +21,18 @@ function buildReplayPayload(data, metadata, rawSegmentBytesCount) {
|
|
|
24
21
|
bytesCount: data.byteLength
|
|
25
22
|
};
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
function toFormEntries(input, onEntry, prefix) {
|
|
29
25
|
if (prefix === undefined) {
|
|
30
26
|
prefix = '';
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
(0, _browserCore.each)((0, _browserCore.objectEntries)(input), function (item) {
|
|
34
29
|
var value = item[1];
|
|
35
30
|
var key = item[0];
|
|
36
|
-
|
|
37
31
|
if (_typeof(value) === 'object' && value !== null) {
|
|
38
32
|
toFormEntries(value, onEntry, '' + prefix + key + '_');
|
|
39
33
|
} else {
|
|
40
34
|
onEntry('' + prefix + key, String(value));
|
|
41
35
|
}
|
|
42
36
|
});
|
|
43
|
-
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=buildReplayPayload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildReplayPayload.js","names":["_browserCore","require","_typeof","obj","Symbol","iterator","constructor","prototype","buildReplayPayload","data","metadata","rawSegmentBytesCount","formData","FormData","append","Blob","type","session","id","start","toFormEntries","key","value","toString","bytesCount","byteLength","input","onEntry","prefix","undefined","each","objectEntries","item","String"],"sources":["../../../../src/domain/replay/segmentCollection/buildReplayPayload.js"],"sourcesContent":["import { objectEntries, each } from '@cloudcare/browser-core'\n\nexport function buildReplayPayload(data, metadata, rawSegmentBytesCount) {\n var formData = new FormData()\n formData.append(\n 'segment',\n new Blob([data], {\n type: 'application/octet-stream'\n }),\n metadata.session.id + '-' + metadata.start\n )\n\n toFormEntries(metadata, function (key, value) {\n formData.append(key, value)\n })\n formData.append('raw_segment_size', rawSegmentBytesCount.toString())\n\n return { data: formData, bytesCount: data.byteLength }\n}\n\nexport function toFormEntries(input, onEntry, prefix) {\n if (prefix === undefined) {\n prefix = ''\n }\n each(objectEntries(input), function (item) {\n var value = item[1]\n var key = item[0]\n if (typeof value === 'object' && value !== null) {\n toFormEntries(value, onEntry, '' + prefix + key + '_')\n } else {\n onEntry('' + prefix + key, String(value))\n }\n })\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAA6D,SAAAC,QAAAC,GAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,GAAA,kBAAAA,GAAA,gBAAAA,GAAA,WAAAA,GAAA,yBAAAC,MAAA,IAAAD,GAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,GAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,GAAA,KAAAD,OAAA,CAAAC,GAAA;AAEtD,SAASK,kBAAkBA,CAACC,IAAI,EAAEC,QAAQ,EAAEC,oBAAoB,EAAE;EACvE,IAAIC,QAAQ,GAAG,IAAIC,QAAQ,CAAC,CAAC;EAC7BD,QAAQ,CAACE,MAAM,CACb,SAAS,EACT,IAAIC,IAAI,CAAC,CAACN,IAAI,CAAC,EAAE;IACfO,IAAI,EAAE;EACR,CAAC,CAAC,EACFN,QAAQ,CAACO,OAAO,CAACC,EAAE,GAAG,GAAG,GAAGR,QAAQ,CAACS,KACvC,CAAC;EAEDC,aAAa,CAACV,QAAQ,EAAE,UAAUW,GAAG,EAAEC,KAAK,EAAE;IAC5CV,QAAQ,CAACE,MAAM,CAACO,GAAG,EAAEC,KAAK,CAAC;EAC7B,CAAC,CAAC;EACFV,QAAQ,CAACE,MAAM,CAAC,kBAAkB,EAAEH,oBAAoB,CAACY,QAAQ,CAAC,CAAC,CAAC;EAEpE,OAAO;IAAEd,IAAI,EAAEG,QAAQ;IAAEY,UAAU,EAAEf,IAAI,CAACgB;EAAW,CAAC;AACxD;AAEO,SAASL,aAAaA,CAACM,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAE;EACpD,IAAIA,MAAM,KAAKC,SAAS,EAAE;IACxBD,MAAM,GAAG,EAAE;EACb;EACA,IAAAE,iBAAI,EAAC,IAAAC,0BAAa,EAACL,KAAK,CAAC,EAAE,UAAUM,IAAI,EAAE;IACzC,IAAIV,KAAK,GAAGU,IAAI,CAAC,CAAC,CAAC;IACnB,IAAIX,GAAG,GAAGW,IAAI,CAAC,CAAC,CAAC;IACjB,IAAI9B,OAAA,CAAOoB,KAAK,MAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,EAAE;MAC/CF,aAAa,CAACE,KAAK,EAAEK,OAAO,EAAE,EAAE,GAAGC,MAAM,GAAGP,GAAG,GAAG,GAAG,CAAC;IACxD,CAAC,MAAM;MACLM,OAAO,CAAC,EAAE,GAAGC,MAAM,GAAGP,GAAG,EAAEY,MAAM,CAACX,KAAK,CAAC,CAAC;IAC3C;EACF,CAAC,CAAC;AACJ"}
|
|
@@ -27,7 +27,6 @@ Object.defineProperty(exports, "startSegmentCollection", {
|
|
|
27
27
|
return _segmentCollection.startSegmentCollection;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
|
|
31
30
|
var _segmentCollection = require("./segmentCollection");
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
var _startDeflateWorker = require("./startDeflateWorker");
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_segmentCollection","require","_startDeflateWorker"],"sources":["../../../../src/domain/replay/segmentCollection/index.js"],"sourcesContent":["export {\n startSegmentCollection,\n setSegmentBytesLimit\n} from './segmentCollection'\nexport { startDeflateWorker } from './startDeflateWorker'\nexport { SEGMENT_BYTES_LIMIT } from './segmentCollection'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAIA,IAAAC,mBAAA,GAAAD,OAAA"}
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
4
|
-
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.Segment = Segment;
|
|
9
|
-
|
|
10
8
|
var _browserCore = require("@cloudcare/browser-core");
|
|
11
|
-
|
|
12
9
|
var _types = require("../../../types");
|
|
13
|
-
|
|
14
10
|
var replayStats = _interopRequireWildcard(require("../replayStats"));
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
13
|
var STREAM_ID = 1;
|
|
21
14
|
var nextId = 0;
|
|
22
|
-
|
|
23
15
|
function Segment(worker, context, creationReason, initialRecord, onWrote, onFlushed) {
|
|
24
16
|
this.worker = worker;
|
|
25
17
|
this.pendingWriteCount = 0;
|
|
@@ -39,23 +31,18 @@ function Segment(worker, context, creationReason, initialRecord, onWrote, onFlus
|
|
|
39
31
|
var rawBytesCount = 0;
|
|
40
32
|
var compressedBytesCount = 0;
|
|
41
33
|
var compressedData = [];
|
|
42
|
-
|
|
43
34
|
var _this = this;
|
|
44
|
-
|
|
45
35
|
var wokerListener = (0, _browserCore.addEventListener)(worker, 'message', function (params) {
|
|
46
36
|
var data = params.data;
|
|
47
|
-
|
|
48
37
|
if (data.type !== 'wrote') {
|
|
49
38
|
return;
|
|
50
39
|
}
|
|
51
|
-
|
|
52
40
|
if (data.id === _this.id) {
|
|
53
41
|
_this.pendingWriteCount -= 1;
|
|
54
42
|
replayStats.addWroteData(viewId, data.additionalBytesCount);
|
|
55
43
|
rawBytesCount += data.additionalBytesCount;
|
|
56
44
|
compressedBytesCount += data.result.length;
|
|
57
45
|
compressedData.push(data.result);
|
|
58
|
-
|
|
59
46
|
if (_this.flushReason && _this.pendingWriteCount === 0) {
|
|
60
47
|
compressedData.push(data.trailer);
|
|
61
48
|
onFlushed((0, _browserCore.concatBuffers)(compressedData), rawBytesCount);
|
|
@@ -75,24 +62,21 @@ function Segment(worker, context, creationReason, initialRecord, onWrote, onFlus
|
|
|
75
62
|
removeMessageListener();
|
|
76
63
|
}
|
|
77
64
|
});
|
|
78
|
-
var removeMessageListener = wokerListener.stop;
|
|
65
|
+
var removeMessageListener = wokerListener.stop;
|
|
66
|
+
// worker.addEventListener('message', listener)
|
|
79
67
|
|
|
80
68
|
this.write('{"records":[' + JSON.stringify(initialRecord));
|
|
81
69
|
}
|
|
82
|
-
|
|
83
70
|
Segment.prototype.addRecord = function (record) {
|
|
84
71
|
this.metadata.start = Math.min(this.metadata.start, record.timestamp);
|
|
85
72
|
this.metadata.end = Math.max(this.metadata.end, record.timestamp);
|
|
86
73
|
this.metadata.records_count += 1;
|
|
87
74
|
replayStats.addRecord(this.metadata.view.id);
|
|
88
|
-
|
|
89
75
|
if (!this.metadata.has_full_snapshot) {
|
|
90
76
|
this.metadata.has_full_snapshot = record.type === _types.RecordType.FullSnapshot;
|
|
91
77
|
}
|
|
92
|
-
|
|
93
78
|
this.write(',' + JSON.stringify(record));
|
|
94
79
|
};
|
|
95
|
-
|
|
96
80
|
Segment.prototype.flush = function (reason) {
|
|
97
81
|
this.write('],' + JSON.stringify(this.metadata).slice(1) + '\n');
|
|
98
82
|
this.worker.postMessage({
|
|
@@ -101,7 +85,6 @@ Segment.prototype.flush = function (reason) {
|
|
|
101
85
|
});
|
|
102
86
|
this.flushReason = reason;
|
|
103
87
|
};
|
|
104
|
-
|
|
105
88
|
Segment.prototype.write = function (data) {
|
|
106
89
|
this.pendingWriteCount += 1;
|
|
107
90
|
this.worker.postMessage({
|
|
@@ -110,4 +93,5 @@ Segment.prototype.write = function (data) {
|
|
|
110
93
|
streamId: STREAM_ID,
|
|
111
94
|
action: 'write'
|
|
112
95
|
});
|
|
113
|
-
};
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=segment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segment.js","names":["_browserCore","require","_types","replayStats","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","STREAM_ID","nextId","Segment","worker","context","creationReason","initialRecord","onWrote","onFlushed","pendingWriteCount","id","viewId","view","metadata","assign","start","timestamp","end","creation_reason","records_count","has_full_snapshot","type","RecordType","FullSnapshot","index_in_view","getSegmentsCount","source","addSegment","addRecord","rawBytesCount","compressedBytesCount","compressedData","_this","wokerListener","addEventListener","params","data","addWroteData","additionalBytesCount","result","length","push","flushReason","trailer","concatBuffers","removeMessageListener","stop","write","JSON","stringify","record","Math","min","max","flush","reason","slice","postMessage","action","streamId"],"sources":["../../../../src/domain/replay/segmentCollection/segment.js"],"sourcesContent":["import {\n assign,\n addEventListener,\n concatBuffers\n} from '@cloudcare/browser-core'\nimport { RecordType } from '../../../types'\nimport * as replayStats from '../replayStats'\nvar STREAM_ID = 1\nvar nextId = 0\nexport function Segment(\n worker,\n context,\n creationReason,\n initialRecord,\n onWrote,\n onFlushed\n) {\n this.worker = worker\n this.pendingWriteCount = 0\n this.id = nextId++\n var viewId = context.view.id\n\n this.metadata = assign(\n {\n start: initialRecord.timestamp,\n end: initialRecord.timestamp,\n creation_reason: creationReason,\n records_count: 1,\n has_full_snapshot: initialRecord.type === RecordType.FullSnapshot,\n index_in_view: replayStats.getSegmentsCount(viewId),\n source: 'browser'\n },\n context\n )\n replayStats.addSegment(viewId)\n replayStats.addRecord(viewId)\n var rawBytesCount = 0\n var compressedBytesCount = 0\n var compressedData = []\n var _this = this\n var wokerListener = addEventListener(worker, 'message', function (params) {\n var data = params.data\n if (data.type !== 'wrote') {\n return\n }\n\n if (data.id === _this.id) {\n _this.pendingWriteCount -= 1\n replayStats.addWroteData(viewId, data.additionalBytesCount)\n rawBytesCount += data.additionalBytesCount\n compressedBytesCount += data.result.length\n compressedData.push(data.result)\n if (_this.flushReason && _this.pendingWriteCount === 0) {\n compressedData.push(data.trailer)\n onFlushed(concatBuffers(compressedData), rawBytesCount)\n removeMessageListener()\n } else {\n onWrote(compressedBytesCount)\n }\n } else if (data.id > _this.id) {\n // Messages should be received in the same order as they are sent, so if we receive a\n // message with an id superior to this Segment instance id, we know that another, more\n // recent Segment instance is being used.\n //\n // In theory, a \"flush\" response should have been received at this point, so the listener\n // should already have been removed. But if something goes wrong and we didn't receive a\n // \"flush\" response, remove the listener to avoid any leak, and send a monitor message to\n // help investigate the issue.\n removeMessageListener()\n }\n })\n var removeMessageListener = wokerListener.stop\n // worker.addEventListener('message', listener)\n\n this.write('{\"records\":[' + JSON.stringify(initialRecord))\n}\nSegment.prototype.addRecord = function (record) {\n this.metadata.start = Math.min(this.metadata.start, record.timestamp)\n this.metadata.end = Math.max(this.metadata.end, record.timestamp)\n this.metadata.records_count += 1\n replayStats.addRecord(this.metadata.view.id)\n if (!this.metadata.has_full_snapshot) {\n this.metadata.has_full_snapshot = record.type === RecordType.FullSnapshot\n }\n this.write(',' + JSON.stringify(record))\n}\nSegment.prototype.flush = function (reason) {\n this.write('],' + JSON.stringify(this.metadata).slice(1) + '\\n')\n\n this.worker.postMessage({\n action: 'reset',\n streamId: STREAM_ID\n })\n this.flushReason = reason\n}\n\nSegment.prototype.write = function (data) {\n this.pend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,CAAC;EACjE,IAAI,CAACH,QAAQ,CAACM,aAAa,IAAI,CAAC;EAChC3C,WAAW,CAACoD,SAAS,CAAC,IAAI,CAACf,QAAQ,CAACD,IAAI,CAACF,EAAE,CAAC;EAC5C,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACO,iBAAiB,EAAE;IACpC,IAAI,CAACP,QAAQ,CAACO,iBAAiB,GAAG8B,MAAM,CAAC7B,IAAI,KAAKC,iBAAU,CAACC,YAAY;EAC3E;EACA,IAAI,CAACwB,KAAK,CAAC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAACC,MAAM,CAAC,CAAC;AAC1C,CAAC;AACDhD,OAAO,CAACP,SAAS,CAAC2D,KAAK,GAAG,UAAUC,MAAM,EAAE;EAC1C,IAAI,CAACR,KAAK,CAAC,IAAI,GAAGC,IAAI,CAACC,SAAS,CAAC,IAAI,CAACpC,QAAQ,CAAC,CAAC2C,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;EAEhE,IAAI,CAACrD,MAAM,CAACsD,WAAW,CAAC;IACtBC,MAAM,EAAE,OAAO;IACfC,QAAQ,EAAE3D;EACZ,CAAC,CAAC;EACF,IAAI,CAAC0C,WAAW,GAAGa,MAAM;AAC3B,CAAC;AAEDrD,OAAO,CAACP,SAAS,CAACoD,KAAK,GAAG,UAAUX,IAAI,EAAE;EACxC,IAAI,CAAC3B,iBAAiB,IAAI,CAAC;EAC3B,IAAI,CAACN,MAAM,CAACsD,WAAW,CAAC;IACtBrB,IAAI,EAAEA,IAAI;IACV1B,EAAE,EAAE,IAAI,CAACA,EAAE;IACXiD,QAAQ,EAAE3D,SAAS;IACnB0D,MAAM,EAAE;EACV,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -8,21 +8,18 @@ exports.computeSegmentContext = computeSegmentContext;
|
|
|
8
8
|
exports.doStartSegmentCollection = doStartSegmentCollection;
|
|
9
9
|
exports.setSegmentBytesLimit = setSegmentBytesLimit;
|
|
10
10
|
exports.startSegmentCollection = startSegmentCollection;
|
|
11
|
-
|
|
12
11
|
var _browserCore = require("@cloudcare/browser-core");
|
|
13
|
-
|
|
14
12
|
var _buildReplayPayload = require("./buildReplayPayload");
|
|
15
|
-
|
|
16
13
|
var _segment = require("./segment");
|
|
17
|
-
|
|
18
14
|
var SEGMENT_DURATION_LIMIT = 30 * _browserCore.ONE_SECOND;
|
|
19
15
|
/**
|
|
20
16
|
* beacon payload max queue size implementation is 64kb
|
|
21
17
|
* ensure that we leave room for logs, rum and potential other users
|
|
22
18
|
*/
|
|
23
|
-
|
|
24
19
|
exports.SEGMENT_DURATION_LIMIT = SEGMENT_DURATION_LIMIT;
|
|
25
|
-
var SEGMENT_BYTES_LIMIT = 60000;
|
|
20
|
+
var SEGMENT_BYTES_LIMIT = 60000;
|
|
21
|
+
|
|
22
|
+
// Segments are the main data structure for session replays. They contain context information used
|
|
26
23
|
// for indexing or UI needs, and a list of records (RRWeb 'events', renamed to avoid confusing
|
|
27
24
|
// namings). They are stored without any processing from the intake, and fetched one after the
|
|
28
25
|
// other while a session is being replayed. Their encoding (deflate) are carefully crafted to allow
|
|
@@ -46,21 +43,17 @@ var SEGMENT_BYTES_LIMIT = 60000; // Segments are the main data structure for ses
|
|
|
46
43
|
//
|
|
47
44
|
// To help investigate session replays issues, each segment is created with a "creation reason",
|
|
48
45
|
// indicating why the session has been created.
|
|
49
|
-
|
|
50
46
|
exports.SEGMENT_BYTES_LIMIT = SEGMENT_BYTES_LIMIT;
|
|
51
|
-
|
|
52
47
|
function startSegmentCollection(lifeCycle, configuration, sessionManager, viewContexts, httpRequest, worker) {
|
|
53
48
|
return doStartSegmentCollection(lifeCycle, function () {
|
|
54
49
|
return computeSegmentContext(configuration, sessionManager, viewContexts);
|
|
55
50
|
}, httpRequest, worker);
|
|
56
51
|
}
|
|
57
|
-
|
|
58
52
|
var SegmentCollectionStatus = {
|
|
59
53
|
WaitingForInitialRecord: 0,
|
|
60
54
|
SegmentPending: 1,
|
|
61
55
|
Stopped: 2
|
|
62
56
|
};
|
|
63
|
-
|
|
64
57
|
function doStartSegmentCollection(lifeCycle, getSegmentContext, httpRequest, worker) {
|
|
65
58
|
var state = {
|
|
66
59
|
status: SegmentCollectionStatus.WaitingForInitialRecord,
|
|
@@ -74,13 +67,11 @@ function doStartSegmentCollection(lifeCycle, getSegmentContext, httpRequest, wor
|
|
|
74
67
|
flushSegment(pageExitEvent.reason);
|
|
75
68
|
});
|
|
76
69
|
var unsubscribePageExited = subscribePageExited.unsubscribe;
|
|
77
|
-
|
|
78
70
|
function flushSegment(flushReason) {
|
|
79
71
|
if (state.status === SegmentCollectionStatus.SegmentPending) {
|
|
80
72
|
state.segment.flush(flushReason);
|
|
81
73
|
(0, _browserCore.clearTimeout)(state.expirationTimeoutId);
|
|
82
74
|
}
|
|
83
|
-
|
|
84
75
|
if (flushReason !== 'stop') {
|
|
85
76
|
state = {
|
|
86
77
|
status: SegmentCollectionStatus.WaitingForInitialRecord,
|
|
@@ -92,21 +83,17 @@ function doStartSegmentCollection(lifeCycle, getSegmentContext, httpRequest, wor
|
|
|
92
83
|
};
|
|
93
84
|
}
|
|
94
85
|
}
|
|
95
|
-
|
|
96
86
|
function createNewSegment(creationReason, initialRecord) {
|
|
97
87
|
var context = getSegmentContext();
|
|
98
|
-
|
|
99
88
|
if (!context) {
|
|
100
89
|
return;
|
|
101
90
|
}
|
|
102
|
-
|
|
103
91
|
var segment = new _segment.Segment(worker, context, creationReason, initialRecord, function (compressedSegmentBytesCount) {
|
|
104
92
|
if (!segment.flushReason && compressedSegmentBytesCount > SEGMENT_BYTES_LIMIT) {
|
|
105
93
|
flushSegment('segment_bytes_limit');
|
|
106
94
|
}
|
|
107
95
|
}, function (data, rawSegmentBytesCount) {
|
|
108
96
|
var payload = (0, _buildReplayPayload.buildReplayPayload)(data, segment.metadata, rawSegmentBytesCount);
|
|
109
|
-
|
|
110
97
|
if ((0, _browserCore.isPageExitReason)(segment.flushReason)) {
|
|
111
98
|
httpRequest.sendOnExit(payload);
|
|
112
99
|
} else {
|
|
@@ -121,14 +108,12 @@ function doStartSegmentCollection(lifeCycle, getSegmentContext, httpRequest, wor
|
|
|
121
108
|
}, SEGMENT_DURATION_LIMIT)
|
|
122
109
|
};
|
|
123
110
|
}
|
|
124
|
-
|
|
125
111
|
return {
|
|
126
112
|
addRecord: function addRecord(record) {
|
|
127
113
|
switch (state.status) {
|
|
128
114
|
case SegmentCollectionStatus.WaitingForInitialRecord:
|
|
129
115
|
createNewSegment(state.nextSegmentCreationReason, record);
|
|
130
116
|
break;
|
|
131
|
-
|
|
132
117
|
case SegmentCollectionStatus.SegmentPending:
|
|
133
118
|
state.segment.addRecord(record);
|
|
134
119
|
break;
|
|
@@ -141,15 +126,12 @@ function doStartSegmentCollection(lifeCycle, getSegmentContext, httpRequest, wor
|
|
|
141
126
|
}
|
|
142
127
|
};
|
|
143
128
|
}
|
|
144
|
-
|
|
145
129
|
function computeSegmentContext(configuration, sessionManager, viewContexts) {
|
|
146
130
|
var session = sessionManager.findTrackedSession();
|
|
147
131
|
var viewContext = viewContexts.findView();
|
|
148
|
-
|
|
149
132
|
if (!session || !viewContext) {
|
|
150
133
|
return undefined;
|
|
151
134
|
}
|
|
152
|
-
|
|
153
135
|
return {
|
|
154
136
|
sdk: {
|
|
155
137
|
name: configuration.sdkName,
|
|
@@ -169,11 +151,10 @@ function computeSegmentContext(configuration, sessionManager, viewContexts) {
|
|
|
169
151
|
}
|
|
170
152
|
};
|
|
171
153
|
}
|
|
172
|
-
|
|
173
154
|
function setSegmentBytesLimit(newSegmentBytesLimit) {
|
|
174
155
|
if (newSegmentBytesLimit === undefined) {
|
|
175
156
|
newSegmentBytesLimit = 60000;
|
|
176
157
|
}
|
|
177
|
-
|
|
178
158
|
exports.SEGMENT_BYTES_LIMIT = SEGMENT_BYTES_LIMIT = newSegmentBytesLimit;
|
|
179
|
-
}
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=segmentCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segmentCollection.js","names":["_browserCore","require","_buildReplayPayload","_segment","SEGMENT_DURATION_LIMIT","ONE_SECOND","exports","SEGMENT_BYTES_LIMIT","startSegmentCollection","lifeCycle","configuration","sessionManager","viewContexts","httpRequest","worker","doStartSegmentCollection","computeSegmentContext","SegmentCollectionStatus","WaitingForInitialRecord","SegmentPending","Stopped","getSegmentContext","state","status","nextSegmentCreationReason","subscribeViewCreated","subscribe","LifeCycleEventType","VIEW_CREATED","flushSegment","unsubscribeViewCreated","unsubscribe","subscribePageExited","PAGE_EXITED","pageExitEvent","reason","unsubscribePageExited","flushReason","segment","flush","clearTimeout","expirationTimeoutId","createNewSegment","creationReason","initialRecord","context","Segment","compressedSegmentBytesCount","data","rawSegmentBytesCount","payload","buildReplayPayload","metadata","isPageExitReason","sendOnExit","send","setTimeout","addRecord","record","stop","session","findTrackedSession","viewContext","findView","undefined","sdk","name","sdkName","version","sdkVersion","env","service","app","id","applicationId","view","setSegmentBytesLimit","newSegmentBytesLimit"],"sources":["../../../../src/domain/replay/segmentCollection/segmentCollection.js"],"sourcesContent":["import {\n ONE_SECOND,\n LifeCycleEventType,\n isPageExitReason,\n setTimeout,\n clearTimeout\n} from '@cloudcare/browser-core'\nimport { buildReplayPayload } from './buildReplayPayload'\nimport { Segment } from './segment'\n\nexport var SEGMENT_DURATION_LIMIT = 30 * ONE_SECOND\n/**\n * beacon payload max queue size implementation is 64kb\n * ensure that we leave room for logs, rum and potential other users\n */\nexport var SEGMENT_BYTES_LIMIT = 60000\n\n// Segments are the main data structure for session replays. They contain context information used\n// for indexing or UI needs, and a list of records (RRWeb 'events', renamed to avoid confusing\n// namings). They are stored without any processing from the intake, and fetched one after the\n// other while a session is being replayed. Their encoding (deflate) are carefully crafted to allow\n// concatenating multiple segments together. Segments have a size overhead (metadata), so our goal is to\n// build segments containing as many records as possible while complying with the various flush\n// strategies to guarantee a good replay quality.\n//\n// When the recording starts, a segment is initially created. The segment is flushed (finalized and\n// sent) based on various events (non-exhaustive list):\n//\n// * the page visibility change or becomes to unload\n// * the segment duration reaches a limit\n// * the encoded segment bytes count reaches a limit\n// * ...\n//\n// A segment cannot be created without its context. If the RUM session ends and no session id is\n// available when creating a new segment, records will be ignored, until the session is renewed and\n// a new session id is available.\n//\n// Empty segments (segments with no record) aren't useful and should be ignored.\n//\n// To help investigate session replays issues, each segment is created with a \"creation reason\",\n// indicating why the session has been created.\n\nexport function startSegmentCollection(\n lifeCycle,\n configuration,\n sessionManager,\n viewContexts,\n httpRequest,\n worker\n) {\n return doStartSegmentCollection(\n lifeCycle,\n function () {\n return computeSegmentContext(configuration, sessionManager, viewContexts)\n },\n httpRequest,\n worker\n )\n}\n\nvar SegmentCollectionStatus = {\n WaitingForInitialRecord: 0,\n SegmentPending: 1,\n Stopped: 2\n}\n\nexport function doStartSegmentCollection(\n lifeCycle,\n getSegmentContext,\n httpRequest,\n worker\n) {\n var state = {\n status: SegmentCollectionStatus.WaitingForInitialRecord,\n nextSegmentCreationReason: 'init'\n }\n var subscribeViewCreated = lifeCycle.subscribe(\n LifeCycleEventType.VIEW_CREATED,\n function () {\n flushSegment('view_change')\n }\n )\n var unsubscribeViewCreated = subscribeViewCreated.unsubscribe\n var subscribePageExited = lifeCycle.subscribe(\n LifeCycleEventType.PAGE_EXITED,\n function (pageExitEvent) {\n flushSegment(pageExitEvent.reason)\n }\n )\n var unsubscribePageExited = subscribePageExited.unsubscribe\n\n function flushSegment(flushReason) {\n if (state.status === SegmentCollectionStatus.SegmentPending) {\n state.segment.flush(flushReason)\n clearTimeout(state.expirationTimeoutId)\n }\n\n if (flushReason !== 'stop') {\n state = {\n status: SegmentCollectionStatus.WaitingForInitialRecord,\n nextSegmentCreationReason: flushReason\n }\n } else {\n state = {\n status: SegmentCollectionStatus.Stopped\n }\n }\n }\n\n function createNewSegment(creationReason, initialRecord) {\n var context = getSegmentContext()\n if (!context) {\n return\n }\n\n var segment = new Segment(\n worker,\n context,\n creationReason,\n initialRecord,\n function (compressedSegmentBytesCount) {\n if (\n !segment.flushReason &&\n compressedSegmentBytesCount > SEGMENT_BYTES_LIMIT\n ) {\n flushSegment('segment_bytes_limit')\n }\n },\n function (data, rawSegmentBytesCount) {\n var payload = buildReplayPayload(\n data,\n segment.metadata,\n rawSegmentBytesCount\n )\n if (isPageExitReason(segment.flushReason)) {\n httpRequest.sendOnExit(payload)\n } else {\n httpRequest.send(payload)\n }\n }\n )\n state = {\n status: SegmentCollectionStatus.SegmentPending,\n segment: segment,\n expirationTimeoutId: setTimeout(function () {\n flushSegment('segment_duration_limit')\n }, SEGMENT_DURATION_LIMIT)\n }\n }\n\n return {\n addRecord: function (record) {\n switch (state.status) {\n case SegmentCollectionStatus.WaitingForInitialRecord:\n createNewSegment(state.nextSegmentCreationReason, record)\n break\n\n case SegmentCollectionStatus.SegmentPending:\n state.segment.addRecord(record)\n break\n }\n },\n\n stop: function () {\n flushSegment('stop')\n unsubscribeViewCreated()\n unsubscribePageExited()\n }\n }\n}\n\nexport function computeSegmentContext(\n configuration,\n sessionManager,\n viewContexts\n) {\n var session = sessionManager.findTrackedSession()\n var viewContext = viewContexts.findView()\n if (!session || !viewContext) {\n return undefined\n }\n return {\n sdk: {\n name: configuration.sdkName,\n version: configuration.sdkVersion\n },\n env: configuration.env || '',\n service: viewContext.service || configuration.service || 'browser',\n version: viewContext.version || configuration.version || '',\n app: {\n id: configuration.applicationId\n },\n session: {\n id: session.id\n },\n view: {\n id: viewContext.id\n }\n }\n}\n\nexport function setSegmentBytesLimit(newSegmentBytesLimit) {\n if (newSegmentBytesLimit === undefined) {\n newSegmentBytesLimit = 60000\n }\n SEGMENT_BYTES_LIMIT = newSegmentBytesLimit\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEO,IAAIG,sBAAsB,GAAG,EAAE,GAAGC,uBAAU;AACnD;AAC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