Skip to content

Commit 3b1bcaf

Browse files
authored
fix(replay): Improve handling of maskAllText selector (#6637)
1 parent a23bda5 commit 3b1bcaf

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

packages/replay/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ export const DEFAULT_SESSION_SAMPLE_RATE = 0.1;
2727
export const DEFAULT_ERROR_SAMPLE_RATE = 1.0;
2828

2929
/** The select to use for the `maskAllText` option */
30-
export const MASK_ALL_TEXT_SELECTOR = 'body *:not(style,script)';
30+
export const MASK_ALL_TEXT_SELECTOR = 'body *:not(style), body *:not(script)';

packages/replay/src/integration.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export class Replay implements Integration {
4747
useCompression = true,
4848
sessionSampleRate,
4949
errorSampleRate,
50-
maskAllText = true,
50+
maskAllText,
51+
maskTextSelector,
5152
maskAllInputs = true,
5253
blockAllMedia = true,
5354
_experiments = {},
@@ -62,6 +63,7 @@ export class Replay implements Integration {
6263
blockClass,
6364
ignoreClass,
6465
maskTextClass,
66+
maskTextSelector,
6567
blockSelector,
6668
...recordingOptions,
6769
};
@@ -74,7 +76,7 @@ export class Replay implements Integration {
7476
sessionSampleRate: DEFAULT_SESSION_SAMPLE_RATE,
7577
errorSampleRate: DEFAULT_ERROR_SAMPLE_RATE,
7678
useCompression,
77-
maskAllText,
79+
maskAllText: typeof maskAllText === 'boolean' ? maskAllText : !maskTextSelector,
7880
blockAllMedia,
7981
_experiments,
8082
};

packages/replay/test/unit/index-integrationSettings.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ describe('integration settings', () => {
184184
expect(replay['_recordingOptions'].maskTextSelector).toBe(undefined);
185185
});
186186

187-
it('overwrites custom maskTextSelector option', async () => {
187+
it('maskTextSelector takes precedence over maskAllText when not specifiying maskAllText:true', async () => {
188+
const { replay } = await mockSdk({ replayOptions: { maskTextSelector: '[custom]' } });
189+
190+
expect(replay['_recordingOptions'].maskTextSelector).toBe('[custom]');
191+
});
192+
193+
it('maskAllText takes precedence over maskTextSelector when specifiying maskAllText:true', async () => {
188194
const { replay } = await mockSdk({ replayOptions: { maskAllText: true, maskTextSelector: '[custom]' } });
189195

190196
expect(replay['_recordingOptions'].maskTextSelector).toBe(MASK_ALL_TEXT_SELECTOR);

0 commit comments

Comments
 (0)