@cloudcare/browser-rum 3.3.25 → 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 (88) hide show
  1. package/bundle/dataflux-rum.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/recorderApi.js +36 -1
  4. package/cjs/boot/recorderApi.js.map +1 -1
  5. package/cjs/boot/rum.js +2 -6
  6. package/cjs/boot/rum.js.map +1 -1
  7. package/cjs/domain/deflate/deflateWorker.js +1 -1
  8. package/cjs/domain/privacy.js +71 -102
  9. package/cjs/domain/privacy.js.map +1 -1
  10. package/cjs/domain/replay/record/canvasCommandCapture.js +12 -16
  11. package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -1
  12. package/cjs/domain/replay/record/canvasCommandObserver.js +10 -6
  13. package/cjs/domain/replay/record/canvasCommandObserver.js.map +1 -1
  14. package/cjs/domain/replay/record/canvasContext.js +8 -18
  15. package/cjs/domain/replay/record/canvasContext.js.map +1 -1
  16. package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
  17. package/cjs/domain/replay/record/canvasObserver.js +1 -1
  18. package/cjs/domain/replay/record/canvasObserver.js.map +1 -1
  19. package/cjs/domain/replay/record/canvasWebGLPluginHost.js +5 -1
  20. package/cjs/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
  21. package/cjs/domain/replay/record/observers.js +3 -7
  22. package/cjs/domain/replay/record/observers.js.map +1 -1
  23. package/cjs/domain/replay/record/record.js +14 -1
  24. package/cjs/domain/replay/record/record.js.map +1 -1
  25. package/cjs/domain/replay/record/serializationUtils.js +8 -23
  26. package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
  27. package/cjs/domain/replay/record/serialize.js +5 -21
  28. package/cjs/domain/replay/record/serialize.js.map +1 -1
  29. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +17 -24
  30. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  31. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +5 -10
  32. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
  33. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  34. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  35. package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -1
  36. package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  37. package/esm/boot/buildEnv.js +1 -1
  38. package/esm/boot/recorderApi.js +1 -1
  39. package/esm/boot/recorderApi.js.map +1 -1
  40. package/esm/boot/rum.js +1 -1
  41. package/esm/boot/rum.js.map +1 -1
  42. package/esm/domain/deflate/deflateWorker.js +1 -1
  43. package/esm/domain/privacy.js +1 -1
  44. package/esm/domain/privacy.js.map +1 -1
  45. package/esm/domain/replay/record/canvasCommandCapture.js +1 -1
  46. package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
  47. package/esm/domain/replay/record/canvasCommandObserver.js +1 -1
  48. package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -1
  49. package/esm/domain/replay/record/canvasContext.js +1 -1
  50. package/esm/domain/replay/record/canvasContext.js.map +1 -1
  51. package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
  52. package/esm/domain/replay/record/canvasObserver.js +1 -1
  53. package/esm/domain/replay/record/canvasObserver.js.map +1 -1
  54. package/esm/domain/replay/record/canvasWebGLPluginHost.js +1 -1
  55. package/esm/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
  56. package/esm/domain/replay/record/observers.js +1 -1
  57. package/esm/domain/replay/record/observers.js.map +1 -1
  58. package/esm/domain/replay/record/record.js +1 -1
  59. package/esm/domain/replay/record/record.js.map +1 -1
  60. package/esm/domain/replay/record/serializationUtils.js +1 -1
  61. package/esm/domain/replay/record/serializationUtils.js.map +1 -1
  62. package/esm/domain/replay/record/serialize.js +1 -1
  63. package/esm/domain/replay/record/serialize.js.map +1 -1
  64. package/esm/domain/rumEventsCollection/resource/resourceCollection.js +1 -1
  65. package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  66. package/esm/domain/rumEventsCollection/resource/resourceUtils.js +1 -1
  67. package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
  68. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  69. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  70. package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -1
  71. package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  72. package/package.json +4 -4
  73. package/src/boot/recorderApi.js +51 -2
  74. package/src/boot/rum.js +6 -15
  75. package/src/domain/privacy.js +84 -148
  76. package/src/domain/replay/record/canvasCommandCapture.js +14 -17
  77. package/src/domain/replay/record/canvasCommandObserver.js +11 -18
  78. package/src/domain/replay/record/canvasContext.js +10 -24
  79. package/src/domain/replay/record/canvasObserver.js +2 -2
  80. package/src/domain/replay/record/canvasWebGLPluginHost.js +4 -1
  81. package/src/domain/replay/record/observers.js +4 -8
  82. package/src/domain/replay/record/record.js +19 -4
  83. package/src/domain/replay/record/serializationUtils.js +10 -33
  84. package/src/domain/replay/record/serialize.js +7 -28
  85. package/src/domain/rumEventsCollection/resource/resourceCollection.js +19 -27
  86. package/src/domain/rumEventsCollection/resource/resourceUtils.js +5 -10
  87. package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  88. package/src/domain/rumEventsCollection/view/viewCollection.js +2 -3
@@ -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
@@ -776,21 +777,7 @@ export function serializeAttribute(
776
777
  }
777
778
  }
778
779
 
779
- if (!attributeValue || typeof attributeValue !== 'string') {
780
- return attributeValue
781
- }
782
-
783
- // Minimum Fix for customer.
784
- // if (
785
- // attributeValue.length > MAX_ATTRIBUTE_VALUE_CHAR_LENGTH &&
786
- // attributeValue.slice(0, 5) === 'data:'
787
- // ) {
788
- // return 'data:truncated'
789
- // }
790
- if (isLongDataUrl(attributeValue)) {
791
- return sanitizeDataUrl(attributeValue)
792
- }
793
- return attributeValue
780
+ return sanitizeDataUrl(attributeValue)
794
781
  }
795
782
 
796
783
  /**
@@ -861,9 +848,7 @@ function transformAttribute(doc, tagName, name, value) {
861
848
  }
862
849
 
863
850
  function getAttributesForPrivacyLevel(element, tagName, nodePrivacyLevel, options) {
864
- if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
865
- return {}
866
- }
851
+ var isFormControl = isFormValueElement(tagName)
867
852
  var safeAttrs = {}
868
853
  var doc = element.ownerDocument
869
854
  var serializedSourceLength = 0
@@ -879,7 +864,7 @@ function getAttributesForPrivacyLevel(element, tagName, nodePrivacyLevel, option
879
864
  var attributeName = attribute.name
880
865
  // Markup holds defaults. Read the current form state once, below.
881
866
  if (
882
- (attributeName === 'value' && tagName === 'input') ||
867
+ (attributeName === 'value' && isFormControl) ||
883
868
  (attributeName === 'selected' && tagName === 'option')
884
869
  ) {
885
870
  continue
@@ -925,13 +910,7 @@ function getAttributesForPrivacyLevel(element, tagName, nodePrivacyLevel, option
925
910
  }
926
911
  }
927
912
 
928
- if (
929
- element.value &&
930
- (tagName === 'textarea' ||
931
- tagName === 'select' ||
932
- tagName === 'option' ||
933
- tagName === 'input')
934
- ) {
913
+ if (isFormControl && (element.value || (tagName === 'option' && element.hasAttribute('value')))) {
935
914
  var formValue = getElementInputValue(
936
915
  options.configuration,
937
916
  element,
@@ -1,4 +1,5 @@
1
1
  import {
2
+ assign,
2
3
  getStatusGroup,
3
4
  UUID,
4
5
  extend,
@@ -25,7 +26,6 @@ import {
25
26
  computeResourceEntrySize,
26
27
  isResourceEntryRequestType,
27
28
  isResourceUrlLimit,
28
- isLongDataUrl,
29
29
  sanitizeDataUrl,
30
30
  computeResourceEntryDeliveryType,
31
31
  computeResourceEntryProtocol
@@ -172,20 +172,14 @@ export function startResourceCollection(
172
172
 
173
173
  export function processWebSocket(event) {
174
174
  var duration = event.endClocks.timeStamp - event.startClocks.timeStamp
175
- var urlObj = getUrlParts(event.url)
176
175
  return {
177
176
  startTime: event.startClocks.relative,
178
177
  rawRumEvent: {
179
178
  date: event.startClocks.timeStamp,
180
179
  type: RumEventType.RESOURCE,
181
- resource: {
180
+ resource: assign(getResourceUrlFields(event.url), {
182
181
  id: UUID(),
183
182
  type: ResourceType.WEBSOCKET,
184
- url: event.url,
185
- urlHost: urlObj.Host,
186
- urlPath: urlObj.Path,
187
- urlPathGroup: replaceNumberCharByPath(urlObj.Path),
188
- urlQuery: getQueryParamsFromUrl(event.url),
189
183
  duration: toServerDuration(duration),
190
184
  websocket: {
191
185
  connectionId: event.connectionId,
@@ -218,7 +212,7 @@ export function processWebSocket(event) {
218
212
  protocol: event.protocol,
219
213
  setupDuration: toServerDuration(event.setupDuration)
220
214
  }
221
- }
215
+ })
222
216
  },
223
217
  domainContext: {
224
218
  isWebSocket: true,
@@ -227,6 +221,18 @@ export function processWebSocket(event) {
227
221
  }
228
222
  }
229
223
 
224
+ function getResourceUrlFields(rawUrl) {
225
+ var url = sanitizeDataUrl(rawUrl)
226
+ var parts = getUrlParts(url)
227
+ return {
228
+ url: url,
229
+ urlHost: parts.Host,
230
+ urlPath: parts.Path,
231
+ urlPathGroup: replaceNumberCharByPath(parts.Path),
232
+ urlQuery: getQueryParamsFromUrl(url)
233
+ }
234
+ }
235
+
230
236
  function processRequest(request, pageStateHistory, matchingTiming) {
231
237
  var startClocks = matchingTiming
232
238
  ? relativeToClocks(matchingTiming.startTime)
@@ -245,11 +251,10 @@ function processRequest(request, pageStateHistory, matchingTiming) {
245
251
  request.duration
246
252
  )
247
253
 
248
- var urlObj = getUrlParts(request.url)
249
254
  var resourceEvent = extend2Lev(
250
255
  {
251
256
  date: startClocks.timeStamp,
252
- resource: {
257
+ resource: assign(getResourceUrlFields(request.url), {
253
258
  id: UUID(),
254
259
  type: type,
255
260
  duration: duration,
@@ -259,17 +264,10 @@ function processRequest(request, pageStateHistory, matchingTiming) {
259
264
  method: request.method,
260
265
  status: request.status,
261
266
  statusGroup: getStatusGroup(request.status),
262
- url: isLongDataUrl(request.url)
263
- ? sanitizeDataUrl(request.url)
264
- : request.url,
265
- urlHost: urlObj.Host,
266
- urlPath: urlObj.Path,
267
- urlPathGroup: replaceNumberCharByPath(urlObj.Path),
268
- urlQuery: getQueryParamsFromUrl(request.url),
269
267
  deliveryType:
270
268
  matchingTiming && computeResourceEntryDeliveryType(matchingTiming),
271
269
  protocol: matchingTiming && computeResourceEntryProtocol(matchingTiming)
272
- },
270
+ }),
273
271
  type: RumEventType.RESOURCE
274
272
  },
275
273
  tracingInfo,
@@ -305,24 +303,18 @@ function processResourceEntry(entry, configuration) {
305
303
  var tracingInfo = computeResourceEntryTracingInfo(entry)
306
304
  var type = computeResourceEntryType(entry)
307
305
  var entryMetrics = computeResourceEntryMetrics(entry)
308
- var urlObj = getUrlParts(entry.name)
309
306
  var resourceEvent = extend2Lev(
310
307
  {
311
308
  date: startClocks.timeStamp,
312
- resource: {
309
+ resource: assign(getResourceUrlFields(entry.name), {
313
310
  id: UUID(),
314
311
  type: type,
315
- url: entry.name,
316
- urlHost: urlObj.Host,
317
- urlPath: urlObj.Path,
318
- urlPathGroup: replaceNumberCharByPath(urlObj.Path),
319
- urlQuery: getQueryParamsFromUrl(entry.name),
320
312
  method: 'GET',
321
313
  status: discardZeroStatus(entry.responseStatus),
322
314
  statusGroup: getStatusGroup(entry.responseStatus),
323
315
  deliveryType: computeResourceEntryDeliveryType(entry),
324
316
  protocol: computeResourceEntryProtocol(entry)
325
- },
317
+ }),
326
318
  type: RumEventType.RESOURCE
327
319
  },
328
320
  tracingInfo,
@@ -276,19 +276,14 @@ export function isAllowedRequestUrl(configuration, url) {
276
276
  return url && !isIntakeRequest(url, configuration)
277
277
  }
278
278
 
279
- var DATA_URL_REGEX = /data:(.+)?(;base64)?,/g
279
+ var MAX_DATA_URL_HEADER_LENGTH = 256
280
280
  export var MAX_ATTRIBUTE_VALUE_CHAR_LENGTH = 24_000
281
281
  export function isLongDataUrl(url) {
282
- if (url.length <= MAX_ATTRIBUTE_VALUE_CHAR_LENGTH) {
283
- return false
284
- } else if (url.substring(0, 5) === 'data:') {
285
- // Avoid String.match RangeError: Maximum call stack size exceeded
286
- url = url.substring(0, MAX_ATTRIBUTE_VALUE_CHAR_LENGTH)
287
- return true
288
- }
289
- return false
282
+ return typeof url === 'string' && url.length > MAX_ATTRIBUTE_VALUE_CHAR_LENGTH && /^[\x00-\x20]*data:/i.test(url)
290
283
  }
291
284
 
292
285
  export function sanitizeDataUrl(url) {
293
- return url.match(DATA_URL_REGEX)[0] + '[...]'
286
+ if (!isLongDataUrl(url)) return url
287
+ var header = /data:[^,]*,/i.exec(url.slice(0, MAX_DATA_URL_HEADER_LENGTH + 1))
288
+ return (header ? header[0] : 'data:') + '[...]'
294
289
  }
@@ -106,7 +106,7 @@ function slidingSessionWindow() {
106
106
  var shouldCreateNewWindow =
107
107
  startTime === undefined ||
108
108
  entry.startTime - endTime >= MAX_UPDATE_GAP ||
109
- entry.startTime - startTime >= 5 * MAX_WINDOW_DURATION
109
+ entry.startTime - startTime >= MAX_WINDOW_DURATION
110
110
  var isMaxValue
111
111
 
112
112
  if (shouldCreateNewWindow) {
@@ -134,9 +134,8 @@ function processViewUpdate(view, configuration, recorderApi, pageStateHistory) {
134
134
  view.commonViewMetrics,
135
135
  'cumulativeLayoutShift.value'
136
136
  ),
137
- cumulative_layout_shift_time: findByPath(
138
- view.commonViewMetrics,
139
- 'cumulativeLayoutShift.time'
137
+ cumulative_layout_shift_time: toServerDuration(
138
+ findByPath(view.commonViewMetrics, 'cumulativeLayoutShift.time')
140
139
  ),
141
140
  cumulative_layout_shift_target_selector: findByPath(
142
141
  view.commonViewMetrics,