Skip to content

Commit

Permalink
Upgrade to @sentry/nextjs 8.13.0
Browse files Browse the repository at this point in the history
The configuration for the server needs to be imported from a next.js instrumentation file `instrumentation.js|ts`. As we're not using edge runtime, neither `sentry.edge.config` or an additional branch in `instrumentation.js` is needed.

Setting a `sentry` property on the Next.js config object as a means of configuration is no longer supported. The `sentryBuildOptions` argument of the `withSentryConfig()` function instead must be used instead.
  • Loading branch information
garciafdezpatricia committed Jul 4, 2024
1 parent 1d8edf3 commit 2a293f0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
20 changes: 20 additions & 0 deletions instrumentation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as Sentry from "@sentry/nextjs";

const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;

export function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
Sentry.init({
dsn: SENTRY_DSN,
});
}

// In case the edge runtime is used:
// 1. Create a sentry.edge.config file
// 2. Uncomment the following lines
// if (process.env.NEXT_RUNTIME === "edge") {
// Sentry.init({
// dsn: SENTRY_DSN,
// });
// }
}
34 changes: 17 additions & 17 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,34 @@ const nextConfig = {
locales: ["en"],
defaultLocale: "en",
},
// Optional build-time configuration options
sentry: {
// See the 'Configure Source Maps' and 'Configure Legacy Browser Support'
// sections below for information on the following options:
//
// We want to expose source maps:
hideSourceMaps: false,
// disableServerWebpackPlugin: true,
// disableClientWebpackPlugin: true,
// autoInstrumentServerFunctions: true,
// widenClientFileUpload: true,
// transpileClientSDK: true
global: globalThis,
experimental: {
instrumentationHook: true,
},
};

const sentryWebpackPluginOptions = {
const sentry = {
// See the 'Configure Source Maps' and 'Configure Legacy Browser Support'
// sections below for information on the following options:
//
// We want to expose source maps:
hideSourceMaps: false,
// disableServerWebpackPlugin: true,
// disableClientWebpackPlugin: true,
// autoInstrumentServerFunctions: true,
// widenClientFileUpload: true,
// transpileClientSDK: true
global: globalThis,

// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, org, project, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore

silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
silent: true, // Suppresses all logs
};

// Make sure adding Sentry options is the last code to run before exporting, to
// ensure that your source maps include changes from all other Webpack plugins
export default withSentryConfig(nextConfig, sentryWebpackPluginOptions);
export default withSentryConfig(nextConfig, sentry);

0 comments on commit 2a293f0

Please sign in to comment.