mirror of
https://gitee.com/dify_ai/dify.git
synced 2024-12-05 04:38:37 +08:00
31 lines
708 B
TypeScript
31 lines
708 B
TypeScript
|
'use client'
|
||
|
|
||
|
import { useEffect } from 'react'
|
||
|
import * as Sentry from '@sentry/react'
|
||
|
|
||
|
const isDevelopment = process.env.NODE_ENV === 'development'
|
||
|
|
||
|
const SentryInit = ({
|
||
|
children,
|
||
|
}: { children: React.ReactElement }) => {
|
||
|
useEffect(() => {
|
||
|
const SENTRY_DSN = document?.body?.getAttribute('data-public-sentry-dsn')
|
||
|
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
|