@cloudcare/browser-rum 3.0.0 → 3.0.2

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 (29) hide show
  1. package/bundle/dataflux-rum.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/domain/replay/record/mutationObserver.js +12 -7
  4. package/cjs/domain/replay/record/observers.js +10 -13
  5. package/cjs/domain/replay/record/privacy.js +1 -3
  6. package/cjs/domain/replay/record/serializationUtils.js +100 -0
  7. package/cjs/domain/replay/record/serialize.js +40 -13
  8. package/cjs/domain/replay/segmentCollection/deflateWorker.js +8 -7
  9. package/cjs/domain/replay/segmentCollection/startDeflateWorker.js +1 -0
  10. package/cjs/domain/rumSessionManager.js +1 -1
  11. package/esm/boot/buildEnv.js +1 -1
  12. package/esm/domain/replay/record/mutationObserver.js +13 -8
  13. package/esm/domain/replay/record/observers.js +12 -15
  14. package/esm/domain/replay/record/privacy.js +1 -3
  15. package/esm/domain/replay/record/serializationUtils.js +96 -0
  16. package/esm/domain/replay/record/serialize.js +41 -14
  17. package/esm/domain/replay/segmentCollection/deflateWorker.js +13 -10
  18. package/esm/domain/replay/segmentCollection/startDeflateWorker.js +1 -0
  19. package/esm/domain/rumSessionManager.js +1 -1
  20. package/package.json +3 -3
  21. package/src/domain/replay/record/mutationObserver.js +18 -8
  22. package/src/domain/replay/record/observers.js +16 -13
  23. package/src/domain/replay/record/privacy.js +1 -1
  24. package/src/domain/replay/record/serializationUtils.js +81 -2
  25. package/src/domain/replay/record/serialize.js +54 -15
  26. package/src/domain/replay/segmentCollection/deflateWorker.js +19 -12
  27. package/src/domain/replay/segmentCollection/segment.js +0 -1
  28. package/src/domain/replay/segmentCollection/startDeflateWorker.js +1 -0
  29. package/src/domain/rumSessionManager.js +1 -1
@@ -3,7 +3,7 @@ import { STABLE_ATTRIBUTES } from '../../rumEventsCollection/actions/getSelector
3
3
  import { NodePrivacyLevel, PRIVACY_ATTR_NAME, PRIVACY_ATTR_VALUE_HIDDEN, CENSORED_STRING_MARK, CENSORED_IMG_MARK } from '../../../constants';
4
4
  import { NodeType } from '../../../types';
5
5
  import { getTextContent, shouldMaskNode, reducePrivacyLevel, getNodeSelfPrivacyLevel, MAX_ATTRIBUTE_VALUE_CHAR_LENGTH } from './privacy';
6
- import { getSerializedNodeId, setSerializedNodeId, getElementInputValue, switchToAbsoluteUrl, serializeStyleSheets } from './serializationUtils'; // Those values are the only one that can be used when inheriting privacy levels from parent to
6
+ import { getSerializedNodeId, setSerializedNodeId, getElementInputValue, switchToAbsoluteUrl, serializeStyleSheets, absoluteToDoc, getAbsoluteSrcsetString } from './serializationUtils'; // Those values are the only one that can be used when inheriting privacy levels from parent to
7
7
  // children during serialization, since HIDDEN and IGNORE shouldn't serialize their children. This
8
8
  // ensures that no children are serialized when they shouldn't.
9
9
 
@@ -192,11 +192,9 @@ export function serializeElementNode(element, options) {
192
192
  */
193
193
 
194
194
  function serializeTextNode(textNode, options) {
195
- var _textNode$parentEleme;
196
-
197
195
  // The parent node may not be a html element which has a tagName attribute.
198
196
  // So just let it be undefined which is ok in this use case.
199
- var parentTagName = (_textNode$parentEleme = textNode.parentElement) === null || _textNode$parentEleme === void 0 ? void 0 : _textNode$parentEleme.tagName;
197
+ var parentTagName = textNode.parentElement && textNode.parentElement.tagName;
200
198
  var textContent = getTextContent(textNode, options.ignoreWhiteSpace || false, options.parentNodePrivacyLevel);
201
199
 
202
200
  if (!textContent) {
@@ -298,19 +296,24 @@ function getValidTagName(tagName) {
298
296
  return processedTagName;
299
297
  }
300
298
 
301
- function getCssRulesString(s) {
302
- try {
303
- var rules = s.rules || s.cssRules;
299
+ function getCssRulesString(cssStyleSheet) {
300
+ if (!cssStyleSheet) {
301
+ return null;
302
+ }
304
303
 
305
- if (rules) {
306
- var styleSheetCssText = Array.from(rules, getCssRuleString).join('');
307
- return switchToAbsoluteUrl(styleSheetCssText, s.href);
308
- }
304
+ var rules;
309
305
 
310
- return null;
311
- } catch (error) {
306
+ try {
307
+ rules = cssStyleSheet.rules || cssStyleSheet.cssRules;
308
+ } catch (_unused) {// if css is protected by CORS we cannot access cssRules see: https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
309
+ }
310
+
311
+ if (!rules) {
312
312
  return null;
313
313
  }
314
+
315
+ var styleSheetCssText = Array.from(rules, getCssRuleString).join('');
316
+ return switchToAbsoluteUrl(styleSheetCssText, cssStyleSheet.href);
314
317
  }
315
318
 
316
319
  function getCssRuleString(rule) {
@@ -325,6 +328,30 @@ function isSVGElement(el) {
325
328
  return el.tagName === 'svg' || el instanceof SVGElement;
326
329
  }
327
330
 
331
+ function transformAttribute(doc, tagName, name, value) {
332
+ if (name === 'src' || name === 'href' && value && !(tagName === 'use' && value[0] === '#')) {
333
+ return absoluteToDoc(doc, value);
334
+ } else if (name === 'xlink:href' && value && value[0] !== '#') {
335
+ return absoluteToDoc(doc, value);
336
+ } else if (name === 'background' && value && (tagName === 'table' || tagName === 'td' || tagName === 'th')) {
337
+ return absoluteToDoc(doc, value);
338
+ } else if (name === 'srcset' && value) {
339
+ return getAbsoluteSrcsetString(doc, value);
340
+ } else if (name === 'style' && value) {
341
+ return switchToAbsoluteUrl(value, getHref());
342
+ } else if (tagName === 'object' && name === 'data' && value) {
343
+ return absoluteToDoc(doc, value);
344
+ } else {
345
+ return value;
346
+ }
347
+ }
348
+
349
+ function getHref() {
350
+ var a = document.createElement('a');
351
+ a.href = '';
352
+ return a.href;
353
+ }
354
+
328
355
  function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
329
356
  if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
330
357
  return {};
@@ -340,7 +367,7 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
340
367
  var attributeValue = serializeAttribute(element, nodePrivacyLevel, attributeName, options.configuration);
341
368
 
342
369
  if (attributeValue !== null) {
343
- safeAttrs[attributeName] = attributeValue;
370
+ safeAttrs[attributeName] = transformAttribute(doc, tagName, attributeName, attributeValue);
344
371
  }
345
372
  }
346
373
 
@@ -10,14 +10,14 @@ export function createDeflateWorker() {
10
10
 
11
11
  function workerCodeFn() {
12
12
  monitor(function () {
13
- var {
14
- Deflate,
15
- constants,
16
- string2buf
17
- } = makePakoDeflate();
13
+ var _makePakoDeflate = makePakoDeflate();
14
+
15
+ var Deflate = _makePakoDeflate.Deflate;
16
+ var constants = _makePakoDeflate.constants;
17
+ var string2buf = _makePakoDeflate.string2buf;
18
18
  var deflate = new Deflate();
19
19
  var rawBytesCount = 0;
20
- self.addEventListener('message', monitor(event => {
20
+ self.addEventListener('message', monitor(function (event) {
21
21
  var data = event.data;
22
22
 
23
23
  switch (data.action) {
@@ -33,7 +33,9 @@ function workerCodeFn() {
33
33
  self.postMessage({
34
34
  type: 'wrote',
35
35
  id: data.id,
36
- compressedBytesCount: deflate.chunks.reduce((total, chunk) => total + chunk.length, 0),
36
+ compressedBytesCount: deflate.chunks.reduce(function (total, chunk) {
37
+ return total + chunk.length;
38
+ }, 0),
37
39
  additionalBytesCount
38
40
  });
39
41
  break;
@@ -41,14 +43,13 @@ function workerCodeFn() {
41
43
 
42
44
  case 'flush':
43
45
  {
44
- var _additionalBytesCount = data.data ? pushData(data.data) : 0;
45
-
46
+ var additionalBytesCount = data.data ? pushData(data.data) : 0;
46
47
  deflate.push('', constants.Z_FINISH);
47
48
  self.postMessage({
48
49
  type: 'flushed',
49
50
  id: data.id,
50
51
  result: deflate.result,
51
- additionalBytesCount: _additionalBytesCount,
52
+ additionalBytesCount,
52
53
  rawBytesCount
53
54
  });
54
55
  deflate = new Deflate();
@@ -72,6 +73,8 @@ function workerCodeFn() {
72
73
  try {
73
74
  return fn.apply(this, arguments);
74
75
  } catch (e) {
76
+ console.error('===monitor', e);
77
+
75
78
  try {
76
79
  self.postMessage({
77
80
  type: 'errored',
@@ -79,6 +79,7 @@ export function doStartDeflateWorker(createDeflateWorkerImpl) {
79
79
  });
80
80
  return worker;
81
81
  } catch (error) {
82
+ console.errror('====doStartDeflateWorker', error);
82
83
  onError(error);
83
84
  }
84
85
  }
@@ -60,7 +60,7 @@ function computeSessionState(configuration, rawTrackingType) {
60
60
 
61
61
  if (hasValidRumSession(rawTrackingType)) {
62
62
  trackingType = rawTrackingType;
63
- } else if (!performDraw(configuration.sampleRate)) {
63
+ } else if (!performDraw(configuration.sessionSampleRate)) {
64
64
  trackingType = RumTrackingType.NOT_TRACKED;
65
65
  } else if (!performDraw(configuration.sessionReplaySampleRate)) {
66
66
  trackingType = RumTrackingType.TRACKED_WITHOUT_SESSION_REPLAY;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@cloudcare/browser-rum",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "dependencies": {
7
- "@cloudcare/browser-core": "2.0.0"
7
+ "@cloudcare/browser-core": "2.0.1"
8
8
  },
9
9
  "scripts": {
10
10
  "dev": "webpack serve --open --mode=development",
@@ -29,5 +29,5 @@
29
29
  "license": "MIT",
30
30
  "homepage": "https://github.com/CloudCare/dataflux-rum-sdk-javascript/blob/master/packages/rum/README.md",
31
31
  "description": "DataFlux RUM Web 端数据指标监控",
32
- "gitHead": "bc7a044056367a5f9a0bc941462cb4e1d4d1d925"
32
+ "gitHead": "84d23b733f540e749455013790782b475eb8b83d"
33
33
  }
@@ -2,7 +2,8 @@ import {
2
2
  noop,
3
3
  getChildNodes,
4
4
  isNodeShadowHost,
5
- getParentNode
5
+ getParentNode,
6
+ isNullUndefinedDefaultValue
6
7
  } from '@cloudcare/browser-core'
7
8
  import { getMutationObserverConstructor } from '../../domMutationCollection'
8
9
  import { NodePrivacyLevel } from '../../../constants'
@@ -109,7 +110,14 @@ function processMutations(
109
110
  )
110
111
  var adds = _processChildListMutations.adds
111
112
  var removes = _processChildListMutations.removes
112
- var hasBeenSerialized = _processChildListMutations.hasBeenSerialized
113
+ // var hasBeenSerialized = _processChildListMutations.hasBeenSerialized
114
+ var serializedNodeIds = _processChildListMutations.serializedNodeIds
115
+ function hasBeenSerialized(node) {
116
+ return (
117
+ hasSerializedNode(node) &&
118
+ serializedNodeIds.has(getSerializedNodeId(node))
119
+ )
120
+ }
113
121
  var texts = processCharacterDataMutations(
114
122
  filteredMutations.filter(function (mutation) {
115
123
  return (
@@ -121,15 +129,15 @@ function processMutations(
121
129
 
122
130
  var attributes = processAttributesMutations(
123
131
  filteredMutations.filter(function (mutation) {
124
- mutation.type === 'attributes' && !hasBeenSerialized(mutation.target)
132
+ return (
133
+ mutation.type === 'attributes' && !hasBeenSerialized(mutation.target)
134
+ )
125
135
  }),
126
136
  configuration
127
137
  )
128
-
129
138
  if (!texts.length && !attributes.length && !removes.length && !adds.length) {
130
139
  return
131
140
  }
132
-
133
141
  mutationCallback({
134
142
  adds: adds,
135
143
  removes: removes,
@@ -236,6 +244,7 @@ function processChildListMutations(
236
244
  return {
237
245
  adds: addedNodeMutations,
238
246
  removes: removedNodeMutations,
247
+ serializedNodeIds: serializedNodeIds,
239
248
  hasBeenSerialized: hasBeenSerialized
240
249
  }
241
250
 
@@ -293,8 +302,9 @@ function processCharacterDataMutations(mutations, configuration) {
293
302
  textMutations.push({
294
303
  id: getSerializedNodeId(mutation.target),
295
304
  // TODO: pass a valid "ignoreWhiteSpace" argument
296
- value:
297
- getTextContent(mutation.target, false, parentNodePrivacyLevel) ?? null
305
+ value: isNullUndefinedDefaultValue(
306
+ getTextContent(mutation.target, false, parentNodePrivacyLevel, null)
307
+ )
298
308
  })
299
309
  }
300
310
 
@@ -308,7 +318,7 @@ function processAttributesMutations(mutations, configuration) {
308
318
  var handledElements = new Map()
309
319
  var filteredMutations = mutations.filter(function (mutation) {
310
320
  var handledAttributes = handledElements.get(mutation.target)
311
- if (handledAttributes?.has(mutation.attributeName)) {
321
+ if (handledAttributes && handledAttributes.has(mutation.attributeName)) {
312
322
  return false
313
323
  }
314
324
  if (!handledAttributes) {
@@ -236,7 +236,7 @@ function tryToComputeCoordinates(event) {
236
236
  if (!Number.isFinite(x) || !Number.isFinite(y)) {
237
237
  return undefined
238
238
  }
239
- return { x, y }
239
+ return { x: x, y: y }
240
240
  }
241
241
 
242
242
  function initScrollObserver(cb, defaultPrivacyLevel, elementsScrollPositions) {
@@ -535,20 +535,23 @@ export function initFrustrationObserver(lifeCycle, frustrationCb) {
535
535
  if (
536
536
  data.rawRumEvent.type === RumEventType.ACTION &&
537
537
  data.rawRumEvent.action.type === ActionType.CLICK &&
538
- data.rawRumEvent.action.frustration?.type?.length &&
538
+ data.rawRumEvent.action.frustration &&
539
+ data.rawRumEvent.action.frustration.type &&
540
+ data.rawRumEvent.action.frustration.type.length &&
539
541
  'events' in data.domainContext &&
540
- data.domainContext.events?.length
542
+ data.domainContext.events &&
543
+ data.domainContext.events.length
541
544
  ) {
542
- frustrationCb({
543
- timestamp: data.rawRumEvent.date,
544
- type: RecordType.FrustrationRecord,
545
- data: {
546
- frustrationTypes: data.rawRumEvent.action.frustration.type,
547
- recordIds: data.domainContext.events.map(function (e) {
548
- return getRecordIdForEvent(e)
549
- })
550
- }
551
- })
545
+ // frustrationCb({
546
+ // timestamp: data.rawRumEvent.date,
547
+ // type: RecordType.FrustrationRecord,
548
+ // data: {
549
+ // frustrationTypes: data.rawRumEvent.action.frustration.type,
550
+ // recordIds: data.domainContext.events.map(function (e) {
551
+ // return getRecordIdForEvent(e)
552
+ // })
553
+ // }
554
+ // })
552
555
  }
553
556
  }
554
557
  ).unsubscribe
@@ -187,7 +187,7 @@ export function getTextContent(
187
187
  ) {
188
188
  // The parent node may not be a html element which has a tagName attribute.
189
189
  // So just let it be undefined which is ok in this use case.
190
- var parentTagName = textNode.parentElement?.tagName
190
+ var parentTagName = textNode.parentElement && textNode.parentElement.tagName
191
191
  var textContent = textNode.textContent || ''
192
192
 
193
193
  if (ignoreWhiteSpace && !textContent.trim()) {
@@ -72,7 +72,16 @@ export function getElementInputValue(element, nodePrivacyLevel) {
72
72
 
73
73
  return value
74
74
  }
75
-
75
+ function extractOrigin(url) {
76
+ var origin = ''
77
+ if (url.indexOf('//') > -1) {
78
+ origin = url.split('/').slice(0, 3).join('/')
79
+ } else {
80
+ origin = url.split('/')[0]
81
+ }
82
+ origin = origin.split('?')[0]
83
+ return origin
84
+ }
76
85
  export var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm
77
86
  export var ABSOLUTE_URL = /^[A-Za-z]+:|^\/\//
78
87
  export var DATA_URI = /^data:.*,/i
@@ -96,7 +105,12 @@ export function switchToAbsoluteUrl(cssText, cssHref) {
96
105
  if (!cssHref || !url || ABSOLUTE_URL.test(url) || DATA_URI.test(url)) {
97
106
  return matchingSubstring
98
107
  }
99
-
108
+ if (url[0] === '/') {
109
+ return 'url('
110
+ .concat(quote)
111
+ .concat(extractOrigin(cssHref) + url)
112
+ .concat(quote, ')')
113
+ }
100
114
  var quote = singleQuote || doubleQuote || ''
101
115
  return `url(${quote}${makeUrlAbsolute(url, cssHref)}${quote})`
102
116
  }
@@ -132,3 +146,68 @@ export function serializeStyleSheets(cssStyleSheets) {
132
146
  return styleSheet
133
147
  })
134
148
  }
149
+ export function absoluteToDoc(doc, attributeValue) {
150
+ if (!attributeValue || attributeValue.trim() === '') {
151
+ return attributeValue
152
+ }
153
+ var a = doc.createElement('a')
154
+ a.href = attributeValue
155
+ return a.href
156
+ }
157
+
158
+ var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/
159
+ var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/
160
+ export function getAbsoluteSrcsetString(doc, attributeValue) {
161
+ if (attributeValue.trim() === '') {
162
+ return attributeValue
163
+ }
164
+ var pos = 0
165
+ function collectCharacters(regEx) {
166
+ var chars
167
+ var match = regEx.exec(attributeValue.substring(pos))
168
+ if (match) {
169
+ chars = match[0]
170
+ pos += chars.length
171
+ return chars
172
+ }
173
+ return ''
174
+ }
175
+ var output = []
176
+ while (true) {
177
+ collectCharacters(SRCSET_COMMAS_OR_SPACES)
178
+ if (pos >= attributeValue.length) {
179
+ break
180
+ }
181
+ var url = collectCharacters(SRCSET_NOT_SPACES)
182
+ if (url.slice(-1) === ',') {
183
+ url = absoluteToDoc(doc, url.substring(0, url.length - 1))
184
+ output.push(url)
185
+ } else {
186
+ var descriptorsStr = ''
187
+ url = absoluteToDoc(doc, url)
188
+ var inParens = false
189
+ while (true) {
190
+ var c = attributeValue.charAt(pos)
191
+ if (c === '') {
192
+ output.push((url + descriptorsStr).trim())
193
+ break
194
+ } else if (!inParens) {
195
+ if (c === ',') {
196
+ pos += 1
197
+ output.push((url + descriptorsStr).trim())
198
+ break
199
+ } else if (c === '(') {
200
+ inParens = true
201
+ }
202
+ } else {
203
+ if (c === ')') {
204
+ inParens = false
205
+ }
206
+ }
207
+ descriptorsStr += c
208
+ pos += 1
209
+ }
210
+ }
211
+ }
212
+ return output.join(', ')
213
+ }
@@ -26,7 +26,9 @@ import {
26
26
  setSerializedNodeId,
27
27
  getElementInputValue,
28
28
  switchToAbsoluteUrl,
29
- serializeStyleSheets
29
+ serializeStyleSheets,
30
+ absoluteToDoc,
31
+ getAbsoluteSrcsetString
30
32
  } from './serializationUtils'
31
33
 
32
34
  // Those values are the only one that can be used when inheriting privacy levels from parent to
@@ -224,7 +226,7 @@ export function serializeElementNode(element, options) {
224
226
  function serializeTextNode(textNode, options) {
225
227
  // The parent node may not be a html element which has a tagName attribute.
226
228
  // So just let it be undefined which is ok in this use case.
227
- var parentTagName = textNode.parentElement?.tagName
229
+ var parentTagName = textNode.parentElement && textNode.parentElement.tagName
228
230
  var textContent = getTextContent(
229
231
  textNode,
230
232
  options.ignoreWhiteSpace || false,
@@ -336,18 +338,21 @@ function getValidTagName(tagName) {
336
338
  return processedTagName
337
339
  }
338
340
 
339
- function getCssRulesString(s) {
340
- try {
341
- var rules = s.rules || s.cssRules
342
- if (rules) {
343
- var styleSheetCssText = Array.from(rules, getCssRuleString).join('')
344
- return switchToAbsoluteUrl(styleSheetCssText, s.href)
345
- }
346
-
341
+ function getCssRulesString(cssStyleSheet) {
342
+ if (!cssStyleSheet) {
347
343
  return null
348
- } catch (error) {
344
+ }
345
+ var rules
346
+ try {
347
+ rules = cssStyleSheet.rules || cssStyleSheet.cssRules
348
+ } catch {
349
+ // if css is protected by CORS we cannot access cssRules see: https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
350
+ }
351
+ if (!rules) {
349
352
  return null
350
353
  }
354
+ var styleSheetCssText = Array.from(rules, getCssRuleString).join('')
355
+ return switchToAbsoluteUrl(styleSheetCssText, cssStyleSheet.href)
351
356
  }
352
357
 
353
358
  function getCssRuleString(rule) {
@@ -363,7 +368,35 @@ function isCSSImportRule(rule) {
363
368
  function isSVGElement(el) {
364
369
  return el.tagName === 'svg' || el instanceof SVGElement
365
370
  }
366
-
371
+ function transformAttribute(doc, tagName, name, value) {
372
+ if (
373
+ name === 'src' ||
374
+ (name === 'href' && value && !(tagName === 'use' && value[0] === '#'))
375
+ ) {
376
+ return absoluteToDoc(doc, value)
377
+ } else if (name === 'xlink:href' && value && value[0] !== '#') {
378
+ return absoluteToDoc(doc, value)
379
+ } else if (
380
+ name === 'background' &&
381
+ value &&
382
+ (tagName === 'table' || tagName === 'td' || tagName === 'th')
383
+ ) {
384
+ return absoluteToDoc(doc, value)
385
+ } else if (name === 'srcset' && value) {
386
+ return getAbsoluteSrcsetString(doc, value)
387
+ } else if (name === 'style' && value) {
388
+ return switchToAbsoluteUrl(value, getHref())
389
+ } else if (tagName === 'object' && name === 'data' && value) {
390
+ return absoluteToDoc(doc, value)
391
+ } else {
392
+ return value
393
+ }
394
+ }
395
+ function getHref() {
396
+ var a = document.createElement('a')
397
+ a.href = ''
398
+ return a.href
399
+ }
367
400
  function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
368
401
  if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
369
402
  return {}
@@ -382,7 +415,12 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
382
415
  options.configuration
383
416
  )
384
417
  if (attributeValue !== null) {
385
- safeAttrs[attributeName] = attributeValue
418
+ safeAttrs[attributeName] = transformAttribute(
419
+ doc,
420
+ tagName,
421
+ attributeName,
422
+ attributeValue
423
+ )
386
424
  }
387
425
  }
388
426
 
@@ -416,6 +454,7 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
416
454
  return s.href === element.href
417
455
  })
418
456
  var cssText = getCssRulesString(stylesheet)
457
+
419
458
  if (cssText && stylesheet) {
420
459
  safeAttrs._cssText = cssText
421
460
  }
@@ -465,8 +504,8 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
465
504
  /**
466
505
  * Serialize the scroll state for each element only for full snapshot
467
506
  */
468
- let scrollTop
469
- let scrollLeft
507
+ var scrollTop
508
+ var scrollLeft
470
509
  var serializationContext = options.serializationContext
471
510
  switch (serializationContext.status) {
472
511
  case SerializationContextStatus.INITIAL_FULL_SNAPSHOT:
@@ -10,14 +10,17 @@ export function createDeflateWorker() {
10
10
 
11
11
  function workerCodeFn() {
12
12
  monitor(function () {
13
- const { Deflate, constants, string2buf } = makePakoDeflate()
13
+ var _makePakoDeflate = makePakoDeflate()
14
+ var Deflate = _makePakoDeflate.Deflate
15
+ var constants = _makePakoDeflate.constants
16
+ var string2buf = _makePakoDeflate.string2buf
14
17
 
15
- let deflate = new Deflate()
16
- let rawBytesCount = 0
18
+ var deflate = new Deflate()
19
+ var rawBytesCount = 0
17
20
  self.addEventListener(
18
21
  'message',
19
- monitor((event) => {
20
- const data = event.data
22
+ monitor(function (event) {
23
+ var data = event.data
21
24
  switch (data.action) {
22
25
  case 'init':
23
26
  self.postMessage({
@@ -25,20 +28,23 @@ function workerCodeFn() {
25
28
  })
26
29
  break
27
30
  case 'write': {
28
- const additionalBytesCount = pushData(data.data)
31
+ var additionalBytesCount = pushData(data.data)
29
32
  self.postMessage({
30
33
  type: 'wrote',
31
34
  id: data.id,
32
- compressedBytesCount: deflate.chunks.reduce(
33
- (total, chunk) => total + chunk.length,
34
- 0
35
- ),
35
+ compressedBytesCount: deflate.chunks.reduce(function (
36
+ total,
37
+ chunk
38
+ ) {
39
+ return total + chunk.length
40
+ },
41
+ 0),
36
42
  additionalBytesCount
37
43
  })
38
44
  break
39
45
  }
40
46
  case 'flush': {
41
- const additionalBytesCount = data.data ? pushData(data.data) : 0
47
+ var additionalBytesCount = data.data ? pushData(data.data) : 0
42
48
  deflate.push('', constants.Z_FINISH)
43
49
  self.postMessage({
44
50
  type: 'flushed',
@@ -57,7 +63,7 @@ function workerCodeFn() {
57
63
 
58
64
  function pushData(data) {
59
65
  // TextEncoder is not supported on old browser version like Edge 18, therefore we use string2buf
60
- const binaryData = string2buf(data)
66
+ var binaryData = string2buf(data)
61
67
  deflate.push(binaryData, constants.Z_SYNC_FLUSH)
62
68
  rawBytesCount += binaryData.length
63
69
  return binaryData.length
@@ -69,6 +75,7 @@ function workerCodeFn() {
69
75
  try {
70
76
  return fn.apply(this, arguments)
71
77
  } catch (e) {
78
+ console.error('===monitor', e)
72
79
  try {
73
80
  self.postMessage({
74
81
  type: 'errored',
@@ -35,7 +35,6 @@ export function Segment(
35
35
  if (data.type === 'errored' || data.type === 'initialized') {
36
36
  return
37
37
  }
38
-
39
38
  if (data.id === _this.id) {
40
39
  replayStats.addWroteData(viewId, data.additionalBytesCount)
41
40
  if (data.type === 'flushed') {
@@ -67,6 +67,7 @@ export function doStartDeflateWorker(createDeflateWorkerImpl) {
67
67
  worker.postMessage({ action: 'init' })
68
68
  return worker
69
69
  } catch (error) {
70
+ console.errror('====doStartDeflateWorker', error)
70
71
  onError(error)
71
72
  }
72
73
  }
@@ -75,7 +75,7 @@ function computeSessionState(configuration, rawTrackingType) {
75
75
  var trackingType
76
76
  if (hasValidRumSession(rawTrackingType)) {
77
77
  trackingType = rawTrackingType
78
- } else if (!performDraw(configuration.sampleRate)) {
78
+ } else if (!performDraw(configuration.sessionSampleRate)) {
79
79
  trackingType = RumTrackingType.NOT_TRACKED
80
80
  } else if (!performDraw(configuration.sessionReplaySampleRate)) {
81
81
  trackingType = RumTrackingType.TRACKED_WITHOUT_SESSION_REPLAY