Skip to content
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
27 changes: 27 additions & 0 deletions docs/platforms/javascript/common/session-replay/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,33 @@ Sampling allows you to control how much of your website's traffic will result in
record up to a minute of events prior to the error and continue recording
until the session ends.

```javascript {5-6} {filename:instrumentation-client.ts}
Sentry.init({
// ... other configuration

// Session Replay sampling rates
replaysSessionSampleRate: 0.1, // Capture 10% of all sessions
replaysOnErrorSampleRate: 1.0, // Capture 100% of error sessions

// For development/testing, you can set replaysSessionSampleRate to 1.0
// to capture all sessions for complete visibility
});
```

### Recommended Production Sample Rates

Choose your `replaysSessionSampleRate` based on your traffic volume:

| Traffic Volume | Session Sample Rate | Error Sample Rate | Description |
|---|---|---|---|
| **High** (100k+ sessions/day) | `0.01` (1%) | `1.0` (100%) | Minimal session capture, all errors |
| **Medium** (10k-100k sessions/day) | `0.1` (10%) | `1.0` (100%) | Balanced approach |
| **Low** (under 10k sessions/day) | `0.25` (25%) | `1.0` (100%) | Higher session capture for better insights |

**Why keep `replaysOnErrorSampleRate` at 1.0?** Error sessions provide the most valuable debugging context, so capturing all of them is recommended regardless of traffic volume.

### How Sampling Works

Sampling begins as soon as a session starts. <PlatformIdentifier name="replays-session-sample-rate" /> is evaluated first. If it's sampled, the replay recording will begin. Otherwise, <PlatformIdentifier name="replays-on-error-sample-rate" /> is evaluated and if it's sampled, the integration will begin buffering the replay and will only upload it to Sentry if an error occurs. The remainder of the replay will behave similarly to a whole-session replay.

## Error Linking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ Sentry.init({
// Note, Replay is NOT instantiated below:
integrations: [],
});
```

Then, somewhere in your application, for example in a `useEffect` hook, you can lazy-load the Replay integration:

// Sometime later
```javascript
import("@sentry/nextjs").then((lazyLoadedSentry) => {
Sentry.addIntegration(lazyLoadedSentry.replayIntegration());
});
```
```