@cloudcare/browser-rum 3.1.2 → 3.1.5
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 +1 -1
- package/cjs/boot/rum.js +23 -3
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/boot/startRecording.js +1 -1
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/domain/assembly.js +6 -5
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/configuration.js +3 -7
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/contexts/displayContext.js +12 -18
- package/cjs/domain/contexts/displayContext.js.map +1 -1
- package/cjs/domain/performanceCollection.js +16 -10
- package/cjs/domain/performanceCollection.js.map +1 -1
- package/cjs/domain/replay/deflate/deflateWorker.js +1 -1
- package/cjs/domain/replay/record/privacy.js +0 -1
- package/cjs/domain/replay/record/privacy.js.map +1 -1
- package/cjs/domain/replay/record/serialize.js +12 -13
- package/cjs/domain/replay/record/serialize.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +10 -33
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/matchRequestTiming.js +2 -8
- package/cjs/domain/rumEventsCollection/resource/matchRequestTiming.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +53 -21
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js +11 -25
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +45 -2
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +2 -4
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js +22 -29
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/{trackFirstInputTimings.js → trackFirstInput.js} +12 -9
- package/cjs/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +18 -27
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +66 -11
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +11 -6
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js +10 -2
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js +55 -24
- package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +34 -12
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +34 -33
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/cjs/domain/trackEventCounts.js +4 -4
- package/cjs/domain/trackEventCounts.js.map +1 -1
- package/cjs/domain/waitPageActivityEnd.js.map +1 -1
- package/cjs/transport/startRumBatch.js +1 -1
- package/cjs/transport/startRumBatch.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/rum.js +23 -3
- package/esm/boot/rum.js.map +1 -1
- package/esm/boot/startRecording.js +1 -1
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/domain/assembly.js +6 -5
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/configuration.js +4 -8
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/contexts/displayContext.js +11 -16
- package/esm/domain/contexts/displayContext.js.map +1 -1
- package/esm/domain/performanceCollection.js +17 -10
- package/esm/domain/performanceCollection.js.map +1 -1
- package/esm/domain/replay/deflate/deflateWorker.js +1 -1
- package/esm/domain/replay/record/privacy.js +0 -1
- package/esm/domain/replay/record/privacy.js.map +1 -1
- package/esm/domain/replay/record/serialize.js +13 -14
- package/esm/domain/replay/record/serialize.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js +10 -33
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestTiming.js +3 -9
- package/esm/domain/rumEventsCollection/resource/matchRequestTiming.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +54 -22
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js +13 -27
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +47 -3
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +2 -4
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js +22 -28
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/{trackFirstInputTimings.js → trackFirstInput.js} +13 -9
- package/esm/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +19 -28
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +65 -12
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +12 -6
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js +10 -2
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js +55 -25
- package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +33 -12
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js +35 -34
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/domain/trackEventCounts.js +4 -4
- package/esm/domain/trackEventCounts.js.map +1 -1
- package/esm/domain/waitPageActivityEnd.js.map +1 -1
- package/esm/transport/startRumBatch.js +1 -1
- package/esm/transport/startRumBatch.js.map +1 -1
- package/package.json +4 -4
- package/src/boot/rum.js +27 -3
- package/src/boot/startRecording.js +1 -0
- package/src/domain/assembly.js +6 -4
- package/src/domain/configuration.js +5 -9
- package/src/domain/contexts/displayContext.js +11 -20
- package/src/domain/performanceCollection.js +21 -10
- package/src/domain/replay/record/privacy.js +1 -5
- package/src/domain/replay/record/serialize.js +13 -16
- package/src/domain/rumEventsCollection/actions/trackClickActions.js +7 -35
- package/src/domain/rumEventsCollection/resource/matchRequestTiming.js +4 -13
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +115 -29
- package/src/domain/rumEventsCollection/view/trackCommonViewMetrics.js +18 -35
- package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +59 -3
- package/src/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +2 -4
- package/src/domain/rumEventsCollection/view/trackFirstHidden.js +27 -32
- package/src/domain/rumEventsCollection/view/{trackFirstInputTimings.js → trackFirstInput.js} +25 -8
- package/src/domain/rumEventsCollection/view/trackInitialViewTimings.js +24 -28
- package/src/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +79 -15
- package/src/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +21 -6
- package/src/domain/rumEventsCollection/view/trackLoadingTime.js +10 -2
- package/src/domain/rumEventsCollection/view/trackScrollMetrics.js +79 -35
- package/src/domain/rumEventsCollection/view/trackViews.js +39 -16
- package/src/domain/rumEventsCollection/view/viewCollection.js +90 -37
- package/src/domain/trackEventCounts.js +4 -4
- package/src/domain/waitPageActivityEnd.js +1 -0
- package/src/transport/startRumBatch.js +3 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstInputTimings.js.map +0 -1
- package/esm/domain/rumEventsCollection/view/trackFirstInputTimings.js.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/domain/.DS_Store +0 -0
- package/src/domain/rumEventsCollection/.DS_Store +0 -0
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
display,
|
|
4
4
|
isPercentage,
|
|
5
5
|
validateAndBuildConfiguration,
|
|
6
|
+
validatePostRequestRequireParamsConfiguration,
|
|
6
7
|
isArray,
|
|
7
8
|
TraceType,
|
|
8
9
|
isNullUndefinedDefaultValue,
|
|
@@ -21,12 +22,9 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
21
22
|
)
|
|
22
23
|
return
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
return false
|
|
29
|
-
}
|
|
25
|
+
var requireParamsValidate =
|
|
26
|
+
validatePostRequestRequireParamsConfiguration(initConfiguration)
|
|
27
|
+
if (!requireParamsValidate) return
|
|
30
28
|
// TODO remove fallback in next major
|
|
31
29
|
if (
|
|
32
30
|
initConfiguration.sessionReplaySampleRate !== undefined &&
|
|
@@ -74,7 +72,6 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
74
72
|
initConfiguration.trackUserInteractions,
|
|
75
73
|
initConfiguration.trackInteractions
|
|
76
74
|
)
|
|
77
|
-
var trackFrustrations = !!initConfiguration.trackFrustrations
|
|
78
75
|
|
|
79
76
|
return assign(
|
|
80
77
|
{
|
|
@@ -90,8 +87,7 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
90
87
|
initConfiguration.excludedActivityUrls,
|
|
91
88
|
[]
|
|
92
89
|
),
|
|
93
|
-
trackUserInteractions: trackUserInteractions
|
|
94
|
-
trackFrustrations: trackFrustrations,
|
|
90
|
+
trackUserInteractions: trackUserInteractions,
|
|
95
91
|
trackViewsManually: !!initConfiguration.trackViewsManually,
|
|
96
92
|
traceType: isNullUndefinedDefaultValue(
|
|
97
93
|
initConfiguration.traceType,
|
|
@@ -3,27 +3,18 @@ import {
|
|
|
3
3
|
initViewportObservable
|
|
4
4
|
} from '../initViewportObservable'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
viewport =
|
|
12
|
-
|
|
13
|
-
viewportDimension
|
|
14
|
-
) {
|
|
15
|
-
viewport = viewportDimension
|
|
16
|
-
}).unsubscribe
|
|
17
|
-
}
|
|
6
|
+
export function startDisplayContext() {
|
|
7
|
+
var viewport = getViewportDimension()
|
|
8
|
+
var unsubscribeViewport = initViewportObservable().subscribe(function (
|
|
9
|
+
viewportDimension
|
|
10
|
+
) {
|
|
11
|
+
viewport = viewportDimension
|
|
12
|
+
}).unsubscribe
|
|
18
13
|
|
|
19
14
|
return {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function resetDisplayContext() {
|
|
25
|
-
if (stopListeners) {
|
|
26
|
-
stopListeners()
|
|
15
|
+
get: function () {
|
|
16
|
+
return { viewport: viewport }
|
|
17
|
+
},
|
|
18
|
+
stop: unsubscribeViewport
|
|
27
19
|
}
|
|
28
|
-
viewport = undefined
|
|
29
20
|
}
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
runOnReadyState,
|
|
14
14
|
setTimeout,
|
|
15
15
|
addEventListener,
|
|
16
|
-
monitor
|
|
16
|
+
monitor,
|
|
17
|
+
assign
|
|
17
18
|
} from '@cloudcare/browser-core'
|
|
18
19
|
import {
|
|
19
20
|
FAKE_INITIAL_DOCUMENT,
|
|
@@ -55,7 +56,8 @@ export function startPerformanceCollection(lifeCycle, configuration) {
|
|
|
55
56
|
var experimentalEntries = [
|
|
56
57
|
'largest-contentful-paint',
|
|
57
58
|
'first-input',
|
|
58
|
-
'layout-shift'
|
|
59
|
+
'layout-shift',
|
|
60
|
+
'event'
|
|
59
61
|
]
|
|
60
62
|
try {
|
|
61
63
|
// Experimental entries are not retrieved by performance.getEntries()
|
|
@@ -63,7 +65,13 @@ export function startPerformanceCollection(lifeCycle, configuration) {
|
|
|
63
65
|
// to get values that could happen before SDK init
|
|
64
66
|
each(experimentalEntries, function (type) {
|
|
65
67
|
var observer = new PerformanceObserver(handlePerformanceEntryList)
|
|
66
|
-
observer.observe({
|
|
68
|
+
observer.observe({
|
|
69
|
+
type: type,
|
|
70
|
+
buffered: true,
|
|
71
|
+
// durationThreshold only impact PerformanceEventTiming entries used for INP computation which requires a threshold at 40 (default is 104ms)
|
|
72
|
+
// cf: https://github.com/GoogleChrome/web-vitals/blob/3806160ffbc93c3c4abf210a167b81228172b31c/src/onINP.ts#L209
|
|
73
|
+
durationThreshold: 40
|
|
74
|
+
})
|
|
67
75
|
})
|
|
68
76
|
} catch (e) {
|
|
69
77
|
// Some old browser versions (ex: chrome 67) don't support the PerformanceObserver type and buffered options
|
|
@@ -100,7 +108,10 @@ export function retrieveInitialDocumentResourceTiming(callback) {
|
|
|
100
108
|
var forcedAttributes = {
|
|
101
109
|
entryType: 'resource',
|
|
102
110
|
initiatorType: FAKE_INITIAL_DOCUMENT,
|
|
103
|
-
traceId: ''
|
|
111
|
+
traceId: '',
|
|
112
|
+
toJSON: function () {
|
|
113
|
+
return assign({}, timing, { toJSON: undefined })
|
|
114
|
+
}
|
|
104
115
|
}
|
|
105
116
|
if (
|
|
106
117
|
supportPerformanceTimingEvent('navigation') &&
|
|
@@ -167,7 +178,10 @@ function retrieveFirstInputTiming(callback) {
|
|
|
167
178
|
var timing = {
|
|
168
179
|
entryType: 'first-input',
|
|
169
180
|
processingStart: relativeNow(),
|
|
170
|
-
|
|
181
|
+
processingEnd: relativeNow(),
|
|
182
|
+
startTime: evt.timeStamp,
|
|
183
|
+
duration: 0,
|
|
184
|
+
name: ''
|
|
171
185
|
}
|
|
172
186
|
|
|
173
187
|
if (evt.type === DOM_EVENT.POINTER_DOWN) {
|
|
@@ -236,7 +250,8 @@ function handleRumPerformanceEntries(lifeCycle, configuration, entries) {
|
|
|
236
250
|
entry.entryType === 'longtask' ||
|
|
237
251
|
entry.entryType === 'largest-contentful-paint' ||
|
|
238
252
|
entry.entryType === 'first-input' ||
|
|
239
|
-
entry.entryType === 'layout-shift'
|
|
253
|
+
entry.entryType === 'layout-shift' ||
|
|
254
|
+
entry.entryType === 'event'
|
|
240
255
|
)
|
|
241
256
|
})
|
|
242
257
|
|
|
@@ -268,7 +283,3 @@ function isForbiddenResource(configuration, entry) {
|
|
|
268
283
|
!isAllowedRequestUrl(configuration, entry.name)
|
|
269
284
|
)
|
|
270
285
|
}
|
|
271
|
-
export function supportPerformanceEntry() {
|
|
272
|
-
// Safari 10 doesn't support PerformanceEntry
|
|
273
|
-
return typeof PerformanceEntry === 'function'
|
|
274
|
-
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assign,
|
|
3
3
|
startsWith,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
isNodeShadowRoot,
|
|
5
|
+
forEachChildNodes,
|
|
6
|
+
hasChildNodes
|
|
6
7
|
} from '@cloudcare/browser-core'
|
|
7
8
|
import { STABLE_ATTRIBUTES } from '../../rumEventsCollection/actions/getSelectorsFromElement'
|
|
8
9
|
import {
|
|
@@ -109,18 +110,13 @@ function serializeDocumentTypeNode(documentType) {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
function serializeDocumentFragmentNode(element, options) {
|
|
112
|
-
var childNodes = []
|
|
113
|
-
if (element.childNodes.length) {
|
|
114
|
-
childNodes = serializeChildNodes(element, options)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
113
|
var isShadowRoot = isNodeShadowRoot(element)
|
|
118
114
|
if (isShadowRoot) {
|
|
119
115
|
options.serializationContext.shadowRootsController.addShadowRoot(element)
|
|
120
116
|
}
|
|
121
117
|
return {
|
|
122
118
|
type: NodeType.DocumentFragment,
|
|
123
|
-
childNodes:
|
|
119
|
+
childNodes: serializeChildNodes(element, options),
|
|
124
120
|
isShadowRoot: isShadowRoot,
|
|
125
121
|
adoptedStyleSheets: isShadowRoot
|
|
126
122
|
? serializeStyleSheets(element.adoptedStyleSheets)
|
|
@@ -185,7 +181,7 @@ export function serializeElementNode(element, options) {
|
|
|
185
181
|
)
|
|
186
182
|
|
|
187
183
|
var childNodes = []
|
|
188
|
-
if (element
|
|
184
|
+
if (hasChildNodes(element) && tagName !== 'style') {
|
|
189
185
|
// OBJECT POOLING OPTIMIZATION:
|
|
190
186
|
// We should not create a new object systematically as it could impact performances. Try to reuse
|
|
191
187
|
// the same object as much as possible, and clone it only if we need to.
|
|
@@ -204,12 +200,12 @@ export function serializeElementNode(element, options) {
|
|
|
204
200
|
childNodes = serializeChildNodes(element, childNodesSerializationOptions)
|
|
205
201
|
}
|
|
206
202
|
|
|
207
|
-
if (isNodeShadowHost(element)) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
203
|
+
// if (isNodeShadowHost(element)) {
|
|
204
|
+
// var shadowRoot = serializeNodeWithId(element.shadowRoot, options)
|
|
205
|
+
// if (shadowRoot !== null) {
|
|
206
|
+
// childNodes.push(shadowRoot)
|
|
207
|
+
// }
|
|
208
|
+
// }
|
|
213
209
|
|
|
214
210
|
return {
|
|
215
211
|
type: NodeType.Element,
|
|
@@ -253,12 +249,13 @@ function serializeCDataNode() {
|
|
|
253
249
|
|
|
254
250
|
export function serializeChildNodes(node, options) {
|
|
255
251
|
var result = []
|
|
256
|
-
node
|
|
252
|
+
forEachChildNodes(node, function (childNode) {
|
|
257
253
|
var serializedChildNode = serializeNodeWithId(childNode, options)
|
|
258
254
|
if (serializedChildNode) {
|
|
259
255
|
result.push(serializedChildNode)
|
|
260
256
|
}
|
|
261
257
|
})
|
|
258
|
+
// node.childNodes.forEach()
|
|
262
259
|
return result
|
|
263
260
|
}
|
|
264
261
|
|
|
@@ -52,7 +52,6 @@ export function trackClickActions(
|
|
|
52
52
|
configuration,
|
|
53
53
|
lifeCycle,
|
|
54
54
|
domMutationObservable,
|
|
55
|
-
history,
|
|
56
55
|
pointerDownEvent
|
|
57
56
|
)
|
|
58
57
|
},
|
|
@@ -74,12 +73,14 @@ export function trackClickActions(
|
|
|
74
73
|
var stopActionEventsListener = _listenActionEvents.stop
|
|
75
74
|
var actionContexts = {
|
|
76
75
|
findActionId: function (startTime) {
|
|
77
|
-
|
|
76
|
+
const allIds = history.findAll(startTime)
|
|
77
|
+
if (allIds && allIds.length) {
|
|
78
|
+
return allIds[allIds.length - 1]
|
|
79
|
+
}
|
|
80
|
+
return undefined
|
|
78
81
|
},
|
|
79
82
|
findAllActionId: function (startTime) {
|
|
80
|
-
return
|
|
81
|
-
? history.findAll(startTime)
|
|
82
|
-
: history.find(startTime)
|
|
83
|
+
return history.findAll(startTime)
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
|
|
@@ -110,24 +111,12 @@ function processPointerDown(
|
|
|
110
111
|
configuration,
|
|
111
112
|
lifeCycle,
|
|
112
113
|
domMutationObservable,
|
|
113
|
-
history,
|
|
114
114
|
pointerDownEvent
|
|
115
115
|
) {
|
|
116
|
-
if (!configuration.trackFrustrations && history.find()) {
|
|
117
|
-
// TODO: remove this in a future major version. To keep retrocompatibility, ignore any new
|
|
118
|
-
// action if another one is already occurring.
|
|
119
|
-
return
|
|
120
|
-
}
|
|
121
|
-
|
|
122
116
|
var clickActionBase = computeClickActionBase(
|
|
123
117
|
pointerDownEvent,
|
|
124
118
|
configuration.actionNameAttribute
|
|
125
119
|
)
|
|
126
|
-
if (!configuration.trackFrustrations && !clickActionBase.name) {
|
|
127
|
-
// TODO: remove this in a future major version. To keep retrocompatibility, ignore any action
|
|
128
|
-
// with a blank name
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
120
|
|
|
132
121
|
var hadActivityOnPointerDown = false
|
|
133
122
|
|
|
@@ -138,8 +127,6 @@ function processPointerDown(
|
|
|
138
127
|
function (pageActivityEndEvent) {
|
|
139
128
|
hadActivityOnPointerDown = pageActivityEndEvent.hadActivity
|
|
140
129
|
},
|
|
141
|
-
// We don't care about the activity duration, we just want to know whether an activity did happen
|
|
142
|
-
// within the "validation delay" or not. Limit the duration so the callback is called sooner.
|
|
143
130
|
PAGE_ACTIVITY_VALIDATION_DELAY
|
|
144
131
|
)
|
|
145
132
|
|
|
@@ -169,10 +156,7 @@ function startClickAction(
|
|
|
169
156
|
clickActionBase,
|
|
170
157
|
startEvent
|
|
171
158
|
)
|
|
172
|
-
|
|
173
|
-
if (configuration.trackFrustrations) {
|
|
174
|
-
appendClickToClickChain(click)
|
|
175
|
-
}
|
|
159
|
+
appendClickToClickChain(click)
|
|
176
160
|
var _waitPageActivityEnd = waitPageActivityEnd(
|
|
177
161
|
lifeCycle,
|
|
178
162
|
domMutationObservable,
|
|
@@ -196,18 +180,6 @@ function startClickAction(
|
|
|
196
180
|
} else {
|
|
197
181
|
click.stop()
|
|
198
182
|
}
|
|
199
|
-
|
|
200
|
-
// Validate or discard the click only if we don't track frustrations. It'll be done when
|
|
201
|
-
// the click chain is finalized.
|
|
202
|
-
if (!configuration.trackFrustrations) {
|
|
203
|
-
if (!pageActivityEndEvent.hadActivity) {
|
|
204
|
-
// If we are not tracking frustrations, we should discard the click to keep backward
|
|
205
|
-
// compatibility.
|
|
206
|
-
click.discard()
|
|
207
|
-
} else {
|
|
208
|
-
click.validate()
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
183
|
}
|
|
212
184
|
},
|
|
213
185
|
CLICK_ACTION_MAX_DURATION
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toValidEntry } from './resourceUtils'
|
|
2
|
-
import { map, filter } from '@cloudcare/browser-core'
|
|
2
|
+
import { map, filter, addDuration } from '@cloudcare/browser-core'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Look for corresponding timing in resource timing buffer
|
|
@@ -26,7 +26,7 @@ export function matchRequestTiming(request) {
|
|
|
26
26
|
var candidates = map(sameNameEntries, function (entry) {
|
|
27
27
|
return entry.toJSON()
|
|
28
28
|
})
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
candidates = filter(candidates, toValidEntry)
|
|
31
31
|
candidates = filter(candidates, function (entry) {
|
|
32
32
|
return isBetween(
|
|
@@ -42,20 +42,11 @@ export function matchRequestTiming(request) {
|
|
|
42
42
|
if (candidates.length === 1) {
|
|
43
43
|
return candidates[0]
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
if (candidates.length === 2 && firstCanBeOptionRequest(candidates)) {
|
|
47
|
-
return candidates[1]
|
|
48
|
-
}
|
|
49
|
-
|
|
50
45
|
return
|
|
51
46
|
}
|
|
52
47
|
|
|
53
|
-
function firstCanBeOptionRequest(correspondingEntries) {
|
|
54
|
-
return endTime(correspondingEntries[0]) <= correspondingEntries[1].startTime
|
|
55
|
-
}
|
|
56
|
-
|
|
57
48
|
function endTime(timing) {
|
|
58
|
-
return timing.startTime
|
|
49
|
+
return addDuration(timing.startTime, timing.duration)
|
|
59
50
|
}
|
|
60
51
|
|
|
61
52
|
function isBetween(timing, start, end) {
|
|
@@ -63,6 +54,6 @@ function isBetween(timing, start, end) {
|
|
|
63
54
|
var errorMargin = 1
|
|
64
55
|
return (
|
|
65
56
|
timing.startTime >= start - errorMargin &&
|
|
66
|
-
endTime(timing) <= end
|
|
57
|
+
endTime(timing) <= addDuration(end, errorMargin)
|
|
67
58
|
)
|
|
68
59
|
}
|
|
@@ -11,7 +11,10 @@ import {
|
|
|
11
11
|
RequestType,
|
|
12
12
|
ResourceType,
|
|
13
13
|
RumEventType,
|
|
14
|
-
LifeCycleEventType
|
|
14
|
+
LifeCycleEventType,
|
|
15
|
+
toServerDuration,
|
|
16
|
+
some,
|
|
17
|
+
isNullUndefinedDefaultValue
|
|
15
18
|
} from '@cloudcare/browser-core'
|
|
16
19
|
import { matchRequestTiming } from './matchRequestTiming'
|
|
17
20
|
import {
|
|
@@ -24,13 +27,23 @@ import {
|
|
|
24
27
|
isCacheHit,
|
|
25
28
|
isResourceUrlLimit
|
|
26
29
|
} from './resourceUtils'
|
|
27
|
-
import {
|
|
28
|
-
export function startResourceCollection(
|
|
30
|
+
import { PageState } from '../../contexts/pageStateHistory.js'
|
|
31
|
+
export function startResourceCollection(
|
|
32
|
+
lifeCycle,
|
|
33
|
+
configuration,
|
|
34
|
+
sessionManager,
|
|
35
|
+
pageStateHistory
|
|
36
|
+
) {
|
|
29
37
|
lifeCycle.subscribe(LifeCycleEventType.REQUEST_COMPLETED, function (request) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
var rawEvent = processRequest(
|
|
39
|
+
request,
|
|
40
|
+
configuration,
|
|
41
|
+
sessionManager,
|
|
42
|
+
pageStateHistory
|
|
33
43
|
)
|
|
44
|
+
if (rawEvent) {
|
|
45
|
+
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, rawEvent)
|
|
46
|
+
}
|
|
34
47
|
})
|
|
35
48
|
|
|
36
49
|
lifeCycle.subscribe(
|
|
@@ -43,27 +56,62 @@ export function startResourceCollection(lifeCycle, configuration) {
|
|
|
43
56
|
!isRequestKind(entry) &&
|
|
44
57
|
!isResourceUrlLimit(entry.name, configuration.resourceUrlLimit)
|
|
45
58
|
) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
var rawEvent = processResourceEntry(
|
|
60
|
+
entry,
|
|
61
|
+
configuration,
|
|
62
|
+
sessionManager,
|
|
63
|
+
pageStateHistory
|
|
49
64
|
)
|
|
65
|
+
if (rawEvent) {
|
|
66
|
+
lifeCycle.notify(
|
|
67
|
+
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,
|
|
68
|
+
rawEvent
|
|
69
|
+
)
|
|
70
|
+
}
|
|
50
71
|
}
|
|
51
72
|
}
|
|
52
73
|
}
|
|
53
74
|
)
|
|
54
75
|
}
|
|
55
76
|
|
|
56
|
-
function processRequest(
|
|
57
|
-
|
|
58
|
-
|
|
77
|
+
function processRequest(
|
|
78
|
+
request,
|
|
79
|
+
configuration,
|
|
80
|
+
sessionManager,
|
|
81
|
+
pageStateHistory
|
|
82
|
+
) {
|
|
59
83
|
var matchingTiming = matchRequestTiming(request)
|
|
60
84
|
var startClocks = matchingTiming
|
|
61
85
|
? relativeToClocks(matchingTiming.startTime)
|
|
62
86
|
: request.startClocks
|
|
87
|
+
var shouldIndex = shouldIndexResource(
|
|
88
|
+
configuration,
|
|
89
|
+
sessionManager,
|
|
90
|
+
startClocks
|
|
91
|
+
)
|
|
92
|
+
var tracingInfo = computeRequestTracingInfo(request)
|
|
93
|
+
if (!shouldIndex && !tracingInfo) {
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
var type =
|
|
97
|
+
request.type === RequestType.XHR ? ResourceType.XHR : ResourceType.FETCH
|
|
63
98
|
var correspondingTimingOverrides = matchingTiming
|
|
64
99
|
? computePerformanceEntryMetrics(matchingTiming)
|
|
65
100
|
: undefined
|
|
66
|
-
|
|
101
|
+
|
|
102
|
+
var duration = computeRequestDuration(
|
|
103
|
+
pageStateHistory,
|
|
104
|
+
startClocks,
|
|
105
|
+
request.duration
|
|
106
|
+
)
|
|
107
|
+
var pageStateInfo = computePageStateInfo(
|
|
108
|
+
pageStateHistory,
|
|
109
|
+
startClocks,
|
|
110
|
+
isNullUndefinedDefaultValue(
|
|
111
|
+
matchingTiming && matchingTiming.duration,
|
|
112
|
+
request.duration
|
|
113
|
+
)
|
|
114
|
+
)
|
|
67
115
|
var urlObj = urlParse(request.url).getParse()
|
|
68
116
|
var resourceEvent = extend2Lev(
|
|
69
117
|
{
|
|
@@ -71,7 +119,7 @@ function processRequest(request) {
|
|
|
71
119
|
resource: {
|
|
72
120
|
id: UUID,
|
|
73
121
|
type: type,
|
|
74
|
-
duration:
|
|
122
|
+
duration: duration,
|
|
75
123
|
method: request.method,
|
|
76
124
|
status: request.status,
|
|
77
125
|
statusGroup: getStatusGroup(request.status),
|
|
@@ -84,14 +132,14 @@ function processRequest(request) {
|
|
|
84
132
|
type: RumEventType.RESOURCE
|
|
85
133
|
},
|
|
86
134
|
tracingInfo,
|
|
87
|
-
correspondingTimingOverrides
|
|
135
|
+
correspondingTimingOverrides,
|
|
136
|
+
pageStateInfo
|
|
88
137
|
)
|
|
89
138
|
return {
|
|
90
139
|
startTime: startClocks.relative,
|
|
91
140
|
rawRumEvent: resourceEvent,
|
|
92
141
|
domainContext: {
|
|
93
|
-
performanceEntry:
|
|
94
|
-
matchingTiming && toPerformanceEntryRepresentation(matchingTiming),
|
|
142
|
+
performanceEntry: matchingTiming,
|
|
95
143
|
xhr: request.xhr,
|
|
96
144
|
response: request.response,
|
|
97
145
|
requestInput: request.input,
|
|
@@ -101,10 +149,24 @@ function processRequest(request) {
|
|
|
101
149
|
}
|
|
102
150
|
}
|
|
103
151
|
|
|
104
|
-
function processResourceEntry(
|
|
152
|
+
function processResourceEntry(
|
|
153
|
+
entry,
|
|
154
|
+
configuration,
|
|
155
|
+
sessionManager,
|
|
156
|
+
pageStateHistory
|
|
157
|
+
) {
|
|
158
|
+
var startClocks = relativeToClocks(entry.startTime)
|
|
159
|
+
var shouldIndex = shouldIndexResource(
|
|
160
|
+
configuration,
|
|
161
|
+
sessionManager,
|
|
162
|
+
startClocks
|
|
163
|
+
)
|
|
164
|
+
var tracingInfo = computeEntryTracingInfo(entry)
|
|
165
|
+
if (!shouldIndex && !tracingInfo) {
|
|
166
|
+
return
|
|
167
|
+
}
|
|
105
168
|
var type = computeResourceKind(entry)
|
|
106
169
|
var entryMetrics = computePerformanceEntryMetrics(entry)
|
|
107
|
-
var tracingInfo = computeEntryTracingInfo(entry)
|
|
108
170
|
var urlObj = urlParse(entry.name).getParse()
|
|
109
171
|
var statusCode = ''
|
|
110
172
|
if (is304(entry)) {
|
|
@@ -112,7 +174,12 @@ function processResourceEntry(entry) {
|
|
|
112
174
|
} else if (isCacheHit(entry)) {
|
|
113
175
|
statusCode = 200
|
|
114
176
|
}
|
|
115
|
-
var
|
|
177
|
+
var pageStateInfo = computePageStateInfo(
|
|
178
|
+
pageStateHistory,
|
|
179
|
+
startClocks,
|
|
180
|
+
entry.duration
|
|
181
|
+
)
|
|
182
|
+
|
|
116
183
|
var resourceEvent = extend2Lev(
|
|
117
184
|
{
|
|
118
185
|
date: startClocks.timeStamp,
|
|
@@ -131,16 +198,20 @@ function processResourceEntry(entry) {
|
|
|
131
198
|
type: RumEventType.RESOURCE
|
|
132
199
|
},
|
|
133
200
|
tracingInfo,
|
|
134
|
-
entryMetrics
|
|
201
|
+
entryMetrics,
|
|
202
|
+
pageStateInfo
|
|
135
203
|
)
|
|
136
204
|
return {
|
|
137
205
|
startTime: startClocks.relative,
|
|
138
206
|
rawRumEvent: resourceEvent,
|
|
139
207
|
domainContext: {
|
|
140
|
-
performanceEntry:
|
|
208
|
+
performanceEntry: entry
|
|
141
209
|
}
|
|
142
210
|
}
|
|
143
211
|
}
|
|
212
|
+
function shouldIndexResource(configuration, sessionManager, resourceStart) {
|
|
213
|
+
return sessionManager.findTrackedSession(resourceStart.relative)
|
|
214
|
+
}
|
|
144
215
|
|
|
145
216
|
function computePerformanceEntryMetrics(timing) {
|
|
146
217
|
return {
|
|
@@ -154,12 +225,7 @@ function computePerformanceEntryMetrics(timing) {
|
|
|
154
225
|
)
|
|
155
226
|
}
|
|
156
227
|
}
|
|
157
|
-
|
|
158
|
-
if (supportPerformanceEntry() && entry instanceof PerformanceEntry) {
|
|
159
|
-
entry.toJSON()
|
|
160
|
-
}
|
|
161
|
-
return entry
|
|
162
|
-
}
|
|
228
|
+
|
|
163
229
|
function computeRequestTracingInfo(request) {
|
|
164
230
|
var hasBeenTraced = request.traceSampled && request.traceId && request.spanId
|
|
165
231
|
if (!hasBeenTraced) {
|
|
@@ -173,7 +239,27 @@ function computeRequestTracingInfo(request) {
|
|
|
173
239
|
resource: { id: UUID() }
|
|
174
240
|
}
|
|
175
241
|
}
|
|
176
|
-
|
|
242
|
+
function computePageStateInfo(pageStateHistory, startClocks, duration) {
|
|
243
|
+
return {
|
|
244
|
+
_gc: {
|
|
245
|
+
page_states: pageStateHistory.findAll(startClocks.relative, duration),
|
|
246
|
+
page_was_discarded: String(document.wasDiscarded)
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function computeRequestDuration(pageStateHistory, startClocks, duration) {
|
|
251
|
+
const requestCrosseds = pageStateHistory.findAll(
|
|
252
|
+
startClocks.relative,
|
|
253
|
+
duration
|
|
254
|
+
)
|
|
255
|
+
var requestCrossedFrozenState
|
|
256
|
+
if (requestCrosseds) {
|
|
257
|
+
requestCrossedFrozenState = some(requestCrosseds, function (pageState) {
|
|
258
|
+
return pageState.state === PageState.FROZEN
|
|
259
|
+
})
|
|
260
|
+
}
|
|
261
|
+
return !requestCrossedFrozenState ? toServerDuration(duration) : undefined
|
|
262
|
+
}
|
|
177
263
|
function computeEntryTracingInfo(entry) {
|
|
178
264
|
return entry.traceId ? { _gc: { traceId: entry.traceId } } : undefined
|
|
179
265
|
}
|