@cloudcare/browser-rum 3.3.22 → 3.3.23
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 +7 -6
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/performanceUtils.js +6 -1
- package/cjs/domain/performanceUtils.js.map +1 -1
- package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +3 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js +25 -3
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +56 -32
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/transport/startRumBatch.js +4 -0
- package/cjs/transport/startRumBatch.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/rum.js +7 -6
- package/esm/boot/rum.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/performanceUtils.js +6 -1
- package/esm/domain/performanceUtils.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +3 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js +25 -3
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +57 -33
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/transport/startRumBatch.js +4 -0
- package/esm/transport/startRumBatch.js.map +1 -1
- package/package.json +4 -4
- package/src/boot/rum.js +7 -6
- package/src/domain/performanceUtils.js +17 -1
- package/src/domain/replay/segmentCollection/segmentCollection.js +6 -1
- package/src/domain/rumEventsCollection/view/trackNavigationTimings.js +37 -3
- package/src/domain/rumEventsCollection/view/trackViews.js +66 -38
- package/src/transport/startRumBatch.js +4 -0
package/src/boot/rum.js
CHANGED
|
@@ -49,12 +49,6 @@ export function startRum(
|
|
|
49
49
|
lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error })
|
|
50
50
|
}
|
|
51
51
|
var pageExitObservable = createPageExitObservable()
|
|
52
|
-
var pageExitSubscription = pageExitObservable.subscribe(function (event) {
|
|
53
|
-
lifeCycle.notify(LifeCycleEventType.PAGE_EXITED, event)
|
|
54
|
-
})
|
|
55
|
-
cleanupTasks.push(function () {
|
|
56
|
-
pageExitSubscription.unsubscribe()
|
|
57
|
-
})
|
|
58
52
|
var session = !canUseEventBridge()
|
|
59
53
|
? startRumSessionManager(configuration, lifeCycle)
|
|
60
54
|
: startRumSessionManagerStub()
|
|
@@ -73,6 +67,13 @@ export function startRum(
|
|
|
73
67
|
})
|
|
74
68
|
} else {
|
|
75
69
|
startRumEventBridge(lifeCycle)
|
|
70
|
+
// Bridge events are delivered directly, without an HTTP flush controller.
|
|
71
|
+
var pageExitSubscription = pageExitObservable.subscribe(function (event) {
|
|
72
|
+
lifeCycle.notify(LifeCycleEventType.PAGE_EXITED, event)
|
|
73
|
+
})
|
|
74
|
+
cleanupTasks.push(function () {
|
|
75
|
+
pageExitSubscription.unsubscribe()
|
|
76
|
+
})
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
var userSession = startCacheUsrCache(configuration)
|
|
@@ -9,12 +9,28 @@ export function getNavigationEntry() {
|
|
|
9
9
|
var navigationEntry = performance.getEntriesByType(
|
|
10
10
|
RumPerformanceEntryType.NAVIGATION
|
|
11
11
|
)[0]
|
|
12
|
-
|
|
12
|
+
// WebKit 26.4 can populate loadEventEnd while leaving DOM timings at zero.
|
|
13
|
+
// Try legacy timing, but retain the native entry if it is not more complete.
|
|
14
|
+
if (
|
|
15
|
+
navigationEntry &&
|
|
16
|
+
!(navigationEntry.loadEventEnd > 0 && navigationEntry.domComplete <= 0)
|
|
17
|
+
) {
|
|
13
18
|
return navigationEntry
|
|
14
19
|
}
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
var timings = computeTimingsFromDeprecatedPerformanceTiming()
|
|
23
|
+
if (
|
|
24
|
+
navigationEntry &&
|
|
25
|
+
!(
|
|
26
|
+
isFinite(timings.loadEventEnd) &&
|
|
27
|
+
timings.loadEventEnd > 0 &&
|
|
28
|
+
timings.domComplete > 0 &&
|
|
29
|
+
timings.domComplete <= timings.loadEventEnd
|
|
30
|
+
)
|
|
31
|
+
) {
|
|
32
|
+
return navigationEntry
|
|
33
|
+
}
|
|
18
34
|
var entry = assign(
|
|
19
35
|
{
|
|
20
36
|
entryType: RumPerformanceEntryType.NAVIGATION,
|
|
@@ -177,7 +177,12 @@ export function doStartSegmentCollection(
|
|
|
177
177
|
var subscribePageExited = lifeCycle.subscribe(
|
|
178
178
|
LifeCycleEventType.PAGE_EXITED,
|
|
179
179
|
function (pageExitEvent) {
|
|
180
|
-
if (
|
|
180
|
+
if (
|
|
181
|
+
state.$rStatus === SegmentCollectionStatus.Stopped ||
|
|
182
|
+
pageExitEvent.reason === PageExitReason.PAGE_TERMINATED
|
|
183
|
+
) {
|
|
184
|
+
// Terminal pagehide refreshes the RUM View but skips Replay work.
|
|
185
|
+
// DOM/Canvas preparation and Replay encoding are too late here.
|
|
181
186
|
return
|
|
182
187
|
}
|
|
183
188
|
prepareRecordsBeforePageExit(pageExitEvent)
|
|
@@ -6,6 +6,10 @@ import {
|
|
|
6
6
|
} from '@cloudcare/browser-core'
|
|
7
7
|
|
|
8
8
|
import { getNavigationEntry } from '../../performanceUtils'
|
|
9
|
+
|
|
10
|
+
var NAVIGATION_TIMING_RETRY_DELAY = 100
|
|
11
|
+
var MAX_NAVIGATION_TIMING_RETRIES = 100
|
|
12
|
+
|
|
9
13
|
export function trackNavigationTimings(
|
|
10
14
|
configuration,
|
|
11
15
|
callback,
|
|
@@ -14,13 +18,38 @@ export function trackNavigationTimings(
|
|
|
14
18
|
if (getNavigationEntryImpl === undefined) {
|
|
15
19
|
getNavigationEntryImpl = getNavigationEntry
|
|
16
20
|
}
|
|
17
|
-
|
|
21
|
+
var retryTimeoutId
|
|
22
|
+
var retries = 0
|
|
23
|
+
var stopped = false
|
|
24
|
+
var loadTracking = waitAfterLoadEvent(readNavigationTimings)
|
|
25
|
+
|
|
26
|
+
function readNavigationTimings() {
|
|
27
|
+
if (stopped) {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
18
30
|
var entry = getNavigationEntryImpl()
|
|
19
31
|
|
|
20
32
|
if (!isIncompleteNavigation(entry)) {
|
|
33
|
+
stopped = true
|
|
21
34
|
callback(processNavigationEntry(entry))
|
|
35
|
+
} else if (retries < MAX_NAVIGATION_TIMING_RETRIES) {
|
|
36
|
+
// Some WebViews populate navigation timing after the load callback.
|
|
37
|
+
// Bound retries so an unavailable timing cannot keep a timer forever.
|
|
38
|
+
retries += 1
|
|
39
|
+
retryTimeoutId = setTimeout(
|
|
40
|
+
readNavigationTimings,
|
|
41
|
+
NAVIGATION_TIMING_RETRY_DELAY
|
|
42
|
+
)
|
|
22
43
|
}
|
|
23
|
-
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
stop: function () {
|
|
48
|
+
stopped = true
|
|
49
|
+
loadTracking.stop()
|
|
50
|
+
clearTimeout(retryTimeoutId)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
24
53
|
}
|
|
25
54
|
|
|
26
55
|
function processNavigationEntry(entry) {
|
|
@@ -47,7 +76,12 @@ function processNavigationEntry(entry) {
|
|
|
47
76
|
}
|
|
48
77
|
|
|
49
78
|
function isIncompleteNavigation(entry) {
|
|
50
|
-
return
|
|
79
|
+
return (
|
|
80
|
+
!entry ||
|
|
81
|
+
typeof entry.loadEventEnd !== 'number' ||
|
|
82
|
+
!isFinite(entry.loadEventEnd) ||
|
|
83
|
+
entry.loadEventEnd <= 0
|
|
84
|
+
)
|
|
51
85
|
}
|
|
52
86
|
|
|
53
87
|
function waitAfterLoadEvent(callback) {
|
|
@@ -19,9 +19,11 @@ import {
|
|
|
19
19
|
Observable,
|
|
20
20
|
clearInterval,
|
|
21
21
|
setTimeout,
|
|
22
|
+
clearTimeout,
|
|
22
23
|
isNullUndefinedDefaultValue,
|
|
23
24
|
createContextManager,
|
|
24
25
|
addEventListeners,
|
|
26
|
+
DOM_EVENT,
|
|
25
27
|
canUseEventBridge
|
|
26
28
|
} from '@cloudcare/browser-core'
|
|
27
29
|
|
|
@@ -44,12 +46,6 @@ export function trackViews(
|
|
|
44
46
|
recorderApi
|
|
45
47
|
) {
|
|
46
48
|
var eventBridgeAvailable = canUseEventBridge()
|
|
47
|
-
var maxViewDuration = eventBridgeAvailable
|
|
48
|
-
? Infinity
|
|
49
|
-
: SESSION_TIME_OUT_DELAY
|
|
50
|
-
var isWebViewActive =
|
|
51
|
-
!eventBridgeAvailable ||
|
|
52
|
-
(document.visibilityState !== 'hidden' && document.hasFocus())
|
|
53
49
|
var activeViews = new Set()
|
|
54
50
|
function startNewView(
|
|
55
51
|
loadingType,
|
|
@@ -69,7 +65,7 @@ export function trackViews(
|
|
|
69
65
|
canMatchSoftNavigation,
|
|
70
66
|
fallbackNavigationType,
|
|
71
67
|
recorderApi,
|
|
72
|
-
|
|
68
|
+
eventBridgeAvailable
|
|
73
69
|
)
|
|
74
70
|
activeViews.add(newlyCreatedView)
|
|
75
71
|
newlyCreatedView.stopObservable.subscribe(function () {
|
|
@@ -78,10 +74,6 @@ export function trackViews(
|
|
|
78
74
|
softNavigationView = undefined
|
|
79
75
|
}
|
|
80
76
|
})
|
|
81
|
-
if (!isWebViewActive) {
|
|
82
|
-
newlyCreatedView.end({ sessionIsActive: false })
|
|
83
|
-
newlyCreatedView.stop()
|
|
84
|
-
}
|
|
85
77
|
return newlyCreatedView
|
|
86
78
|
}
|
|
87
79
|
var currentView = startNewView(
|
|
@@ -120,7 +112,6 @@ export function trackViews(
|
|
|
120
112
|
}
|
|
121
113
|
}
|
|
122
114
|
)
|
|
123
|
-
var stopWebViewLifecycleTracking = noop
|
|
124
115
|
var forcedSessionSubscription
|
|
125
116
|
startViewLifeCycle()
|
|
126
117
|
var pendingNavigation
|
|
@@ -136,10 +127,6 @@ export function trackViews(
|
|
|
136
127
|
context: currentView.contextManager.getContext()
|
|
137
128
|
})
|
|
138
129
|
}
|
|
139
|
-
function endWebView() {
|
|
140
|
-
currentView.end({ sessionIsActive: false })
|
|
141
|
-
currentView.stop()
|
|
142
|
-
}
|
|
143
130
|
lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, renewCurrentView)
|
|
144
131
|
forcedSessionSubscription = lifeCycle.subscribe(
|
|
145
132
|
LifeCycleEventType.SESSION_FORCED,
|
|
@@ -168,22 +155,6 @@ export function trackViews(
|
|
|
168
155
|
})
|
|
169
156
|
}
|
|
170
157
|
)
|
|
171
|
-
|
|
172
|
-
if (eventBridgeAvailable) {
|
|
173
|
-
function updateWebViewLifecycle(event) {
|
|
174
|
-
var nextIsActive =
|
|
175
|
-
document.visibilityState !== 'hidden' && event.type !== 'blur'
|
|
176
|
-
if (nextIsActive !== isWebViewActive) {
|
|
177
|
-
isWebViewActive = nextIsActive
|
|
178
|
-
isWebViewActive ? renewCurrentView() : endWebView()
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
stopWebViewLifecycleTracking = addEventListeners(
|
|
182
|
-
window,
|
|
183
|
-
['blur', 'focus', 'resume', 'visibilitychange'],
|
|
184
|
-
updateWebViewLifecycle
|
|
185
|
-
).stop
|
|
186
|
-
}
|
|
187
158
|
}
|
|
188
159
|
|
|
189
160
|
function renewViewOnLocationChange(locationChangeObservable) {
|
|
@@ -244,7 +215,6 @@ export function trackViews(
|
|
|
244
215
|
if (locationChangeSubscription) {
|
|
245
216
|
locationChangeSubscription.unsubscribe()
|
|
246
217
|
}
|
|
247
|
-
stopWebViewLifecycleTracking()
|
|
248
218
|
forcedSessionSubscription.unsubscribe()
|
|
249
219
|
softNavigationMetricsTracking()
|
|
250
220
|
currentView.end()
|
|
@@ -266,8 +236,9 @@ function newView(
|
|
|
266
236
|
canMatchSoftNavigation,
|
|
267
237
|
fallbackNavigationType,
|
|
268
238
|
recorderApi,
|
|
269
|
-
|
|
239
|
+
eventBridgeAvailable
|
|
270
240
|
) {
|
|
241
|
+
var maxViewDuration = eventBridgeAvailable ? Infinity : SESSION_TIME_OUT_DELAY
|
|
271
242
|
// Setup initial values
|
|
272
243
|
if (startClocks === undefined) {
|
|
273
244
|
startClocks = clocksNow()
|
|
@@ -383,9 +354,27 @@ function newView(
|
|
|
383
354
|
replayRecordingStateSubscription =
|
|
384
355
|
recorderApi.recordingStateObservable.subscribe(updateReplayRecordingState)
|
|
385
356
|
}
|
|
357
|
+
var terminalViewUpdated = false
|
|
358
|
+
var restoreTimeoutId
|
|
359
|
+
function cancelRestoreViewUpdate() {
|
|
360
|
+
if (restoreTimeoutId !== undefined) {
|
|
361
|
+
clearTimeout(restoreTimeoutId)
|
|
362
|
+
restoreTimeoutId = undefined
|
|
363
|
+
}
|
|
364
|
+
}
|
|
386
365
|
const pageMayExitSubscription = lifeCycle.subscribe(
|
|
387
366
|
LifeCycleEventType.PAGE_EXITED,
|
|
388
367
|
(pageMayExitEvent) => {
|
|
368
|
+
cancelRestoreViewUpdate()
|
|
369
|
+
if (pageMayExitEvent.reason === PageExitReason.PAGE_TERMINATED) {
|
|
370
|
+
// Refresh duration and context before the batch's synchronous exit
|
|
371
|
+
// flush. Keep Replay running; its terminal handler does no new work.
|
|
372
|
+
if (!terminalViewUpdated) {
|
|
373
|
+
terminalViewUpdated = true
|
|
374
|
+
triggerViewUpdate()
|
|
375
|
+
}
|
|
376
|
+
return
|
|
377
|
+
}
|
|
389
378
|
var isReplayRecording =
|
|
390
379
|
recorderApi &&
|
|
391
380
|
typeof recorderApi.isRecording === 'function' &&
|
|
@@ -394,17 +383,54 @@ function newView(
|
|
|
394
383
|
(pageMayExitEvent.reason === PageExitReason.UNLOADING &&
|
|
395
384
|
(!isReplayRecording || !hasReplayRecordingStateObservable)) ||
|
|
396
385
|
(pageMayExitEvent.reason !== PageExitReason.UNLOADING &&
|
|
397
|
-
isReplayRecording)
|
|
386
|
+
isReplayRecording) ||
|
|
387
|
+
(eventBridgeAvailable && pageMayExitEvent.reason === PageExitReason.HIDDEN)
|
|
398
388
|
) {
|
|
399
|
-
// Replay segments flush at
|
|
400
|
-
// duration aligned with those boundaries
|
|
401
|
-
//
|
|
389
|
+
// Replay segments flush at non-terminal page-exit boundaries. Keep the View
|
|
390
|
+
// duration aligned with those boundaries while Replay is active. A
|
|
391
|
+
// bridged View also refreshes on hide without ending metric collection.
|
|
402
392
|
// An active recorder with a state observable publishes its final View
|
|
403
393
|
// after stop, so do not publish the same unload boundary twice here.
|
|
404
394
|
triggerViewUpdate()
|
|
405
395
|
}
|
|
406
396
|
}
|
|
407
397
|
)
|
|
398
|
+
var stopWebViewRestoreTracking = noop
|
|
399
|
+
if (eventBridgeAvailable) {
|
|
400
|
+
var wasHidden = document.visibilityState === 'hidden'
|
|
401
|
+
var stopRestoreListeners = addEventListeners(
|
|
402
|
+
window,
|
|
403
|
+
[DOM_EVENT.VISIBILITY_CHANGE, DOM_EVENT.RESUME, DOM_EVENT.PAGE_SHOW],
|
|
404
|
+
function () {
|
|
405
|
+
var isHidden = document.visibilityState === 'hidden'
|
|
406
|
+
var shouldRefresh = wasHidden && !isHidden
|
|
407
|
+
wasHidden = isHidden
|
|
408
|
+
if (isHidden) {
|
|
409
|
+
cancelRestoreViewUpdate()
|
|
410
|
+
} else if (shouldRefresh && !terminalViewUpdated) {
|
|
411
|
+
// Visibility is resumable, including BFCache. Keep the View identity,
|
|
412
|
+
// navigation observers and late resource counters across this boundary.
|
|
413
|
+
// Capture the transition now, but let application event handlers update
|
|
414
|
+
// global context before assembling the restored View.
|
|
415
|
+
restoreTimeoutId = setTimeout(function () {
|
|
416
|
+
restoreTimeoutId = undefined
|
|
417
|
+
if (
|
|
418
|
+
endClocks === undefined &&
|
|
419
|
+
!terminalViewUpdated &&
|
|
420
|
+
document.visibilityState !== 'hidden'
|
|
421
|
+
) {
|
|
422
|
+
triggerViewUpdate()
|
|
423
|
+
}
|
|
424
|
+
}, 0)
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
{ capture: true }
|
|
428
|
+
).stop
|
|
429
|
+
stopWebViewRestoreTracking = function () {
|
|
430
|
+
stopRestoreListeners()
|
|
431
|
+
cancelRestoreViewUpdate()
|
|
432
|
+
}
|
|
433
|
+
}
|
|
408
434
|
triggerViewUpdate()
|
|
409
435
|
// View context update should always be throttled
|
|
410
436
|
contextManager.changeObservable.subscribe(scheduleViewUpdate)
|
|
@@ -484,12 +510,14 @@ function newView(
|
|
|
484
510
|
setViewEnd(endClocks.relative)
|
|
485
511
|
stopCommonViewMetricsTracking()
|
|
486
512
|
pageMayExitSubscription.unsubscribe()
|
|
513
|
+
stopWebViewRestoreTracking()
|
|
487
514
|
triggerViewUpdate()
|
|
488
515
|
setTimeout(function () {
|
|
489
516
|
result.stop()
|
|
490
517
|
}, KEEP_TRACKING_AFTER_VIEW_DELAY)
|
|
491
518
|
},
|
|
492
519
|
stop: function () {
|
|
520
|
+
stopWebViewRestoreTracking()
|
|
493
521
|
stopInitialViewMetricsTracking()
|
|
494
522
|
stopEventCountsTracking()
|
|
495
523
|
stopINPTracking()
|
|
@@ -41,6 +41,9 @@ export function startRumBatch(
|
|
|
41
41
|
pageExitObservable,
|
|
42
42
|
sessionExpireObservable
|
|
43
43
|
)
|
|
44
|
+
const prepareUrgentFlushSubscription = batch.prepareUrgentFlushObservable.subscribe(
|
|
45
|
+
event => lifeCycle.notify(LifeCycleEventType.PAGE_EXITED, event)
|
|
46
|
+
)
|
|
44
47
|
const rumEventSubscription = lifeCycle.subscribe(
|
|
45
48
|
LifeCycleEventType.RUM_EVENT_COLLECTED,
|
|
46
49
|
function (serverRumEvent) {
|
|
@@ -93,6 +96,7 @@ export function startRumBatch(
|
|
|
93
96
|
add: batch.add,
|
|
94
97
|
upsert: batch.upsert,
|
|
95
98
|
stop: function () {
|
|
99
|
+
prepareUrgentFlushSubscription.unsubscribe()
|
|
96
100
|
rumEventSubscription.unsubscribe()
|
|
97
101
|
initialViewSubscription.unsubscribe()
|
|
98
102
|
forcedViewSubscription.unsubscribe()
|