From b983427721dda54aac187c9b95f8d21988944c06 Mon Sep 17 00:00:00 2001 From: liuweiqing Date: Sun, 11 Feb 2024 23:11:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20sentry=E8=BF=BD=E8=B8=AA=E7=94=A8?= =?UTF-8?q?=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/login/page.tsx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/login/page.tsx b/app/login/page.tsx index 19940fd..25b4ce1 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -2,6 +2,7 @@ import Link from "next/link"; import { headers, cookies } from "next/headers"; import { createClient } from "@/utils/supabase/server"; import { redirect } from "next/navigation"; +import * as Sentry from "@sentry/nextjs"; export default function Login({ searchParams, @@ -16,11 +17,19 @@ export default function Login({ const cookieStore = cookies(); const supabase = createClient(cookieStore); - const { error } = await supabase.auth.signInWithPassword({ + const { data, error } = await supabase.auth.signInWithPassword({ email, password, }); - + //sentry + const user = data?.user; + if (user) { + Sentry.setUser({ + email: user.email, + id: user.id, + ip_address: "{{auto}}}", + }); + } if (error) { return redirect("/login?message=Could not authenticate user"); } @@ -54,9 +63,14 @@ export default function Login({ if (profileError) { console.error("Failed to create user profile:", profileError); } - } else if (error) { - console.error("Sign in error:", error); + //sentry + Sentry.setUser({ + email: user.email, + id: user.id, + ip_address: "{{auto}}}", + }); } + if (error) { return redirect("/login?message=Could not authenticate user"); }