Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat: sentry exception tracking for authentication error page (#1739)

Marc Klingen5c1a7535ee5f
diff --git a/web/src/components/error-page.tsx b/web/src/components/error-page.tsx
index 90a542ec24..7633cfcef1 100644
--- a/web/src/components/error-page.tsx
+++ b/web/src/components/error-page.tsx
@@ -2,6 +2,8 @@ import { Button } from "@/src/components/ui/button";
import { AlertCircle } from "lucide-react";
import { useSession } from "next-auth/react";
import { useRouter } from "next/router";
+import { captureException } from "@sentry/nextjs";
+import { useEffect } from "react";
export const ErrorPage = ({
title = "Error",
@@ -24,3 +26,21 @@ export const ErrorPage = ({
</div>
);
};
+
+export const ErrorPageWithSentry = ({
+ title = "Error",
+ message,
+}: {
+ title?: string;
+ message: string;
+}) => {
+ useEffect(() => {
+ // Capture the error with Sentry
+ if (window !== undefined)
+ captureException(
+ new Error(`ErrorPageWithSentry rendered: ${title}, ${message}`),
+ );
+ }, [title, message]); // Empty dependency array means this effect runs once on mount
+
+ return <ErrorPage title={title} message={message} />;
+};
diff --git a/web/src/pages/auth/error.tsx b/web/src/pages/auth/error.tsx
index dacc5a3c12..d0fd488861 100644
--- a/web/src/pages/auth/error.tsx
+++ b/web/src/pages/auth/error.tsx
@@ -1,4 +1,4 @@
-import { ErrorPage } from "@/src/components/error-page";
+import { ErrorPageWithSentry } from "@/src/components/error-page";
import { useRouter } from "next/router";
export default function AuthError() {
@@ -8,5 +8,7 @@ export default function AuthError() {
? decodeURIComponent(String(error))
: "An authentication error occurred. Please reach out to support.";
- return <ErrorPage title="Authentication Error" message={errorMessage} />;
+ return (
+ <ErrorPageWithSentry title="Authentication Error" message={errorMessage} />
+ );
}