diff --git a/rnd/autogpt_builder/src/app/login/actions.ts b/rnd/autogpt_builder/src/app/login/actions.ts index dadd1de912..96508f4b0a 100644 --- a/rnd/autogpt_builder/src/app/login/actions.ts +++ b/rnd/autogpt_builder/src/app/login/actions.ts @@ -3,6 +3,7 @@ import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; import { createServerClient } from "@/lib/supabase/server"; import { z } from "zod"; +import AutoGPTServerAPI from "@/lib/autogpt-server-api"; const loginFormSchema = z.object({ email: z.string().email().min(2).max(64), @@ -32,6 +33,7 @@ export async function login(values: z.infer) { } export async function signup(values: z.infer) { + "use server"; const supabase = createServerClient(); if (!supabase) { @@ -48,6 +50,16 @@ export async function signup(values: z.infer) { if (data.session) { await supabase.auth.setSession(data.session); } + if (data.user) { + const api = new AutoGPTServerAPI(); + + api.logCreateUser({ + email: values.email, + user_id: data.user.id, + name: values.email, + username: values.email, + }); + } revalidatePath("/", "layout"); redirect("/profile"); diff --git a/rnd/autogpt_builder/src/components/providers/PageViewProvider.tsx b/rnd/autogpt_builder/src/components/providers/PageViewProvider.tsx index a88c06bfb8..9fceb96d49 100644 --- a/rnd/autogpt_builder/src/components/providers/PageViewProvider.tsx +++ b/rnd/autogpt_builder/src/components/providers/PageViewProvider.tsx @@ -2,6 +2,8 @@ import React, { createContext, useContext, useEffect } from "react"; import { usePathname, useSearchParams } from "next/navigation"; import logPageViewAction from "./actions"; +const EXCLUDED_PATHS = ["/login"]; + const PageViewContext = createContext(null); export const PageViewProvider: React.FC<{ children: React.ReactNode }> = ({ @@ -11,6 +13,10 @@ export const PageViewProvider: React.FC<{ children: React.ReactNode }> = ({ const searchParams = useSearchParams(); useEffect(() => { + if (EXCLUDED_PATHS.includes(pathname)) { + return; + } + const logPageView = async () => { const pageViewData = { page: pathname, diff --git a/rnd/autogpt_server/autogpt_server/data/user.py b/rnd/autogpt_server/autogpt_server/data/user.py index b05a84030d..d0a9827cfc 100644 --- a/rnd/autogpt_server/autogpt_server/data/user.py +++ b/rnd/autogpt_server/autogpt_server/data/user.py @@ -9,6 +9,15 @@ DEFAULT_USER_ID = "3e53486c-cf57-477e-ba2a-cb02dc828e1a" DEFAULT_EMAIL = "default@example.com" +class UserMetadata(BaseModel): + name: str + picture: str + +class UserData(BaseModel): + sub: str + email: str + user_metadata: UserMetadata + async def get_or_create_user(user_data: dict) -> User: user_id = user_data.get("sub")