import * as Sentry from '@sentry/react' import { inIframe } from '../utils/inIframe' export function initSentry() { if (inIframe && import.meta.env.VITE_SENTRY_ENABLE_IN_IFRAME !== 'true') { return } Sentry.init({ dsn: import.meta.env.VITE_SENTRY_DSN, environment: import.meta.env.VITE_SENTRY_ENVIRONMENT || 'development', release: import.meta.env.VITE_SENTRY_RELEASE, sendDefaultPii: true, ignoreErrors: [], tracesSampleRate: 0.5, integrations: [ Sentry.browserTracingIntegration(), // Sentry in iframe is currently enabled for a few internal users only, so enable Session Replay there to test the experience ...(inIframe ? [Sentry.replayIntegration({ maskAllText: false, maskAllInputs: false, blockAllMedia: false, networkDetailAllowUrls: [/^\/api\//], networkCaptureBodies: true, })] : []), ], ...(inIframe ? { replaysSessionSampleRate: 1.0, replaysOnErrorSampleRate: 1.0 } : {}), enableLogs: true, tracePropagationTargets: [ 'localhost', /^https:\/\/.*\.paraflow\.cc/, /^https:\/\/.*\.paraflow\.com/, /^\/api\//, ], }) } export function setSentryUser(user: { id: string; email: string; name: string | null } | null) { if (inIframe && import.meta.env.VITE_SENTRY_ENABLE_IN_IFRAME !== 'true') { return } Sentry.setUser({ id: user?.id, email: user?.email, username: user?.name ?? undefined }) }