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

30 lines
689 B
TypeScript
Raw Normal View History

2023-06-29 07:30:12 +00:00
'use client'
import * as Sentry from '@sentry/react'
import { useEffect } from 'react'
2023-06-29 07:30:12 +00:00
import { IS_DEV } from '@/config'
2023-06-29 07:30:12 +00:00
const SentryInitializer = ({
2023-06-29 07:30:12 +00:00
children,
}: { children: React.ReactElement }) => {
2023-06-29 07:30:12 +00:00
useEffect(() => {
const SENTRY_DSN = document?.body?.getAttribute('data-public-sentry-dsn')
if (!IS_DEV && SENTRY_DSN) {
2023-06-29 07:30:12 +00:00
Sentry.init({
dsn: SENTRY_DSN,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration(),
2023-06-29 07:30:12 +00:00
],
tracesSampleRate: 0.1,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
})
}
}, [])
return children
}
export default SentryInitializer