diff --git a/docs/platforms/javascript/guides/nextjs/manual-setup.mdx b/docs/platforms/javascript/guides/nextjs/manual-setup.mdx index fef4e39593acb..8606f00a8006a 100644 --- a/docs/platforms/javascript/guides/nextjs/manual-setup.mdx +++ b/docs/platforms/javascript/guides/nextjs/manual-setup.mdx @@ -87,7 +87,13 @@ export default withSentryConfig(nextConfig, { ### Initialize Sentry Client-Side and Server-Side SDKs -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: +Create three files in your application's root directory: +- `sentry.server.config.(js|ts)` +- `sentry.edge.config.(js|ts)` +- `instrumentation-client.(js|ts)` + - 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. + +Add the following initialization code into each respective file: These files run in different environments (browser, server, edge) and are @@ -112,8 +118,8 @@ Sentry.init({ // https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate tracesSampleRate: 1.0, // ___PRODUCT_OPTION_END___ performance - // Replay may only be enabled for the client-side // ___PRODUCT_OPTION_START___ session-replay + // Replay may only be enabled for the client-side integrations: [Sentry.replayIntegration()], // Capture Replay for 10% of all sessions, @@ -188,10 +194,8 @@ Sentry.init({ }); ``` - - Include your [Data Source Name](/concepts/key-terms/dsn-explainer/) (DSN) - directly in these files, or use a _public_ environment variable like - `NEXT_PUBLIC_SENTRY_DSN`. + + Include your DSN directly in these files, or use a _public_ environment variable like `NEXT_PUBLIC_SENTRY_DSN`. ### Register Sentry Server-Side SDK Initialization @@ -210,12 +214,6 @@ export async function register() { } ``` - - You need to enable the instrumentation hook by setting the - `experimental.instrumentationHook` to `true` in your `next.config.(js|mjs)` - file. - - If you want the Sentry SDK to be available on the server side and not on the client side, simply delete `instrumentation-client.(js|ts)`. This will prevent diff --git a/platform-includes/performance/configure-sample-rate/javascript.nextjs.mdx b/platform-includes/performance/configure-sample-rate/javascript.nextjs.mdx index ef9209563348c..c0a1484e608ff 100644 --- a/platform-includes/performance/configure-sample-rate/javascript.nextjs.mdx +++ b/platform-includes/performance/configure-sample-rate/javascript.nextjs.mdx @@ -1,13 +1,45 @@ -Set `tracesSampleRate` in your config files, `instrumentation-client.js`, `sentry.server.config.js`, and `sentry.edge.config.js`: +Set `tracesSampleRate` in your config files: +- `sentry.server.config.js` +- `sentry.edge.config.js`: +- `instrumentation-client.js` + - 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. -```javascript +```javascript {tabTitle:Client} {filename:instrumentation-client.(js|ts)} import * as Sentry from "@sentry/nextjs"; Sentry.init({ dsn: "___PUBLIC_DSN___", + // We recommend adjusting this value in production, or using `tracesSampler` + // for finer control + tracesSampleRate: 1.0, + // ... rest of your config +}); + +// This export will instrument router navigations, and is only relevant if you enable tracing. +// `captureRouterTransitionStart` is available from SDK version 9.12.0 onwards +export const onRouterTransitionStart = Sentry.captureRouterTransitionStart; +``` + +```javascript {tabTitle:Server} {filename:sentry.server.config.(js|ts)} +import * as Sentry from "@sentry/nextjs"; +Sentry.init({ + dsn: "___PUBLIC_DSN___", // We recommend adjusting this value in production, or using `tracesSampler` // for finer control tracesSampleRate: 1.0, + // ... rest of your config }); ``` + +```javascript {tabTitle:Edge} {filename:sentry.edge.config.(js|ts)} +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + // We recommend adjusting this value in production, or using `tracesSampler` + // for finer control + tracesSampleRate: 1.0, + // ... rest of your config +}); +``` \ No newline at end of file