This commit is contained in:
Tomas Dvorak
2025-11-11 10:29:30 +01:00
parent d5b4faea61
commit 8762bde4bf
139 changed files with 7240 additions and 2870 deletions
+7 -2
View File
@@ -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');