Skip to content

Commit 23df92e

Browse files
committed
concrete replay options
1 parent 9d0dd48 commit 23df92e

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
@@ -46,34 +46,109 @@ export class Replay implements Integration {
4646
initialFlushDelay = INITIAL_FLUSH_DELAY,
4747
stickySession = true,
4848
useCompression = true,
49+
_experiments = {},
4950
sessionSampleRate,
5051
errorSampleRate,
5152
maskAllText,
52-
maskTextSelector,
5353
maskAllInputs = true,
5454
blockAllMedia = true,
55-
_experiments = {},
56-
blockClass = 'sentry-block',
57-
ignoreClass = 'sentry-ignore',
58-
maskTextClass = 'sentry-mask',
59-
unmaskTextSelector = '.sentry-unmask',
60-
blockSelector = '[data-sentry-block]',
61-
..._recordingOptions
55+
56+
mask = [],
57+
unmask = [],
58+
block= [],
59+
unblock= [],
60+
ignore = [],
61+
maskFn,
62+
63+
// @deprecated
64+
blockClass,
65+
blockSelector,
66+
maskTextClass,
67+
maskTextSelector,
68+
ignoreClass,
6269
}: ReplayConfiguration = {}) {
70+
71+
const blockSelectors = [
72+
...block,
73+
// @deprecated
74+
...blockSelector.split(','),
75+
76+
// sentry defaults
77+
'.sentry-block',
78+
'[data-sentry-block]',
79+
];
80+
81+
// @deprecated
82+
if (blockClass) {
83+
blockSelectors.push(`.${blockClass}`);
84+
}
85+
86+
const unblockSelectors = [
87+
...unblock,
88+
89+
// sentry defaults
90+
'.sentry-unblock',
91+
]
92+
93+
const ignoreSelectors = [
94+
...ignore,
95+
// sentry defaults
96+
'.sentry-ignore',
97+
];
98+
99+
// @deprecated
100+
if (ignoreClass) {
101+
ignoreSelectors.push(`.${ignoreClass}`)
102+
}
103+
104+
const maskTextSelectors = [
105+
...mask,
106+
107+
// sentry defaults
108+
'.sentry-mask',
109+
]
110+
111+
// @deprecated
112+
if (maskTextClass) {
113+
maskTextSelectors.push(maskTextClass);
114+
}
115+
116+
117+
const unmaskTextSelectors = [
118+
...unmask,
119+
120+
// sentry defaults
121+
'.sentry-unmask',
122+
];
123+
124+
const unblockSelector = unblockSelectors.join(',');
125+
const ignoreSelector = ignoreSelectors.join(',');
126+
const maskSelector = maskTextSelectors.join(',');
127+
const unmaskSelector = unmaskTextSelectors.join(',');
128+
129+
63130
this._recordingOptions = {
64131
maskAllInputs,
65-
blockClass,
66-
blockSelector,
67-
ignoreClass,
68-
maskTextClass,
69-
maskTextSelector,
70-
unmaskTextSelector,
132+
blockSelector: blockSelectors.join(','),
133+
// @TODO
134+
unblockSelector,
135+
// @TODO
136+
ignoreSelector,
137+
maskTextSelector: maskSelector,
138+
unmaskTextSelector: unmaskSelector,
139+
maskTextFn: maskFn,
71140

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

79154
this._options = {

packages/replay/src/types.ts

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

127158
// These are optional for ReplayPluginOptions because the plugin sets default values
128159
type OptionalReplayPluginOptions = Partial<ReplayPluginOptions>;
129160

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

132186
interface CommonEventContext {
133187
/**

0 commit comments

Comments
 (0)