Skip to content

Commit c1b37de

Browse files
committed
Adding platform includes for capturing errors, consistent with manual setup. Adding links and descriptive text to features. Adding hidden LLM steering content for .md generation (restricting certain behaviors).
1 parent bf4c23a commit c1b37de

File tree

1 file changed

+18
-31
lines changed
  • docs/platforms/javascript/guides/nextjs

1 file changed

+18
-31
lines changed

docs/platforms/javascript/guides/nextjs/index.mdx

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ categories:
99
- server-node
1010
---
1111

12+
<PlatformContent includePath="llm-steering" />
13+
1214
<PlatformContent includePath="llm-rules-platform" />
1315

1416
<PlatformContent includePath="getting-started-prerequisites" />
@@ -158,39 +160,17 @@ For detailed manual setup instructions, see our [manual setup guide](/platforms/
158160

159161
Make sure runtime errors are surfaced to Sentry using Next.js error components.
160162

161-
<Expandable title="App Router (app/)">
162-
163-
Create `app/global-error.(tsx|jsx)` to catch uncaught errors:
164-
165-
```tsx {filename:app/global-error.tsx}
166-
"use client";
167-
168-
export default function GlobalError({ error }: { error: Error }) {
169-
return (
170-
<html>
171-
<body>
172-
<h2>Something went wrong!</h2>
173-
<p>{error.message}</p>
174-
<button onClick={() => window.location.reload()}>Try again</button>
175-
</body>
176-
</html>
177-
);
178-
}
179-
```
180-
181-
</Expandable>
163+
### App Router
182164

183-
<Expandable title="Pages Router (pages/)">
165+
<PlatformContent includePath="getting-started-capture-errors/app-router-global-error" />
184166

185-
Add `_error.(js|tsx)` to capture render errors:
167+
#### Errors from Nested React Server Components
186168

187-
```tsx {filename:pages/_error.tsx}
188-
import NextErrorComponent from "next/error";
169+
<PlatformContent includePath="getting-started-capture-errors/nested-server-components" />
189170

190-
export default NextErrorComponent;
191-
```
171+
### Pages Router
192172

193-
</Expandable>
173+
<PlatformContent includePath="getting-started-capture-errors/pages-router-error" />
194174

195175
<Alert level="info">
196176
The installation wizard will scaffold these files for you if they are missing.
@@ -202,7 +182,7 @@ export default NextErrorComponent;
202182

203183
## Step 4: Sending Logs
204184

205-
Now let's add structured logging to capture application insights. Logs are enabled in your configuration above.
185+
[Structured logging](/platforms/javascript/guides/nextjs/logs/) lets users send text-based log information from their applications to Sentry. Once in Sentry, these logs can be viewed alongside relevant errors, searched by text-string, or searched using their individual attributes.
206186

207187
Use Sentry's logger to capture structured logs with meaningful attributes that help you debug issues and understand user behavior.
208188

@@ -232,7 +212,9 @@ logger.warn(logger.fmt`Rate limit exceeded for user: ${123}`);
232212

233213
## Step 5: Customizing Replays
234214

235-
By default, Session Replay masks sensitive data for privacy. Customize this to show specific content that's safe to display by adjusting the client-side integration.
215+
[Replays](/product/explore/session-replay/web/getting-started/) allow you to see video-like reproductions of user sessions.
216+
217+
By default, Session Replay masks sensitive data for privacy and to protect PII data. You can modify the replay configurations in your client-side Sentry initialization to show (unmask) specific content that's safe to display.
236218

237219
```javascript {filename:instrumentation-client.(js|ts)}
238220
import * as Sentry from "@sentry/nextjs";
@@ -241,12 +223,17 @@ Sentry.init({
241223
dsn: "___PUBLIC_DSN___",
242224
integrations: [
243225
Sentry.replayIntegration({
226+
// This will show the content of the div with the class "reveal-content" and the span with the data-safe-to-show attribute
244227
unmask: [".reveal-content", "[data-safe-to-show]"],
228+
// This will show all text content in replays. Use with caution.
245229
maskAllText: false,
230+
// This will show all media content in replays. Use with caution.
246231
blockAllMedia: false,
247232
}),
248233
],
234+
// Only capture replays for 10% of sessions
249235
replaysSessionSampleRate: 0.1,
236+
// Capture replays for 100% of sessions with an error
250237
replaysOnErrorSampleRate: 1.0,
251238
});
252239
```
@@ -260,7 +247,7 @@ Sentry.init({
260247

261248
## Step 6: Custom Traces with Attributes
262249

263-
Create custom spans to measure specific operations and add meaningful attributes. This helps you understand performance bottlenecks and debug issues with detailed context.
250+
[Tracing](/platforms/javascript/guides/nextjs/tracing/) allows you to monitor interactions between multiple services or applications. Create custom spans to measure specific operations and add meaningful attributes. This helps you understand performance bottlenecks and debug issues with detailed context.
264251

265252
```javascript
266253
import * as Sentry from "@sentry/nextjs";

0 commit comments

Comments
 (0)