SurfSense/surfsense_web/app/error.tsx
DESKTOP-RTLN3BA\$punk 1ab395a34e feat: enhance error handling with PostHog integration
- Added PostHog error capturing for non-authentication errors in BaseApiService.
- Refactored PostHog client initialization to ensure a single instance is used across the application.
2026-03-12 01:28:39 -07:00

32 lines
776 B
TypeScript

"use client";
import posthog from "posthog-js";
import { useEffect } from "react";
export default function Error({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
useEffect(() => {
posthog.captureException(error);
}, [error]);
return (
<div className="flex min-h-[50vh] flex-col items-center justify-center gap-4 text-center">
<h2 className="text-2xl font-semibold">Something went wrong</h2>
<p className="text-muted-foreground max-w-md">
An unexpected error occurred. Please try again.
</p>
<button
type="button"
onClick={reset}
className="rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors"
>
Try again
</button>
</div>
);
}