@cloudcare/browser-rum 3.3.11 → 3.3.13
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/recorderApi.js +22 -2
- package/cjs/boot/recorderApi.js.map +1 -1
- package/cjs/boot/startRecording.js +52 -2
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/domain/assembly.js +15 -2
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/replay/record/canvasContinuousScheduler.js +1 -1
- package/cjs/domain/replay/record/canvasContinuousScheduler.js.map +1 -1
- package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/cjs/domain/replay/record/canvasObserver.js +1 -1
- package/cjs/domain/replay/record/canvasObserver.js.map +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +16 -6
- package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
- package/cjs/domain/replay/record/observers.js +45 -13
- package/cjs/domain/replay/record/observers.js.map +1 -1
- package/cjs/domain/replay/record/record.js +104 -15
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/replay/record/serializationUtils.js +1 -1
- package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +45 -17
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/replay/timeAnchor.js +27 -0
- package/cjs/domain/replay/timeAnchor.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackViews.js +31 -4
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/recorderApi.js +23 -3
- package/esm/boot/recorderApi.js.map +1 -1
- package/esm/boot/startRecording.js +52 -2
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/domain/assembly.js +16 -3
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/replay/record/canvasContinuousScheduler.js +1 -1
- package/esm/domain/replay/record/canvasContinuousScheduler.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/esm/domain/replay/record/canvasObserver.js +1 -1
- package/esm/domain/replay/record/canvasObserver.js.map +1 -1
- package/esm/domain/replay/record/mutationObserver.js +16 -6
- package/esm/domain/replay/record/mutationObserver.js.map +1 -1
- package/esm/domain/replay/record/observers.js +45 -13
- package/esm/domain/replay/record/observers.js.map +1 -1
- package/esm/domain/replay/record/record.js +89 -17
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/record/serializationUtils.js +1 -1
- package/esm/domain/replay/record/serializationUtils.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +45 -17
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/replay/timeAnchor.js +20 -0
- package/esm/domain/replay/timeAnchor.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackViews.js +31 -4
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/package.json +4 -4
- package/src/boot/recorderApi.js +25 -3
- package/src/boot/startRecording.js +53 -2
- package/src/domain/assembly.js +18 -4
- package/src/domain/replay/record/canvasContinuousScheduler.js +1 -2
- package/src/domain/replay/record/canvasObserver.js +1 -1
- package/src/domain/replay/record/mutationObserver.js +21 -11
- package/src/domain/replay/record/observers.js +65 -33
- package/src/domain/replay/record/record.js +169 -33
- package/src/domain/replay/record/serializationUtils.js +2 -2
- package/src/domain/replay/segmentCollection/segmentCollection.js +83 -18
- package/src/domain/replay/timeAnchor.js +33 -0
- package/src/domain/rumEventsCollection/view/trackViews.js +52 -8
- package/src/domain/rumEventsCollection/view/viewCollection.js +2 -1
|
@@ -12,6 +12,10 @@ import {
|
|
|
12
12
|
import { IncrementalSource, RecordType } from '../../../types'
|
|
13
13
|
import { buildReplayPayload } from './buildReplayPayload'
|
|
14
14
|
import { createSegment } from './segment'
|
|
15
|
+
import {
|
|
16
|
+
isSessionReplayTimeAnchor,
|
|
17
|
+
SESSION_REPLAY_TIME_ANCHOR_BACKPRESSURE_RESERVE
|
|
18
|
+
} from '../timeAnchor'
|
|
15
19
|
|
|
16
20
|
export var SEGMENT_DURATION_LIMIT = 5 * ONE_SECOND
|
|
17
21
|
/**
|
|
@@ -26,6 +30,7 @@ export var SEGMENT_BYTES_LIMIT = 60000
|
|
|
26
30
|
var SEGMENT_FORM_DATA_ESTIMATED_OVERHEAD = 2 * 1024
|
|
27
31
|
var SEGMENT_PENDING_RAW_BYTES_LIMIT = 4 * 1024 * 1024
|
|
28
32
|
var LOCKED_SEGMENTS_LIMIT = 12
|
|
33
|
+
var REPLAY_MEMORY_BUDGET_BYTES = 48 * 1024 * 1024
|
|
29
34
|
var CANVAS_FLUSH_MIN_INTERVAL = 250
|
|
30
35
|
var MAX_CONSECUTIVE_FULL_SNAPSHOT_FAILURES = 3
|
|
31
36
|
|
|
@@ -108,6 +113,7 @@ export function doStartSegmentCollection(
|
|
|
108
113
|
? options.pendingRawBytesLimit
|
|
109
114
|
: SEGMENT_PENDING_RAW_BYTES_LIMIT
|
|
110
115
|
var lockedSegments = []
|
|
116
|
+
var memoryBudget = options.memoryBudget
|
|
111
117
|
var lockedBufferGeneration = 0
|
|
112
118
|
var reportedDropReasons = {}
|
|
113
119
|
var lastCanvasFlushAt = -Infinity
|
|
@@ -142,12 +148,15 @@ export function doStartSegmentCollection(
|
|
|
142
148
|
$rLocked: isLocked,
|
|
143
149
|
$rGeneration: activeBaselineGeneration
|
|
144
150
|
}
|
|
151
|
+
if (memoryBudget) {
|
|
152
|
+
memoryBudget.$rSegment = getSegmentMemoryUsage
|
|
153
|
+
}
|
|
145
154
|
function prepareRecordsBeforePageExit(pageExitEvent) {
|
|
146
155
|
if (!options.beforePageExitFlush) {
|
|
147
156
|
return
|
|
148
157
|
}
|
|
149
158
|
try {
|
|
150
|
-
options.beforePageExitFlush(pageExitEvent)
|
|
159
|
+
return options.beforePageExitFlush(pageExitEvent)
|
|
151
160
|
} catch (error) {
|
|
152
161
|
addTelemetryDebug(
|
|
153
162
|
'Session Replay failed to prepare records before page exit.',
|
|
@@ -383,6 +392,10 @@ export function doStartSegmentCollection(
|
|
|
383
392
|
if (!isPageExitReason(flushReason)) {
|
|
384
393
|
return
|
|
385
394
|
}
|
|
395
|
+
var exitState =
|
|
396
|
+
flushReason === PageExitReason.HIDDEN
|
|
397
|
+
? PageExitReason.HIDDEN
|
|
398
|
+
: true
|
|
386
399
|
if (flushReason === PageExitReason.UNLOADING) {
|
|
387
400
|
unloadingTransportLatched = true
|
|
388
401
|
if (unloadingDeliveryBytesRemaining === undefined) {
|
|
@@ -391,7 +404,7 @@ export function doStartSegmentCollection(
|
|
|
391
404
|
drainRetryPayloadsForUnload()
|
|
392
405
|
}
|
|
393
406
|
inFlightSegmentFlushes.forEach(function (transport) {
|
|
394
|
-
transport.$rExit =
|
|
407
|
+
transport.$rExit = exitState
|
|
395
408
|
})
|
|
396
409
|
// A dependent segment can finish encoding before its Full Snapshot and is
|
|
397
410
|
// then removed from inFlightSegmentFlushes while waiting for the baseline
|
|
@@ -404,7 +417,7 @@ export function doStartSegmentCollection(
|
|
|
404
417
|
pendingSegmentResultsByGeneration[baselineGeneration].forEach(function (
|
|
405
418
|
segmentResult
|
|
406
419
|
) {
|
|
407
|
-
segmentResult.$rExit =
|
|
420
|
+
segmentResult.$rExit = exitState
|
|
408
421
|
})
|
|
409
422
|
})
|
|
410
423
|
}
|
|
@@ -499,8 +512,7 @@ export function doStartSegmentCollection(
|
|
|
499
512
|
}
|
|
500
513
|
var shouldUseExitTransport =
|
|
501
514
|
!segmentResult.$rRegular &&
|
|
502
|
-
(segmentResult.$rExit ||
|
|
503
|
-
isPageExitReason(segmentResult.$rReason) ||
|
|
515
|
+
(segmentResult.$rExit === true ||
|
|
504
516
|
unloadingTransportLatched)
|
|
505
517
|
var estimatedDeliveryBytesCount =
|
|
506
518
|
encoderResult.outputBytesCount +
|
|
@@ -526,12 +538,21 @@ export function doStartSegmentCollection(
|
|
|
526
538
|
)
|
|
527
539
|
payload.$rExitBytesCount = estimatedDeliveryBytesCount
|
|
528
540
|
payload.$rEnforceOrder = true
|
|
541
|
+
payload.$rKeepalive = Boolean(
|
|
542
|
+
!shouldUseExitTransport &&
|
|
543
|
+
segmentResult.$rExit === PageExitReason.HIDDEN &&
|
|
544
|
+
estimatedDeliveryBytesCount <= SEGMENT_BYTES_LIMIT
|
|
545
|
+
)
|
|
529
546
|
payload.$rIsValid = function () {
|
|
530
547
|
return segmentResult.$rTransportGeneration.$rValid
|
|
531
548
|
}
|
|
532
549
|
payload.$rOnPermanentDrop = function (reason) {
|
|
533
550
|
handlePermanentTransportDrop(segmentResult, reason)
|
|
534
551
|
}
|
|
552
|
+
// Blob owns the encoded bytes after buildReplayPayload(). Release the
|
|
553
|
+
// original Uint8Array reference while transport callbacks keep only the
|
|
554
|
+
// generation metadata.
|
|
555
|
+
segmentResult.$rEncoder = undefined
|
|
535
556
|
|
|
536
557
|
if (shouldUseExitTransport) {
|
|
537
558
|
var exitDeliveryResult = httpRequest.sendOnExit(
|
|
@@ -571,9 +592,8 @@ export function doStartSegmentCollection(
|
|
|
571
592
|
}
|
|
572
593
|
|
|
573
594
|
function retainLockedSegment(segmentResult) {
|
|
574
|
-
//
|
|
575
|
-
//
|
|
576
|
-
// regular transport instead of retaining a stale sendOnExit decision.
|
|
595
|
+
// Locked error-session buffers are only delivered after checkout. Clear
|
|
596
|
+
// any historical page-exit hint so a later unlock uses regular transport.
|
|
577
597
|
segmentResult.$rExit = false
|
|
578
598
|
segmentResult.$rRegular = true
|
|
579
599
|
if (replayResetNeeded) {
|
|
@@ -594,7 +614,12 @@ export function doStartSegmentCollection(
|
|
|
594
614
|
lockedSegments.splice(0, latestFullSnapshotIndex)
|
|
595
615
|
}
|
|
596
616
|
|
|
597
|
-
if (
|
|
617
|
+
if (
|
|
618
|
+
lockedSegments.length > LOCKED_SEGMENTS_LIMIT ||
|
|
619
|
+
(memoryBudget &&
|
|
620
|
+
getSegmentMemoryUsage() + memoryBudget.$rRecord() >
|
|
621
|
+
REPLAY_MEMORY_BUDGET_BYTES)
|
|
622
|
+
) {
|
|
598
623
|
// Incremental segments form a dependency chain. Keeping the anchor while
|
|
599
624
|
// deleting a middle segment can leave later records referencing nodes the
|
|
600
625
|
// player never received. Retire the whole lock generation and admit no
|
|
@@ -610,6 +635,29 @@ export function doStartSegmentCollection(
|
|
|
610
635
|
}
|
|
611
636
|
}
|
|
612
637
|
|
|
638
|
+
function getLockedSegmentsBytesCount() {
|
|
639
|
+
return lockedSegments.reduce(function (bytesCount, segmentResult) {
|
|
640
|
+
var encoderResult = segmentResult.$rEncoder
|
|
641
|
+
return (
|
|
642
|
+
bytesCount +
|
|
643
|
+
(encoderResult &&
|
|
644
|
+
typeof encoderResult.outputBytesCount === 'number'
|
|
645
|
+
? encoderResult.outputBytesCount
|
|
646
|
+
: 0)
|
|
647
|
+
)
|
|
648
|
+
}, 0)
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
function getSegmentMemoryUsage() {
|
|
652
|
+
return (
|
|
653
|
+
getPendingRawBytesCount() +
|
|
654
|
+
getLockedSegmentsBytesCount() +
|
|
655
|
+
(typeof httpRequest.$rPendingBytes === 'function'
|
|
656
|
+
? httpRequest.$rPendingBytes()
|
|
657
|
+
: 0)
|
|
658
|
+
)
|
|
659
|
+
}
|
|
660
|
+
|
|
613
661
|
function drainLockedSegments() {
|
|
614
662
|
const segmentsToSend = lockedSegments
|
|
615
663
|
lockedSegments = []
|
|
@@ -812,7 +860,10 @@ export function doStartSegmentCollection(
|
|
|
812
860
|
const lockedGeneration = segmentState.$rLockGeneration
|
|
813
861
|
const baselineGeneration = state.$rGeneration
|
|
814
862
|
const transport = {
|
|
815
|
-
$rExit:
|
|
863
|
+
$rExit:
|
|
864
|
+
flushReason === PageExitReason.HIDDEN
|
|
865
|
+
? PageExitReason.HIDDEN
|
|
866
|
+
: isPageExitReason(flushReason),
|
|
816
867
|
$rSequence: ++nextSegmentFlushSequence
|
|
817
868
|
}
|
|
818
869
|
clearTimeout(state.$rExpiration)
|
|
@@ -922,6 +973,12 @@ export function doStartSegmentCollection(
|
|
|
922
973
|
const segmentState = state
|
|
923
974
|
const segment = segmentState.$rSegment
|
|
924
975
|
var synchronousEncoderError
|
|
976
|
+
var isTimeAnchor = isSessionReplayTimeAnchor(record)
|
|
977
|
+
var recordPendingRawBytesLimit = pendingRawBytesLimit
|
|
978
|
+
if (isTimeAnchor && recordPendingRawBytesLimit !== undefined) {
|
|
979
|
+
recordPendingRawBytesLimit +=
|
|
980
|
+
SESSION_REPLAY_TIME_ANCHOR_BACKPRESSURE_RESERVE
|
|
981
|
+
}
|
|
925
982
|
var addResult = segment.addRecord(
|
|
926
983
|
record,
|
|
927
984
|
function (encodedBytesCount, error) {
|
|
@@ -966,7 +1023,11 @@ export function doStartSegmentCollection(
|
|
|
966
1023
|
scheduleReplayResetNotification()
|
|
967
1024
|
},
|
|
968
1025
|
ignoreSegmentBytesLimit ? undefined : SEGMENT_BYTES_LIMIT,
|
|
969
|
-
|
|
1026
|
+
// The SDK time anchor is a fixed, tiny, state-free boundary. Give it a
|
|
1027
|
+
// small bounded reserve behind the regular worker backlog without
|
|
1028
|
+
// synchronously draining that backlog; segment size and async action
|
|
1029
|
+
// ordering remain unchanged.
|
|
1030
|
+
recordPendingRawBytesLimit,
|
|
970
1031
|
serializedRecordData
|
|
971
1032
|
)
|
|
972
1033
|
if (synchronousEncoderError) {
|
|
@@ -1198,6 +1259,7 @@ export function doStartSegmentCollection(
|
|
|
1198
1259
|
$rAddBaselineRecords: addBaselineRecords,
|
|
1199
1260
|
addRecord: function (record) {
|
|
1200
1261
|
lastAddRecordWasBackpressured = false
|
|
1262
|
+
var isTimeAnchor = isSessionReplayTimeAnchor(record)
|
|
1201
1263
|
if (state.$rStatus === SegmentCollectionStatus.Stopped) {
|
|
1202
1264
|
return rejectRecordAdmission()
|
|
1203
1265
|
}
|
|
@@ -1256,7 +1318,10 @@ export function doStartSegmentCollection(
|
|
|
1256
1318
|
// publishes any DOM membership carried by the record. Returning false
|
|
1257
1319
|
// lets it cancel that staged membership, so the existing baseline
|
|
1258
1320
|
// remains valid and does not need a global reset.
|
|
1259
|
-
if (
|
|
1321
|
+
if (
|
|
1322
|
+
record.type !== RecordType.IncrementalSnapshot &&
|
|
1323
|
+
!isTimeAnchor
|
|
1324
|
+
) {
|
|
1260
1325
|
failBaselineGeneration(
|
|
1261
1326
|
addResult.$rGeneration,
|
|
1262
1327
|
record.type === RecordType.FullSnapshot
|
|
@@ -1294,7 +1359,10 @@ export function doStartSegmentCollection(
|
|
|
1294
1359
|
// See the synchronous incremental rejection rationale above. Full
|
|
1295
1360
|
// snapshots and non-incremental baseline records retain the existing
|
|
1296
1361
|
// recovery semantics.
|
|
1297
|
-
if (
|
|
1362
|
+
if (
|
|
1363
|
+
record.type !== RecordType.IncrementalSnapshot &&
|
|
1364
|
+
!isTimeAnchor
|
|
1365
|
+
) {
|
|
1298
1366
|
failBaselineGeneration(
|
|
1299
1367
|
addResult.$rGeneration,
|
|
1300
1368
|
record.type === RecordType.FullSnapshot
|
|
@@ -1417,11 +1485,8 @@ export function doStartSegmentCollection(
|
|
|
1417
1485
|
}
|
|
1418
1486
|
}
|
|
1419
1487
|
flushSegment(flushReason || 'stop', undefined, true)
|
|
1420
|
-
// Normal stop/session renewal
|
|
1421
|
-
//
|
|
1422
|
-
// encoder queues a reset after each finish, so a restarted recorder can
|
|
1423
|
-
// append a new generation while these old results complete in order.
|
|
1424
|
-
// Only a real unload needs the bounded synchronous drain.
|
|
1488
|
+
// Normal stop/session renewal leaves shared encoder groups to complete
|
|
1489
|
+
// asynchronously. Only a real unload uses the bounded synchronous drain.
|
|
1425
1490
|
flushPendingSegmentEncodingsForUnload(flushReason)
|
|
1426
1491
|
unsubscribeLifecycle()
|
|
1427
1492
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export var SESSION_REPLAY_TIME_ANCHOR_INTERVAL = 60 * 1000
|
|
2
|
+
// Keep enough headroom for a final stateless anchor when the regular replay
|
|
3
|
+
// encoder backlog has reached its limit, without turning the exemption into an
|
|
4
|
+
// unbounded queue if the worker remains stalled.
|
|
5
|
+
export var SESSION_REPLAY_TIME_ANCHOR_BACKPRESSURE_RESERVE = 4 * 1024
|
|
6
|
+
// rrweb EventType.Custom. Keep this internal record wire-compatible without
|
|
7
|
+
// expanding the SDK's public RecordType contract.
|
|
8
|
+
export var SESSION_REPLAY_TIME_ANCHOR_RECORD_TYPE = 5
|
|
9
|
+
export var SESSION_REPLAY_TIME_ANCHOR_TAG =
|
|
10
|
+
'rum-session-replay-time-anchor'
|
|
11
|
+
|
|
12
|
+
export function isSessionReplayTimeAnchor(record) {
|
|
13
|
+
if (
|
|
14
|
+
!record ||
|
|
15
|
+
record.type !== SESSION_REPLAY_TIME_ANCHOR_RECORD_TYPE ||
|
|
16
|
+
typeof record.timestamp !== 'number' ||
|
|
17
|
+
!record.data ||
|
|
18
|
+
record.data.tag !== SESSION_REPLAY_TIME_ANCHOR_TAG ||
|
|
19
|
+
!record.data.payload
|
|
20
|
+
) {
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
23
|
+
// Only the fixed, state-free SDK record may bypass the shared encoder raw
|
|
24
|
+
// backlog limit. A customer Custom event reusing the tag, adding fields or
|
|
25
|
+
// carrying a payload must retain the normal non-incremental failure rules.
|
|
26
|
+
return (
|
|
27
|
+
Object.keys(record).length === 3 &&
|
|
28
|
+
Object.keys(record.data).length === 2 &&
|
|
29
|
+
typeof record.data.payload === 'object' &&
|
|
30
|
+
!Array.isArray(record.data.payload) &&
|
|
31
|
+
Object.keys(record.data.payload).length === 0
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -39,7 +39,8 @@ export function trackViews(
|
|
|
39
39
|
configuration,
|
|
40
40
|
locationChangeObservable,
|
|
41
41
|
areViewsTrackedAutomatically,
|
|
42
|
-
initialViewOptions
|
|
42
|
+
initialViewOptions,
|
|
43
|
+
recorderApi
|
|
43
44
|
) {
|
|
44
45
|
var eventBridgeAvailable = canUseEventBridge()
|
|
45
46
|
var isWebViewActive =
|
|
@@ -62,7 +63,8 @@ export function trackViews(
|
|
|
62
63
|
startClocks,
|
|
63
64
|
viewOptions,
|
|
64
65
|
canMatchSoftNavigation,
|
|
65
|
-
fallbackNavigationType
|
|
66
|
+
fallbackNavigationType,
|
|
67
|
+
recorderApi
|
|
66
68
|
)
|
|
67
69
|
activeViews.add(newlyCreatedView)
|
|
68
70
|
newlyCreatedView.stopObservable.subscribe(function () {
|
|
@@ -186,10 +188,7 @@ export function trackViews(
|
|
|
186
188
|
},
|
|
187
189
|
startView: function (options, startClocks) {
|
|
188
190
|
var fallbackNavigationType
|
|
189
|
-
if (
|
|
190
|
-
pendingNavigation &&
|
|
191
|
-
pendingNavigation[0] === location.href
|
|
192
|
-
) {
|
|
191
|
+
if (pendingNavigation && pendingNavigation[0] === location.href) {
|
|
193
192
|
fallbackNavigationType = pendingNavigation[1]
|
|
194
193
|
}
|
|
195
194
|
pendingNavigation = undefined
|
|
@@ -235,7 +234,8 @@ function newView(
|
|
|
235
234
|
startClocks,
|
|
236
235
|
viewOptions,
|
|
237
236
|
canMatchSoftNavigation,
|
|
238
|
-
fallbackNavigationType
|
|
237
|
+
fallbackNavigationType,
|
|
238
|
+
recorderApi
|
|
239
239
|
) {
|
|
240
240
|
// Setup initial values
|
|
241
241
|
if (startClocks === undefined) {
|
|
@@ -325,10 +325,51 @@ function newView(
|
|
|
325
325
|
triggerViewUpdate,
|
|
326
326
|
SESSION_KEEP_ALIVE_INTERVAL
|
|
327
327
|
)
|
|
328
|
+
var replayWasRecording = Boolean(
|
|
329
|
+
recorderApi &&
|
|
330
|
+
typeof recorderApi.isRecording === 'function' &&
|
|
331
|
+
recorderApi.isRecording()
|
|
332
|
+
)
|
|
333
|
+
function updateReplayRecordingState(isRecording) {
|
|
334
|
+
if (replayWasRecording === isRecording) {
|
|
335
|
+
return
|
|
336
|
+
}
|
|
337
|
+
replayWasRecording = isRecording
|
|
338
|
+
if (endClocks === undefined) {
|
|
339
|
+
// Recorder start/stop boundaries need an immediate View update. The
|
|
340
|
+
// existing five-minute View keepalive already covers long-lived active
|
|
341
|
+
// Views, so Replay must not add a second one-minute upload loop.
|
|
342
|
+
triggerViewUpdate()
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
var replayRecordingStateSubscription
|
|
346
|
+
var hasReplayRecordingStateObservable = Boolean(
|
|
347
|
+
recorderApi &&
|
|
348
|
+
recorderApi.recordingStateObservable &&
|
|
349
|
+
typeof recorderApi.recordingStateObservable.subscribe === 'function'
|
|
350
|
+
)
|
|
351
|
+
if (hasReplayRecordingStateObservable) {
|
|
352
|
+
replayRecordingStateSubscription =
|
|
353
|
+
recorderApi.recordingStateObservable.subscribe(updateReplayRecordingState)
|
|
354
|
+
}
|
|
328
355
|
const pageMayExitSubscription = lifeCycle.subscribe(
|
|
329
356
|
LifeCycleEventType.PAGE_EXITED,
|
|
330
357
|
(pageMayExitEvent) => {
|
|
331
|
-
|
|
358
|
+
var isReplayRecording =
|
|
359
|
+
recorderApi &&
|
|
360
|
+
typeof recorderApi.isRecording === 'function' &&
|
|
361
|
+
recorderApi.isRecording()
|
|
362
|
+
if (
|
|
363
|
+
(pageMayExitEvent.reason === PageExitReason.UNLOADING &&
|
|
364
|
+
(!isReplayRecording || !hasReplayRecordingStateObservable)) ||
|
|
365
|
+
(pageMayExitEvent.reason !== PageExitReason.UNLOADING &&
|
|
366
|
+
isReplayRecording)
|
|
367
|
+
) {
|
|
368
|
+
// Replay segments flush at every page-exit boundary. Keep the View
|
|
369
|
+
// duration aligned with those boundaries only while Replay is active;
|
|
370
|
+
// unloading remains the existing update boundary for every RUM view.
|
|
371
|
+
// An active recorder with a state observable publishes its final View
|
|
372
|
+
// after stop, so do not publish the same unload boundary twice here.
|
|
332
373
|
triggerViewUpdate()
|
|
333
374
|
}
|
|
334
375
|
}
|
|
@@ -400,6 +441,9 @@ function newView(
|
|
|
400
441
|
endClocks: endClocks
|
|
401
442
|
})
|
|
402
443
|
clearInterval(keepAliveIntervalId)
|
|
444
|
+
if (replayRecordingStateSubscription) {
|
|
445
|
+
replayRecordingStateSubscription.unsubscribe()
|
|
446
|
+
}
|
|
403
447
|
setViewEnd(endClocks.relative)
|
|
404
448
|
stopCommonViewMetricsTracking()
|
|
405
449
|
pageMayExitSubscription.unsubscribe()
|