diff options
| author | MaheshtheDev <[email protected]> | 2025-09-10 03:33:45 +0000 |
|---|---|---|
| committer | MaheshtheDev <[email protected]> | 2025-09-10 03:33:45 +0000 |
| commit | 96f1a97fd6acd64d21bbdd388de04a47ef39c1a5 (patch) | |
| tree | 2fd46b56686358f5101ae72c0c722859519d6001 | |
| parent | merged (diff) | |
| download | supermemory-96f1a97fd6acd64d21bbdd388de04a47ef39c1a5.tar.xz supermemory-96f1a97fd6acd64d21bbdd388de04a47ef39c1a5.zip | |
feat: pro subscriber email config (#417)
| -rw-r--r-- | apps/web/components/views/profile.tsx | 24 | ||||
| -rw-r--r-- | packages/lib/api.ts | 10 |
2 files changed, 32 insertions, 2 deletions
diff --git a/apps/web/components/views/profile.tsx b/apps/web/components/views/profile.tsx index dfe7e3a8..9fa086ec 100644 --- a/apps/web/components/views/profile.tsx +++ b/apps/web/components/views/profile.tsx @@ -18,6 +18,7 @@ import Link from "next/link" import { useRouter } from "next/navigation" import { useEffect, useState } from "react" import { analytics } from "@/lib/analytics" +import { $fetch } from "@lib/api" export function ProfileView() { const router = useRouter() @@ -76,11 +77,30 @@ export function ProfileView() { const handleUpgrade = async () => { setIsLoading(true) try { - await attach({ + const upgradeResult = await attach({ productId: "consumer_pro", successUrl: "https://app.supermemory.ai/", }) - window.location.reload() + if ( + upgradeResult.statusCode === 200 && + upgradeResult.data && + "code" in upgradeResult.data + ) { + const isProPlanActivated = + upgradeResult.data.code === "new_product_attached" + if (isProPlanActivated && session?.name && session?.email) { + try { + await $fetch("@post/emails/welcome/pro", { + body: { + email: session?.email, + firstName: session?.name, + }, + }) + } catch (error) { + console.error(error) + } + } + } } catch (error) { console.error(error) setIsLoading(false) diff --git a/packages/lib/api.ts b/packages/lib/api.ts index ba609b16..e6ca8555 100644 --- a/packages/lib/api.ts +++ b/packages/lib/api.ts @@ -191,6 +191,16 @@ export const apiSchema = createSchema({ "@get/waitlist/status": { output: WaitlistStatusResponseSchema, }, + + "@post/emails/welcome/pro": { + input: z.object({ + email: z.string(), + firstName: z.string(), + }), + output: z.object({ + message: z.string(), + }), + } }) export const $fetch = createFetch({ |