diff --git a/packages/replay/src/integration.ts b/packages/replay/src/integration.ts index 688808e0ccf1..dca865c50590 100644 --- a/packages/replay/src/integration.ts +++ b/packages/replay/src/integration.ts @@ -11,6 +11,7 @@ import { } from './constants'; import { ReplayContainer } from './replay'; import type { + InitialReplayPluginOptions, RecordingOptions, ReplayCanvasIntegrationOptions, ReplayConfiguration, @@ -27,9 +28,6 @@ const DEFAULT_NETWORK_HEADERS = ['content-length', 'content-type', 'accept']; let _initialized = false; -type InitialReplayPluginOptions = Omit & - Partial>; - /** * Sentry integration for [Session Replay](https://sentry.io/for/session-replay/). * @@ -90,8 +88,6 @@ export class Replay implements Integration { useCompression = true, workerUrl, _experiments = {}, - sessionSampleRate, - errorSampleRate, maskAllText = true, maskAllInputs = true, blockAllMedia = true, @@ -189,8 +185,6 @@ export class Replay implements Integration { minReplayDuration: Math.min(minReplayDuration, MIN_REPLAY_DURATION_LIMIT), maxReplayDuration: Math.min(maxReplayDuration, MAX_REPLAY_DURATION), stickySession, - sessionSampleRate, - errorSampleRate, useCompression, workerUrl, blockAllMedia, @@ -211,30 +205,6 @@ export class Replay implements Integration { _experiments, }; - if (typeof sessionSampleRate === 'number') { - // eslint-disable-next-line - console.warn( - `[Replay] You are passing \`sessionSampleRate\` to the Replay integration. -This option is deprecated and will be removed soon. -Instead, configure \`replaysSessionSampleRate\` directly in the SDK init options, e.g.: -Sentry.init({ replaysSessionSampleRate: ${sessionSampleRate} })`, - ); - - this._initialOptions.sessionSampleRate = sessionSampleRate; - } - - if (typeof errorSampleRate === 'number') { - // eslint-disable-next-line - console.warn( - `[Replay] You are passing \`errorSampleRate\` to the Replay integration. -This option is deprecated and will be removed soon. -Instead, configure \`replaysOnErrorSampleRate\` directly in the SDK init options, e.g.: -Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`, - ); - - this._initialOptions.errorSampleRate = errorSampleRate; - } - if (this._initialOptions.blockAllMedia) { // `blockAllMedia` is a more user friendly option to configure blocking // embedded media elements @@ -401,7 +371,11 @@ function loadReplayOptionsFromClient(initialOptions: InitialReplayPluginOptions) const client = getClient(); const opt = client && (client.getOptions() as BrowserClientReplayOptions); - const finalOptions = { sessionSampleRate: 0, errorSampleRate: 0, ...dropUndefinedKeys(initialOptions) }; + const finalOptions: ReplayPluginOptions = { + sessionSampleRate: 0, + errorSampleRate: 0, + ...dropUndefinedKeys(initialOptions), + }; if (!opt) { consoleSandbox(() => { @@ -411,12 +385,7 @@ function loadReplayOptionsFromClient(initialOptions: InitialReplayPluginOptions) return finalOptions; } - if ( - initialOptions.sessionSampleRate == null && // TODO remove once deprecated rates are removed - initialOptions.errorSampleRate == null && // TODO remove once deprecated rates are removed - opt.replaysSessionSampleRate == null && - opt.replaysOnErrorSampleRate == null - ) { + if (opt.replaysSessionSampleRate == null && opt.replaysOnErrorSampleRate == null) { consoleSandbox(() => { // eslint-disable-next-line no-console console.warn( diff --git a/packages/replay/src/types/replay.ts b/packages/replay/src/types/replay.ts index 61325e4a9959..0cd337e141a3 100644 --- a/packages/replay/src/types/replay.ts +++ b/packages/replay/src/types/replay.ts @@ -235,6 +235,20 @@ export interface ReplayPluginOptions extends ReplayNetworkOptions { }>; } +/** + * The options that can be set in the plugin options. `sessionSampleRate` and `errorSampleRate` are added + * in the root level of the SDK options as `replaysSessionSampleRate` and `replaysOnErrorSampleRate`. + */ +export type InitialReplayPluginOptions = Omit; + +// These are optional for ReplayPluginOptions because the plugin sets default values +type OptionalReplayPluginOptions = Partial & { + /** + * Mask element attributes that are contained in list + */ + maskAttributes?: string[]; +}; + /** * Session options that are configurable by the integration configuration */ @@ -280,14 +294,6 @@ export interface ReplayIntegrationPrivacyOptions { maskFn?: (s: string) => string; } -// These are optional for ReplayPluginOptions because the plugin sets default values -type OptionalReplayPluginOptions = Partial & { - /** - * Mask element attributes that are contained in list - */ - maskAttributes?: string[]; -}; - export interface DeprecatedPrivacyOptions { /** * @deprecated Use `block` which accepts an array of CSS selectors diff --git a/packages/replay/test/integration/integrationSettings.test.ts b/packages/replay/test/integration/integrationSettings.test.ts index 9f92c9833145..0178f5266ce2 100644 --- a/packages/replay/test/integration/integrationSettings.test.ts +++ b/packages/replay/test/integration/integrationSettings.test.ts @@ -42,26 +42,6 @@ describe('Integration | integrationSettings', () => { mockConsole.mockRestore(); }); - it('works with defining settings in integration', async () => { - const { replay } = await mockSdk({ - replayOptions: { sessionSampleRate: 0.5 }, - sentryOptions: { replaysSessionSampleRate: undefined }, - }); - - expect(replay.getOptions().sessionSampleRate).toBe(0.5); - expect(mockConsole).toBeCalledTimes(1); - }); - - it('works with defining 0 in integration but logs warnings', async () => { - const { replay } = await mockSdk({ - replayOptions: { sessionSampleRate: 0 }, - sentryOptions: { replaysSessionSampleRate: undefined }, - }); - - expect(replay.getOptions().sessionSampleRate).toBe(0); - expect(mockConsole).toBeCalledTimes(1); - }); - it('works with defining settings in SDK', async () => { const { replay } = await mockSdk({ sentryOptions: { replaysSessionSampleRate: 0.5 }, replayOptions: {} }); @@ -75,26 +55,6 @@ describe('Integration | integrationSettings', () => { expect(replay.getOptions().sessionSampleRate).toBe(0); expect(mockConsole).toBeCalledTimes(0); }); - - it('SDK option takes precedence', async () => { - const { replay } = await mockSdk({ - sentryOptions: { replaysSessionSampleRate: 0.5 }, - replayOptions: { sessionSampleRate: 0.1 }, - }); - - expect(replay.getOptions().sessionSampleRate).toBe(0.5); - expect(mockConsole).toBeCalledTimes(1); - }); - - it('SDK option takes precedence even when 0', async () => { - const { replay } = await mockSdk({ - sentryOptions: { replaysSessionSampleRate: 0 }, - replayOptions: { sessionSampleRate: 0.1 }, - }); - - expect(replay.getOptions().sessionSampleRate).toBe(0); - expect(mockConsole).toBeCalledTimes(1); - }); }); describe('replaysOnErrorSampleRate', () => { @@ -108,26 +68,6 @@ describe('Integration | integrationSettings', () => { mockConsole.mockRestore(); }); - it('works with defining settings in integration', async () => { - const { replay } = await mockSdk({ - replayOptions: { errorSampleRate: 0.5 }, - sentryOptions: { replaysOnErrorSampleRate: undefined }, - }); - - expect(replay.getOptions().errorSampleRate).toBe(0.5); - expect(mockConsole).toBeCalledTimes(1); - }); - - it('works with defining 0 in integration', async () => { - const { replay } = await mockSdk({ - replayOptions: { errorSampleRate: 0 }, - sentryOptions: { replaysOnErrorSampleRate: undefined }, - }); - - expect(replay.getOptions().errorSampleRate).toBe(0); - expect(mockConsole).toBeCalledTimes(1); - }); - it('works with defining settings in SDK', async () => { const { replay } = await mockSdk({ sentryOptions: { replaysOnErrorSampleRate: 0.5 }, replayOptions: {} }); @@ -141,26 +81,6 @@ describe('Integration | integrationSettings', () => { expect(replay.getOptions().errorSampleRate).toBe(0); expect(mockConsole).toBeCalledTimes(0); }); - - it('SDK option takes precedence', async () => { - const { replay } = await mockSdk({ - sentryOptions: { replaysOnErrorSampleRate: 0.5 }, - replayOptions: { errorSampleRate: 0.1 }, - }); - - expect(replay.getOptions().errorSampleRate).toBe(0.5); - expect(mockConsole).toBeCalledTimes(1); - }); - - it('SDK option takes precedence even when 0', async () => { - const { replay } = await mockSdk({ - sentryOptions: { replaysOnErrorSampleRate: 0 }, - replayOptions: { errorSampleRate: 0.1 }, - }); - - expect(replay.getOptions().errorSampleRate).toBe(0); - expect(mockConsole).toBeCalledTimes(1); - }); }); describe('all sample rates', () => {