import { Component, type ErrorInfo, type ReactNode } from "react"; import { captureException } from "@/lib/posthog"; interface ErrorBoundaryProps { children: ReactNode; } interface ErrorBoundaryState { error: Error | null; } /** * App-wide error boundary. Without this, any render-time exception unmounts the * React tree and the user sees a blank white screen. This surfaces the actual * error message + stack so failures are diagnosable in place. */ export class ErrorBoundary extends Component { state: ErrorBoundaryState = { error: null }; static getDerivedStateFromError(error: Error): ErrorBoundaryState { return { error }; } componentDidCatch(error: Error, info: ErrorInfo) { captureException(error, { componentStack: info.componentStack }); // eslint-disable-next-line no-console console.error("[ErrorBoundary] Uncaught render error:", error, info.componentStack); } handleReset = () => this.setState({ error: null }); render() { const { error } = this.state; if (!error) return this.props.children; return (

Something went wrong

A render error was caught. Details below — share this with the developer.

            {error.message}
            {"\n\n"}
            {error.stack}
          
); } }