@cloudcare/browser-rum 3.3.23 → 3.3.24

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 (255) hide show
  1. package/bundle/dataflux-rum.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/domain/deflate/deflateWorker.js +1 -1
  4. package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
  5. package/esm/boot/buildEnv.js +2 -5
  6. package/esm/boot/buildEnv.js.map +1 -1
  7. package/esm/boot/disabledRumPublicApi.js +2 -35
  8. package/esm/boot/disabledRumPublicApi.js.map +1 -1
  9. package/esm/boot/perStartRum.js +2 -260
  10. package/esm/boot/perStartRum.js.map +1 -1
  11. package/esm/boot/recorderApi.js +2 -338
  12. package/esm/boot/recorderApi.js.map +1 -1
  13. package/esm/boot/recorderApiStub.js +2 -21
  14. package/esm/boot/recorderApiStub.js.map +1 -1
  15. package/esm/boot/rum.entry.js +2 -13
  16. package/esm/boot/rum.entry.js.map +1 -1
  17. package/esm/boot/rum.js +2 -184
  18. package/esm/boot/rum.js.map +1 -1
  19. package/esm/boot/rum.slim.entry.js +2 -7
  20. package/esm/boot/rum.slim.entry.js.map +1 -1
  21. package/esm/boot/rumEntryFactory.js +2 -18
  22. package/esm/boot/rumEntryFactory.js.map +1 -1
  23. package/esm/boot/rumPublicApi.js +2 -344
  24. package/esm/boot/rumPublicApi.js.map +1 -1
  25. package/esm/boot/rumRecorderApiStub.js +2 -13
  26. package/esm/boot/rumRecorderApiStub.js.map +1 -1
  27. package/esm/boot/rumSlimConfiguration.js +2 -10
  28. package/esm/boot/rumSlimConfiguration.js.map +1 -1
  29. package/esm/boot/sessionReplayPublicApi.js +2 -43
  30. package/esm/boot/sessionReplayPublicApi.js.map +1 -1
  31. package/esm/boot/startRecording.js +2 -444
  32. package/esm/boot/startRecording.js.map +1 -1
  33. package/esm/constants.js +2 -28
  34. package/esm/constants.js.map +1 -1
  35. package/esm/domain/assembly.js +2 -213
  36. package/esm/domain/assembly.js.map +1 -1
  37. package/esm/domain/configuration.js +2 -323
  38. package/esm/domain/configuration.js.map +1 -1
  39. package/esm/domain/contexts/commonContext.js +2 -8
  40. package/esm/domain/contexts/commonContext.js.map +1 -1
  41. package/esm/domain/contexts/displayContext.js +2 -16
  42. package/esm/domain/contexts/displayContext.js.map +1 -1
  43. package/esm/domain/contexts/foregroundContexts.js +2 -103
  44. package/esm/domain/contexts/foregroundContexts.js.map +1 -1
  45. package/esm/domain/contexts/internalContext.js +2 -41
  46. package/esm/domain/contexts/internalContext.js.map +1 -1
  47. package/esm/domain/contexts/pageStateHistory.js +2 -104
  48. package/esm/domain/contexts/pageStateHistory.js.map +1 -1
  49. package/esm/domain/contexts/urlContexts.js +2 -85
  50. package/esm/domain/contexts/urlContexts.js.map +1 -1
  51. package/esm/domain/contexts/viewContexts.js +2 -45
  52. package/esm/domain/contexts/viewContexts.js.map +1 -1
  53. package/esm/domain/deflate/deflateEncoder.js +2 -592
  54. package/esm/domain/deflate/deflateEncoder.js.map +1 -1
  55. package/esm/domain/deflate/deflateWorker.js +2 -225
  56. package/esm/domain/deflate/deflateWorker.js.map +1 -1
  57. package/esm/domain/deflate/index.js +2 -3
  58. package/esm/domain/deflate/index.js.map +1 -1
  59. package/esm/domain/domMutationObservable.js +2 -62
  60. package/esm/domain/domMutationObservable.js.map +1 -1
  61. package/esm/domain/encoderStreamId.js +2 -6
  62. package/esm/domain/encoderStreamId.js.map +1 -1
  63. package/esm/domain/firstInputPolyfill.js +2 -77
  64. package/esm/domain/firstInputPolyfill.js.map +1 -1
  65. package/esm/domain/initViewportObservable.js +2 -36
  66. package/esm/domain/initViewportObservable.js.map +1 -1
  67. package/esm/domain/locationChangeObservable.js +2 -65
  68. package/esm/domain/locationChangeObservable.js.map +1 -1
  69. package/esm/domain/performanceObservable.js +2 -116
  70. package/esm/domain/performanceObservable.js.map +1 -1
  71. package/esm/domain/performanceUtils.js +2 -45
  72. package/esm/domain/performanceUtils.js.map +1 -1
  73. package/esm/domain/plugins.js +2 -59
  74. package/esm/domain/plugins.js.map +1 -1
  75. package/esm/domain/privacy.js +2 -266
  76. package/esm/domain/privacy.js.map +1 -1
  77. package/esm/domain/replay/record/canvasAutoSnapshot.js +2 -9
  78. package/esm/domain/replay/record/canvasAutoSnapshot.js.map +1 -1
  79. package/esm/domain/replay/record/canvasCommandCapture.js +2 -1275
  80. package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
  81. package/esm/domain/replay/record/canvasCommandObserver.js +2 -1207
  82. package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -1
  83. package/esm/domain/replay/record/canvasCommandSerializeArgs.js +2 -111
  84. package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
  85. package/esm/domain/replay/record/canvasContext.js +2 -50
  86. package/esm/domain/replay/record/canvasContext.js.map +1 -1
  87. package/esm/domain/replay/record/canvasContinuousScheduler.js +2 -378
  88. package/esm/domain/replay/record/canvasContinuousScheduler.js.map +1 -1
  89. package/esm/domain/replay/record/canvasEncodeBridge.js +2 -692
  90. package/esm/domain/replay/record/canvasEncodeBridge.js.map +1 -1
  91. package/esm/domain/replay/record/canvasEncodeWorker.js +2 -164
  92. package/esm/domain/replay/record/canvasEncodeWorker.js.map +1 -1
  93. package/esm/domain/replay/record/canvasFrameSignature.js +2 -75
  94. package/esm/domain/replay/record/canvasFrameSignature.js.map +1 -1
  95. package/esm/domain/replay/record/canvasMutationRecord.js +2 -26
  96. package/esm/domain/replay/record/canvasMutationRecord.js.map +1 -1
  97. package/esm/domain/replay/record/canvasObserver.js +2 -420
  98. package/esm/domain/replay/record/canvasObserver.js.map +1 -1
  99. package/esm/domain/replay/record/canvasSerializeArgs.js +2 -101
  100. package/esm/domain/replay/record/canvasSerializeArgs.js.map +1 -1
  101. package/esm/domain/replay/record/canvasWebGLPluginHost.js +2 -26
  102. package/esm/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
  103. package/esm/domain/replay/record/elementsScrollPositions.js +2 -23
  104. package/esm/domain/replay/record/elementsScrollPositions.js.map +1 -1
  105. package/esm/domain/replay/record/index.js +2 -4
  106. package/esm/domain/replay/record/index.js.map +1 -1
  107. package/esm/domain/replay/record/mutationBatch.js +2 -562
  108. package/esm/domain/replay/record/mutationBatch.js.map +1 -1
  109. package/esm/domain/replay/record/mutationObserver.js +2 -2332
  110. package/esm/domain/replay/record/mutationObserver.js.map +1 -1
  111. package/esm/domain/replay/record/mutationResourceBudget.js +2 -137
  112. package/esm/domain/replay/record/mutationResourceBudget.js.map +1 -1
  113. package/esm/domain/replay/record/observers.js +2 -624
  114. package/esm/domain/replay/record/observers.js.map +1 -1
  115. package/esm/domain/replay/record/privacy.js +2 -1
  116. package/esm/domain/replay/record/privacy.js.map +1 -1
  117. package/esm/domain/replay/record/record.js +2 -3511
  118. package/esm/domain/replay/record/record.js.map +1 -1
  119. package/esm/domain/replay/record/serializationUtils.js +2 -677
  120. package/esm/domain/replay/record/serializationUtils.js.map +1 -1
  121. package/esm/domain/replay/record/serialize.js +2 -735
  122. package/esm/domain/replay/record/serialize.js.map +1 -1
  123. package/esm/domain/replay/record/shadowRootsController.js +2 -902
  124. package/esm/domain/replay/record/shadowRootsController.js.map +1 -1
  125. package/esm/domain/replay/record/utils.js +2 -36
  126. package/esm/domain/replay/record/utils.js.map +1 -1
  127. package/esm/domain/replay/record/viewports.js +2 -58
  128. package/esm/domain/replay/record/viewports.js.map +1 -1
  129. package/esm/domain/replay/replayStats.js +2 -59
  130. package/esm/domain/replay/replayStats.js.map +1 -1
  131. package/esm/domain/replay/segmentCollection/buildReplayPayload.js +2 -31
  132. package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
  133. package/esm/domain/replay/segmentCollection/index.js +2 -3
  134. package/esm/domain/replay/segmentCollection/index.js.map +1 -1
  135. package/esm/domain/replay/segmentCollection/segment.js +2 -415
  136. package/esm/domain/replay/segmentCollection/segment.js.map +1 -1
  137. package/esm/domain/replay/segmentCollection/segmentCollection.js +2 -1114
  138. package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  139. package/esm/domain/replay/startRecordBridge.js +2 -13
  140. package/esm/domain/replay/startRecordBridge.js.map +1 -1
  141. package/esm/domain/replay/timeAnchor.js +2 -20
  142. package/esm/domain/replay/timeAnchor.js.map +1 -1
  143. package/esm/domain/requestCollection.js +2 -121
  144. package/esm/domain/requestCollection.js.map +1 -1
  145. package/esm/domain/rumEventsCollection/actions/actionCollection.js +2 -83
  146. package/esm/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
  147. package/esm/domain/rumEventsCollection/actions/clickChain.js +2 -62
  148. package/esm/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
  149. package/esm/domain/rumEventsCollection/actions/computeFrustration.js +2 -67
  150. package/esm/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -1
  151. package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js +2 -279
  152. package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
  153. package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +2 -233
  154. package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
  155. package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js +2 -21
  156. package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
  157. package/esm/domain/rumEventsCollection/actions/listenActionEvents.js +2 -67
  158. package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
  159. package/esm/domain/rumEventsCollection/actions/trackClickActions.js +2 -263
  160. package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
  161. package/esm/domain/rumEventsCollection/error/errorCollection.js +2 -93
  162. package/esm/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
  163. package/esm/domain/rumEventsCollection/error/trackConsoleError.js +2 -12
  164. package/esm/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
  165. package/esm/domain/rumEventsCollection/error/trackReportError.js +2 -19
  166. package/esm/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
  167. package/esm/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js +2 -55
  168. package/esm/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
  169. package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js +2 -38
  170. package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
  171. package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -69
  172. package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
  173. package/esm/domain/rumEventsCollection/resource/resourceCollection.js +2 -294
  174. package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  175. package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js +2 -232
  176. package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
  177. package/esm/domain/rumEventsCollection/resource/resourceUtils.js +2 -218
  178. package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
  179. package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +2 -19
  180. package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
  181. package/esm/domain/rumEventsCollection/resource/webSocketCollection.js +2 -191
  182. package/esm/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -1
  183. package/esm/domain/rumEventsCollection/view/interactionCountPolyfill.js +2 -47
  184. package/esm/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -1
  185. package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js +2 -42
  186. package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
  187. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +2 -117
  188. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  189. package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +2 -20
  190. package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
  191. package/esm/domain/rumEventsCollection/view/trackFirstHidden.js +2 -49
  192. package/esm/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
  193. package/esm/domain/rumEventsCollection/view/trackFirstInput.js +2 -41
  194. package/esm/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
  195. package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +2 -44
  196. package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
  197. package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +2 -153
  198. package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
  199. package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +2 -54
  200. package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
  201. package/esm/domain/rumEventsCollection/view/trackLoadingTime.js +2 -50
  202. package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
  203. package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js +2 -73
  204. package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
  205. package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js +2 -84
  206. package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
  207. package/esm/domain/rumEventsCollection/view/trackSoftNavigationMetrics.js +2 -38
  208. package/esm/domain/rumEventsCollection/view/trackSoftNavigationMetrics.js.map +1 -1
  209. package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js +2 -15
  210. package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
  211. package/esm/domain/rumEventsCollection/view/trackViews.js +2 -418
  212. package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  213. package/esm/domain/rumEventsCollection/view/viewCollection.js +2 -127
  214. package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  215. package/esm/domain/rumSessionManager.js +2 -208
  216. package/esm/domain/rumSessionManager.js.map +1 -1
  217. package/esm/domain/tracing/ddtraceTracer.js +2 -40
  218. package/esm/domain/tracing/ddtraceTracer.js.map +1 -1
  219. package/esm/domain/tracing/getDocumentTraceId.js +2 -69
  220. package/esm/domain/tracing/getDocumentTraceId.js.map +1 -1
  221. package/esm/domain/tracing/jaegerTracer.js +2 -42
  222. package/esm/domain/tracing/jaegerTracer.js.map +1 -1
  223. package/esm/domain/tracing/sampler.js +2 -61
  224. package/esm/domain/tracing/sampler.js.map +1 -1
  225. package/esm/domain/tracing/skywalkingTracer.js +2 -90
  226. package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
  227. package/esm/domain/tracing/traceIdentifier.js +2 -57
  228. package/esm/domain/tracing/traceIdentifier.js.map +1 -1
  229. package/esm/domain/tracing/tracer.js +2 -128
  230. package/esm/domain/tracing/tracer.js.map +1 -1
  231. package/esm/domain/tracing/w3cTraceParentTracer.js +2 -69
  232. package/esm/domain/tracing/w3cTraceParentTracer.js.map +1 -1
  233. package/esm/domain/tracing/zipkinMultiTracer.js +2 -42
  234. package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -1
  235. package/esm/domain/tracing/zipkinSingleTracer.js +2 -41
  236. package/esm/domain/tracing/zipkinSingleTracer.js.map +1 -1
  237. package/esm/domain/trackEventCounts.js +2 -49
  238. package/esm/domain/trackEventCounts.js.map +1 -1
  239. package/esm/domain/usr/index.js +2 -38
  240. package/esm/domain/usr/index.js.map +1 -1
  241. package/esm/domain/visitorId/index.js +2 -406
  242. package/esm/domain/visitorId/index.js.map +1 -1
  243. package/esm/domain/waitPageActivityEnd.js +2 -142
  244. package/esm/domain/waitPageActivityEnd.js.map +1 -1
  245. package/esm/index.js +2 -4
  246. package/esm/index.js.map +1 -1
  247. package/esm/transport/startRumBatch.js +2 -74
  248. package/esm/transport/startRumBatch.js.map +1 -1
  249. package/esm/transport/startRumEventBridge.js +2 -9
  250. package/esm/transport/startRumEventBridge.js.map +1 -1
  251. package/esm/types/index.js +2 -1
  252. package/esm/types/index.js.map +1 -1
  253. package/esm/types/sessionReplayConstants.js +2 -46
  254. package/esm/types/sessionReplayConstants.js.map +1 -1
  255. package/package.json +5 -5
@@ -1,624 +1,2 @@
1
- import { SDKMap } from '@cloudcare/browser-core';
2
- import { instrumentSetter, instrumentMethod, assign, throttle, DOM_EVENT, addEventListeners, addEventListener, noop, LifeCycleEventType, RumEventType, ActionType, isNodeShadowHost, getScrollX, getScrollY } from '@cloudcare/browser-core';
3
- import { initViewportObservable } from '../../initViewportObservable';
4
- import { NodePrivacyLevel } from '../../../constants';
5
- import { RecordType, IncrementalSource, MediaInteractionType, MouseInteractionType } from '../../../types';
6
- import { getNodePrivacyLevel, shouldMaskNode } from './privacy';
7
- import { getElementInputValue, getSerializedNodeId, hasSerializedNode } from './serializationUtils';
8
- import { assembleIncrementalSnapshot, getPathToNestedCSSRule, isTouchEvent } from './utils';
9
- import { startMutationObserver } from './mutationObserver';
10
- import { getVisualViewport, convertMouseEventToLayoutCoordinates } from './viewports';
11
- var MOUSE_MOVE_OBSERVER_THRESHOLD = 50;
12
- var SCROLL_OBSERVER_THRESHOLD = 100;
13
- var VISUAL_VIEWPORT_OBSERVER_THRESHOLD = 200;
14
- var MAX_TRACKED_RADIO_GROUPS = 256;
15
- var MAX_INPUT_SETTER_PROTOTYPES = 36;
16
- var INPUT_TAG_NAMES = {
17
- INPUT: true,
18
- TEXTAREA: true,
19
- SELECT: true
20
- };
21
- var recordIds = new WeakMap();
22
- var nextId = 1;
23
- export function getRecordIdForEvent(event) {
24
- if (!recordIds.has(event)) {
25
- recordIds.set(event, nextId++);
26
- }
27
- return recordIds.get(event);
28
- }
29
- export function initObservers(o) {
30
- var cleanupTasks = [];
31
- var mutationHandler;
32
- var isNodeIgnoredForStateObserver = createNodeIgnorePredicate(o.shadowRootsController, o.isNodeIgnored);
33
- var isNodeIgnoredForStatelessObserver = createNodeIgnorePredicate(o.shadowRootsController, o.isNodeIgnoredForStatelessObserver || o.isNodeIgnored);
34
- try {
35
- mutationHandler = initMutationObserver(o.mutationCb, o.configuration, o.shadowRootsController, o.mutationPerfCb, o.mutationOverflowCb, o.mutationActivityCb, o.mutationNodeSerializationCb,
36
- // DOM mutation assembly and stateful observers use the queued-aware
37
- // predicate. Stateless interactions use the strict published-only
38
- // predicate below and never advance a pending serializer.
39
- o.isNodeIgnored && function (node) {
40
- return o.isNodeIgnored(node, true);
41
- }, o.isNodePublished, o.mutationResourceBudget);
42
- cleanupTasks.push(mutationHandler.stop);
43
- cleanupTasks.push(initMoveObserver(o.mousemoveCb, o.configuration, isNodeIgnoredForStatelessObserver));
44
- cleanupTasks.push(initMouseInteractionObserver(o.mouseInteractionCb, o.configuration, isNodeIgnoredForStatelessObserver));
45
- cleanupTasks.push(initScrollObserver(o.scrollCb, o.configuration, o.elementsScrollPositions, isNodeIgnoredForStateObserver));
46
- cleanupTasks.push(initViewportResizeObserver(o.viewportResizeCb, o.configuration));
47
- if (!o.inputObserver) {
48
- cleanupTasks.push(initInputObserver(o.inputCb, o.configuration, undefined, isNodeIgnoredForStateObserver));
49
- }
50
- cleanupTasks.push(initMediaInteractionObserver(o.mediaInteractionCb, o.configuration, isNodeIgnoredForStateObserver));
51
- cleanupTasks.push(initStyleSheetObserver(o.styleSheetCb, o.configuration, isNodeIgnoredForStateObserver));
52
- cleanupTasks.push(initFocusObserver(o.focusCb, o.configuration));
53
- cleanupTasks.push(initVisualViewportResizeObserver(o.visualViewportResizeCb, o.configuration));
54
- cleanupTasks.push(initFrustrationObserver(o.lifeCycle, o.frustrationCb, o.configuration, isNodeIgnoredForStatelessObserver));
55
- } catch (error) {
56
- try {
57
- runObserverCleanupTasks(cleanupTasks.slice().reverse());
58
- } catch (_) {}
59
- throw error;
60
- }
61
- return {
62
- flush: function flush() {
63
- return mutationHandler.flush();
64
- },
65
- refreshAndFlushPendingRootForNode: function refreshAndFlushPendingRootForNode(node) {
66
- if (mutationHandler.refreshAndFlushPendingRootForNode) {
67
- return mutationHandler.refreshAndFlushPendingRootForNode(node);
68
- }
69
- },
70
- reset: function reset() {
71
- if (mutationHandler.reset) {
72
- mutationHandler.reset();
73
- }
74
- },
75
- stop: function stop() {
76
- runObserverCleanupTasks(cleanupTasks);
77
- }
78
- };
79
- }
80
- function createNodeIgnorePredicate(shadowRootsController, customIsNodeIgnored) {
81
- if (typeof customIsNodeIgnored === 'function') {
82
- return function (node) {
83
- try {
84
- return customIsNodeIgnored(node);
85
- } catch (_) {
86
- return true;
87
- }
88
- };
89
- }
90
- if (!shadowRootsController || typeof shadowRootsController.isNodeInSkippedShadowRoot !== 'function') {
91
- return function () {
92
- return false;
93
- };
94
- }
95
- return function (node) {
96
- try {
97
- return shadowRootsController.isNodeInSkippedShadowRoot(node);
98
- } catch (_) {
99
- return true;
100
- }
101
- };
102
- }
103
- function neverIgnoreNode() {
104
- return false;
105
- }
106
- function runObserverCleanupTasks(tasks) {
107
- var firstError;
108
- tasks.forEach(function (task) {
109
- try {
110
- task();
111
- } catch (error) {
112
- if (!firstError) {
113
- firstError = error;
114
- }
115
- }
116
- });
117
- if (firstError) {
118
- throw firstError;
119
- }
120
- }
121
- export function initMutationObserver(cb, configuration, shadowRootsController, mutationPerfCb, mutationOverflowCb, mutationActivityCb, mutationNodeSerializationCb, isNodeIgnored, isNodePublished, mutationResourceBudget) {
122
- return startMutationObserver(cb, configuration, shadowRootsController, document, mutationPerfCb, mutationOverflowCb, mutationActivityCb, mutationNodeSerializationCb, isNodeIgnored, isNodePublished, undefined, mutationResourceBudget);
123
- }
124
- export function initMoveObserver(cb, configuration, isNodeIgnored) {
125
- isNodeIgnored = isNodeIgnored || neverIgnoreNode;
126
- var _updatePosition = throttle(function (event) {
127
- var target = getEventTarget(event);
128
- if (!isNodeIgnored(target) && hasSerializedNode(target)) {
129
- var coordinates = tryToComputeCoordinates(event);
130
- if (!coordinates) {
131
- return;
132
- }
133
- var position = {
134
- id: getSerializedNodeId(target),
135
- timeOffset: 0,
136
- x: coordinates.x,
137
- y: coordinates.y
138
- };
139
- cb([position], isTouchEvent(event) ? IncrementalSource.TouchMove : IncrementalSource.MouseMove);
140
- }
141
- }, MOUSE_MOVE_OBSERVER_THRESHOLD, {
142
- trailing: false
143
- });
144
- var cancelThrottle = _updatePosition.cancel;
145
- var updatePosition = _updatePosition.throttled;
146
- var _listener = addEventListeners(document, [DOM_EVENT.MOUSE_MOVE, DOM_EVENT.TOUCH_MOVE], updatePosition, {
147
- capture: true,
148
- passive: true
149
- });
150
- var removeListener = _listener.stop;
151
- return function () {
152
- removeListener();
153
- cancelThrottle();
154
- };
155
- }
156
- var eventTypeToMouseInteraction = {};
157
- // Listen for pointerup DOM events instead of mouseup for MouseInteraction/MouseUp records. This
158
- // allows to reference such records from Frustration records.
159
- //
160
- // In the context of supporting Mobile Session Replay, we introduced `PointerInteraction` records
161
- // used by the Mobile SDKs in place of `MouseInteraction`. In the future, we should replace
162
- // `MouseInteraction` by `PointerInteraction` in the Browser SDK so we have an uniform way to
163
- // convey such interaction. This would cleanly solve the issue since we would have
164
- // `PointerInteraction/Up` records that we could reference from `Frustration` records.
165
- eventTypeToMouseInteraction[DOM_EVENT.POINTER_UP] = MouseInteractionType.MouseUp;
166
- eventTypeToMouseInteraction[DOM_EVENT.MOUSE_DOWN] = MouseInteractionType.MouseDown;
167
- eventTypeToMouseInteraction[DOM_EVENT.CLICK] = MouseInteractionType.Click;
168
- eventTypeToMouseInteraction[DOM_EVENT.CONTEXT_MENU] = MouseInteractionType.ContextMenu;
169
- eventTypeToMouseInteraction[DOM_EVENT.DBL_CLICK] = MouseInteractionType.DblClick;
170
- eventTypeToMouseInteraction[DOM_EVENT.FOCUS] = MouseInteractionType.Focus;
171
- eventTypeToMouseInteraction[DOM_EVENT.BLUR] = MouseInteractionType.Blur;
172
- eventTypeToMouseInteraction[DOM_EVENT.TOUCH_START] = MouseInteractionType.TouchStart;
173
- eventTypeToMouseInteraction[DOM_EVENT.TOUCH_END] = MouseInteractionType.TouchEnd;
174
- export function initMouseInteractionObserver(cb, configuration, isNodeIgnored) {
175
- isNodeIgnored = isNodeIgnored || neverIgnoreNode;
176
- var handler = function handler(event) {
177
- var target = getEventTarget(event);
178
- if (isNodeIgnored(target) || getNodePrivacyLevel(target, configuration.defaultPrivacyLevel) === NodePrivacyLevel.HIDDEN || !hasSerializedNode(target)) {
179
- return;
180
- }
181
- var id = getSerializedNodeId(target);
182
- var type = eventTypeToMouseInteraction[event.type];
183
- var interaction;
184
- if (type !== MouseInteractionType.Blur && type !== MouseInteractionType.Focus) {
185
- var coordinates = tryToComputeCoordinates(event);
186
- if (!coordinates) {
187
- return;
188
- }
189
- interaction = {
190
- id: id,
191
- type: type,
192
- x: coordinates.x,
193
- y: coordinates.y
194
- };
195
- } else {
196
- interaction = {
197
- id: id,
198
- type: type
199
- };
200
- }
201
- var record = assign({
202
- id: getRecordIdForEvent(event)
203
- }, assembleIncrementalSnapshot(IncrementalSource.MouseInteraction, interaction));
204
- cb(record);
205
- };
206
- return addEventListeners(document, Object.keys(eventTypeToMouseInteraction), handler, {
207
- capture: true,
208
- passive: true
209
- }).stop;
210
- }
211
- function tryToComputeCoordinates(event) {
212
- var _event = isTouchEvent(event) ? event.changedTouches[0] : event;
213
- var x = _event.clientX;
214
- var y = _event.clientY;
215
- if (window.visualViewport) {
216
- var _convertMouseEventToLayoutCoordinates = convertMouseEventToLayoutCoordinates(x, y);
217
- x = _convertMouseEventToLayoutCoordinates.visualViewportX;
218
- y = _convertMouseEventToLayoutCoordinates.visualViewportY;
219
- }
220
- if (!Number.isFinite(x) || !Number.isFinite(y)) {
221
- return undefined;
222
- }
223
- return {
224
- x: x,
225
- y: y
226
- };
227
- }
228
- function initScrollObserver(cb, configuration, elementsScrollPositions, isNodeIgnored) {
229
- isNodeIgnored = isNodeIgnored || neverIgnoreNode;
230
- var _updatePosition = throttle(function (event) {
231
- var target = getEventTarget(event);
232
- if (!target) {
233
- return;
234
- }
235
- var ignored = isNodeIgnored(target);
236
- if (getNodePrivacyLevel(target, configuration.defaultPrivacyLevel) === NodePrivacyLevel.HIDDEN || !hasSerializedNode(target)) {
237
- return;
238
- }
239
- var id = getSerializedNodeId(target);
240
- var scrollPositions = target === document ? {
241
- scrollTop: getScrollY(),
242
- scrollLeft: getScrollX()
243
- } : {
244
- scrollTop: Math.round(target.scrollTop),
245
- scrollLeft: Math.round(target.scrollLeft)
246
- };
247
- elementsScrollPositions.set(target, scrollPositions);
248
- if (ignored) {
249
- // Keep the live scroll baseline current while a time-sliced full
250
- // snapshot temporarily gates incremental records.
251
- return;
252
- }
253
- cb({
254
- id: id,
255
- x: scrollPositions.scrollLeft,
256
- y: scrollPositions.scrollTop
257
- });
258
- }, SCROLL_OBSERVER_THRESHOLD);
259
- var cancelThrottle = _updatePosition.cancel;
260
- var updatePosition = _updatePosition.throttled;
261
- var _listener = addEventListener(document, DOM_EVENT.SCROLL, updatePosition, {
262
- capture: true,
263
- passive: true
264
- });
265
- var removeListener = _listener.stop;
266
- return function () {
267
- removeListener();
268
- cancelThrottle();
269
- };
270
- }
271
- function initViewportResizeObserver(cb, configuration) {
272
- return initViewportObservable().subscribe(cb).unsubscribe;
273
- }
274
- export function initInputObserver(cb, configuration, target, isNodeIgnored) {
275
- if (target === undefined) {
276
- target = document;
277
- }
278
- isNodeIgnored = isNodeIgnored || neverIgnoreNode;
279
- var lastInputStateMap = new WeakMap();
280
- var radioGroupStateByRoot = new WeakMap();
281
- var isShadowRoot = target !== document;
282
- var setterInstrumentationStoppers = [];
283
- var instrumentedInputPrototypes = new WeakSet();
284
- var instrumentedInputPrototypeCount = 0;
285
- var _addEventListeners = addEventListeners(target,
286
- // The 'input' event bubbles across shadow roots, so we don't have to listen for it on shadow
287
- // roots since it will be handled by the event listener that we did add to the document. Only
288
- // the 'change' event is blocked and needs to be handled on shadow roots.
289
- isShadowRoot ? [DOM_EVENT.CHANGE] : [DOM_EVENT.INPUT, DOM_EVENT.CHANGE], function (event) {
290
- var target = getEventTarget(event);
291
- if (isInputElement(target)) {
292
- onElementChange(target);
293
- }
294
- }, {
295
- capture: true,
296
- passive: true
297
- });
298
- var stopEventListeners = _addEventListeners.stop;
299
- if (!isShadowRoot) {
300
- observeInputNode(document.createElement('input'));
301
- observeInputNode(document.createElement('textarea'));
302
- observeInputNode(document.createElement('select'));
303
- }
304
- var stop = function stop() {
305
- setterInstrumentationStoppers.forEach(function (stopper) {
306
- stopper();
307
- });
308
- stopEventListeners();
309
- };
310
- stop.observeInputNode = isShadowRoot ? noop : observeInputNode;
311
- return stop;
312
- function observeInputNode(node) {
313
- if (!isInputElement(node)) {
314
- return;
315
- }
316
- var prototype;
317
- try {
318
- prototype = Object.getPrototypeOf(node);
319
- } catch (_) {
320
- return;
321
- }
322
- if (!prototype || instrumentedInputPrototypes.has(prototype) || instrumentedInputPrototypeCount >= MAX_INPUT_SETTER_PROTOTYPES) {
323
- return;
324
- }
325
- instrumentedInputPrototypes.add(prototype);
326
- instrumentedInputPrototypeCount += 1;
327
- var properties = node.tagName === 'TEXTAREA' ? ['value'] : ['value', node.tagName === 'INPUT' ? 'checked' : 'selectedIndex'];
328
- properties.forEach(function (property) {
329
- setterInstrumentationStoppers.push(instrumentSetter(prototype, property, onElementChange).stop);
330
- });
331
- }
332
- function onElementChange(target) {
333
- if (isNodeIgnored(target)) {
334
- return;
335
- }
336
- var nodePrivacyLevel = getNodePrivacyLevel(target, configuration.defaultPrivacyLevel);
337
- if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
338
- return;
339
- }
340
- var type = target.type;
341
- var inputState;
342
- if (type === 'radio' || type === 'checkbox') {
343
- if (shouldMaskNode(configuration, target, nodePrivacyLevel)) {
344
- return;
345
- }
346
- inputState = {
347
- isChecked: target.checked
348
- };
349
- } else {
350
- var value = getElementInputValue(configuration, target, nodePrivacyLevel);
351
- if (value === undefined) {
352
- return;
353
- }
354
- inputState = {
355
- text: value
356
- };
357
- }
358
-
359
- // Can be multiple changes on the same node within the same batched mutation observation.
360
- var shouldTrackRadioGroup = cbWithDedup(target, inputState);
361
-
362
- // If a radio was checked, other radios with the same name attribute will be unchecked.
363
- // Keep only the last observed checked radio per native group. This avoids
364
- // scanning an arbitrarily large document and does not manufacture false
365
- // records for every unchecked peer when a group is first observed.
366
- if (type === 'radio' && target.name && shouldTrackRadioGroup) {
367
- synchronizeRadioGroup(target);
368
- }
369
- }
370
- function synchronizeRadioGroup(target) {
371
- var root = getRadioRoot(target);
372
- var groupMap = getRadioGroupMap(root, target.form);
373
- var name = target.name;
374
- var previouslyCheckedRadio = getTrackedRadio(groupMap, name, target, root);
375
- if (!target.checked) {
376
- if (previouslyCheckedRadio === target) {
377
- groupMap["delete"](name);
378
- }
379
- return;
380
- }
381
- trackRadio(groupMap, name, target);
382
- if (previouslyCheckedRadio && previouslyCheckedRadio !== target && isInSameRadioGroup(previouslyCheckedRadio, target, root) && !previouslyCheckedRadio.checked) {
383
- cbWithDedup(previouslyCheckedRadio, {
384
- isChecked: false
385
- });
386
- }
387
- }
388
- function getTrackedRadio(groupMap, name, target, root) {
389
- var reference = groupMap.get(name);
390
- if (!reference) {
391
- return undefined;
392
- }
393
- var radio = reference.weakRef ? reference.weakRef.deref() : reference.radio;
394
- if (!radio || !radio.isConnected || !isInSameRadioGroup(radio, target, root)) {
395
- groupMap["delete"](name);
396
- return undefined;
397
- }
398
- return radio;
399
- }
400
- function trackRadio(groupMap, name, radio) {
401
- if (groupMap.has(name)) {
402
- groupMap["delete"](name);
403
- }
404
- groupMap.set(name, typeof WeakRef === 'function' ? {
405
- weakRef: new WeakRef(radio)
406
- } : {
407
- radio: radio
408
- });
409
- if (groupMap.size > MAX_TRACKED_RADIO_GROUPS) {
410
- groupMap["delete"](groupMap.keys().next().value);
411
- }
412
- }
413
- function getRadioGroupMap(root, form) {
414
- var rootState = radioGroupStateByRoot.get(root);
415
- if (!rootState) {
416
- rootState = {
417
- groupsWithoutForm: new SDKMap(),
418
- groupsByForm: new WeakMap()
419
- };
420
- radioGroupStateByRoot.set(root, rootState);
421
- }
422
- if (!form) {
423
- return rootState.groupsWithoutForm;
424
- }
425
- var formGroups = rootState.groupsByForm.get(form);
426
- if (!formGroups) {
427
- formGroups = new SDKMap();
428
- rootState.groupsByForm.set(form, formGroups);
429
- }
430
- return formGroups;
431
- }
432
- function getRadioRoot(input) {
433
- if (typeof input.getRootNode === 'function') {
434
- var root = input.getRootNode();
435
- if (root) {
436
- return root;
437
- }
438
- }
439
- return input.ownerDocument || document;
440
- }
441
- function isInSameRadioGroup(candidate, target, root) {
442
- return candidate.type === 'radio' && candidate.name === target.name && candidate.form === target.form && getRadioRoot(candidate) === root;
443
- }
444
-
445
- /**
446
- * There can be multiple changes on the same node within the same batched mutation observation.
447
- */
448
- function cbWithDedup(target, inputState) {
449
- if (isNodeIgnored(target) || !hasSerializedNode(target)) {
450
- return false;
451
- }
452
- var lastInputState = lastInputStateMap.get(target);
453
- if (!lastInputState || lastInputState.text !== inputState.text || lastInputState.isChecked !== inputState.isChecked) {
454
- lastInputStateMap.set(target, inputState);
455
- cb(assign({
456
- id: getSerializedNodeId(target)
457
- }, inputState));
458
- }
459
- return true;
460
- }
461
- }
462
- function isInputElement(target) {
463
- return !!target && INPUT_TAG_NAMES[target.tagName];
464
- }
465
- export function initStyleSheetObserver(cb, configuration, isNodeIgnored) {
466
- isNodeIgnored = isNodeIgnored || neverIgnoreNode;
467
- function checkStyleSheetAndCallback(styleSheet, callback) {
468
- if (styleSheet && !isNodeIgnored(styleSheet.ownerNode) && hasSerializedNode(styleSheet.ownerNode)) {
469
- callback(getSerializedNodeId(styleSheet.ownerNode));
470
- }
471
- }
472
- var instrumentationStoppers = [instrumentMethod(CSSStyleSheet.prototype, 'insertRule', function (params) {
473
- var styleSheet = params.target;
474
- var parameters = params.parameters;
475
- var rule = parameters[0];
476
- var index = parameters[1];
477
- checkStyleSheetAndCallback(styleSheet, function (id) {
478
- return cb({
479
- id: id,
480
- adds: [{
481
- rule: rule,
482
- index: index
483
- }]
484
- });
485
- });
486
- }), instrumentMethod(CSSStyleSheet.prototype, 'deleteRule', function (params) {
487
- var styleSheet = params.target;
488
- var parameters = params.parameters;
489
- var index = parameters[0];
490
- checkStyleSheetAndCallback(styleSheet, function (id) {
491
- return cb({
492
- id: id,
493
- removes: [{
494
- index: index
495
- }]
496
- });
497
- });
498
- })];
499
- if (typeof CSSGroupingRule !== 'undefined') {
500
- instrumentGroupingCSSRuleClass(CSSGroupingRule);
501
- } else {
502
- instrumentGroupingCSSRuleClass(CSSMediaRule);
503
- instrumentGroupingCSSRuleClass(CSSSupportsRule);
504
- }
505
- function instrumentGroupingCSSRuleClass(cls) {
506
- instrumentationStoppers.push(instrumentMethod(cls.prototype, 'insertRule', function (params) {
507
- var styleSheet = params.target;
508
- var parameters = params.parameters;
509
- var rule = parameters[0];
510
- var index = parameters[1];
511
- checkStyleSheetAndCallback(styleSheet.parentStyleSheet, function (id) {
512
- var path = getPathToNestedCSSRule(styleSheet);
513
- if (path) {
514
- path.push(index || 0);
515
- cb({
516
- id: id,
517
- adds: [{
518
- rule: rule,
519
- index: path
520
- }]
521
- });
522
- }
523
- });
524
- }), instrumentMethod(cls.prototype, 'deleteRule', function (params) {
525
- var styleSheet = params.target;
526
- var parameters = params.parameters;
527
- var index = parameters[0];
528
- checkStyleSheetAndCallback(styleSheet.parentStyleSheet, function (id) {
529
- var path = getPathToNestedCSSRule(styleSheet);
530
- if (path) {
531
- path.push(index);
532
- cb({
533
- id: id,
534
- removes: [{
535
- index: path
536
- }]
537
- });
538
- }
539
- });
540
- }));
541
- }
542
- return function () {
543
- instrumentationStoppers.forEach(function (stopper) {
544
- stopper.stop();
545
- });
546
- };
547
- }
548
- function initMediaInteractionObserver(mediaInteractionCb, configuration, isNodeIgnored) {
549
- isNodeIgnored = isNodeIgnored || neverIgnoreNode;
550
- var handler = function handler(event) {
551
- var target = getEventTarget(event);
552
- if (!target || isNodeIgnored(target) || getNodePrivacyLevel(target, configuration.defaultPrivacyLevel) === NodePrivacyLevel.HIDDEN || !hasSerializedNode(target)) {
553
- return;
554
- }
555
- mediaInteractionCb({
556
- id: getSerializedNodeId(target),
557
- type: event.type === DOM_EVENT.PLAY ? MediaInteractionType.Play : MediaInteractionType.Pause
558
- });
559
- };
560
- return addEventListeners(document, [DOM_EVENT.PLAY, DOM_EVENT.PAUSE], handler, {
561
- capture: true,
562
- passive: true
563
- }).stop;
564
- }
565
- function initFocusObserver(focusCb, configuration) {
566
- return addEventListeners(window, [DOM_EVENT.FOCUS, DOM_EVENT.BLUR], function () {
567
- focusCb({
568
- has_focus: document.hasFocus()
569
- });
570
- }).stop;
571
- }
572
- function initVisualViewportResizeObserver(cb, configuration) {
573
- if (!window.visualViewport) {
574
- return noop;
575
- }
576
- var _updateDimension = throttle(function () {
577
- cb(getVisualViewport());
578
- }, VISUAL_VIEWPORT_OBSERVER_THRESHOLD, {
579
- trailing: false
580
- });
581
- var removeListener = addEventListeners(window.visualViewport, [DOM_EVENT.RESIZE, DOM_EVENT.SCROLL], _updateDimension.throttled, {
582
- capture: true,
583
- passive: true
584
- }).stop;
585
- var cancelThrottle = _updateDimension.cancel;
586
- return function stop() {
587
- removeListener();
588
- cancelThrottle();
589
- };
590
- }
591
- export function initFrustrationObserver(lifeCycle, frustrationCb, configuration, isNodeIgnored) {
592
- isNodeIgnored = isNodeIgnored || neverIgnoreNode;
593
- return lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (data) {
594
- if (data.rawRumEvent.type === RumEventType.ACTION && data.rawRumEvent.action.type === ActionType.CLICK && data.rawRumEvent.action.frustration && data.rawRumEvent.action.frustration.type && data.rawRumEvent.action.frustration.type.length && 'events' in data.domainContext && data.domainContext.events && data.domainContext.events.length) {
595
- var replayEvents = data.domainContext.events.filter(function (event) {
596
- try {
597
- return !isNodeIgnored(getEventTarget(event));
598
- } catch (_) {
599
- return false;
600
- }
601
- });
602
- if (!replayEvents.length) {
603
- return;
604
- }
605
- frustrationCb({
606
- timestamp: data.rawRumEvent.date,
607
- type: RecordType.FrustrationRecord,
608
- data: {
609
- frustrationTypes: data.rawRumEvent.action.frustration.type,
610
- recordIds: replayEvents.map(function (e) {
611
- return getRecordIdForEvent(e);
612
- })
613
- }
614
- });
615
- }
616
- }).unsubscribe;
617
- }
618
- function getEventTarget(event) {
619
- if (event.composed === true && isNodeShadowHost(event.target)) {
620
- return event.composedPath()[0];
621
- }
622
- return event.target;
623
- }
624
- //# sourceMappingURL=observers.js.map
1
+ import{SDKMap}from"@cloudcare/browser-core";import{instrumentSetter,instrumentMethod,assign,throttle,DOM_EVENT,addEventListeners,addEventListener,noop,LifeCycleEventType,RumEventType,ActionType,isNodeShadowHost,getScrollX,getScrollY}from"@cloudcare/browser-core";import{initViewportObservable}from"../../initViewportObservable";import{NodePrivacyLevel}from"../../../constants";import{RecordType,IncrementalSource,MediaInteractionType,MouseInteractionType}from"../../../types";import{getNodePrivacyLevel,shouldMaskNode}from"./privacy";import{getElementInputValue,getSerializedNodeId,hasSerializedNode}from"./serializationUtils";import{assembleIncrementalSnapshot,getPathToNestedCSSRule,isTouchEvent}from"./utils";import{startMutationObserver}from"./mutationObserver";import{getVisualViewport,convertMouseEventToLayoutCoordinates}from"./viewports";var INPUT_TAG_NAMES={INPUT:!0,TEXTAREA:!0,SELECT:!0},recordIds=new WeakMap,nextId=1;export function getRecordIdForEvent(event){return recordIds.has(event)||recordIds.set(event,nextId++),recordIds.get(event)}export function initObservers(o){var mutationHandler,cleanupTasks=[],isNodeIgnoredForStateObserver=createNodeIgnorePredicate(o.shadowRootsController,o.isNodeIgnored),isNodeIgnoredForStatelessObserver=createNodeIgnorePredicate(o.shadowRootsController,o.isNodeIgnoredForStatelessObserver||o.isNodeIgnored);try{mutationHandler=initMutationObserver(o.mutationCb,o.configuration,o.shadowRootsController,o.mutationPerfCb,o.mutationOverflowCb,o.mutationActivityCb,o.mutationNodeSerializationCb,o.isNodeIgnored&&function(node){return o.isNodeIgnored(node,!0)},o.isNodePublished,o.mutationResourceBudget),cleanupTasks.push(mutationHandler.stop),cleanupTasks.push(initMoveObserver(o.mousemoveCb,o.configuration,isNodeIgnoredForStatelessObserver)),cleanupTasks.push(initMouseInteractionObserver(o.mouseInteractionCb,o.configuration,isNodeIgnoredForStatelessObserver)),cleanupTasks.push(function initScrollObserver(cb,configuration,elementsScrollPositions,isNodeIgnored){isNodeIgnored=isNodeIgnored||neverIgnoreNode;var _updatePosition=throttle((function(event){var target=getEventTarget(event);if(target){var ignored=isNodeIgnored(target);if(getNodePrivacyLevel(target,configuration.defaultPrivacyLevel)!==NodePrivacyLevel.HIDDEN&&hasSerializedNode(target)){var id=getSerializedNodeId(target),scrollPositions=target===document?{scrollTop:getScrollY(),scrollLeft:getScrollX()}:{scrollTop:Math.round(target.scrollTop),scrollLeft:Math.round(target.scrollLeft)};elementsScrollPositions.set(target,scrollPositions),ignored||cb({id:id,x:scrollPositions.scrollLeft,y:scrollPositions.scrollTop})}}}),100),cancelThrottle=_updatePosition.cancel,updatePosition=_updatePosition.throttled,removeListener=addEventListener(document,DOM_EVENT.SCROLL,updatePosition,{capture:!0,passive:!0}).stop;return function(){removeListener(),cancelThrottle()}}(o.scrollCb,o.configuration,o.elementsScrollPositions,isNodeIgnoredForStateObserver)),cleanupTasks.push(function initViewportResizeObserver(cb,configuration){return initViewportObservable().subscribe(cb).unsubscribe}(o.viewportResizeCb,o.configuration)),o.inputObserver||cleanupTasks.push(initInputObserver(o.inputCb,o.configuration,void 0,isNodeIgnoredForStateObserver)),cleanupTasks.push(function initMediaInteractionObserver(mediaInteractionCb,configuration,isNodeIgnored){isNodeIgnored=isNodeIgnored||neverIgnoreNode;var handler=function handler(event){var target=getEventTarget(event);target&&!isNodeIgnored(target)&&getNodePrivacyLevel(target,configuration.defaultPrivacyLevel)!==NodePrivacyLevel.HIDDEN&&hasSerializedNode(target)&&mediaInteractionCb({id:getSerializedNodeId(target),type:event.type===DOM_EVENT.PLAY?MediaInteractionType.Play:MediaInteractionType.Pause})};return addEventListeners(document,[DOM_EVENT.PLAY,DOM_EVENT.PAUSE],handler,{capture:!0,passive:!0}).stop}(o.mediaInteractionCb,o.configuration,isNodeIgnoredForStateObserver)),cleanupTasks.push(initStyleSheetObserver(o.styleSheetCb,o.configuration,isNodeIgnoredForStateObserver)),cleanupTasks.push(function initFocusObserver(focusCb,configuration){return addEventListeners(window,[DOM_EVENT.FOCUS,DOM_EVENT.BLUR],(function(){focusCb({has_focus:document.hasFocus()})})).stop}(o.focusCb,o.configuration)),cleanupTasks.push(function initVisualViewportResizeObserver(cb,configuration){if(!window.visualViewport)return noop;var _updateDimension=throttle((function(){cb(getVisualViewport())}),200,{trailing:!1}),removeListener=addEventListeners(window.visualViewport,[DOM_EVENT.RESIZE,DOM_EVENT.SCROLL],_updateDimension.throttled,{capture:!0,passive:!0}).stop,cancelThrottle=_updateDimension.cancel;return function stop(){removeListener(),cancelThrottle()}}(o.visualViewportResizeCb,o.configuration)),cleanupTasks.push(initFrustrationObserver(o.lifeCycle,o.frustrationCb,o.configuration,isNodeIgnoredForStatelessObserver))}catch(error){try{runObserverCleanupTasks(cleanupTasks.slice().reverse())}catch(_){}throw error}return{flush:function flush(){return mutationHandler.flush()},refreshAndFlushPendingRootForNode:function refreshAndFlushPendingRootForNode(node){if(mutationHandler.refreshAndFlushPendingRootForNode)return mutationHandler.refreshAndFlushPendingRootForNode(node)},reset:function reset(){mutationHandler.reset&&mutationHandler.reset()},stop:function stop(){runObserverCleanupTasks(cleanupTasks)}}}function createNodeIgnorePredicate(shadowRootsController,customIsNodeIgnored){return"function"==typeof customIsNodeIgnored?function(node){try{return customIsNodeIgnored(node)}catch(_){return!0}}:shadowRootsController&&"function"==typeof shadowRootsController.isNodeInSkippedShadowRoot?function(node){try{return shadowRootsController.isNodeInSkippedShadowRoot(node)}catch(_){return!0}}:function(){return!1}}function neverIgnoreNode(){return!1}function runObserverCleanupTasks(tasks){var firstError;if(tasks.forEach((function(task){try{task()}catch(error){firstError||(firstError=error)}})),firstError)throw firstError}export function initMutationObserver(cb,configuration,shadowRootsController,mutationPerfCb,mutationOverflowCb,mutationActivityCb,mutationNodeSerializationCb,isNodeIgnored,isNodePublished,mutationResourceBudget){return startMutationObserver(cb,configuration,shadowRootsController,document,mutationPerfCb,mutationOverflowCb,mutationActivityCb,mutationNodeSerializationCb,isNodeIgnored,isNodePublished,void 0,mutationResourceBudget)}export function initMoveObserver(cb,configuration,isNodeIgnored){isNodeIgnored=isNodeIgnored||neverIgnoreNode;var _updatePosition=throttle((function(event){var target=getEventTarget(event);if(!isNodeIgnored(target)&&hasSerializedNode(target)){var coordinates=tryToComputeCoordinates(event);if(!coordinates)return;var position={id:getSerializedNodeId(target),timeOffset:0,x:coordinates.x,y:coordinates.y};cb([position],isTouchEvent(event)?IncrementalSource.TouchMove:IncrementalSource.MouseMove)}}),50,{trailing:!1}),cancelThrottle=_updatePosition.cancel,updatePosition=_updatePosition.throttled,removeListener=addEventListeners(document,[DOM_EVENT.MOUSE_MOVE,DOM_EVENT.TOUCH_MOVE],updatePosition,{capture:!0,passive:!0}).stop;return function(){removeListener(),cancelThrottle()}}var eventTypeToMouseInteraction={};eventTypeToMouseInteraction[DOM_EVENT.POINTER_UP]=MouseInteractionType.MouseUp,eventTypeToMouseInteraction[DOM_EVENT.MOUSE_DOWN]=MouseInteractionType.MouseDown,eventTypeToMouseInteraction[DOM_EVENT.CLICK]=MouseInteractionType.Click,eventTypeToMouseInteraction[DOM_EVENT.CONTEXT_MENU]=MouseInteractionType.ContextMenu,eventTypeToMouseInteraction[DOM_EVENT.DBL_CLICK]=MouseInteractionType.DblClick,eventTypeToMouseInteraction[DOM_EVENT.FOCUS]=MouseInteractionType.Focus,eventTypeToMouseInteraction[DOM_EVENT.BLUR]=MouseInteractionType.Blur,eventTypeToMouseInteraction[DOM_EVENT.TOUCH_START]=MouseInteractionType.TouchStart,eventTypeToMouseInteraction[DOM_EVENT.TOUCH_END]=MouseInteractionType.TouchEnd;export function initMouseInteractionObserver(cb,configuration,isNodeIgnored){isNodeIgnored=isNodeIgnored||neverIgnoreNode;return addEventListeners(document,Object.keys(eventTypeToMouseInteraction),(function handler(event){var target=getEventTarget(event);if(!isNodeIgnored(target)&&getNodePrivacyLevel(target,configuration.defaultPrivacyLevel)!==NodePrivacyLevel.HIDDEN&&hasSerializedNode(target)){var interaction,id=getSerializedNodeId(target),type=eventTypeToMouseInteraction[event.type];if(type!==MouseInteractionType.Blur&&type!==MouseInteractionType.Focus){var coordinates=tryToComputeCoordinates(event);if(!coordinates)return;interaction={id:id,type:type,x:coordinates.x,y:coordinates.y}}else interaction={id:id,type:type};var record=assign({id:getRecordIdForEvent(event)},assembleIncrementalSnapshot(IncrementalSource.MouseInteraction,interaction));cb(record)}}),{capture:!0,passive:!0}).stop}function tryToComputeCoordinates(event){var _event=isTouchEvent(event)?event.changedTouches[0]:event,x=_event.clientX,y=_event.clientY;if(window.visualViewport){var _convertMouseEventToLayoutCoordinates=convertMouseEventToLayoutCoordinates(x,y);x=_convertMouseEventToLayoutCoordinates.visualViewportX,y=_convertMouseEventToLayoutCoordinates.visualViewportY}if(Number.isFinite(x)&&Number.isFinite(y))return{x:x,y:y}}export function initInputObserver(cb,configuration,target,isNodeIgnored){void 0===target&&(target=document),isNodeIgnored=isNodeIgnored||neverIgnoreNode;var lastInputStateMap=new WeakMap,radioGroupStateByRoot=new WeakMap,isShadowRoot=target!==document,setterInstrumentationStoppers=[],instrumentedInputPrototypes=new WeakSet,instrumentedInputPrototypeCount=0,_addEventListeners=addEventListeners(target,isShadowRoot?[DOM_EVENT.CHANGE]:[DOM_EVENT.INPUT,DOM_EVENT.CHANGE],(function(event){var target=getEventTarget(event);isInputElement(target)&&onElementChange(target)}),{capture:!0,passive:!0}),stopEventListeners=_addEventListeners.stop;isShadowRoot||(observeInputNode(document.createElement("input")),observeInputNode(document.createElement("textarea")),observeInputNode(document.createElement("select")));var stop=function stop(){setterInstrumentationStoppers.forEach((function(stopper){stopper()})),stopEventListeners()};return stop.observeInputNode=isShadowRoot?noop:observeInputNode,stop;function observeInputNode(node){if(isInputElement(node)){var prototype;try{prototype=Object.getPrototypeOf(node)}catch(_){return}if(!(!prototype||instrumentedInputPrototypes.has(prototype)||instrumentedInputPrototypeCount>=36))instrumentedInputPrototypes.add(prototype),instrumentedInputPrototypeCount+=1,("TEXTAREA"===node.tagName?["value"]:["value","INPUT"===node.tagName?"checked":"selectedIndex"]).forEach((function(property){setterInstrumentationStoppers.push(instrumentSetter(prototype,property,onElementChange).stop)}))}}function onElementChange(target){if(!isNodeIgnored(target)){var nodePrivacyLevel=getNodePrivacyLevel(target,configuration.defaultPrivacyLevel);if(nodePrivacyLevel!==NodePrivacyLevel.HIDDEN){var inputState,type=target.type;if("radio"===type||"checkbox"===type){if(shouldMaskNode(configuration,target,nodePrivacyLevel))return;inputState={isChecked:target.checked}}else{var value=getElementInputValue(configuration,target,nodePrivacyLevel);if(void 0===value)return;inputState={text:value}}var shouldTrackRadioGroup=cbWithDedup(target,inputState);"radio"===type&&target.name&&shouldTrackRadioGroup&&function synchronizeRadioGroup(target){var root=getRadioRoot(target),groupMap=function getRadioGroupMap(root,form){var rootState=radioGroupStateByRoot.get(root);rootState||(rootState={groupsWithoutForm:new SDKMap,groupsByForm:new WeakMap},radioGroupStateByRoot.set(root,rootState));if(!form)return rootState.groupsWithoutForm;var formGroups=rootState.groupsByForm.get(form);formGroups||(formGroups=new SDKMap,rootState.groupsByForm.set(form,formGroups));return formGroups}(root,target.form),name=target.name,previouslyCheckedRadio=function getTrackedRadio(groupMap,name,target,root){var reference=groupMap.get(name);if(!reference)return;var radio=reference.weakRef?reference.weakRef.deref():reference.radio;if(!radio||!radio.isConnected||!isInSameRadioGroup(radio,target,root))return void groupMap.delete(name);return radio}(groupMap,name,target,root);if(!target.checked)return void(previouslyCheckedRadio===target&&groupMap.delete(name));(function trackRadio(groupMap,name,radio){groupMap.has(name)&&groupMap.delete(name);groupMap.set(name,"function"==typeof WeakRef?{weakRef:new WeakRef(radio)}:{radio:radio}),groupMap.size>256&&groupMap.delete(groupMap.keys().next().value)})(groupMap,name,target),previouslyCheckedRadio&&previouslyCheckedRadio!==target&&isInSameRadioGroup(previouslyCheckedRadio,target,root)&&!previouslyCheckedRadio.checked&&cbWithDedup(previouslyCheckedRadio,{isChecked:!1})}(target)}}}function getRadioRoot(input){if("function"==typeof input.getRootNode){var root=input.getRootNode();if(root)return root}return input.ownerDocument||document}function isInSameRadioGroup(candidate,target,root){return"radio"===candidate.type&&candidate.name===target.name&&candidate.form===target.form&&getRadioRoot(candidate)===root}function cbWithDedup(target,inputState){if(isNodeIgnored(target)||!hasSerializedNode(target))return!1;var lastInputState=lastInputStateMap.get(target);return lastInputState&&lastInputState.text===inputState.text&&lastInputState.isChecked===inputState.isChecked||(lastInputStateMap.set(target,inputState),cb(assign({id:getSerializedNodeId(target)},inputState))),!0}}function isInputElement(target){return!!target&&INPUT_TAG_NAMES[target.tagName]}export function initStyleSheetObserver(cb,configuration,isNodeIgnored){function checkStyleSheetAndCallback(styleSheet,callback){styleSheet&&!isNodeIgnored(styleSheet.ownerNode)&&hasSerializedNode(styleSheet.ownerNode)&&callback(getSerializedNodeId(styleSheet.ownerNode))}isNodeIgnored=isNodeIgnored||neverIgnoreNode;var instrumentationStoppers=[instrumentMethod(CSSStyleSheet.prototype,"insertRule",(function(params){var styleSheet=params.target,parameters=params.parameters,rule=parameters[0],index=parameters[1];checkStyleSheetAndCallback(styleSheet,(function(id){return cb({id:id,adds:[{rule:rule,index:index}]})}))})),instrumentMethod(CSSStyleSheet.prototype,"deleteRule",(function(params){var styleSheet=params.target,index=params.parameters[0];checkStyleSheetAndCallback(styleSheet,(function(id){return cb({id:id,removes:[{index:index}]})}))}))];function instrumentGroupingCSSRuleClass(cls){instrumentationStoppers.push(instrumentMethod(cls.prototype,"insertRule",(function(params){var styleSheet=params.target,parameters=params.parameters,rule=parameters[0],index=parameters[1];checkStyleSheetAndCallback(styleSheet.parentStyleSheet,(function(id){var path=getPathToNestedCSSRule(styleSheet);path&&(path.push(index||0),cb({id:id,adds:[{rule:rule,index:path}]}))}))})),instrumentMethod(cls.prototype,"deleteRule",(function(params){var styleSheet=params.target,index=params.parameters[0];checkStyleSheetAndCallback(styleSheet.parentStyleSheet,(function(id){var path=getPathToNestedCSSRule(styleSheet);path&&(path.push(index),cb({id:id,removes:[{index:path}]}))}))})))}return"undefined"!=typeof CSSGroupingRule?instrumentGroupingCSSRuleClass(CSSGroupingRule):(instrumentGroupingCSSRuleClass(CSSMediaRule),instrumentGroupingCSSRuleClass(CSSSupportsRule)),function(){instrumentationStoppers.forEach((function(stopper){stopper.stop()}))}}export function initFrustrationObserver(lifeCycle,frustrationCb,configuration,isNodeIgnored){return isNodeIgnored=isNodeIgnored||neverIgnoreNode,lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,(function(data){if(data.rawRumEvent.type===RumEventType.ACTION&&data.rawRumEvent.action.type===ActionType.CLICK&&data.rawRumEvent.action.frustration&&data.rawRumEvent.action.frustration.type&&data.rawRumEvent.action.frustration.type.length&&"events"in data.domainContext&&data.domainContext.events&&data.domainContext.events.length){var replayEvents=data.domainContext.events.filter((function(event){try{return!isNodeIgnored(getEventTarget(event))}catch(_){return!1}}));if(!replayEvents.length)return;frustrationCb({timestamp:data.rawRumEvent.date,type:RecordType.FrustrationRecord,data:{frustrationTypes:data.rawRumEvent.action.frustration.type,recordIds:replayEvents.map((function(e){return getRecordIdForEvent(e)}))}})}})).unsubscribe}function getEventTarget(event){return!0===event.composed&&isNodeShadowHost(event.target)?event.composedPath()[0]:event.target}
2
+ //# sourceMappingURL=observers.js.map