mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-18 05:26:56 +08:00

Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: jZonG <jzongcode@gmail.com>
30 lines
706 B
TypeScript
30 lines
706 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.ReactNode }) => {
|
|
useEffect(() => {
|
|
const SENTRY_DSN = document?.body?.getAttribute('data-public-sentry-dsn')
|
|
if (!isDevelopment && SENTRY_DSN) {
|
|
Sentry.init({
|
|
dsn: SENTRY_DSN,
|
|
integrations: [
|
|
Sentry.browserTracingIntegration(),
|
|
Sentry.replayIntegration(),
|
|
],
|
|
tracesSampleRate: 0.1,
|
|
replaysSessionSampleRate: 0.1,
|
|
replaysOnErrorSampleRate: 1.0,
|
|
})
|
|
}
|
|
}, [])
|
|
return children
|
|
}
|
|
|
|
export default SentryInit
|