Skip to content

Commit 63b0949

Browse files
chargomemydea
authored andcommitted
docs(js): Clarify docs on Next.js tracing setup (#13815)
Co-authored-by: Francesco Gringl-Novy <[email protected]>
1 parent 1649610 commit 63b0949

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

docs/platforms/javascript/guides/nextjs/manual-setup.mdx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ export default withSentryConfig(nextConfig, {
8787

8888
### Initialize Sentry Client-Side and Server-Side SDKs
8989

90-
Create three files in your application's root directory: `sentry.server.config.(js|ts)`, `sentry.edge.config.(js|ts)`, and `instrumentation-client.(js|ts)`. Add the following initialization code into each respective file:
90+
Create three files in your application's root directory:
91+
- `sentry.server.config.(js|ts)`
92+
- `sentry.edge.config.(js|ts)`
93+
- `instrumentation-client.(js|ts)`
94+
- If you previously had a file called `sentry.client.config.(js|ts)`, you can safely rename this to `instrumentation-client.(js|ts)` for all Next.js versions.
95+
96+
Add the following initialization code into each respective file:
9197

9298
<Alert level="info" title="Note">
9399
These files run in different environments (browser, server, edge) and are
@@ -112,8 +118,8 @@ Sentry.init({
112118
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
113119
tracesSampleRate: 1.0,
114120
// ___PRODUCT_OPTION_END___ performance
115-
// Replay may only be enabled for the client-side
116121
// ___PRODUCT_OPTION_START___ session-replay
122+
// Replay may only be enabled for the client-side
117123
integrations: [Sentry.replayIntegration()],
118124

119125
// Capture Replay for 10% of all sessions,
@@ -188,10 +194,8 @@ Sentry.init({
188194
});
189195
```
190196

191-
<Alert level="success" title="Tip">
192-
Include your [Data Source Name](/concepts/key-terms/dsn-explainer/) (DSN)
193-
directly in these files, or use a _public_ environment variable like
194-
`NEXT_PUBLIC_SENTRY_DSN`.
197+
<Alert title="Tip">
198+
Include your DSN directly in these files, or use a _public_ environment variable like `NEXT_PUBLIC_SENTRY_DSN`.
195199
</Alert>
196200

197201
### Register Sentry Server-Side SDK Initialization
@@ -210,12 +214,6 @@ export async function register() {
210214
}
211215
```
212216

213-
<Alert level="warning" title="Next.js version <15 only">
214-
You need to enable the instrumentation hook by setting the
215-
`experimental.instrumentationHook` to `true` in your `next.config.(js|mjs)`
216-
file.
217-
</Alert>
218-
219217
<Expandable title="Opt out of Sentry SDK bundling on client- or server-side.">
220218
If you want the Sentry SDK to be available on the server side and not on the
221219
client side, simply delete `instrumentation-client.(js|ts)`. This will prevent
Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,45 @@
1-
Set `tracesSampleRate` in your config files, `instrumentation-client.js`, `sentry.server.config.js`, and `sentry.edge.config.js`:
1+
Set `tracesSampleRate` in your config files:
2+
- `sentry.server.config.js`
3+
- `sentry.edge.config.js`:
4+
- `instrumentation-client.js`
5+
- If you previously had a file called `sentry.client.config.(js|ts)`, you can safely rename this to `instrumentation-client.(js|ts)` for all Next.js versions.
26

3-
```javascript
7+
```javascript {tabTitle:Client} {filename:instrumentation-client.(js|ts)}
48
import * as Sentry from "@sentry/nextjs";
59

610
Sentry.init({
711
dsn: "___PUBLIC_DSN___",
12+
// We recommend adjusting this value in production, or using `tracesSampler`
13+
// for finer control
14+
tracesSampleRate: 1.0,
15+
// ... rest of your config
16+
});
17+
18+
// This export will instrument router navigations, and is only relevant if you enable tracing.
19+
// `captureRouterTransitionStart` is available from SDK version 9.12.0 onwards
20+
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
21+
```
22+
23+
```javascript {tabTitle:Server} {filename:sentry.server.config.(js|ts)}
24+
import * as Sentry from "@sentry/nextjs";
825

26+
Sentry.init({
27+
dsn: "___PUBLIC_DSN___",
928
// We recommend adjusting this value in production, or using `tracesSampler`
1029
// for finer control
1130
tracesSampleRate: 1.0,
31+
// ... rest of your config
1232
});
1333
```
34+
35+
```javascript {tabTitle:Edge} {filename:sentry.edge.config.(js|ts)}
36+
import * as Sentry from "@sentry/nextjs";
37+
38+
Sentry.init({
39+
dsn: "___PUBLIC_DSN___",
40+
// We recommend adjusting this value in production, or using `tracesSampler`
41+
// for finer control
42+
tracesSampleRate: 1.0,
43+
// ... rest of your config
44+
});
45+
```

0 commit comments

Comments
 (0)