Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import * as Sentry from '@sentry/nextjs'
|
|
|
|
import { shouldDropExpectedProductSentryEvent } from './lib/observability/expectedProductError'
|
|
|
|
const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN?.trim()
|
|
|
|
function tracesSampleRate(): number {
|
|
const raw = process.env.NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE ?? '0.1'
|
|
const parsed = Number.parseFloat(raw)
|
|
|
|
return Number.isFinite(parsed) ? parsed : 0.1
|
|
}
|
|
|
|
export function initBrowserSentry() {
|
|
// فقط در production — در local/dev نویز و مصرف سهمیه نمیخواهیم
|
|
if (process.env.NODE_ENV !== 'production' || !dsn) return
|
|
|
|
Sentry.init({
|
|
dsn,
|
|
environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT?.trim() || process.env.NODE_ENV || 'production',
|
|
release: process.env.NEXT_PUBLIC_APP_VERSION || undefined,
|
|
tracesSampleRate: tracesSampleRate(),
|
|
// Replay off by default (privacy + quota). Enable later if needed.
|
|
sendDefaultPii: false,
|
|
beforeSend(event, hint) {
|
|
if (shouldDropExpectedProductSentryEvent(event, hint.originalException)) return null
|
|
|
|
return event
|
|
},
|
|
})
|
|
}
|