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