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({