mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-05 03:02:56 +00:00
dev day #89
This commit is contained in:
@@ -17,6 +17,7 @@ import { HelmetProvider } from 'react-helmet-async';
|
||||
import reportWebVitals from './reportWebVitals';
|
||||
import * as serviceWorkerRegistration from './serviceWorkerRegistration';
|
||||
import { promptUserToUpdate } from './serviceWorkerRegistration';
|
||||
import { installGlobalErrorHandlers, reportError } from './services/errorReporter';
|
||||
// Cookie consent utilities
|
||||
type Consent = { analytics?: boolean };
|
||||
const getConsent = (): Consent | null => {
|
||||
@@ -51,6 +52,7 @@ class ErrorBoundary extends React.Component<{children: React.ReactNode}, {hasErr
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
|
||||
reportError({ message: error.message, stack: error.stack, component: 'ErrorBoundary', context: { react: errorInfo.componentStack } });
|
||||
console.error('Error caught by ErrorBoundary:', error, errorInfo);
|
||||
}
|
||||
|
||||
@@ -68,9 +70,12 @@ class ErrorBoundary extends React.Component<{children: React.ReactNode}, {hasErr
|
||||
}
|
||||
}
|
||||
|
||||
// Log unhandled promise rejections
|
||||
installGlobalErrorHandlers();
|
||||
window.addEventListener('unhandledrejection', (event) => {
|
||||
// Optionally report to monitoring service here
|
||||
const reason: any = (event as any).reason;
|
||||
const message = typeof reason === 'string' ? reason : (reason?.message || 'Unhandled rejection');
|
||||
const stack = typeof reason === 'object' ? (reason?.stack || '') : '';
|
||||
reportError({ message, stack });
|
||||
});
|
||||
|
||||
const rootElement = document.getElementById('root');
|
||||
|
||||
Reference in New Issue
Block a user