Skip to content

Commit e60cd02

Browse files
feat(replay): Add more default block filters (#7233)
1 parent e25c067 commit e60cd02

File tree

8 files changed

+23
-18
lines changed

8 files changed

+23
-18
lines changed

packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-chromium.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
"type": 2,
3333
"tagName": "link",
3434
"attributes": {
35-
"rel": "icon",
36-
"type": "image/png",
37-
"href": "file://assets/icon/favicon.png"
35+
"rr_width": "[0-50]px",
36+
"rr_height": "[0-50]px"
3837
},
3938
"childNodes": [],
4039
"id": 6

packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-firefox.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
"type": 2,
3333
"tagName": "link",
3434
"attributes": {
35-
"rel": "icon",
36-
"type": "image/png",
37-
"href": "file:///icon/favicon.png"
35+
"rr_width": "[0-50]px",
36+
"rr_height": "[0-50]px"
3837
},
3938
"childNodes": [],
4039
"id": 6

packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-webkit.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
"type": 2,
3333
"tagName": "link",
3434
"attributes": {
35-
"rel": "icon",
36-
"type": "image/png",
37-
"href": "file://assets/icon/favicon.png"
35+
"rr_width": "[0-50]px",
36+
"rr_height": "[0-50]px"
3837
},
3938
"childNodes": [],
4039
"id": 6

packages/replay/src/integration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import type { RecordingOptions, ReplayConfiguration, ReplayPluginOptions } from
88
import { getPrivacyOptions } from './util/getPrivacyOptions';
99
import { isBrowser } from './util/isBrowser';
1010

11-
const MEDIA_SELECTORS = 'img,image,svg,video,object,picture,embed,map,audio';
11+
const MEDIA_SELECTORS =
12+
'img,image,svg,video,object,picture,embed,map,audio,link[rel="icon"],link[rel="apple-touch-icon"]';
1213

1314
let _initialized = false;
1415

packages/replay/src/util/getPrivacyOptions.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export function getPrivacyOptions({
6969
// eslint-disable-next-line deprecation/deprecation
7070
ignoreClass,
7171
}: GetPrivacyOptions): GetPrivacyReturn {
72+
const defaultBlockedElements = ['base[href="/"]'];
73+
7274
const maskSelector = getOption(mask, ['.sentry-mask', '[data-sentry-mask]'], maskTextClass, maskTextSelector);
7375
const unmaskSelector = getOption(unmask, ['.sentry-unmask', '[data-sentry-unmask]']);
7476

@@ -79,7 +81,12 @@ export function getPrivacyOptions({
7981
maskInputSelector: maskSelector,
8082
unmaskInputSelector: unmaskSelector,
8183

82-
blockSelector: getOption(block, ['.sentry-block', '[data-sentry-block]'], blockClass, blockSelector),
84+
blockSelector: getOption(
85+
block,
86+
['.sentry-block', '[data-sentry-block]', ...defaultBlockedElements],
87+
blockClass,
88+
blockSelector,
89+
),
8390
unblockSelector: getOption(unblock, ['.sentry-unblock', '[data-sentry-unblock]']),
8491
ignoreSelector: getOption(ignore, ['.sentry-ignore', '[data-sentry-ignore]'], ignoreClass),
8592
};

packages/replay/test/integration/integrationSettings.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ describe('Integration | integrationSettings', () => {
99
it('sets the correct configuration when `blockAllMedia` is disabled', async () => {
1010
const { replay } = await mockSdk({ replayOptions: { blockAllMedia: false } });
1111

12-
expect(replay['_recordingOptions'].blockSelector).toBe('.sentry-block,[data-sentry-block]');
12+
expect(replay['_recordingOptions'].blockSelector).toBe('.sentry-block,[data-sentry-block],base[href="/"]');
1313
});
1414

1515
it('sets the correct configuration when `blockSelector` is empty and `blockAllMedia` is enabled', async () => {
1616
const { replay } = await mockSdk({ replayOptions: { blockSelector: '' } });
1717

1818
expect(replay['_recordingOptions'].blockSelector).toMatchInlineSnapshot(
19-
'",.sentry-block,[data-sentry-block],img,image,svg,video,object,picture,embed,map,audio"',
19+
'",.sentry-block,[data-sentry-block],base[href=\\"/\\"],img,image,svg,video,object,picture,embed,map,audio,link[rel=\\"icon\\"],link[rel=\\"apple-touch-icon\\"]"',
2020
);
2121
});
2222

@@ -26,7 +26,7 @@ describe('Integration | integrationSettings', () => {
2626
});
2727

2828
expect(replay['_recordingOptions'].blockSelector).toMatchInlineSnapshot(
29-
'"[data-test-blockSelector],.sentry-block,[data-sentry-block],img,image,svg,video,object,picture,embed,map,audio"',
29+
'"[data-test-blockSelector],.sentry-block,[data-sentry-block],base[href=\\"/\\"],img,image,svg,video,object,picture,embed,map,audio,link[rel=\\"icon\\"],link[rel=\\"apple-touch-icon\\"]"',
3030
);
3131
});
3232
});

packages/replay/test/integration/rrweb.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Integration | rrweb', () => {
1717
});
1818
expect(mockRecord.mock.calls[0][0]).toMatchInlineSnapshot(`
1919
Object {
20-
"blockSelector": ".sentry-block,[data-sentry-block],img,image,svg,video,object,picture,embed,map,audio",
20+
"blockSelector": ".sentry-block,[data-sentry-block],base[href=\\"/\\"],img,image,svg,video,object,picture,embed,map,audio,link[rel=\\"icon\\"],link[rel=\\"apple-touch-icon\\"]",
2121
"collectFonts": true,
2222
"emit": [Function],
2323
"ignoreSelector": ".sentry-test-ignore,.sentry-ignore,[data-sentry-ignore]",

packages/replay/test/unit/util/getPrivacyOptions.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Unit | util | getPrivacyOptions', () => {
1919
}),
2020
).toMatchInlineSnapshot(`
2121
Object {
22-
"blockSelector": ".custom-block,.sentry-block,[data-sentry-block]",
22+
"blockSelector": ".custom-block,.sentry-block,[data-sentry-block],base[href=\\"/\\"]",
2323
"ignoreSelector": ".custom-ignore,.sentry-ignore,[data-sentry-ignore]",
2424
"maskInputSelector": ".custom-mask,.sentry-mask,[data-sentry-mask]",
2525
"maskTextSelector": ".custom-mask,.sentry-mask,[data-sentry-mask]",
@@ -47,7 +47,7 @@ describe('Unit | util | getPrivacyOptions', () => {
4747
}),
4848
).toMatchInlineSnapshot(`
4949
Object {
50-
"blockSelector": ".custom-block,.deprecated-block-selector,.sentry-block,[data-sentry-block],.deprecated-block-class",
50+
"blockSelector": ".custom-block,.deprecated-block-selector,.sentry-block,[data-sentry-block],base[href=\\"/\\"],.deprecated-block-class",
5151
"ignoreSelector": ".custom-ignore,.sentry-ignore,[data-sentry-ignore],.deprecated-ignore-class",
5252
"maskInputSelector": ".custom-mask,.deprecated-mask-selector,.sentry-mask,[data-sentry-mask],.deprecated-mask-class",
5353
"maskTextSelector": ".custom-mask,.deprecated-mask-selector,.sentry-mask,[data-sentry-mask],.deprecated-mask-class",
@@ -73,7 +73,7 @@ describe('Unit | util | getPrivacyOptions', () => {
7373
).toMatchInlineSnapshot(`
7474
Object {
7575
"blockClass": /deprecated-block-\\*/,
76-
"blockSelector": ".custom-block,.sentry-block,[data-sentry-block]",
76+
"blockSelector": ".custom-block,.sentry-block,[data-sentry-block],base[href=\\"/\\"]",
7777
"ignoreSelector": ".custom-ignore,.sentry-ignore,[data-sentry-ignore]",
7878
"maskInputSelector": ".custom-mask,.sentry-mask,[data-sentry-mask]",
7979
"maskTextClass": /deprecated-mask-\\*/,

0 commit comments

Comments
 (0)