diff --git a/instrumentation.js b/instrumentation.js new file mode 100644 index 0000000..d36ec41 --- /dev/null +++ b/instrumentation.js @@ -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, + // }); + // } +} diff --git a/next.config.mjs b/next.config.mjs index 327e740..3aed7a7 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -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);