Skip to content

Commit 8ea83ee

Browse files
committed
docs(nextjs:session-replay) Clear sampling setup
1 parent 5065a34 commit 8ea83ee

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

docs/platforms/javascript/common/session-replay/index.mdx

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,30 @@ Sampling allows you to control how much of your website's traffic will result in
157157
record up to a minute of events prior to the error and continue recording
158158
until the session ends.
159159

160-
### Recommended Sample Rate Values
160+
```javascript {5-6} {filename:instrumentation-client.ts}
161+
Sentry.init({
162+
// ... other configuration
163+
164+
// Session Replay sampling rates
165+
replaysSessionSampleRate: 0.1, // Capture 10% of all sessions
166+
replaysOnErrorSampleRate: 1.0, // Capture 100% of error sessions
167+
168+
// For development/testing, you can set replaysSessionSampleRate to 1.0
169+
// to capture all sessions for complete visibility
170+
});
171+
```
172+
173+
### Recommended Production Sample Rates
174+
175+
Choose your `replaysSessionSampleRate` based on your traffic volume:
161176

162-
**For Development/Testing:**
163-
- `replaysSessionSampleRate: 1.0` (100%) - Capture all sessions for complete visibility
164-
- `replaysOnErrorSampleRate: 1.0` (100%) - Capture all error sessions
177+
| Traffic Volume | Session Sample Rate | Error Sample Rate | Description |
178+
|---|---|---|---|
179+
| **High** (100k+ sessions/day) | `0.01` (1%) | `1.0` (100%) | Minimal session capture, all errors |
180+
| **Medium** (10k-100k sessions/day) | `0.1` (10%) | `1.0` (100%) | Balanced approach |
181+
| **Low** (under 10k sessions/day) | `0.25` (25%) | `1.0` (100%) | Higher session capture for better insights |
165182

166-
**For Production:**
167-
- `replaysSessionSampleRate: 0.01` (1%) for high-traffic sites (100k+ sessions/day)
168-
- `replaysSessionSampleRate: 0.1` (10%) for medium-traffic sites (10k-100k sessions/day)
169-
- `replaysSessionSampleRate: 0.25` (25%) for low-traffic sites (under 10k sessions/day)
170-
- `replaysOnErrorSampleRate: 1.0` (100%) - Always capture sessions with errors for debugging
183+
**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.
171184

172185
### How Sampling Works
173186

platform-includes/configuration/integrations/lazy-loading-replay/javascript.nextjs.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ Sentry.init({
33
// Note, Replay is NOT instantiated below:
44
integrations: [],
55
});
6+
```
7+
8+
Then, somewhere in your application, for example in a `useEffect` hook, you can lazy-load the Replay integration:
69

7-
// Sometime later
10+
```javascript
811
import("@sentry/nextjs").then((lazyLoadedSentry) => {
912
Sentry.addIntegration(lazyLoadedSentry.replayIntegration());
1013
});
11-
```
14+
```

0 commit comments

Comments
 (0)