// A no-op when NEXT_PUBLIC_SENTRY_DSN isn't set, so this is safe in every environment // (dev, or a fresh deploy that hasn't configured Sentry yet). The dynamic import (rather // than a top-level `import * as Sentry`) keeps the Sentry client SDK out of every visitor's // bundle entirely when it's unconfigured — Next inlines NEXT_PUBLIC_* at build time, so an // unset DSN lets the bundler dead-code-eliminate this whole block, import included. if (process.env.NEXT_PUBLIC_SENTRY_DSN) { const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN; import("@sentry/nextjs").then((Sentry) => { Sentry.init({ dsn, environment: process.env.NODE_ENV || "development", // Small single-VM deployment, not high-traffic — start conservative and raise // this once real usage is visible in Sentry, rather than sampling every request. tracesSampleRate: 0.1, }); }); }