import { useEffect } from 'react'; import * as Sentry from '@sentry/nextjs'; import { ClientLogType } from '@akinon/next/sentry'; export const useSentryUncaughtErrors = (error: Error & { digest?: string }) => { useEffect(() => { Sentry.withScope(function (scope) { scope.setLevel('fatal'); scope.setTags({ APP_TYPE: 'ProjectZeroNext', TYPE: 'Client', LOG_TYPE: ClientLogType.UNCAUGHT_ERROR_PAGE }); scope.setExtra('error', error); const error_ = new Error('FATAL: Uncaught client error'); error_.name = 'UNCAUGHT_ERROR_PAGE'; Sentry.captureException(error_, { fingerprint: ['UNCAUGHT_ERROR_PAGE', error.digest] }); }); }, [error]); };