Skip to content

Commit 4cc53ed

Browse files
sergicalclaude
andcommitted
docs(nextjs): Improve Session Replay platform-includes
- Rewrite setup with SplitLayout for better readability - Add client-side only note in pre-requisites - Simplify install with skip-to-setup link - Keep privacy and lazy-loading sections with links Co-Authored-By: Claude <[email protected]>
1 parent 3489ddf commit 4cc53ed

File tree

3 files changed

+80
-26
lines changed

3 files changed

+80
-26
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
The Replay integration is already included with the Sentry SDK. We recommend installing the SDK through our installation wizard:
1+
Session Replay is included with `@sentry/nextjs`. If you haven't installed Sentry yet, run the wizard:
22

33
```bash
44
npx @sentry/wizard@latest -i nextjs
55
```
6+
7+
If you already have Sentry installed, skip to [Set Up](#set-up) below.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Session Replay requires `@sentry/nextjs` version `7.27.0` or higher.
2+
3+
<Alert level="info">
4+
Session Replay is **client-side only**. Configure it in
5+
`instrumentation-client.ts`, not in server or edge config files.
6+
</Alert>
Lines changed: 71 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,93 @@
1-
On your client-side NextJS app, add:
1+
Session Replay is configured in your **client-side** initialization file only.
22

3-
```javascript {8,12,14-20} {filename:instrumentation-client.ts}
3+
<SplitLayout>
4+
5+
<SplitSection>
6+
<SplitSectionText>
7+
8+
#### Add Replay Integration
9+
10+
Add `replayIntegration()` to your client initialization and configure the sample rates.
11+
12+
**Testing tip:** Set `replaysSessionSampleRate: 1.0` during development to capture all sessions.
13+
14+
</SplitSectionText>
15+
<SplitSectionCode>
16+
17+
```typescript {filename:instrumentation-client.ts}
418
import * as Sentry from "@sentry/nextjs";
519

620
Sentry.init({
721
dsn: "___PUBLIC_DSN___",
822

9-
// This sets the sample rate to be 10%. You may want this to be 100% while
10-
// in development and sample at a lower rate in production
23+
// Capture 10% of all sessions
1124
replaysSessionSampleRate: 0.1,
1225

13-
// If the entire session is not sampled, use the below sample rate to sample
14-
// sessions when an error occurs.
26+
// Capture 100% of sessions with errors
1527
replaysOnErrorSampleRate: 1.0,
1628

17-
integrations: [
18-
Sentry.replayIntegration({
19-
// Additional SDK configuration goes in here, for example:
20-
maskAllText: true,
21-
blockAllMedia: true,
22-
}),
23-
],
29+
integrations: [Sentry.replayIntegration()],
2430
});
2531
```
2632

27-
### Verify
33+
</SplitSectionCode>
34+
</SplitSection>
35+
36+
<SplitSection>
37+
<SplitSectionText>
38+
39+
#### Privacy Options
2840

29-
While you're testing, we recommend that you set `replaysSessionSampleRate` to `1.0`. This ensures that every user session will be sent to Sentry.
41+
By default, Replay masks all text and blocks media. Customize privacy settings based on your needs.
3042

31-
Once testing is complete, **we recommend lowering this value in production**. We still recommend keeping `replaysOnErrorSampleRate` set to `1.0`, so that, whenever possible, every error has an associated replay with additional debugging context.
43+
See <PlatformLink to="/session-replay/privacy/">Session Replay Privacy</PlatformLink> for all options.
3244

33-
### PII & Privacy Considerations
45+
</SplitSectionText>
46+
<SplitSectionCode>
3447

35-
Personally identifiable information (PII), and privacy are important considerations when enabling Session Replay. There are multiple ways in which Sentry helps you avoid collecting PII, including:
48+
```typescript {filename:instrumentation-client.ts}
49+
Sentry.replayIntegration({
50+
// Text masking (default: true)
51+
maskAllText: true,
52+
53+
// Block images/videos (default: true)
54+
blockAllMedia: true,
55+
56+
// Mask specific inputs
57+
maskAllInputs: true,
58+
}),
59+
```
3660

37-
- [Masking](/platforms/javascript/session-replay/privacy/#masking), which replaces the text content with something else. (The default behavior being to replace each character with a \*.)
38-
- Making [Network request, response bodies, and headers](/platforms/javascript/session-replay/privacy/#network-request-and-response-bodies-and-headers) an opt-in feature, because the best way to avoid getting PII into Sentry is by not adding URLs of endpoints that may contain PII.
61+
</SplitSectionCode>
62+
</SplitSection>
3963

40-
While we have certain privacy considerations in place, Sentry's Session Replays allow you to set up the [privacy configurations](/platforms/javascript/session-replay/privacy/#privacy-configuration) that work best for your use case. For example, if you're working on a static website that's free of PII or other types of private data, you can opt out of the default text masking and image blocking settings.
41-
To learn more about session replay privacy, [read our docs.](/platforms/javascript/session-replay/privacy/)
64+
<SplitSection>
65+
<SplitSectionText>
4266

43-
### Lazy-loading Replay
67+
#### Lazy-Loading Replay
4468

45-
Once you've added the integration, Replay will start automatically. If you don't want to start it immediately (lazy-load it), you can use `addIntegration`:
69+
Load Replay only when needed instead of at startup. Useful for reducing initial bundle size.
70+
71+
</SplitSectionText>
72+
<SplitSectionCode>
73+
74+
```typescript {filename:instrumentation-client.ts}
75+
// Don't add replayIntegration to init
76+
Sentry.init({
77+
integrations: [],
78+
});
79+
80+
// Later, when you want to start recording:
81+
import("@sentry/nextjs").then((lazyLoadedSentry) => {
82+
Sentry.addIntegration(lazyLoadedSentry.replayIntegration());
83+
});
84+
```
85+
86+
</SplitSectionCode>
87+
</SplitSection>
88+
89+
</SplitLayout>
90+
91+
### Verify
4692

47-
<PlatformContent includePath="configuration/integrations/lazy-loading-replay" />
93+
Open your app, interact with it, then check [**Replays**](https://sentry.io/orgredirect/organizations/:orgslug/replays/) in Sentry to see your session.

0 commit comments

Comments
 (0)