mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 08:23:34 +00:00
26 lines
806 B
TypeScript
26 lines
806 B
TypeScript
import { ReactNode, useEffect } from 'react';
|
|
import { useAppContext } from '@/hooks/useAppContext';
|
|
import { initializeSentry, disableSentry, isSentryInitialized } from '@/lib/sentry';
|
|
|
|
interface SentryProviderProps {
|
|
children: ReactNode;
|
|
}
|
|
|
|
export function SentryProvider({ children }: SentryProviderProps) {
|
|
const { config } = useAppContext();
|
|
|
|
useEffect(() => {
|
|
const shouldEnableSentry = config.sentryDsn && config.sentryEnabled;
|
|
|
|
if (shouldEnableSentry && !isSentryInitialized()) {
|
|
// Initialize Sentry
|
|
initializeSentry(config.sentryDsn).catch(console.error);
|
|
} else if (!shouldEnableSentry && isSentryInitialized()) {
|
|
// Disable Sentry
|
|
disableSentry().catch(console.error);
|
|
}
|
|
}, [config.sentryDsn, config.sentryEnabled]);
|
|
|
|
return <>{children}</>;
|
|
}
|