Skip to content

Commit 8c1eaa2

Browse files
committed
concrete replay options
1 parent 2885aff commit 8c1eaa2

File tree

2 files changed

+148
-19
lines changed

2 files changed

+148
-19
lines changed

packages/replay/src/integration.ts

Lines changed: 93 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,109 @@ export class Replay implements Integration {
4747
initialFlushDelay = INITIAL_FLUSH_DELAY,
4848
stickySession = true,
4949
useCompression = true,
50+
_experiments = {},
5051
sessionSampleRate,
5152
errorSampleRate,
5253
maskAllText,
53-
maskTextSelector,
5454
maskAllInputs = true,
5555
blockAllMedia = true,
56-
_experiments = {},
57-
blockClass = 'sentry-block',
58-
ignoreClass = 'sentry-ignore',
59-
maskTextClass = 'sentry-mask',
60-
unmaskTextSelector = '.sentry-unmask',
61-
blockSelector = '[data-sentry-block]',
62-
...recordingOptions
56+
57+
mask = [],
58+
unmask = [],
59+
block= [],
60+
unblock= [],
61+
ignore = [],
62+
maskFn,
63+
64+
// @deprecated
65+
blockClass,
66+
blockSelector,
67+
maskTextClass,
68+
maskTextSelector,
69+
ignoreClass,
6370
}: ReplayConfiguration = {}) {
71+
72+
const blockSelectors = [
73+
...block,
74+
// @deprecated
75+
...blockSelector.split(','),
76+
77+
// sentry defaults
78+
'.sentry-block',
79+
'[data-sentry-block]',
80+
];
81+
82+
// @deprecated
83+
if (blockClass) {
84+
blockSelectors.push(`.${blockClass}`);
85+
}
86+
87+
const unblockSelectors = [
88+
...unblock,
89+
90+
// sentry defaults
91+
'.sentry-unblock',
92+
]
93+
94+
const ignoreSelectors = [
95+
...ignore,
96+
// sentry defaults
97+
'.sentry-ignore',
98+
];
99+
100+
// @deprecated
101+
if (ignoreClass) {
102+
ignoreSelectors.push(`.${ignoreClass}`)
103+
}
104+
105+
const maskTextSelectors = [
106+
...mask,
107+
108+
// sentry defaults
109+
'.sentry-mask',
110+
]
111+
112+
// @deprecated
113+
if (maskTextClass) {
114+
maskTextSelectors.push(maskTextClass);
115+
}
116+
117+
118+
const unmaskTextSelectors = [
119+
...unmask,
120+
121+
// sentry defaults
122+
'.sentry-unmask',
123+
];
124+
125+
const unblockSelector = unblockSelectors.join(',');
126+
const ignoreSelector = ignoreSelectors.join(',');
127+
const maskSelector = maskTextSelectors.join(',');
128+
const unmaskSelector = unmaskTextSelectors.join(',');
129+
130+
64131
this.recordingOptions = {
65132
maskAllInputs,
66-
blockClass,
67-
blockSelector,
68-
ignoreClass,
69-
maskTextClass,
70-
maskTextSelector,
71-
unmaskTextSelector,
133+
blockSelector: blockSelectors.join(','),
134+
// @TODO
135+
unblockSelector,
136+
// @TODO
137+
ignoreSelector,
138+
maskTextSelector: maskSelector,
139+
unmaskTextSelector: unmaskSelector,
140+
maskTextFn: maskFn,
72141

73142
// We are making the decision to make these selectors the same
74-
unmaskInputSelector: unmaskTextSelector,
75-
maskInputSelector: maskTextSelector,
76-
77-
...recordingOptions,
143+
maskInputSelector: maskSelector,
144+
unmaskInputSelector: unmaskSelector,
145+
maskInputFn: maskFn,
146+
147+
// Our defaults
148+
slimDOMOptions: 'all',
149+
inlineStylesheet: true,
150+
// Disable inline images/fonts as it can cause CORS, also increases segment size
151+
inlineImages: false,
152+
collectFonts: false,
78153
};
79154

80155
this.options = {

packages/replay/src/types.ts

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,66 @@ export interface ReplayPluginOptions extends SessionOptions {
119119
captureExceptions: boolean;
120120
traceInternals: boolean;
121121
}>;
122+
123+
/**
124+
* Mask text content for elements that match the CSS selectors in the list.
125+
*/
126+
mask: string[];
127+
128+
/**
129+
* Unmask text content for elements that match the CSS selectors in the list.
130+
*/
131+
unmask: string[];
132+
133+
/**
134+
* Block elements that match the CSS selectors in the list. Blocking replaces
135+
* the element with an empty placeholder with the same dimensions.
136+
*/
137+
block: string[];
138+
139+
/**
140+
* Unblock elements that match the CSS selectors in the list. This is useful when using `blockAllMedia`.
141+
*/
142+
unblock: string[];
143+
144+
/**
145+
* Ignore input events for elements that match the CSS selectors in the list.
146+
*/
147+
ignore: string[];
148+
149+
/**
150+
* A callback function to customize how your text is masked.
151+
*/
152+
maskFn: Pick<RecordingOptions, 'maskTextFn'>;
122153
}
123154

124155
// These are optional for ReplayPluginOptions because the plugin sets default values
125156
type OptionalReplayPluginOptions = Partial<ReplayPluginOptions>;
126157

127-
export interface ReplayConfiguration extends OptionalReplayPluginOptions, RecordingOptions {}
158+
interface DeprecatedRecordingOptions {
159+
/**
160+
* @deprecated Use `block` which accepts an array of CSS selectors
161+
*/
162+
blockSelector: RecordingOptions['blockSelector'];
163+
/**
164+
* @deprecated Use `block` which accepts an array of CSS selectors
165+
*/
166+
blockClass: RecordingOptions['blockClass'];
167+
/**
168+
* @deprecated Use `mask` which accepts an array of CSS selectors
169+
*/
170+
maskTextClass: RecordingOptions['maskTextClass'];
171+
/**
172+
* @deprecated Use `mask` which accepts an array of CSS selectors
173+
*/
174+
maskTextSelector: RecordingOptions['maskTextSelector'];
175+
/**
176+
* @deprecated Use `ignore` which accepts an array of CSS selectors
177+
*/
178+
ignoreClass: RecordingOptions['ignoreClass'];
179+
}
180+
181+
export interface ReplayConfiguration extends OptionalReplayPluginOptions, DeprecatedRecordingOptions, Pick<RecordingOptions, 'maskAllInputs'>{}
128182

129183
interface CommonEventContext {
130184
/**

0 commit comments

Comments
 (0)