// Sentry initialization for the Node.js server runtime.
// Loaded by instrumentation.ts when NEXT_RUNTIME === "nodejs".
import * as Sentry from "@sentry/nextjs"

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

Sentry.init({
  dsn,
  // Inert until a DSN is configured — safe to ship before Sentry is set up.
  enabled: !!dsn,
  environment: process.env.SENTRY_ENVIRONMENT || process.env.NODE_ENV,
  // Performance tracing — sample less in production to control volume/cost.
  tracesSampleRate: process.env.NODE_ENV === "production" ? 0.2 : 1.0,
  // Don't attach PII (IP, cookies, request bodies) by default.
  sendDefaultPii: false,
})
