/**
 * Sentry shim.
 *
 * This module exposes the small surface area the rest of the codebase needs
 * (`init()`, `captureException(err, ctx?)`). The default implementation is a
 * no-op — `@sentry/nextjs` isn't installed yet. Swapping in the real SDK is
 * a 1-file change here once the dep lands and `SENTRY_DSN` is set.
 *
 * Callers should NOT branch on whether Sentry is configured. They should
 * just call `captureException` — this module decides whether to forward.
 */

import { env } from '@/lib/env';

let initialized = false;

export function init(): void {
    if (initialized) return;
    initialized = true;
    // No-op today. When @sentry/nextjs is installed:
    //   if (env.SENTRY_DSN) {
    //     const Sentry = require('@sentry/nextjs');
    //     Sentry.init({ dsn: env.SENTRY_DSN, tracesSampleRate: 0.1 });
    //   }
}

export function captureException(err: unknown, ctx?: Record<string, unknown>): void {
    if (!env.SENTRY_DSN) return;
    // No-op today. When @sentry/nextjs is installed:
    //   const Sentry = require('@sentry/nextjs');
    //   Sentry.captureException(err, { extra: ctx });
    void err;
    void ctx;
}

export function isConfigured(): boolean {
    return !!env.SENTRY_DSN;
}
