From 559b4010c276f45dec791aaea17133d6690aac63 Mon Sep 17 00:00:00 2001 From: 14790897 <14790897abc@gmail.com> Date: Thu, 7 Mar 2024 10:08:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20GitHub=E7=99=BB=E5=85=A5=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=8F=92=E5=85=A5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/AuthButton.tsx | 5 +++++ sentry.client.config.ts | 8 +++++++- utils/supabase/supabaseutils.ts | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/components/AuthButton.tsx b/components/AuthButton.tsx index 0148b70..7926f92 100644 --- a/components/AuthButton.tsx +++ b/components/AuthButton.tsx @@ -4,6 +4,8 @@ import { createClient } from "@/utils/supabase/server"; import Link from "next/link"; import { cookies } from "next/headers"; import { redirect } from "next/navigation"; +import { insertUserProfile } from "@/utils/supabase/supabaseutils"; + // import { signOut } from "@/utils/supabase/serversignout"; export default async function AuthButton() { @@ -11,8 +13,11 @@ export default async function AuthButton() { const supabase = createClient(cookieStore); const { + data, data: { user }, } = await supabase.auth.getUser(); + //profiles表 插入用户信息 + await insertUserProfile(data, supabase); const signOut = async () => { "use server"; diff --git a/sentry.client.config.ts b/sentry.client.config.ts index eb201d6..e279d44 100644 --- a/sentry.client.config.ts +++ b/sentry.client.config.ts @@ -18,7 +18,13 @@ if (process.env.NODE_ENV === "production") { // This sets the sample rate to be 10%. You may want this to be 100% while // in development and sample at a lower rate in production replaysSessionSampleRate: 0.1, - + beforeSend(event, hint) { + // 检查事件是否为通过 `captureMessage` 发送的 + if (event.logger === "javascript" && event.message) { + return event; // 允许发送消息事件 + } + return null; // 过滤掉其他类型的事件 + }, // You can remove this option if you're not planning to use the Sentry Session Replay feature: integrations: [ Sentry.replayIntegration({ diff --git a/utils/supabase/supabaseutils.ts b/utils/supabase/supabaseutils.ts index 7ed72f8..467910c 100644 --- a/utils/supabase/supabaseutils.ts +++ b/utils/supabase/supabaseutils.ts @@ -178,7 +178,12 @@ export async function fetchUserVipStatus(userId: string) { //profiles表 插入用户信息 export async function insertUserProfile(data: any, supabase: SupabaseClient) { - const user = data?.user; + let user; + if (data.user) { + user = data.user; + } else { + user = data; + } if (user) { const { data, error: profileError } = await supabase .from("profiles") @@ -186,6 +191,7 @@ export async function insertUserProfile(data: any, supabase: SupabaseClient) { if (profileError) { console.error("Failed to create user profile:", profileError); + Sentry.captureException(profileError); } //sentry Sentry.setUser({