dify/web/app/components/sentry-initor.tsx

32 lines
712 B
TypeScript
Raw Normal View History

2023-06-29 15:30:12 +08:00
'use client'
import { useEffect } from 'react'
import * as Sentry from '@sentry/react'
2024-05-06 15:32:49 +08:00
import { env } from '@/env'
2023-06-29 15:30:12 +08:00
2024-05-06 15:32:49 +08:00
const isDevelopment = env.NEXT_PUBLIC_NODE_ENV === 'DEVELOPMENT'
2023-06-29 15:30:12 +08:00
const SentryInit = ({
children,
}: { children: React.ReactElement }) => {
useEffect(() => {
2024-05-06 15:32:49 +08:00
const SENTRY_DSN = env.NEXT_PUBLIC_SENTRY_DSN
2023-06-29 15:30:12 +08:00
if (!isDevelopment && SENTRY_DSN) {
Sentry.init({
dsn: SENTRY_DSN,
integrations: [
new Sentry.BrowserTracing({
}),
new Sentry.Replay(),
],
tracesSampleRate: 0.1,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
})
}
}, [])
return children
}
export default SentryInit