// Sentry initialization for the browser. Next.js loads this client-side
// instrumentation file automatically (Next 15.3+).
import * as Sentry from "@sentry/nextjs"

const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN

Sentry.init({
  dsn,
  // Inert until a DSN is configured.
  enabled: !!dsn,
  environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT || process.env.NODE_ENV,
  tracesSampleRate: process.env.NODE_ENV === "production" ? 0.2 : 1.0,
  // Session Replay: record 10% of all sessions, and 100% of sessions with an
  // error. Text is masked and media blocked so tenant/landlord PII isn't captured.
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
  integrations: [Sentry.replayIntegration({ maskAllText: true, blockAllMedia: true })],
})

// Instrument client-side route transitions for tracing.
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart
