Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🔧 chore: Migrating from Sentry NextJS SDK 7.x to 10.x (#9264)

CanisMinor11ceb8b346ac
diff --git a/next.config.ts b/next.config.ts
index 46f0eb706ef..2f9593a6e4f 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -330,44 +330,35 @@ const hasSentry = !!process.env.NEXT_PUBLIC_SENTRY_DSN;
const withSentry =
isProd && hasSentry
? (c: NextConfig) =>
- withSentryConfig(
- c,
- {
- org: process.env.SENTRY_ORG,
+ withSentryConfig(c, {
+ // Enables automatic instrumentation of Vercel Cron Monitors.
+ // See the following for more information:
+ // https://docs.sentry.io/product/crons/
+ // https://vercel.com/docs/cron-jobs
+ automaticVercelMonitors: true,
- project: process.env.SENTRY_PROJECT,
- // For all available options, see:
- // https://github.com/getsentry/sentry-webpack-plugin#options
- // Suppresses source map uploading logs during build
- silent: true,
- },
- {
- // Enables automatic instrumentation of Vercel Cron Monitors.
- // See the following for more information:
- // https://docs.sentry.io/product/crons/
- // https://vercel.com/docs/cron-jobs
- automaticVercelMonitors: true,
+ // Automatically tree-shake Sentry logger statements to reduce bundle size
+ disableLogger: true,
- // Automatically tree-shake Sentry logger statements to reduce bundle size
- disableLogger: true,
+ org: process.env.SENTRY_ORG,
- // Hides source maps from generated client bundles
- hideSourceMaps: true,
+ project: process.env.SENTRY_PROJECT,
- // Transpiles SDK to be compatible with IE11 (increases bundle size)
- transpileClientSDK: true,
+ // For all available options, see:
+ // https://github.com/getsentry/sentry-webpack-plugin#options
+ // Suppresses source map uploading logs during build
+ silent: true,
- // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers. (increases server load)
- // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
- // side errors will fail.
- tunnelRoute: '/monitoring',
+ // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers. (increases server load)
+ // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
+ // side errors will fail.
+ tunnelRoute: '/monitoring',
- // For all available options, see:
- // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
- // Upload a larger set of source maps for prettier stack traces (increases build time)
- widenClientFileUpload: true,
- },
- )
+ // For all available options, see:
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
+ // Upload a larger set of source maps for prettier stack traces (increases build time)
+ widenClientFileUpload: true,
+ })
: noWrapper;
export default withBundleAnalyzer(withPWA(withSentry(nextConfig) as NextConfig));
diff --git a/package.json b/package.json
index 28a64498bdf..d13b1c02757 100644
--- a/package.json
+++ b/package.json
@@ -167,7 +167,7 @@
"@neondatabase/serverless": "^1.0.1",
"@next/third-parties": "^15.5.3",
"@react-spring/web": "^9.7.5",
- "@sentry/nextjs": "^7.120.4",
+ "@sentry/nextjs": "^10.11.0",
"@serwist/next": "^9.2.1",
"@t3-oss/env-nextjs": "^0.13.8",
"@tanstack/react-query": "^5.87.4",
diff --git a/sentry.client.config.ts b/sentry.client.config.ts
index 0bf965a82f5..e088f25ea64 100644
--- a/sentry.client.config.ts
+++ b/sentry.client.config.ts
@@ -11,6 +11,7 @@ if (!!process.env.NEXT_PUBLIC_SENTRY_DSN) {
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
// You can remove this option if you're not planning to use the Sentry Session Replay feature:
integrations: [
+ Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
blockAllMedia: true,
// Additional Replay configuration goes in here, for example:
diff --git a/src/instrumentation.ts b/src/instrumentation.ts
new file mode 100644
index 00000000000..84c2170a895
--- /dev/null
+++ b/src/instrumentation.ts
@@ -0,0 +1,10 @@
+// ref: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
+export async function register() {
+ if (process.env.NEXT_RUNTIME === 'nodejs') {
+ await import('../sentry.server.config');
+ }
+
+ if (process.env.NEXT_RUNTIME === 'edge') {
+ await import('../sentry.edge.config');
+ }
+}