Skip to content

fix(replay): Improve handling of maskAllText selector #6637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/replay/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export const DEFAULT_SESSION_SAMPLE_RATE = 0.1;
export const DEFAULT_ERROR_SAMPLE_RATE = 1.0;

/** The select to use for the `maskAllText` option */
export const MASK_ALL_TEXT_SELECTOR = 'body *:not(style,script)';
export const MASK_ALL_TEXT_SELECTOR = 'body *:not(style), body *:not(script)';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

6 changes: 4 additions & 2 deletions packages/replay/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export class Replay implements Integration {
useCompression = true,
sessionSampleRate,
errorSampleRate,
maskAllText = true,
maskAllText,
maskTextSelector,
maskAllInputs = true,
blockAllMedia = true,
_experiments = {},
Expand All @@ -62,6 +63,7 @@ export class Replay implements Integration {
blockClass,
ignoreClass,
maskTextClass,
maskTextSelector,
blockSelector,
...recordingOptions,
};
Expand All @@ -74,7 +76,7 @@ export class Replay implements Integration {
sessionSampleRate: DEFAULT_SESSION_SAMPLE_RATE,
errorSampleRate: DEFAULT_ERROR_SAMPLE_RATE,
useCompression,
maskAllText,
maskAllText: typeof maskAllText === 'boolean' ? maskAllText : !maskTextSelector,
blockAllMedia,
_experiments,
};
Expand Down
8 changes: 7 additions & 1 deletion packages/replay/test/unit/index-integrationSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,13 @@ describe('integration settings', () => {
expect(replay['_recordingOptions'].maskTextSelector).toBe(undefined);
});

it('overwrites custom maskTextSelector option', async () => {
it('maskTextSelector takes precedence over maskAllText when not specifiying maskAllText:true', async () => {
const { replay } = await mockSdk({ replayOptions: { maskTextSelector: '[custom]' } });

expect(replay['_recordingOptions'].maskTextSelector).toBe('[custom]');
});

it('maskAllText takes precedence over maskTextSelector when specifiying maskAllText:true', async () => {
const { replay } = await mockSdk({ replayOptions: { maskAllText: true, maskTextSelector: '[custom]' } });

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