Remove useSentry hook, reorganize in SoapboxHead

environments/review-main-yi2y9f/deployments/4156^2
Alex Gleason 11 months ago
parent c3673638d7
commit 2cdfaf4871
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -19,7 +19,6 @@ export { useOwnAccount } from './useOwnAccount';
export { usePrevious } from './usePrevious';
export { useRefEventHandler } from './useRefEventHandler';
export { useRegistrationStatus } from './useRegistrationStatus';
export { useSentry } from './useSentry';
export { useSettings } from './useSettings';
export { useSoapboxConfig } from './useSoapboxConfig';
export { useSystemTheme } from './useSystemTheme';

@ -1,14 +1,14 @@
import clsx from 'clsx';
import React from 'react';
import React, { useEffect } from 'react';
import {
useSentry,
useSettings,
useSoapboxConfig,
useTheme,
useLocale,
} from 'soapbox/hooks';
import { normalizeSoapboxConfig } from 'soapbox/normalizers';
import { startSentry } from 'soapbox/sentry';
import { generateThemeCss } from 'soapbox/utils/theme';
const Helmet = React.lazy(() => import('soapbox/components/helmet'));
@ -26,6 +26,7 @@ const SoapboxHead: React.FC<ISoapboxHead> = ({ children }) => {
const demo = !!settings.get('demo');
const darkMode = useTheme() === 'dark';
const themeCss = generateThemeCss(demo ? normalizeSoapboxConfig({ brandColor: '#0482d8' }) : soapboxConfig);
const dsn = soapboxConfig.sentryDsn;
const bodyClass = clsx('h-full bg-white text-base dark:bg-gray-800', {
'no-reduce-motion': !settings.get('reduceMotion'),
@ -33,7 +34,11 @@ const SoapboxHead: React.FC<ISoapboxHead> = ({ children }) => {
'demetricator': settings.get('demetricator'),
});
useSentry(soapboxConfig.sentryDsn);
useEffect(() => {
if (dsn) {
startSentry(dsn).catch(console.error);
}
}, [dsn]);
return (
<>

@ -1,14 +1,3 @@
import { useEffect } from 'react';
/** Hook to start Sentry. Should only be called once. */
function useSentry(dsn: string | undefined) {
useEffect(() => {
if (dsn) {
startSentry(dsn).catch(console.error);
}
}, [dsn]);
}
/** Start Sentry. */
async function startSentry(dsn: string): Promise<void> {
const [Sentry, { Integrations: Integrations }] = await Promise.all([
@ -47,4 +36,4 @@ async function startSentry(dsn: string): Promise<void> {
});
}
export { useSentry };
export { startSentry };
Loading…
Cancel
Save