Skip to content

Commit c3447d0

Browse files
authored
feat(replay/v8): Delete deprecated replaySession and errorSampleRates (#11045)
Options can be configured with `replaysSessionSampleRate` and `replaysOnErrorSampleRate`. closes #6958
1 parent 390fd0a commit c3447d0

File tree

3 files changed

+21
-126
lines changed

3 files changed

+21
-126
lines changed

packages/replay/src/integration.ts

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from './constants';
1212
import { ReplayContainer } from './replay';
1313
import type {
14+
InitialReplayPluginOptions,
1415
RecordingOptions,
1516
ReplayCanvasIntegrationOptions,
1617
ReplayConfiguration,
@@ -27,9 +28,6 @@ const DEFAULT_NETWORK_HEADERS = ['content-length', 'content-type', 'accept'];
2728

2829
let _initialized = false;
2930

30-
type InitialReplayPluginOptions = Omit<ReplayPluginOptions, 'sessionSampleRate' | 'errorSampleRate'> &
31-
Partial<Pick<ReplayPluginOptions, 'sessionSampleRate' | 'errorSampleRate'>>;
32-
3331
/**
3432
* Sentry integration for [Session Replay](https://sentry.io/for/session-replay/).
3533
*
@@ -90,8 +88,6 @@ export class Replay implements Integration {
9088
useCompression = true,
9189
workerUrl,
9290
_experiments = {},
93-
sessionSampleRate,
94-
errorSampleRate,
9591
maskAllText = true,
9692
maskAllInputs = true,
9793
blockAllMedia = true,
@@ -189,8 +185,6 @@ export class Replay implements Integration {
189185
minReplayDuration: Math.min(minReplayDuration, MIN_REPLAY_DURATION_LIMIT),
190186
maxReplayDuration: Math.min(maxReplayDuration, MAX_REPLAY_DURATION),
191187
stickySession,
192-
sessionSampleRate,
193-
errorSampleRate,
194188
useCompression,
195189
workerUrl,
196190
blockAllMedia,
@@ -211,30 +205,6 @@ export class Replay implements Integration {
211205
_experiments,
212206
};
213207

214-
if (typeof sessionSampleRate === 'number') {
215-
// eslint-disable-next-line
216-
console.warn(
217-
`[Replay] You are passing \`sessionSampleRate\` to the Replay integration.
218-
This option is deprecated and will be removed soon.
219-
Instead, configure \`replaysSessionSampleRate\` directly in the SDK init options, e.g.:
220-
Sentry.init({ replaysSessionSampleRate: ${sessionSampleRate} })`,
221-
);
222-
223-
this._initialOptions.sessionSampleRate = sessionSampleRate;
224-
}
225-
226-
if (typeof errorSampleRate === 'number') {
227-
// eslint-disable-next-line
228-
console.warn(
229-
`[Replay] You are passing \`errorSampleRate\` to the Replay integration.
230-
This option is deprecated and will be removed soon.
231-
Instead, configure \`replaysOnErrorSampleRate\` directly in the SDK init options, e.g.:
232-
Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
233-
);
234-
235-
this._initialOptions.errorSampleRate = errorSampleRate;
236-
}
237-
238208
if (this._initialOptions.blockAllMedia) {
239209
// `blockAllMedia` is a more user friendly option to configure blocking
240210
// embedded media elements
@@ -401,7 +371,11 @@ function loadReplayOptionsFromClient(initialOptions: InitialReplayPluginOptions)
401371
const client = getClient();
402372
const opt = client && (client.getOptions() as BrowserClientReplayOptions);
403373

404-
const finalOptions = { sessionSampleRate: 0, errorSampleRate: 0, ...dropUndefinedKeys(initialOptions) };
374+
const finalOptions: ReplayPluginOptions = {
375+
sessionSampleRate: 0,
376+
errorSampleRate: 0,
377+
...dropUndefinedKeys(initialOptions),
378+
};
405379

406380
if (!opt) {
407381
consoleSandbox(() => {
@@ -411,12 +385,7 @@ function loadReplayOptionsFromClient(initialOptions: InitialReplayPluginOptions)
411385
return finalOptions;
412386
}
413387

414-
if (
415-
initialOptions.sessionSampleRate == null && // TODO remove once deprecated rates are removed
416-
initialOptions.errorSampleRate == null && // TODO remove once deprecated rates are removed
417-
opt.replaysSessionSampleRate == null &&
418-
opt.replaysOnErrorSampleRate == null
419-
) {
388+
if (opt.replaysSessionSampleRate == null && opt.replaysOnErrorSampleRate == null) {
420389
consoleSandbox(() => {
421390
// eslint-disable-next-line no-console
422391
console.warn(

packages/replay/src/types/replay.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,20 @@ export interface ReplayPluginOptions extends ReplayNetworkOptions {
235235
}>;
236236
}
237237

238+
/**
239+
* The options that can be set in the plugin options. `sessionSampleRate` and `errorSampleRate` are added
240+
* in the root level of the SDK options as `replaysSessionSampleRate` and `replaysOnErrorSampleRate`.
241+
*/
242+
export type InitialReplayPluginOptions = Omit<ReplayPluginOptions, 'sessionSampleRate' | 'errorSampleRate'>;
243+
244+
// These are optional for ReplayPluginOptions because the plugin sets default values
245+
type OptionalReplayPluginOptions = Partial<InitialReplayPluginOptions> & {
246+
/**
247+
* Mask element attributes that are contained in list
248+
*/
249+
maskAttributes?: string[];
250+
};
251+
238252
/**
239253
* Session options that are configurable by the integration configuration
240254
*/
@@ -280,14 +294,6 @@ export interface ReplayIntegrationPrivacyOptions {
280294
maskFn?: (s: string) => string;
281295
}
282296

283-
// These are optional for ReplayPluginOptions because the plugin sets default values
284-
type OptionalReplayPluginOptions = Partial<ReplayPluginOptions> & {
285-
/**
286-
* Mask element attributes that are contained in list
287-
*/
288-
maskAttributes?: string[];
289-
};
290-
291297
export interface DeprecatedPrivacyOptions {
292298
/**
293299
* @deprecated Use `block` which accepts an array of CSS selectors

packages/replay/test/integration/integrationSettings.test.ts

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,6 @@ describe('Integration | integrationSettings', () => {
4242
mockConsole.mockRestore();
4343
});
4444

45-
it('works with defining settings in integration', async () => {
46-
const { replay } = await mockSdk({
47-
replayOptions: { sessionSampleRate: 0.5 },
48-
sentryOptions: { replaysSessionSampleRate: undefined },
49-
});
50-
51-
expect(replay.getOptions().sessionSampleRate).toBe(0.5);
52-
expect(mockConsole).toBeCalledTimes(1);
53-
});
54-
55-
it('works with defining 0 in integration but logs warnings', async () => {
56-
const { replay } = await mockSdk({
57-
replayOptions: { sessionSampleRate: 0 },
58-
sentryOptions: { replaysSessionSampleRate: undefined },
59-
});
60-
61-
expect(replay.getOptions().sessionSampleRate).toBe(0);
62-
expect(mockConsole).toBeCalledTimes(1);
63-
});
64-
6545
it('works with defining settings in SDK', async () => {
6646
const { replay } = await mockSdk({ sentryOptions: { replaysSessionSampleRate: 0.5 }, replayOptions: {} });
6747

@@ -75,26 +55,6 @@ describe('Integration | integrationSettings', () => {
7555
expect(replay.getOptions().sessionSampleRate).toBe(0);
7656
expect(mockConsole).toBeCalledTimes(0);
7757
});
78-
79-
it('SDK option takes precedence', async () => {
80-
const { replay } = await mockSdk({
81-
sentryOptions: { replaysSessionSampleRate: 0.5 },
82-
replayOptions: { sessionSampleRate: 0.1 },
83-
});
84-
85-
expect(replay.getOptions().sessionSampleRate).toBe(0.5);
86-
expect(mockConsole).toBeCalledTimes(1);
87-
});
88-
89-
it('SDK option takes precedence even when 0', async () => {
90-
const { replay } = await mockSdk({
91-
sentryOptions: { replaysSessionSampleRate: 0 },
92-
replayOptions: { sessionSampleRate: 0.1 },
93-
});
94-
95-
expect(replay.getOptions().sessionSampleRate).toBe(0);
96-
expect(mockConsole).toBeCalledTimes(1);
97-
});
9858
});
9959

10060
describe('replaysOnErrorSampleRate', () => {
@@ -108,26 +68,6 @@ describe('Integration | integrationSettings', () => {
10868
mockConsole.mockRestore();
10969
});
11070

111-
it('works with defining settings in integration', async () => {
112-
const { replay } = await mockSdk({
113-
replayOptions: { errorSampleRate: 0.5 },
114-
sentryOptions: { replaysOnErrorSampleRate: undefined },
115-
});
116-
117-
expect(replay.getOptions().errorSampleRate).toBe(0.5);
118-
expect(mockConsole).toBeCalledTimes(1);
119-
});
120-
121-
it('works with defining 0 in integration', async () => {
122-
const { replay } = await mockSdk({
123-
replayOptions: { errorSampleRate: 0 },
124-
sentryOptions: { replaysOnErrorSampleRate: undefined },
125-
});
126-
127-
expect(replay.getOptions().errorSampleRate).toBe(0);
128-
expect(mockConsole).toBeCalledTimes(1);
129-
});
130-
13171
it('works with defining settings in SDK', async () => {
13272
const { replay } = await mockSdk({ sentryOptions: { replaysOnErrorSampleRate: 0.5 }, replayOptions: {} });
13373

@@ -141,26 +81,6 @@ describe('Integration | integrationSettings', () => {
14181
expect(replay.getOptions().errorSampleRate).toBe(0);
14282
expect(mockConsole).toBeCalledTimes(0);
14383
});
144-
145-
it('SDK option takes precedence', async () => {
146-
const { replay } = await mockSdk({
147-
sentryOptions: { replaysOnErrorSampleRate: 0.5 },
148-
replayOptions: { errorSampleRate: 0.1 },
149-
});
150-
151-
expect(replay.getOptions().errorSampleRate).toBe(0.5);
152-
expect(mockConsole).toBeCalledTimes(1);
153-
});
154-
155-
it('SDK option takes precedence even when 0', async () => {
156-
const { replay } = await mockSdk({
157-
sentryOptions: { replaysOnErrorSampleRate: 0 },
158-
replayOptions: { errorSampleRate: 0.1 },
159-
});
160-
161-
expect(replay.getOptions().errorSampleRate).toBe(0);
162-
expect(mockConsole).toBeCalledTimes(1);
163-
});
16484
});
16585

16686
describe('all sample rates', () => {

0 commit comments

Comments
 (0)