@cloudcare/browser-rum 3.3.12 → 3.3.14

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.
Files changed (83) hide show
  1. package/bundle/dataflux-rum.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/recorderApi.js +22 -2
  4. package/cjs/boot/recorderApi.js.map +1 -1
  5. package/cjs/boot/startRecording.js +54 -1
  6. package/cjs/boot/startRecording.js.map +1 -1
  7. package/cjs/domain/assembly.js +15 -2
  8. package/cjs/domain/assembly.js.map +1 -1
  9. package/cjs/domain/configuration.js +1 -0
  10. package/cjs/domain/configuration.js.map +1 -1
  11. package/cjs/domain/deflate/deflateWorker.js +1 -1
  12. package/cjs/domain/privacy.js +278 -0
  13. package/cjs/domain/privacy.js.map +1 -0
  14. package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
  15. package/cjs/domain/replay/record/mutationObserver.js +16 -6
  16. package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
  17. package/cjs/domain/replay/record/privacy.js +11 -272
  18. package/cjs/domain/replay/record/privacy.js.map +1 -1
  19. package/cjs/domain/replay/record/record.js +94 -8
  20. package/cjs/domain/replay/record/record.js.map +1 -1
  21. package/cjs/domain/replay/segmentCollection/segmentCollection.js +45 -17
  22. package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  23. package/cjs/domain/replay/timeAnchor.js +27 -0
  24. package/cjs/domain/replay/timeAnchor.js.map +1 -0
  25. package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js +81 -19
  26. package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
  27. package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +11 -4
  28. package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
  29. package/cjs/domain/rumEventsCollection/view/trackViews.js +45 -7
  30. package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  31. package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -1
  32. package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  33. package/cjs/domain/rumSessionManager.js +2 -2
  34. package/cjs/domain/rumSessionManager.js.map +1 -1
  35. package/esm/boot/buildEnv.js +1 -1
  36. package/esm/boot/recorderApi.js +23 -3
  37. package/esm/boot/recorderApi.js.map +1 -1
  38. package/esm/boot/startRecording.js +54 -1
  39. package/esm/boot/startRecording.js.map +1 -1
  40. package/esm/domain/assembly.js +16 -3
  41. package/esm/domain/assembly.js.map +1 -1
  42. package/esm/domain/configuration.js +1 -0
  43. package/esm/domain/configuration.js.map +1 -1
  44. package/esm/domain/deflate/deflateWorker.js +1 -1
  45. package/esm/domain/privacy.js +266 -0
  46. package/esm/domain/privacy.js.map +1 -0
  47. package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
  48. package/esm/domain/replay/record/mutationObserver.js +16 -6
  49. package/esm/domain/replay/record/mutationObserver.js.map +1 -1
  50. package/esm/domain/replay/record/privacy.js +1 -266
  51. package/esm/domain/replay/record/privacy.js.map +1 -1
  52. package/esm/domain/replay/record/record.js +78 -9
  53. package/esm/domain/replay/record/record.js.map +1 -1
  54. package/esm/domain/replay/segmentCollection/segmentCollection.js +45 -17
  55. package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  56. package/esm/domain/replay/timeAnchor.js +20 -0
  57. package/esm/domain/replay/timeAnchor.js.map +1 -0
  58. package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js +80 -18
  59. package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
  60. package/esm/domain/rumEventsCollection/actions/trackClickActions.js +11 -4
  61. package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
  62. package/esm/domain/rumEventsCollection/view/trackViews.js +46 -8
  63. package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  64. package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -1
  65. package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  66. package/esm/domain/rumSessionManager.js +2 -2
  67. package/esm/domain/rumSessionManager.js.map +1 -1
  68. package/package.json +4 -4
  69. package/src/boot/recorderApi.js +25 -3
  70. package/src/boot/startRecording.js +61 -1
  71. package/src/domain/assembly.js +18 -4
  72. package/src/domain/configuration.js +4 -0
  73. package/src/domain/privacy.js +356 -0
  74. package/src/domain/replay/record/mutationObserver.js +21 -11
  75. package/src/domain/replay/record/privacy.js +1 -356
  76. package/src/domain/replay/record/record.js +129 -8
  77. package/src/domain/replay/segmentCollection/segmentCollection.js +83 -18
  78. package/src/domain/replay/timeAnchor.js +33 -0
  79. package/src/domain/rumEventsCollection/actions/getActionNameFromElement.js +148 -21
  80. package/src/domain/rumEventsCollection/actions/trackClickActions.js +19 -5
  81. package/src/domain/rumEventsCollection/view/trackViews.js +83 -12
  82. package/src/domain/rumEventsCollection/view/viewCollection.js +2 -1
  83. package/src/domain/rumSessionManager.js +2 -2
@@ -11,6 +11,7 @@ import {
11
11
  ViewLoadingType,
12
12
  LifeCycleEventType,
13
13
  PageExitReason,
14
+ SESSION_TIME_OUT_DELAY,
14
15
  isHashAnAnchor,
15
16
  getPathFromHash,
16
17
  noop,
@@ -39,9 +40,13 @@ export function trackViews(
39
40
  configuration,
40
41
  locationChangeObservable,
41
42
  areViewsTrackedAutomatically,
42
- initialViewOptions
43
+ initialViewOptions,
44
+ recorderApi
43
45
  ) {
44
46
  var eventBridgeAvailable = canUseEventBridge()
47
+ var maxViewDuration = eventBridgeAvailable
48
+ ? Infinity
49
+ : SESSION_TIME_OUT_DELAY
45
50
  var isWebViewActive =
46
51
  !eventBridgeAvailable ||
47
52
  (document.visibilityState !== 'hidden' && document.hasFocus())
@@ -62,7 +67,9 @@ export function trackViews(
62
67
  startClocks,
63
68
  viewOptions,
64
69
  canMatchSoftNavigation,
65
- fallbackNavigationType
70
+ fallbackNavigationType,
71
+ recorderApi,
72
+ maxViewDuration
66
73
  )
67
74
  activeViews.add(newlyCreatedView)
68
75
  newlyCreatedView.stopObservable.subscribe(function () {
@@ -134,9 +141,26 @@ export function trackViews(
134
141
  }
135
142
  lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, renewCurrentView)
136
143
 
137
- lifeCycle.subscribe(LifeCycleEventType.SESSION_EXPIRED, function () {
138
- currentView.end({ sessionIsActive: false })
139
- })
144
+ lifeCycle.subscribe(
145
+ LifeCycleEventType.SESSION_EXPIRED,
146
+ function (sessionExpirationTime) {
147
+ var sessionExpirationClocks
148
+ if (
149
+ typeof sessionExpirationTime === 'number' &&
150
+ sessionExpirationTime >= currentView.startClocks.timeStamp
151
+ ) {
152
+ const origin = clocksOrigin()
153
+ sessionExpirationClocks = {
154
+ relative: elapsed(origin.timeStamp, sessionExpirationTime),
155
+ timeStamp: sessionExpirationTime
156
+ }
157
+ }
158
+ currentView.end({
159
+ sessionIsActive: false,
160
+ endClocks: sessionExpirationClocks
161
+ })
162
+ }
163
+ )
140
164
 
141
165
  if (eventBridgeAvailable) {
142
166
  function updateWebViewLifecycle(event) {
@@ -186,10 +210,7 @@ export function trackViews(
186
210
  },
187
211
  startView: function (options, startClocks) {
188
212
  var fallbackNavigationType
189
- if (
190
- pendingNavigation &&
191
- pendingNavigation[0] === location.href
192
- ) {
213
+ if (pendingNavigation && pendingNavigation[0] === location.href) {
193
214
  fallbackNavigationType = pendingNavigation[1]
194
215
  }
195
216
  pendingNavigation = undefined
@@ -235,7 +256,9 @@ function newView(
235
256
  startClocks,
236
257
  viewOptions,
237
258
  canMatchSoftNavigation,
238
- fallbackNavigationType
259
+ fallbackNavigationType,
260
+ recorderApi,
261
+ maxViewDuration
239
262
  ) {
240
263
  // Setup initial values
241
264
  if (startClocks === undefined) {
@@ -325,10 +348,51 @@ function newView(
325
348
  triggerViewUpdate,
326
349
  SESSION_KEEP_ALIVE_INTERVAL
327
350
  )
351
+ var replayWasRecording = Boolean(
352
+ recorderApi &&
353
+ typeof recorderApi.isRecording === 'function' &&
354
+ recorderApi.isRecording()
355
+ )
356
+ function updateReplayRecordingState(isRecording) {
357
+ if (replayWasRecording === isRecording) {
358
+ return
359
+ }
360
+ replayWasRecording = isRecording
361
+ if (endClocks === undefined) {
362
+ // Recorder start/stop boundaries need an immediate View update. The
363
+ // existing five-minute View keepalive already covers long-lived active
364
+ // Views, so Replay must not add a second one-minute upload loop.
365
+ triggerViewUpdate()
366
+ }
367
+ }
368
+ var replayRecordingStateSubscription
369
+ var hasReplayRecordingStateObservable = Boolean(
370
+ recorderApi &&
371
+ recorderApi.recordingStateObservable &&
372
+ typeof recorderApi.recordingStateObservable.subscribe === 'function'
373
+ )
374
+ if (hasReplayRecordingStateObservable) {
375
+ replayRecordingStateSubscription =
376
+ recorderApi.recordingStateObservable.subscribe(updateReplayRecordingState)
377
+ }
328
378
  const pageMayExitSubscription = lifeCycle.subscribe(
329
379
  LifeCycleEventType.PAGE_EXITED,
330
380
  (pageMayExitEvent) => {
331
- if (pageMayExitEvent.reason === PageExitReason.UNLOADING) {
381
+ var isReplayRecording =
382
+ recorderApi &&
383
+ typeof recorderApi.isRecording === 'function' &&
384
+ recorderApi.isRecording()
385
+ if (
386
+ (pageMayExitEvent.reason === PageExitReason.UNLOADING &&
387
+ (!isReplayRecording || !hasReplayRecordingStateObservable)) ||
388
+ (pageMayExitEvent.reason !== PageExitReason.UNLOADING &&
389
+ isReplayRecording)
390
+ ) {
391
+ // Replay segments flush at every page-exit boundary. Keep the View
392
+ // duration aligned with those boundaries only while Replay is active;
393
+ // unloading remains the existing update boundary for every RUM view.
394
+ // An active recorder with a state observable publishes its final View
395
+ // after stop, so do not publish the same unload boundary twice here.
332
396
  triggerViewUpdate()
333
397
  }
334
398
  }
@@ -370,7 +434,10 @@ function newView(
370
434
  startClocks: startClocks,
371
435
  commonViewMetrics: getCommonViewMetrics(),
372
436
  initialViewMetrics: initialViewMetrics,
373
- duration: elapsed(startClocks.timeStamp, currentEnd),
437
+ duration: Math.min(
438
+ elapsed(startClocks.timeStamp, currentEnd),
439
+ maxViewDuration
440
+ ),
374
441
  isActive: endClocks === undefined,
375
442
  sessionIsActive: sessionIsActive,
376
443
  eventCounts: eventCounts
@@ -381,6 +448,7 @@ function newView(
381
448
  service: service,
382
449
  version: version,
383
450
  contextManager: contextManager,
451
+ startClocks: startClocks,
384
452
  stopObservable: stopObservable,
385
453
  end: function (options) {
386
454
  if (endClocks) {
@@ -400,6 +468,9 @@ function newView(
400
468
  endClocks: endClocks
401
469
  })
402
470
  clearInterval(keepAliveIntervalId)
471
+ if (replayRecordingStateSubscription) {
472
+ replayRecordingStateSubscription.unsubscribe()
473
+ }
403
474
  setViewEnd(endClocks.relative)
404
475
  stopCommonViewMetricsTracking()
405
476
  pageMayExitSubscription.unsubscribe()
@@ -35,7 +35,8 @@ export function startViewCollection(
35
35
  configuration,
36
36
  locationChangeObservable,
37
37
  !configuration.trackViewsManually,
38
- initialViewOptions
38
+ initialViewOptions,
39
+ recorderApi
39
40
  )
40
41
  }
41
42
  function computePerformanceViewDetails(navigationTimings) {
@@ -43,8 +43,8 @@ export function startRumSessionManager(configuration, lifeCycle) {
43
43
  }
44
44
  )
45
45
 
46
- sessionManager.expireObservable.subscribe(function () {
47
- lifeCycle.notify(LifeCycleEventType.SESSION_EXPIRED)
46
+ sessionManager.expireObservable.subscribe(function (sessionExpirationTime) {
47
+ lifeCycle.notify(LifeCycleEventType.SESSION_EXPIRED, sessionExpirationTime)
48
48
  })
49
49
 
50
50
  sessionManager.renewObservable.subscribe(function () {