sentry-initor.tsx 708 B

123456789101112131415161718192021222324252627282930
  1. 'use client'
  2. import { useEffect } from 'react'
  3. import * as Sentry from '@sentry/react'
  4. const isDevelopment = process.env.NODE_ENV === 'development'
  5. const SentryInit = ({
  6. children,
  7. }: { children: React.ReactElement }) => {
  8. useEffect(() => {
  9. const SENTRY_DSN = document?.body?.getAttribute('data-public-sentry-dsn')
  10. if (!isDevelopment && SENTRY_DSN) {
  11. Sentry.init({
  12. dsn: SENTRY_DSN,
  13. integrations: [
  14. new Sentry.BrowserTracing({
  15. }),
  16. new Sentry.Replay(),
  17. ],
  18. tracesSampleRate: 0.1,
  19. replaysSessionSampleRate: 0.1,
  20. replaysOnErrorSampleRate: 1.0,
  21. })
  22. }
  23. }, [])
  24. return children
  25. }
  26. export default SentryInit