diff --git a/apps/web/app/(app)/onboarding/OnboardingFinish.tsx b/apps/web/app/(app)/onboarding/OnboardingFinish.tsx new file mode 100644 index 000000000..7d28429f8 --- /dev/null +++ b/apps/web/app/(app)/onboarding/OnboardingFinish.tsx @@ -0,0 +1,24 @@ +"use client"; + +import { Button } from "@/components/ui/button"; +import Link from "next/link"; +import { completedAppOnboardingAction } from "@/utils/actions/user"; +import { env } from "@/env"; +import { appHomePath } from "@/utils/config"; + +export const OnboardingFinish = () => { + return ( + + ); +}; diff --git a/apps/web/app/(app)/onboarding/page.tsx b/apps/web/app/(app)/onboarding/page.tsx index d8d8d28e1..8cf921832 100644 --- a/apps/web/app/(app)/onboarding/page.tsx +++ b/apps/web/app/(app)/onboarding/page.tsx @@ -1,12 +1,9 @@ -import Link from "next/link"; import { PageHeading, TypographyP } from "@/components/Typography"; import { Steps } from "@/app/(app)/onboarding/Steps"; import { OnboardingBulkUnsubscriber } from "@/app/(app)/onboarding/OnboardingBulkUnsubscriber"; import { OnboardingColdEmailBlocker } from "@/app/(app)/onboarding/OnboardingColdEmailBlocker"; import { OnboardingAIEmailAssistant } from "@/app/(app)/onboarding/OnboardingEmailAssistant"; -import { Button } from "@/components/ui/button"; -import { appHomePath } from "@/utils/config"; -import { env } from "@/env"; +import { OnboardingFinish } from "@/app/(app)/onboarding/OnboardingFinish"; export default function OnboardingPage({ searchParams, @@ -48,19 +45,7 @@ export default function OnboardingPage({ { title: "Continue", description: "Get started with Inbox Zero", - content: ( - - ), + content: , active: searchParams.step === "4", }, ]} diff --git a/apps/web/app/(landing)/welcome/form.tsx b/apps/web/app/(landing)/welcome/form.tsx index 3a7cfa902..16d614385 100644 --- a/apps/web/app/(landing)/welcome/form.tsx +++ b/apps/web/app/(landing)/welcome/form.tsx @@ -79,16 +79,7 @@ export const OnboardingForm = (props: { questionIndex: number }) => { submitPosthog(responses); await completedOnboardingAction(); - if (env.NEXT_PUBLIC_WELCOME_UPGRADE_ENABLED) { - router.push("/welcome-upgrade"); - } else { - // send to automation home if AI Automation is chosen - if (responses["$survey_response"].includes("AI Automation")) { - router.push(aiHomePath); - } else { - router.push(appHomePath); - } - } + router.push("/onboarding"); } else { router.push(`/welcome?${newSeachParams}`); } diff --git a/apps/web/app/(landing)/welcome/page.tsx b/apps/web/app/(landing)/welcome/page.tsx index e21fed468..b36a4a0ea 100644 --- a/apps/web/app/(landing)/welcome/page.tsx +++ b/apps/web/app/(landing)/welcome/page.tsx @@ -31,12 +31,12 @@ export default async function WelcomePage({ const user = await prisma.user.findUnique({ where: { id: session.user.id }, - select: { completedOnboarding: true, utms: true }, + select: { completedOnboardingAt: true, utms: true }, }); if (!user) redirect("/login"); - if (!searchParams.force && user.completedOnboarding) redirect(appHomePath); + if (!searchParams.force && user.completedOnboardingAt) redirect(appHomePath); const questionIndex = searchParams.question ? Number.parseInt(searchParams.question) @@ -65,7 +65,7 @@ export default async function WelcomePage({ )} - {/* {!user.completedOnboarding && } */} + {/* {!user.completedOnboardingAt && } */} ); diff --git a/apps/web/prisma/migrations/20241020163727_app_onboarding/migration.sql b/apps/web/prisma/migrations/20241020163727_app_onboarding/migration.sql new file mode 100644 index 000000000..4eadba057 --- /dev/null +++ b/apps/web/prisma/migrations/20241020163727_app_onboarding/migration.sql @@ -0,0 +1,11 @@ +-- AlterTable +ALTER TABLE "User" +ADD COLUMN "completedAppOnboardingAt" TIMESTAMP(3), +ADD COLUMN "completedOnboardingAt" TIMESTAMP(3); + +-- UpdateData +UPDATE "User" +SET "completedOnboardingAt" = CASE + WHEN "completedOnboarding" = true THEN "createdAt" + ELSE NULL +END; diff --git a/apps/web/prisma/schema.prisma b/apps/web/prisma/schema.prisma index 06b76edc9..2267250f1 100644 --- a/apps/web/prisma/schema.prisma +++ b/apps/web/prisma/schema.prisma @@ -54,7 +54,9 @@ model User { about String? watchEmailsExpirationDate DateTime? lastSyncedHistoryId String? - completedOnboarding Boolean @default(false) + completedOnboarding Boolean @default(false) // deprecated + completedOnboardingAt DateTime? // questions about the user. e.g. their role + completedAppOnboardingAt DateTime? // how to use the app onboardingAnswers Json? behaviorProfile Json? lastLogin DateTime? diff --git a/apps/web/utils/actions/user.ts b/apps/web/utils/actions/user.ts index 7a7d7b14f..68190874d 100644 --- a/apps/web/utils/actions/user.ts +++ b/apps/web/utils/actions/user.ts @@ -62,8 +62,21 @@ export const completedOnboardingAction = withActionInstrumentation( if (!session?.user.id) return { error: "Not logged in" }; await prisma.user.update({ - where: { id: session.user.id }, - data: { completedOnboarding: true }, + where: { id: session.user.id, completedOnboardingAt: null }, + data: { completedOnboardingAt: new Date() }, + }); + }, +); + +export const completedAppOnboardingAction = withActionInstrumentation( + "completedAppOnboarding", + async () => { + const session = await auth(); + if (!session?.user.id) return { error: "Not logged in" }; + + await prisma.user.update({ + where: { id: session.user.id, completedAppOnboardingAt: null }, + data: { completedAppOnboardingAt: new Date() }, }); }, );