// supabase/functions/signup-function/index.ts
interface WebhookPayload {
type: "INSERT" | "UPDATE" | "DELETE";
table: string;
record: {
id: string;
email?: string;
created_at?: string;
};
schema: string;
old_record: null | Record<string, any>;
}
Deno.serve(async (req) => {
const payload: WebhookPayload = await req.json();
// 只处理 users 表的 INSERT 事件
if (payload.type !== "INSERT" || payload.table !== "users") {
return new Response(JSON.stringify({ message: "Event ignored" }));
}
// 发送 kira_signup 事件到 PostHog
await sendToPostHog(userId, userEmail, userName);
});