@cloudcare/browser-rum 3.0.29 → 3.1.1

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 (399) hide show
  1. package/bundle/dataflux-rum.js +1 -1
  2. package/cjs/boot/buildEnv.js +3 -2
  3. package/cjs/boot/buildEnv.js.map +1 -0
  4. package/cjs/boot/recorderApi.js +30 -46
  5. package/cjs/boot/recorderApi.js.map +1 -0
  6. package/cjs/boot/rum.entry.js +2 -7
  7. package/cjs/boot/rum.entry.js.map +1 -0
  8. package/cjs/boot/rum.js +40 -43
  9. package/cjs/boot/rum.js.map +1 -0
  10. package/cjs/boot/rumPublicApi.js +3 -49
  11. package/cjs/boot/rumPublicApi.js.map +1 -0
  12. package/cjs/boot/startRecording.js +7 -11
  13. package/cjs/boot/startRecording.js.map +1 -0
  14. package/cjs/constants.js +8 -6
  15. package/cjs/constants.js.map +1 -0
  16. package/cjs/domain/assembly.js +8 -20
  17. package/cjs/domain/assembly.js.map +1 -0
  18. package/cjs/domain/configuration.js +15 -52
  19. package/cjs/domain/configuration.js.map +1 -0
  20. package/cjs/domain/contexts/commonContext.js +2 -2
  21. package/cjs/domain/contexts/commonContext.js.map +1 -0
  22. package/cjs/domain/contexts/displayContext.js +28 -0
  23. package/cjs/domain/contexts/displayContext.js.map +1 -0
  24. package/cjs/domain/contexts/foregroundContexts.js +4 -29
  25. package/cjs/domain/contexts/foregroundContexts.js.map +1 -0
  26. package/cjs/domain/contexts/internalContext.js +5 -4
  27. package/cjs/domain/contexts/internalContext.js.map +1 -0
  28. package/cjs/domain/contexts/pageStateHistory.js +105 -0
  29. package/cjs/domain/contexts/pageStateHistory.js.map +1 -0
  30. package/cjs/domain/contexts/urlContexts.js +3 -9
  31. package/cjs/domain/contexts/urlContexts.js.map +1 -0
  32. package/cjs/domain/contexts/viewContexts.js +2 -6
  33. package/cjs/domain/contexts/viewContexts.js.map +1 -0
  34. package/cjs/domain/domMutationCollection.js +6 -10
  35. package/cjs/domain/domMutationCollection.js.map +1 -0
  36. package/cjs/domain/initViewportObservable.js +4 -11
  37. package/cjs/domain/initViewportObservable.js.map +1 -0
  38. package/cjs/domain/locationChangeObservable.js +2 -11
  39. package/cjs/domain/locationChangeObservable.js.map +1 -0
  40. package/cjs/domain/performanceCollection.js +11 -39
  41. package/cjs/domain/performanceCollection.js.map +1 -0
  42. package/cjs/domain/replay/deflate/deflateEncoder.js +82 -0
  43. package/cjs/domain/replay/deflate/deflateEncoder.js.map +1 -0
  44. package/cjs/domain/replay/deflate/deflateWorker.js +142 -0
  45. package/cjs/domain/replay/deflate/deflateWorker.js.map +1 -0
  46. package/cjs/domain/replay/deflate/index.js +44 -0
  47. package/cjs/domain/replay/deflate/index.js.map +1 -0
  48. package/cjs/domain/replay/record/elementsScrollPositions.js +2 -3
  49. package/cjs/domain/replay/record/elementsScrollPositions.js.map +1 -0
  50. package/cjs/domain/replay/record/index.js +2 -4
  51. package/cjs/domain/replay/record/index.js.map +1 -0
  52. package/cjs/domain/replay/record/mutationBatch.js +4 -11
  53. package/cjs/domain/replay/record/mutationBatch.js.map +1 -0
  54. package/cjs/domain/replay/record/mutationObserver.js +27 -86
  55. package/cjs/domain/replay/record/mutationObserver.js.map +1 -0
  56. package/cjs/domain/replay/record/observers.js +15 -89
  57. package/cjs/domain/replay/record/observers.js.map +1 -0
  58. package/cjs/domain/replay/record/privacy.js +57 -75
  59. package/cjs/domain/replay/record/privacy.js.map +1 -0
  60. package/cjs/domain/replay/record/record.js +6 -29
  61. package/cjs/domain/replay/record/record.js.map +1 -0
  62. package/cjs/domain/replay/record/serializationUtils.js +8 -68
  63. package/cjs/domain/replay/record/serializationUtils.js.map +1 -0
  64. package/cjs/domain/replay/record/serialize.js +43 -118
  65. package/cjs/domain/replay/record/serialize.js.map +1 -0
  66. package/cjs/domain/replay/record/shadowRootsController.js +4 -11
  67. package/cjs/domain/replay/record/shadowRootsController.js.map +1 -0
  68. package/cjs/domain/replay/record/utils.js +4 -12
  69. package/cjs/domain/replay/record/utils.js.map +1 -0
  70. package/cjs/domain/replay/record/viewports.js +4 -42
  71. package/cjs/domain/replay/record/viewports.js.map +1 -0
  72. package/cjs/domain/replay/replayStats.js +2 -14
  73. package/cjs/domain/replay/replayStats.js.map +1 -0
  74. package/cjs/domain/replay/segmentCollection/buildReplayPayload.js +4 -9
  75. package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -0
  76. package/cjs/domain/replay/segmentCollection/index.js +1 -9
  77. package/cjs/domain/replay/segmentCollection/index.js.map +1 -0
  78. package/cjs/domain/replay/segmentCollection/segment.js +23 -87
  79. package/cjs/domain/replay/segmentCollection/segment.js.map +1 -0
  80. package/cjs/domain/replay/segmentCollection/segmentCollection.js +41 -64
  81. package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -0
  82. package/cjs/domain/requestCollection.js +2 -17
  83. package/cjs/domain/requestCollection.js.map +1 -0
  84. package/cjs/domain/rumEventsCollection/actions/actionCollection.js +12 -22
  85. package/cjs/domain/rumEventsCollection/actions/actionCollection.js.map +1 -0
  86. package/cjs/domain/rumEventsCollection/actions/clickChain.js +3 -14
  87. package/cjs/domain/rumEventsCollection/actions/clickChain.js.map +1 -0
  88. package/cjs/domain/rumEventsCollection/actions/computeFrustration.js +12 -20
  89. package/cjs/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -0
  90. package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js +22 -53
  91. package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -0
  92. package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +13 -45
  93. package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -0
  94. package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js +4 -6
  95. package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -0
  96. package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +15 -45
  97. package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -0
  98. package/cjs/domain/rumEventsCollection/error/errorCollection.js +13 -23
  99. package/cjs/domain/rumEventsCollection/error/errorCollection.js.map +1 -0
  100. package/cjs/domain/rumEventsCollection/error/trackConsoleError.js +2 -3
  101. package/cjs/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -0
  102. package/cjs/domain/rumEventsCollection/error/trackReportError.js +4 -5
  103. package/cjs/domain/rumEventsCollection/error/trackReportError.js.map +1 -0
  104. package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js +2 -7
  105. package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -0
  106. package/cjs/domain/rumEventsCollection/resource/matchRequestTiming.js +2 -13
  107. package/cjs/domain/rumEventsCollection/resource/matchRequestTiming.js.map +1 -0
  108. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +2 -18
  109. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -0
  110. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +58 -69
  111. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -0
  112. package/cjs/domain/rumEventsCollection/view/interactionCountPolyfill.js +55 -0
  113. package/cjs/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -0
  114. package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js +62 -0
  115. package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -0
  116. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +74 -0
  117. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -0
  118. package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +26 -0
  119. package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -0
  120. package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js +2 -8
  121. package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -0
  122. package/cjs/domain/rumEventsCollection/view/trackFirstInputTimings.js +38 -0
  123. package/cjs/domain/rumEventsCollection/view/trackFirstInputTimings.js.map +1 -0
  124. package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +26 -179
  125. package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -0
  126. package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +120 -0
  127. package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -0
  128. package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +49 -0
  129. package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -0
  130. package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js +39 -0
  131. package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -0
  132. package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js +37 -0
  133. package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -0
  134. package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js +61 -0
  135. package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -0
  136. package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js +3 -6
  137. package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -0
  138. package/cjs/domain/rumEventsCollection/view/trackViews.js +26 -58
  139. package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -0
  140. package/cjs/domain/rumEventsCollection/view/viewCollection.js +43 -48
  141. package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -0
  142. package/cjs/domain/rumSessionManager.js +3 -13
  143. package/cjs/domain/rumSessionManager.js.map +1 -0
  144. package/cjs/domain/tracing/ddtraceTracer.js +2 -4
  145. package/cjs/domain/tracing/ddtraceTracer.js.map +1 -0
  146. package/cjs/domain/tracing/getDocumentTraceId.js +5 -22
  147. package/cjs/domain/tracing/getDocumentTraceId.js.map +1 -0
  148. package/cjs/domain/tracing/jaegerTracer.js +2 -4
  149. package/cjs/domain/tracing/jaegerTracer.js.map +1 -0
  150. package/cjs/domain/tracing/skywalkingTracer.js +6 -13
  151. package/cjs/domain/tracing/skywalkingTracer.js.map +1 -0
  152. package/cjs/domain/tracing/traceIdentifier.js +2 -7
  153. package/cjs/domain/tracing/traceIdentifier.js.map +1 -0
  154. package/cjs/domain/tracing/tracer.js +5 -30
  155. package/cjs/domain/tracing/tracer.js.map +1 -0
  156. package/cjs/domain/tracing/w3cTraceParentTracer.js +2 -11
  157. package/cjs/domain/tracing/w3cTraceParentTracer.js.map +1 -0
  158. package/cjs/domain/tracing/zipkinMultiTracer.js +4 -6
  159. package/cjs/domain/tracing/zipkinMultiTracer.js.map +1 -0
  160. package/cjs/domain/tracing/zipkinSingleTracer.js +2 -4
  161. package/cjs/domain/tracing/zipkinSingleTracer.js.map +1 -0
  162. package/cjs/domain/trackEventCounts.js +2 -10
  163. package/cjs/domain/trackEventCounts.js.map +1 -0
  164. package/cjs/domain/usr/index.js +2 -7
  165. package/cjs/domain/usr/index.js.map +1 -0
  166. package/cjs/domain/waitPageActivityEnd.js +7 -23
  167. package/cjs/domain/waitPageActivityEnd.js.map +1 -0
  168. package/cjs/index.js +2 -2
  169. package/cjs/index.js.map +1 -0
  170. package/cjs/transport/startRumBatch.js +7 -8
  171. package/cjs/transport/startRumBatch.js.map +1 -0
  172. package/cjs/transport/startRumEventBridge.js +2 -3
  173. package/cjs/transport/startRumEventBridge.js.map +1 -0
  174. package/cjs/types/index.js +2 -3
  175. package/cjs/types/index.js.map +1 -0
  176. package/cjs/types/sessionReplayConstants.js +4 -3
  177. package/cjs/types/sessionReplayConstants.js.map +1 -0
  178. package/esm/boot/buildEnv.js +3 -2
  179. package/esm/boot/buildEnv.js.map +1 -0
  180. package/esm/boot/recorderApi.js +32 -42
  181. package/esm/boot/recorderApi.js.map +1 -0
  182. package/esm/boot/rum.entry.js +2 -1
  183. package/esm/boot/rum.entry.js.map +1 -0
  184. package/esm/boot/rum.js +41 -23
  185. package/esm/boot/rum.js.map +1 -0
  186. package/esm/boot/rumPublicApi.js +3 -43
  187. package/esm/boot/rumPublicApi.js.map +1 -0
  188. package/esm/boot/startRecording.js +8 -7
  189. package/esm/boot/startRecording.js.map +1 -0
  190. package/esm/constants.js +8 -4
  191. package/esm/constants.js.map +1 -0
  192. package/esm/domain/assembly.js +8 -17
  193. package/esm/domain/assembly.js.map +1 -0
  194. package/esm/domain/configuration.js +15 -38
  195. package/esm/domain/configuration.js.map +1 -0
  196. package/esm/domain/contexts/commonContext.js +2 -1
  197. package/esm/domain/contexts/commonContext.js.map +1 -0
  198. package/esm/domain/contexts/displayContext.js +21 -0
  199. package/esm/domain/contexts/displayContext.js.map +1 -0
  200. package/esm/domain/contexts/foregroundContexts.js +6 -25
  201. package/esm/domain/contexts/foregroundContexts.js.map +1 -0
  202. package/esm/domain/contexts/internalContext.js +5 -3
  203. package/esm/domain/contexts/internalContext.js.map +1 -0
  204. package/esm/domain/contexts/pageStateHistory.js +95 -0
  205. package/esm/domain/contexts/pageStateHistory.js.map +1 -0
  206. package/esm/domain/contexts/urlContexts.js +3 -6
  207. package/esm/domain/contexts/urlContexts.js.map +1 -0
  208. package/esm/domain/contexts/viewContexts.js +2 -3
  209. package/esm/domain/contexts/viewContexts.js.map +1 -0
  210. package/esm/domain/domMutationCollection.js +6 -7
  211. package/esm/domain/domMutationCollection.js.map +1 -0
  212. package/esm/domain/initViewportObservable.js +4 -6
  213. package/esm/domain/initViewportObservable.js.map +1 -0
  214. package/esm/domain/locationChangeObservable.js +2 -9
  215. package/esm/domain/locationChangeObservable.js.map +1 -0
  216. package/esm/domain/performanceCollection.js +11 -35
  217. package/esm/domain/performanceCollection.js.map +1 -0
  218. package/esm/domain/replay/deflate/deflateEncoder.js +74 -0
  219. package/esm/domain/replay/deflate/deflateEncoder.js.map +1 -0
  220. package/esm/domain/replay/deflate/deflateWorker.js +129 -0
  221. package/esm/domain/replay/deflate/deflateWorker.js.map +1 -0
  222. package/esm/domain/replay/deflate/index.js +3 -0
  223. package/esm/domain/replay/deflate/index.js.map +1 -0
  224. package/esm/domain/replay/record/elementsScrollPositions.js +2 -2
  225. package/esm/domain/replay/record/elementsScrollPositions.js.map +1 -0
  226. package/esm/domain/replay/record/index.js +2 -1
  227. package/esm/domain/replay/record/index.js.map +1 -0
  228. package/esm/domain/replay/record/mutationBatch.js +5 -9
  229. package/esm/domain/replay/record/mutationBatch.js.map +1 -0
  230. package/esm/domain/replay/record/mutationObserver.js +29 -80
  231. package/esm/domain/replay/record/mutationObserver.js.map +1 -0
  232. package/esm/domain/replay/record/observers.js +15 -72
  233. package/esm/domain/replay/record/observers.js.map +1 -0
  234. package/esm/domain/replay/record/privacy.js +57 -65
  235. package/esm/domain/replay/record/privacy.js.map +1 -0
  236. package/esm/domain/replay/record/record.js +6 -19
  237. package/esm/domain/replay/record/record.js.map +1 -0
  238. package/esm/domain/replay/record/serializationUtils.js +8 -46
  239. package/esm/domain/replay/record/serializationUtils.js.map +1 -0
  240. package/esm/domain/replay/record/serialize.js +45 -107
  241. package/esm/domain/replay/record/serialize.js.map +1 -0
  242. package/esm/domain/replay/record/shadowRootsController.js +4 -6
  243. package/esm/domain/replay/record/shadowRootsController.js.map +1 -0
  244. package/esm/domain/replay/record/utils.js +4 -6
  245. package/esm/domain/replay/record/utils.js.map +1 -0
  246. package/esm/domain/replay/record/viewports.js +3 -32
  247. package/esm/domain/replay/record/viewports.js.map +1 -0
  248. package/esm/domain/replay/replayStats.js +2 -8
  249. package/esm/domain/replay/replayStats.js.map +1 -0
  250. package/esm/domain/replay/segmentCollection/buildReplayPayload.js +4 -6
  251. package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -0
  252. package/esm/domain/replay/segmentCollection/index.js +2 -2
  253. package/esm/domain/replay/segmentCollection/index.js.map +1 -0
  254. package/esm/domain/replay/segmentCollection/segment.js +21 -77
  255. package/esm/domain/replay/segmentCollection/segment.js.map +1 -0
  256. package/esm/domain/replay/segmentCollection/segmentCollection.js +40 -53
  257. package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -0
  258. package/esm/domain/requestCollection.js +2 -10
  259. package/esm/domain/requestCollection.js.map +1 -0
  260. package/esm/domain/rumEventsCollection/actions/actionCollection.js +12 -19
  261. package/esm/domain/rumEventsCollection/actions/actionCollection.js.map +1 -0
  262. package/esm/domain/rumEventsCollection/actions/clickChain.js +3 -10
  263. package/esm/domain/rumEventsCollection/actions/clickChain.js.map +1 -0
  264. package/esm/domain/rumEventsCollection/actions/computeFrustration.js +12 -14
  265. package/esm/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -0
  266. package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js +22 -50
  267. package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -0
  268. package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +12 -40
  269. package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -0
  270. package/esm/domain/rumEventsCollection/actions/listenActionEvents.js +4 -4
  271. package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -0
  272. package/esm/domain/rumEventsCollection/actions/trackClickActions.js +18 -37
  273. package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -0
  274. package/esm/domain/rumEventsCollection/error/errorCollection.js +14 -19
  275. package/esm/domain/rumEventsCollection/error/errorCollection.js.map +1 -0
  276. package/esm/domain/rumEventsCollection/error/trackConsoleError.js +2 -1
  277. package/esm/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -0
  278. package/esm/domain/rumEventsCollection/error/trackReportError.js +4 -3
  279. package/esm/domain/rumEventsCollection/error/trackReportError.js.map +1 -0
  280. package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js +2 -5
  281. package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -0
  282. package/esm/domain/rumEventsCollection/resource/matchRequestTiming.js +3 -11
  283. package/esm/domain/rumEventsCollection/resource/matchRequestTiming.js.map +1 -0
  284. package/esm/domain/rumEventsCollection/resource/resourceCollection.js +2 -13
  285. package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -0
  286. package/esm/domain/rumEventsCollection/resource/resourceUtils.js +58 -57
  287. package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -0
  288. package/esm/domain/rumEventsCollection/view/interactionCountPolyfill.js +47 -0
  289. package/esm/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -0
  290. package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js +56 -0
  291. package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -0
  292. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +67 -0
  293. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -0
  294. package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +18 -0
  295. package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -0
  296. package/esm/domain/rumEventsCollection/view/trackFirstHidden.js +2 -4
  297. package/esm/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -0
  298. package/esm/domain/rumEventsCollection/view/trackFirstInputTimings.js +32 -0
  299. package/esm/domain/rumEventsCollection/view/trackFirstInputTimings.js.map +1 -0
  300. package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +25 -164
  301. package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -0
  302. package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +113 -0
  303. package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -0
  304. package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +41 -0
  305. package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -0
  306. package/esm/domain/rumEventsCollection/view/trackLoadingTime.js +33 -0
  307. package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -0
  308. package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js +31 -0
  309. package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -0
  310. package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js +53 -0
  311. package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -0
  312. package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js +5 -3
  313. package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -0
  314. package/esm/domain/rumEventsCollection/view/trackViews.js +28 -54
  315. package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -0
  316. package/esm/domain/rumEventsCollection/view/viewCollection.js +43 -44
  317. package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -0
  318. package/esm/domain/rumSessionManager.js +3 -9
  319. package/esm/domain/rumSessionManager.js.map +1 -0
  320. package/esm/domain/tracing/ddtraceTracer.js +2 -2
  321. package/esm/domain/tracing/ddtraceTracer.js.map +1 -0
  322. package/esm/domain/tracing/getDocumentTraceId.js +5 -15
  323. package/esm/domain/tracing/getDocumentTraceId.js.map +1 -0
  324. package/esm/domain/tracing/jaegerTracer.js +3 -2
  325. package/esm/domain/tracing/jaegerTracer.js.map +1 -0
  326. package/esm/domain/tracing/skywalkingTracer.js +8 -12
  327. package/esm/domain/tracing/skywalkingTracer.js.map +1 -0
  328. package/esm/domain/tracing/traceIdentifier.js +2 -4
  329. package/esm/domain/tracing/traceIdentifier.js.map +1 -0
  330. package/esm/domain/tracing/tracer.js +5 -19
  331. package/esm/domain/tracing/tracer.js.map +1 -0
  332. package/esm/domain/tracing/w3cTraceParentTracer.js +4 -8
  333. package/esm/domain/tracing/w3cTraceParentTracer.js.map +1 -0
  334. package/esm/domain/tracing/zipkinMultiTracer.js +5 -4
  335. package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -0
  336. package/esm/domain/tracing/zipkinSingleTracer.js +3 -2
  337. package/esm/domain/tracing/zipkinSingleTracer.js.map +1 -0
  338. package/esm/domain/trackEventCounts.js +2 -8
  339. package/esm/domain/trackEventCounts.js.map +1 -0
  340. package/esm/domain/usr/index.js +2 -3
  341. package/esm/domain/usr/index.js.map +1 -0
  342. package/esm/domain/waitPageActivityEnd.js +9 -19
  343. package/esm/domain/waitPageActivityEnd.js.map +1 -0
  344. package/esm/index.js +2 -1
  345. package/esm/index.js.map +1 -0
  346. package/esm/transport/startRumBatch.js +7 -6
  347. package/esm/transport/startRumBatch.js.map +1 -0
  348. package/esm/transport/startRumEventBridge.js +2 -1
  349. package/esm/transport/startRumEventBridge.js.map +1 -0
  350. package/esm/types/index.js.map +1 -0
  351. package/esm/types/sessionReplayConstants.js +5 -3
  352. package/esm/types/sessionReplayConstants.js.map +1 -0
  353. package/package.json +6 -5
  354. package/src/boot/recorderApi.js +43 -32
  355. package/src/boot/rum.js +45 -10
  356. package/src/boot/startRecording.js +7 -3
  357. package/src/domain/assembly.js +5 -2
  358. package/src/domain/configuration.js +0 -1
  359. package/src/domain/contexts/displayContext.js +29 -0
  360. package/src/domain/contexts/internalContext.js +3 -1
  361. package/src/domain/contexts/pageStateHistory.js +138 -0
  362. package/src/domain/replay/deflate/deflateEncoder.js +88 -0
  363. package/src/domain/replay/{segmentCollection/startDeflateWorker.js → deflate/deflateWorker.js} +55 -32
  364. package/src/domain/replay/deflate/index.js +7 -0
  365. package/src/domain/replay/record/mutationObserver.js +2 -1
  366. package/src/domain/replay/record/observers.js +3 -3
  367. package/src/domain/replay/record/privacy.js +20 -23
  368. package/src/domain/replay/record/record.js +2 -2
  369. package/src/domain/replay/record/serializationUtils.js +4 -2
  370. package/src/domain/replay/record/serialize.js +11 -14
  371. package/src/domain/replay/record/shadowRootsController.js +0 -1
  372. package/src/domain/replay/record/viewports.js +0 -26
  373. package/src/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
  374. package/src/domain/replay/segmentCollection/index.js +0 -1
  375. package/src/domain/replay/segmentCollection/segment.js +28 -83
  376. package/src/domain/replay/segmentCollection/segmentCollection.js +49 -55
  377. package/src/domain/rumEventsCollection/actions/actionCollection.js +12 -12
  378. package/src/domain/rumEventsCollection/actions/trackClickActions.js +8 -6
  379. package/src/domain/rumEventsCollection/error/errorCollection.js +20 -15
  380. package/src/domain/rumEventsCollection/error/trackReportError.js +22 -16
  381. package/src/domain/rumEventsCollection/view/interactionCountPolyfill.js +59 -0
  382. package/src/domain/rumEventsCollection/view/trackCommonViewMetrics.js +87 -0
  383. package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +73 -0
  384. package/src/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +23 -0
  385. package/src/domain/rumEventsCollection/view/trackFirstInputTimings.js +40 -0
  386. package/src/domain/rumEventsCollection/view/trackInitialViewTimings.js +29 -199
  387. package/src/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +144 -0
  388. package/src/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +57 -0
  389. package/src/domain/rumEventsCollection/view/trackLoadingTime.js +50 -0
  390. package/src/domain/rumEventsCollection/view/trackNavigationTimings.js +35 -0
  391. package/src/domain/rumEventsCollection/view/trackScrollMetrics.js +74 -0
  392. package/src/domain/rumEventsCollection/view/trackViews.js +32 -37
  393. package/src/domain/rumEventsCollection/view/viewCollection.js +51 -22
  394. package/src/transport/startRumBatch.js +5 -1
  395. package/cjs/domain/replay/segmentCollection/startDeflateWorker.js +0 -145
  396. package/cjs/domain/rumEventsCollection/view/trackViewMetrics.js +0 -156
  397. package/esm/domain/replay/segmentCollection/startDeflateWorker.js +0 -128
  398. package/esm/domain/rumEventsCollection/view/trackViewMetrics.js +0 -146
  399. package/src/domain/rumEventsCollection/view/trackViewMetrics.js +0 -176
@@ -3,23 +3,23 @@ import { switchToAbsoluteUrl, getCssRulesString, getHref } from './serialization
3
3
  import { NodePrivacyLevel, PRIVACY_ATTR_NAME, PRIVACY_ATTR_VALUE_ALLOW, PRIVACY_ATTR_VALUE_MASK, PRIVACY_ATTR_VALUE_MASK_USER_INPUT, PRIVACY_ATTR_VALUE_HIDDEN, PRIVACY_CLASS_ALLOW, PRIVACY_CLASS_MASK, PRIVACY_CLASS_MASK_USER_INPUT, PRIVACY_CLASS_HIDDEN, FORM_PRIVATE_TAG_NAMES, CENSORED_STRING_MARK } from '../../../constants';
4
4
  export var MAX_ATTRIBUTE_VALUE_CHAR_LENGTH = 100000;
5
5
  var TEXT_MASKING_CHAR = 'x';
6
+
6
7
  /**
7
8
  * Get node privacy level by iterating over its ancestors. When the direct parent privacy level is
8
9
  * know, it is best to use something like:
9
10
  *
10
11
  * derivePrivacyLevelGivenParent(getNodeSelfPrivacyLevel(node), parentNodePrivacyLevel)
11
12
  */
12
-
13
13
  export function getNodePrivacyLevel(node, defaultPrivacyLevel) {
14
14
  var parentNode = getParentNode(node);
15
15
  var parentNodePrivacyLevel = parentNode ? getNodePrivacyLevel(parentNode, defaultPrivacyLevel) : defaultPrivacyLevel;
16
16
  var selfNodePrivacyLevel = getNodeSelfPrivacyLevel(node);
17
17
  return reducePrivacyLevel(selfNodePrivacyLevel, parentNodePrivacyLevel);
18
18
  }
19
+
19
20
  /**
20
21
  * Reduces the next privacy level based on self + parent privacy levels
21
22
  */
22
-
23
23
  export function reducePrivacyLevel(childPrivacyLevel, parentNodePrivacyLevel) {
24
24
  switch (parentNodePrivacyLevel) {
25
25
  // These values cannot be overridden
@@ -27,7 +27,6 @@ export function reducePrivacyLevel(childPrivacyLevel, parentNodePrivacyLevel) {
27
27
  case NodePrivacyLevel.IGNORE:
28
28
  return parentNodePrivacyLevel;
29
29
  }
30
-
31
30
  switch (childPrivacyLevel) {
32
31
  case NodePrivacyLevel.ALLOW:
33
32
  case NodePrivacyLevel.MASK:
@@ -35,67 +34,60 @@ export function reducePrivacyLevel(childPrivacyLevel, parentNodePrivacyLevel) {
35
34
  case NodePrivacyLevel.HIDDEN:
36
35
  case NodePrivacyLevel.IGNORE:
37
36
  return childPrivacyLevel;
38
-
39
37
  default:
40
38
  return parentNodePrivacyLevel;
41
39
  }
42
40
  }
41
+
43
42
  /**
44
43
  * Determines the node's own privacy level without checking for ancestors.
45
44
  */
46
-
47
45
  export function getNodeSelfPrivacyLevel(node) {
48
46
  // Only Element types can have a privacy level set
49
47
  if (!isElementNode(node)) {
50
48
  return;
51
49
  }
50
+ var privAttr = node.getAttribute(PRIVACY_ATTR_NAME);
52
51
 
53
- var privAttr = node.getAttribute(PRIVACY_ATTR_NAME); // Overrules for replay purpose
54
-
52
+ // Overrules for replay purpose
55
53
  if (node.tagName === 'BASE') {
56
54
  return NodePrivacyLevel.ALLOW;
57
- } // Overrules to enforce end-user protection
58
-
55
+ }
59
56
 
57
+ // Overrules to enforce end-user protection
60
58
  if (node.tagName === 'INPUT') {
61
59
  var inputElement = node;
62
-
63
60
  if (inputElement.type === 'password' || inputElement.type === 'email' || inputElement.type === 'tel') {
64
61
  return NodePrivacyLevel.MASK;
65
62
  }
66
-
67
63
  if (inputElement.type === 'hidden') {
68
64
  return NodePrivacyLevel.MASK;
69
65
  }
70
-
71
- var autocomplete = inputElement.getAttribute('autocomplete'); // Handle input[autocomplete=cc-number/cc-csc/cc-exp/cc-exp-month/cc-exp-year]
72
-
66
+ var autocomplete = inputElement.getAttribute('autocomplete');
67
+ // Handle input[autocomplete=cc-number/cc-csc/cc-exp/cc-exp-month/cc-exp-year]
73
68
  if (autocomplete && autocomplete.indexOf('cc-') === 0) {
74
69
  return NodePrivacyLevel.MASK;
75
70
  }
76
- } // Check HTML privacy attributes and classes
77
-
71
+ }
78
72
 
73
+ // Check HTML privacy attributes and classes
79
74
  if (privAttr === PRIVACY_ATTR_VALUE_HIDDEN || node.classList.contains(PRIVACY_CLASS_HIDDEN)) {
80
75
  return NodePrivacyLevel.HIDDEN;
81
76
  }
82
-
83
77
  if (privAttr === PRIVACY_ATTR_VALUE_MASK || node.classList.contains(PRIVACY_CLASS_MASK)) {
84
78
  return NodePrivacyLevel.MASK;
85
79
  }
86
-
87
80
  if (privAttr === PRIVACY_ATTR_VALUE_MASK_USER_INPUT || node.classList.contains(PRIVACY_CLASS_MASK_USER_INPUT)) {
88
81
  return NodePrivacyLevel.MASK_USER_INPUT;
89
82
  }
90
-
91
83
  if (privAttr === PRIVACY_ATTR_VALUE_ALLOW || node.classList.contains(PRIVACY_CLASS_ALLOW)) {
92
84
  return NodePrivacyLevel.ALLOW;
93
85
  }
94
-
95
86
  if (shouldIgnoreElement(node)) {
96
87
  return NodePrivacyLevel.IGNORE;
97
88
  }
98
89
  }
90
+
99
91
  /**
100
92
  * Helper aiming to unify `mask` and `mask-user-input` privacy levels:
101
93
  *
@@ -107,29 +99,23 @@ export function getNodeSelfPrivacyLevel(node) {
107
99
  * Other `shouldMaskNode` cases are edge cases that should not matter too much (ex: should we mask a
108
100
  * node if it is ignored or hidden? it doesn't matter since it won't be serialized).
109
101
  */
110
-
111
102
  export function shouldMaskNode(node, privacyLevel) {
112
103
  switch (privacyLevel) {
113
104
  case NodePrivacyLevel.MASK:
114
105
  case NodePrivacyLevel.HIDDEN:
115
106
  case NodePrivacyLevel.IGNORE:
116
107
  return true;
117
-
118
108
  case NodePrivacyLevel.MASK_USER_INPUT:
119
109
  return isTextNode(node) ? isFormElement(node.parentNode) : isFormElement(node);
120
-
121
110
  default:
122
111
  return false;
123
112
  }
124
113
  }
125
-
126
114
  function isFormElement(node) {
127
115
  if (!node || node.nodeType !== node.ELEMENT_NODE) {
128
116
  return false;
129
117
  }
130
-
131
118
  var element = node;
132
-
133
119
  if (element.tagName === 'INPUT') {
134
120
  switch (element.type) {
135
121
  case 'button':
@@ -139,15 +125,13 @@ function isFormElement(node) {
139
125
  return false;
140
126
  }
141
127
  }
142
-
143
128
  return !!FORM_PRIVATE_TAG_NAMES[element.tagName];
144
129
  }
130
+
145
131
  /**
146
132
  * Text censoring non-destructively maintains whitespace characters in order to preserve text shape
147
133
  * during replay.
148
134
  */
149
-
150
-
151
135
  export var censorText = function censorText(text) {
152
136
  return text.replace(/\S/g, TEXT_MASKING_CHAR);
153
137
  };
@@ -156,24 +140,22 @@ export function getTextContent(textNode, ignoreWhiteSpace, parentNodePrivacyLeve
156
140
  // So just let it be undefined which is ok in this use case.
157
141
  var parentTagName = textNode.parentElement && textNode.parentElement.tagName;
158
142
  var textContent = textNode.textContent || '';
159
-
160
143
  if (ignoreWhiteSpace && !textContent.trim()) {
161
144
  return;
162
145
  }
163
-
164
146
  var nodePrivacyLevel = parentNodePrivacyLevel;
165
- var isStyle = parentTagName === 'STYLE' ? true : undefined;
166
- var isScript = parentTagName === 'SCRIPT';
167
147
 
148
+ // var isStyle = parentTagName === 'STYLE' ? true : undefined
149
+ var isScript = parentTagName === 'SCRIPT';
168
150
  if (isScript) {
169
151
  // For perf reasons, we don't record script (heuristic)
170
152
  textContent = CENSORED_STRING_MARK;
171
153
  } else if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
172
154
  // Should never occur, but just in case, we set to CENSORED_MARK.
173
155
  textContent = CENSORED_STRING_MARK;
174
- } else if (shouldMaskNode(textNode, nodePrivacyLevel) && // Style tags are `overruled` (Use `hide` to enforce privacy)
175
- !isStyle) {
176
- if ( // Scrambling the child list breaks text nodes for DATALIST/SELECT/OPTGROUP
156
+ } else if (shouldMaskNode(textNode, nodePrivacyLevel)) {
157
+ if (
158
+ // Scrambling the child list breaks text nodes for DATALIST/SELECT/OPTGROUP
177
159
  parentTagName === 'DATALIST' || parentTagName === 'SELECT' || parentTagName === 'OPTGROUP') {
178
160
  if (!textContent.trim()) {
179
161
  return;
@@ -184,62 +166,72 @@ export function getTextContent(textNode, ignoreWhiteSpace, parentNodePrivacyLeve
184
166
  } else {
185
167
  textContent = censorText(textContent);
186
168
  }
187
- } else if (isStyle && textContent) {
188
- try {
189
- // try to read style sheet
190
- if (textNode.nextSibling || textNode.previousSibling) {// This is not the only child of the stylesheet.
191
- // We can't read all of the sheet's .cssRules and expect them
192
- // to _only_ include the current rule(s) added by the text node.
193
- // So we'll be conservative and keep textContent as-is.
194
- } else if (textNode.parentNode && textNode.parentNode.sheet && textNode.parentNode.sheet.cssRules) {
195
- textContent = getCssRulesString(textNode.parentNode.sheet);
196
- }
197
- } catch (err) {}
198
-
199
- textContent = switchToAbsoluteUrl(textContent, getHref());
200
169
  }
201
-
170
+ // else if (isStyle && textContent) {
171
+ // try {
172
+ // // try to read style sheet
173
+ // if (textNode.nextSibling || textNode.previousSibling) {
174
+ // // This is not the only child of the stylesheet.
175
+ // // We can't read all of the sheet's .cssRules and expect them
176
+ // // to _only_ include the current rule(s) added by the text node.
177
+ // // So we'll be conservative and keep textContent as-is.
178
+ // } else if (
179
+ // textNode.parentNode &&
180
+ // textNode.parentNode.sheet &&
181
+ // textNode.parentNode.sheet.cssRules
182
+ // ) {
183
+ // textContent = getCssRulesString(textNode.parentNode.sheet)
184
+ // }
185
+ // } catch (err) {}
186
+ // textContent = switchToAbsoluteUrl(textContent, getHref())
187
+ // }
202
188
  return textContent;
203
189
  }
190
+
204
191
  /**
205
192
  * TODO: Preserve CSS element order, and record the presence of the tag, just don't render
206
193
  * We don't need this logic on the recorder side.
207
194
  * For security related meta's, customer can mask themmanually given they
208
195
  * are easy to identify in the HEAD tag.
209
196
  */
210
-
211
197
  export function shouldIgnoreElement(element) {
212
198
  if (element.nodeName === 'SCRIPT') {
213
199
  return true;
214
200
  }
215
-
216
201
  if (element.nodeName === 'LINK') {
217
202
  var relAttribute = getLowerCaseAttribute('rel');
218
- return (// Link as script - Ignore only when rel=preload, modulepreload or prefetch
219
- /preload|prefetch/i.test(relAttribute) && getLowerCaseAttribute('as') === 'script' || // Favicons
203
+ return (
204
+ // Link as script - Ignore only when rel=preload, modulepreload or prefetch
205
+ /preload|prefetch/i.test(relAttribute) && getLowerCaseAttribute('as') === 'script' ||
206
+ // Favicons
220
207
  relAttribute === 'shortcut icon' || relAttribute === 'icon'
221
208
  );
222
209
  }
223
-
224
210
  if (element.nodeName === 'META') {
225
211
  var nameAttribute = getLowerCaseAttribute('name');
226
212
  var relAttribute = getLowerCaseAttribute('rel');
227
213
  var propertyAttribute = getLowerCaseAttribute('property');
228
- return (// Favicons
229
- /^msapplication-tile(image|color)$/.test(nameAttribute) || nameAttribute === 'application-name' || relAttribute === 'icon' || relAttribute === 'apple-touch-icon' || relAttribute === 'shortcut icon' || // Description
230
- nameAttribute === 'keywords' || nameAttribute === 'description' || // Social
231
- /^(og|twitter|fb):/.test(propertyAttribute) || /^(og|twitter):/.test(nameAttribute) || nameAttribute === 'pinterest' || // Robots
232
- nameAttribute === 'robots' || nameAttribute === 'googlebot' || nameAttribute === 'bingbot' || // Http headers. Ex: X-UA-Compatible, Content-Type, Content-Language, cache-control,
214
+ return (
215
+ // Favicons
216
+ /^msapplication-tile(image|color)$/.test(nameAttribute) || nameAttribute === 'application-name' || relAttribute === 'icon' || relAttribute === 'apple-touch-icon' || relAttribute === 'shortcut icon' ||
217
+ // Description
218
+ nameAttribute === 'keywords' || nameAttribute === 'description' ||
219
+ // Social
220
+ /^(og|twitter|fb):/.test(propertyAttribute) || /^(og|twitter):/.test(nameAttribute) || nameAttribute === 'pinterest' ||
221
+ // Robots
222
+ nameAttribute === 'robots' || nameAttribute === 'googlebot' || nameAttribute === 'bingbot' ||
223
+ // Http headers. Ex: X-UA-Compatible, Content-Type, Content-Language, cache-control,
233
224
  // X-Translated-By
234
- element.hasAttribute('http-equiv') || // Authorship
235
- nameAttribute === 'author' || nameAttribute === 'generator' || nameAttribute === 'framework' || nameAttribute === 'publisher' || nameAttribute === 'progid' || /^article:/.test(propertyAttribute) || /^product:/.test(propertyAttribute) || // Verification
225
+ element.hasAttribute('http-equiv') ||
226
+ // Authorship
227
+ nameAttribute === 'author' || nameAttribute === 'generator' || nameAttribute === 'framework' || nameAttribute === 'publisher' || nameAttribute === 'progid' || /^article:/.test(propertyAttribute) || /^product:/.test(propertyAttribute) ||
228
+ // Verification
236
229
  nameAttribute === 'google-site-verification' || nameAttribute === 'yandex-verification' || nameAttribute === 'csrf-token' || nameAttribute === 'p:domain_verify' || nameAttribute === 'verify-v1' || nameAttribute === 'verification' || nameAttribute === 'shopify-checkout-api-token'
237
230
  );
238
231
  }
239
-
240
232
  function getLowerCaseAttribute(name) {
241
233
  return (element.getAttribute(name) || '').toLowerCase();
242
234
  }
243
-
244
235
  return false;
245
- }
236
+ }
237
+ //# sourceMappingURL=privacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy.js","names":["isElementNode","getParentNode","isTextNode","switchToAbsoluteUrl","getCssRulesString","getHref","NodePrivacyLevel","PRIVACY_ATTR_NAME","PRIVACY_ATTR_VALUE_ALLOW","PRIVACY_ATTR_VALUE_MASK","PRIVACY_ATTR_VALUE_MASK_USER_INPUT","PRIVACY_ATTR_VALUE_HIDDEN","PRIVACY_CLASS_ALLOW","PRIVACY_CLASS_MASK","PRIVACY_CLASS_MASK_USER_INPUT","PRIVACY_CLASS_HIDDEN","FORM_PRIVATE_TAG_NAMES","CENSORED_STRING_MARK","MAX_ATTRIBUTE_VALUE_CHAR_LENGTH","TEXT_MASKING_CHAR","getNodePrivacyLevel","node","defaultPrivacyLevel","parentNode","parentNodePrivacyLevel","selfNodePrivacyLevel","getNodeSelfPrivacyLevel","reducePrivacyLevel","childPrivacyLevel","HIDDEN","IGNORE","ALLOW","MASK","MASK_USER_INPUT","privAttr","getAttribute","tagName","inputElement","type","autocomplete","indexOf","classList","contains","shouldIgnoreElement","shouldMaskNode","privacyLevel","isFormElement","nodeType","ELEMENT_NODE","element","censorText","text","replace","getTextContent","textNode","ignoreWhiteSpace","parentTagName","parentElement","textContent","trim","nodePrivacyLevel","isScript","nodeName","relAttribute","getLowerCaseAttribute","test","nameAttribute","propertyAttribute","hasAttribute","name","toLowerCase"],"sources":["../../../../src/domain/replay/record/privacy.js"],"sourcesContent":["import {\n isElementNode,\n getParentNode,\n isTextNode\n} from '@cloudcare/browser-core'\nimport {\n switchToAbsoluteUrl,\n getCssRulesString,\n getHref\n} from './serializationUtils'\nimport {\n NodePrivacyLevel,\n PRIVACY_ATTR_NAME,\n PRIVACY_ATTR_VALUE_ALLOW,\n PRIVACY_ATTR_VALUE_MASK,\n PRIVACY_ATTR_VALUE_MASK_USER_INPUT,\n PRIVACY_ATTR_VALUE_HIDDEN,\n PRIVACY_CLASS_ALLOW,\n PRIVACY_CLASS_MASK,\n PRIVACY_CLASS_MASK_USER_INPUT,\n PRIVACY_CLASS_HIDDEN,\n FORM_PRIVATE_TAG_NAMES,\n CENSORED_STRING_MARK\n} from '../../../constants'\n\nexport var MAX_ATTRIBUTE_VALUE_CHAR_LENGTH = 100_000\n\nvar TEXT_MASKING_CHAR = 'x'\n\n/**\n * Get node privacy level by iterating over its ancestors. When the direct parent privacy level is\n * know, it is best to use something like:\n *\n * derivePrivacyLevelGivenParent(getNodeSelfPrivacyLevel(node), parentNodePrivacyLevel)\n */\nexport function getNodePrivacyLevel(node, defaultPrivacyLevel) {\n var parentNode = getParentNode(node)\n var parentNodePrivacyLevel = parentNode\n ? getNodePrivacyLevel(parentNode, defaultPrivacyLevel)\n : defaultPrivacyLevel\n var selfNodePrivacyLevel = getNodeSelfPrivacyLevel(node)\n return reducePrivacyLevel(selfNodePrivacyLevel, parentNodePrivacyLevel)\n}\n\n/**\n * Reduces the next privacy level based on self + parent privacy levels\n */\nexport function reducePrivacyLevel(childPrivacyLevel, parentNodePrivacyLevel) {\n switch (parentNodePrivacyLevel) {\n // These values cannot be overridden\n case NodePrivacyLevel.HIDDEN:\n case NodePrivacyLevel.IGNORE:\n return parentNodePrivacyLevel\n }\n switch (childPrivacyLevel) {\n case NodePrivacyLevel.ALLOW:\n case NodePrivacyLevel.MASK:\n case NodePrivacyLevel.MASK_USER_INPUT:\n case NodePrivacyLevel.HIDDEN:\n case NodePrivacyLevel.IGNORE:\n return childPrivacyLevel\n default:\n return parentNodePrivacyLevel\n }\n}\n\n/**\n * Determines the node's own privacy level without checking for ancestors.\n */\nexport function getNodeSelfPrivacyLevel(node) {\n // Only Element types can have a privacy level set\n if (!isElementNode(node)) {\n return\n }\n\n var privAttr = node.getAttribute(PRIVACY_ATTR_NAME)\n\n // Overrules for replay purpose\n if (node.tagName === 'BASE') {\n return NodePrivacyLevel.ALLOW\n }\n\n // Overrules to enforce end-user protection\n if (node.tagName === 'INPUT') {\n var inputElement = node\n if (\n inputElement.type === 'password' ||\n inputElement.type === 'email' ||\n inputElement.type === 'tel'\n ) {\n return NodePrivacyLevel.MASK\n }\n if (inputElement.type === 'hidden') {\n return NodePrivacyLevel.MASK\n }\n var autocomplete = inputElement.getAttribute('autocomplete')\n // Handle input[autocomplete=cc-number/cc-csc/cc-exp/cc-exp-month/cc-exp-year]\n if (autocomplete && autocomplete.indexOf('cc-') === 0) {\n return NodePrivacyLevel.MASK\n }\n }\n\n // Check HTML privacy attributes and classes\n if (\n privAttr === PRIVACY_ATTR_VALUE_HIDDEN ||\n node.classList.contains(PRIVACY_CLASS_HIDDEN)\n ) {\n return NodePrivacyLevel.HIDDEN\n }\n\n if (\n privAttr === PRIVACY_ATTR_VALUE_MASK ||\n node.classList.contains(PRIVACY_CLASS_MASK)\n ) {\n return NodePrivacyLevel.MASK\n }\n\n if (\n privAttr === PRIVACY_ATTR_VALUE_MASK_USER_INPUT ||\n node.classList.contains(PRIVACY_CLASS_MASK_USER_INPUT)\n ) {\n return NodePrivacyLevel.MASK_USER_INPUT\n }\n\n if (\n privAttr === PRIVACY_ATTR_VALUE_ALLOW ||\n node.classList.contains(PRIVACY_CLASS_ALLOW)\n ) {\n return NodePrivacyLevel.ALLOW\n }\n\n if (shouldIgnoreElement(node)) {\n return NodePrivacyLevel.IGNORE\n }\n}\n\n/**\n * Helper aiming to unify `mask` and `mask-user-input` privacy levels:\n *\n * In the `mask` case, it is trivial: we should mask the element.\n *\n * In the `mask-user-input` case, we should mask the element only if it is a \"form\" element or the\n * direct parent is a form element for text nodes).\n *\n * Other `shouldMaskNode` cases are edge cases that should not matter too much (ex: should we mask a\n * node if it is ignored or hidden? it doesn't matter since it won't be serialized).\n */\nexport function shouldMaskNode(node, privacyLevel) {\n switch (privacyLevel) {\n case NodePrivacyLevel.MASK:\n case NodePrivacyLevel.HIDDEN:\n case NodePrivacyLevel.IGNORE:\n return true\n case NodePrivacyLevel.MASK_USER_INPUT:\n return isTextNode(node)\n ? isFormElement(node.parentNode)\n : isFormElement(node)\n default:\n return false\n }\n}\n\nfunction isFormElement(node) {\n if (!node || node.nodeType !== node.ELEMENT_NODE) {\n return false\n }\n var element = node\n if (element.tagName === 'INPUT') {\n switch (element.type) {\n case 'button':\n case 'color':\n case 'reset':\n case 'submit':\n return false\n }\n }\n return !!FORM_PRIVATE_TAG_NAMES[element.tagName]\n}\n\n/**\n * Text censoring non-destructively maintains whitespace characters in order to preserve text shape\n * during replay.\n */\nexport var censorText = function (text) {\n return text.replace(/\\S/g, TEXT_MASKING_CHAR)\n}\n\nexport function getTextContent(\n textNode,\n ignoreWhiteSpace,\n parentNodePrivacyLevel\n) {\n // The parent node may not be a html element which has a tagName attribute.\n // So just let it be undefined which is ok in this use case.\n var parentTagName = textNode.parentElement && textNode.parentElement.tagName\n var textContent = textNode.textContent || ''\n\n if (ignoreWhiteSpace && !textContent.trim()) {\n return\n }\n\n var nodePrivacyLevel = parentNodePrivacyLevel\n\n // var isStyle = parentTagName === 'STYLE' ? true : undefined\n var isScript = parentTagName === 'SCRIPT'\n\n if (isScript) {\n // For perf reasons, we don't record script (heuristic)\n textContent = CENSORED_STRING_MARK\n } else if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {\n // Should never occur, but just in case, we set to CENSORED_MARK.\n textContent = CENSORED_STRING_MARK\n } else if (shouldMaskNode(textNode, nodePrivacyLevel)) {\n if (\n // Scrambling the child list breaks text nodes for DATALIST/SELECT/OPTGROUP\n parentTagName === 'DATALIST' ||\n parentTagName === 'SELECT' ||\n parentTagName === 'OPTGROUP'\n ) {\n if (!textContent.trim()) {\n return\n }\n } else if (parentTagName === 'OPTION') {\n // <Option> has low entropy in charset + text length, so use `CENSORED_STRING_MARK` when masked\n textContent = CENSORED_STRING_MARK\n } else {\n textContent = censorText(textContent)\n }\n }\n // else if (isStyle && textContent) {\n // try {\n // // try to read style sheet\n // if (textNode.nextSibling || textNode.previousSibling) {\n // // This is not the only child of the stylesheet.\n // // We can't read all of the sheet's .cssRules and expect them\n // // to _only_ include the current rule(s) added by the text node.\n // // So we'll be conservative and keep textContent as-is.\n // } else if (\n // textNode.parentNode &&\n // textNode.parentNode.sheet &&\n // textNode.parentNode.sheet.cssRules\n // ) {\n // textContent = getCssRulesString(textNode.parentNode.sheet)\n // }\n // } catch (err) {}\n // textContent = switchToAbsoluteUrl(textContent, getHref())\n // }\n return textContent\n}\n\n/**\n * TODO: Preserve CSS element order, and record the presence of the tag, just don't render\n * We don't need this logic on the recorder side.\n * For security related meta's, customer can mask themmanually given they\n * are easy to identify in the HEAD tag.\n */\nexport function shouldIgnoreElement(element) {\n if (element.nodeName === 'SCRIPT') {\n return true\n }\n\n if (element.nodeName === 'LINK') {\n var relAttribute = getLowerCaseAttribute('rel')\n return (\n // Link as script - Ignore only when rel=preload, modulepreload or prefetch\n (/preload|prefetch/i.test(relAttribute) &&\n getLowerCaseAttribute('as') === 'script') ||\n // Favicons\n relAttribute === 'shortcut icon' ||\n relAttribute === 'icon'\n )\n }\n\n if (element.nodeName === 'META') {\n var nameAttribute = getLowerCaseAttribute('name')\n var relAttribute = getLowerCaseAttribute('rel')\n var propertyAttribute = getLowerCaseAttribute('property')\n return (\n // Favicons\n /^msapplication-tile(image|color)$/.test(nameAttribute) ||\n nameAttribute === 'application-name' ||\n relAttribute === 'icon' ||\n relAttribute === 'apple-touch-icon' ||\n relAttribute === 'shortcut icon' ||\n // Description\n nameAttribute === 'keywords' ||\n nameAttribute === 'description' ||\n // Social\n /^(og|twitter|fb):/.test(propertyAttribute) ||\n /^(og|twitter):/.test(nameAttribute) ||\n nameAttribute === 'pinterest' ||\n // Robots\n nameAttribute === 'robots' ||\n nameAttribute === 'googlebot' ||\n nameAttribute === 'bingbot' ||\n // Http headers. Ex: X-UA-Compatible, Content-Type, Content-Language, cache-control,\n // X-Translated-By\n element.hasAttribute('http-equiv') ||\n // Authorship\n nameAttribute === 'author' ||\n nameAttribute === 'generator' ||\n nameAttribute === 'framework' ||\n nameAttribute === 'publisher' ||\n nameAttribute === 'progid' ||\n /^article:/.test(propertyAttribute) ||\n /^product:/.test(propertyAttribute) ||\n // Verification\n nameAttribute === 'google-site-verification' ||\n nameAttribute === 'yandex-verification' ||\n nameAttribute === 'csrf-token' ||\n nameAttribute === 'p:domain_verify' ||\n nameAttribute === 'verify-v1' ||\n nameAttribute === 'verification' ||\n nameAttribute === 'shopify-checkout-api-token'\n )\n }\n\n function getLowerCaseAttribute(name) {\n return (element.getAttribute(name) || '').toLowerCase()\n }\n\n return false\n}\n"],"mappings":"AAAA,SACEA,aAAa,EACbC,aAAa,EACbC,UAAU,QACL,yBAAyB;AAChC,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,OAAO,QACF,sBAAsB;AAC7B,SACEC,gBAAgB,EAChBC,iBAAiB,EACjBC,wBAAwB,EACxBC,uBAAuB,EACvBC,kCAAkC,EAClCC,yBAAyB,EACzBC,mBAAmB,EACnBC,kBAAkB,EAClBC,6BAA6B,EAC7BC,oBAAoB,EACpBC,sBAAsB,EACtBC,oBAAoB,QACf,oBAAoB;AAE3B,OAAO,IAAIC,+BAA+B,GAAG,MAAO;AAEpD,IAAIC,iBAAiB,GAAG,GAAG;;AAE3B;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,IAAI,EAAEC,mBAAmB,EAAE;EAC7D,IAAIC,UAAU,GAAGtB,aAAa,CAACoB,IAAI,CAAC;EACpC,IAAIG,sBAAsB,GAAGD,UAAU,GACnCH,mBAAmB,CAACG,UAAU,EAAED,mBAAmB,CAAC,GACpDA,mBAAmB;EACvB,IAAIG,oBAAoB,GAAGC,uBAAuB,CAACL,IAAI,CAAC;EACxD,OAAOM,kBAAkB,CAACF,oBAAoB,EAAED,sBAAsB,CAAC;AACzE;;AAEA;AACA;AACA;AACA,OAAO,SAASG,kBAAkBA,CAACC,iBAAiB,EAAEJ,sBAAsB,EAAE;EAC5E,QAAQA,sBAAsB;IA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I,CAACE,iBAAiB,CAAC,IAC3C,gBAAgB,CAACF,IAAI,CAACC,aAAa,CAAC,IACpCA,aAAa,KAAK,WAAW;MAC7B;MACAA,aAAa,KAAK,QAAQ,IAC1BA,aAAa,KAAK,WAAW,IAC7BA,aAAa,KAAK,SAAS;MAC3B;MACA;MACAjB,OAAO,CAACmB,YAAY,CAAC,YAAY,CAAC;MAClC;MACAF,aAAa,KAAK,QAAQ,IAC1BA,aAAa,KAAK,WAAW,IAC7BA,aAAa,KAAK,WAAW,IAC7BA,aAAa,KAAK,WAAW,IAC7BA,aAAa,KAAK,QAAQ,IAC1B,WAAW,CAACD,IAAI,CAACE,iBAAiB,CAAC,IACnC,WAAW,CAACF,IAAI,CAACE,iBAAiB,CAAC;MACnC;MACAD,aAAa,KAAK,0BAA0B,IAC5CA,aAAa,KAAK,qBAAqB,IACvCA,aAAa,KAAK,YAAY,IAC9BA,aAAa,KAAK,iBAAiB,IACnCA,aAAa,KAAK,WAAW,IAC7BA,aAAa,KAAK,cAAc,IAChCA,aAAa,KAAK;IAA4B;EAElD;EAEA,SAASF,qBAAqBA,CAACK,IAAI,EAAE;IACnC,OAAO,CAACpB,OAAO,CAACd,YAAY,CAACkC,IAAI,CAAC,IAAI,EAAE,EAAEC,WAAW,CAAC,CAAC;EACzD;EAEA,OAAO,KAAK;AACd"}
@@ -1,39 +1,33 @@
1
- import { timeStampNow } from '@cloudcare/browser-core';
1
+ import { timeStampNow, getScrollX, getScrollY } from '@cloudcare/browser-core';
2
2
  import { getViewportDimension } from '../../initViewportObservable';
3
3
  import { RecordType, IncrementalSource } from '../../../types';
4
4
  import { serializeDocument, SerializationContextStatus } from './serialize';
5
5
  import { initObservers } from './observers';
6
- import { getVisualViewport, getScrollX, getScrollY } from './viewports';
6
+ import { getVisualViewport } from './viewports';
7
7
  import { assembleIncrementalSnapshot } from './utils';
8
8
  import { createElementsScrollPositions } from './elementsScrollPositions';
9
9
  import { initShadowRootsController } from './shadowRootsController';
10
10
  export function record(options) {
11
- var emit = options.emit; // runtime checks for user options
12
-
11
+ var emit = options.emit;
12
+ // runtime checks for user options
13
13
  if (!emit) {
14
14
  throw new Error('emit function is required');
15
15
  }
16
-
17
16
  var elementsScrollPositions = createElementsScrollPositions();
18
-
19
17
  var mutationCb = function mutationCb(mutation) {
20
18
  emit(assembleIncrementalSnapshot(IncrementalSource.Mutation, mutation));
21
19
  };
22
-
23
20
  var inputCb = function inputCb(s) {
24
21
  emit(assembleIncrementalSnapshot(IncrementalSource.Input, s));
25
22
  };
26
-
27
23
  var shadowRootsController = initShadowRootsController(options.configuration, {
28
24
  mutationCb: mutationCb,
29
25
  inputCb: inputCb
30
26
  });
31
-
32
27
  var takeFullSnapshot = function takeFullSnapshot(timestamp, serializationContext) {
33
28
  if (typeof timestamp === 'undefined') {
34
29
  timestamp = timeStampNow();
35
30
  }
36
-
37
31
  if (typeof serializationContext === 'undefined') {
38
32
  serializationContext = {
39
33
  status: SerializationContextStatus.INITIAL_FULL_SNAPSHOT,
@@ -41,9 +35,7 @@ export function record(options) {
41
35
  shadowRootsController: shadowRootsController
42
36
  };
43
37
  }
44
-
45
38
  var _viewportDimension = getViewportDimension();
46
-
47
39
  var width = _viewportDimension.width;
48
40
  var height = _viewportDimension.height;
49
41
  emit({
@@ -73,7 +65,6 @@ export function record(options) {
73
65
  type: RecordType.FullSnapshot,
74
66
  timestamp: timestamp
75
67
  });
76
-
77
68
  if (window.visualViewport) {
78
69
  emit({
79
70
  data: getVisualViewport(),
@@ -82,9 +73,7 @@ export function record(options) {
82
73
  });
83
74
  }
84
75
  };
85
-
86
76
  takeFullSnapshot();
87
-
88
77
  var _initObservers = initObservers({
89
78
  lifeCycle: options.lifeCycle,
90
79
  configuration: options.configuration,
@@ -130,15 +119,12 @@ export function record(options) {
130
119
  },
131
120
  shadowRootsController: shadowRootsController
132
121
  });
133
-
134
122
  var stopObservers = _initObservers.stop;
135
123
  var flushMutationsFromObservers = _initObservers.flush;
136
-
137
124
  function flushMutations() {
138
125
  shadowRootsController.flush();
139
126
  flushMutationsFromObservers();
140
127
  }
141
-
142
128
  return {
143
129
  stop: function stop() {
144
130
  shadowRootsController.stop();
@@ -155,4 +141,5 @@ export function record(options) {
155
141
  flushMutations: flushMutations,
156
142
  shadowRootsController: shadowRootsController
157
143
  };
158
- }
144
+ }
145
+ //# sourceMappingURL=record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","names":["timeStampNow","getScrollX","getScrollY","getViewportDimension","RecordType","IncrementalSource","serializeDocument","SerializationContextStatus","initObservers","getVisualViewport","assembleIncrementalSnapshot","createElementsScrollPositions","initShadowRootsController","record","options","emit","Error","elementsScrollPositions","mutationCb","mutation","Mutation","inputCb","s","Input","shadowRootsController","configuration","takeFullSnapshot","timestamp","serializationContext","status","INITIAL_FULL_SNAPSHOT","_viewportDimension","width","height","data","href","window","location","type","Meta","has_focus","document","hasFocus","Focus","node","initialOffset","left","top","FullSnapshot","visualViewport","VisualViewport","_initObservers","lifeCycle","mediaInteractionCb","p","MediaInteraction","mouseInteractionCb","mouseInteractionRecord","mousemoveCb","positions","source","scrollCb","Scroll","styleSheetCb","r","StyleSheetRule","viewportResizeCb","d","ViewportResize","frustrationCb","frustrationRecord","focusCb","visualViewportResizeCb","stopObservers","stop","flushMutationsFromObservers","flush","flushMutations","takeSubsequentFullSnapshot","SUBSEQUENT_FULL_SNAPSHOT"],"sources":["../../../../src/domain/replay/record/record.js"],"sourcesContent":["import { timeStampNow, getScrollX, getScrollY } from '@cloudcare/browser-core'\nimport { getViewportDimension } from '../../initViewportObservable'\n\nimport { RecordType, IncrementalSource } from '../../../types'\nimport { serializeDocument, SerializationContextStatus } from './serialize'\nimport { initObservers } from './observers'\n\nimport { getVisualViewport } from './viewports'\nimport { assembleIncrementalSnapshot } from './utils'\nimport { createElementsScrollPositions } from './elementsScrollPositions'\nimport { initShadowRootsController } from './shadowRootsController'\n\nexport function record(options) {\n var emit = options.emit\n // runtime checks for user options\n if (!emit) {\n throw new Error('emit function is required')\n }\n\n var elementsScrollPositions = createElementsScrollPositions()\n\n var mutationCb = function (mutation) {\n emit(assembleIncrementalSnapshot(IncrementalSource.Mutation, mutation))\n }\n var inputCb = function (s) {\n emit(assembleIncrementalSnapshot(IncrementalSource.Input, s))\n }\n\n var shadowRootsController = initShadowRootsController(options.configuration, {\n mutationCb,\n inputCb\n })\n\n var takeFullSnapshot = function (timestamp, serializationContext) {\n if (typeof timestamp === 'undefined') {\n timestamp = timeStampNow()\n }\n if (typeof serializationContext === 'undefined') {\n serializationContext = {\n status: SerializationContextStatus.INITIAL_FULL_SNAPSHOT,\n elementsScrollPositions: elementsScrollPositions,\n shadowRootsController: shadowRootsController\n }\n }\n var _viewportDimension = getViewportDimension()\n var width = _viewportDimension.width\n var height = _viewportDimension.height\n emit({\n data: {\n height: height,\n href: window.location.href,\n width: width\n },\n type: RecordType.Meta,\n timestamp: timestamp\n })\n\n emit({\n data: {\n has_focus: document.hasFocus()\n },\n type: RecordType.Focus,\n timestamp: timestamp\n })\n\n emit({\n data: {\n node: serializeDocument(\n document,\n options.configuration,\n serializationContext\n ),\n initialOffset: {\n left: getScrollX(),\n top: getScrollY()\n }\n },\n type: RecordType.FullSnapshot,\n timestamp: timestamp\n })\n\n if (window.visualViewport) {\n emit({\n data: getVisualViewport(),\n type: RecordType.VisualViewport,\n timestamp: timestamp\n })\n }\n }\n\n takeFullSnapshot()\n var _initObservers = initObservers({\n lifeCycle: options.lifeCycle,\n configuration: options.configuration,\n elementsScrollPositions: elementsScrollPositions,\n inputCb: inputCb,\n mediaInteractionCb: function (p) {\n emit(assembleIncrementalSnapshot(IncrementalSource.MediaInteraction, p))\n },\n mouseInteractionCb: function (mouseInteractionRecord) {\n emit(mouseInteractionRecord)\n },\n mousemoveCb: function (positions, source) {\n emit(assembleIncrementalSnapshot(source, { positions: positions }))\n },\n mutationCb: mutationCb,\n scrollCb: function (p) {\n emit(assembleIncrementalSnapshot(IncrementalSource.Scroll, p))\n },\n styleSheetCb: function (r) {\n emit(assembleIncrementalSnapshot(IncrementalSource.StyleSheetRule, r))\n },\n viewportResizeCb: function (d) {\n emit(assembleIncrementalSnapshot(IncrementalSource.ViewportResize, d))\n },\n frustrationCb: function (frustrationRecord) {\n emit(frustrationRecord)\n },\n focusCb: function (data) {\n emit({\n data: data,\n type: RecordType.Focus,\n timestamp: timeStampNow()\n })\n },\n visualViewportResizeCb: function (data) {\n emit({\n data: data,\n type: RecordType.VisualViewport,\n timestamp: timeStampNow()\n })\n },\n shadowRootsController: shadowRootsController\n })\n var stopObservers = _initObservers.stop\n var flushMutationsFromObservers = _initObservers.flush\n function flushMutations() {\n shadowRootsController.flush()\n flushMutationsFromObservers()\n }\n\n return {\n stop: function () {\n shadowRootsController.stop()\n stopObservers()\n },\n takeSubsequentFullSnapshot: function (timestamp) {\n flushMutations()\n takeFullSnapshot(timestamp, {\n shadowRootsController: shadowRootsController,\n status: SerializationContextStatus.SUBSEQUENT_FULL_SNAPSHOT,\n elementsScrollPositions: elementsScrollPositions\n })\n },\n flushMutations: flushMutations,\n shadowRootsController: shadowRootsController\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAQ,yBAAyB;AAC9E,SAASC,oBAAoB,QAAQ,8BAA8B;AAEnE,SAASC,UAAU,EAAEC,iBAAiB,QAAQ,gBAAgB;AAC9D,SAASC,iBAAiB,EAAEC,0BAA0B,QAAQ,aAAa;AAC3E,SAASC,aAAa,QAAQ,aAAa;AAE3C,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,2BAA2B,QAAQ,SAAS;AACrD,SAASC,6BAA6B,QAAQ,2BAA2B;AACzE,SAASC,yBAAyB,QAAQ,yBAAyB;AAEnE,OAAO,SAASC,MAAMA,CAACC,OAAO,EAAE;EAC9B,IAAIC,IAAI,GAAGD,OAAO,CAACC,IAAI;EACvB;EACA,IAAI,CAACA,IAAI,EAAE;IACT,MAAM,IAAIC,KAAK,CAAC,2BAA2B,C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