Skip to content

Commit a3e2ae3

Browse files
authored
docs(nextjs): Remove sentry.server.config and sentry.edge.config (#10040)
1 parent 6dd0fff commit a3e2ae3

File tree

5 files changed

+40
-98
lines changed

5 files changed

+40
-98
lines changed

docs/platforms/javascript/common/configuration/integrations/index.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ However, it's important to note that not all integrations are compatible with al
1515

1616
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:
1717

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)`.
2121

2222
</PlatformSection>
2323

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

+35-49
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ export default withSentryConfig(nextConfig, {
6868
});
6969
```
7070

71-
## Create Initialization Config Files
71+
## Create Client Initialization Config File
7272

73-
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.
7674

7775
<SignInNote />
7876

@@ -102,64 +100,52 @@ Sentry.init({
102100
});
103101
```
104102

105-
```javascript {tabTitle:Server} {filename:sentry.server.config.(js|ts)}
106-
import * as Sentry from "@sentry/nextjs";
107-
108-
Sentry.init({
109-
dsn: "___PUBLIC_DSN___",
110-
111-
// Set tracesSampleRate to 1.0 to capture 100%
112-
// of transactions for performance monitoring.
113-
// We recommend adjusting this value in production
114-
tracesSampleRate: 1.0,
115-
116-
// ...
117-
118-
// Note: if you want to override the automatic release value, do not set a
119-
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
120-
// that it will also get attached to your source maps
121-
});
122-
```
123-
124-
```javascript {tabTitle:Edge} {filename:sentry.edge.config.(js|ts)}
125-
import * as Sentry from "@sentry/nextjs";
126-
127-
Sentry.init({
128-
dsn: "___PUBLIC_DSN___",
129-
130-
// Set tracesSampleRate to 1.0 to capture 100%
131-
// of transactions for performance monitoring.
132-
// 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-
143103
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`.
144104

145105
While the client initialization code will be injected into your application's client bundle by `withSentryConfig` which we set up earlier,
146106
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:
148108

149109
```javascript {filename:instrumentation.(js|ts)}
110+
import * as Sentry from "@sentry/nextjs";
111+
150112
export async function register() {
151113
if (process.env.NEXT_RUNTIME === "nodejs") {
152-
await import("./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+
});
153128
}
154129

155130
if (process.env.NEXT_RUNTIME === "edge") {
156-
await import("./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+
});
157145
}
158146
}
159147
```
160148

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-
163149
## Report React Component Render Errors
164150

165151
To capture React render errors you need to add Error components for the App Router and the Pages Router respectively.
@@ -610,9 +596,9 @@ module.exports = withSentryConfig(nextConfig, {
610596

611597
### Opt Out of Sentry SDK bundling in Client or Server side
612598

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)`.
614600

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.
616602

617603
## Disable the Sentry SDK Debug Logger to Save Bundle Size
618604

platform-includes/metrics/configure/javascript.nextjs.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ Sentry.init({
1010
});
1111
```
1212

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.
1414

1515
```JavaScript
16-
// sentry.server.config.js AND/OR sentry.edge.config.js
1716
Sentry.init({
1817
dsn: '___PUBLIC_DSN___',
1918
_experiments: {

platform-includes/performance/configure-sample-rate/javascript.nextjs.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
In both, `sentry.server.config.js` and `sentry.client.config.js`, set:
1+
Set `tracesSampleRate` in `sentry.client.config.js`, as well as in the Sentry setup in `instrumentation.(js|ts)`:
22

33
<SignInNote />
44

platform-includes/performance/opentelemetry-setup/javascript.nextjs.mdx

-43
This file was deleted.

0 commit comments

Comments
 (0)