@cloudcare/browser-rum 3.2.18 → 3.2.22
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/README.md +128 -190
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +2 -3
- package/cjs/boot/buildEnv.js.map +1 -1
- package/cjs/boot/perStartRum.js +9 -2
- package/cjs/boot/perStartRum.js.map +1 -1
- package/cjs/boot/recorderApi.js +1 -1
- package/cjs/boot/recorderApi.js.map +1 -1
- package/cjs/boot/rum.entry.js +1 -2
- package/cjs/boot/rum.entry.js.map +1 -1
- package/cjs/boot/rum.js +1 -1
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/boot/rumPublicApi.js +1 -1
- package/cjs/boot/rumPublicApi.js.map +1 -1
- package/cjs/boot/startRecording.js +57 -8
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/constants.js +13 -26
- package/cjs/constants.js.map +1 -1
- package/cjs/domain/assembly.js +16 -8
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/configuration.js +13 -3
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/contexts/displayContext.js.map +1 -1
- package/cjs/domain/contexts/foregroundContexts.js +2 -4
- package/cjs/domain/contexts/foregroundContexts.js.map +1 -1
- package/cjs/domain/contexts/internalContext.js.map +1 -1
- package/cjs/domain/contexts/pageStateHistory.js +4 -8
- package/cjs/domain/contexts/pageStateHistory.js.map +1 -1
- package/cjs/domain/contexts/urlContexts.js +1 -2
- package/cjs/domain/contexts/urlContexts.js.map +1 -1
- package/cjs/domain/contexts/viewContexts.js +1 -2
- package/cjs/domain/contexts/viewContexts.js.map +1 -1
- package/cjs/domain/deflate/deflateEncoder.js +1 -2
- package/cjs/domain/deflate/deflateEncoder.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +3 -5
- package/cjs/domain/deflate/deflateWorker.js.map +1 -1
- package/cjs/domain/firstInputPolyfill.js.map +1 -1
- package/cjs/domain/locationChangeObservable.js.map +1 -1
- package/cjs/domain/performanceObservable.js +3 -3
- package/cjs/domain/performanceObservable.js.map +1 -1
- package/cjs/domain/performanceUtils.js.map +1 -1
- package/cjs/domain/replay/record/elementsScrollPositions.js.map +1 -1
- package/cjs/domain/replay/record/mutationBatch.js +1 -2
- package/cjs/domain/replay/record/mutationBatch.js.map +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +2 -2
- package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
- package/cjs/domain/replay/record/observers.js +31 -32
- package/cjs/domain/replay/record/observers.js.map +1 -1
- package/cjs/domain/replay/record/privacy.js +6 -7
- package/cjs/domain/replay/record/privacy.js.map +1 -1
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/replay/record/serializationUtils.js +5 -8
- package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
- package/cjs/domain/replay/record/serialize.js +8 -10
- package/cjs/domain/replay/record/serialize.js.map +1 -1
- package/cjs/domain/replay/record/shadowRootsController.js +2 -3
- package/cjs/domain/replay/record/shadowRootsController.js.map +1 -1
- package/cjs/domain/replay/record/viewports.js +2 -4
- package/cjs/domain/replay/record/viewports.js.map +1 -1
- package/cjs/domain/replay/replayStats.js +2 -2
- package/cjs/domain/replay/replayStats.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segment.js +3 -3
- package/cjs/domain/replay/segmentCollection/segment.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +42 -17
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/replay/startRecordBridge.js +19 -0
- package/cjs/domain/replay/startRecordBridge.js.map +1 -0
- package/cjs/domain/requestCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/clickChain.js +2 -4
- package/cjs/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js +1 -2
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +1 -2
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js +2 -4
- package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +2 -2
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/errorCollection.js +12 -1
- package/cjs/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +2 -5
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/interactionCountPolyfill.js +1 -2
- package/cjs/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js +27 -10
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +18 -12
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/rumSessionManager.js +92 -32
- package/cjs/domain/rumSessionManager.js.map +1 -1
- package/cjs/domain/tracing/ddtraceTracer.js.map +1 -1
- package/cjs/domain/tracing/getDocumentTraceId.js +1 -2
- package/cjs/domain/tracing/getDocumentTraceId.js.map +1 -1
- package/cjs/domain/tracing/jaegerTracer.js.map +1 -1
- package/cjs/domain/tracing/sampler.js +69 -0
- package/cjs/domain/tracing/sampler.js.map +1 -0
- package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
- package/cjs/domain/tracing/traceIdentifier.js.map +1 -1
- package/cjs/domain/tracing/tracer.js +8 -2
- package/cjs/domain/tracing/tracer.js.map +1 -1
- package/cjs/domain/tracing/w3cTraceParentTracer.js.map +1 -1
- package/cjs/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/cjs/domain/tracing/zipkinSingleTracer.js.map +1 -1
- package/cjs/domain/trackEventCounts.js.map +1 -1
- package/cjs/domain/usr/index.js +3 -6
- package/cjs/domain/usr/index.js.map +1 -1
- package/cjs/domain/waitPageActivityEnd.js +2 -4
- package/cjs/domain/waitPageActivityEnd.js.map +1 -1
- package/cjs/types/sessionReplayConstants.js +5 -10
- package/cjs/types/sessionReplayConstants.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/perStartRum.js +10 -3
- package/esm/boot/perStartRum.js.map +1 -1
- package/esm/boot/recorderApi.js +2 -2
- package/esm/boot/recorderApi.js.map +1 -1
- package/esm/boot/rum.js +1 -1
- package/esm/boot/rum.js.map +1 -1
- package/esm/boot/rumPublicApi.js +1 -1
- package/esm/boot/rumPublicApi.js.map +1 -1
- package/esm/boot/startRecording.js +57 -9
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/domain/assembly.js +16 -8
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/configuration.js +13 -3
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/contexts/displayContext.js.map +1 -1
- package/esm/domain/contexts/foregroundContexts.js.map +1 -1
- package/esm/domain/contexts/internalContext.js.map +1 -1
- package/esm/domain/contexts/pageStateHistory.js.map +1 -1
- package/esm/domain/contexts/urlContexts.js.map +1 -1
- package/esm/domain/contexts/viewContexts.js.map +1 -1
- package/esm/domain/deflate/deflateEncoder.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/firstInputPolyfill.js.map +1 -1
- package/esm/domain/locationChangeObservable.js.map +1 -1
- package/esm/domain/performanceObservable.js +2 -1
- package/esm/domain/performanceObservable.js.map +1 -1
- package/esm/domain/performanceUtils.js.map +1 -1
- package/esm/domain/replay/record/elementsScrollPositions.js.map +1 -1
- package/esm/domain/replay/record/mutationBatch.js.map +1 -1
- package/esm/domain/replay/record/mutationObserver.js +2 -2
- package/esm/domain/replay/record/mutationObserver.js.map +1 -1
- package/esm/domain/replay/record/observers.js +31 -32
- package/esm/domain/replay/record/observers.js.map +1 -1
- package/esm/domain/replay/record/privacy.js +4 -3
- package/esm/domain/replay/record/privacy.js.map +1 -1
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/record/serializationUtils.js +2 -2
- package/esm/domain/replay/record/serializationUtils.js.map +1 -1
- package/esm/domain/replay/record/serialize.js +7 -8
- package/esm/domain/replay/record/serialize.js.map +1 -1
- package/esm/domain/replay/record/shadowRootsController.js +1 -1
- package/esm/domain/replay/record/shadowRootsController.js.map +1 -1
- package/esm/domain/replay/replayStats.js +1 -1
- package/esm/domain/replay/replayStats.js.map +1 -1
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +39 -13
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/replay/startRecordBridge.js +13 -0
- package/esm/domain/replay/startRecordBridge.js.map +1 -0
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js +12 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +0 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js +28 -11
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +15 -6
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumSessionManager.js +89 -26
- package/esm/domain/rumSessionManager.js.map +1 -1
- package/esm/domain/tracing/ddtraceTracer.js.map +1 -1
- package/esm/domain/tracing/jaegerTracer.js.map +1 -1
- package/esm/domain/tracing/sampler.js +61 -0
- package/esm/domain/tracing/sampler.js.map +1 -0
- package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
- package/esm/domain/tracing/traceIdentifier.js.map +1 -1
- package/esm/domain/tracing/tracer.js +8 -2
- package/esm/domain/tracing/tracer.js.map +1 -1
- package/esm/domain/tracing/w3cTraceParentTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinSingleTracer.js.map +1 -1
- package/esm/domain/trackEventCounts.js.map +1 -1
- package/esm/domain/usr/index.js.map +1 -1
- package/esm/types/sessionReplayConstants.js +0 -1
- package/esm/types/sessionReplayConstants.js.map +1 -1
- package/package.json +35 -35
- package/src/boot/perStartRum.js +13 -4
- package/src/boot/recorderApi.js +6 -2
- package/src/boot/rum.js +1 -0
- package/src/boot/rumPublicApi.js +0 -1
- package/src/boot/startRecording.js +69 -17
- package/src/domain/assembly.js +20 -3
- package/src/domain/configuration.js +36 -3
- package/src/domain/performanceObservable.js +2 -1
- package/src/domain/replay/record/mutationObserver.js +12 -2
- package/src/domain/replay/record/observers.js +43 -28
- package/src/domain/replay/record/privacy.js +8 -2
- package/src/domain/replay/record/serializationUtils.js +2 -2
- package/src/domain/replay/record/serialize.js +9 -2
- package/src/domain/replay/record/shadowRootsController.js +1 -1
- package/src/domain/replay/replayStats.js +1 -1
- package/src/domain/replay/segmentCollection/segmentCollection.js +47 -20
- package/src/domain/replay/startRecordBridge.js +14 -0
- package/src/domain/rumEventsCollection/error/errorCollection.js +12 -0
- package/src/domain/rumEventsCollection/view/trackFirstHidden.js +31 -22
- package/src/domain/rumEventsCollection/view/trackViews.js +18 -9
- package/src/domain/rumSessionManager.js +129 -34
- package/src/domain/tracing/sampler.js +65 -0
- package/src/domain/tracing/tracer.js +11 -5
|
@@ -27,12 +27,31 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
27
27
|
var requireParamsValidate =
|
|
28
28
|
validatePostRequestRequireParamsConfiguration(initConfiguration)
|
|
29
29
|
if (!requireParamsValidate) return
|
|
30
|
-
|
|
30
|
+
if (
|
|
31
|
+
initConfiguration.sessionOnErrorSampleRate !== undefined &&
|
|
32
|
+
!isPercentage(initConfiguration.sessionOnErrorSampleRate)
|
|
33
|
+
) {
|
|
34
|
+
display.error(
|
|
35
|
+
'Error Session Sample Rate should be a number between 0 and 100'
|
|
36
|
+
)
|
|
37
|
+
return
|
|
38
|
+
}
|
|
31
39
|
if (
|
|
32
40
|
initConfiguration.sessionReplaySampleRate !== undefined &&
|
|
33
41
|
!isPercentage(initConfiguration.sessionReplaySampleRate)
|
|
34
42
|
) {
|
|
35
|
-
display.error(
|
|
43
|
+
display.error(
|
|
44
|
+
'Session Replay Sample Rate should be a number between 0 and 100'
|
|
45
|
+
)
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
if (
|
|
49
|
+
initConfiguration.sessionReplayOnErrorSampleRate !== undefined &&
|
|
50
|
+
!isPercentage(initConfiguration.sessionReplayOnErrorSampleRate)
|
|
51
|
+
) {
|
|
52
|
+
display.error(
|
|
53
|
+
'Error Session Replay Sample Rate should be a number between 0 and 100'
|
|
54
|
+
)
|
|
36
55
|
return
|
|
37
56
|
}
|
|
38
57
|
var allowedTracingUrls = validateAndBuildTracingOptions(initConfiguration)
|
|
@@ -82,6 +101,14 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
82
101
|
initConfiguration.sessionReplaySampleRate,
|
|
83
102
|
100
|
|
84
103
|
),
|
|
104
|
+
sessionOnErrorSampleRate: isNullUndefinedDefaultValue(
|
|
105
|
+
initConfiguration.sessionOnErrorSampleRate,
|
|
106
|
+
0
|
|
107
|
+
),
|
|
108
|
+
sessionReplayOnErrorSampleRate: isNullUndefinedDefaultValue(
|
|
109
|
+
initConfiguration.sessionReplayOnErrorSampleRate,
|
|
110
|
+
0
|
|
111
|
+
),
|
|
85
112
|
tracingSampleRate: initConfiguration.tracingSampleRate,
|
|
86
113
|
allowedTracingUrls: allowedTracingUrls,
|
|
87
114
|
injectTraceHeader:
|
|
@@ -115,7 +142,13 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
115
142
|
initConfiguration.defaultPrivacyLevel
|
|
116
143
|
)
|
|
117
144
|
? initConfiguration.defaultPrivacyLevel
|
|
118
|
-
: DefaultPrivacyLevel.MASK_USER_INPUT
|
|
145
|
+
: DefaultPrivacyLevel.MASK_USER_INPUT,
|
|
146
|
+
shouldMaskNode:
|
|
147
|
+
initConfiguration.shouldMaskNode &&
|
|
148
|
+
catchUserErrors(
|
|
149
|
+
initConfiguration.shouldMaskNode,
|
|
150
|
+
'shouldMaskNode threw an error:'
|
|
151
|
+
)
|
|
119
152
|
},
|
|
120
153
|
baseConfiguration,
|
|
121
154
|
buildEnv
|
|
@@ -23,7 +23,8 @@ export var RumPerformanceEntryType = {
|
|
|
23
23
|
LONG_ANIMATION_FRAME: 'long-animation-frame',
|
|
24
24
|
NAVIGATION: 'navigation',
|
|
25
25
|
PAINT: 'paint',
|
|
26
|
-
RESOURCE: 'resource'
|
|
26
|
+
RESOURCE: 'resource',
|
|
27
|
+
VISIBILITY_STATE: 'visibility-state'
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export function createPerformanceObservable(configuration, options) {
|
|
@@ -324,7 +324,13 @@ function processCharacterDataMutations(
|
|
|
324
324
|
textMutations.push({
|
|
325
325
|
id: getSerializedNodeId(mutation.target),
|
|
326
326
|
value: isNullUndefinedDefaultValue(
|
|
327
|
-
getTextContent(
|
|
327
|
+
getTextContent(
|
|
328
|
+
configuration,
|
|
329
|
+
mutation.target,
|
|
330
|
+
false,
|
|
331
|
+
parentNodePrivacyLevel,
|
|
332
|
+
null
|
|
333
|
+
)
|
|
328
334
|
)
|
|
329
335
|
})
|
|
330
336
|
}
|
|
@@ -380,7 +386,11 @@ function processAttributesMutations(
|
|
|
380
386
|
|
|
381
387
|
var transformedValue
|
|
382
388
|
if (mutation.attributeName === 'value') {
|
|
383
|
-
var inputValue = getElementInputValue(
|
|
389
|
+
var inputValue = getElementInputValue(
|
|
390
|
+
configuration,
|
|
391
|
+
mutation.target,
|
|
392
|
+
privacyLevel
|
|
393
|
+
)
|
|
384
394
|
if (inputValue === undefined) {
|
|
385
395
|
continue
|
|
386
396
|
}
|
|
@@ -61,31 +61,39 @@ export function initObservers(o) {
|
|
|
61
61
|
o.configuration,
|
|
62
62
|
o.shadowRootsController
|
|
63
63
|
)
|
|
64
|
-
var mousemoveHandler = initMoveObserver(o.mousemoveCb)
|
|
64
|
+
var mousemoveHandler = initMoveObserver(o.mousemoveCb, o.configuration)
|
|
65
65
|
var mouseInteractionHandler = initMouseInteractionObserver(
|
|
66
66
|
o.mouseInteractionCb,
|
|
67
|
-
o.configuration
|
|
67
|
+
o.configuration
|
|
68
68
|
)
|
|
69
69
|
var scrollHandler = initScrollObserver(
|
|
70
70
|
o.scrollCb,
|
|
71
|
-
o.configuration
|
|
71
|
+
o.configuration,
|
|
72
72
|
o.elementsScrollPositions
|
|
73
73
|
)
|
|
74
|
-
var viewportResizeHandler = initViewportResizeObserver(
|
|
75
|
-
|
|
76
|
-
o.
|
|
77
|
-
o.configuration.defaultPrivacyLevel
|
|
74
|
+
var viewportResizeHandler = initViewportResizeObserver(
|
|
75
|
+
o.viewportResizeCb,
|
|
76
|
+
o.configuration
|
|
78
77
|
)
|
|
78
|
+
var inputHandler = initInputObserver(o.inputCb, o.configuration)
|
|
79
79
|
var mediaInteractionHandler = initMediaInteractionObserver(
|
|
80
80
|
o.mediaInteractionCb,
|
|
81
|
-
o.configuration
|
|
81
|
+
o.configuration
|
|
82
|
+
)
|
|
83
|
+
var styleSheetObserver = initStyleSheetObserver(
|
|
84
|
+
o.styleSheetCb,
|
|
85
|
+
o.configuration
|
|
82
86
|
)
|
|
83
|
-
var
|
|
84
|
-
var focusHandler = initFocusObserver(o.focusCb)
|
|
87
|
+
var focusHandler = initFocusObserver(o.focusCb, o.configuration)
|
|
85
88
|
var visualViewportResizeHandler = initVisualViewportResizeObserver(
|
|
86
|
-
o.visualViewportResizeCb
|
|
89
|
+
o.visualViewportResizeCb,
|
|
90
|
+
o.configuration
|
|
91
|
+
)
|
|
92
|
+
var frustrationHandler = initFrustrationObserver(
|
|
93
|
+
o.lifeCycle,
|
|
94
|
+
o.frustrationCb,
|
|
95
|
+
o.configuration
|
|
87
96
|
)
|
|
88
|
-
var frustrationHandler = initFrustrationObserver(o.lifeCycle, o.frustrationCb)
|
|
89
97
|
|
|
90
98
|
return {
|
|
91
99
|
flush: function () {
|
|
@@ -116,7 +124,7 @@ export function initMutationObserver(cb, configuration, shadowRootsController) {
|
|
|
116
124
|
)
|
|
117
125
|
}
|
|
118
126
|
|
|
119
|
-
export function initMoveObserver(cb) {
|
|
127
|
+
export function initMoveObserver(cb, configuration) {
|
|
120
128
|
var _updatePosition = throttle(
|
|
121
129
|
function (event) {
|
|
122
130
|
var target = getEventTarget(event)
|
|
@@ -184,11 +192,11 @@ var eventTypeToMouseInteraction = {
|
|
|
184
192
|
[DOM_EVENT.TOUCH_START]: MouseInteractionType.TouchStart,
|
|
185
193
|
[DOM_EVENT.TOUCH_END]: MouseInteractionType.TouchEnd
|
|
186
194
|
}
|
|
187
|
-
export function initMouseInteractionObserver(cb,
|
|
195
|
+
export function initMouseInteractionObserver(cb, configuration) {
|
|
188
196
|
var handler = function (event) {
|
|
189
197
|
var target = getEventTarget(event)
|
|
190
198
|
if (
|
|
191
|
-
getNodePrivacyLevel(target, defaultPrivacyLevel) ===
|
|
199
|
+
getNodePrivacyLevel(target, configuration.defaultPrivacyLevel) ===
|
|
192
200
|
NodePrivacyLevel.HIDDEN ||
|
|
193
201
|
!hasSerializedNode(target)
|
|
194
202
|
) {
|
|
@@ -247,12 +255,12 @@ function tryToComputeCoordinates(event) {
|
|
|
247
255
|
return { x: x, y: y }
|
|
248
256
|
}
|
|
249
257
|
|
|
250
|
-
function initScrollObserver(cb,
|
|
258
|
+
function initScrollObserver(cb, configuration, elementsScrollPositions) {
|
|
251
259
|
var _updatePosition = throttle(function (event) {
|
|
252
260
|
var target = getEventTarget(event)
|
|
253
261
|
if (
|
|
254
262
|
!target ||
|
|
255
|
-
getNodePrivacyLevel(target, defaultPrivacyLevel) ===
|
|
263
|
+
getNodePrivacyLevel(target, configuration.defaultPrivacyLevel) ===
|
|
256
264
|
NodePrivacyLevel.HIDDEN ||
|
|
257
265
|
!hasSerializedNode(target)
|
|
258
266
|
) {
|
|
@@ -290,11 +298,11 @@ function initScrollObserver(cb, defaultPrivacyLevel, elementsScrollPositions) {
|
|
|
290
298
|
}
|
|
291
299
|
}
|
|
292
300
|
|
|
293
|
-
function initViewportResizeObserver(cb) {
|
|
301
|
+
function initViewportResizeObserver(cb, configuration) {
|
|
294
302
|
return initViewportObservable().subscribe(cb).unsubscribe
|
|
295
303
|
}
|
|
296
304
|
|
|
297
|
-
export function initInputObserver(cb,
|
|
305
|
+
export function initInputObserver(cb, configuration, target) {
|
|
298
306
|
if (target === undefined) {
|
|
299
307
|
target = document
|
|
300
308
|
}
|
|
@@ -351,7 +359,10 @@ export function initInputObserver(cb, defaultPrivacyLevel, target) {
|
|
|
351
359
|
}
|
|
352
360
|
|
|
353
361
|
function onElementChange(target) {
|
|
354
|
-
var nodePrivacyLevel = getNodePrivacyLevel(
|
|
362
|
+
var nodePrivacyLevel = getNodePrivacyLevel(
|
|
363
|
+
target,
|
|
364
|
+
configuration.defaultPrivacyLevel
|
|
365
|
+
)
|
|
355
366
|
if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
|
|
356
367
|
return
|
|
357
368
|
}
|
|
@@ -360,12 +371,12 @@ export function initInputObserver(cb, defaultPrivacyLevel, target) {
|
|
|
360
371
|
|
|
361
372
|
let inputState
|
|
362
373
|
if (type === 'radio' || type === 'checkbox') {
|
|
363
|
-
if (shouldMaskNode(target, nodePrivacyLevel)) {
|
|
374
|
+
if (shouldMaskNode(configuration, target, nodePrivacyLevel)) {
|
|
364
375
|
return
|
|
365
376
|
}
|
|
366
377
|
inputState = { isChecked: target.checked }
|
|
367
378
|
} else {
|
|
368
|
-
var value = getElementInputValue(target, nodePrivacyLevel)
|
|
379
|
+
var value = getElementInputValue(configuration, target, nodePrivacyLevel)
|
|
369
380
|
if (value === undefined) {
|
|
370
381
|
return
|
|
371
382
|
}
|
|
@@ -417,7 +428,7 @@ export function initInputObserver(cb, defaultPrivacyLevel, target) {
|
|
|
417
428
|
}
|
|
418
429
|
}
|
|
419
430
|
|
|
420
|
-
export function initStyleSheetObserver(cb) {
|
|
431
|
+
export function initStyleSheetObserver(cb, configuration) {
|
|
421
432
|
function checkStyleSheetAndCallback(styleSheet, callback) {
|
|
422
433
|
if (styleSheet && hasSerializedNode(styleSheet.ownerNode)) {
|
|
423
434
|
callback(getSerializedNodeId(styleSheet.ownerNode))
|
|
@@ -488,12 +499,12 @@ export function initStyleSheetObserver(cb) {
|
|
|
488
499
|
}
|
|
489
500
|
}
|
|
490
501
|
|
|
491
|
-
function initMediaInteractionObserver(mediaInteractionCb,
|
|
502
|
+
function initMediaInteractionObserver(mediaInteractionCb, configuration) {
|
|
492
503
|
var handler = function (event) {
|
|
493
504
|
var target = getEventTarget(event)
|
|
494
505
|
if (
|
|
495
506
|
!target ||
|
|
496
|
-
getNodePrivacyLevel(target, defaultPrivacyLevel) ===
|
|
507
|
+
getNodePrivacyLevel(target, configuration.defaultPrivacyLevel) ===
|
|
497
508
|
NodePrivacyLevel.HIDDEN ||
|
|
498
509
|
!hasSerializedNode(target)
|
|
499
510
|
) {
|
|
@@ -515,7 +526,7 @@ function initMediaInteractionObserver(mediaInteractionCb, defaultPrivacyLevel) {
|
|
|
515
526
|
).stop
|
|
516
527
|
}
|
|
517
528
|
|
|
518
|
-
function initFocusObserver(focusCb) {
|
|
529
|
+
function initFocusObserver(focusCb, configuration) {
|
|
519
530
|
return addEventListeners(
|
|
520
531
|
window,
|
|
521
532
|
[DOM_EVENT.FOCUS, DOM_EVENT.BLUR],
|
|
@@ -525,7 +536,7 @@ function initFocusObserver(focusCb) {
|
|
|
525
536
|
).stop
|
|
526
537
|
}
|
|
527
538
|
|
|
528
|
-
function initVisualViewportResizeObserver(cb) {
|
|
539
|
+
function initVisualViewportResizeObserver(cb, configuration) {
|
|
529
540
|
if (!window.visualViewport) {
|
|
530
541
|
return noop
|
|
531
542
|
}
|
|
@@ -554,7 +565,11 @@ function initVisualViewportResizeObserver(cb) {
|
|
|
554
565
|
}
|
|
555
566
|
}
|
|
556
567
|
|
|
557
|
-
export function initFrustrationObserver(
|
|
568
|
+
export function initFrustrationObserver(
|
|
569
|
+
lifeCycle,
|
|
570
|
+
frustrationCb,
|
|
571
|
+
configuration
|
|
572
|
+
) {
|
|
558
573
|
return lifeCycle.subscribe(
|
|
559
574
|
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,
|
|
560
575
|
function (data) {
|
|
@@ -151,7 +151,12 @@ export function getNodeSelfPrivacyLevel(node) {
|
|
|
151
151
|
* Other `shouldMaskNode` cases are edge cases that should not matter too much (ex: should we mask a
|
|
152
152
|
* node if it is ignored or hidden? it doesn't matter since it won't be serialized).
|
|
153
153
|
*/
|
|
154
|
-
export function shouldMaskNode(node, privacyLevel) {
|
|
154
|
+
export function shouldMaskNode(configuration, node, privacyLevel) {
|
|
155
|
+
if (
|
|
156
|
+
configuration.shouldMaskNode &&
|
|
157
|
+
configuration.shouldMaskNode(node, privacyLevel) === true
|
|
158
|
+
)
|
|
159
|
+
return true
|
|
155
160
|
switch (privacyLevel) {
|
|
156
161
|
case NodePrivacyLevel.MASK:
|
|
157
162
|
case NodePrivacyLevel.HIDDEN:
|
|
@@ -192,6 +197,7 @@ export var censorText = function (text) {
|
|
|
192
197
|
}
|
|
193
198
|
|
|
194
199
|
export function getTextContent(
|
|
200
|
+
configuration,
|
|
195
201
|
textNode,
|
|
196
202
|
ignoreWhiteSpace,
|
|
197
203
|
parentNodePrivacyLevel
|
|
@@ -216,7 +222,7 @@ export function getTextContent(
|
|
|
216
222
|
} else if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
|
|
217
223
|
// Should never occur, but just in case, we set to CENSORED_MARK.
|
|
218
224
|
textContent = CENSORED_STRING_MARK
|
|
219
|
-
} else if (shouldMaskNode(textNode, nodePrivacyLevel)) {
|
|
225
|
+
} else if (shouldMaskNode(configuration, textNode, nodePrivacyLevel)) {
|
|
220
226
|
if (
|
|
221
227
|
// Scrambling the child list breaks text nodes for DATALIST/SELECT/OPTGROUP
|
|
222
228
|
parentTagName === 'DATALIST' ||
|
|
@@ -37,7 +37,7 @@ export function setSerializedNodeId(node, serializeNodeId) {
|
|
|
37
37
|
* the input privacy mode of the element.
|
|
38
38
|
* PERFROMANCE OPTIMIZATION: Assumes that privacy level `HIDDEN` is never encountered because of earlier checks.
|
|
39
39
|
*/
|
|
40
|
-
export function getElementInputValue(element, nodePrivacyLevel) {
|
|
40
|
+
export function getElementInputValue(configuration, element, nodePrivacyLevel) {
|
|
41
41
|
/*
|
|
42
42
|
BROWSER SPEC NOTE: <input>, <select>
|
|
43
43
|
For some <input> elements, the `value` is an exceptional property/attribute that has the
|
|
@@ -46,7 +46,7 @@ export function getElementInputValue(element, nodePrivacyLevel) {
|
|
|
46
46
|
*/
|
|
47
47
|
var tagName = element.tagName
|
|
48
48
|
var value = element.value
|
|
49
|
-
if (shouldMaskNode(element, nodePrivacyLevel)) {
|
|
49
|
+
if (shouldMaskNode(configuration, element, nodePrivacyLevel)) {
|
|
50
50
|
var type = element.type
|
|
51
51
|
if (
|
|
52
52
|
tagName === 'INPUT' &&
|
|
@@ -228,6 +228,7 @@ function serializeTextNode(textNode, options) {
|
|
|
228
228
|
// So just let it be undefined which is ok in this use case.
|
|
229
229
|
// var parentTagName = textNode.parentElement && textNode.parentElement.tagName
|
|
230
230
|
var textContent = getTextContent(
|
|
231
|
+
options.configuration,
|
|
231
232
|
textNode,
|
|
232
233
|
options.ignoreWhiteSpace || false,
|
|
233
234
|
options.parentNodePrivacyLevel
|
|
@@ -407,7 +408,11 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
|
407
408
|
tagName === 'option' ||
|
|
408
409
|
tagName === 'input')
|
|
409
410
|
) {
|
|
410
|
-
var formValue = getElementInputValue(
|
|
411
|
+
var formValue = getElementInputValue(
|
|
412
|
+
options.configuration,
|
|
413
|
+
element,
|
|
414
|
+
nodePrivacyLevel
|
|
415
|
+
)
|
|
411
416
|
if (formValue !== undefined) {
|
|
412
417
|
safeAttrs.value = formValue
|
|
413
418
|
}
|
|
@@ -459,7 +464,9 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
|
459
464
|
) {
|
|
460
465
|
if (nodePrivacyLevel === NodePrivacyLevel.ALLOW) {
|
|
461
466
|
safeAttrs.checked = !!inputElement.checked
|
|
462
|
-
} else if (
|
|
467
|
+
} else if (
|
|
468
|
+
shouldMaskNode(options.configuration, inputElement, nodePrivacyLevel)
|
|
469
|
+
) {
|
|
463
470
|
delete safeAttrs.checked
|
|
464
471
|
}
|
|
465
472
|
}
|
|
@@ -23,7 +23,7 @@ export var initShadowRootsController = function (configuration, data) {
|
|
|
23
23
|
// the change event no do bubble up across the shadow root, we have to listen on the shadow root
|
|
24
24
|
var stopInputObserver = initInputObserver(
|
|
25
25
|
inputCb,
|
|
26
|
-
configuration
|
|
26
|
+
configuration,
|
|
27
27
|
shadowRoot
|
|
28
28
|
)
|
|
29
29
|
controllerByShadowRoot.set(shadowRoot, {
|
|
@@ -46,7 +46,8 @@ export function startSegmentCollection(
|
|
|
46
46
|
sessionManager,
|
|
47
47
|
viewContexts,
|
|
48
48
|
httpRequest,
|
|
49
|
-
encoder
|
|
49
|
+
encoder,
|
|
50
|
+
isLocked = false
|
|
50
51
|
) {
|
|
51
52
|
return doStartSegmentCollection(
|
|
52
53
|
lifeCycle,
|
|
@@ -54,7 +55,8 @@ export function startSegmentCollection(
|
|
|
54
55
|
return computeSegmentContext(configuration, sessionManager, viewContexts)
|
|
55
56
|
},
|
|
56
57
|
httpRequest,
|
|
57
|
-
encoder
|
|
58
|
+
encoder,
|
|
59
|
+
isLocked
|
|
58
60
|
)
|
|
59
61
|
}
|
|
60
62
|
|
|
@@ -68,11 +70,13 @@ export function doStartSegmentCollection(
|
|
|
68
70
|
lifeCycle,
|
|
69
71
|
getSegmentContext,
|
|
70
72
|
httpRequest,
|
|
71
|
-
encoder
|
|
73
|
+
encoder,
|
|
74
|
+
isLocked
|
|
72
75
|
) {
|
|
73
76
|
var state = {
|
|
74
77
|
status: SegmentCollectionStatus.WaitingForInitialRecord,
|
|
75
|
-
nextSegmentCreationReason: 'init'
|
|
78
|
+
nextSegmentCreationReason: 'init',
|
|
79
|
+
isLocked: isLocked
|
|
76
80
|
}
|
|
77
81
|
var subscribeViewCreated = lifeCycle.subscribe(
|
|
78
82
|
LifeCycleEventType.VIEW_CREATED,
|
|
@@ -88,33 +92,46 @@ export function doStartSegmentCollection(
|
|
|
88
92
|
}
|
|
89
93
|
)
|
|
90
94
|
var unsubscribePageExited = subscribePageExited.unsubscribe
|
|
91
|
-
|
|
92
|
-
function flushSegment(flushReason) {
|
|
95
|
+
const lockedFlushReason = ['view_change', 'buffer_checkout']
|
|
96
|
+
function flushSegment(flushReason, callback) {
|
|
97
|
+
const isLocked = state.isLocked
|
|
93
98
|
if (state.status === SegmentCollectionStatus.SegmentPending) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
httpRequest.sendOnExit(payload)
|
|
103
|
-
} else {
|
|
104
|
-
httpRequest.send(payload)
|
|
99
|
+
if (isLocked && lockedFlushReason.includes(flushReason)) {
|
|
100
|
+
state.segment.flush(() => {
|
|
101
|
+
if (callback) callback()
|
|
102
|
+
})
|
|
103
|
+
} else {
|
|
104
|
+
// if the segment is locked, we don't send it
|
|
105
|
+
if (isLocked) {
|
|
106
|
+
return
|
|
105
107
|
}
|
|
106
|
-
|
|
108
|
+
state.segment.flush(function (metadata, encoderResult) {
|
|
109
|
+
var payload = buildReplayPayload(
|
|
110
|
+
encoderResult.output,
|
|
111
|
+
metadata,
|
|
112
|
+
encoderResult.rawBytesCount
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
if (isPageExitReason(flushReason)) {
|
|
116
|
+
httpRequest.sendOnExit(payload)
|
|
117
|
+
} else {
|
|
118
|
+
httpRequest.send(payload)
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
}
|
|
107
122
|
clearTimeout(state.expirationTimeoutId)
|
|
108
123
|
}
|
|
109
124
|
|
|
110
125
|
if (flushReason !== 'stop') {
|
|
111
126
|
state = {
|
|
112
127
|
status: SegmentCollectionStatus.WaitingForInitialRecord,
|
|
113
|
-
nextSegmentCreationReason: flushReason
|
|
128
|
+
nextSegmentCreationReason: flushReason,
|
|
129
|
+
isLocked: state.isLocked
|
|
114
130
|
}
|
|
115
131
|
} else {
|
|
116
132
|
state = {
|
|
117
|
-
status: SegmentCollectionStatus.Stopped
|
|
133
|
+
status: SegmentCollectionStatus.Stopped,
|
|
134
|
+
isLocked: false
|
|
118
135
|
}
|
|
119
136
|
}
|
|
120
137
|
}
|
|
@@ -138,6 +155,7 @@ export function doStartSegmentCollection(
|
|
|
138
155
|
context: context,
|
|
139
156
|
creationReason: state.nextSegmentCreationReason
|
|
140
157
|
}),
|
|
158
|
+
isLocked: state.isLocked,
|
|
141
159
|
expirationTimeoutId: setTimeout(function () {
|
|
142
160
|
flushSegment('segment_duration_limit')
|
|
143
161
|
}, SEGMENT_DURATION_LIMIT)
|
|
@@ -151,6 +169,15 @@ export function doStartSegmentCollection(
|
|
|
151
169
|
})
|
|
152
170
|
},
|
|
153
171
|
|
|
172
|
+
unlockSegment: function () {
|
|
173
|
+
state.isLocked = false
|
|
174
|
+
},
|
|
175
|
+
flushBufferSegment: function (callback) {
|
|
176
|
+
flushSegment('buffer_checkout', callback)
|
|
177
|
+
},
|
|
178
|
+
isLocked: function () {
|
|
179
|
+
return state.isLocked
|
|
180
|
+
},
|
|
154
181
|
stop: function () {
|
|
155
182
|
flushSegment('stop')
|
|
156
183
|
unsubscribeViewCreated()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getEventBridge } from '@cloudcare/browser-core'
|
|
2
|
+
|
|
3
|
+
export function startRecordBridge(viewHistory) {
|
|
4
|
+
const bridge = getEventBridge()
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
addRecord: (record) => {
|
|
8
|
+
// Get the current active view, not at the time of the record, aligning with the segment logic.
|
|
9
|
+
// This approach could potentially associate the record to an incorrect view, in case the record date is in the past (e.g. frustration records).
|
|
10
|
+
const view = viewHistory.findView()
|
|
11
|
+
bridge.send('session_replay', record, view.id)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -18,6 +18,7 @@ import { PageState } from '../../contexts/pageStateHistory'
|
|
|
18
18
|
export function startErrorCollection(
|
|
19
19
|
lifeCycle,
|
|
20
20
|
configuration,
|
|
21
|
+
sessionManager,
|
|
21
22
|
pageStateHistory
|
|
22
23
|
) {
|
|
23
24
|
var errorObservable = new Observable()
|
|
@@ -25,8 +26,19 @@ export function startErrorCollection(
|
|
|
25
26
|
trackConsoleError(errorObservable)
|
|
26
27
|
trackRuntimeError(errorObservable)
|
|
27
28
|
trackReportError(configuration, errorObservable)
|
|
29
|
+
var session = sessionManager.findTrackedSession()
|
|
30
|
+
let hasError = session.isErrorSession && session.sessionHasError
|
|
31
|
+
if (session.isErrorSession) {
|
|
32
|
+
lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, function () {
|
|
33
|
+
hasError = false
|
|
34
|
+
})
|
|
35
|
+
}
|
|
28
36
|
|
|
29
37
|
errorObservable.subscribe(function (error) {
|
|
38
|
+
if (session.isErrorSession && !hasError) {
|
|
39
|
+
sessionManager.setErrorForSession()
|
|
40
|
+
hasError = true
|
|
41
|
+
}
|
|
30
42
|
lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error })
|
|
31
43
|
})
|
|
32
44
|
|
|
@@ -1,37 +1,46 @@
|
|
|
1
|
-
import { DOM_EVENT, addEventListeners } from '@cloudcare/browser-core'
|
|
2
|
-
|
|
1
|
+
import { DOM_EVENT, addEventListeners, noop } from '@cloudcare/browser-core'
|
|
2
|
+
import {
|
|
3
|
+
supportPerformanceTimingEvent,
|
|
4
|
+
RumPerformanceEntryType
|
|
5
|
+
} from '../../../domain/performanceObservable.js'
|
|
3
6
|
export function trackFirstHidden(eventTarget) {
|
|
4
7
|
if (typeof eventTarget === 'undefined') {
|
|
5
8
|
eventTarget = window
|
|
6
9
|
}
|
|
7
|
-
var timeStamp
|
|
8
|
-
var stopListeners
|
|
9
10
|
if (document.visibilityState === 'hidden') {
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
document.visibilityState === 'hidden'
|
|
20
|
-
) {
|
|
21
|
-
timeStamp = event.timeStamp
|
|
22
|
-
stopListeners()
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
{ capture: true }
|
|
26
|
-
).stop
|
|
11
|
+
return { getTimeStamp: () => 0, stop: noop }
|
|
12
|
+
}
|
|
13
|
+
if (supportPerformanceTimingEvent(RumPerformanceEntryType.VISIBILITY_STATE)) {
|
|
14
|
+
const firstHiddenEntry = performance
|
|
15
|
+
.getEntriesByType(RumPerformanceEntryType.VISIBILITY_STATE)
|
|
16
|
+
.find((entry) => entry.name === 'hidden')
|
|
17
|
+
if (firstHiddenEntry) {
|
|
18
|
+
return { getTimeStamp: () => firstHiddenEntry.startTime, stop: noop }
|
|
19
|
+
}
|
|
27
20
|
}
|
|
21
|
+
let timeStamp = Infinity
|
|
22
|
+
|
|
23
|
+
const { stop } = addEventListeners(
|
|
24
|
+
eventTarget,
|
|
25
|
+
[DOM_EVENT.PAGE_HIDE, DOM_EVENT.VISIBILITY_CHANGE],
|
|
26
|
+
(event) => {
|
|
27
|
+
if (
|
|
28
|
+
event.type === DOM_EVENT.PAGE_HIDE ||
|
|
29
|
+
document.visibilityState === 'hidden'
|
|
30
|
+
) {
|
|
31
|
+
timeStamp = event.timeStamp
|
|
32
|
+
stop()
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{ capture: true }
|
|
36
|
+
)
|
|
28
37
|
|
|
29
38
|
return {
|
|
30
39
|
getTimeStamp: function () {
|
|
31
40
|
return timeStamp
|
|
32
41
|
},
|
|
33
42
|
stop: function () {
|
|
34
|
-
|
|
43
|
+
stop()
|
|
35
44
|
}
|
|
36
45
|
}
|
|
37
46
|
}
|
|
@@ -79,15 +79,15 @@ export function trackViews(
|
|
|
79
79
|
lifeCycle.subscribe(LifeCycleEventType.SESSION_EXPIRED, function () {
|
|
80
80
|
currentView.end({ sessionIsActive: false })
|
|
81
81
|
})
|
|
82
|
-
// End the current view on page unload
|
|
83
|
-
lifeCycle.subscribe(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
)
|
|
82
|
+
// // End the current view on page unload
|
|
83
|
+
// lifeCycle.subscribe(
|
|
84
|
+
// LifeCycleEventType.PAGE_EXITED,
|
|
85
|
+
// function (pageExitEvent) {
|
|
86
|
+
// if (pageExitEvent.reason === PageExitReason.UNLOADING) {
|
|
87
|
+
// currentView.end()
|
|
88
|
+
// }
|
|
89
|
+
// }
|
|
90
|
+
// )
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
function renewViewOnLocationChange(locationChangeObservable) {
|
|
@@ -229,6 +229,14 @@ function newView(
|
|
|
229
229
|
triggerViewUpdate,
|
|
230
230
|
SESSION_KEEP_ALIVE_INTERVAL
|
|
231
231
|
)
|
|
232
|
+
const pageMayExitSubscription = lifeCycle.subscribe(
|
|
233
|
+
LifeCycleEventType.PAGE_EXITED,
|
|
234
|
+
(pageMayExitEvent) => {
|
|
235
|
+
if (pageMayExitEvent.reason === PageExitReason.UNLOADING) {
|
|
236
|
+
triggerViewUpdate()
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
)
|
|
232
240
|
triggerViewUpdate()
|
|
233
241
|
// View context update should always be throttled
|
|
234
242
|
contextManager.changeObservable.subscribe(scheduleViewUpdate)
|
|
@@ -297,6 +305,7 @@ function newView(
|
|
|
297
305
|
clearInterval(keepAliveIntervalId)
|
|
298
306
|
setViewEnd(endClocks.relative)
|
|
299
307
|
stopCommonViewMetricsTracking()
|
|
308
|
+
pageMayExitSubscription.unsubscribe()
|
|
300
309
|
triggerViewUpdate()
|
|
301
310
|
setTimeout(function () {
|
|
302
311
|
result.stop()
|