Skip to content

Commit 6070d09

Browse files
Luca Forstnerbitsandfoxes
authored andcommitted
Refer to instrumentation-client.ts instead of sentry.client.config.ts for Next.js (#13311)
1 parent 7c26e07 commit 6070d09

File tree

12 files changed

+60
-53
lines changed

12 files changed

+60
-53
lines changed

docs/platforms/javascript/common/tracing/instrumentation/automatic-instrumentation.mdx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ Capturing spans requires that you first <PlatformLink to="/tracing/">set up trac
2626

2727
<PlatformSection supported={["javascript.nextjs"]} notSupported={["javascript"]}>
2828

29-
Though the `BrowserTracing` integration is automatically enabled in `@sentry/nextjs`, in order to customize its options you must include it in your `Sentry.init` in `sentry.client.config.js`:
30-
29+
Though the `BrowserTracing` integration is automatically enabled in `@sentry/nextjs`, in order to customize its options you must include it in your `Sentry.init` in `instrumentation-client.js`:
3130

3231
```javascript
3332
import * as Sentry from "@sentry/nextjs";
@@ -76,8 +75,8 @@ You will need to configure your web server [CORS](https://developer.mozilla.org/
7675
<PlatformContent includePath="performance/beforeNavigate-example" />
7776

7877
<Alert>
79-
If you're using React, read our docs to learn how to set up your
80-
[React Router integration](/platforms/javascript/guides/react/configuration/integrations/react-router/).
78+
If you're using React, read our docs to learn how to set up your [React Router
79+
integration](/platforms/javascript/guides/react/configuration/integrations/react-router/).
8180
</Alert>
8281

8382
### shouldCreateSpanForRequest
@@ -131,8 +130,11 @@ This option determines whether spans for long tasks automatically get created.
131130
The default is `true`.
132131

133132
### enableLongAnimationFrame
133+
134134
<Alert>
135-
The `enableLongAnimationFrame` option requires SDK [version 8.18.0](https://github.com/getsentry/sentry-javascript/releases/tag/8.18.0) or higher.
135+
The `enableLongAnimationFrame` option requires SDK [version
136+
8.18.0](https://github.com/getsentry/sentry-javascript/releases/tag/8.18.0) or
137+
higher.
136138
</Alert>
137139

138140
This option determines whether spans for long animation frames get created automatically. If both `enableLongAnimationFrame` and `enableLongTask` are enabled, Sentry will send long animation frames and fallback to long tasks (if long animation frames aren't supported by the browser).
@@ -142,7 +144,9 @@ The default is `true`.
142144
### enableInp
143145

144146
<Alert>
145-
The `enableInp` option requires SDK [version 7.104.0](https://github.com/getsentry/sentry-javascript/releases/tag/7.104.0) or higher.
147+
The `enableInp` option requires SDK [version
148+
7.104.0](https://github.com/getsentry/sentry-javascript/releases/tag/7.104.0)
149+
or higher.
146150
</Alert>
147151

148152
This option determines whether interactions spans automatically get created when an [Interaction to Next Paint (INP)](/product/insights/web-vitals/web-vitals-concepts/#interaction-to-next-paint-inp) event is detected. Interactions are scored and surfaced in the [Web Vitals](/product/insights/web-vitals/) module.
@@ -153,6 +157,7 @@ The default is `true` in `8.x` of the SDK, and `false` in `7.x`.
153157
INP samples currently incur no cost to enable at Sentry. Basic samples contain limited information such as the interaction target, latency, and user. You may wish to enrich your INP samples by setting up [Session Replays](/platforms/javascript/session-replay/) and/or setting up [Browser Profiling](/platforms/javascript/profiling/) instrumentation around your interactive elements to gain further insights into your slowest interactions.
154158

155159
Please note that any Session Replays and Browser Profiles used this way will incur their [standard cost](/pricing/#per-category-pricing) depending on your plan and are subject to the sampling rates configured.
160+
156161
</Alert>
157162

158163
<PlatformContent includePath="performance/enable-inp-example" />

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,19 @@ export default withSentryConfig(nextConfig, {
100100

101101
### Initialize Sentry Client-Side and Server-Side SDKs
102102

103-
Create three files in your application's root directory: `sentry.client.config.(js|ts)`, `sentry.server.config.(js|ts)` and `sentry.edge.config.(js|ts)`. Add the following initialization code into each respective file:
103+
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:
104104

105105
<Alert level="info" title="Note">
106106
These files run in different environments (browser, server, edge) and are
107107
slightly different, so copy them carefully.
108108
</Alert>
109109

110-
```javascript {tabTitle:Client} {filename:sentry.client.config.(js|ts)} {"onboardingOptions": {"performance": "7-13", "session-replay": "5-6, 14-20"}}
110+
```javascript {tabTitle:Client} {filename:instrumentation-client.(js|ts)} {"onboardingOptions": {"performance": "7-13", "session-replay": "5-6, 14-20"}}
111111
import * as Sentry from "@sentry/nextjs";
112112

113+
// This export will instrument router navigations. `captureRouterTransitionStart` is available from SDK version 9.12.0 onwards - upgrade if necessary!
114+
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
115+
113116
Sentry.init({
114117
dsn: "___PUBLIC_DSN___",
115118
// Replay may only be enabled for the client-side
@@ -575,7 +578,7 @@ module.exports = withSentryConfig(nextConfig, {
575578

576579
### Opt Out of Sentry SDK bundling in Client- or Server-Side
577580

578-
If you want the Sentry SDK to be available in your server-side and not in client-side, you can simply delete `sentry.client.config.js`. This will prevent webpack from pulling in the Sentry related files when generating the browser bundle.
581+
If you want the Sentry SDK to be available in your server-side and not in client-side, you can simply delete `instrumentation-client.(js|ts)`. This will prevent webpack from pulling in the Sentry related files when generating the browser bundle.
579582
Similarly, to opt out of server-side SDK bundling, you can simply delete the `sentry.server.config.js` and `sentry.edge.config.js` files. Make sure to remove any imports of these files from `instrumentation.ts`.
580583

581584
## Step 8: Instrument Vercel Cron Jobs (Optional)

platform-includes/configuration/integrations/javascript.nextjs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ However, it's important to note that not all integrations are compatible with al
33

44
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.js runtime, you can only include these integrations in their respective configuration files:
55

6-
- For the browser runtime, add integrations to `sentry.client.config.(js|ts)`.
6+
- For the browser runtime, add integrations to `instrumentation-client.(js|ts)`.
77
- For Node.js.js, add integrations to your Sentry setup in `instrumentation.(js|ts)`.
88
- For the Edge runtime, add integrations to your Sentry setup in `instrumentation.(js|ts)`.
99

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
```javascript {filename:sentry.client.config.ts}
1+
```javascript {filename:instrumentation-client.ts}
22
Sentry.init({
33
// Note, Replay is NOT instantiated below:
44
integrations: [],
55
});
66

77
// Sometime later
8-
import("@sentry/nextjs").then(lazyLoadedSentry => {
8+
import("@sentry/nextjs").then((lazyLoadedSentry) => {
99
Sentry.addIntegration(lazyLoadedSentry.replayIntegration());
1010
});
1111
```

platform-includes/distributed-tracing/how-to-use/javascript.nextjs.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ For client-side, when you are interacting with other external API systems, you m
44

55
<Alert>
66

7-
Note: port numbers are relevant for trace propagation and the origin. You may need to configure the `tracePropagationTargets` to ensure that traces are propagated across your services if they run on different ports.
7+
Note: port numbers are relevant for trace propagation and the origin. You may need to configure the `tracePropagationTargets` to ensure that traces are propagated across your services if they run on different ports.
88

99
For example, if you have a Node.js backend running locally on port 3000, that destination (`http://localhost:3000`) should be added to the `tracePropagationTargets` array on your frontend to ensure that CORS doesn't restrict the propagation of traces.
1010

1111
</Alert>
1212

1313
```javascript
14-
// sentry.client.config.js
14+
// instrumentation-client.js
1515
Sentry.init({
1616
dsn: "___PUBLIC_DSN___",
1717
integrations: [Sentry.browserTracingIntegration()],
@@ -26,7 +26,7 @@ If you're using version `7.57.x` or below, you'll need to have our <PlatformLink
2626
#### Example 1: Microservices E-commerce Platform
2727

2828
```javascript
29-
// sentry.client.config.js
29+
// instrumentation-client.js
3030
Sentry.init({
3131
dsn: "___PUBLIC_DSN___",
3232
integrations: [Sentry.browserTracingIntegration()],
@@ -39,15 +39,15 @@ Sentry.init({
3939

4040
This tells Sentry to pass trace headers across the following paths:
4141

42-
* Your main API server (where product data comes from)
43-
* Your authentication server (where logins happen)
42+
- Your main API server (where product data comes from)
43+
- Your authentication server (where logins happen)
4444

4545
This way, if a customer experiences an error during checkout, or you want to check the performance of a specific endpoint, you can see the complete path their request took across these different services.
4646

4747
#### Example 2: Mobile App with Backend Services
4848

4949
```javascript
50-
// sentry.client.config.js
50+
// instrumentation-client.js
5151
Sentry.init({
5252
dsn: "___PUBLIC_DSN___",
5353
integrations: [Sentry.browserTracingIntegration()],
@@ -56,16 +56,16 @@ Sentry.init({
5656
tracePropagationTargets: [
5757
"https://api.myapp.com",
5858
"https://media.myapp.com",
59-
/^\/local-api\//
59+
/^\/local-api\//,
6060
],
6161
});
6262
```
6363

6464
This configuration lets your app track user actions across:
6565

66-
* Your main API server (handles most app functions)
67-
* Your media server (handles images, videos, etc.)
68-
* Any local API endpoints in your app
66+
- Your main API server (handles most app functions)
67+
- Your media server (handles images, videos, etc.)
68+
- Any local API endpoints in your app
6969

7070
If your app crashes while a user is uploading a photo, you can trace exactly where the problem occurred - in the app itself, the main API, or the media service.
7171

platform-includes/migration/javascript-v8/v7-deprecation/javascript.nextjs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Server-side Integrations:
5959

6060
Browser tracing is automatically set up for you in these packages so you do not need to change you code unless you were using the `BrowserTracing` class directly.
6161

62-
```JavaScript {filename:sentry.client.config.js} diff
62+
```JavaScript {filename:instrumentation-client.js} diff
6363
import * as Sentry from "@sentry/nextjs";
6464

6565
Sentry.init({

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Set `tracesSampleRate` in your config files, `sentry.server.config.js`, `sentry.client.config.js`, and `sentry.edge.config.js`:
2-
1+
Set `tracesSampleRate` in your config files, `instrumentation-client.js`, `sentry.server.config.js`, and `sentry.edge.config.js`:
32

43
```javascript
54
import * as Sentry from "@sentry/nextjs";

platform-includes/profiling/automatic-instrumentation-setup/javascript.nextjs.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
```javascript {filename:sentry.client.config.js|ts}
1+
```javascript {filename:instrumentation-client.js|ts}
22
import * as Sentry from "@sentry/nextjs";
33

44
Sentry.init({
@@ -26,7 +26,7 @@ Sentry.init({
2626

2727
Alternatively, instead of a `profilesSampleRate` your can also provide a `profilesSampler` function:
2828

29-
```javascript {filename:sentry.client.config.js|ts}
29+
```javascript {filename:instrumentation-client.js|ts}
3030
import * as Sentry from "@sentry/nextjs";
3131

3232
Sentry.init({

platform-includes/session-replay/setup/javascript.nextjs.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
On your client-side NextJS app, add:
22

3-
```javascript {8,12,14-20} {filename:sentry.client.config.ts}
3+
```javascript {8,12,14-20} {filename:instrumentation-client.ts}
44
import * as Sentry from "@sentry/nextjs";
55

66
Sentry.init({
@@ -30,11 +30,11 @@ While you're testing, we recommend that you set `replaysSessionSampleRate` to `1
3030

3131
Once testing is complete, **we recommend lowering this value in production**. We still recommend keeping `replaysOnErrorSampleRate` set to `1.0`, so that, whenever possible, every error has an associated replay with additional debugging context.
3232

33-
3433
### PII & Privacy Considerations
3534

3635
Personally identifiable information (PII), and privacy are important considerations when enabling Session Replay. There are multiple ways in which Sentry helps you avoid collecting PII, including:
37-
- [Masking](/platforms/javascript/session-replay/privacy/#masking), which replaces the text content with something else. (The default behavior being to replace each character with a *.)
36+
37+
- [Masking](/platforms/javascript/session-replay/privacy/#masking), which replaces the text content with something else. (The default behavior being to replace each character with a \*.)
3838
- Making [Network request, response bodies, and headers](/platforms/javascript/session-replay/privacy/#network-request-and-response-bodies-and-headers) an opt-in feature, because the best way to avoid getting PII into Sentry is by not adding URLs of endpoints that may contain PII.
3939

4040
While we have certain privacy considerations in place, Sentry's Session Replays allow you to set up the [privacy configurations](/platforms/javascript/session-replay/privacy/#privacy-configuration) that work best for your use case. For example, if you're working on a static website that's free of PII or other types of private data, you can opt out of the default text masking and image blocking settings.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
```javascript
2-
// sentry.client.config.js
2+
// instrumentation-client.js
33
Sentry.init({
44
dsn: "___PUBLIC_DSN___",
55
integrations: [Sentry.browserTracingIntegration()],
66
// Capture 25% of all transactions
7-
tracesSampleRate: 0.25
7+
tracesSampleRate: 0.25,
88
});
9-
```
9+
```

0 commit comments

Comments
 (0)