Skip to content

ref(replay): Rename replaysSampleRate to replaysSessionSampleRate #6422

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
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/browser/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type BrowserClientReplayOptions = {
* The sample rate for session-long replays.
* 1.0 will record all sessions and 0 will record none.
*/
replaysSampleRate?: number;
replaysSessionSampleRate?: number;

/**
* The sample rate for sessions that has had an error occur.
Expand Down
2 changes: 1 addition & 1 deletion packages/replay/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ They are now defined on the top level of the SDK:
```js
Sentry.init({
dsn: '__DSN__',
replaysSampleRate: 0.1,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
integrations: [
new Replay({
Expand Down
8 changes: 4 additions & 4 deletions packages/replay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Sentry.init({

// This sets the sample rate to be 10%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaysSampleRate: 0.1,
replaysSessionSampleRate: 0.1,

// If the entire session is not sampled, use the below sample rate to sample
// sessions when an error occurs.
Expand Down Expand Up @@ -101,10 +101,10 @@ Alternatively, rather than recording an entire session, you can capture a replay

Sampling allows you to control how much of your website's traffic will result in a Session Replay. There are two sample rates you can adjust to get the replays more relevant to your interests:

- `replaysSampleRate` - The sample rate for replays that begin recording immediately and last the entirety of the user's session.
- `replaysSessionSampleRate` - The sample rate for replays that begin recording immediately and last the entirety of the user's session.
- `replaysOnErrorSampleRate` - The sample rate for replays that are recorded when an error happens. This type of replay will record up to a minute of events prior to the error and continue recording until the session ends.

Sampling occurs when the session is first started. `replaysSampleRate` is evaluated first. If it is sampled, then the replay recording begins. Otherwise, `replaysOnErrorSampleRate` is evaluated and if it is sampled, the integration will begin buffering the replay and will only upload a replay to Sentry when an error occurs. The remainder of the replay will behave similarly to a whole-session replay.
Sampling occurs when the session is first started. `replaysSessionSampleRate` is evaluated first. If it is sampled, then the replay recording begins. Otherwise, `replaysOnErrorSampleRate` is evaluated and if it is sampled, the integration will begin buffering the replay and will only upload a replay to Sentry when an error occurs. The remainder of the replay will behave similarly to a whole-session replay.


## Configuration
Expand All @@ -116,7 +116,7 @@ The following options can be configured on the root level of your browser-based

| key | type | default | description |
| ------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| replaysSampleRate | number | `0.1` | The sample rate for replays that begin recording immediately and last the entirety of the user's session. 1.0 will collect all replays, 0 will collect no replays. |
| replaysSessionSampleRate | number | `0.1` | The sample rate for replays that begin recording immediately and last the entirety of the user's session. 1.0 will collect all replays, 0 will collect no replays. |
| replaysOnErrorSampleRate | number | `1.0` |The sample rate for replays that are recorded when an error happens. This type of replay will record up to a minute of events prior to the error and continue recording until the session ends. 1.0 capturing all sessions with an error, and 0 capturing none.

### General Integration Configuration
Expand Down
4 changes: 2 additions & 2 deletions packages/replay/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1354,8 +1354,8 @@ export class Replay implements Integration {
const client = getCurrentHub().getClient() as BrowserClient | undefined;
const opt = client && (client.getOptions() as BrowserOptions | undefined);

if (opt && opt.replaysSampleRate) {
this.options.sessionSampleRate = opt.replaysSampleRate;
if (opt && opt.replaysSessionSampleRate) {
this.options.sessionSampleRate = opt.replaysSessionSampleRate;
}

if (opt && opt.replaysOnErrorSampleRate) {
Expand Down
6 changes: 3 additions & 3 deletions packages/replay/test/unit/index-integrationSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ describe('blockAllMedia', () => {
});
});

describe('replaysSampleRate', () => {
describe('replaysSessionSampleRate', () => {
it('works with defining settings in integration', async () => {
({ replay } = await mockSdk({ replayOptions: { sessionSampleRate: 0.5 } }));

expect(replay.options.sessionSampleRate).toBe(0.5);
});

it('works with defining settings in SDK', async () => {
({ replay } = await mockSdk({ sentryOptions: { replaysSampleRate: 0.5 } }));
({ replay } = await mockSdk({ sentryOptions: { replaysSessionSampleRate: 0.5 } }));

expect(replay.options.sessionSampleRate).toBe(0.5);
});

it('SDK option takes precedence', async () => {
({ replay } = await mockSdk({
sentryOptions: { replaysSampleRate: 0.5 },
sentryOptions: { replaysSessionSampleRate: 0.5 },
replayOptions: { sessionSampleRate: 0.1 },
}));

Expand Down