@cloudcare/browser-rum 3.1.2 → 3.1.3
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 +1 -3
- 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 +33 -18
- 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 +17 -14
- 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/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 +1 -3
- 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 +34 -19
- 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 +18 -15
- 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/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 +1 -3
- 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 +67 -21
- 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 +47 -18
- package/src/domain/trackEventCounts.js +4 -4
- 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/boot/rum.js
CHANGED
|
@@ -20,6 +20,7 @@ import { startActionCollection } from '../domain/rumEventsCollection/actions/act
|
|
|
20
20
|
import { startRumBatch } from '../transport/startRumBatch'
|
|
21
21
|
import { startRumEventBridge } from '../transport/startRumEventBridge'
|
|
22
22
|
import { startRumAssembly } from '../domain/assembly'
|
|
23
|
+
import { startDisplayContext } from '../domain/contexts/displayContext.js'
|
|
23
24
|
import { startInternalContext } from '../domain/contexts/internalContext'
|
|
24
25
|
// import { startForegroundContexts } from '../domain/contexts/foregroundContexts'
|
|
25
26
|
import { startUrlContexts } from '../domain/contexts/urlContexts'
|
|
@@ -38,6 +39,7 @@ export function startRum(
|
|
|
38
39
|
userContextManager,
|
|
39
40
|
initialViewOptions
|
|
40
41
|
) {
|
|
42
|
+
var cleanupTasks = []
|
|
41
43
|
var lifeCycle = new LifeCycle()
|
|
42
44
|
var telemetry = startRumTelemetry(configuration)
|
|
43
45
|
telemetry.setContextProvider(function () {
|
|
@@ -64,7 +66,9 @@ export function startRum(
|
|
|
64
66
|
pageExitObservable.subscribe(function (event) {
|
|
65
67
|
lifeCycle.notify(LifeCycleEventType.PAGE_EXITED, event)
|
|
66
68
|
})
|
|
67
|
-
|
|
69
|
+
cleanupTasks.push(function () {
|
|
70
|
+
pageExitSubscription.unsubscribe()
|
|
71
|
+
})
|
|
68
72
|
var session = !canUseEventBridge()
|
|
69
73
|
? startRumSessionManager(configuration, lifeCycle)
|
|
70
74
|
: startRumSessionManagerStub()
|
|
@@ -77,6 +81,9 @@ export function startRum(
|
|
|
77
81
|
pageExitObservable,
|
|
78
82
|
session.expireObservable
|
|
79
83
|
)
|
|
84
|
+
cleanupTasks.push(function () {
|
|
85
|
+
batch.stop()
|
|
86
|
+
})
|
|
80
87
|
} else {
|
|
81
88
|
startRumEventBridge(lifeCycle)
|
|
82
89
|
}
|
|
@@ -105,9 +112,13 @@ export function startRum(
|
|
|
105
112
|
var urlContexts = _startRumEventCollection.urlContexts
|
|
106
113
|
var actionContexts = _startRumEventCollection.actionContexts
|
|
107
114
|
var pageStateHistory = _startRumEventCollection.pageStateHistory
|
|
115
|
+
var stopRumEventCollection = _startRumEventCollection.stop
|
|
108
116
|
var addAction = _startRumEventCollection.addAction
|
|
117
|
+
|
|
118
|
+
cleanupTasks.push(stopRumEventCollection)
|
|
119
|
+
|
|
109
120
|
startLongTaskCollection(lifeCycle, session)
|
|
110
|
-
startResourceCollection(lifeCycle, configuration)
|
|
121
|
+
startResourceCollection(lifeCycle, configuration, session, pageStateHistory)
|
|
111
122
|
|
|
112
123
|
var _startViewCollection = startViewCollection(
|
|
113
124
|
lifeCycle,
|
|
@@ -121,6 +132,9 @@ export function startRum(
|
|
|
121
132
|
)
|
|
122
133
|
var addTiming = _startViewCollection.addTiming
|
|
123
134
|
var startView = _startViewCollection.startView
|
|
135
|
+
var stopViewCollection = _startViewCollection.stop
|
|
136
|
+
cleanupTasks.push(stopViewCollection)
|
|
137
|
+
|
|
124
138
|
var _startErrorCollection = startErrorCollection(
|
|
125
139
|
lifeCycle,
|
|
126
140
|
configuration,
|
|
@@ -148,7 +162,12 @@ export function startRum(
|
|
|
148
162
|
stopSession: function () {
|
|
149
163
|
session.expire()
|
|
150
164
|
},
|
|
151
|
-
getInternalContext: internalContext.get
|
|
165
|
+
getInternalContext: internalContext.get,
|
|
166
|
+
stop: function () {
|
|
167
|
+
cleanupTasks.forEach(function (task) {
|
|
168
|
+
task()
|
|
169
|
+
})
|
|
170
|
+
}
|
|
152
171
|
}
|
|
153
172
|
}
|
|
154
173
|
function startRumTelemetry(configuration) {
|
|
@@ -189,6 +208,8 @@ export function startRumEventCollection(
|
|
|
189
208
|
)
|
|
190
209
|
var actionContexts = _startActionCollection.actionContexts
|
|
191
210
|
var addAction = _startActionCollection.addAction
|
|
211
|
+
|
|
212
|
+
var displayContext = startDisplayContext()
|
|
192
213
|
startRumAssembly(
|
|
193
214
|
configuration,
|
|
194
215
|
lifeCycle,
|
|
@@ -197,6 +218,7 @@ export function startRumEventCollection(
|
|
|
197
218
|
viewContexts,
|
|
198
219
|
urlContexts,
|
|
199
220
|
actionContexts,
|
|
221
|
+
displayContext,
|
|
200
222
|
buildCommonContext,
|
|
201
223
|
reportError
|
|
202
224
|
)
|
|
@@ -208,7 +230,9 @@ export function startRumEventCollection(
|
|
|
208
230
|
actionContexts: actionContexts,
|
|
209
231
|
stop: function () {
|
|
210
232
|
viewContexts.stop()
|
|
233
|
+
urlContexts.stop()
|
|
211
234
|
pageStateHistory.stop()
|
|
235
|
+
displayContext.stop()
|
|
212
236
|
}
|
|
213
237
|
}
|
|
214
238
|
}
|
package/src/domain/assembly.js
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
display,
|
|
13
13
|
assign
|
|
14
14
|
} from '@cloudcare/browser-core'
|
|
15
|
-
import { getDisplayContext } from './contexts/displayContext'
|
|
16
15
|
var SessionType = {
|
|
17
16
|
SYNTHETICS: 'synthetics',
|
|
18
17
|
USER: 'user'
|
|
@@ -36,6 +35,7 @@ export function startRumAssembly(
|
|
|
36
35
|
viewContexts,
|
|
37
36
|
urlContexts,
|
|
38
37
|
actionContexts,
|
|
38
|
+
displayContext,
|
|
39
39
|
buildCommonContext,
|
|
40
40
|
reportError
|
|
41
41
|
) {
|
|
@@ -117,7 +117,8 @@ export function startRumAssembly(
|
|
|
117
117
|
date: timeStampNow(),
|
|
118
118
|
user: {
|
|
119
119
|
id: userSessionManager.getId(),
|
|
120
|
-
is_signin: 'F'
|
|
120
|
+
is_signin: 'F',
|
|
121
|
+
is_login: false
|
|
121
122
|
},
|
|
122
123
|
session: {
|
|
123
124
|
// must be computed on each event because synthetics instrumentation can be done after sdk execution
|
|
@@ -139,7 +140,7 @@ export function startRumAssembly(
|
|
|
139
140
|
needToAssembleWithAction(rawRumEvent) && actionId
|
|
140
141
|
? { id: actionId, ids: actionIds }
|
|
141
142
|
: undefined,
|
|
142
|
-
display:
|
|
143
|
+
display: displayContext.get()
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
var rumEvent = extend2Lev(rumContext, viewContext, rawRumEvent)
|
|
@@ -156,7 +157,8 @@ export function startRumAssembly(
|
|
|
156
157
|
serverRumEvent.user = extend2Lev(
|
|
157
158
|
{
|
|
158
159
|
// id: session.getAnonymousID(),
|
|
159
|
-
is_signin: 'T'
|
|
160
|
+
is_signin: 'T',
|
|
161
|
+
is_login: true
|
|
160
162
|
},
|
|
161
163
|
commonContext.user
|
|
162
164
|
)
|
|
@@ -74,7 +74,6 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
74
74
|
initConfiguration.trackUserInteractions,
|
|
75
75
|
initConfiguration.trackInteractions
|
|
76
76
|
)
|
|
77
|
-
var trackFrustrations = !!initConfiguration.trackFrustrations
|
|
78
77
|
|
|
79
78
|
return assign(
|
|
80
79
|
{
|
|
@@ -90,8 +89,7 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
90
89
|
initConfiguration.excludedActivityUrls,
|
|
91
90
|
[]
|
|
92
91
|
),
|
|
93
|
-
trackUserInteractions: trackUserInteractions
|
|
94
|
-
trackFrustrations: trackFrustrations,
|
|
92
|
+
trackUserInteractions: trackUserInteractions,
|
|
95
93
|
trackViewsManually: !!initConfiguration.trackViewsManually,
|
|
96
94
|
traceType: isNullUndefinedDefaultValue(
|
|
97
95
|
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,12 +27,17 @@ 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
38
|
lifeCycle.notify(
|
|
31
39
|
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,
|
|
32
|
-
processRequest(request)
|
|
40
|
+
processRequest(request, sessionManager, pageStateHistory)
|
|
33
41
|
)
|
|
34
42
|
})
|
|
35
43
|
|
|
@@ -45,7 +53,7 @@ export function startResourceCollection(lifeCycle, configuration) {
|
|
|
45
53
|
) {
|
|
46
54
|
lifeCycle.notify(
|
|
47
55
|
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,
|
|
48
|
-
processResourceEntry(entry)
|
|
56
|
+
processResourceEntry(entry, sessionManager, pageStateHistory)
|
|
49
57
|
)
|
|
50
58
|
}
|
|
51
59
|
}
|
|
@@ -53,7 +61,7 @@ export function startResourceCollection(lifeCycle, configuration) {
|
|
|
53
61
|
)
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
function processRequest(request) {
|
|
64
|
+
function processRequest(request, sessionManager, pageStateHistory) {
|
|
57
65
|
var type =
|
|
58
66
|
request.type === RequestType.XHR ? ResourceType.XHR : ResourceType.FETCH
|
|
59
67
|
var matchingTiming = matchRequestTiming(request)
|
|
@@ -64,6 +72,20 @@ function processRequest(request) {
|
|
|
64
72
|
? computePerformanceEntryMetrics(matchingTiming)
|
|
65
73
|
: undefined
|
|
66
74
|
var tracingInfo = computeRequestTracingInfo(request)
|
|
75
|
+
|
|
76
|
+
var duration = computeRequestDuration(
|
|
77
|
+
pageStateHistory,
|
|
78
|
+
startClocks,
|
|
79
|
+
request.duration
|
|
80
|
+
)
|
|
81
|
+
var pageStateInfo = computePageStateInfo(
|
|
82
|
+
pageStateHistory,
|
|
83
|
+
startClocks,
|
|
84
|
+
isNullUndefinedDefaultValue(
|
|
85
|
+
matchingTiming && matchingTiming.duration,
|
|
86
|
+
request.duration
|
|
87
|
+
)
|
|
88
|
+
)
|
|
67
89
|
var urlObj = urlParse(request.url).getParse()
|
|
68
90
|
var resourceEvent = extend2Lev(
|
|
69
91
|
{
|
|
@@ -71,7 +93,7 @@ function processRequest(request) {
|
|
|
71
93
|
resource: {
|
|
72
94
|
id: UUID,
|
|
73
95
|
type: type,
|
|
74
|
-
duration:
|
|
96
|
+
duration: duration,
|
|
75
97
|
method: request.method,
|
|
76
98
|
status: request.status,
|
|
77
99
|
statusGroup: getStatusGroup(request.status),
|
|
@@ -84,14 +106,14 @@ function processRequest(request) {
|
|
|
84
106
|
type: RumEventType.RESOURCE
|
|
85
107
|
},
|
|
86
108
|
tracingInfo,
|
|
87
|
-
correspondingTimingOverrides
|
|
109
|
+
correspondingTimingOverrides,
|
|
110
|
+
pageStateInfo
|
|
88
111
|
)
|
|
89
112
|
return {
|
|
90
113
|
startTime: startClocks.relative,
|
|
91
114
|
rawRumEvent: resourceEvent,
|
|
92
115
|
domainContext: {
|
|
93
|
-
performanceEntry:
|
|
94
|
-
matchingTiming && toPerformanceEntryRepresentation(matchingTiming),
|
|
116
|
+
performanceEntry: matchingTiming,
|
|
95
117
|
xhr: request.xhr,
|
|
96
118
|
response: request.response,
|
|
97
119
|
requestInput: request.input,
|
|
@@ -101,9 +123,11 @@ function processRequest(request) {
|
|
|
101
123
|
}
|
|
102
124
|
}
|
|
103
125
|
|
|
104
|
-
function processResourceEntry(entry) {
|
|
126
|
+
function processResourceEntry(entry, sessionManager, pageStateHistory) {
|
|
105
127
|
var type = computeResourceKind(entry)
|
|
106
128
|
var entryMetrics = computePerformanceEntryMetrics(entry)
|
|
129
|
+
var startClocks = relativeToClocks(entry.startTime)
|
|
130
|
+
|
|
107
131
|
var tracingInfo = computeEntryTracingInfo(entry)
|
|
108
132
|
var urlObj = urlParse(entry.name).getParse()
|
|
109
133
|
var statusCode = ''
|
|
@@ -112,7 +136,13 @@ function processResourceEntry(entry) {
|
|
|
112
136
|
} else if (isCacheHit(entry)) {
|
|
113
137
|
statusCode = 200
|
|
114
138
|
}
|
|
115
|
-
|
|
139
|
+
|
|
140
|
+
var pageStateInfo = computePageStateInfo(
|
|
141
|
+
pageStateHistory,
|
|
142
|
+
startClocks,
|
|
143
|
+
entry.duration
|
|
144
|
+
)
|
|
145
|
+
|
|
116
146
|
var resourceEvent = extend2Lev(
|
|
117
147
|
{
|
|
118
148
|
date: startClocks.timeStamp,
|
|
@@ -131,13 +161,14 @@ function processResourceEntry(entry) {
|
|
|
131
161
|
type: RumEventType.RESOURCE
|
|
132
162
|
},
|
|
133
163
|
tracingInfo,
|
|
134
|
-
entryMetrics
|
|
164
|
+
entryMetrics,
|
|
165
|
+
pageStateInfo
|
|
135
166
|
)
|
|
136
167
|
return {
|
|
137
168
|
startTime: startClocks.relative,
|
|
138
169
|
rawRumEvent: resourceEvent,
|
|
139
170
|
domainContext: {
|
|
140
|
-
performanceEntry:
|
|
171
|
+
performanceEntry: entry
|
|
141
172
|
}
|
|
142
173
|
}
|
|
143
174
|
}
|
|
@@ -154,12 +185,7 @@ function computePerformanceEntryMetrics(timing) {
|
|
|
154
185
|
)
|
|
155
186
|
}
|
|
156
187
|
}
|
|
157
|
-
|
|
158
|
-
if (supportPerformanceEntry() && entry instanceof PerformanceEntry) {
|
|
159
|
-
entry.toJSON()
|
|
160
|
-
}
|
|
161
|
-
return entry
|
|
162
|
-
}
|
|
188
|
+
|
|
163
189
|
function computeRequestTracingInfo(request) {
|
|
164
190
|
var hasBeenTraced = request.traceSampled && request.traceId && request.spanId
|
|
165
191
|
if (!hasBeenTraced) {
|
|
@@ -173,7 +199,27 @@ function computeRequestTracingInfo(request) {
|
|
|
173
199
|
resource: { id: UUID() }
|
|
174
200
|
}
|
|
175
201
|
}
|
|
176
|
-
|
|
202
|
+
function computePageStateInfo(pageStateHistory, startClocks, duration) {
|
|
203
|
+
return {
|
|
204
|
+
_gc: {
|
|
205
|
+
page_states: pageStateHistory.findAll(startClocks.relative, duration),
|
|
206
|
+
page_was_discarded: String(document.wasDiscarded)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function computeRequestDuration(pageStateHistory, startClocks, duration) {
|
|
211
|
+
const requestCrosseds = pageStateHistory.findAll(
|
|
212
|
+
startClocks.relative,
|
|
213
|
+
duration
|
|
214
|
+
)
|
|
215
|
+
var requestCrossedFrozenState
|
|
216
|
+
if (requestCrosseds) {
|
|
217
|
+
requestCrossedFrozenState = some(requestCrosseds, function (pageState) {
|
|
218
|
+
return pageState.state === PageState.FROZEN
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
return !requestCrossedFrozenState ? toServerDuration(duration) : undefined
|
|
222
|
+
}
|
|
177
223
|
function computeEntryTracingInfo(entry) {
|
|
178
224
|
return entry.traceId ? { _gc: { traceId: entry.traceId } } : undefined
|
|
179
225
|
}
|