From 60c225240cef11fb71093a238dfbc0ad5c54af69 Mon Sep 17 00:00:00 2001 From: Lucas Date: Tue, 21 Feb 2023 00:15:47 +0900 Subject: [PATCH 01/10] Add additional block filters --- packages/replay/src/integration.ts | 2 +- packages/replay/src/util/getPrivacyOptions.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/replay/src/integration.ts b/packages/replay/src/integration.ts index 7d55c555042a..b0da1ef20782 100644 --- a/packages/replay/src/integration.ts +++ b/packages/replay/src/integration.ts @@ -8,7 +8,7 @@ import type { RecordingOptions, ReplayConfiguration, ReplayPluginOptions } from import { getPrivacyOptions } from './util/getPrivacyOptions'; import { isBrowser } from './util/isBrowser'; -const MEDIA_SELECTORS = 'img,image,svg,video,object,picture,embed,map,audio'; +const MEDIA_SELECTORS = 'img,image,svg,video,object,picture,embed,map,audio,link[rel="icon"],link[rel="apple-touch-icon"]'; let _initialized = false; diff --git a/packages/replay/src/util/getPrivacyOptions.ts b/packages/replay/src/util/getPrivacyOptions.ts index c5943e46f491..b1d13ff37775 100644 --- a/packages/replay/src/util/getPrivacyOptions.ts +++ b/packages/replay/src/util/getPrivacyOptions.ts @@ -79,7 +79,7 @@ export function getPrivacyOptions({ maskInputSelector: maskSelector, unmaskInputSelector: unmaskSelector, - blockSelector: getOption(block, ['.sentry-block', '[data-sentry-block]'], blockClass, blockSelector), + blockSelector: getOption(block, ['.sentry-block', '[data-sentry-block]', 'base[href="/"]'], blockClass, blockSelector), unblockSelector: getOption(unblock, ['.sentry-unblock', '[data-sentry-unblock]']), ignoreSelector: getOption(ignore, ['.sentry-ignore', '[data-sentry-ignore]'], ignoreClass), }; From 3e44dacb360352e5a8998c850fe50ecfbab36b90 Mon Sep 17 00:00:00 2001 From: Lucas Date: Tue, 21 Feb 2023 00:46:01 +0900 Subject: [PATCH 02/10] fix prettier --- packages/replay/src/integration.ts | 3 ++- packages/replay/src/util/getPrivacyOptions.ts | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/replay/src/integration.ts b/packages/replay/src/integration.ts index b0da1ef20782..c08eb0431cac 100644 --- a/packages/replay/src/integration.ts +++ b/packages/replay/src/integration.ts @@ -8,7 +8,8 @@ import type { RecordingOptions, ReplayConfiguration, ReplayPluginOptions } from import { getPrivacyOptions } from './util/getPrivacyOptions'; import { isBrowser } from './util/isBrowser'; -const MEDIA_SELECTORS = 'img,image,svg,video,object,picture,embed,map,audio,link[rel="icon"],link[rel="apple-touch-icon"]'; +const MEDIA_SELECTORS = + 'img,image,svg,video,object,picture,embed,map,audio,link[rel="icon"],link[rel="apple-touch-icon"]'; let _initialized = false; diff --git a/packages/replay/src/util/getPrivacyOptions.ts b/packages/replay/src/util/getPrivacyOptions.ts index b1d13ff37775..2263bcfe8a3a 100644 --- a/packages/replay/src/util/getPrivacyOptions.ts +++ b/packages/replay/src/util/getPrivacyOptions.ts @@ -79,7 +79,12 @@ export function getPrivacyOptions({ maskInputSelector: maskSelector, unmaskInputSelector: unmaskSelector, - blockSelector: getOption(block, ['.sentry-block', '[data-sentry-block]', 'base[href="/"]'], blockClass, blockSelector), + blockSelector: getOption( + block, + ['.sentry-block', '[data-sentry-block]', 'base[href="/"]'], + blockClass, + blockSelector, + ), unblockSelector: getOption(unblock, ['.sentry-unblock', '[data-sentry-unblock]']), ignoreSelector: getOption(ignore, ['.sentry-ignore', '[data-sentry-ignore]'], ignoreClass), }; From 6d7b8ace56965a77aa256dc18f66fca65f81b906 Mon Sep 17 00:00:00 2001 From: Lucas Date: Tue, 21 Feb 2023 21:09:56 +0900 Subject: [PATCH 03/10] isolated base block to const var --- packages/replay/src/util/getPrivacyOptions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/replay/src/util/getPrivacyOptions.ts b/packages/replay/src/util/getPrivacyOptions.ts index 2263bcfe8a3a..a8655bdf76af 100644 --- a/packages/replay/src/util/getPrivacyOptions.ts +++ b/packages/replay/src/util/getPrivacyOptions.ts @@ -69,6 +69,8 @@ export function getPrivacyOptions({ // eslint-disable-next-line deprecation/deprecation ignoreClass, }: GetPrivacyOptions): GetPrivacyReturn { + const defaultBlockedElements = ['base[href="/"]']; + const maskSelector = getOption(mask, ['.sentry-mask', '[data-sentry-mask]'], maskTextClass, maskTextSelector); const unmaskSelector = getOption(unmask, ['.sentry-unmask', '[data-sentry-unmask]']); @@ -81,7 +83,7 @@ export function getPrivacyOptions({ blockSelector: getOption( block, - ['.sentry-block', '[data-sentry-block]', 'base[href="/"]'], + ['.sentry-block', '[data-sentry-block]', ...defaultBlockedElements], blockClass, blockSelector, ), From d6da7068ad1d773556a561ea7caaf8feeedbd453 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 22 Feb 2023 01:15:12 +0900 Subject: [PATCH 04/10] fix changes --- .../test.ts-snapshots/seg-1-snap-incremental-chromium | 2 +- .../replay/test/integration/integrationSettings.test.ts | 6 +++--- packages/replay/test/integration/rrweb.test.ts | 2 +- packages/replay/test/unit/util/getPrivacyOptions.test.ts | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-1-snap-incremental-chromium b/packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-1-snap-incremental-chromium index fd46cda96828..f7b4b32ab1ee 100644 --- a/packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-1-snap-incremental-chromium +++ b/packages/integration-tests/suites/replay/multiple-pages/test.ts-snapshots/seg-1-snap-incremental-chromium @@ -6,7 +6,7 @@ "x": 41, "y": 18, "id": 9, - "timeOffset": 0 + "timeOffset": -1 } ] }, diff --git a/packages/replay/test/integration/integrationSettings.test.ts b/packages/replay/test/integration/integrationSettings.test.ts index d0f75afdb285..425baa2751cb 100644 --- a/packages/replay/test/integration/integrationSettings.test.ts +++ b/packages/replay/test/integration/integrationSettings.test.ts @@ -9,14 +9,14 @@ describe('Integration | integrationSettings', () => { it('sets the correct configuration when `blockAllMedia` is disabled', async () => { const { replay } = await mockSdk({ replayOptions: { blockAllMedia: false } }); - expect(replay['_recordingOptions'].blockSelector).toBe('.sentry-block,[data-sentry-block]'); + expect(replay['_recordingOptions'].blockSelector).toBe('.sentry-block,[data-sentry-block],base[href=\"/\"]'); }); it('sets the correct configuration when `blockSelector` is empty and `blockAllMedia` is enabled', async () => { const { replay } = await mockSdk({ replayOptions: { blockSelector: '' } }); expect(replay['_recordingOptions'].blockSelector).toMatchInlineSnapshot( - '",.sentry-block,[data-sentry-block],img,image,svg,video,object,picture,embed,map,audio"', + '",.sentry-block,[data-sentry-block],base[href=\"/\"],img,image,svg,video,object,picture,embed,map,audio"', ); }); @@ -26,7 +26,7 @@ describe('Integration | integrationSettings', () => { }); expect(replay['_recordingOptions'].blockSelector).toMatchInlineSnapshot( - '"[data-test-blockSelector],.sentry-block,[data-sentry-block],img,image,svg,video,object,picture,embed,map,audio"', + '"[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\"]"', ); }); }); diff --git a/packages/replay/test/integration/rrweb.test.ts b/packages/replay/test/integration/rrweb.test.ts index 05d46c93193e..83932bbd3e31 100644 --- a/packages/replay/test/integration/rrweb.test.ts +++ b/packages/replay/test/integration/rrweb.test.ts @@ -17,7 +17,7 @@ describe('Integration | rrweb', () => { }); expect(mockRecord.mock.calls[0][0]).toMatchInlineSnapshot(` Object { - "blockSelector": ".sentry-block,[data-sentry-block],img,image,svg,video,object,picture,embed,map,audio", + "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\"]', "collectFonts": true, "emit": [Function], "ignoreSelector": ".sentry-test-ignore,.sentry-ignore,[data-sentry-ignore]", diff --git a/packages/replay/test/unit/util/getPrivacyOptions.test.ts b/packages/replay/test/unit/util/getPrivacyOptions.test.ts index 689f9b573f0f..2034c1b93187 100644 --- a/packages/replay/test/unit/util/getPrivacyOptions.test.ts +++ b/packages/replay/test/unit/util/getPrivacyOptions.test.ts @@ -2,7 +2,7 @@ import { getPrivacyOptions } from '../../../src/util/getPrivacyOptions'; describe('Unit | util | getPrivacyOptions', () => { beforeEach(() => { - jest.spyOn(console, 'warn').mockImplementation(() => {}); + jest.spyOn(console, 'warn').mockImplementation(() => { }); }); afterEach(() => { jest.clearAllMocks(); @@ -73,7 +73,7 @@ describe('Unit | util | getPrivacyOptions', () => { ).toMatchInlineSnapshot(` Object { "blockClass": /deprecated-block-\\*/, - "blockSelector": ".custom-block,.sentry-block,[data-sentry-block]", + "blockSelector": '.custom-block,.sentry-block,[data-sentry-block],base[href="/"]', "ignoreSelector": ".custom-ignore,.sentry-ignore,[data-sentry-ignore]", "maskInputSelector": ".custom-mask,.sentry-mask,[data-sentry-mask]", "maskTextClass": /deprecated-mask-\\*/, From 310480e69e37f6a198f3328fc5482cbb24412e57 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 22 Feb 2023 21:01:00 +0900 Subject: [PATCH 05/10] fix snapshot --- .../privacyDefault/test.ts-snapshots/privacy-chromium.json | 5 ++--- .../privacyDefault/test.ts-snapshots/privacy-firefox.json | 5 ++--- .../privacyDefault/test.ts-snapshots/privacy-webkit.json | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-chromium.json b/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-chromium.json index f31f8b967d12..11bf6d7a7fa7 100644 --- a/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-chromium.json +++ b/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-chromium.json @@ -32,9 +32,8 @@ "type": 2, "tagName": "link", "attributes": { - "rel": "icon", - "type": "image/png", - "href": "file://assets/icon/favicon.png" + "rr_width": "[0-50]px", + "rr_height": "[0-50]px" }, "childNodes": [], "id": 6 diff --git a/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-firefox.json b/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-firefox.json index d33a2d86b730..11bf6d7a7fa7 100644 --- a/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-firefox.json +++ b/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-firefox.json @@ -32,9 +32,8 @@ "type": 2, "tagName": "link", "attributes": { - "rel": "icon", - "type": "image/png", - "href": "file:///icon/favicon.png" + "rr_width": "[0-50]px", + "rr_height": "[0-50]px" }, "childNodes": [], "id": 6 diff --git a/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-webkit.json b/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-webkit.json index f31f8b967d12..11bf6d7a7fa7 100644 --- a/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-webkit.json +++ b/packages/integration-tests/suites/replay/privacyDefault/test.ts-snapshots/privacy-webkit.json @@ -32,9 +32,8 @@ "type": 2, "tagName": "link", "attributes": { - "rel": "icon", - "type": "image/png", - "href": "file://assets/icon/favicon.png" + "rr_width": "[0-50]px", + "rr_height": "[0-50]px" }, "childNodes": [], "id": 6 From 32a20fe52a804b86184aa71f834de09c316fb80d Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 22 Feb 2023 21:43:40 +0900 Subject: [PATCH 06/10] fix tests --- .../replay/test/integration/integrationSettings.test.ts | 4 ++-- packages/replay/test/integration/rrweb.test.ts | 2 +- packages/replay/test/unit/util/getPrivacyOptions.test.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/replay/test/integration/integrationSettings.test.ts b/packages/replay/test/integration/integrationSettings.test.ts index 425baa2751cb..b36b236a59a1 100644 --- a/packages/replay/test/integration/integrationSettings.test.ts +++ b/packages/replay/test/integration/integrationSettings.test.ts @@ -16,7 +16,7 @@ describe('Integration | integrationSettings', () => { const { replay } = await mockSdk({ replayOptions: { blockSelector: '' } }); expect(replay['_recordingOptions'].blockSelector).toMatchInlineSnapshot( - '",.sentry-block,[data-sentry-block],base[href=\"/\"],img,image,svg,video,object,picture,embed,map,audio"', + '",.sentry-block,[data-sentry-block],base[href=\\"/\\"],img,image,svg,video,object,picture,embed,map,audio,link[rel=\\"icon\\"],link[rel=\\"apple-touch-icon\\"]"', ); }); @@ -26,7 +26,7 @@ describe('Integration | integrationSettings', () => { }); expect(replay['_recordingOptions'].blockSelector).toMatchInlineSnapshot( - '"[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\"]"', + '"[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\\"]"', ); }); }); diff --git a/packages/replay/test/integration/rrweb.test.ts b/packages/replay/test/integration/rrweb.test.ts index 83932bbd3e31..6d324d96208e 100644 --- a/packages/replay/test/integration/rrweb.test.ts +++ b/packages/replay/test/integration/rrweb.test.ts @@ -17,7 +17,7 @@ describe('Integration | rrweb', () => { }); expect(mockRecord.mock.calls[0][0]).toMatchInlineSnapshot(` Object { - "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\"]', + "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\\"]", "collectFonts": true, "emit": [Function], "ignoreSelector": ".sentry-test-ignore,.sentry-ignore,[data-sentry-ignore]", diff --git a/packages/replay/test/unit/util/getPrivacyOptions.test.ts b/packages/replay/test/unit/util/getPrivacyOptions.test.ts index 2034c1b93187..7c4d99708e69 100644 --- a/packages/replay/test/unit/util/getPrivacyOptions.test.ts +++ b/packages/replay/test/unit/util/getPrivacyOptions.test.ts @@ -19,7 +19,7 @@ describe('Unit | util | getPrivacyOptions', () => { }), ).toMatchInlineSnapshot(` Object { - "blockSelector": ".custom-block,.sentry-block,[data-sentry-block]", + "blockSelector": ".custom-block,.sentry-block,[data-sentry-block],base[href=\\"/\\"]", "ignoreSelector": ".custom-ignore,.sentry-ignore,[data-sentry-ignore]", "maskInputSelector": ".custom-mask,.sentry-mask,[data-sentry-mask]", "maskTextSelector": ".custom-mask,.sentry-mask,[data-sentry-mask]", @@ -47,7 +47,7 @@ describe('Unit | util | getPrivacyOptions', () => { }), ).toMatchInlineSnapshot(` Object { - "blockSelector": ".custom-block,.deprecated-block-selector,.sentry-block,[data-sentry-block],.deprecated-block-class", + "blockSelector": ".custom-block,.deprecated-block-selector,.sentry-block,[data-sentry-block],base[href=\\"/\\"],.deprecated-block-class", "ignoreSelector": ".custom-ignore,.sentry-ignore,[data-sentry-ignore],.deprecated-ignore-class", "maskInputSelector": ".custom-mask,.deprecated-mask-selector,.sentry-mask,[data-sentry-mask],.deprecated-mask-class", "maskTextSelector": ".custom-mask,.deprecated-mask-selector,.sentry-mask,[data-sentry-mask],.deprecated-mask-class", @@ -73,7 +73,7 @@ describe('Unit | util | getPrivacyOptions', () => { ).toMatchInlineSnapshot(` Object { "blockClass": /deprecated-block-\\*/, - "blockSelector": '.custom-block,.sentry-block,[data-sentry-block],base[href="/"]', + "blockSelector": ".custom-block,.sentry-block,[data-sentry-block],base[href=\\"/\\"]", "ignoreSelector": ".custom-ignore,.sentry-ignore,[data-sentry-ignore]", "maskInputSelector": ".custom-mask,.sentry-mask,[data-sentry-mask]", "maskTextClass": /deprecated-mask-\\*/, From ce813b89ecfea2a1b118c546d045216de77b94c0 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 22 Feb 2023 21:57:08 +0900 Subject: [PATCH 07/10] fix lint --- packages/replay/test/integration/integrationSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/replay/test/integration/integrationSettings.test.ts b/packages/replay/test/integration/integrationSettings.test.ts index b36b236a59a1..b178e7423f9a 100644 --- a/packages/replay/test/integration/integrationSettings.test.ts +++ b/packages/replay/test/integration/integrationSettings.test.ts @@ -9,7 +9,7 @@ describe('Integration | integrationSettings', () => { it('sets the correct configuration when `blockAllMedia` is disabled', async () => { const { replay } = await mockSdk({ replayOptions: { blockAllMedia: false } }); - expect(replay['_recordingOptions'].blockSelector).toBe('.sentry-block,[data-sentry-block],base[href=\"/\"]'); + expect(replay['_recordingOptions'].blockSelector).toBe('.sentry-block,[data-sentry-block],base[href=\\"/\\"]'); }); it('sets the correct configuration when `blockSelector` is empty and `blockAllMedia` is enabled', async () => { From 79d575cc70678b0985aa8b36dc034b1ad6f6e6d9 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 22 Feb 2023 22:08:44 +0900 Subject: [PATCH 08/10] fix prettier --- packages/replay/test/unit/util/getPrivacyOptions.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/replay/test/unit/util/getPrivacyOptions.test.ts b/packages/replay/test/unit/util/getPrivacyOptions.test.ts index 7c4d99708e69..3f13f6410a35 100644 --- a/packages/replay/test/unit/util/getPrivacyOptions.test.ts +++ b/packages/replay/test/unit/util/getPrivacyOptions.test.ts @@ -2,7 +2,7 @@ import { getPrivacyOptions } from '../../../src/util/getPrivacyOptions'; describe('Unit | util | getPrivacyOptions', () => { beforeEach(() => { - jest.spyOn(console, 'warn').mockImplementation(() => { }); + jest.spyOn(console, 'warn').mockImplementation(() => {}); }); afterEach(() => { jest.clearAllMocks(); From 912aef98c98793218b623a73a979ed1f700799d5 Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 22 Feb 2023 22:18:34 +0900 Subject: [PATCH 09/10] nit test --- packages/replay/test/integration/integrationSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/replay/test/integration/integrationSettings.test.ts b/packages/replay/test/integration/integrationSettings.test.ts index b178e7423f9a..b36b236a59a1 100644 --- a/packages/replay/test/integration/integrationSettings.test.ts +++ b/packages/replay/test/integration/integrationSettings.test.ts @@ -9,7 +9,7 @@ describe('Integration | integrationSettings', () => { it('sets the correct configuration when `blockAllMedia` is disabled', async () => { const { replay } = await mockSdk({ replayOptions: { blockAllMedia: false } }); - expect(replay['_recordingOptions'].blockSelector).toBe('.sentry-block,[data-sentry-block],base[href=\\"/\\"]'); + expect(replay['_recordingOptions'].blockSelector).toBe('.sentry-block,[data-sentry-block],base[href=\"/\"]'); }); it('sets the correct configuration when `blockSelector` is empty and `blockAllMedia` is enabled', async () => { From 0b70fa3ce15461e3ebec4b14117299d4f5cb920d Mon Sep 17 00:00:00 2001 From: Lucas Date: Wed, 22 Feb 2023 22:37:54 +0900 Subject: [PATCH 10/10] fix link on replay --- packages/replay/test/integration/integrationSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/replay/test/integration/integrationSettings.test.ts b/packages/replay/test/integration/integrationSettings.test.ts index b36b236a59a1..9f92c9833145 100644 --- a/packages/replay/test/integration/integrationSettings.test.ts +++ b/packages/replay/test/integration/integrationSettings.test.ts @@ -9,7 +9,7 @@ describe('Integration | integrationSettings', () => { it('sets the correct configuration when `blockAllMedia` is disabled', async () => { const { replay } = await mockSdk({ replayOptions: { blockAllMedia: false } }); - expect(replay['_recordingOptions'].blockSelector).toBe('.sentry-block,[data-sentry-block],base[href=\"/\"]'); + expect(replay['_recordingOptions'].blockSelector).toBe('.sentry-block,[data-sentry-block],base[href="/"]'); }); it('sets the correct configuration when `blockSelector` is empty and `blockAllMedia` is enabled', async () => {