@cloudcare/browser-rum 3.0.1 → 3.0.3
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.
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/domain/replay/record/privacy.js +1 -3
- package/cjs/domain/replay/record/serializationUtils.js +101 -0
- package/cjs/domain/replay/record/serialize.js +40 -13
- package/cjs/domain/rumSessionManager.js +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/domain/replay/record/privacy.js +1 -3
- package/esm/domain/replay/record/serializationUtils.js +97 -0
- package/esm/domain/replay/record/serialize.js +41 -14
- package/esm/domain/rumSessionManager.js +1 -1
- package/package.json +2 -2
- package/src/domain/replay/record/privacy.js +1 -1
- package/src/domain/replay/record/serializationUtils.js +81 -2
- package/src/domain/replay/record/serialize.js +51 -12
- package/src/domain/rumSessionManager.js +1 -1
|
@@ -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
|
|
229
|
+
var parentTagName = textNode.parentElement && textNode.parentElement.tagName
|
|
228
230
|
var textContent = getTextContent(
|
|
229
231
|
textNode,
|
|
230
232
|
options.ignoreWhiteSpace || false,
|
|
@@ -336,17 +338,21 @@ function getValidTagName(tagName) {
|
|
|
336
338
|
return processedTagName
|
|
337
339
|
}
|
|
338
340
|
|
|
339
|
-
function getCssRulesString(
|
|
340
|
-
|
|
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
|
-
}
|
|
341
|
+
function getCssRulesString(cssStyleSheet) {
|
|
342
|
+
if (!cssStyleSheet) {
|
|
346
343
|
return null
|
|
347
|
-
}
|
|
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) {
|
|
348
352
|
return null
|
|
349
353
|
}
|
|
354
|
+
var styleSheetCssText = Array.from(rules, getCssRuleString).join('')
|
|
355
|
+
return switchToAbsoluteUrl(styleSheetCssText, cssStyleSheet.href)
|
|
350
356
|
}
|
|
351
357
|
|
|
352
358
|
function getCssRuleString(rule) {
|
|
@@ -362,7 +368,35 @@ function isCSSImportRule(rule) {
|
|
|
362
368
|
function isSVGElement(el) {
|
|
363
369
|
return el.tagName === 'svg' || el instanceof SVGElement
|
|
364
370
|
}
|
|
365
|
-
|
|
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
|
+
}
|
|
366
400
|
function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
367
401
|
if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
|
|
368
402
|
return {}
|
|
@@ -381,7 +415,12 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
|
381
415
|
options.configuration
|
|
382
416
|
)
|
|
383
417
|
if (attributeValue !== null) {
|
|
384
|
-
safeAttrs[attributeName] =
|
|
418
|
+
safeAttrs[attributeName] = transformAttribute(
|
|
419
|
+
doc,
|
|
420
|
+
tagName,
|
|
421
|
+
attributeName,
|
|
422
|
+
attributeValue
|
|
423
|
+
)
|
|
385
424
|
}
|
|
386
425
|
}
|
|
387
426
|
|
|
@@ -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.
|
|
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
|