@sentry/replay 7.38.0 → 7.40.0
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/cjs/index.js +55 -35
- package/cjs/index.js.map +1 -1
- package/esm/index.js +55 -35
- package/esm/index.js.map +1 -1
- package/package.json +6 -6
- package/types/integration.d.ts.map +1 -1
- package/types/util/getPrivacyOptions.d.ts.map +1 -1
package/cjs/index.js
CHANGED
|
@@ -51,13 +51,20 @@ function isShadowRoot(n) {
|
|
|
51
51
|
const host = n === null || n === void 0 ? void 0 : n.host;
|
|
52
52
|
return Boolean(host && host.shadowRoot && host.shadowRoot === n);
|
|
53
53
|
}
|
|
54
|
+
function isInputTypeMasked({ maskInputOptions, tagName, type, }) {
|
|
55
|
+
return (maskInputOptions[tagName.toLowerCase()] ||
|
|
56
|
+
maskInputOptions[type] ||
|
|
57
|
+
(tagName === 'input' && !type && maskInputOptions['text']));
|
|
58
|
+
}
|
|
59
|
+
function hasInputMaskOptions({ tagName, type, maskInputOptions, maskInputSelector, }) {
|
|
60
|
+
return (maskInputSelector || isInputTypeMasked({ maskInputOptions, tagName, type }));
|
|
61
|
+
}
|
|
54
62
|
function maskInputValue({ input, maskInputSelector, unmaskInputSelector, maskInputOptions, tagName, type, value, maskInputFn, }) {
|
|
55
63
|
let text = value || '';
|
|
56
64
|
if (unmaskInputSelector && input.matches(unmaskInputSelector)) {
|
|
57
65
|
return text;
|
|
58
66
|
}
|
|
59
|
-
if (maskInputOptions
|
|
60
|
-
maskInputOptions[type] ||
|
|
67
|
+
if (isInputTypeMasked({ maskInputOptions, tagName, type }) ||
|
|
61
68
|
(maskInputSelector && input.matches(maskInputSelector))) {
|
|
62
69
|
if (maskInputFn) {
|
|
63
70
|
text = maskInputFn(text);
|
|
@@ -92,7 +99,7 @@ let _id = 1;
|
|
|
92
99
|
const tagNameRegex = new RegExp('[^a-z0-9-_:]');
|
|
93
100
|
const IGNORED_NODE = -2;
|
|
94
101
|
function defaultMaskFn(str) {
|
|
95
|
-
return str.replace(/[\S]/g, '*');
|
|
102
|
+
return str ? str.replace(/[\S]/g, '*') : '';
|
|
96
103
|
}
|
|
97
104
|
function genId() {
|
|
98
105
|
return _id++;
|
|
@@ -263,32 +270,33 @@ function getHref() {
|
|
|
263
270
|
return a.href;
|
|
264
271
|
}
|
|
265
272
|
function transformAttribute(doc, tagName, name, value, maskAllText, maskTextFn) {
|
|
266
|
-
if (
|
|
273
|
+
if (!value) {
|
|
274
|
+
return value;
|
|
275
|
+
}
|
|
276
|
+
if (name === 'src' || name === 'href') {
|
|
267
277
|
return absoluteToDoc(doc, value);
|
|
268
278
|
}
|
|
269
|
-
else if (name === 'xlink:href' && value
|
|
279
|
+
else if (name === 'xlink:href' && value[0] !== '#') {
|
|
270
280
|
return absoluteToDoc(doc, value);
|
|
271
281
|
}
|
|
272
282
|
else if (name === 'background' &&
|
|
273
|
-
value &&
|
|
274
283
|
(tagName === 'table' || tagName === 'td' || tagName === 'th')) {
|
|
275
284
|
return absoluteToDoc(doc, value);
|
|
276
285
|
}
|
|
277
|
-
else if (name === 'srcset'
|
|
286
|
+
else if (name === 'srcset') {
|
|
278
287
|
return getAbsoluteSrcsetString(doc, value);
|
|
279
288
|
}
|
|
280
|
-
else if (name === 'style'
|
|
289
|
+
else if (name === 'style') {
|
|
281
290
|
return absoluteToStylesheet(value, getHref());
|
|
282
291
|
}
|
|
283
|
-
else if (tagName === 'object' && name === 'data'
|
|
292
|
+
else if (tagName === 'object' && name === 'data') {
|
|
284
293
|
return absoluteToDoc(doc, value);
|
|
285
294
|
}
|
|
286
|
-
else if (maskAllText &&
|
|
295
|
+
else if (maskAllText &&
|
|
296
|
+
['placeholder', 'title', 'aria-label'].indexOf(name) > -1) {
|
|
287
297
|
return maskTextFn ? maskTextFn(value) : defaultMaskFn(value);
|
|
288
298
|
}
|
|
289
|
-
|
|
290
|
-
return value;
|
|
291
|
-
}
|
|
299
|
+
return value;
|
|
292
300
|
}
|
|
293
301
|
function _isBlockedElement(element, blockClass, blockSelector, unblockSelector) {
|
|
294
302
|
if (unblockSelector && element.matches(unblockSelector)) {
|
|
@@ -422,7 +430,9 @@ function serializeNode(n, options) {
|
|
|
422
430
|
const tagName = getValidTagName(n);
|
|
423
431
|
let attributes = {};
|
|
424
432
|
for (const { name, value } of Array.from(n.attributes)) {
|
|
425
|
-
|
|
433
|
+
if (!skipAttribute(tagName, name)) {
|
|
434
|
+
attributes[name] = transformAttribute(doc, tagName, name, value, maskAllText, maskTextFn);
|
|
435
|
+
}
|
|
426
436
|
}
|
|
427
437
|
if (tagName === 'link' && inlineStylesheet) {
|
|
428
438
|
const stylesheet = Array.from(doc.styleSheets).find((s) => {
|
|
@@ -581,16 +591,7 @@ function serializeNode(n, options) {
|
|
|
581
591
|
textContent = 'SCRIPT_PLACEHOLDER';
|
|
582
592
|
}
|
|
583
593
|
if (parentTagName === 'TEXTAREA' && textContent) {
|
|
584
|
-
textContent =
|
|
585
|
-
input: n.parentNode,
|
|
586
|
-
maskInputSelector,
|
|
587
|
-
unmaskInputSelector,
|
|
588
|
-
maskInputOptions,
|
|
589
|
-
tagName: parentTagName,
|
|
590
|
-
type: null,
|
|
591
|
-
value: textContent,
|
|
592
|
-
maskInputFn,
|
|
593
|
-
});
|
|
594
|
+
textContent = '';
|
|
594
595
|
}
|
|
595
596
|
else if (!isStyle &&
|
|
596
597
|
!isScript &&
|
|
@@ -623,7 +624,7 @@ function serializeNode(n, options) {
|
|
|
623
624
|
}
|
|
624
625
|
}
|
|
625
626
|
function lowerIfExists(maybeAttr) {
|
|
626
|
-
if (maybeAttr === undefined) {
|
|
627
|
+
if (maybeAttr === undefined || maybeAttr === null) {
|
|
627
628
|
return '';
|
|
628
629
|
}
|
|
629
630
|
else {
|
|
@@ -638,7 +639,8 @@ function slimDOMExcluded(sn, slimDOMOptions) {
|
|
|
638
639
|
if (slimDOMOptions.script &&
|
|
639
640
|
(sn.tagName === 'script' ||
|
|
640
641
|
(sn.tagName === 'link' &&
|
|
641
|
-
sn.attributes.rel === 'preload'
|
|
642
|
+
(sn.attributes.rel === 'preload' ||
|
|
643
|
+
sn.attributes.rel === 'modulepreload') &&
|
|
642
644
|
sn.attributes.as === 'script') ||
|
|
643
645
|
(sn.tagName === 'link' &&
|
|
644
646
|
sn.attributes.rel === 'prefetch' &&
|
|
@@ -927,6 +929,9 @@ function snapshot(n, options) {
|
|
|
927
929
|
idNodeMap,
|
|
928
930
|
];
|
|
929
931
|
}
|
|
932
|
+
function skipAttribute(tagName, attributeName, value) {
|
|
933
|
+
return ((tagName === 'video' || tagName === 'audio') && attributeName === 'autoplay');
|
|
934
|
+
}
|
|
930
935
|
|
|
931
936
|
var EventType;
|
|
932
937
|
(function (EventType) {
|
|
@@ -1368,7 +1373,7 @@ class MutationBuffer {
|
|
|
1368
1373
|
((_e = (_d = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _d === void 0 ? void 0 : _d.call(rootShadowHost)) === null || _e === void 0 ? void 0 : _e.host) ||
|
|
1369
1374
|
null;
|
|
1370
1375
|
const notInDoc = !this.doc.contains(n) &&
|
|
1371
|
-
(rootShadowHost
|
|
1376
|
+
(!rootShadowHost || !this.doc.contains(rootShadowHost));
|
|
1372
1377
|
if (!n.parentNode || notInDoc) {
|
|
1373
1378
|
return;
|
|
1374
1379
|
}
|
|
@@ -1948,8 +1953,12 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, blockSelector, un
|
|
|
1948
1953
|
if (type === 'radio' || type === 'checkbox') {
|
|
1949
1954
|
isChecked = target.checked;
|
|
1950
1955
|
}
|
|
1951
|
-
else if (
|
|
1952
|
-
maskInputOptions
|
|
1956
|
+
else if (hasInputMaskOptions({
|
|
1957
|
+
maskInputOptions,
|
|
1958
|
+
maskInputSelector,
|
|
1959
|
+
tagName: target.tagName,
|
|
1960
|
+
type,
|
|
1961
|
+
})) {
|
|
1953
1962
|
text = maskInputValue({
|
|
1954
1963
|
input: target,
|
|
1955
1964
|
maskInputOptions,
|
|
@@ -4502,16 +4511,19 @@ function createLargestContentfulPaint(entry) {
|
|
|
4502
4511
|
startTimeOrNavigationActivation = (navEntry && navEntry.activationStart) || 0;
|
|
4503
4512
|
}
|
|
4504
4513
|
|
|
4505
|
-
|
|
4514
|
+
// value is in ms
|
|
4506
4515
|
const value = Math.max(startTime - startTimeOrNavigationActivation, 0);
|
|
4516
|
+
// LCP doesn't have a "duration", it just happens at a single point in time.
|
|
4517
|
+
// But the UI expects both, so use end (in seconds) for both timestamps.
|
|
4518
|
+
const end = getAbsoluteTime(startTimeOrNavigationActivation) + value / 1000;
|
|
4507
4519
|
|
|
4508
4520
|
return {
|
|
4509
4521
|
type: entryType,
|
|
4510
4522
|
name: entryType,
|
|
4511
|
-
start,
|
|
4512
|
-
end
|
|
4523
|
+
start: end,
|
|
4524
|
+
end,
|
|
4513
4525
|
data: {
|
|
4514
|
-
value,
|
|
4526
|
+
value, // LCP "duration" in ms
|
|
4515
4527
|
size,
|
|
4516
4528
|
// Not sure why this errors, Node should be correct (Argument of type 'Node' is not assignable to parameter of type 'INode')
|
|
4517
4529
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -5812,6 +5824,8 @@ function getPrivacyOptions({
|
|
|
5812
5824
|
// eslint-disable-next-line deprecation/deprecation
|
|
5813
5825
|
ignoreClass,
|
|
5814
5826
|
}) {
|
|
5827
|
+
const defaultBlockedElements = ['base[href="/"]'];
|
|
5828
|
+
|
|
5815
5829
|
const maskSelector = getOption(mask, ['.sentry-mask', '[data-sentry-mask]'], maskTextClass, maskTextSelector);
|
|
5816
5830
|
const unmaskSelector = getOption(unmask, ['.sentry-unmask', '[data-sentry-unmask]']);
|
|
5817
5831
|
|
|
@@ -5822,7 +5836,12 @@ function getPrivacyOptions({
|
|
|
5822
5836
|
maskInputSelector: maskSelector,
|
|
5823
5837
|
unmaskInputSelector: unmaskSelector,
|
|
5824
5838
|
|
|
5825
|
-
blockSelector: getOption(
|
|
5839
|
+
blockSelector: getOption(
|
|
5840
|
+
block,
|
|
5841
|
+
['.sentry-block', '[data-sentry-block]', ...defaultBlockedElements],
|
|
5842
|
+
blockClass,
|
|
5843
|
+
blockSelector,
|
|
5844
|
+
),
|
|
5826
5845
|
unblockSelector: getOption(unblock, ['.sentry-unblock', '[data-sentry-unblock]']),
|
|
5827
5846
|
ignoreSelector: getOption(ignore, ['.sentry-ignore', '[data-sentry-ignore]'], ignoreClass),
|
|
5828
5847
|
};
|
|
@@ -5851,7 +5870,8 @@ function isElectronNodeRenderer() {
|
|
|
5851
5870
|
return typeof process !== 'undefined' && (process ).type === 'renderer';
|
|
5852
5871
|
}
|
|
5853
5872
|
|
|
5854
|
-
const MEDIA_SELECTORS =
|
|
5873
|
+
const MEDIA_SELECTORS =
|
|
5874
|
+
'img,image,svg,video,object,picture,embed,map,audio,link[rel="icon"],link[rel="apple-touch-icon"]';
|
|
5855
5875
|
|
|
5856
5876
|
let _initialized = false;
|
|
5857
5877
|
|