sentry-initor.tsx 706 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.ReactNode }) => {
  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. Sentry.browserTracingIntegration(),
  15. Sentry.replayIntegration(),
  16. ],
  17. tracesSampleRate: 0.1,
  18. replaysSessionSampleRate: 0.1,
  19. replaysOnErrorSampleRate: 1.0,
  20. })
  21. }
  22. }, [])
  23. return children
  24. }
  25. export default SentryInit