@cloudcare/browser-rum 3.3.24 → 3.3.26

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 (209) hide show
  1. package/README.md +33 -0
  2. package/README.zh.md +30 -0
  3. package/bundle/dataflux-rum.js +1 -1
  4. package/cjs/boot/buildEnv.js +1 -1
  5. package/cjs/boot/disabledRumPublicApi.js +5 -0
  6. package/cjs/boot/disabledRumPublicApi.js.map +1 -1
  7. package/cjs/boot/initCallbacks.js +25 -0
  8. package/cjs/boot/initCallbacks.js.map +1 -0
  9. package/cjs/boot/perStartRum.js +99 -50
  10. package/cjs/boot/perStartRum.js.map +1 -1
  11. package/cjs/boot/recorderApi.js +36 -1
  12. package/cjs/boot/recorderApi.js.map +1 -1
  13. package/cjs/boot/rum.js +8 -9
  14. package/cjs/boot/rum.js.map +1 -1
  15. package/cjs/boot/rumPublicApi.js +6 -7
  16. package/cjs/boot/rumPublicApi.js.map +1 -1
  17. package/cjs/boot/startRecording.js +2 -0
  18. package/cjs/boot/startRecording.js.map +1 -1
  19. package/cjs/domain/configuration.js +15 -2
  20. package/cjs/domain/configuration.js.map +1 -1
  21. package/cjs/domain/contexts/urlContexts.js +32 -21
  22. package/cjs/domain/contexts/urlContexts.js.map +1 -1
  23. package/cjs/domain/contexts/viewContexts.js +1 -1
  24. package/cjs/domain/contexts/viewContexts.js.map +1 -1
  25. package/cjs/domain/deflate/deflateWorker.js +39 -27
  26. package/cjs/domain/deflate/deflateWorker.js.map +1 -1
  27. package/cjs/domain/privacy.js +79 -107
  28. package/cjs/domain/privacy.js.map +1 -1
  29. package/cjs/domain/replay/record/canvasCommandCapture.js +87 -179
  30. package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -1
  31. package/cjs/domain/replay/record/canvasCommandObserver.js +10 -6
  32. package/cjs/domain/replay/record/canvasCommandObserver.js.map +1 -1
  33. package/cjs/domain/replay/record/canvasCommandObserverStub.js +24 -0
  34. package/cjs/domain/replay/record/canvasCommandObserverStub.js.map +1 -0
  35. package/cjs/domain/replay/record/canvasCommandSerializeArgs.js +3 -2
  36. package/cjs/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
  37. package/cjs/domain/replay/record/canvasContext.js +15 -0
  38. package/cjs/domain/replay/record/canvasContext.js.map +1 -1
  39. package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
  40. package/cjs/domain/replay/record/canvasObserver.js +3 -0
  41. package/cjs/domain/replay/record/canvasObserver.js.map +1 -1
  42. package/cjs/domain/replay/record/canvasWebGLPluginHost.js +5 -1
  43. package/cjs/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
  44. package/cjs/domain/replay/record/mutationObserver.js +3 -12
  45. package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
  46. package/cjs/domain/replay/record/observers.js +3 -7
  47. package/cjs/domain/replay/record/observers.js.map +1 -1
  48. package/cjs/domain/replay/record/record.js +15 -2
  49. package/cjs/domain/replay/record/record.js.map +1 -1
  50. package/cjs/domain/replay/record/serializationUtils.js +8 -23
  51. package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
  52. package/cjs/domain/replay/record/serialize.js +19 -33
  53. package/cjs/domain/replay/record/serialize.js.map +1 -1
  54. package/cjs/domain/replay/segmentCollection/buildReplayPayload.js +21 -6
  55. package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
  56. package/cjs/domain/replay/segmentCollection/segmentCollection.js +91 -143
  57. package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  58. package/cjs/domain/replayCanvasSupported.js +8 -0
  59. package/cjs/domain/replayCanvasSupported.js.map +1 -0
  60. package/cjs/domain/requestCollection.js +38 -39
  61. package/cjs/domain/requestCollection.js.map +1 -1
  62. package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js +1 -1
  63. package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
  64. package/cjs/domain/rumEventsCollection/resource/fetchTimingRegistry.js +143 -0
  65. package/cjs/domain/rumEventsCollection/resource/fetchTimingRegistry.js.map +1 -0
  66. package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -2
  67. package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
  68. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +91 -66
  69. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  70. package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js +11 -9
  71. package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
  72. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +35 -50
  73. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
  74. package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +7 -1
  75. package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
  76. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  77. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  78. package/cjs/domain/rumEventsCollection/view/trackViews.js +3 -0
  79. package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  80. package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -1
  81. package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  82. package/cjs/domain/tracing/skywalkingTracer.js +4 -50
  83. package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
  84. package/cjs/domain/tracing/tracer.js +26 -3
  85. package/cjs/domain/tracing/tracer.js.map +1 -1
  86. package/esm/boot/buildEnv.js +1 -1
  87. package/esm/boot/disabledRumPublicApi.js +1 -1
  88. package/esm/boot/disabledRumPublicApi.js.map +1 -1
  89. package/esm/boot/initCallbacks.js +2 -0
  90. package/esm/boot/initCallbacks.js.map +1 -0
  91. package/esm/boot/perStartRum.js +1 -1
  92. package/esm/boot/perStartRum.js.map +1 -1
  93. package/esm/boot/recorderApi.js +1 -1
  94. package/esm/boot/recorderApi.js.map +1 -1
  95. package/esm/boot/rum.js +1 -1
  96. package/esm/boot/rum.js.map +1 -1
  97. package/esm/boot/rumPublicApi.js +1 -1
  98. package/esm/boot/rumPublicApi.js.map +1 -1
  99. package/esm/boot/startRecording.js +1 -1
  100. package/esm/boot/startRecording.js.map +1 -1
  101. package/esm/domain/configuration.js +1 -1
  102. package/esm/domain/configuration.js.map +1 -1
  103. package/esm/domain/contexts/urlContexts.js +1 -1
  104. package/esm/domain/contexts/urlContexts.js.map +1 -1
  105. package/esm/domain/contexts/viewContexts.js +1 -1
  106. package/esm/domain/contexts/viewContexts.js.map +1 -1
  107. package/esm/domain/deflate/deflateWorker.js +1 -1
  108. package/esm/domain/deflate/deflateWorker.js.map +1 -1
  109. package/esm/domain/privacy.js +1 -1
  110. package/esm/domain/privacy.js.map +1 -1
  111. package/esm/domain/replay/record/canvasCommandCapture.js +1 -1
  112. package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
  113. package/esm/domain/replay/record/canvasCommandObserver.js +1 -1
  114. package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -1
  115. package/esm/domain/replay/record/canvasCommandObserverStub.js +2 -0
  116. package/esm/domain/replay/record/canvasCommandObserverStub.js.map +1 -0
  117. package/esm/domain/replay/record/canvasCommandSerializeArgs.js +1 -1
  118. package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
  119. package/esm/domain/replay/record/canvasContext.js +1 -1
  120. package/esm/domain/replay/record/canvasContext.js.map +1 -1
  121. package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
  122. package/esm/domain/replay/record/canvasObserver.js +1 -1
  123. package/esm/domain/replay/record/canvasObserver.js.map +1 -1
  124. package/esm/domain/replay/record/canvasWebGLPluginHost.js +1 -1
  125. package/esm/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
  126. package/esm/domain/replay/record/mutationObserver.js +1 -1
  127. package/esm/domain/replay/record/mutationObserver.js.map +1 -1
  128. package/esm/domain/replay/record/observers.js +1 -1
  129. package/esm/domain/replay/record/observers.js.map +1 -1
  130. package/esm/domain/replay/record/record.js +1 -1
  131. package/esm/domain/replay/record/record.js.map +1 -1
  132. package/esm/domain/replay/record/serializationUtils.js +1 -1
  133. package/esm/domain/replay/record/serializationUtils.js.map +1 -1
  134. package/esm/domain/replay/record/serialize.js +1 -1
  135. package/esm/domain/replay/record/serialize.js.map +1 -1
  136. package/esm/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
  137. package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
  138. package/esm/domain/replay/segmentCollection/segmentCollection.js +1 -1
  139. package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  140. package/esm/domain/replayCanvasSupported.js +2 -0
  141. package/esm/domain/replayCanvasSupported.js.map +1 -0
  142. package/esm/domain/requestCollection.js +1 -1
  143. package/esm/domain/requestCollection.js.map +1 -1
  144. package/esm/domain/rumEventsCollection/actions/listenActionEvents.js +1 -1
  145. package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
  146. package/esm/domain/rumEventsCollection/resource/fetchTimingRegistry.js +2 -0
  147. package/esm/domain/rumEventsCollection/resource/fetchTimingRegistry.js.map +1 -0
  148. package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +1 -1
  149. package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
  150. package/esm/domain/rumEventsCollection/resource/resourceCollection.js +1 -1
  151. package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  152. package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js +1 -1
  153. package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
  154. package/esm/domain/rumEventsCollection/resource/resourceUtils.js +1 -1
  155. package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
  156. package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +1 -1
  157. package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
  158. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  159. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  160. package/esm/domain/rumEventsCollection/view/trackViews.js +1 -1
  161. package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  162. package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -1
  163. package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  164. package/esm/domain/tracing/skywalkingTracer.js +1 -1
  165. package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
  166. package/esm/domain/tracing/tracer.js +1 -1
  167. package/esm/domain/tracing/tracer.js.map +1 -1
  168. package/package.json +7 -7
  169. package/src/boot/disabledRumPublicApi.js +5 -0
  170. package/src/boot/initCallbacks.js +16 -0
  171. package/src/boot/perStartRum.js +102 -59
  172. package/src/boot/recorderApi.js +51 -2
  173. package/src/boot/rum.js +12 -18
  174. package/src/boot/rumPublicApi.js +6 -8
  175. package/src/boot/startRecording.js +2 -0
  176. package/src/domain/configuration.js +13 -2
  177. package/src/domain/contexts/urlContexts.js +34 -27
  178. package/src/domain/contexts/viewContexts.js +2 -2
  179. package/src/domain/deflate/deflateWorker.js +35 -21
  180. package/src/domain/privacy.js +93 -157
  181. package/src/domain/replay/record/canvasCommandCapture.js +102 -239
  182. package/src/domain/replay/record/canvasCommandObserver.js +11 -18
  183. package/src/domain/replay/record/canvasCommandObserverStub.js +11 -0
  184. package/src/domain/replay/record/canvasCommandSerializeArgs.js +2 -2
  185. package/src/domain/replay/record/canvasContext.js +18 -0
  186. package/src/domain/replay/record/canvasObserver.js +5 -1
  187. package/src/domain/replay/record/canvasWebGLPluginHost.js +4 -1
  188. package/src/domain/replay/record/mutationObserver.js +6 -22
  189. package/src/domain/replay/record/observers.js +4 -8
  190. package/src/domain/replay/record/record.js +20 -5
  191. package/src/domain/replay/record/serializationUtils.js +10 -33
  192. package/src/domain/replay/record/serialize.js +30 -38
  193. package/src/domain/replay/segmentCollection/buildReplayPayload.js +24 -14
  194. package/src/domain/replay/segmentCollection/segmentCollection.js +97 -227
  195. package/src/domain/replayCanvasSupported.js +1 -0
  196. package/src/domain/requestCollection.js +39 -51
  197. package/src/domain/rumEventsCollection/actions/listenActionEvents.js +8 -2
  198. package/src/domain/rumEventsCollection/resource/fetchTimingRegistry.js +138 -0
  199. package/src/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -2
  200. package/src/domain/rumEventsCollection/resource/resourceCollection.js +103 -88
  201. package/src/domain/rumEventsCollection/resource/resourceTrackerManager.js +10 -10
  202. package/src/domain/rumEventsCollection/resource/resourceUtils.js +41 -69
  203. package/src/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +8 -2
  204. package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  205. package/src/domain/rumEventsCollection/view/trackViews.js +3 -0
  206. package/src/domain/rumEventsCollection/view/viewCollection.js +2 -3
  207. package/src/domain/tracing/skywalkingTracer.js +14 -91
  208. package/src/domain/tracing/tracer.js +28 -4
  209. package/types/index.d.ts +9 -0
@@ -1,3 +1,20 @@
1
+ import { PRIVACY_ATTR_NAME } from '../../../constants'
2
+ import { getNodePrivacyLevel, shouldMaskNode } from './privacy'
3
+
4
+ // Most drawing commands have no privacy-marked ancestor. Native matching
5
+ // skips unrelated ancestors on that hot path, including for an allowed canvas.
6
+ var privacySelector =
7
+ `[${PRIVACY_ATTR_NAME}],.gc-privacy-hidden,.gc-privacy-mask,.gc-privacy-mask-user-input,.gc-privacy-allow,input,base,script,link,meta`
8
+
9
+ export function isCanvasPrivate(canvas, configuration) {
10
+ try {
11
+ var level = getNodePrivacyLevel(canvas, configuration.defaultPrivacyLevel, undefined, privacySelector)
12
+ return shouldMaskNode(configuration, canvas, level)
13
+ } catch (_) {
14
+ return true
15
+ }
16
+ }
17
+
1
18
  var contextTypeByCanvas = new WeakMap()
2
19
  var replayInternalCanvases = new WeakSet()
3
20
 
@@ -58,6 +75,7 @@ export function isWebGLReplayCanvas(canvas) {
58
75
 
59
76
  export function getReplayCanvasRecordingDecision(configuration, canvas) {
60
77
  try {
78
+ if (isCanvasPrivate(canvas, configuration)) return false
61
79
  return configuration.shouldRecordCanvas
62
80
  ? configuration.shouldRecordCanvas(canvas)
63
81
  : true
@@ -13,7 +13,8 @@ import {
13
13
  isCanvasFrameBelowThreshold
14
14
  } from './canvasFrameSignature'
15
15
  import {
16
- getReplayCanvasRecordingDecision
16
+ getReplayCanvasRecordingDecision,
17
+ isCanvasPrivate
17
18
  } from './canvasContext'
18
19
 
19
20
  var DEFAULT_ENCODED_DATA_URL_CACHE_MAX_CHARACTERS = 1024 * 1024
@@ -402,6 +403,9 @@ export function createCanvasObserver(options) {
402
403
  ) {
403
404
  return createSnapshotFailureResult('resized_during_snapshot')
404
405
  }
406
+ if (isCanvasPrivate(canvas, configuration)) {
407
+ return createSnapshotFailureResult('rejected_by_should_record_canvas')
408
+ }
405
409
  if (!isNodeActive(canvas)) {
406
410
  return createSnapshotFailureResult('not_serialized')
407
411
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ getReplayCanvasRecordingDecision,
2
3
  isWebGLReplayCanvas,
3
4
  markReplayInternalCanvas
4
5
  } from './canvasContext'
@@ -20,9 +21,11 @@ export function createSessionReplayWebGLRuntime(
20
21
  }
21
22
 
22
23
  try {
24
+ var webGLConfiguration = Object.create(configuration)
25
+ webGLConfiguration.shouldRecordCanvas = canvas => getReplayCanvasRecordingDecision(configuration, canvas)
23
26
  return (
24
27
  createRuntime(
25
- configuration,
28
+ webGLConfiguration,
26
29
  baseEncodeBridge,
27
30
  markReplayInternalCanvas,
28
31
  report
@@ -1666,28 +1666,12 @@ function processAttributesMutations(
1666
1666
  configuration.defaultPrivacyLevel,
1667
1667
  nodePrivacyLevelCache
1668
1668
  )
1669
- var attributeValue = serializeAttribute(
1670
- mutation.target,
1671
- privacyLevel,
1672
- mutation.attributeName,
1673
- configuration
1674
- )
1675
-
1676
- var transformedValue
1677
- if (mutation.attributeName === 'value') {
1678
- var inputValue = getElementInputValue(
1679
- configuration,
1680
- mutation.target,
1681
- privacyLevel
1682
- )
1683
- if (inputValue === undefined) {
1684
- continue
1685
- }
1686
- transformedValue = inputValue
1687
- } else if (typeof attributeValue === 'string') {
1688
- transformedValue = attributeValue
1689
- } else {
1690
- transformedValue = null
1669
+ var transformedValue =
1670
+ mutation.attributeName === 'value'
1671
+ ? getElementInputValue(configuration, mutation.target, privacyLevel)
1672
+ : serializeAttribute(mutation.target, privacyLevel, mutation.attributeName, configuration)
1673
+ if (transformedValue === undefined) {
1674
+ continue
1691
1675
  }
1692
1676
  transformedValue = truncateSerializedValue(
1693
1677
  transformedValue,
@@ -46,11 +46,6 @@ var SCROLL_OBSERVER_THRESHOLD = 100
46
46
  var VISUAL_VIEWPORT_OBSERVER_THRESHOLD = 200
47
47
  var MAX_TRACKED_RADIO_GROUPS = 256
48
48
  var MAX_INPUT_SETTER_PROTOTYPES = 36
49
- var INPUT_TAG_NAMES = {
50
- INPUT: true,
51
- TEXTAREA: true,
52
- SELECT: true
53
- }
54
49
 
55
50
  var recordIds = new WeakMap()
56
51
  let nextId = 1
@@ -530,11 +525,11 @@ export function initInputObserver(
530
525
  instrumentedInputPrototypes.add(prototype)
531
526
  instrumentedInputPrototypeCount += 1
532
527
  var properties =
533
- node.tagName === 'TEXTAREA'
528
+ node.localName === 'textarea'
534
529
  ? ['value']
535
530
  : [
536
531
  'value',
537
- node.tagName === 'INPUT' ? 'checked' : 'selectedIndex'
532
+ node.localName === 'input' ? 'checked' : 'selectedIndex'
538
533
  ]
539
534
  properties.forEach(function (property) {
540
535
  setterInstrumentationStoppers.push(
@@ -713,7 +708,8 @@ export function initInputObserver(
713
708
  }
714
709
 
715
710
  function isInputElement(target) {
716
- return !!target && INPUT_TAG_NAMES[target.tagName]
711
+ var tagName = target && target.localName
712
+ return tagName === 'input' || tagName === 'textarea' || tagName === 'select'
717
713
  }
718
714
 
719
715
  export function initStyleSheetObserver(
@@ -88,6 +88,7 @@ var FULL_SNAPSHOT_SERIALIZATION_MAX_NODE_COUNT =
88
88
  SERIALIZATION_MAX_NODE_COUNT * 4
89
89
  var FULL_SNAPSHOT_MAX_RESTART_COUNT = 3
90
90
  var FULL_SNAPSHOT_MAX_TOTAL_DURATION_MS = 1000
91
+ var INITIAL_FULL_SNAPSHOT_THROTTLED_SLICE_DELAY_MS = 16
91
92
  var FULL_SNAPSHOT_MAX_WALL_DURATION_MS = 30000
92
93
  var FULL_SNAPSHOT_MUTATION_QUIET_DELAY_MS = 250
93
94
  var REPLAY_MEMORY_BUDGET_BYTES = 48 * 1024 * 1024
@@ -1987,7 +1988,7 @@ export function record(options) {
1987
1988
  {
1988
1989
  data: {
1989
1990
  height: height,
1990
- href: window.location.href,
1991
+ href: options.$rGetDocumentUrl ? options.$rGetDocumentUrl() : window.location.href,
1991
1992
  width: width
1992
1993
  },
1993
1994
  type: RecordType.Meta,
@@ -3002,6 +3003,14 @@ export function record(options) {
3002
3003
  return
3003
3004
  }
3004
3005
  delay = delay || 0
3006
+ if (
3007
+ pendingFullSnapshotIsInitial &&
3008
+ pendingFullSnapshotActiveDuration > FULL_SNAPSHOT_MAX_TOTAL_DURATION_MS
3009
+ ) {
3010
+ // Finishing the first baseline makes the whole view playable. Keep the
3011
+ // traversal, but leave time for input and paint between its 4 ms slices.
3012
+ delay = Math.max(delay, INITIAL_FULL_SNAPSHOT_THROTTLED_SLICE_DELAY_MS)
3013
+ }
3005
3014
  pendingFullSnapshotTimeout = setTimeout(function () {
3006
3015
  pendingFullSnapshotTimeout = undefined
3007
3016
  if (failPendingFullSnapshotOnTimeout()) {
@@ -3333,15 +3342,21 @@ export function record(options) {
3333
3342
  }
3334
3343
 
3335
3344
  function failPendingFullSnapshotOnTimeout() {
3345
+ var elapsedMs = getPerformanceTime() - pendingFullSnapshotStartedAt
3336
3346
  if (
3337
3347
  pendingFullSnapshotTimestamp === undefined ||
3338
- (pendingFullSnapshotActiveDuration <=
3339
- FULL_SNAPSHOT_MAX_TOTAL_DURATION_MS &&
3340
- getPerformanceTime() - pendingFullSnapshotStartedAt <=
3341
- FULL_SNAPSHOT_MAX_WALL_DURATION_MS)
3348
+ ((pendingFullSnapshotIsInitial ||
3349
+ pendingFullSnapshotActiveDuration <= FULL_SNAPSHOT_MAX_TOTAL_DURATION_MS) &&
3350
+ elapsedMs <= FULL_SNAPSHOT_MAX_WALL_DURATION_MS)
3342
3351
  ) {
3343
3352
  return false
3344
3353
  }
3354
+ if (pendingFullSnapshotIsInitial) {
3355
+ addTelemetryDebug('initial_full_snapshot_serialization_timeout', {
3356
+ activeDurationMs: Math.round(pendingFullSnapshotActiveDuration),
3357
+ elapsedMs: Math.round(elapsedMs)
3358
+ })
3359
+ }
3345
3360
  failOrAbandonFullSnapshot('full_snapshot_serialization_timeout')
3346
3361
  return true
3347
3362
  }
@@ -5,7 +5,7 @@ import {
5
5
  isSafari
6
6
  } from '@cloudcare/browser-core'
7
7
  import { CENSORED_STRING_MARK } from '../../../constants'
8
- import { shouldMaskNode } from './privacy'
8
+ import { getNodePrivacyLevel, shouldMaskNode } from './privacy'
9
9
 
10
10
  var serializedNodeIds = new WeakMap()
11
11
  export var MAX_SERIALIZED_CANVAS_REGISTRY_SIZE = 2048
@@ -284,47 +284,24 @@ function getSerializedCanvasNodesWithinScanLimit(maxScanCount) {
284
284
  return connectedSerializedCanvasNodes
285
285
  }
286
286
 
287
+ export function isFormValueElement(tagName) {
288
+ return /^(input|textarea|select|option)$/.test(tagName)
289
+ }
290
+
287
291
  /**
288
292
  * Get the element "value" to be serialized as an attribute or an input update record. It respects
289
293
  * the input privacy mode of the element.
290
294
  * PERFROMANCE OPTIMIZATION: Assumes that privacy level `HIDDEN` is never encountered because of earlier checks.
291
295
  */
292
296
  export function getElementInputValue(configuration, element, nodePrivacyLevel) {
293
- /*
294
- BROWSER SPEC NOTE: <input>, <select>
295
- For some <input> elements, the `value` is an exceptional property/attribute that has the
296
- value synced between el.value and el.getAttribute()
297
- input[type=button,checkbox,hidden,image,radio,reset,submit]
298
- */
299
- var tagName = element.tagName
297
+ if (!isFormValueElement(element.localName)) return
300
298
  var value = element.value
301
- if (shouldMaskNode(configuration, element, nodePrivacyLevel)) {
302
- var type = element.type
303
- if (
304
- tagName === 'INPUT' &&
305
- (type === 'button' ||
306
- type === 'submit' ||
307
- type === 'reset' ||
308
- type === 'range')
309
- ) {
310
- // Overrule `MASK` privacy level for button-like element values, as they are used during replay
311
- // to display their label. They can still be hidden via the "hidden" privacy attribute or class name.
312
- return value
313
- } else if (!value || tagName === 'OPTION') {
314
- // <Option> value provides no benefit
315
- return
316
- }
317
- return CENSORED_STRING_MARK
318
- }
319
-
320
- if (tagName === 'OPTION' || tagName === 'SELECT') {
321
- return element.value
322
- }
323
-
324
- if (tagName !== 'INPUT' && tagName !== 'TEXTAREA') {
299
+ var option = element.localName === 'select' && element.options[element.selectedIndex]
300
+ if (shouldMaskNode(configuration, element, nodePrivacyLevel) ||
301
+ (option && shouldMaskNode(configuration, option, getNodePrivacyLevel(option, nodePrivacyLevel)))) {
302
+ if (value && element.localName !== 'option') return CENSORED_STRING_MARK
325
303
  return
326
304
  }
327
-
328
305
  return value
329
306
  }
330
307
  function extractOrigin(url) {
@@ -18,6 +18,7 @@ import {
18
18
 
19
19
  import { NodeType } from '../../../types'
20
20
  import {
21
+ getElementTagName,
21
22
  getTextContent,
22
23
  shouldMaskNode,
23
24
  reducePrivacyLevel,
@@ -27,6 +28,7 @@ import {
27
28
  getSerializedNodeId,
28
29
  setSerializedNodeId,
29
30
  getElementInputValue,
31
+ isFormValueElement,
30
32
  getHiddenElementPlaceholderSize,
31
33
  switchToAbsoluteUrl,
32
34
  createStyleSheetsSerializerTask,
@@ -39,7 +41,6 @@ import {
39
41
  STYLESHEET_SERIALIZATION_MAX_SNAPSHOT_BYTES
40
42
  } from './serializationUtils'
41
43
  import {
42
- isLongDataUrl,
43
44
  sanitizeDataUrl
44
45
  } from '../../rumEventsCollection/resource/resourceUtils'
45
46
  // Those values are the only one that can be used when inheriting privacy levels from parent to
@@ -473,7 +474,7 @@ export function serializeElementNode(element, options) {
473
474
  }
474
475
 
475
476
  function describeElementNode(element, options) {
476
- var tagName = getValidTagName(element.tagName)
477
+ var tagName = getValidTagName(getElementTagName(element))
477
478
  var isSVG = isSVGElement(element) || undefined
478
479
 
479
480
  // For performance reason, we don't use getNodePrivacyLevel directly: we leverage the
@@ -512,6 +513,7 @@ function describeElementNode(element, options) {
512
513
 
513
514
  var attributes = getAttributesForPrivacyLevel(
514
515
  element,
516
+ tagName,
515
517
  nodePrivacyLevel,
516
518
  options
517
519
  )
@@ -721,6 +723,16 @@ export function serializeAttribute(
721
723
  attributeName,
722
724
  configuration
723
725
  ) {
726
+ if (attributeName === 'selected' && element.localName === 'option') {
727
+ // Omit private selection entirely, including which option changed.
728
+ if (
729
+ nodePrivacyLevel !== NodePrivacyLevel.ALLOW ||
730
+ shouldMaskNode(configuration, element, nodePrivacyLevel)
731
+ ) {
732
+ return undefined
733
+ }
734
+ return element.selected ? '' : null
735
+ }
724
736
  if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
725
737
  // dup condition for direct access case
726
738
  return null
@@ -765,21 +777,7 @@ export function serializeAttribute(
765
777
  }
766
778
  }
767
779
 
768
- if (!attributeValue || typeof attributeValue !== 'string') {
769
- return attributeValue
770
- }
771
-
772
- // Minimum Fix for customer.
773
- // if (
774
- // attributeValue.length > MAX_ATTRIBUTE_VALUE_CHAR_LENGTH &&
775
- // attributeValue.slice(0, 5) === 'data:'
776
- // ) {
777
- // return 'data:truncated'
778
- // }
779
- if (isLongDataUrl(attributeValue)) {
780
- return sanitizeDataUrl(attributeValue)
781
- }
782
- return attributeValue
780
+ return sanitizeDataUrl(attributeValue)
783
781
  }
784
782
 
785
783
  /**
@@ -849,12 +847,9 @@ function transformAttribute(doc, tagName, name, value) {
849
847
  }
850
848
  }
851
849
 
852
- function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
853
- if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
854
- return {}
855
- }
850
+ function getAttributesForPrivacyLevel(element, tagName, nodePrivacyLevel, options) {
851
+ var isFormControl = isFormValueElement(tagName)
856
852
  var safeAttrs = {}
857
- var tagName = getValidTagName(element.tagName)
858
853
  var doc = element.ownerDocument
859
854
  var serializedSourceLength = 0
860
855
  var maxNodeSourceLength = getMaxNodeSourceLength(options)
@@ -867,6 +862,13 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
867
862
  ) {
868
863
  var attribute = element.attributes.item(i)
869
864
  var attributeName = attribute.name
865
+ // Markup holds defaults. Read the current form state once, below.
866
+ if (
867
+ (attributeName === 'value' && isFormControl) ||
868
+ (attributeName === 'selected' && tagName === 'option')
869
+ ) {
870
+ continue
871
+ }
870
872
  var remainingSourceLength =
871
873
  maxNodeSourceLength -
872
874
  serializedSourceLength -
@@ -908,13 +910,7 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
908
910
  }
909
911
  }
910
912
 
911
- if (
912
- element.value &&
913
- (tagName === 'textarea' ||
914
- tagName === 'select' ||
915
- tagName === 'option' ||
916
- tagName === 'input')
917
- ) {
913
+ if (isFormControl && (element.value || (tagName === 'option' && element.hasAttribute('value')))) {
918
914
  var formValue = getElementInputValue(
919
915
  options.configuration,
920
916
  element,
@@ -934,15 +930,11 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
934
930
  }
935
931
  }
936
932
 
937
- /**
938
- * <Option> can be selected, which occurs if its `value` matches ancestor `<Select>.value`
939
- */
940
- if (tagName === 'option' && nodePrivacyLevel === NodePrivacyLevel.ALLOW) {
941
- // For privacy=`MASK`, all the values would be the same, so skip.
942
- var optionElement = element
943
- if (optionElement.selected) {
944
- safeAttrs.selected = optionElement.selected
945
- }
933
+ if (
934
+ tagName === 'option' &&
935
+ serializeAttribute(element, nodePrivacyLevel, 'selected', options.configuration) === ''
936
+ ) {
937
+ safeAttrs.selected = true
946
938
  }
947
939
 
948
940
  // remote css
@@ -1,21 +1,31 @@
1
- import { objectEntries, each } from '@cloudcare/browser-core'
1
+ import { objectEntries, each, computeBytesCount } from '@cloudcare/browser-core'
2
+
3
+ // FormData chooses its own boundary. Budget the maximum 70 bytes at each
4
+ // delimiter so the synchronous exit path never needs to encode the body twice.
5
+ const PART_BYTES = 70 + '--\r\nContent-Disposition: form-data; name=""\r\n\r\n\r\n'.length
6
+ const CLOSING_BYTES = 70 + '----\r\n'.length
7
+ const FILE_HEADER_BYTES = '; filename=""\r\nContent-Type: application/octet-stream'.length
8
+
9
+ function fieldBytes(value, header) {
10
+ const normalized = value.replace(/\r\n|\r|\n/g, '\r\n')
11
+ return computeBytesCount(header ? normalized.replace(/["\r\n]/g, '%XX') : normalized)
12
+ }
2
13
 
3
14
  export function buildReplayPayload(data, metadata, rawSegmentBytesCount) {
4
- var formData = new FormData()
5
- formData.append(
6
- 'segment',
7
- new Blob([data], {
8
- type: 'application/octet-stream'
9
- }),
10
- metadata.session.id + '-' + metadata.start
11
- )
15
+ const formData = new FormData()
16
+ const segment = new Blob([data], { type: 'application/octet-stream' })
17
+ const filename = metadata.session.id + '-' + metadata.start
18
+ formData.append('segment', segment, filename)
19
+ let exitBytes = CLOSING_BYTES + PART_BYTES + FILE_HEADER_BYTES + 'segment'.length +
20
+ fieldBytes(filename, true) + segment.size
12
21
 
13
- toFormEntries(metadata, function (key, value) {
22
+ function appendField(key, value) {
14
23
  formData.append(key, value)
15
- })
16
- formData.append('raw_segment_size', rawSegmentBytesCount)
17
-
18
- return { data: formData, bytesCount: data.byteLength }
24
+ exitBytes += PART_BYTES + fieldBytes(key, true) + fieldBytes(value, false)
25
+ }
26
+ toFormEntries(metadata, appendField)
27
+ appendField('raw_segment_size', String(rawSegmentBytesCount))
28
+ return { data: formData, bytesCount: segment.size, $rExitBytesCount: exitBytes }
19
29
  }
20
30
 
21
31
  export function toFormEntries(input, onEntry, prefix) {