@cloudcare/browser-rum 3.3.7 → 3.3.9
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/domain/contexts/viewContexts.js +1 -0
- package/cjs/domain/contexts/viewContexts.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/locationChangeObservable.js +20 -6
- package/cjs/domain/locationChangeObservable.js.map +1 -1
- package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +1 -0
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/webSocketCollection.js +1 -0
- package/cjs/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackSoftNavigationMetrics.js +44 -0
- package/cjs/domain/rumEventsCollection/view/trackSoftNavigationMetrics.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackViews.js +75 -9
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -0
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/domain/contexts/viewContexts.js +2 -1
- package/esm/domain/contexts/viewContexts.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/locationChangeObservable.js +20 -6
- package/esm/domain/locationChangeObservable.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +1 -0
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/webSocketCollection.js +1 -0
- package/esm/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackSoftNavigationMetrics.js +38 -0
- package/esm/domain/rumEventsCollection/view/trackSoftNavigationMetrics.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackViews.js +75 -9
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -0
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/package.json +4 -4
- package/src/domain/contexts/viewContexts.js +3 -1
- package/src/domain/locationChangeObservable.js +24 -6
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +1 -0
- package/src/domain/rumEventsCollection/resource/webSocketCollection.js +1 -0
- package/src/domain/rumEventsCollection/view/trackSoftNavigationMetrics.js +42 -0
- package/src/domain/rumEventsCollection/view/trackViews.js +131 -11
- package/src/domain/rumEventsCollection/view/viewCollection.js +1 -0
|
@@ -27,6 +27,8 @@ import {
|
|
|
27
27
|
import { trackInitialViewMetrics } from './trackInitialViewTimings'
|
|
28
28
|
import { trackCommonViewMetrics } from './trackCommonViewMetrics'
|
|
29
29
|
import { trackViewEventCounts } from './trackViewEventCounts'
|
|
30
|
+
import { trackSoftNavigationMetrics } from './trackSoftNavigationMetrics'
|
|
31
|
+
import { getSelectorFromElement } from '../actions/getSelectorsFromElement'
|
|
30
32
|
export var THROTTLE_VIEW_UPDATE_PERIOD = 3000
|
|
31
33
|
export var SESSION_KEEP_ALIVE_INTERVAL = 5 * ONE_MINUTE
|
|
32
34
|
export var KEEP_TRACKING_AFTER_VIEW_DELAY = 5 * ONE_MINUTE
|
|
@@ -44,7 +46,13 @@ export function trackViews(
|
|
|
44
46
|
!eventBridgeAvailable ||
|
|
45
47
|
(document.visibilityState !== 'hidden' && document.hasFocus())
|
|
46
48
|
var activeViews = new Set()
|
|
47
|
-
function startNewView(
|
|
49
|
+
function startNewView(
|
|
50
|
+
loadingType,
|
|
51
|
+
startClocks,
|
|
52
|
+
viewOptions,
|
|
53
|
+
canMatchSoftNavigation,
|
|
54
|
+
fallbackNavigationType
|
|
55
|
+
) {
|
|
48
56
|
var newlyCreatedView = newView(
|
|
49
57
|
lifeCycle,
|
|
50
58
|
domMutationObservable,
|
|
@@ -52,11 +60,16 @@ export function trackViews(
|
|
|
52
60
|
location,
|
|
53
61
|
loadingType,
|
|
54
62
|
startClocks,
|
|
55
|
-
viewOptions
|
|
63
|
+
viewOptions,
|
|
64
|
+
canMatchSoftNavigation,
|
|
65
|
+
fallbackNavigationType
|
|
56
66
|
)
|
|
57
67
|
activeViews.add(newlyCreatedView)
|
|
58
68
|
newlyCreatedView.stopObservable.subscribe(function () {
|
|
59
69
|
activeViews.delete(newlyCreatedView)
|
|
70
|
+
if (softNavigationView === newlyCreatedView) {
|
|
71
|
+
softNavigationView = undefined
|
|
72
|
+
}
|
|
60
73
|
})
|
|
61
74
|
if (!isWebViewActive) {
|
|
62
75
|
newlyCreatedView.end({ sessionIsActive: false })
|
|
@@ -69,14 +82,43 @@ export function trackViews(
|
|
|
69
82
|
clocksOrigin(),
|
|
70
83
|
initialViewOptions
|
|
71
84
|
)
|
|
85
|
+
var softNavigationView
|
|
86
|
+
var softNavigationInteractionId
|
|
87
|
+
var softNavigationMetricsTracking = trackSoftNavigationMetrics(
|
|
88
|
+
function (entry) {
|
|
89
|
+
if (entry.entryType === 'soft-navigation') {
|
|
90
|
+
softNavigationView = findSoftNavigationView(activeViews, entry)
|
|
91
|
+
softNavigationInteractionId = entry.interactionId
|
|
92
|
+
if (softNavigationView) {
|
|
93
|
+
softNavigationView.$rSetSoftNavigationMetrics(
|
|
94
|
+
entry.navigationType,
|
|
95
|
+
entry.duration,
|
|
96
|
+
getSoftNavigationLcp(
|
|
97
|
+
configuration,
|
|
98
|
+
entry.getLargestInteractionContentfulPaint
|
|
99
|
+
? entry.getLargestInteractionContentfulPaint()
|
|
100
|
+
: entry.largestInteractionContentfulPaint
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
} else if (
|
|
105
|
+
softNavigationView &&
|
|
106
|
+
softNavigationInteractionId === entry.interactionId
|
|
107
|
+
) {
|
|
108
|
+
softNavigationView.$rSetSoftNavigationMetrics(
|
|
109
|
+
undefined,
|
|
110
|
+
undefined,
|
|
111
|
+
getSoftNavigationLcp(configuration, entry)
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
)
|
|
72
116
|
var stopWebViewLifecycleTracking = noop
|
|
73
117
|
startViewLifeCycle()
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
)
|
|
79
|
-
}
|
|
118
|
+
var pendingNavigation
|
|
119
|
+
var locationChangeSubscription = renewViewOnLocationChange(
|
|
120
|
+
locationChangeObservable
|
|
121
|
+
)
|
|
80
122
|
function startViewLifeCycle() {
|
|
81
123
|
function renewCurrentView() {
|
|
82
124
|
currentView = startNewView(ViewLoadingType.ROUTE_CHANGE, undefined, {
|
|
@@ -118,8 +160,18 @@ export function trackViews(
|
|
|
118
160
|
var oldLocation = params.oldLocation
|
|
119
161
|
var newLocation = params.newLocation
|
|
120
162
|
if (areDifferentLocation(oldLocation, newLocation)) {
|
|
163
|
+
if (!areViewsTrackedAutomatically) {
|
|
164
|
+
pendingNavigation = [newLocation.href, params.navigationType]
|
|
165
|
+
return
|
|
166
|
+
}
|
|
121
167
|
currentView.end()
|
|
122
|
-
currentView = startNewView(
|
|
168
|
+
currentView = startNewView(
|
|
169
|
+
ViewLoadingType.ROUTE_CHANGE,
|
|
170
|
+
undefined,
|
|
171
|
+
undefined,
|
|
172
|
+
true,
|
|
173
|
+
params.navigationType
|
|
174
|
+
)
|
|
123
175
|
return
|
|
124
176
|
}
|
|
125
177
|
})
|
|
@@ -133,11 +185,21 @@ export function trackViews(
|
|
|
133
185
|
currentView.addTiming(name, time)
|
|
134
186
|
},
|
|
135
187
|
startView: function (options, startClocks) {
|
|
188
|
+
var fallbackNavigationType
|
|
189
|
+
if (
|
|
190
|
+
pendingNavigation &&
|
|
191
|
+
pendingNavigation[0] === location.href
|
|
192
|
+
) {
|
|
193
|
+
fallbackNavigationType = pendingNavigation[1]
|
|
194
|
+
}
|
|
195
|
+
pendingNavigation = undefined
|
|
136
196
|
currentView.end({ endClocks: startClocks })
|
|
137
197
|
currentView = startNewView(
|
|
138
198
|
ViewLoadingType.ROUTE_CHANGE,
|
|
139
199
|
startClocks,
|
|
140
|
-
options
|
|
200
|
+
options,
|
|
201
|
+
true,
|
|
202
|
+
fallbackNavigationType
|
|
141
203
|
)
|
|
142
204
|
},
|
|
143
205
|
setViewContext: (context) => {
|
|
@@ -155,6 +217,7 @@ export function trackViews(
|
|
|
155
217
|
locationChangeSubscription.unsubscribe()
|
|
156
218
|
}
|
|
157
219
|
stopWebViewLifecycleTracking()
|
|
220
|
+
softNavigationMetricsTracking()
|
|
158
221
|
currentView.end()
|
|
159
222
|
activeViews.forEach(function (view) {
|
|
160
223
|
view.stop()
|
|
@@ -170,7 +233,9 @@ function newView(
|
|
|
170
233
|
initialLocation,
|
|
171
234
|
loadingType,
|
|
172
235
|
startClocks,
|
|
173
|
-
viewOptions
|
|
236
|
+
viewOptions,
|
|
237
|
+
canMatchSoftNavigation,
|
|
238
|
+
fallbackNavigationType
|
|
174
239
|
) {
|
|
175
240
|
// Setup initial values
|
|
176
241
|
if (startClocks === undefined) {
|
|
@@ -246,6 +311,7 @@ function newView(
|
|
|
246
311
|
}
|
|
247
312
|
var stopInitialViewMetricsTracking = _trackInitialViewTimings.stop
|
|
248
313
|
var initialViewMetrics = _trackInitialViewTimings.initialViewMetrics
|
|
314
|
+
var navigationType = fallbackNavigationType
|
|
249
315
|
var _trackViewEventCounts = trackViewEventCounts(
|
|
250
316
|
lifeCycle,
|
|
251
317
|
id,
|
|
@@ -299,6 +365,7 @@ function newView(
|
|
|
299
365
|
version: version,
|
|
300
366
|
context: contextManager.getContext(),
|
|
301
367
|
loadingType: loadingType,
|
|
368
|
+
navigationType: navigationType,
|
|
302
369
|
location: location,
|
|
303
370
|
startClocks: startClocks,
|
|
304
371
|
commonViewMetrics: getCommonViewMetrics(),
|
|
@@ -360,11 +427,64 @@ function newView(
|
|
|
360
427
|
setViewName(updatedName) {
|
|
361
428
|
name = updatedName
|
|
362
429
|
triggerViewUpdate()
|
|
430
|
+
},
|
|
431
|
+
$rSetSoftNavigationMetrics: function (
|
|
432
|
+
softNavigationType,
|
|
433
|
+
firstContentfulPaint,
|
|
434
|
+
largestContentfulPaint
|
|
435
|
+
) {
|
|
436
|
+
navigationType = softNavigationType || navigationType
|
|
437
|
+
if (typeof firstContentfulPaint === 'number') {
|
|
438
|
+
initialViewMetrics.firstContentfulPaint = firstContentfulPaint
|
|
439
|
+
}
|
|
440
|
+
if (largestContentfulPaint) {
|
|
441
|
+
initialViewMetrics.largestContentfulPaint = largestContentfulPaint
|
|
442
|
+
}
|
|
443
|
+
scheduleViewUpdate()
|
|
363
444
|
}
|
|
364
445
|
}
|
|
446
|
+
result.$rLocation = location
|
|
447
|
+
if (canMatchSoftNavigation) {
|
|
448
|
+
result.$rSoftNavigationStart = startClocks.relative
|
|
449
|
+
}
|
|
365
450
|
return result
|
|
366
451
|
}
|
|
367
452
|
|
|
453
|
+
function findSoftNavigationView(activeViews, softNavigation) {
|
|
454
|
+
// History tracking creates the View before Chrome emits its paint-backed
|
|
455
|
+
// soft-navigation entry. Enrich that View instead of creating a duplicate.
|
|
456
|
+
var matchingView
|
|
457
|
+
var closestStart = Infinity
|
|
458
|
+
activeViews.forEach(function (view) {
|
|
459
|
+
var startDelay = view.$rSoftNavigationStart - softNavigation.startTime
|
|
460
|
+
if (
|
|
461
|
+
startDelay >= -1 &&
|
|
462
|
+
startDelay < closestStart &&
|
|
463
|
+
view.$rLocation.href === softNavigation.name
|
|
464
|
+
) {
|
|
465
|
+
matchingView = view
|
|
466
|
+
closestStart = startDelay
|
|
467
|
+
}
|
|
468
|
+
})
|
|
469
|
+
return matchingView
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function getSoftNavigationLcp(configuration, entry) {
|
|
473
|
+
var candidate = entry && entry.largestContentfulPaint
|
|
474
|
+
var renderTime = candidate && (candidate.renderTime || candidate.loadTime)
|
|
475
|
+
if (renderTime) {
|
|
476
|
+
return {
|
|
477
|
+
value: Math.max(renderTime - entry.startTime, 0),
|
|
478
|
+
targetSelector:
|
|
479
|
+
candidate.element &&
|
|
480
|
+
getSelectorFromElement(
|
|
481
|
+
candidate.element,
|
|
482
|
+
configuration.actionNameAttribute
|
|
483
|
+
)
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
368
488
|
/**
|
|
369
489
|
* Timing name is used as facet path that must contain only letters, digits, or the characters - _ . @ $
|
|
370
490
|
*/
|
|
@@ -195,6 +195,7 @@ function processViewUpdate(view, configuration, recorderApi, pageStateHistory) {
|
|
|
195
195
|
toServerDuration(view.commonViewMetrics.loadingTime)
|
|
196
196
|
),
|
|
197
197
|
loading_type: view.loadingType,
|
|
198
|
+
navigation_type: view.navigationType,
|
|
198
199
|
long_task: {
|
|
199
200
|
count: view.eventCounts.longTaskCount
|
|
200
201
|
},
|