// tdd-guard:skip — Sentry SDK side-effect bootstrap. Behaviour is owned by
// Sentry; we only configure inputs. KAR-519: DSN comes from env so it is
// not committed.
//
// If SENTRY_DSN is unset the init becomes a no-op (Sentry's documented
// behaviour), which is the correct path for local dev without a Sentry
// project wired up.
import * as Sentry from "@sentry/nextjs"

const dsn = process.env.SENTRY_DSN
const sampleRate = Number(process.env.SENTRY_TRACES_SAMPLE_RATE ?? "0.1")

if (dsn) {
  Sentry.init({
    dsn,
    tracesSampleRate: Number.isFinite(sampleRate) ? sampleRate : 0.1,
    enableLogs: true,
    sendDefaultPii: false,
  })
}
