Faro & grafana improvements
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import React from 'react';
|
||||
|
||||
export default class ErrorBoundary extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { hasError: false, error: null };
|
||||
}
|
||||
|
||||
static getDerivedStateFromError(error) {
|
||||
return { hasError: true, error };
|
||||
}
|
||||
|
||||
componentDidCatch(error, info) {
|
||||
// Report to Faro if available
|
||||
try {
|
||||
const faro = window.__faro;
|
||||
if (faro?.api?.pushError) {
|
||||
faro.api.pushError(error, { type: 'react-boundary', componentStack: info.componentStack });
|
||||
}
|
||||
} catch {
|
||||
// Faro reporting must never break the app
|
||||
}
|
||||
console.error('[ErrorBoundary]', error, info);
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.hasError) {
|
||||
return (
|
||||
<div style={{
|
||||
padding: '2rem',
|
||||
textAlign: 'center',
|
||||
fontFamily: 'system-ui, sans-serif',
|
||||
color: '#333',
|
||||
}}>
|
||||
<h2>Algo salió mal</h2>
|
||||
<p style={{ color: '#666' }}>Ha ocurrido un error inesperado. Por favor, recarga la página.</p>
|
||||
<button
|
||||
onClick={() => window.location.reload()}
|
||||
style={{
|
||||
marginTop: '1rem',
|
||||
padding: '0.5rem 1.5rem',
|
||||
backgroundColor: '#27633a',
|
||||
color: '#fff',
|
||||
border: 'none',
|
||||
borderRadius: '6px',
|
||||
cursor: 'pointer',
|
||||
fontSize: '1rem',
|
||||
}}
|
||||
>
|
||||
Recargar
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user