Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This integration can be very helpful in reducing noise that's not related to you

<Alert>

**Prerequisite**: To use the `thirdPartyErrorFilterIntegration`, ensure you are using a bundler and one of [Sentry's bundler plugins](https://github.com/getsentry/sentry-javascript-bundler-plugins). For **Next.js with Turbopack**, use the [`_experimental.turbopackApplicationKey`](/platforms/javascript/guides/nextjs/configuration/build/#_experimentalturbopackapplicationkey) build option instead.
**Prerequisite**: To use the `thirdPartyErrorFilterIntegration`, ensure you are using a bundler and one of [Sentry's bundler plugins](https://github.com/getsentry/sentry-javascript-bundler-plugins). For **Next.js**, set the [`applicationKey`](/platforms/javascript/guides/nextjs/configuration/build/#applicationKey) build option, which works for both Webpack and Turbopack builds.

</Alert>

Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/javascript/common/troubleshooting/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ shamefully-hoist=true
};

// The Sentry plugin should always be applied last
const { withSentryConfig } = require('@sentry/nextjs');
const { withSentryConfig } = require('@sentry/nextjs/config');
module.exports = withSentryConfig(module.exports)
```

Expand Down
166 changes: 73 additions & 93 deletions docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,72 @@ Excluded routes will appear as raw URLs in transaction names instead of paramete

</SdkOption>

<SdkOption name="reactComponentAnnotation" type="object">

Annotates your React components with `data-sentry-component`, `data-sentry-element`, and `data-sentry-source-file` attributes at build time, so Sentry can identify which component a user interacted with in [Session Replay](/platforms/javascript/guides/nextjs/session-replay/) and [breadcrumbs](/platforms/javascript/guides/nextjs/enriching-events/breadcrumbs/).

Disabled unless you set a value. Set `enabled: true` to turn it on, and `ignoredComponents` to skip components by name.

This option drives both Webpack and Turbopack builds. On Turbopack it requires **Next.js 16+**; on an older version the SDK warns at build time.

```javascript {filename:next.config.ts}
import { withSentryConfig } from "@sentry/nextjs/config";

export default withSentryConfig(nextConfig, {
reactComponentAnnotation: {
enabled: true,
ignoredComponents: ["SensitiveForm", "InternalDebugPanel"],
},
});
```

<Alert level="info">
The bundler-specific `webpack.reactComponentAnnotation` and
`_experimental.turbopackReactComponentAnnotation` options are deprecated in
favor of this one and will be removed in the next major version. If both a
bundler-specific option and this one are set, the bundler-specific one wins
for that bundler.
</Alert>

</SdkOption>

<SdkOption name="applicationKey" type="string">

Application key used by [`thirdPartyErrorFilterIntegration`](/platforms/javascript/configuration/filtering/#using-thirdpartyerrorfilterintegration) to tell your code apart from third-party code, so you can drop errors coming from browser extensions, injected scripts, and third-party widgets.

The value must match an entry in the `filterKeys` array of your `thirdPartyErrorFilterIntegration` configuration. This option works for both Webpack and Turbopack builds.

```javascript {tabTitle:Config} {mdExpandTabs} {filename:next.config.ts}
import { withSentryConfig } from "@sentry/nextjs/config";

export default withSentryConfig(nextConfig, {
applicationKey: "my-nextjs-app",
});
```

```javascript {tabTitle:Client} {filename:instrumentation-client.ts}
import * as Sentry from "@sentry/nextjs";

Sentry.init({
integrations: [
Sentry.thirdPartyErrorFilterIntegration({
filterKeys: ["my-nextjs-app"],
behaviour: "drop-error-if-exclusively-contains-third-party-frames",
}),
],
});
```

</SdkOption>

<SdkOption name="buildTimeInstrumentation" type="boolean" defaultValue="true">

Automatically instrument server-side dependencies at build time. This is what gives you tracing for libraries that can't be patched at runtime, including on platforms like Vercel and Netlify.

Set to `false` to turn it off. Turbopack support requires **Next.js 16+**; the Webpack path works on earlier versions.

</SdkOption>

## Next.js Webpack Options

<Alert level="info">
Expand Down Expand Up @@ -343,118 +409,32 @@ Automatically create cron monitors in Sentry for your Vercel Cron Jobs if config

</SdkOption>

<SdkOption
name="webpack.unstable_sentryWebpackPluginOptions"
type="SentryWebpackPluginOptions"
>
Pass configuration options directly to the [Sentry Webpack
Plugin](https://www.npmjs.com/package/@sentry/webpack-plugin) that ships with
the Sentry Next.js SDK. If `withSentryConfig` doesn't provide the option you
need to modify, you may override the `sentryWebpackPluginOptions` using this
option.
<Alert level="warning" title="Important">
This option is considered unstable, and its API may change in a breaking way
in any release.
</Alert>
</SdkOption>

<SdkOption name="webpack.reactComponentAnnotation.enabled" type="boolean" defaultValue="false">

Enables React component name tracking. When enabled, it annotates React components with data attributes that allow Sentry to track which components users interacted with in features like Session Replay and breadcrumbs.

</SdkOption>

<SdkOption name="webpack.reactComponentAnnotation.ignoredComponents" type="string[] | undefined">

A list of React component names to exclude from component annotation.

</SdkOption>

<SdkOption name="webpack.treeshake" type="object">

Configuration options for tree shaking. Refer to the [tree shaking documentation](/platforms/javascript/guides/nextjs/configuration/tree-shaking) for more details.

</SdkOption>

## Experimental Turbopack Options
## Experimental Options

<Alert level="warning">
These options are experimental and require **Next.js 16+**. Their API may
change in future releases.
These options are experimental. Their API may change in future releases.
</Alert>

<SdkOption name="_experimental.turbopackReactComponentAnnotation.enabled" type="boolean" defaultValue="false">

<AvailableSince version="10.43.0" />

Enables React component name annotation for Turbopack builds. This is the Turbopack equivalent of [`webpack.reactComponentAnnotation`](#webpackreactcomponentannotationenabled).

When enabled, React components are annotated with `data-sentry-component`, `data-sentry-element`, and `data-sentry-source-file` attributes at build time. These attributes allow Sentry to identify which components users interacted with in [Session Replay](/platforms/javascript/guides/nextjs/session-replay/) and [breadcrumbs](/platforms/javascript/guides/nextjs/enriching-events/breadcrumbs/).

```javascript {filename:next.config.ts}
import { withSentryConfig } from "@sentry/nextjs";

export default withSentryConfig(nextConfig, {
_experimental: {
turbopackReactComponentAnnotation: {
enabled: true,
},
},
});
```

</SdkOption>
<SdkOption name="_experimental.vercelCronsMonitoring" type="boolean" defaultValue="false">

<SdkOption name="_experimental.turbopackReactComponentAnnotation.ignoredComponents" type="string[]">
Automatically create [Cron Monitors](/product/monitors-and-alerts/monitors/crons/) in Sentry for the Vercel Cron Jobs configured in your `vercel.json`, by detecting cron requests and emitting check-ins from spans.

A list of React component names to exclude from annotation in Turbopack builds.
Unlike [`webpack.automaticVercelMonitors`](#webpack.automaticVercelMonitors), which wraps route handlers at build time, this works with both Webpack and Turbopack and with both the App Router and the Pages Router. If you enable both, the SDK uses this one and warns that the other is redundant.

```javascript {filename:next.config.ts}
import { withSentryConfig } from "@sentry/nextjs";
import { withSentryConfig } from "@sentry/nextjs/config";

export default withSentryConfig(nextConfig, {
_experimental: {
turbopackReactComponentAnnotation: {
enabled: true,
ignoredComponents: ["SensitiveForm", "InternalDebugPanel"],
},
vercelCronsMonitoring: true,
},
});
```

</SdkOption>

<SdkOption name="_experimental.turbopackApplicationKey" type="string">

<AvailableSince version="10.41.0" />

Application key used by [`thirdPartyErrorFilterIntegration`](/platforms/javascript/configuration/filtering/#using-thirdpartyerrorfilterintegration) to distinguish first-party code from third-party code in Turbopack builds. This is the Turbopack equivalent of setting `applicationKey` via the Sentry Webpack Plugin.

When set, a Turbopack loader injects `_sentryModuleMetadata` into every first-party module, enabling the `thirdPartyErrorFilterIntegration` to filter errors from browser extensions, injected scripts, and third-party widgets.

The value must match the `filterKeys` array in your `thirdPartyErrorFilterIntegration` configuration.

```javascript {tabTitle:Config} {filename:next.config.ts}
import { withSentryConfig } from "@sentry/nextjs";

export default withSentryConfig(nextConfig, {
_experimental: {
turbopackApplicationKey: "my-nextjs-app",
},
});
```

```javascript {tabTitle:Client} {filename:instrumentation-client.ts}
import * as Sentry from "@sentry/nextjs";

Sentry.init({
integrations: [
Sentry.thirdPartyErrorFilterIntegration({
filterKeys: ["my-nextjs-app"],
behaviour: "drop-error-if-exclusively-contains-third-party-frames",
}),
],
});
```

</SdkOption>
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The following sections cover each available tree-shaking option and how to confi

<SdkOption name="webpack.treeshake.removeDebugLogging" type="boolean" defaultValue="false">

Setting this option to true will remove all Sentry SDK debug logging code (the console logs that appear when you set `debug: true` in your SDK configuration). This doesn't affect Sentry's Logs product (controlled by the `enableLogs` option) or your app's logging.
Setting this option to true will remove all Sentry SDK debug logging code (the console logs that appear when you set `debug: true` in your SDK configuration). This doesn't affect Sentry's Logs product or your app's logging.

</SdkOption>

Expand Down
4 changes: 3 additions & 1 deletion docs/platforms/javascript/guides/nextjs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Sentry.init({
// ___PRODUCT_OPTION_END___ session-replay
],
});

export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
```

```typescript {tabTitle:Server} {filename:sentry.server.config.ts}
Expand Down Expand Up @@ -148,7 +150,7 @@ Your `next.config.ts` is wrapped with `withSentryConfig` to enable source map up
<SplitSectionCode>

```typescript {filename:next.config.ts}
import { withSentryConfig } from "@sentry/nextjs";
import { withSentryConfig } from "@sentry/nextjs/config";

export default withSentryConfig(nextConfig, {
org: "___ORG_SLUG___",
Expand Down
6 changes: 1 addition & 5 deletions docs/platforms/javascript/guides/nextjs/logs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ Logs work across all Next.js runtimes:
- **Server** — Node.js server-side logging
- **Edge** — Edge runtime logging

<Alert>
On SDK versions below `10.71.0`, logs are opt-in. Set `enableLogs: true` in your `Sentry.init` in all three runtime files to send them.
</Alert>

</SplitSectionText>
<SplitSectionCode>

Expand Down Expand Up @@ -386,7 +382,7 @@ Any attributes set via `Sentry.setAttribute()` / `Sentry.setAttributes()` (or di

### Logs not appearing

On SDK versions below `10.71.0`, logs are opt-in. Make sure `enableLogs: true` is set in **all** Sentry config files:
Logs are captured as soon as you call a `Sentry.logger.*` method or add a logging integration. Check that the runtime you're logging from initializes the SDK at all:

- `instrumentation-client.ts` (client)
- `sentry.server.config.ts` (server)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Extend your app's default Next.js options by adding `withSentryConfig` into your

```typescript {filename:next.config.ts}
import type { NextConfig } from "next";
import { withSentryConfig } from "@sentry/nextjs";
import { withSentryConfig } from "@sentry/nextjs/config";

const nextConfig: NextConfig = {
// Your existing Next.js configuration
Expand Down Expand Up @@ -156,10 +156,7 @@ Sentry.init({
// ___PRODUCT_OPTION_END___ session-replay
});

// ___PRODUCT_OPTION_START___ performance
// This export will instrument router navigations
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
// ___PRODUCT_OPTION_END___ performance
```

```typescript {tabTitle:Server} {filename:sentry.server.config.ts}
Expand Down
Loading
Loading