Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(growth): signup flow changes (#2187)

Seamusa7e786496e3b
diff --git a/js/app/packages/app/component/Onboarding.tsx b/js/app/packages/app/component/Onboarding.tsx
deleted file mode 100644
index 87e2e4b533..0000000000
--- a/js/app/packages/app/component/Onboarding.tsx
+++ /dev/null
@@ -1,205 +0,0 @@
-import { useAnalytics } from '@app/component/analytics-context';
-import { DEFAULT_ROUTE } from '@app/constants/defaultRoute';
-import { updateUserAuth, useIsAuthenticated } from '@core/auth';
-import { useHasPaidAccess } from '@core/auth/license';
-import { ActionSequence } from '@core/component/FormControls/ActionSequence';
-import MacroLogo from '@core/component/MacroLogo';
-import { useEmailLinks, useEmailLinksStatus } from '@core/email-link';
-import { licenseChannel } from '@core/util/licenseUpdateBroadcastChannel';
-import { updateUserInfo } from '@queries/auth/user-info';
-import { stripeServiceClient } from '@service-stripe/client';
-import { useNavigate, useSearchParams } from '@solidjs/router';
-import { createEffect, onCleanup, Show } from 'solid-js';
-
-export default function Onboarding() {
- const analytics = useAnalytics();
-
- const authenticated = useIsAuthenticated();
- const connected = useEmailLinksStatus();
- const subscribed = useHasPaidAccess();
-
- const { connect: connectEmail } = useEmailLinks();
-
- const navigate = useNavigate();
- const [searchParams] = useSearchParams();
-
- // TRACK PROGRESS, REDIRECT ON COMPLETE
- createEffect(() => {
- const steps = [connected(), subscribed()];
-
- const p = steps
- .map((b) => +!!b) // unary + converts bool to int
- .reduce((a, b) => a + b);
-
- if (p === steps.length) {
- complete();
- }
- });
-
- function complete() {
- // Redirect on completion
- if (localStorage.getItem('new_user_onboarding')) {
- localStorage.removeItem('new_user_onboarding');
- }
- return navigate(DEFAULT_ROUTE);
- }
-
- // WATCH FOR AUTH SUCCESS
- // createEffect(() => {
- // const isAuthed = authenticated();
- // const wasAttemptingSSO = localStorage.getItem('new_user_sso_auth_attempt');
-
- // if (isAuthed && wasAttemptingSSO) {
- // track(TrackingEvents.ONBOARDING.CREATE_ACCOUNT.SSO.GOOGLE.AUTH_SUCCESS);
- // localStorage.removeItem('new_user_sso_auth_attempt');
- // }
- // });
-
- // WATCH FOR SUBSCRIPTION SUCCESS
- createEffect(() => {
- const subscriptionSuccess = searchParams.subscriptionSuccess;
- if (subscriptionSuccess === 'true') {
- analytics.track('subscription_success');
- updateUserInfo();
- }
- });
-
- // Listen for license updates across browser tabs
- createEffect(() => {
- const unlisten = licenseChannel.subscribe(() => {
- updateUserInfo();
- });
-
- onCleanup(unlisten);
- });
-
- // const location = useLocation<RedirectLocation>();
- // const startSsoLogin = async (idp_name: string) => {
- // localStorage.setItem('new_user_onboarding', 'true');
- // localStorage.setItem('new_user_sso_auth_attempt', 'true');
-
- // track(TrackingEvents.ONBOARDING.START);
- // track(TrackingEvents.ONBOARDING.CREATE_ACCOUNT.SSO.GOOGLE.AUTH_START);
-
- // const authUrl = new URL(`${SERVER_HOSTS['auth-service']}/login/sso`);
- // authUrl.searchParams.set('idp_name', idp_name);
- // if (location.state?.originalLocation) {
- // const { pathname, search, hash } = location.state.originalLocation;
- // authUrl.searchParams.set(
- // 'original_url',
- // `${window.location.origin}${pathname}${search}${hash}`
- // );
- // } else {
- // authUrl.searchParams.set('original_url', window.location.href);
- // }
- // window.location.href = authUrl.toString();
- // };
-
- // ALSO AUTHS!
- const connectInbox = async () => {
- try {
- await connectEmail();
- } catch (error) {
- console.error(error);
- }
-
- await updateUserAuth();
- if (subscribed()) complete();
- };
-
- const handlePayment = async () => {
- try {
- analytics.track('subscription_start', {
- type: 'new_subscription',
- customType: 'New subscription',
- });
- const url =
- await stripeServiceClient.createCheckoutSession('New subscription');
- window.location.href = url;
- } catch (error) {
- console.error(error);
- }
- };
-
- return (
- <div class="relative flex flex-col gap-4 justify-between items-center p-4 md:p-8 m-1 md:m-8 border border-edge max-w-screen overflow-x-hidden">
- <header
- class="flex max-md:flex-col w-full items-center gap-8"
- classList={{
- 'justify-between': !authenticated(),
- }}
- >
- <div class="w-40">
- <MacroLogo class="fill-ink-muted" />
- </div>
-
- <Show when={!authenticated()}>
- <p class="font-mono text-ink-extra-muted text-xs">
- Already have an account?{' '}
- <a
- onClick={() => {
- localStorage.removeItem('onboarding_state');
- navigate('/login');
- }}
- class="hover:text-ink decoration-solid hover:decoration-dashed underline underline-offset-2 cursor-pointer"
- >
- Sign in
- </a>
- </p>
- </Show>
- </header>
-
- <section class="flex flex-col gap-8 w-max pb-8 -mt-16">
- <div class="space-y-2">
- <h1 class="font-semibold text-4xl md:text-5xl">Boot Sequence</h1>
- <p class="font-medium text-ink-muted">
- Let's initialize your new workspace.
- </p>
- </div>
-
- <ActionSequence
- steps={[
- // {
- // label: 'Authenticate with Google',
- // onClick: () => startSsoLogin('google'),
- // disabled: !!authenticated(),
- // completed: !!authenticated(),
- // },
- {
- label: 'Authenticate with Google',
- onClick: connectInbox,
- disabled: authenticated() || connected(),
- completed: connected(),
- },
- {
- label: 'Start Your Subscription',
- onClick: handlePayment,
- disabled: !authenticated() || !connected(),
- completed: subscribed(),
- },
- ]}
- />
- </section>
-
- <footer class="text-ink-placeholder">
- <p class="text-center text-xs">
- By signing up, you agree to our{' '}
- <a
- class="underline hover:decoration-dashed decoration-solid"
- href="/terms"
- >
- terms
- </a>{' '}
- and{' '}
- <a
- class="underline hover:decoration-dashed decoration-solid"
- href="/privacy"
- >
- privacy policy
- </a>
- .
- </p>
- </footer>
- </div>
- );
-}
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsx
index a3f1077e8a..da73151c93 100644
--- a/js/app/packages/app/component/Root.tsx
+++ b/js/app/packages/app/component/Root.tsx
@@ -68,13 +68,13 @@ import {
} from '../../block-theme/utils/themeUtils';
import { TauriRouteListener } from '../../tauri/src/TauriProvider';
import { Login } from './auth/Login';
+import { Signup } from './auth/Signup';
import { setCookie } from './auth/Shared';
import { makeEmailAuthComponents } from './EmailAuth';
import { GlobalAppStateProvider } from './GlobalAppState';
import { SearchProvider } from './next-soup/search-context';
import { Layout } from './Layout';
import MacroJump from './MacroJump';
-import Onboarding from './Onboarding';
import { ReactiveFavicon } from './ReactiveFavicon';
import { SuspenseContextComp } from './SuspenseContext';
import { lazy } from 'solid-js';
@@ -208,7 +208,7 @@ function NotFound() {
return '';
}
-const { EmailSignUp, EmailCallback, CALLBACK_PATH } = makeEmailAuthComponents({
+const { EmailCallback, CALLBACK_PATH } = makeEmailAuthComponents({
callbackPath: '/email-signup-callback',
successPath: '/',
});
@@ -252,7 +252,7 @@ const ROUTES: RouteDefinition[] = [
},
{
path: '/signup',
- component: EmailSignUp,
+ component: Signup,
},
{
path: CALLBACK_PATH,
@@ -295,14 +295,6 @@ const ROUTES: RouteDefinition[] = [
path: '/login',
component: () => <Login />,
},
- {
- path: '/onboarding',
- component: () => (
- <div class="flex *:flex-1 w-full h-dvh overflow-y-hidden">
- <Onboarding />
- </div>
- ),
- },
{
path: '/welcome',
component: () => (
diff --git a/js/app/packages/app/component/auth/EmailForm.tsx b/js/app/packages/app/component/auth/EmailForm.tsx
index 8c68fbafc1..9e3cd04d54 100644
--- a/js/app/packages/app/component/auth/EmailForm.tsx
+++ b/js/app/packages/app/component/auth/EmailForm.tsx
@@ -150,7 +150,7 @@ export function EmailForm(props: { setStage: (next: Stage) => void }) {
<div class="border-b border-edge-muted py-4 px-6 flex flex-none justify-between items-center">
<button
- class="hover:text-accent hover:transition-none cursor-pointer transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
+ class="hover:text-accent hover:transition-none transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
onClick={() => {
if (isTouchDevice()) return;
handleBack();
@@ -169,7 +169,7 @@ export function EmailForm(props: { setStage: (next: Stage) => void }) {
</button>
<button
- class="hover:text-accent hover:transition-none cursor-pointer transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
+ class="hover:text-accent hover:transition-none transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
type="submit"
disabled={submission.pending}
onClick={(e) => {
diff --git a/js/app/packages/app/component/auth/LoginOptions.tsx b/js/app/packages/app/component/auth/LoginOptions.tsx
index 976a4c300d..7a54d51d5c 100644
--- a/js/app/packages/app/component/auth/LoginOptions.tsx
+++ b/js/app/packages/app/component/auth/LoginOptions.tsx
@@ -33,7 +33,7 @@ function LoginOption(props: {
e.preventDefault();
props.onClick();
}}
- class="grid items-center justify-center p-4 border-b border-edge-muted [transition:color_var(--transition)] hover:bg-hover/60 hover:text-accent hover:transition-none cursor-pointer"
+ class="grid items-center justify-center p-4 border-b border-edge-muted [transition:color_var(--transition)] hover:bg-hover/60 hover:text-accent hover:transition-none"
>
<div class="flex gap-2.5 items-center justify-center">
{props.icon}
diff --git a/js/app/packages/app/component/auth/Signup.tsx b/js/app/packages/app/component/auth/Signup.tsx
new file mode 100644
index 0000000000..863349447e
--- /dev/null
+++ b/js/app/packages/app/component/auth/Signup.tsx
@@ -0,0 +1,141 @@
+import { SERVER_HOSTS } from '@core/constant/servers';
+import { ClippedPanel } from '@core/component/ClippedPanel';
+import { PcNoiseGrid } from '@core/component/PcNoiseGrid';
+import { useUserInfo } from '@queries/auth';
+import { Navigate, useLocation } from '@solidjs/router';
+import { onMount, Show } from 'solid-js';
+import { useAnalytics } from '@app/component/analytics-context';
+import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';
+import type { RedirectLocation } from '@core/util/authRedirect';
+import IconGoogle from '@macro-icons/macro-google.svg';
+import LogoIcon from '@macro-icons/macro-logo.svg';
+
+export function Signup() {
+ const userInfo = useUserInfo();
+ const analytics = useAnalytics();
+ const location = useLocation<RedirectLocation>();
+
+ onMount(() => {
+ analytics.pageView('signup');
+ });
+
+ const startGoogleLogin = () => {
+ const authUrl = new URL(`${SERVER_HOSTS['auth-service']}/login/sso`);
+ authUrl.searchParams.set('idp_name', 'google');
+
+ const referral_code =
+ new URL(window.location.href).searchParams.get('referral_code') ??
+ new URLSearchParams(location.state?.originalLocation?.search).get(
+ 'referral_code'
+ );
+
+ if (referral_code) authUrl.searchParams.set('referral_code', referral_code);
+
+ authUrl.searchParams.set(
+ 'original_url',
+ `${window.location.origin}${ROUTER_BASE_CONCAT}welcome`
+ );
+
+ window.location.href = authUrl.toString();
+ };
+
+ return (
+ <Show
+ when={!userInfo()?.authenticated}
+ fallback={
+ <Navigate href={userInfo()?.tutorialComplete ? '/' : '/welcome'} />
+ }
+ >
+ <div class="flex items-center justify-center h-full w-full p-8 overflow-hidden relative">
+ <style>
+ {
+ /*css*/ `
+ @keyframes login-fade-up {
+ from { opacity: 0; transform: translateY(8px); }
+ to { opacity: 1; transform: translateY(0); }
+ }
+ .login-card {
+ animation: login-fade-up 300ms ease-out both;
+ }
+ .login-stagger > * {
+ animation: login-fade-up 300ms ease-out both;
+ }
+ .login-stagger > *:nth-child(1) { animation-delay: 50ms; }
+ .login-stagger > *:nth-child(2) { animation-delay: 120ms; }
+ .login-stagger > *:nth-child(3) { animation-delay: 190ms; }
+ .login-stagger > *:nth-child(4) { animation-delay: 260ms; }
+ `
+ }
+ </style>
+ <div class="inset-0 absolute text-edge bg-panel opacity-10 -z-1">
+ <PcNoiseGrid
+ cellSize={30}
+ warp={0}
+ crunch={0.2}
+ freq={0.001}
+ size={[0, 0.3]}
+ rounding={0}
+ fill={0}
+ stroke={1}
+ speed={[0.017, 0.209]}
+ />
+ </div>
+
+ <div class="w-full max-w-[420px] login-card">
+ <ClippedPanel
+ cornerRadius={'4px'}
+ class="bg-panel shadow-lg shadow-[#1111]"
+ >
+ <div class="login-stagger">
+ <div class="flex items-center justify-center py-10">
+ <LogoIcon class="size-20 text-accent" />
+ </div>
+ <div class="text-center text-lg font-medium">
+ Welcome to Macro
+ </div>
+ <div class="px-8 pb-4 pt-2 text-center text-sm text-ink/60 leading-relaxed">
+ Sign in with Google to sync your inbox and set up your
+ workspace.
+ </div>
+ <div class="w-full">
+ <div class="grid select-none border-t border-edge-muted">
+ <div
+ onClick={startGoogleLogin}
+ class="grid items-center justify-center p-4 border-b border-edge-muted [transition:color_var(--transition)] hover:bg-hover/60 hover:text-accent hover:transition-none"
+ >
+ <div class="flex gap-2.5 items-center justify-center">
+ <IconGoogle />
+ <div class="whitespace-nowrap">Sign up with Google</div>
+ </div>
+ </div>
+
+ <div class="p-4 text-center text-xs text-ink/50">
+ <a
+ class="underline hover:text-ink/70"
+ href={`${ROUTER_BASE_CONCAT}login`}
+ >
+ Existing user? Log in
+ </a>
+ </div>
+
+ <div class="p-4 pt-0 text-center text-xs text-ink/50">
+ By signing up, you agree to our
+ <br />
+ <a class="underline hover:text-ink/70" href="/terms">
+ terms
+ </a>{' '}
+ and{' '}
+ <a class="underline hover:text-ink/70" href="/privacy">
+ privacy policy
+ </a>
+ .
+ </div>
+ </div>
+ </div>
+ </div>
+ </ClippedPanel>
+ </div>
+ </div>
+ </Show>
+ );
+}
diff --git a/js/app/packages/app/component/auth/VerifyForm.tsx b/js/app/packages/app/component/auth/VerifyForm.tsx
index 3e3b4a17ad..70b323b141 100644
--- a/js/app/packages/app/component/auth/VerifyForm.tsx
+++ b/js/app/packages/app/component/auth/VerifyForm.tsx
@@ -130,9 +130,9 @@ export function VerifyForm(props: { setStage: (next: Stage) => void }) {
}}
/>
<button
- class={`inline-block font-medium text-accent-ink hover:text-accent-ink/80 cursor-default transition
- ${showResendCode() ? 'opacity-100 cursor-pointer' : 'opacity-50 pointer-events-none cursor-not-allowed'}
- ${emailSubmission.pending || submission.pending ? 'opacity-50 cursor-not-allowed' : ''}`}
+ class={`inline-block font-medium text-accent-ink hover:text-accent-ink/80 transition
+ ${showResendCode() ? 'opacity-100' : 'opacity-50 pointer-events-none'}
+ ${emailSubmission.pending || submission.pending ? 'opacity-50 pointer-events-none' : ''}`}
disabled={
emailSubmission.pending || submission.pending || !showResendCode()
}
@@ -147,7 +147,7 @@ export function VerifyForm(props: { setStage: (next: Stage) => void }) {
<div class="border-b border-edge-muted py-4 px-6 flex flex-none justify-between items-center">
<button
- class="hover:text-accent hover:transition-none cursor-pointer transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
+ class="hover:text-accent hover:transition-none transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
onClick={resetEmailCode}
type="button"
>
@@ -156,7 +156,7 @@ export function VerifyForm(props: { setStage: (next: Stage) => void }) {
</button>
<button
- class="hover:text-accent hover:transition-none cursor-pointer transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
+ class="hover:text-accent hover:transition-none transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
type="submit"
disabled={submission.pending}
>
diff --git a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
index 30f7318a2c..9ef37ad3ab 100644
--- a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx
@@ -1,7 +1,7 @@
import { useSplitPanel } from '@app/component/split-layout/layoutUtils';
import MacroLogo from '@core/component/MacroLogo';
import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
-import { useLocation } from '@solidjs/router';
+import { useLocation, useNavigate } from '@solidjs/router';
import {
createEffect,
createSignal,
@@ -12,6 +12,7 @@ import {
} from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { useCompleteTutorialMutation } from '@queries/auth/tutorial';
+import { useTutorialCompleted } from '@core/context/user';
import { CommandState } from '@app/component/command';
import { resetSandbox } from './sandbox/sandbox-store';
import { commandKOpen, setCommandKOpen } from './lessons/command-k';
@@ -19,11 +20,7 @@ import { createOnboardingState } from './create-onboarding-state';
import { LESSONS } from './lessons';
import { ContinueButton, SkipButton } from './components-lib';
import { OnboardingProgress } from './OnboardingProgress';
-import {
- clearCompletedLessons,
- loadCompletedLessons,
- saveCompletedLesson,
-} from './persistence';
+import { clearCompletedLessons, saveCompletedLesson } from './persistence';
import { ClippedPanel } from '@core/component/ClippedPanel';
import { PcNoiseGrid } from '@core/component/PcNoiseGrid';
import { useAnalytics } from '@app/component/analytics-context';
@@ -33,6 +30,7 @@ export default function InteractiveOnboarding() {
const splitPanel = useSplitPanel();
const completeTutorial = useCompleteTutorialMutation();
+ const tutorialCompleted = useTutorialCompleted();
const location = useLocation();
const testMode = new URLSearchParams(location.search).has('test');
@@ -55,8 +53,7 @@ export default function InteractiveOnboarding() {
const state = createOnboardingState({
definitions: LESSONS,
- initialCompleted:
- debugCompleted ?? (testMode ? new Set() : loadCompletedLessons()),
+ initialCompleted: debugCompleted ?? new Set(),
});
const [readyToContinue, setReadyToContinue] = createSignal(false);
@@ -71,6 +68,18 @@ export default function InteractiveOnboarding() {
});
};
+ // Redirect away if the backend already marks the tutorial as complete
+ const navigate = useNavigate();
+ createEffect(() => {
+ if (tutorialCompleted() && !testMode) {
+ if (splitPanel) {
+ navigateAway();
+ } else {
+ navigate('/', { replace: true });
+ }
+ }
+ });
+
let continueButtonRef: HTMLButtonElement | undefined;
const handleLessonComplete = (buttonLabel?: string) => {
diff --git a/js/app/packages/app/component/interactive-onboarding/components-lib.tsx b/js/app/packages/app/component/interactive-onboarding/components-lib.tsx
index 19aff9a457..eabd3c362b 100644
--- a/js/app/packages/app/component/interactive-onboarding/components-lib.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/components-lib.tsx
@@ -161,11 +161,11 @@ export function ContinueButton(props: ContinueButtonProps) {
ref={props.ref}
type="button"
class={cn(
- 'w-full px-3 py-2.5 text-lg font-bold rounded-xs flex items-center justify-between gap-2 bracket-never',
+ 'w-full px-3 py-2.5 text-lg font-bold rounded-xs flex items-center justify-between gap-2 bracket-never border-none',
{
'bg-transparent text-ink/40 font-normal ring-1 ring-edge-muted/50':
props.disabled,
- 'bg-accent text-panel hover:bg-accent hover:ring-2 ring-accent ring-offset-1 focus:ring-2':
+ 'bg-accent text-panel hover:bg-accent hover:ring-2 ring-accent ring-offset-1 ring-offset-panel focus:ring-2':
!props.disabled,
}
)}
diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/choose-plan.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/choose-plan.tsx
index 70e81ee400..42ffd32d5b 100644
--- a/js/app/packages/app/component/interactive-onboarding/lessons/choose-plan.tsx
+++ b/js/app/packages/app/component/interactive-onboarding/lessons/choose-plan.tsx
@@ -1,7 +1,11 @@
-import { onMount, For } from 'solid-js';
+import { onMount, For, createSignal } from 'solid-js';
import type { LessonContentProps, LessonDefinition } from '../types';
+import { stripeServiceClient } from '@service-stripe/client';
+import { useAnalytics } from '@app/component/analytics-context';
+import { toast } from '@core/component/Toast/Toast';
const PLANS: {
+ tier: string;
name: string;
price: number;
description: string;
@@ -9,12 +13,14 @@ const PLANS: {
popular?: boolean;
}[] = [
{
+ tier: 'haiku',
name: 'Haiku',
price: 20,
description: "Access to Anthropic's fast, lightweight model",
calls: '1,000',
},
{
+ tier: 'sonnet',
name: 'Sonnet',
price: 60,
description: "Access to Anthropic's balanced frontier model",
@@ -22,6 +28,7 @@ const PLANS: {
popular: true,
},
{
+ tier: 'opus',
name: 'Opus',
price: 120,
description: "Access to Anthropic's most capable model",
@@ -40,6 +47,27 @@ function ChoosePlanContent(props: LessonContentProps) {
}
function ChoosePlanDemo() {
+ const analytics = useAnalytics();
+ const [loading, setLoading] = createSignal<string | null>(null);
+
+ const handleCheckout = async (tier: string) => {
+ if (loading()) return;
+ setLoading(tier);
+ try {
+ const url = await stripeServiceClient.createCheckoutSession(
+ '',
+ undefined,
+ tier
+ );
+ analytics.track('subscription_start', { type: tier });
+ window.location.href = url;
+ } catch (error) {
+ console.error('Checkout error:', error);
+ toast.failure('Failed to start checkout. Please try again.');
+ setLoading(null);
+ }
+ };
+
return (
<div class="h-full w-full flex items-center justify-center px-8">
<div class="flex gap-4 w-full max-w-2xl items-start">
@@ -84,13 +112,21 @@ function ChoosePlanDemo() {
<div class="mt-auto pt-2">
<button
type="button"
+ onClick={(e) => {
+ e.stopPropagation();
+ handleCheckout(plan.tier);
+ }}
+ disabled={loading() !== null}
class="w-full py-2 rounded-xs text-base font-semibold"
classList={{
'bg-accent text-panel': !!plan.popular,
'bg-ink/8 text-ink hover:bg-ink/12': !plan.popular,
+ 'opacity-60': loading() !== null,
}}
>
- Get {plan.name}
+ {loading() === plan.tier
+ ? 'Loading...'
+ : `Get ${plan.name}`}
</button>
</div>
</div>
diff --git a/js/app/packages/app/component/paywall/PaywallComponent.tsx b/js/app/packages/app/component/paywall/PaywallComponent.tsx
index 4997912f07..2abe09904a 100644
--- a/js/app/packages/app/component/paywall/PaywallComponent.tsx
+++ b/js/app/packages/app/component/paywall/PaywallComponent.tsx
@@ -1,24 +1,33 @@
import { useHasPaidAccess } from '@core/auth';
import { type PaywallKey, PaywallMessages } from '@core/constant/PaywallState';
-import IconCheck from '@icon/regular/check-circle.svg';
import IconX from '@icon/regular/x.svg';
-import Dot from '@phosphor-icons/core/regular/dot.svg?component-solid';
-import { useHasTrialed } from '@core/context/user';
import { stripeServiceClient } from '@service-stripe/client';
-import { createSignal, For, onMount, Show } from 'solid-js';
+import { createSignal, For, Show } from 'solid-js';
import { useAnalytics } from '@app/component/analytics-context';
-const guestFeatures = [
- 'Limited to 10 files and 10 AI messages',
- 'Can connect but not send emails',
-];
-
-const smartFeatures = [
- 'Unlimited files',
- 'Unlimited email',
- 'Unlimited AI',
-
- // '300 AI messages per month'
+const PLANS = [
+ {
+ tier: 'haiku' as const,
+ name: 'Haiku',
+ price: 20,
+ description: "Access to Anthropic's fast, lightweight model",
+ calls: '1,000',
+ },
+ {
+ tier: 'sonnet' as const,
+ name: 'Sonnet',
+ price: 60,
+ description: "Access to Anthropic's balanced frontier model",
+ calls: '5,000',
+ popular: true,
+ },
+ {
+ tier: 'opus' as const,
+ name: 'Opus',
+ price: 120,
+ description: "Access to Anthropic's most capable model",
+ calls: 'Unlimited',
+ },
];
interface PaywallComponent {
@@ -33,27 +42,19 @@ interface PaywallComponent {
const PaywallComponent = (props: PaywallComponent) => {
const analytics = useAnalytics();
- const hasTrialedQuery = useHasTrialed();
- const [hasTrialed, setHasTrialed] = createSignal(false);
- const [selectedPlan, setSelectedPlan] = createSignal<'guest' | 'member'>(
- 'member'
- );
+ const [selectedTier, setSelectedTier] = createSignal<string>('sonnet');
const hasPaid = useHasPaidAccess();
- onMount(() => {
- if (hasTrialedQuery()) {
- setHasTrialed(true);
- }
- });
-
- const handleEarlyMember = async () => {
+ const handleCheckout = async (tier: string) => {
try {
await props.cb();
const url = await stripeServiceClient.createCheckoutSession(
- props.customType ? props.customType : (props.errorKey ?? undefined)
+ props.customType ? props.customType : (props.errorKey ?? undefined),
+ undefined,
+ tier
);
analytics.track('subscription_start', {
- type: 'early_member',
+ type: tier,
customType: props.customType,
errorKey: props.errorKey,
});
@@ -77,15 +78,7 @@ const PaywallComponent = (props: PaywallComponent) => {
manageSubscription();
return;
}
- if (selectedPlan() === 'guest') {
- props.handleGuest?.();
- } else {
- handleEarlyMember();
- }
- };
-
- const handlePlanSelect = (plan: 'guest' | 'member') => {
- setSelectedPlan(plan);
+ handleCheckout(selectedTier());
};
return (
@@ -103,119 +96,66 @@ const PaywallComponent = (props: PaywallComponent) => {
<div class="space-y-6 sm:space-y-8">
<div class="text-center">
<h2 class="mb-2 font-semibold text-ink text-xl sm:text-2xl">
- <Show when={hasTrialed()}>Become an Early Member</Show>
- <Show when={!hasTrialed()}>
- Want to try Early Member for free?
- </Show>
+ Choose your plan
</h2>
<Show when={props.errorKey}>
<p class="mb-4 text-failure-ink text-sm sm:text-base">
{PaywallMessages[props.errorKey as PaywallKey]}
</p>
</Show>
- {/* <Show when={!props.errorKey}>
- <p class="mx-auto max-w-md text-ink text-sm sm:text-base">
- <Show when={!hasTrialed()}>
- If you can afford it, we recommend starting a trial of Early
- Member for faster and better quality answers.
- </Show>
- <Show when={hasTrialed()}>
- If you can afford it, we recommend upgrading to Early Member
- for faster and better quality answers.
- </Show>
- </p>
- </Show> */}
</div>
</div>
</Show>
</div>
- {/* Plan Selection */}
<div class="mx-auto mt-6 w-full max-w-2xl">
- <div class="gap-3 sm:gap-4 grid grid-cols-1 sm:grid-cols-2">
- {/* Guest AI */}
- <button
- inert={hasPaid()}
- onClick={() => handlePlanSelect('guest')}
- class={`p-4 sm:p-5 border transition-all duration-200 relative text-left flex flex-col ${
- selectedPlan() === 'guest'
- ? 'border-ink bg-edge/15'
- : 'border-edge hover:border-edge'
- }`}
- >
- <div class="flex flex-col gap-3">
- <div class="flex justify-between items-start">
- <div>
- <div class="font-semibold text-ink text-base sm:text-lg">
- Guest
- </div>
- <Show when={!hasPaid()}>
- <div class="text-ink text-sm">
- Free (no credit card required)
+ <div class="gap-3 sm:gap-4 grid grid-cols-1 sm:grid-cols-3">
+ <For each={PLANS}>
+ {(plan) => (
+ <button
+ inert={hasPaid()}
+ onClick={() => setSelectedTier(plan.tier)}
+ class="p-4 sm:p-5 border flex flex-col transition-all relative text-left"
+ classList={{
+ 'border-accent ring-1 ring-accent bg-active':
+ selectedTier() === plan.tier,
+ 'border-edge hover:border-edge': selectedTier() !== plan.tier,
+ }}
+ style={{ 'border-radius': '2px' }}
+ >
+ <div class="flex flex-col gap-3 w-full">
+ <div class="flex justify-between items-start">
+ <div>
+ <div class="font-semibold text-ink text-base sm:text-lg">
+ {plan.name}
+ </div>
+ <p class="text-sm text-ink/50 mt-0.5">
+ {plan.description}
+ </p>
</div>
- </Show>
- </div>
- {selectedPlan() === 'guest' && (
- <div class="bg-ink w-3 sm:w-4 h-3 sm:h-4"></div>
- )}
- </div>
- <ul class="space-y-2">
- <For each={guestFeatures}>
- {(feature) => (
- <li class="flex items-center gap-2 text-ink text-sm">
- <IconCheck class="w-4 h-4 text-ink-muted shrink-0" />
- {feature}
- </li>
- )}
- </For>
- </ul>
- </div>
- </button>
-
- {/* Early Member */}
- <button
- inert={hasPaid()}
- onClick={() => handlePlanSelect('member')}
- class={`p-4 sm:p-5 border flex flex-col transition-all relative text-left ${
- selectedPlan() === 'member'
- ? 'border-ink bg-active'
- : 'border-edge hover:border-edge'
- }`}
- >
- <div class="flex flex-col gap-3">
- <div class="flex justify-between items-start">
- <div classList={{ 'flex items-center gap-1': hasTrialed() }}>
- <div class="font-semibold text-ink text-base sm:text-lg">
- Early Member
+ {selectedTier() === plan.tier && (
+ <div class="bg-accent w-3 sm:w-4 h-3 sm:h-4 shrink-0"></div>
+ )}
</div>
- <div class="flex gap-1 items-center text-ink text-sm">
- <Show when={!hasTrialed()}>
- 7 days free, then $20/month
- </Show>
- <Show when={hasTrialed()}>
- <div class="flex items-center justify-center w-[1ch] relative">
- <Dot class="h-8 shrink-0" />
- </div>
- <span>$20/month</span>
- </Show>
+ <div class="flex items-baseline gap-0.5">
+ <span class="text-3xl font-bold text-ink">
+ ${plan.price}
+ </span>
+ <span class="text-base text-ink/40">/mo</span>
+ </div>
+ <div class="text-sm text-ink/60">
+ <span class="font-semibold text-ink">{plan.calls}</span> AI
+ tool calls
</div>
+ <Show when={plan.popular}>
+ <span class="text-[10px] font-semibold text-accent">
+ Most popular
+ </span>
+ </Show>
</div>
- {selectedPlan() === 'member' && (
- <div class="bg-ink w-3 sm:w-4 h-3 sm:h-4"></div>
- )}
- </div>
- <ul class="space-y-2">
- <For each={smartFeatures}>
- {(feature) => (
- <li class="flex items-center gap-2 text-ink text-sm">
- <IconCheck class="w-4 h-4 text-ink-muted shrink-0" />
- {feature}
- </li>
- )}
- </For>
- </ul>
- </div>
- </button>
+ </button>
+ )}
+ </For>
</div>
</div>
@@ -223,19 +163,23 @@ const PaywallComponent = (props: PaywallComponent) => {
<button
onClick={handleContinue}
class={`w-full px-4 py-2 sm:px-6 sm:py-3 font-medium transition-none hover:transition text-sm sm:text-base border border-transparent ${
- selectedPlan() === 'guest' || hasPaid()
+ hasPaid()
? 'bg-active text-ink border-edge hover:bg-hover hover:border-edge'
: 'bg-accent text-page hover:bg-accent-ink'
}`}
>
<Show when={!hasPaid()} fallback={'Manage Subscription'}>
- <Show when={selectedPlan() === 'guest'}>Continue with Guest</Show>
- <Show when={selectedPlan() === 'member'}>
- <Show when={!hasTrialed()}>Start 7 day trial</Show>
- <Show when={hasTrialed()}>Become an Early Member</Show>
- </Show>
+ Get {PLANS.find((p) => p.tier === selectedTier())?.name}
</Show>
</button>
+ <Show when={!hasPaid() && props.handleGuest}>
+ <button
+ onClick={() => props.handleGuest?.()}
+ class="mt-3 text-xs text-ink/40 hover:text-ink/60 underline"
+ >
+ Continue with free plan
+ </button>
+ </Show>
</div>
</div>
);
diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsx
index 60ccd672bc..1e24952916 100644
--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx
+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx
@@ -322,11 +322,6 @@ if (LOCAL_ONLY) {
lazy(() => import('@core/internal/ResizeDemo'))
);
- registerComponent(
- 'onboarding',
- lazy(() => import('@app/component/Onboarding'))
- );
-
registerComponent(
'notifications-playground',
lazy(() =>
diff --git a/js/app/packages/service-clients/service-auth/client.ts b/js/app/packages/service-clients/service-auth/client.ts
index 84c2915ee0..96e0387ee1 100644
--- a/js/app/packages/service-clients/service-auth/client.ts
+++ b/js/app/packages/service-clients/service-auth/client.ts
@@ -408,6 +408,7 @@ export const authServiceClient = {
cancelUrl: string;
discount?: string | null;
gaClientId?: string | null;
+ tier?: string;
}) {
return mapOk(
await fetchWithAuth<{ url: string }>(`${authHost}/user/stripe/checkout`, {
@@ -417,6 +418,7 @@ export const authServiceClient = {
cancelUrl: args.cancelUrl,
discount: args.discount ?? undefined,
gaClientId: args.gaClientId ?? undefined,
+ tier: args.tier ?? undefined,
}),
}),
(result) => result.url
diff --git a/js/app/packages/service-clients/service-stripe/client.ts b/js/app/packages/service-clients/service-stripe/client.ts
index 25bc133385..6b7d35ba1d 100644
--- a/js/app/packages/service-clients/service-stripe/client.ts
+++ b/js/app/packages/service-clients/service-stripe/client.ts
@@ -33,7 +33,11 @@ export const stripeServiceClient = {
* Creates a checkout session
* @returns The URL of the checkout session
*/
- createCheckoutSession: async (type: string = '', discount?: string) => {
+ createCheckoutSession: async (
+ type: string = '',
+ discount?: string,
+ tier?: string
+ ) => {
const gaClientId = await getGaClientId();
const result = await authServiceClient.createCheckoutSession({
@@ -41,6 +45,7 @@ export const stripeServiceClient = {
cancelUrl: `${window.location.origin}/app`,
discount: discount ?? null,
gaClientId: gaClientId ?? null,
+ tier,
});
if (!isOk(result)) {