@cloudcare/browser-rum 3.3.6 → 3.3.7

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 (354) hide show
  1. package/README.md +24 -3
  2. package/README.zh.md +19 -3
  3. package/bundle/dataflux-rum.js +1 -1
  4. package/cjs/boot/buildEnv.js +1 -1
  5. package/cjs/boot/buildEnv.js.map +1 -1
  6. package/cjs/boot/perStartRum.js.map +1 -1
  7. package/cjs/boot/recorderApi.js +170 -200
  8. package/cjs/boot/recorderApi.js.map +1 -1
  9. package/cjs/boot/recorderApiStub.js +3 -29
  10. package/cjs/boot/recorderApiStub.js.map +1 -1
  11. package/cjs/boot/rum.entry.js.map +1 -1
  12. package/cjs/boot/rum.js.map +1 -1
  13. package/cjs/boot/rum.slim.entry.js.map +1 -1
  14. package/cjs/boot/rumEntryFactory.js.map +1 -1
  15. package/cjs/boot/rumPublicApi.js.map +1 -1
  16. package/cjs/boot/rumRecorderApiStub.js.map +1 -1
  17. package/cjs/boot/rumSlimConfiguration.js.map +1 -1
  18. package/cjs/boot/sessionReplayPublicApi.js +14 -27
  19. package/cjs/boot/sessionReplayPublicApi.js.map +1 -1
  20. package/cjs/boot/startRecording.js +333 -108
  21. package/cjs/boot/startRecording.js.map +1 -1
  22. package/cjs/constants.js.map +1 -1
  23. package/cjs/domain/assembly.js +1 -7
  24. package/cjs/domain/assembly.js.map +1 -1
  25. package/cjs/domain/configuration.js +31 -43
  26. package/cjs/domain/configuration.js.map +1 -1
  27. package/cjs/domain/contexts/commonContext.js.map +1 -1
  28. package/cjs/domain/contexts/displayContext.js.map +1 -1
  29. package/cjs/domain/contexts/foregroundContexts.js.map +1 -1
  30. package/cjs/domain/contexts/internalContext.js.map +1 -1
  31. package/cjs/domain/contexts/pageStateHistory.js.map +1 -1
  32. package/cjs/domain/contexts/urlContexts.js +10 -1
  33. package/cjs/domain/contexts/urlContexts.js.map +1 -1
  34. package/cjs/domain/contexts/viewContexts.js.map +1 -1
  35. package/cjs/domain/deflate/deflateEncoder.js +517 -39
  36. package/cjs/domain/deflate/deflateEncoder.js.map +1 -1
  37. package/cjs/domain/deflate/deflateWorker.js +194 -115
  38. package/cjs/domain/deflate/deflateWorker.js.map +1 -1
  39. package/cjs/domain/deflate/index.js.map +1 -1
  40. package/cjs/domain/domMutationObservable.js.map +1 -1
  41. package/cjs/domain/encoderStreamId.js.map +1 -1
  42. package/cjs/domain/firstInputPolyfill.js.map +1 -1
  43. package/cjs/domain/initViewportObservable.js.map +1 -1
  44. package/cjs/domain/locationChangeObservable.js.map +1 -1
  45. package/cjs/domain/performanceObservable.js.map +1 -1
  46. package/cjs/domain/performanceUtils.js.map +1 -1
  47. package/cjs/domain/plugins.js.map +1 -1
  48. package/cjs/domain/replay/record/canvasAutoSnapshot.js.map +1 -1
  49. package/cjs/domain/replay/record/canvasCommandCapture.js +968 -167
  50. package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -1
  51. package/cjs/domain/replay/record/canvasCommandObserver.js +1058 -119
  52. package/cjs/domain/replay/record/canvasCommandObserver.js.map +1 -1
  53. package/cjs/domain/replay/record/canvasCommandSerializeArgs.js +61 -37
  54. package/cjs/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
  55. package/cjs/domain/replay/record/canvasContext.js +63 -0
  56. package/cjs/domain/replay/record/canvasContext.js.map +1 -0
  57. package/cjs/domain/replay/record/canvasContinuousScheduler.js +246 -118
  58. package/cjs/domain/replay/record/canvasContinuousScheduler.js.map +1 -1
  59. package/cjs/domain/replay/record/canvasEncodeBridge.js +539 -87
  60. package/cjs/domain/replay/record/canvasEncodeBridge.js.map +1 -1
  61. package/cjs/domain/replay/record/canvasEncodeWorker.js +50 -32
  62. package/cjs/domain/replay/record/canvasEncodeWorker.js.map +1 -1
  63. package/cjs/domain/replay/record/canvasFrameSignature.js +49 -17
  64. package/cjs/domain/replay/record/canvasFrameSignature.js.map +1 -1
  65. package/cjs/domain/replay/record/canvasMutationRecord.js.map +1 -1
  66. package/cjs/domain/replay/record/canvasObserver.js +295 -59
  67. package/cjs/domain/replay/record/canvasObserver.js.map +1 -1
  68. package/cjs/domain/replay/record/canvasSerializeArgs.js.map +1 -1
  69. package/cjs/domain/replay/record/canvasWebGLPluginHost.js +33 -0
  70. package/cjs/domain/replay/record/canvasWebGLPluginHost.js.map +1 -0
  71. package/cjs/domain/replay/record/elementsScrollPositions.js +3 -0
  72. package/cjs/domain/replay/record/elementsScrollPositions.js.map +1 -1
  73. package/cjs/domain/replay/record/index.js.map +1 -1
  74. package/cjs/domain/replay/record/mutationBatch.js +542 -25
  75. package/cjs/domain/replay/record/mutationBatch.js.map +1 -1
  76. package/cjs/domain/replay/record/mutationObserver.js +1900 -191
  77. package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
  78. package/cjs/domain/replay/record/mutationResourceBudget.js +144 -0
  79. package/cjs/domain/replay/record/mutationResourceBudget.js.map +1 -0
  80. package/cjs/domain/replay/record/observers.js +222 -53
  81. package/cjs/domain/replay/record/observers.js.map +1 -1
  82. package/cjs/domain/replay/record/privacy.js +31 -8
  83. package/cjs/domain/replay/record/privacy.js.map +1 -1
  84. package/cjs/domain/replay/record/record.js +3083 -321
  85. package/cjs/domain/replay/record/record.js.map +1 -1
  86. package/cjs/domain/replay/record/serializationUtils.js +426 -26
  87. package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
  88. package/cjs/domain/replay/record/serialize.js +259 -49
  89. package/cjs/domain/replay/record/serialize.js.map +1 -1
  90. package/cjs/domain/replay/record/shadowRootsController.js +875 -21
  91. package/cjs/domain/replay/record/shadowRootsController.js.map +1 -1
  92. package/cjs/domain/replay/record/utils.js.map +1 -1
  93. package/cjs/domain/replay/record/viewports.js.map +1 -1
  94. package/cjs/domain/replay/replayStats.js.map +1 -1
  95. package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
  96. package/cjs/domain/replay/segmentCollection/index.js.map +1 -1
  97. package/cjs/domain/replay/segmentCollection/segment.js +315 -11
  98. package/cjs/domain/replay/segmentCollection/segment.js.map +1 -1
  99. package/cjs/domain/replay/segmentCollection/segmentCollection.js +956 -71
  100. package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  101. package/cjs/domain/replay/startRecordBridge.js.map +1 -1
  102. package/cjs/domain/requestCollection.js.map +1 -1
  103. package/cjs/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
  104. package/cjs/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
  105. package/cjs/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -1
  106. package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
  107. package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
  108. package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
  109. package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
  110. package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
  111. package/cjs/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
  112. package/cjs/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
  113. package/cjs/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
  114. package/cjs/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
  115. package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
  116. package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
  117. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  118. package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
  119. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
  120. package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
  121. package/cjs/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -1
  122. package/cjs/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -1
  123. package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
  124. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  125. package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
  126. package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
  127. package/cjs/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
  128. package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
  129. package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
  130. package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
  131. package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
  132. package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
  133. package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
  134. package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
  135. package/cjs/domain/rumEventsCollection/view/trackViews.js +29 -11
  136. package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  137. package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  138. package/cjs/domain/rumSessionManager.js.map +1 -1
  139. package/cjs/domain/tracing/ddtraceTracer.js.map +1 -1
  140. package/cjs/domain/tracing/getDocumentTraceId.js.map +1 -1
  141. package/cjs/domain/tracing/jaegerTracer.js.map +1 -1
  142. package/cjs/domain/tracing/sampler.js.map +1 -1
  143. package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
  144. package/cjs/domain/tracing/traceIdentifier.js.map +1 -1
  145. package/cjs/domain/tracing/tracer.js +2 -2
  146. package/cjs/domain/tracing/tracer.js.map +1 -1
  147. package/cjs/domain/tracing/w3cTraceParentTracer.js.map +1 -1
  148. package/cjs/domain/tracing/zipkinMultiTracer.js.map +1 -1
  149. package/cjs/domain/tracing/zipkinSingleTracer.js.map +1 -1
  150. package/cjs/domain/trackEventCounts.js.map +1 -1
  151. package/cjs/domain/usr/index.js.map +1 -1
  152. package/cjs/domain/waitPageActivityEnd.js.map +1 -1
  153. package/cjs/index.js.map +1 -1
  154. package/cjs/transport/startRumBatch.js +3 -1
  155. package/cjs/transport/startRumBatch.js.map +1 -1
  156. package/cjs/transport/startRumEventBridge.js.map +1 -1
  157. package/cjs/types/index.js.map +1 -1
  158. package/cjs/types/sessionReplayConstants.js.map +1 -1
  159. package/esm/boot/buildEnv.js +1 -1
  160. package/esm/boot/buildEnv.js.map +1 -1
  161. package/esm/boot/perStartRum.js.map +1 -1
  162. package/esm/boot/recorderApi.js +172 -202
  163. package/esm/boot/recorderApi.js.map +1 -1
  164. package/esm/boot/recorderApiStub.js +3 -29
  165. package/esm/boot/recorderApiStub.js.map +1 -1
  166. package/esm/boot/rum.entry.js.map +1 -1
  167. package/esm/boot/rum.js.map +1 -1
  168. package/esm/boot/rum.slim.entry.js.map +1 -1
  169. package/esm/boot/rumEntryFactory.js.map +1 -1
  170. package/esm/boot/rumPublicApi.js.map +1 -1
  171. package/esm/boot/rumRecorderApiStub.js.map +1 -1
  172. package/esm/boot/rumSlimConfiguration.js.map +1 -1
  173. package/esm/boot/sessionReplayPublicApi.js +14 -27
  174. package/esm/boot/sessionReplayPublicApi.js.map +1 -1
  175. package/esm/boot/startRecording.js +334 -109
  176. package/esm/boot/startRecording.js.map +1 -1
  177. package/esm/constants.js.map +1 -1
  178. package/esm/domain/assembly.js +1 -7
  179. package/esm/domain/assembly.js.map +1 -1
  180. package/esm/domain/configuration.js +31 -43
  181. package/esm/domain/configuration.js.map +1 -1
  182. package/esm/domain/contexts/commonContext.js.map +1 -1
  183. package/esm/domain/contexts/displayContext.js.map +1 -1
  184. package/esm/domain/contexts/foregroundContexts.js.map +1 -1
  185. package/esm/domain/contexts/internalContext.js.map +1 -1
  186. package/esm/domain/contexts/pageStateHistory.js.map +1 -1
  187. package/esm/domain/contexts/urlContexts.js +11 -2
  188. package/esm/domain/contexts/urlContexts.js.map +1 -1
  189. package/esm/domain/contexts/viewContexts.js.map +1 -1
  190. package/esm/domain/deflate/deflateEncoder.js +517 -39
  191. package/esm/domain/deflate/deflateEncoder.js.map +1 -1
  192. package/esm/domain/deflate/deflateWorker.js +193 -116
  193. package/esm/domain/deflate/deflateWorker.js.map +1 -1
  194. package/esm/domain/deflate/index.js.map +1 -1
  195. package/esm/domain/domMutationObservable.js.map +1 -1
  196. package/esm/domain/encoderStreamId.js.map +1 -1
  197. package/esm/domain/firstInputPolyfill.js.map +1 -1
  198. package/esm/domain/initViewportObservable.js.map +1 -1
  199. package/esm/domain/locationChangeObservable.js.map +1 -1
  200. package/esm/domain/performanceObservable.js.map +1 -1
  201. package/esm/domain/performanceUtils.js.map +1 -1
  202. package/esm/domain/plugins.js.map +1 -1
  203. package/esm/domain/replay/record/canvasAutoSnapshot.js.map +1 -1
  204. package/esm/domain/replay/record/canvasCommandCapture.js +968 -168
  205. package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
  206. package/esm/domain/replay/record/canvasCommandObserver.js +1058 -119
  207. package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -1
  208. package/esm/domain/replay/record/canvasCommandSerializeArgs.js +60 -37
  209. package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
  210. package/esm/domain/replay/record/canvasContext.js +50 -0
  211. package/esm/domain/replay/record/canvasContext.js.map +1 -0
  212. package/esm/domain/replay/record/canvasContinuousScheduler.js +246 -118
  213. package/esm/domain/replay/record/canvasContinuousScheduler.js.map +1 -1
  214. package/esm/domain/replay/record/canvasEncodeBridge.js +539 -87
  215. package/esm/domain/replay/record/canvasEncodeBridge.js.map +1 -1
  216. package/esm/domain/replay/record/canvasEncodeWorker.js +51 -33
  217. package/esm/domain/replay/record/canvasEncodeWorker.js.map +1 -1
  218. package/esm/domain/replay/record/canvasFrameSignature.js +50 -17
  219. package/esm/domain/replay/record/canvasFrameSignature.js.map +1 -1
  220. package/esm/domain/replay/record/canvasMutationRecord.js.map +1 -1
  221. package/esm/domain/replay/record/canvasObserver.js +295 -59
  222. package/esm/domain/replay/record/canvasObserver.js.map +1 -1
  223. package/esm/domain/replay/record/canvasSerializeArgs.js.map +1 -1
  224. package/esm/domain/replay/record/canvasWebGLPluginHost.js +26 -0
  225. package/esm/domain/replay/record/canvasWebGLPluginHost.js.map +1 -0
  226. package/esm/domain/replay/record/elementsScrollPositions.js +3 -0
  227. package/esm/domain/replay/record/elementsScrollPositions.js.map +1 -1
  228. package/esm/domain/replay/record/index.js.map +1 -1
  229. package/esm/domain/replay/record/mutationBatch.js +541 -25
  230. package/esm/domain/replay/record/mutationBatch.js.map +1 -1
  231. package/esm/domain/replay/record/mutationObserver.js +1892 -195
  232. package/esm/domain/replay/record/mutationObserver.js.map +1 -1
  233. package/esm/domain/replay/record/mutationResourceBudget.js +137 -0
  234. package/esm/domain/replay/record/mutationResourceBudget.js.map +1 -0
  235. package/esm/domain/replay/record/observers.js +224 -55
  236. package/esm/domain/replay/record/observers.js.map +1 -1
  237. package/esm/domain/replay/record/privacy.js +30 -7
  238. package/esm/domain/replay/record/privacy.js.map +1 -1
  239. package/esm/domain/replay/record/record.js +3086 -325
  240. package/esm/domain/replay/record/record.js.map +1 -1
  241. package/esm/domain/replay/record/serializationUtils.js +422 -25
  242. package/esm/domain/replay/record/serializationUtils.js.map +1 -1
  243. package/esm/domain/replay/record/serialize.js +258 -50
  244. package/esm/domain/replay/record/serialize.js.map +1 -1
  245. package/esm/domain/replay/record/shadowRootsController.js +875 -21
  246. package/esm/domain/replay/record/shadowRootsController.js.map +1 -1
  247. package/esm/domain/replay/record/utils.js.map +1 -1
  248. package/esm/domain/replay/record/viewports.js.map +1 -1
  249. package/esm/domain/replay/replayStats.js.map +1 -1
  250. package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
  251. package/esm/domain/replay/segmentCollection/index.js.map +1 -1
  252. package/esm/domain/replay/segmentCollection/segment.js +315 -10
  253. package/esm/domain/replay/segmentCollection/segment.js.map +1 -1
  254. package/esm/domain/replay/segmentCollection/segmentCollection.js +957 -72
  255. package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  256. package/esm/domain/replay/startRecordBridge.js.map +1 -1
  257. package/esm/domain/requestCollection.js.map +1 -1
  258. package/esm/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
  259. package/esm/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
  260. package/esm/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -1
  261. package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
  262. package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
  263. package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
  264. package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
  265. package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
  266. package/esm/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
  267. package/esm/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
  268. package/esm/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
  269. package/esm/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
  270. package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
  271. package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
  272. package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  273. package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
  274. package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
  275. package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
  276. package/esm/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -1
  277. package/esm/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -1
  278. package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
  279. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  280. package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
  281. package/esm/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
  282. package/esm/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
  283. package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
  284. package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
  285. package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
  286. package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
  287. package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
  288. package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
  289. package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
  290. package/esm/domain/rumEventsCollection/view/trackViews.js +30 -12
  291. package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  292. package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  293. package/esm/domain/rumSessionManager.js.map +1 -1
  294. package/esm/domain/tracing/ddtraceTracer.js.map +1 -1
  295. package/esm/domain/tracing/getDocumentTraceId.js.map +1 -1
  296. package/esm/domain/tracing/jaegerTracer.js.map +1 -1
  297. package/esm/domain/tracing/sampler.js.map +1 -1
  298. package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
  299. package/esm/domain/tracing/traceIdentifier.js.map +1 -1
  300. package/esm/domain/tracing/tracer.js +2 -2
  301. package/esm/domain/tracing/tracer.js.map +1 -1
  302. package/esm/domain/tracing/w3cTraceParentTracer.js.map +1 -1
  303. package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -1
  304. package/esm/domain/tracing/zipkinSingleTracer.js.map +1 -1
  305. package/esm/domain/trackEventCounts.js.map +1 -1
  306. package/esm/domain/usr/index.js.map +1 -1
  307. package/esm/domain/waitPageActivityEnd.js.map +1 -1
  308. package/esm/index.js.map +1 -1
  309. package/esm/transport/startRumBatch.js +4 -2
  310. package/esm/transport/startRumBatch.js.map +1 -1
  311. package/esm/transport/startRumEventBridge.js.map +1 -1
  312. package/esm/types/index.js.map +1 -1
  313. package/esm/types/sessionReplayConstants.js.map +1 -1
  314. package/package.json +12 -7
  315. package/src/boot/recorderApi.js +247 -220
  316. package/src/boot/recorderApiStub.js +3 -29
  317. package/src/boot/sessionReplayPublicApi.js +15 -28
  318. package/src/boot/startRecording.js +429 -146
  319. package/src/domain/assembly.js +5 -4
  320. package/src/domain/configuration.js +63 -100
  321. package/src/domain/contexts/urlContexts.js +16 -4
  322. package/src/domain/deflate/deflateEncoder.js +699 -43
  323. package/src/domain/deflate/deflateWorker.js +237 -136
  324. package/src/domain/replay/record/canvasCommandCapture.js +1374 -180
  325. package/src/domain/replay/record/canvasCommandObserver.js +1585 -150
  326. package/src/domain/replay/record/canvasCommandSerializeArgs.js +79 -42
  327. package/src/domain/replay/record/canvasContext.js +67 -0
  328. package/src/domain/replay/record/canvasContinuousScheduler.js +379 -143
  329. package/src/domain/replay/record/canvasEncodeBridge.js +691 -106
  330. package/src/domain/replay/record/canvasEncodeWorker.js +67 -43
  331. package/src/domain/replay/record/canvasFrameSignature.js +58 -24
  332. package/src/domain/replay/record/canvasObserver.js +461 -89
  333. package/src/domain/replay/record/canvasWebGLPluginHost.js +43 -0
  334. package/src/domain/replay/record/elementsScrollPositions.js +3 -0
  335. package/src/domain/replay/record/mutationBatch.js +761 -27
  336. package/src/domain/replay/record/mutationObserver.js +2992 -261
  337. package/src/domain/replay/record/mutationResourceBudget.js +191 -0
  338. package/src/domain/replay/record/observers.js +367 -97
  339. package/src/domain/replay/record/privacy.js +34 -12
  340. package/src/domain/replay/record/record.js +4284 -413
  341. package/src/domain/replay/record/serializationUtils.js +587 -28
  342. package/src/domain/replay/record/serialize.js +432 -66
  343. package/src/domain/replay/record/shadowRootsController.js +1108 -30
  344. package/src/domain/replay/segmentCollection/segment.js +441 -11
  345. package/src/domain/replay/segmentCollection/segmentCollection.js +1300 -77
  346. package/src/domain/rumEventsCollection/view/trackViews.js +36 -12
  347. package/src/domain/tracing/tracer.js +4 -5
  348. package/src/transport/startRumBatch.js +6 -1
  349. package/types/index.d.ts +15 -2
  350. package/cjs/domain/replay/record/canvasReplayFixtures.js +0 -105
  351. package/cjs/domain/replay/record/canvasReplayFixtures.js.map +0 -1
  352. package/esm/domain/replay/record/canvasReplayFixtures.js +0 -96
  353. package/esm/domain/replay/record/canvasReplayFixtures.js.map +0 -1
  354. package/src/domain/replay/record/canvasReplayFixtures.js +0 -113
@@ -2,6 +2,7 @@ import {
2
2
  timeStampNow,
3
3
  createHttpRequest,
4
4
  LifeCycleEventType,
5
+ PageExitReason,
5
6
  addTelemetryDebug,
6
7
  ONE_SECOND,
7
8
  canUseEventBridge,
@@ -18,18 +19,89 @@ import { deleteOldestStats } from '../domain/replay/replayStats'
18
19
  /* How long to wait for error checkouts */
19
20
  export const BUFFER_CHECKOUT_TIME = 60 * ONE_SECOND
20
21
  var REPLAY_SEGMENT_FLUSH_HISTORY_LIMIT = 10
22
+
21
23
  export function startRecording(
22
24
  lifeCycle,
23
25
  configuration,
24
26
  sessionManager,
25
27
  viewContexts,
26
28
  encoder,
27
- httpRequest
29
+ httpRequest,
30
+ onStopped,
31
+ createHttpRequestOverride,
32
+ recordOverride
28
33
  ) {
34
+ var createHttpRequestImpl = __BUILD_ENV__REPLAY_DEBUG_ENABLED__
35
+ ? createHttpRequestOverride || createHttpRequest
36
+ : createHttpRequest
37
+ var recordImpl = __BUILD_ENV__REPLAY_DEBUG_ENABLED__
38
+ ? recordOverride || record
39
+ : record
29
40
  var cleanupTasks = []
41
+ var isRecordingStopped = false
42
+ var isRecordingReady = false
43
+ var pendingStopRequested = false
44
+ var pendingStopReason
45
+ var stoppedNotificationSent = false
46
+ var flushRecorderBeforePageExit = function () {}
47
+ var replayResetRequestedBeforeRecorder = false
48
+ var requestReplayReset = function () {
49
+ replayResetRequestedBeforeRecorder = true
50
+ }
51
+ function notifyStopped(flushReason) {
52
+ if (stoppedNotificationSent || !onStopped) {
53
+ return
54
+ }
55
+ stoppedNotificationSent = true
56
+ try {
57
+ onStopped(flushReason)
58
+ } catch (error) {
59
+ addTelemetryDebug('Session Replay stopped callback failed.', {
60
+ reason: flushReason,
61
+ error: String(error)
62
+ })
63
+ }
64
+ }
65
+ function stopRecording(flushReason) {
66
+ if (isRecordingStopped) {
67
+ return
68
+ }
69
+ if (!isRecordingReady) {
70
+ pendingStopRequested = true
71
+ pendingStopReason = flushReason
72
+ return
73
+ }
74
+ isRecordingStopped = true
75
+ var firstCleanupError
76
+ cleanupTasks
77
+ .slice()
78
+ .reverse()
79
+ .forEach(function (task) {
80
+ try {
81
+ task(flushReason)
82
+ } catch (error) {
83
+ if (!firstCleanupError) {
84
+ firstCleanupError = error
85
+ }
86
+ }
87
+ })
88
+ if (firstCleanupError) {
89
+ addTelemetryDebug('Session Replay cleanup failed.', {
90
+ reason: flushReason,
91
+ error: String(firstCleanupError)
92
+ })
93
+ }
94
+ notifyStopped(flushReason)
95
+ }
30
96
  var lastReplaySegmentFlushForDebug
31
- var replaySegmentFlushHistoryForDebug = []
97
+ var replaySegmentFlushHistoryForDebug =
98
+ __BUILD_ENV__REPLAY_DEBUG_ENABLED__ ? [] : undefined
32
99
  var replaySegmentFlushCount = 0
100
+ var replayResetCountForDebug = 0
101
+ var replayResetLastReasonForDebug
102
+ var areReplaySegmentsLockedForDebug = function () {
103
+ return false
104
+ }
33
105
  var reportError = function (error) {
34
106
  lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error })
35
107
  addTelemetryDebug('Error reported to customer', {
@@ -37,167 +109,369 @@ export function startRecording(
37
109
  })
38
110
  }
39
111
 
40
- var replayRequest =
41
- httpRequest ||
42
- createHttpRequest(
43
- configuration.sessionReplayEndPoint,
44
- SEGMENT_BYTES_LIMIT,
45
- configuration.retryMaxSize,
46
- reportError
47
- )
112
+ try {
113
+ var replayRequest = httpRequest || lifeCycle.$rReplayRequest
114
+ if (!replayRequest) {
115
+ replayRequest = createHttpRequestImpl(
116
+ configuration.sessionReplayEndPoint,
117
+ SEGMENT_BYTES_LIMIT,
118
+ configuration.retryMaxSize,
119
+ reportError
120
+ )
121
+ // Recorder restarts share one bounded retry queue/timer/request state.
122
+ // Old segment finishes can then drain in order without multiplying a
123
+ // 20 MiB queue for every stop/start cycle.
124
+ lifeCycle.$rReplayRequest = replayRequest
125
+ }
48
126
 
49
- let addRecord, _record
50
- if (!canUseEventBridge()) {
51
- const session = sessionManager.findTrackedSession()
52
- let isRecordErrorSessionReplay =
53
- session && session.errorSessionReplayAllowed && !session.sessionHasError
54
- var segmentCollection = startSegmentCollection(
55
- lifeCycle,
56
- configuration,
57
- sessionManager,
58
- viewContexts,
59
- replayRequest,
60
- encoder,
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
- }
127
+ let addRecord, addBaselineRecords, _record
128
+ var stopSegmentCollection
129
+ var beginMandatoryFullSnapshotRecovery = function () {}
130
+ var discardMandatoryFullSnapshotRecovery = function () {}
131
+ var wasLastEmitBackpressured = function () {}
132
+ if (!canUseEventBridge()) {
133
+ const session = sessionManager.findTrackedSession()
134
+ let isRecordErrorSessionReplay =
135
+ session && session.errorSessionReplayAllowed && !session.sessionHasError
136
+ var segmentCollection = startSegmentCollection(
137
+ lifeCycle,
138
+ configuration,
139
+ sessionManager,
140
+ viewContexts,
141
+ replayRequest,
142
+ encoder,
143
+ isRecordErrorSessionReplay,
144
+ {
145
+ beforePageExitFlush: function (pageExitEvent) {
146
+ flushRecorderBeforePageExit(pageExitEvent)
147
+ },
148
+ onReplayResetNeeded: function (reason) {
149
+ if (__BUILD_ENV__REPLAY_DEBUG_ENABLED__) {
150
+ replayResetCountForDebug += 1
151
+ replayResetLastReasonForDebug = reason
152
+ }
153
+ requestReplayReset(reason)
154
+ },
155
+ onReplayResetExhausted: function (reason) {
156
+ stopRecording(reason || 'full_snapshot_failure_limit')
157
+ },
158
+ onSegmentFlushed: __BUILD_ENV__REPLAY_DEBUG_ENABLED__
159
+ ? function (segmentFlush) {
160
+ replaySegmentFlushCount += 1
161
+ lastReplaySegmentFlushForDebug =
162
+ cloneReplaySegmentFlushForDebug(
163
+ segmentFlush,
164
+ replaySegmentFlushCount
165
+ )
166
+ replaySegmentFlushHistoryForDebug.push(
167
+ lastReplaySegmentFlushForDebug
168
+ )
169
+ if (
170
+ replaySegmentFlushHistoryForDebug.length >
171
+ REPLAY_SEGMENT_FLUSH_HISTORY_LIMIT
172
+ ) {
173
+ replaySegmentFlushHistoryForDebug.shift()
174
+ }
175
+ }
176
+ : undefined
77
177
  }
178
+ )
179
+ addRecord = segmentCollection.addRecord
180
+ addBaselineRecords = segmentCollection.$rAddBaselineRecords
181
+ wasLastEmitBackpressured =
182
+ segmentCollection.$rWasLastAddRecordBackpressured ||
183
+ wasLastEmitBackpressured
184
+ beginMandatoryFullSnapshotRecovery =
185
+ segmentCollection.$rBeginMandatoryRecovery ||
186
+ beginMandatoryFullSnapshotRecovery
187
+ discardMandatoryFullSnapshotRecovery =
188
+ segmentCollection.$rDiscardMandatoryRecovery ||
189
+ discardMandatoryFullSnapshotRecovery
190
+ let flushBufferSegment = segmentCollection.flushBufferSegment
191
+ let unlockSegment = segmentCollection.unlockSegment
192
+ if (__BUILD_ENV__REPLAY_DEBUG_ENABLED__) {
193
+ areReplaySegmentsLockedForDebug = segmentCollection.isLocked
78
194
  }
79
- )
80
- addRecord = segmentCollection.addRecord
81
- let flushBufferSegment = segmentCollection.flushBufferSegment
82
- let unlockSegment = segmentCollection.unlockSegment
83
- cleanupTasks.push(segmentCollection.stop)
84
- if (isRecordErrorSessionReplay) {
85
- sessionManager.sessionStateUpdateObservable.subscribe(
86
- ({ previousState, newState }) => {
87
- if (!previousState.hasError && newState.hasError) {
88
- isRecordErrorSessionReplay = false
89
- unlockSegment()
195
+ stopSegmentCollection = segmentCollection.stop
196
+ // Register a provisional cleanup before record() starts. Unexpected
197
+ // recorder initialization failures must not leave segment lifecycle
198
+ // subscriptions and timers alive.
199
+ cleanupTasks.push(stopSegmentCollection)
200
+ if (isRecordErrorSessionReplay) {
201
+ var sessionStateUpdateSubscription =
202
+ sessionManager.sessionStateUpdateObservable.subscribe(
203
+ ({ previousState, newState }) => {
204
+ if (!previousState.hasError && newState.hasError) {
205
+ isRecordErrorSessionReplay = false
206
+ unlockSegment()
207
+ }
208
+ }
209
+ )
210
+ cleanupTasks.push(sessionStateUpdateSubscription.unsubscribe)
211
+ }
212
+ let lastFullSnapshotEvent = null
213
+ const wrappedEmit = (recordData) => {
214
+ const accepted = addRecord(recordData)
215
+ if (accepted !== false && isRecordErrorSessionReplay) {
216
+ if (recordData.type === RecordType.FullSnapshot) {
217
+ lastFullSnapshotEvent = recordData
218
+ } else if (recordData.type === RecordType.IncrementalSnapshot) {
219
+ const exceedTime =
220
+ recordData.timestamp - lastFullSnapshotEvent.timestamp >
221
+ BUFFER_CHECKOUT_TIME
222
+ // If the time between the last full snapshot and the incremental snapshot is greater than the buffer time, we need to take a new full snapshot
223
+ if (exceedTime) {
224
+ flushBufferSegment(() => {
225
+ deleteOldestStats()
226
+ takeSubsequentFullSnapshot()
227
+ })
228
+ }
90
229
  }
91
230
  }
231
+ return accepted
232
+ }
233
+ const wrappedEmitBaseline = (records) => {
234
+ const accepted = addBaselineRecords(records)
235
+ if (accepted !== false && isRecordErrorSessionReplay) {
236
+ lastFullSnapshotEvent = records[records.length - 1]
237
+ }
238
+ return accepted
239
+ }
240
+ _record = recordImpl({
241
+ emit: wrappedEmit,
242
+ $rEmitBaseline: wrappedEmitBaseline,
243
+ configuration: configuration,
244
+ lifeCycle: lifeCycle,
245
+ sessionManager: sessionManager,
246
+ $rWasLastEmitBackpressured: wasLastEmitBackpressured,
247
+ $rOnMandatoryFullSnapshotStarted:
248
+ beginMandatoryFullSnapshotRecovery,
249
+ $rOnMandatoryFullSnapshotAbandoned:
250
+ discardMandatoryFullSnapshotRecovery,
251
+ onFullSnapshotFailure: stopRecording
252
+ })
253
+ } else {
254
+ ;({ addRecord } = startRecordBridge(viewContexts))
255
+ _record = recordImpl({
256
+ emit: addRecord,
257
+ configuration: configuration,
258
+ lifeCycle: lifeCycle,
259
+ sessionManager: sessionManager,
260
+ $rWasLastEmitBackpressured: wasLastEmitBackpressured,
261
+ $rOnMandatoryFullSnapshotStarted:
262
+ beginMandatoryFullSnapshotRecovery,
263
+ $rOnMandatoryFullSnapshotAbandoned:
264
+ discardMandatoryFullSnapshotRecovery,
265
+ onFullSnapshotFailure: stopRecording
266
+ })
267
+ }
268
+ if (!_record || typeof _record.stop !== 'function') {
269
+ throw new Error('Session Replay recorder failed to initialize.')
270
+ }
271
+ var stopRecorder = _record.stop
272
+ if (stopSegmentCollection) {
273
+ // Remove the provisional entry and restore the intended successful-stop
274
+ // ordering below (cleanup tasks run in reverse).
275
+ var provisionalCleanupIndex = cleanupTasks.indexOf(
276
+ stopSegmentCollection
92
277
  )
278
+ if (provisionalCleanupIndex !== -1) {
279
+ cleanupTasks.splice(provisionalCleanupIndex, 1)
280
+ }
93
281
  }
94
- let lastFullSnapshotEvent = null
95
- const wrappedEmit = (recordData) => {
96
- addRecord(recordData)
97
- if (isRecordErrorSessionReplay) {
98
- if (recordData.type === RecordType.FullSnapshot) {
99
- lastFullSnapshotEvent = recordData
100
- } else if (recordData.type === RecordType.IncrementalSnapshot) {
101
- const exceedTime =
102
- recordData.timestamp - lastFullSnapshotEvent.timestamp >
103
- BUFFER_CHECKOUT_TIME
104
- // If the time between the last full snapshot and the incremental snapshot is greater than the buffer time, we need to take a new full snapshot
105
- if (exceedTime) {
106
- flushBufferSegment(() => {
107
- deleteOldestStats()
108
- takeSubsequentFullSnapshot()
109
- })
282
+ cleanupTasks.push(
283
+ stopSegmentCollection
284
+ ? function (flushReason) {
285
+ // segmentCollection already invoked beforePageExitFlush while its
286
+ // encoder was writable. Teardown must now discard any unfinished
287
+ // atomic tail instead of doing work that can no longer be sent.
288
+ stopRecorder(flushReason, true)
110
289
  }
111
- }
290
+ : stopRecorder
291
+ )
292
+ if (stopSegmentCollection) {
293
+ // Stop the segment collection first (cleanup tasks run in reverse).
294
+ // Its beforePageExitFlush hook can then drain the still-live recorder,
295
+ // including a second unload pass after synchronous encoder backpressure
296
+ // is released, before the observers are torn down.
297
+ cleanupTasks.push(stopSegmentCollection)
298
+ }
299
+ var takeSubsequentFullSnapshot = _record.takeSubsequentFullSnapshot
300
+ var flushScheduledFullSnapshot =
301
+ _record.flushScheduledFullSnapshot || function () {}
302
+ var flushCanvasCommands =
303
+ _record.$rFlushCanvasCommands || function () {}
304
+ flushRecorderBeforePageExit = function (pageExitEvent) {
305
+ if (
306
+ pageExitEvent &&
307
+ pageExitEvent.reason !== PageExitReason.UNLOADING
308
+ ) {
309
+ // Hidden, frozen, and pagehide states can resume in the same view.
310
+ // Keep an in-progress DOM recovery baseline scheduled so later
311
+ // mutations are never attached to the stale pre-overflow snapshot.
312
+ _record.flushMutations()
313
+ flushCanvasCommands()
314
+ return
112
315
  }
316
+ if (!flushScheduledFullSnapshot()) {
317
+ // The segment is still writable in this hook. Give a paged raw/shadow
318
+ // transaction its final bounded drain before segmentCollection closes;
319
+ // record.stop() runs afterwards and can only discard an unfinished
320
+ // atomic tail.
321
+ _record.flushMutations(true)
322
+ }
323
+ // Keep the command recorder alive until this hook runs: the segment is
324
+ // still writable here, including the second unload pass after synchronous
325
+ // encoder backpressure is released.
326
+ flushCanvasCommands()
113
327
  }
114
- _record = record({
115
- emit: wrappedEmit,
116
- configuration: configuration,
117
- lifeCycle: lifeCycle,
118
- sessionManager: sessionManager
119
- })
120
- } else {
121
- ;({ addRecord } = startRecordBridge(viewContexts))
122
- _record = record({
123
- emit: addRecord,
124
- configuration: configuration,
125
- lifeCycle: lifeCycle,
126
- sessionManager: sessionManager
127
- })
128
- }
129
- cleanupTasks.push(_record.stop)
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 getLastDomMutationForDebug = _record.getLastDomMutationForDebug
141
- var getDomMutationHistoryForDebug = _record.getDomMutationHistoryForDebug
142
- var getReplayPerformanceForDebug = function () {
143
- return cloneReplayPerformanceForDebug(
144
- _record.getReplayPerformanceForDebug
145
- ? _record.getReplayPerformanceForDebug()
146
- : undefined,
147
- replaySegmentFlushCount
328
+ requestReplayReset = createReplayResetScheduler(
329
+ takeSubsequentFullSnapshot,
330
+ cleanupTasks
148
331
  )
149
- }
150
- var getLastReplaySegmentFlushForDebug = function () {
151
- return cloneReplaySegmentFlushForDebug(lastReplaySegmentFlushForDebug)
152
- }
153
- var getReplaySegmentFlushHistoryForDebug = function () {
154
- return replaySegmentFlushHistoryForDebug.map(function (segmentFlush) {
155
- return cloneReplaySegmentFlushForDebug(segmentFlush)
156
- })
157
- }
158
- var flushMutations = _record.flushMutations
159
- var subscribeViewEnded = lifeCycle.subscribe(
160
- LifeCycleEventType.VIEW_ENDED,
161
- function () {
162
- flushMutations()
163
- addRecord({
164
- timestamp: timeStampNow(),
165
- type: RecordType.ViewEnd
166
- })
332
+ if (replayResetRequestedBeforeRecorder) {
333
+ requestReplayReset()
167
334
  }
168
- )
169
- cleanupTasks.push(subscribeViewEnded.unsubscribe)
170
- var scribeViewCreated = lifeCycle.subscribe(
171
- LifeCycleEventType.VIEW_CREATED,
172
- function (view) {
173
- takeSubsequentFullSnapshot(view.startClocks.timeStamp)
335
+ var scheduleSubsequentFullSnapshot =
336
+ _record.scheduleSubsequentFullSnapshot || takeSubsequentFullSnapshot
337
+ var prepareForViewChange =
338
+ _record.prepareForViewChange || _record.flushMutations
339
+ var snapshotCanvas = _record.snapshotCanvas
340
+ var getSerializedNodeIdForDebug = _record.getSerializedNodeIdForDebug
341
+ var recordingDebug
342
+ if (__BUILD_ENV__REPLAY_DEBUG_ENABLED__) {
343
+ recordingDebug = {
344
+ getLastAutoCanvasSnapshotResultForDebug:
345
+ _record.getLastAutoCanvasSnapshotResultForDebug,
346
+ getAutoCanvasSnapshotDebugHistoryForDebug:
347
+ _record.getAutoCanvasSnapshotDebugHistoryForDebug,
348
+ getLastCanvasMutationForDebug:
349
+ _record.getLastCanvasMutationForDebug,
350
+ getCanvasMutationHistoryForDebug:
351
+ _record.getCanvasMutationHistoryForDebug,
352
+ getLastDomMutationForDebug: _record.getLastDomMutationForDebug,
353
+ getDomMutationHistoryForDebug:
354
+ _record.getDomMutationHistoryForDebug,
355
+ getReplayPerformanceForDebug: function () {
356
+ return cloneReplayPerformanceForDebug(
357
+ _record.getReplayPerformanceForDebug
358
+ ? _record.getReplayPerformanceForDebug()
359
+ : undefined,
360
+ replaySegmentFlushCount,
361
+ replayResetCountForDebug,
362
+ replayResetLastReasonForDebug,
363
+ areReplaySegmentsLockedForDebug()
364
+ )
365
+ },
366
+ getLastReplaySegmentFlushForDebug: function () {
367
+ return cloneReplaySegmentFlushForDebug(
368
+ lastReplaySegmentFlushForDebug
369
+ )
370
+ },
371
+ getReplaySegmentFlushHistoryForDebug: function () {
372
+ return replaySegmentFlushHistoryForDebug.map(function (
373
+ segmentFlush
374
+ ) {
375
+ return cloneReplaySegmentFlushForDebug(segmentFlush)
376
+ })
377
+ }
378
+ }
379
+ }
380
+ var flushMutations = _record.flushMutations
381
+ var subscribeViewEnded = lifeCycle.subscribe(
382
+ LifeCycleEventType.VIEW_ENDED,
383
+ function () {
384
+ if (!flushScheduledFullSnapshot(true, true)) {
385
+ // Preserve DOM changes still queued by the native MutationObservers.
386
+ // The next view snapshot has not been scheduled yet, so resetting the
387
+ // observers here would otherwise lose the old view's final state.
388
+ flushMutations()
389
+ }
390
+ // Canvas command batches are frame-scheduled. Publish the old view's
391
+ // final batch before ViewEnd and before VIEW_CREATED resets the canvas
392
+ // baseline for the next replay tree.
393
+ flushCanvasCommands()
394
+ prepareForViewChange()
395
+ addRecord({
396
+ timestamp: timeStampNow(),
397
+ type: RecordType.ViewEnd
398
+ })
399
+ }
400
+ )
401
+ cleanupTasks.push(subscribeViewEnded.unsubscribe)
402
+ var scribeViewCreated = lifeCycle.subscribe(
403
+ LifeCycleEventType.VIEW_CREATED,
404
+ function (view) {
405
+ scheduleSubsequentFullSnapshot(view.startClocks.timeStamp)
406
+ }
407
+ )
408
+ cleanupTasks.push(scribeViewCreated.unsubscribe)
409
+ isRecordingReady = true
410
+ if (pendingStopRequested) {
411
+ stopRecording(pendingStopReason)
174
412
  }
175
- )
176
- cleanupTasks.push(scribeViewCreated.unsubscribe)
413
+ } catch (error) {
414
+ isRecordingReady = true
415
+ stopRecording('start_failure')
416
+ throw error
417
+ }
177
418
 
178
- return {
179
- stop: function () {
180
- cleanupTasks.forEach(function (task) {
181
- task()
182
- })
419
+ var recording = {
420
+ stop: stopRecording,
421
+ isStopped: function () {
422
+ return isRecordingStopped
423
+ },
424
+ // The public/manual snapshot is opportunistic. Internal view, buffer and
425
+ // recovery snapshots keep using the raw non-discardable function above.
426
+ takeSubsequentFullSnapshot: function () {
427
+ return takeSubsequentFullSnapshot(undefined, true)
183
428
  },
184
- takeSubsequentFullSnapshot: takeSubsequentFullSnapshot,
185
429
  snapshotCanvas: snapshotCanvas,
186
430
  getSerializedNodeIdForDebug: getSerializedNodeIdForDebug,
187
- getLastAutoCanvasSnapshotResultForDebug:
188
- getLastAutoCanvasSnapshotResultForDebug,
189
- getAutoCanvasSnapshotDebugHistoryForDebug:
190
- getAutoCanvasSnapshotDebugHistoryForDebug,
191
- getLastCanvasMutationForDebug: getLastCanvasMutationForDebug,
192
- getCanvasMutationHistoryForDebug: getCanvasMutationHistoryForDebug,
193
- getLastDomMutationForDebug: getLastDomMutationForDebug,
194
- getDomMutationHistoryForDebug: getDomMutationHistoryForDebug,
195
- getLastReplaySegmentFlushForDebug: getLastReplaySegmentFlushForDebug,
196
- getReplaySegmentFlushHistoryForDebug:
197
- getReplaySegmentFlushHistoryForDebug,
198
- getReplayPerformanceForDebug: getReplayPerformanceForDebug,
199
431
  flushReplayMutationsForDebug: flushMutations
200
432
  }
433
+ if (__BUILD_ENV__REPLAY_DEBUG_ENABLED__) {
434
+ assign(recording, recordingDebug)
435
+ }
436
+ return recording
437
+ }
438
+
439
+ function createReplayResetScheduler(takeSubsequentFullSnapshot, cleanupTasks) {
440
+ var stopped = false
441
+ var pending = false
442
+ var lastResetAt = -Infinity
443
+ var resetTimeoutId
444
+ var RESET_MIN_INTERVAL = ONE_SECOND
445
+
446
+ function runReset() {
447
+ resetTimeoutId = undefined
448
+ if (stopped || !pending) {
449
+ return
450
+ }
451
+ pending = false
452
+ lastResetAt = Date.now()
453
+ takeSubsequentFullSnapshot()
454
+ }
455
+
456
+ cleanupTasks.push(function () {
457
+ stopped = true
458
+ if (resetTimeoutId !== undefined) {
459
+ clearTimeout(resetTimeoutId)
460
+ resetTimeoutId = undefined
461
+ }
462
+ })
463
+
464
+ return function () {
465
+ if (stopped) {
466
+ return
467
+ }
468
+ pending = true
469
+ if (resetTimeoutId !== undefined) {
470
+ return
471
+ }
472
+ var delay = Math.max(lastResetAt + RESET_MIN_INTERVAL - Date.now(), 0)
473
+ resetTimeoutId = setTimeout(runReset, delay)
474
+ }
201
475
  }
202
476
 
203
477
  function cloneReplaySegmentFlushForDebug(segmentFlush, sequence) {
@@ -218,12 +492,21 @@ function cloneReplaySegmentFlushForDebug(segmentFlush, sequence) {
218
492
  }
219
493
  }
220
494
 
221
- function cloneReplayPerformanceForDebug(stats, replaySegmentFlushCount) {
495
+ function cloneReplayPerformanceForDebug(
496
+ stats,
497
+ replaySegmentFlushCount,
498
+ replayResetCount,
499
+ replayResetLastReason,
500
+ replaySegmentsLocked
501
+ ) {
222
502
  if (!stats && typeof replaySegmentFlushCount === 'undefined') {
223
503
  return undefined
224
504
  }
225
505
 
226
506
  return assign({}, stats || {}, {
227
- replaySegmentFlushCount: replaySegmentFlushCount || 0
507
+ replaySegmentFlushCount: replaySegmentFlushCount || 0,
508
+ replayResetCount: replayResetCount || 0,
509
+ replayResetLastReason: replayResetLastReason,
510
+ replaySegmentsLocked: Boolean(replaySegmentsLocked)
228
511
  })
229
512
  }
@@ -43,10 +43,11 @@ export function startRumAssembly(
43
43
  getCommonContext,
44
44
  reportError
45
45
  ) {
46
- modifiableFieldPathsByEvent[RumEventType.VIEW] = {
47
- ...USER_CUSTOMIZABLE_FIELD_PATHS,
48
- ...VIEW_MODIFIABLE_FIELD_PATHS
49
- }
46
+ modifiableFieldPathsByEvent[RumEventType.VIEW] = assign(
47
+ {},
48
+ USER_CUSTOMIZABLE_FIELD_PATHS,
49
+ VIEW_MODIFIABLE_FIELD_PATHS
50
+ )
50
51
  modifiableFieldPathsByEvent[RumEventType.ERROR] = assign(
51
52
  {
52
53
  'error.message': 'string',