You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also get to the root of an error or performance issue faster, by watching a video-like reproduction of a user session with [session replay](/product/explore/session-replay/web/getting-started/).
19
19
20
-
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
20
+
Send <PlatformLinkto="/platforms/javascript/guides/nextjs/logs/">structured logs</PlatformLink> to Sentry and correlate them with errors and traces.
21
+
22
+
Select which Sentry features you'd like to configure to get the corresponding setup instructions below.
This guide assumes that you enable all features and allow the wizard to create an example page and route. You can add or remove features at any time, but setting them up now will save you the effort of configuring them manually later.
45
-
46
48
<Expandabletitle="What does the installation wizard change inside your application?">
47
49
48
50
- Creates config files with the default `Sentry.init()` calls for all runtimes (Node.js, Browser, and Edge)
@@ -54,9 +56,9 @@ This guide assumes that you enable all features and allow the wizard to create a
54
56
55
57
</Expandable>
56
58
57
-
## Step 2: Configure
59
+
## Configure
58
60
59
-
If you prefer to configure Sentry manually, here are the configuration files the wizard would create:
61
+
If you want to expand on your Sentry configuration by adding additional functionality, or manually instrument your application, here are the configuration files the wizard would create. Initialize Sentry as early as possible.
The installation wizard will scaffold these files for you if they are missing.
163
+
</Alert>
164
+
165
+
<OnboardingOptionoptionId="performance">
166
+
167
+
<OnboardingOptionoptionId="logs">
168
+
169
+
## Sending Logs
170
+
171
+
[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.
172
+
173
+
Use Sentry's logger to capture structured logs with meaningful attributes that help you debug issues and understand user behavior.
174
+
175
+
```javascript
176
+
import*asSentryfrom"@sentry/nextjs";
177
+
178
+
const { logger } = Sentry;
179
+
180
+
logger.info("User completed checkout", {
181
+
userId:123,
182
+
orderId:"order_456",
183
+
amount:99.99,
184
+
});
185
+
186
+
logger.error("Payment processing failed", {
187
+
errorCode:"CARD_DECLINED",
188
+
userId:123,
189
+
attemptCount:3,
190
+
});
191
+
192
+
logger.warn(logger.fmt`Rate limit exceeded for user: ${123}`);
193
+
```
194
+
195
+
</OnboardingOption>
196
+
197
+
<OnboardingOptionoptionId="session-replay">
198
+
199
+
## Customizing Replays
200
+
201
+
[Replays](/product/explore/session-replay/web/getting-started/) allow you to see video-like reproductions of user sessions.
202
+
203
+
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.
// This will show all text content in replays. Use with caution.
215
+
maskAllText:false,
216
+
// This will show all media content in replays. Use with caution.
217
+
blockAllMedia:false,
218
+
}),
219
+
],
220
+
// Only capture replays for 10% of sessions
221
+
replaysSessionSampleRate:0.1,
222
+
// Capture replays for 100% of sessions with an error
223
+
replaysOnErrorSampleRate:1.0,
224
+
});
225
+
```
226
+
227
+
```jsx
228
+
<div className="reveal-content">This content will be visible in replays</div>
229
+
<span data-safe-to-show>Safe user data</span>
230
+
```
231
+
232
+
</OnboardingOption>
233
+
234
+
## Custom Traces with Attributes
235
+
236
+
[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.
If you haven't tested your Sentry configuration yet, let's do it now. You can confirm that Sentry is working properly and sending data to your Sentry project by using the example page and route created by the installation wizard:
149
278
@@ -169,6 +298,8 @@ Now, head over to your project on [Sentry.io](https://sentry.io) to view the col
At this point, you should have integrated Sentry into your Next.js application and should already be sending error and performance data to your Sentry project.
@@ -182,6 +313,8 @@ Our next recommended steps for you are:
182
313
- Get familiar with [Sentry's product features](/product) like tracing, insights, and alerts
183
314
- Learn more about our [Vercel integration](/organization/integrations/deployment/vercel/)
0 commit comments