// Инициализирует Sentry на клиенте. Два режима: // - мягкий (флаг выключен): клиент не грузится вовсе, кроме ручного дебага через // localStorage.sentry_debug=1 — тогда собираются только ошибки, без трейсов и replay; // - полный (SentryFullCollectionEnabled): трейсы, session replay на 100% и tracking // компонентов. Грузит производительность. // SDK всегда импортируется динамически, чтобы не попадать в бандл в мягком режиме. export default defineNuxtPlugin(async (nuxtApp) => { const full = useRuntimeConfig().public.featureFlags.SentryFullCollectionEnabled; const enabled = full || localStorage.getItem('sentry_debug') === '1'; if (!enabled) return; const Sentry = await import('@sentry/nuxt'); const integrations = [ Sentry.vueIntegration({ app: nuxtApp.vueApp, attachErrorHandler: true, trackComponents: full, }), ]; if (full) { integrations.push(Sentry.browserTracingIntegration(), Sentry.replayIntegration()); } Sentry.init({ dsn: useRuntimeConfig().public.sentryDsn, tracesSampleRate: full ? 1.0 : 0, replaysSessionSampleRate: full ? 1.0 : 0, replaysOnErrorSampleRate: full ? 1.0 : 0, integrations, }); });