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
Copy file name to clipboardExpand all lines: docs/platforms/javascript/common/configuration/integrations/index.mdx
+3-3
Original file line number
Diff line number
Diff line change
@@ -15,9 +15,9 @@ However, it's important to note that not all integrations are compatible with al
15
15
16
16
Depending on whether an integration enhances the functionality of a particular runtime, such as the BrowserTracing integration for the browser runtime or the RequestData integration for the Node.js runtime, you can only include these integrations in their respective configuration files:
17
17
18
-
- For the browser runtime, add integrations to `sentry.client.config.ts`.
19
-
- For Node.js, add integrations to `sentry.server.config.ts`.
20
-
- For the Edge runtime, add integrations to `sentry.edge.config.ts`.
18
+
- For the browser runtime, add integrations to `sentry.client.config.(js|ts)`.
19
+
- For Node.js, add integrations to your Sentry setup in `instrumentation.(js|ts)`.
20
+
- For the Edge runtime, add integrations to your Sentry setup in `instrumentation.(js|ts)`.
Create three files in the root directory of your Next.js application: `sentry.client.config.js`, `sentry.server.config.js` and `sentry.edge.config.js`. In these files, add your initialization code for the client-side SDK and server-side SDK, respectively. We've included some examples below.
74
-
75
-
Please note that there are slight differences between these files since they run in different places (browser, server, edge), so copy them carefully!
73
+
Create this file in the root directory of your Next.js application: `sentry.client.config.js`. In this file, add your initialization code for the client-side SDK. The setup for browser-side initialization is explained below.
// We recommend adjusting this value in production
133
-
tracesSampleRate:1.0,
134
-
135
-
// ...
136
-
137
-
// Note: if you want to override the automatic release value, do not set a
138
-
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
139
-
// that it will also get attached to your source maps
140
-
});
141
-
```
142
-
143
103
We recommend you include your DSN directly in these three files. Alternatively you can pass the DSN via a _public_ environment variable like `NEXT_PUBLIC_SENTRY_DSN`.
144
104
145
105
While the client initialization code will be injected into your application's client bundle by `withSentryConfig` which we set up earlier,
146
106
the configuration for the server and edge runtime needs to be imported from a [Next.js Instrumentation file](https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation).
147
-
You can set this file up by adding a `instrumentation.ts` file to the root directory of your Next.js application (or inside the `src` folder if you are using one) and adding the following content:
107
+
You can set this file up by adding a `instrumentation.(js|ts)` file to the root directory of your Next.js application (or inside the `src` folder if you are using one) and adding the following content:
148
108
149
109
```javascript {filename:instrumentation.(js|ts)}
110
+
import*asSentryfrom"@sentry/nextjs";
111
+
150
112
exportasyncfunctionregister() {
151
113
if (process.env.NEXT_RUNTIME==="nodejs") {
152
-
awaitimport("./sentry.server.config");
114
+
Sentry.init({
115
+
dsn:"___PUBLIC_DSN___",
116
+
117
+
// Set tracesSampleRate to 1.0 to capture 100%
118
+
// of transactions for performance monitoring.
119
+
// We recommend adjusting this value in production
120
+
tracesSampleRate:1.0,
121
+
122
+
// ...
123
+
124
+
// Note: if you want to override the automatic release value, do not set a
125
+
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
126
+
// that it will also get attached to your source maps
127
+
});
153
128
}
154
129
155
130
if (process.env.NEXT_RUNTIME==="edge") {
156
-
awaitimport("./sentry.edge.config");
131
+
Sentry.init({
132
+
dsn:"___PUBLIC_DSN___",
133
+
134
+
// Set tracesSampleRate to 1.0 to capture 100%
135
+
// of transactions for performance monitoring.
136
+
// We recommend adjusting this value in production
137
+
tracesSampleRate:1.0,
138
+
139
+
// ...
140
+
141
+
// Note: if you want to override the automatic release value, do not set a
142
+
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
143
+
// that it will also get attached to your source maps
144
+
});
157
145
}
158
146
}
159
147
```
160
148
161
-
Make sure that the `import` statements point to your newly created `sentry.server.config.(js|ts)` and `sentry.edge.config.(js|ts)` files.
162
-
163
149
## Report React Component Render Errors
164
150
165
151
To capture React render errors you need to add Error components for the App Router and the Pages Router respectively.
### Opt Out of Sentry SDK bundling in Client or Server side
612
598
613
-
If you want the `sentry` to be available in your server side & not in client side, you can make your `sentry.client.config.js` empty. This will prevent webpack from pulling in the Sentry related files when generating the browser bundle. The same goes the opposite for opting out of server side bundle by emptying `sentry.server.config.js`.
599
+
If you want the `sentry` to be available in your server side & not in client side, you can make your `sentry.client.config.js` empty. This will prevent webpack from pulling in the Sentry related files when generating the browser bundle. The same goes the opposite for opting out of server side bundle by not initializing Sentry inside `instrumentation.(js|ts)`.
614
600
615
-
You cannot delete the respective config files because the SDK requires you to have it.
601
+
You cannot delete the client config file because the SDK requires you to have it.
616
602
617
603
## Disable the Sentry SDK Debug Logger to Save Bundle Size
Copy file name to clipboardExpand all lines: platform-includes/metrics/configure/javascript.nextjs.mdx
+1-2
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,9 @@ Sentry.init({
10
10
});
11
11
```
12
12
13
-
To configure metrics for your server-side code, add the `metricsAggregator` experimental option to your `Sentry.init` call in your `sentry.server.config.js` and `sentry.edge.config.js` files.
13
+
To configure metrics for your server-side code, add the `metricsAggregator` experimental option to your `Sentry.init` call in your `instrumentation.(js|ts)` file.
0 commit comments