| 
									
										
										
										
											2023-06-29 15:30:12 +08:00
										 |  |  | 'use client' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { useEffect } from 'react' | 
					
						
							|  |  |  | import * as Sentry from '@sentry/react' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const isDevelopment = process.env.NODE_ENV === 'development' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const SentryInit = ({ | 
					
						
							|  |  |  |   children, | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  | }: { children: React.ReactNode }) => { | 
					
						
							| 
									
										
										
										
											2023-06-29 15:30:12 +08:00
										 |  |  |   useEffect(() => { | 
					
						
							|  |  |  |     const SENTRY_DSN = document?.body?.getAttribute('data-public-sentry-dsn') | 
					
						
							|  |  |  |     if (!isDevelopment && SENTRY_DSN) { | 
					
						
							|  |  |  |       Sentry.init({ | 
					
						
							|  |  |  |         dsn: SENTRY_DSN, | 
					
						
							|  |  |  |         integrations: [ | 
					
						
							| 
									
										
										
										
											2025-03-21 17:41:03 +08:00
										 |  |  |           Sentry.browserTracingIntegration(), | 
					
						
							|  |  |  |           Sentry.replayIntegration(), | 
					
						
							| 
									
										
										
										
											2023-06-29 15:30:12 +08:00
										 |  |  |         ], | 
					
						
							|  |  |  |         tracesSampleRate: 0.1, | 
					
						
							|  |  |  |         replaysSessionSampleRate: 0.1, | 
					
						
							|  |  |  |         replaysOnErrorSampleRate: 1.0, | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }, []) | 
					
						
							|  |  |  |   return children | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default SentryInit |