@cloudcare/browser-rum 3.2.49 → 3.3.0

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 (192) hide show
  1. package/README.md +89 -1
  2. package/README.zh.md +105 -0
  3. package/bundle/dataflux-rum.js +1 -1
  4. package/cjs/boot/buildEnv.js +1 -1
  5. package/cjs/boot/perStartRum.js +16 -0
  6. package/cjs/boot/perStartRum.js.map +1 -1
  7. package/cjs/boot/recorderApi.js +154 -1
  8. package/cjs/boot/recorderApi.js.map +1 -1
  9. package/cjs/boot/rum.js +17 -2
  10. package/cjs/boot/rum.js.map +1 -1
  11. package/cjs/boot/rumPublicApi.js +52 -3
  12. package/cjs/boot/rumPublicApi.js.map +1 -1
  13. package/cjs/boot/startRecording.js +69 -4
  14. package/cjs/boot/startRecording.js.map +1 -1
  15. package/cjs/domain/configuration.js +99 -1
  16. package/cjs/domain/configuration.js.map +1 -1
  17. package/cjs/domain/deflate/deflateWorker.js +1 -1
  18. package/cjs/domain/replay/record/canvasAutoSnapshot.js +15 -0
  19. package/cjs/domain/replay/record/canvasAutoSnapshot.js.map +1 -0
  20. package/cjs/domain/replay/record/canvasCommandCapture.js +480 -0
  21. package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -0
  22. package/cjs/domain/replay/record/canvasCommandObserver.js +274 -0
  23. package/cjs/domain/replay/record/canvasCommandObserver.js.map +1 -0
  24. package/cjs/domain/replay/record/canvasCommandSerializeArgs.js +94 -0
  25. package/cjs/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -0
  26. package/cjs/domain/replay/record/canvasContinuousScheduler.js +255 -0
  27. package/cjs/domain/replay/record/canvasContinuousScheduler.js.map +1 -0
  28. package/cjs/domain/replay/record/canvasEncodeBridge.js +247 -0
  29. package/cjs/domain/replay/record/canvasEncodeBridge.js.map +1 -0
  30. package/cjs/domain/replay/record/canvasEncodeWorker.js +154 -0
  31. package/cjs/domain/replay/record/canvasEncodeWorker.js.map +1 -0
  32. package/cjs/domain/replay/record/canvasFrameSignature.js +50 -0
  33. package/cjs/domain/replay/record/canvasFrameSignature.js.map +1 -0
  34. package/cjs/domain/replay/record/canvasMutationRecord.js +33 -0
  35. package/cjs/domain/replay/record/canvasMutationRecord.js.map +1 -0
  36. package/cjs/domain/replay/record/canvasObserver.js +190 -0
  37. package/cjs/domain/replay/record/canvasObserver.js.map +1 -0
  38. package/cjs/domain/replay/record/canvasReplayFixtures.js +105 -0
  39. package/cjs/domain/replay/record/canvasReplayFixtures.js.map +1 -0
  40. package/cjs/domain/replay/record/canvasSerializeArgs.js +110 -0
  41. package/cjs/domain/replay/record/canvasSerializeArgs.js.map +1 -0
  42. package/cjs/domain/replay/record/mutationBatch.js +7 -2
  43. package/cjs/domain/replay/record/mutationBatch.js.map +1 -1
  44. package/cjs/domain/replay/record/mutationObserver.js +369 -55
  45. package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
  46. package/cjs/domain/replay/record/observers.js +8 -3
  47. package/cjs/domain/replay/record/observers.js.map +1 -1
  48. package/cjs/domain/replay/record/record.js +478 -1
  49. package/cjs/domain/replay/record/record.js.map +1 -1
  50. package/cjs/domain/replay/record/serializationUtils.js +60 -4
  51. package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
  52. package/cjs/domain/replay/record/serialize.js +169 -46
  53. package/cjs/domain/replay/record/serialize.js.map +1 -1
  54. package/cjs/domain/replay/segmentCollection/segment.js +58 -1
  55. package/cjs/domain/replay/segmentCollection/segment.js.map +1 -1
  56. package/cjs/domain/replay/segmentCollection/segmentCollection.js +29 -3
  57. package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  58. package/cjs/domain/requestCollection.js +1 -1
  59. package/cjs/domain/requestCollection.js.map +1 -1
  60. package/cjs/domain/rumEventsCollection/actions/clickChain.js +1 -1
  61. package/cjs/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
  62. package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js +2 -1
  63. package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
  64. package/cjs/domain/rumEventsCollection/error/trackReportError.js +2 -2
  65. package/cjs/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
  66. package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +43 -39
  67. package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
  68. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +48 -8
  69. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  70. package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js +237 -0
  71. package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -0
  72. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  73. package/cjs/domain/rumSessionManager.js +2 -0
  74. package/cjs/domain/rumSessionManager.js.map +1 -1
  75. package/cjs/domain/tracing/skywalkingTracer.js +1 -1
  76. package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
  77. package/cjs/types/sessionReplayConstants.js +2 -2
  78. package/cjs/types/sessionReplayConstants.js.map +1 -1
  79. package/esm/boot/buildEnv.js +1 -1
  80. package/esm/boot/perStartRum.js +16 -0
  81. package/esm/boot/perStartRum.js.map +1 -1
  82. package/esm/boot/recorderApi.js +154 -1
  83. package/esm/boot/recorderApi.js.map +1 -1
  84. package/esm/boot/rum.js +17 -2
  85. package/esm/boot/rum.js.map +1 -1
  86. package/esm/boot/rumPublicApi.js +52 -3
  87. package/esm/boot/rumPublicApi.js.map +1 -1
  88. package/esm/boot/startRecording.js +70 -5
  89. package/esm/boot/startRecording.js.map +1 -1
  90. package/esm/domain/configuration.js +100 -2
  91. package/esm/domain/configuration.js.map +1 -1
  92. package/esm/domain/deflate/deflateWorker.js +1 -1
  93. package/esm/domain/replay/record/canvasAutoSnapshot.js +9 -0
  94. package/esm/domain/replay/record/canvasAutoSnapshot.js.map +1 -0
  95. package/esm/domain/replay/record/canvasCommandCapture.js +474 -0
  96. package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -0
  97. package/esm/domain/replay/record/canvasCommandObserver.js +268 -0
  98. package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -0
  99. package/esm/domain/replay/record/canvasCommandSerializeArgs.js +87 -0
  100. package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -0
  101. package/esm/domain/replay/record/canvasContinuousScheduler.js +249 -0
  102. package/esm/domain/replay/record/canvasContinuousScheduler.js.map +1 -0
  103. package/esm/domain/replay/record/canvasEncodeBridge.js +240 -0
  104. package/esm/domain/replay/record/canvasEncodeBridge.js.map +1 -0
  105. package/esm/domain/replay/record/canvasEncodeWorker.js +146 -0
  106. package/esm/domain/replay/record/canvasEncodeWorker.js.map +1 -0
  107. package/esm/domain/replay/record/canvasFrameSignature.js +42 -0
  108. package/esm/domain/replay/record/canvasFrameSignature.js.map +1 -0
  109. package/esm/domain/replay/record/canvasMutationRecord.js +26 -0
  110. package/esm/domain/replay/record/canvasMutationRecord.js.map +1 -0
  111. package/esm/domain/replay/record/canvasObserver.js +184 -0
  112. package/esm/domain/replay/record/canvasObserver.js.map +1 -0
  113. package/esm/domain/replay/record/canvasReplayFixtures.js +96 -0
  114. package/esm/domain/replay/record/canvasReplayFixtures.js.map +1 -0
  115. package/esm/domain/replay/record/canvasSerializeArgs.js +101 -0
  116. package/esm/domain/replay/record/canvasSerializeArgs.js.map +1 -0
  117. package/esm/domain/replay/record/mutationBatch.js +7 -2
  118. package/esm/domain/replay/record/mutationBatch.js.map +1 -1
  119. package/esm/domain/replay/record/mutationObserver.js +369 -56
  120. package/esm/domain/replay/record/mutationObserver.js.map +1 -1
  121. package/esm/domain/replay/record/observers.js +8 -3
  122. package/esm/domain/replay/record/observers.js.map +1 -1
  123. package/esm/domain/replay/record/record.js +479 -2
  124. package/esm/domain/replay/record/record.js.map +1 -1
  125. package/esm/domain/replay/record/serializationUtils.js +58 -4
  126. package/esm/domain/replay/record/serializationUtils.js.map +1 -1
  127. package/esm/domain/replay/record/serialize.js +168 -47
  128. package/esm/domain/replay/record/serialize.js.map +1 -1
  129. package/esm/domain/replay/segmentCollection/segment.js +59 -2
  130. package/esm/domain/replay/segmentCollection/segment.js.map +1 -1
  131. package/esm/domain/replay/segmentCollection/segmentCollection.js +30 -4
  132. package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  133. package/esm/domain/requestCollection.js +1 -1
  134. package/esm/domain/requestCollection.js.map +1 -1
  135. package/esm/domain/rumEventsCollection/actions/clickChain.js +1 -1
  136. package/esm/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
  137. package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js +2 -1
  138. package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
  139. package/esm/domain/rumEventsCollection/error/trackReportError.js +2 -2
  140. package/esm/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
  141. package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +43 -38
  142. package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
  143. package/esm/domain/rumEventsCollection/resource/resourceCollection.js +50 -10
  144. package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  145. package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js +231 -0
  146. package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -0
  147. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  148. package/esm/domain/rumSessionManager.js +2 -0
  149. package/esm/domain/rumSessionManager.js.map +1 -1
  150. package/esm/domain/tracing/skywalkingTracer.js +1 -1
  151. package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
  152. package/esm/types/sessionReplayConstants.js +2 -2
  153. package/esm/types/sessionReplayConstants.js.map +1 -1
  154. package/package.json +5 -5
  155. package/src/boot/perStartRum.js +16 -0
  156. package/src/boot/recorderApi.js +162 -1
  157. package/src/boot/rum.js +21 -2
  158. package/src/boot/rumPublicApi.js +59 -3
  159. package/src/boot/startRecording.js +94 -5
  160. package/src/domain/configuration.js +229 -1
  161. package/src/domain/replay/record/canvasAutoSnapshot.js +8 -0
  162. package/src/domain/replay/record/canvasCommandCapture.js +621 -0
  163. package/src/domain/replay/record/canvasCommandObserver.js +355 -0
  164. package/src/domain/replay/record/canvasCommandSerializeArgs.js +124 -0
  165. package/src/domain/replay/record/canvasContinuousScheduler.js +295 -0
  166. package/src/domain/replay/record/canvasEncodeBridge.js +299 -0
  167. package/src/domain/replay/record/canvasEncodeWorker.js +211 -0
  168. package/src/domain/replay/record/canvasFrameSignature.js +83 -0
  169. package/src/domain/replay/record/canvasMutationRecord.js +29 -0
  170. package/src/domain/replay/record/canvasObserver.js +279 -0
  171. package/src/domain/replay/record/canvasReplayFixtures.js +113 -0
  172. package/src/domain/replay/record/canvasSerializeArgs.js +129 -0
  173. package/src/domain/replay/record/mutationBatch.js +8 -2
  174. package/src/domain/replay/record/mutationObserver.js +449 -66
  175. package/src/domain/replay/record/observers.js +15 -3
  176. package/src/domain/replay/record/record.js +658 -2
  177. package/src/domain/replay/record/serializationUtils.js +75 -4
  178. package/src/domain/replay/record/serialize.js +217 -49
  179. package/src/domain/replay/segmentCollection/segment.js +65 -2
  180. package/src/domain/replay/segmentCollection/segmentCollection.js +46 -4
  181. package/src/domain/requestCollection.js +5 -1
  182. package/src/domain/rumEventsCollection/actions/clickChain.js +1 -1
  183. package/src/domain/rumEventsCollection/actions/interactionSelectorCache.js +2 -1
  184. package/src/domain/rumEventsCollection/error/trackReportError.js +3 -2
  185. package/src/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +51 -46
  186. package/src/domain/rumEventsCollection/resource/resourceCollection.js +69 -10
  187. package/src/domain/rumEventsCollection/resource/resourceTrackerManager.js +264 -0
  188. package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +0 -1
  189. package/src/domain/rumSessionManager.js +2 -0
  190. package/src/domain/tracing/skywalkingTracer.js +1 -1
  191. package/src/types/sessionReplayConstants.js +2 -2
  192. package/types/index.d.ts +133 -1
@@ -34,6 +34,7 @@ export function createPreStartStrategy(
34
34
  var cachedInitConfiguration
35
35
  var cachedConfiguration
36
36
  var cachedRemoteConfiguration
37
+ var resourceTrackerManager = rumPublicApiOptions.resourceTrackerManager
37
38
  function tryStartRum() {
38
39
  if (!cachedInitConfiguration || !cachedConfiguration) {
39
40
  return
@@ -235,6 +236,21 @@ export function createPreStartStrategy(
235
236
  bufferApiCalls.add(function (startRumResult) {
236
237
  startRumResult.addError(providedError, commonContext)
237
238
  })
239
+ },
240
+ createResourceTrackerId: function () {
241
+ return resourceTrackerManager.createTrackerId()
242
+ },
243
+ setResourceContext: function (trackerId, context) {
244
+ resourceTrackerManager.setResourceContext(trackerId, context)
245
+ },
246
+ appendResourceContext: function (trackerId, context) {
247
+ resourceTrackerManager.appendResourceContext(trackerId, context)
248
+ },
249
+ finishResource: function (trackerId) {
250
+ resourceTrackerManager.finishResource(trackerId)
251
+ },
252
+ getResource: function (trackerId) {
253
+ return resourceTrackerManager.getResource(trackerId)
238
254
  }
239
255
  }
240
256
  }
@@ -37,6 +37,36 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
37
37
  start: noop,
38
38
  stop: noop,
39
39
  takeSubsequentFullSnapshot: noop,
40
+ snapshotCanvas: function () {
41
+ return {
42
+ ok: false,
43
+ reason: 'not_recording'
44
+ }
45
+ },
46
+ getSerializedNodeIdForDebug: function () {
47
+ return undefined
48
+ },
49
+ getLastAutoCanvasSnapshotResultForDebug: function () {
50
+ return undefined
51
+ },
52
+ getAutoCanvasSnapshotDebugHistoryForDebug: function () {
53
+ return undefined
54
+ },
55
+ getLastCanvasMutationForDebug: function () {
56
+ return undefined
57
+ },
58
+ getCanvasMutationHistoryForDebug: function () {
59
+ return undefined
60
+ },
61
+ getLastReplaySegmentFlushForDebug: function () {
62
+ return undefined
63
+ },
64
+ getReplaySegmentFlushHistoryForDebug: function () {
65
+ return undefined
66
+ },
67
+ getReplayPerformanceForDebug: function () {
68
+ return undefined
69
+ },
40
70
  getReplayStats: function () {
41
71
  return undefined
42
72
  },
@@ -58,6 +88,36 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
58
88
  state = { status: RecorderStatus.Stopped }
59
89
  }
60
90
  var takeSubsequentFullSnapshot = function () {}
91
+ var snapshotCanvas = function () {
92
+ return {
93
+ ok: false,
94
+ reason: 'not_recording'
95
+ }
96
+ }
97
+ var getSerializedNodeIdForDebug = function () {
98
+ return undefined
99
+ }
100
+ var getLastAutoCanvasSnapshotResultForDebug = function () {
101
+ return undefined
102
+ }
103
+ var getAutoCanvasSnapshotDebugHistoryForDebug = function () {
104
+ return undefined
105
+ }
106
+ var getLastCanvasMutationForDebug = function () {
107
+ return undefined
108
+ }
109
+ var getCanvasMutationHistoryForDebug = function () {
110
+ return undefined
111
+ }
112
+ var getLastReplaySegmentFlushForDebug = function () {
113
+ return undefined
114
+ }
115
+ var getReplaySegmentFlushHistoryForDebug = function () {
116
+ return undefined
117
+ }
118
+ var getReplayPerformanceForDebug = function () {
119
+ return undefined
120
+ }
61
121
  return {
62
122
  start: function (options) {
63
123
  startStrategy(options)
@@ -154,7 +214,24 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
154
214
  state = {
155
215
  status: RecorderStatus.Started,
156
216
  stopRecording: recordingImpl.stop,
157
- takeSubsequentFullSnapshot: recordingImpl.takeSubsequentFullSnapshot
217
+ takeSubsequentFullSnapshot: recordingImpl.takeSubsequentFullSnapshot,
218
+ snapshotCanvas: recordingImpl.snapshotCanvas || noop,
219
+ getSerializedNodeIdForDebug:
220
+ recordingImpl.getSerializedNodeIdForDebug || noop,
221
+ getLastAutoCanvasSnapshotResultForDebug:
222
+ recordingImpl.getLastAutoCanvasSnapshotResultForDebug || noop,
223
+ getAutoCanvasSnapshotDebugHistoryForDebug:
224
+ recordingImpl.getAutoCanvasSnapshotDebugHistoryForDebug || noop,
225
+ getLastCanvasMutationForDebug:
226
+ recordingImpl.getLastCanvasMutationForDebug || noop,
227
+ getCanvasMutationHistoryForDebug:
228
+ recordingImpl.getCanvasMutationHistoryForDebug || noop,
229
+ getLastReplaySegmentFlushForDebug:
230
+ recordingImpl.getLastReplaySegmentFlushForDebug || noop,
231
+ getReplaySegmentFlushHistoryForDebug:
232
+ recordingImpl.getReplaySegmentFlushHistoryForDebug || noop,
233
+ getReplayPerformanceForDebug:
234
+ recordingImpl.getReplayPerformanceForDebug || noop
158
235
  }
159
236
  })
160
237
  }
@@ -175,6 +252,63 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
175
252
  takeSubsequentFullSnapshot = function () {
176
253
  state.takeSubsequentFullSnapshot()
177
254
  }
255
+ snapshotCanvas = function (canvas, options) {
256
+ if (state.status === RecorderStatus.Started) {
257
+ return state.snapshotCanvas(canvas, options)
258
+ }
259
+ return {
260
+ ok: false,
261
+ reason: 'not_recording'
262
+ }
263
+ }
264
+ getSerializedNodeIdForDebug = function (node) {
265
+ if (state.status === RecorderStatus.Started) {
266
+ return state.getSerializedNodeIdForDebug(node)
267
+ }
268
+ return undefined
269
+ }
270
+ getLastAutoCanvasSnapshotResultForDebug = function () {
271
+ if (state.status === RecorderStatus.Started) {
272
+ return state.getLastAutoCanvasSnapshotResultForDebug()
273
+ }
274
+ return undefined
275
+ }
276
+ getAutoCanvasSnapshotDebugHistoryForDebug = function () {
277
+ if (state.status === RecorderStatus.Started) {
278
+ return state.getAutoCanvasSnapshotDebugHistoryForDebug()
279
+ }
280
+ return undefined
281
+ }
282
+ getLastCanvasMutationForDebug = function () {
283
+ if (state.status === RecorderStatus.Started) {
284
+ return state.getLastCanvasMutationForDebug()
285
+ }
286
+ return undefined
287
+ }
288
+ getCanvasMutationHistoryForDebug = function () {
289
+ if (state.status === RecorderStatus.Started) {
290
+ return state.getCanvasMutationHistoryForDebug()
291
+ }
292
+ return undefined
293
+ }
294
+ getLastReplaySegmentFlushForDebug = function () {
295
+ if (state.status === RecorderStatus.Started) {
296
+ return state.getLastReplaySegmentFlushForDebug()
297
+ }
298
+ return undefined
299
+ }
300
+ getReplaySegmentFlushHistoryForDebug = function () {
301
+ if (state.status === RecorderStatus.Started) {
302
+ return state.getReplaySegmentFlushHistoryForDebug()
303
+ }
304
+ return undefined
305
+ }
306
+ getReplayPerformanceForDebug = function () {
307
+ if (state.status === RecorderStatus.Started) {
308
+ return state.getReplayPerformanceForDebug()
309
+ }
310
+ return undefined
311
+ }
178
312
  if (state.status === RecorderStatus.IntentToStart) {
179
313
  startStrategy()
180
314
  }
@@ -182,6 +316,33 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
182
316
  takeSubsequentFullSnapshot() {
183
317
  takeSubsequentFullSnapshot()
184
318
  },
319
+ snapshotCanvas: function (canvas, options) {
320
+ return snapshotCanvas(canvas, options)
321
+ },
322
+ getSerializedNodeIdForDebug: function (node) {
323
+ return getSerializedNodeIdForDebug(node)
324
+ },
325
+ getLastReplaySegmentFlushForDebug: function () {
326
+ return getLastReplaySegmentFlushForDebug()
327
+ },
328
+ getLastAutoCanvasSnapshotResultForDebug: function () {
329
+ return getLastAutoCanvasSnapshotResultForDebug()
330
+ },
331
+ getAutoCanvasSnapshotDebugHistoryForDebug: function () {
332
+ return getAutoCanvasSnapshotDebugHistoryForDebug()
333
+ },
334
+ getLastCanvasMutationForDebug: function () {
335
+ return getLastCanvasMutationForDebug()
336
+ },
337
+ getCanvasMutationHistoryForDebug: function () {
338
+ return getCanvasMutationHistoryForDebug()
339
+ },
340
+ getReplaySegmentFlushHistoryForDebug: function () {
341
+ return getReplaySegmentFlushHistoryForDebug()
342
+ },
343
+ getReplayPerformanceForDebug: function () {
344
+ return getReplayPerformanceForDebug()
345
+ },
185
346
  isRecording: function () {
186
347
  return (
187
348
  getDeflateWorkerStatus() === DeflateWorkerStatus.Initialized &&
package/src/boot/rum.js CHANGED
@@ -37,7 +37,8 @@ export function startRum(
37
37
  customerDataTrackerManager,
38
38
  getCommonContext,
39
39
  initialViewOptions,
40
- createEncoder
40
+ createEncoder,
41
+ resourceTrackerManager
41
42
  ) {
42
43
  var cleanupTasks = []
43
44
  var lifeCycle = new LifeCycle()
@@ -137,7 +138,10 @@ export function startRum(
137
138
  const _startResourceCollection = startResourceCollection(
138
139
  lifeCycle,
139
140
  configuration,
140
- pageStateHistory
141
+ pageStateHistory,
142
+ undefined,
143
+ undefined,
144
+ resourceTrackerManager
141
145
  )
142
146
  var addResource = _startResourceCollection.addResource
143
147
  cleanupTasks.push(_startResourceCollection.stop)
@@ -197,6 +201,21 @@ export function startRum(
197
201
  cleanupTasks.forEach(function (task) {
198
202
  task()
199
203
  })
204
+ },
205
+ createResourceTrackerId: function () {
206
+ return resourceTrackerManager.createTrackerId()
207
+ },
208
+ setResourceContext: function (trackerId, context) {
209
+ resourceTrackerManager.setResourceContext(trackerId, context)
210
+ },
211
+ appendResourceContext: function (trackerId, context) {
212
+ resourceTrackerManager.appendResourceContext(trackerId, context)
213
+ },
214
+ finishResource: function (trackerId) {
215
+ resourceTrackerManager.finishResource(trackerId)
216
+ },
217
+ getResource: function (trackerId) {
218
+ return resourceTrackerManager.getResource(trackerId)
200
219
  }
201
220
  }
202
221
  }
@@ -23,6 +23,7 @@ import {
23
23
  } from '@cloudcare/browser-core'
24
24
  import { buildCommonContext } from '../domain/contexts/commonContext'
25
25
  import { createPreStartStrategy } from './perStartRum'
26
+ import { createResourceTrackerManager } from '../domain/rumEventsCollection/resource/resourceTrackerManager'
26
27
  var RUM_STORAGE_KEY = 'rum'
27
28
  export function makeRumPublicApi(startRumImpl, recorderApi, options) {
28
29
  if (options === undefined) {
@@ -31,6 +32,7 @@ export function makeRumPublicApi(startRumImpl, recorderApi, options) {
31
32
  const customerDataTrackerManager = createCustomerDataTrackerManager(
32
33
  CustomerDataCompressionStatus.Unknown
33
34
  )
35
+ const resourceTrackerManager = createResourceTrackerManager()
34
36
  const globalContextManager = createContextManager('global', {
35
37
  customerDataTracker: customerDataTrackerManager.getOrCreateTracker(
36
38
  CustomerDataType.GlobalContext
@@ -54,7 +56,9 @@ export function makeRumPublicApi(startRumImpl, recorderApi, options) {
54
56
  )
55
57
  }
56
58
  let strategy = createPreStartStrategy(
57
- options,
59
+ assign({}, options, {
60
+ resourceTrackerManager: resourceTrackerManager
61
+ }),
58
62
  getCommonContext,
59
63
  function (configuration, deflateWorker, initialViewOptions) {
60
64
  if (configuration.storeContextsToLocal) {
@@ -86,7 +90,8 @@ export function makeRumPublicApi(startRumImpl, recorderApi, options) {
86
90
  ? function (streamId) {
87
91
  return options.createDeflateEncoder(deflateWorker, streamId)
88
92
  }
89
- : createIdentityEncoder
93
+ : createIdentityEncoder,
94
+ resourceTrackerManager
90
95
  )
91
96
  recorderApi.onRumStart(
92
97
  startRumResult.lifeCycle,
@@ -288,8 +293,59 @@ export function makeRumPublicApi(startRumImpl, recorderApi, options) {
288
293
  force: options && options.force
289
294
  })
290
295
  }),
296
+ isRecording: monitor(function () {
297
+ return recorderApi.isRecording()
298
+ }),
291
299
  stopSessionReplayRecording: monitor(recorderApi.stop),
292
- takeSubsequentFullSnapshot: monitor(recorderApi.takeSubsequentFullSnapshot)
300
+ takeSubsequentFullSnapshot: monitor(recorderApi.takeSubsequentFullSnapshot),
301
+ snapshotCanvas: monitor(function (canvas, options) {
302
+ return recorderApi.snapshotCanvas(canvas, options)
303
+ }),
304
+ getSerializedNodeIdForDebug: monitor(function (node) {
305
+ return recorderApi.getSerializedNodeIdForDebug(node)
306
+ }),
307
+ getLastAutoCanvasSnapshotResultForDebug: monitor(function () {
308
+ return recorderApi.getLastAutoCanvasSnapshotResultForDebug()
309
+ }),
310
+ getAutoCanvasSnapshotDebugHistoryForDebug: monitor(function () {
311
+ return recorderApi.getAutoCanvasSnapshotDebugHistoryForDebug()
312
+ }),
313
+ getLastCanvasMutationForDebug: monitor(function () {
314
+ return recorderApi.getLastCanvasMutationForDebug()
315
+ }),
316
+ getCanvasMutationHistoryForDebug: monitor(function () {
317
+ return recorderApi.getCanvasMutationHistoryForDebug()
318
+ }),
319
+ getLastReplaySegmentFlushForDebug: monitor(function () {
320
+ return recorderApi.getLastReplaySegmentFlushForDebug()
321
+ }),
322
+ getReplaySegmentFlushHistoryForDebug: monitor(function () {
323
+ return recorderApi.getReplaySegmentFlushHistoryForDebug()
324
+ }),
325
+ getReplayPerformanceForDebug: monitor(function () {
326
+ return recorderApi.getReplayPerformanceForDebug()
327
+ }),
328
+ createResourceTrackerId: monitor(function () {
329
+ return resourceTrackerManager.createTrackerId()
330
+ }),
331
+ setResourceContext: monitor(function (trackerId, context) {
332
+ return resourceTrackerManager.setResourceContext(
333
+ trackerId,
334
+ sanitize(context)
335
+ )
336
+ }),
337
+ appendResourceContext: monitor(function (trackerId, context) {
338
+ return resourceTrackerManager.appendResourceContext(
339
+ trackerId,
340
+ sanitize(context)
341
+ )
342
+ }),
343
+ finishResource: monitor(function (trackerId) {
344
+ return resourceTrackerManager.finishResource(trackerId)
345
+ }),
346
+ getResource: monitor(function (trackerId) {
347
+ return resourceTrackerManager.getResource(trackerId)
348
+ })
293
349
  })
294
350
  return rumPublicApi
295
351
  }
@@ -4,7 +4,8 @@ import {
4
4
  LifeCycleEventType,
5
5
  addTelemetryDebug,
6
6
  ONE_SECOND,
7
- canUseEventBridge
7
+ canUseEventBridge,
8
+ assign
8
9
  } from '@cloudcare/browser-core'
9
10
  import { record } from '../domain/replay/record'
10
11
  import { startRecordBridge } from '../domain/replay/startRecordBridge'
@@ -16,6 +17,7 @@ import { RecordType } from '../types'
16
17
  import { deleteOldestStats } from '../domain/replay/replayStats'
17
18
  /* How long to wait for error checkouts */
18
19
  export const BUFFER_CHECKOUT_TIME = 60 * ONE_SECOND
20
+ var REPLAY_SEGMENT_FLUSH_HISTORY_LIMIT = 10
19
21
  export function startRecording(
20
22
  lifeCycle,
21
23
  configuration,
@@ -25,6 +27,9 @@ export function startRecording(
25
27
  httpRequest
26
28
  ) {
27
29
  var cleanupTasks = []
30
+ var lastReplaySegmentFlushForDebug
31
+ var replaySegmentFlushHistoryForDebug = []
32
+ var replaySegmentFlushCount = 0
28
33
  var reportError = function (error) {
29
34
  lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error })
30
35
  addTelemetryDebug('Error reported to customer', {
@@ -53,7 +58,24 @@ export function startRecording(
53
58
  viewContexts,
54
59
  replayRequest,
55
60
  encoder,
56
- isRecordErrorSessionReplay
61
+ isRecordErrorSessionReplay,
62
+ {
63
+ onSegmentFlushed: function (segmentFlush) {
64
+ replaySegmentFlushCount += 1
65
+ lastReplaySegmentFlushForDebug =
66
+ cloneReplaySegmentFlushForDebug(
67
+ segmentFlush,
68
+ replaySegmentFlushCount
69
+ )
70
+ replaySegmentFlushHistoryForDebug.push(lastReplaySegmentFlushForDebug)
71
+ if (
72
+ replaySegmentFlushHistoryForDebug.length >
73
+ REPLAY_SEGMENT_FLUSH_HISTORY_LIMIT
74
+ ) {
75
+ replaySegmentFlushHistoryForDebug.shift()
76
+ }
77
+ }
78
+ }
57
79
  )
58
80
  addRecord = segmentCollection.addRecord
59
81
  let flushBufferSegment = segmentCollection.flushBufferSegment
@@ -92,18 +114,45 @@ export function startRecording(
92
114
  _record = record({
93
115
  emit: wrappedEmit,
94
116
  configuration: configuration,
95
- lifeCycle: lifeCycle
117
+ lifeCycle: lifeCycle,
118
+ sessionManager: sessionManager
96
119
  })
97
120
  } else {
98
121
  ;({ addRecord } = startRecordBridge(viewContexts))
99
122
  _record = record({
100
123
  emit: addRecord,
101
124
  configuration: configuration,
102
- lifeCycle: lifeCycle
125
+ lifeCycle: lifeCycle,
126
+ sessionManager: sessionManager
103
127
  })
104
128
  }
105
129
  cleanupTasks.push(_record.stop)
106
130
  var takeSubsequentFullSnapshot = _record.takeSubsequentFullSnapshot
131
+ var snapshotCanvas = _record.snapshotCanvas
132
+ var getSerializedNodeIdForDebug = _record.getSerializedNodeIdForDebug
133
+ var getLastAutoCanvasSnapshotResultForDebug =
134
+ _record.getLastAutoCanvasSnapshotResultForDebug
135
+ var getAutoCanvasSnapshotDebugHistoryForDebug =
136
+ _record.getAutoCanvasSnapshotDebugHistoryForDebug
137
+ var getLastCanvasMutationForDebug = _record.getLastCanvasMutationForDebug
138
+ var getCanvasMutationHistoryForDebug =
139
+ _record.getCanvasMutationHistoryForDebug
140
+ var getReplayPerformanceForDebug = function () {
141
+ return cloneReplayPerformanceForDebug(
142
+ _record.getReplayPerformanceForDebug
143
+ ? _record.getReplayPerformanceForDebug()
144
+ : undefined,
145
+ replaySegmentFlushCount
146
+ )
147
+ }
148
+ var getLastReplaySegmentFlushForDebug = function () {
149
+ return cloneReplaySegmentFlushForDebug(lastReplaySegmentFlushForDebug)
150
+ }
151
+ var getReplaySegmentFlushHistoryForDebug = function () {
152
+ return replaySegmentFlushHistoryForDebug.map(function (segmentFlush) {
153
+ return cloneReplaySegmentFlushForDebug(segmentFlush)
154
+ })
155
+ }
107
156
  var flushMutations = _record.flushMutations
108
157
  var subscribeViewEnded = lifeCycle.subscribe(
109
158
  LifeCycleEventType.VIEW_ENDED,
@@ -130,6 +179,46 @@ export function startRecording(
130
179
  task()
131
180
  })
132
181
  },
133
- takeSubsequentFullSnapshot: takeSubsequentFullSnapshot
182
+ takeSubsequentFullSnapshot: takeSubsequentFullSnapshot,
183
+ snapshotCanvas: snapshotCanvas,
184
+ getSerializedNodeIdForDebug: getSerializedNodeIdForDebug,
185
+ getLastAutoCanvasSnapshotResultForDebug:
186
+ getLastAutoCanvasSnapshotResultForDebug,
187
+ getAutoCanvasSnapshotDebugHistoryForDebug:
188
+ getAutoCanvasSnapshotDebugHistoryForDebug,
189
+ getLastCanvasMutationForDebug: getLastCanvasMutationForDebug,
190
+ getCanvasMutationHistoryForDebug: getCanvasMutationHistoryForDebug,
191
+ getLastReplaySegmentFlushForDebug: getLastReplaySegmentFlushForDebug,
192
+ getReplaySegmentFlushHistoryForDebug:
193
+ getReplaySegmentFlushHistoryForDebug,
194
+ getReplayPerformanceForDebug: getReplayPerformanceForDebug
195
+ }
196
+ }
197
+
198
+ function cloneReplaySegmentFlushForDebug(segmentFlush, sequence) {
199
+ if (!segmentFlush) {
200
+ return segmentFlush
201
+ }
202
+
203
+ return {
204
+ sequence: typeof sequence === 'number' ? sequence : segmentFlush.sequence,
205
+ creationReason: segmentFlush.creationReason,
206
+ flushReason: segmentFlush.flushReason,
207
+ recordsCount: segmentFlush.recordsCount,
208
+ recordCountsByType: assign({}, segmentFlush.recordCountsByType),
209
+ start: segmentFlush.start,
210
+ end: segmentFlush.end,
211
+ indexInView: segmentFlush.indexInView,
212
+ rawBytesCount: segmentFlush.rawBytesCount
134
213
  }
135
214
  }
215
+
216
+ function cloneReplayPerformanceForDebug(stats, replaySegmentFlushCount) {
217
+ if (!stats && typeof replaySegmentFlushCount === 'undefined') {
218
+ return undefined
219
+ }
220
+
221
+ return assign({}, stats || {}, {
222
+ replaySegmentFlushCount: replaySegmentFlushCount || 0
223
+ })
224
+ }