Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(frontend): offer the free trial on the platform paywall (#14876)

Ubbe59892fe4a1c7
diff --git a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/SubscriptionStep/SubscriptionStep.tsx b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/SubscriptionStep/SubscriptionStep.tsx
index b95ec5f1ab..ddfd18cb0c 100644
--- a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/SubscriptionStep/SubscriptionStep.tsx
+++ b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/SubscriptionStep/SubscriptionStep.tsx
@@ -1,7 +1,7 @@
"use client";
import { FadeIn } from "@/components/atoms/FadeIn/FadeIn";
-import { supportsTrialPlan } from "@/components/organisms/SubscriptionPlans/helpers";
+import { getEligibleTrialOffer } from "@/components/organisms/SubscriptionPlans/helpers";
import { SubscriptionPlans } from "@/components/organisms/SubscriptionPlans/SubscriptionPlans";
import { TrialCardContent } from "@/components/organisms/TrialCard/TrialCard";
import { useTrialCard } from "@/components/organisms/TrialCard/useTrialCard";
@@ -10,16 +10,7 @@ import { useSubscriptionStep } from "./useSubscriptionStep";
export function SubscriptionStep() {
const subscription = useSubscriptionStep();
const trial = useTrialCard("onboarding");
- const offer =
- !trial.isLoading &&
- !trial.queryError &&
- trial.trial?.eligible &&
- !trial.trial.converted &&
- trial.trial.offer &&
- supportsTrialPlan(trial.trial.offer.tier) &&
- subscription.plans.some((plan) => plan.key === trial.trial?.offer?.tier)
- ? trial.trial.offer
- : null;
+ const offer = getEligibleTrialOffer(trial, subscription.plans);
return (
<FadeIn className="w-full">
diff --git a/autogpt_platform/frontend/src/app/(platform)/PaywallGate/PaywallModal.tsx b/autogpt_platform/frontend/src/app/(platform)/PaywallGate/PaywallModal.tsx
index c5700f02bd..b2a5e05706 100644
--- a/autogpt_platform/frontend/src/app/(platform)/PaywallGate/PaywallModal.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/PaywallGate/PaywallModal.tsx
@@ -1,19 +1,19 @@
"use client";
-import { Dialog } from "@/components/molecules/Dialog/Dialog";
import { Button } from "@/components/atoms/Button/Button";
+import { Icon } from "@/components/atoms/Icon/Icon";
import { Skeleton } from "@/components/atoms/Skeleton/Skeleton";
-import { Text } from "@/components/atoms/Text/Text";
-import { PlanCard } from "@/components/molecules/PlanCard/PlanCard";
-import { cn } from "@/lib/utils";
-import Link from "next/link";
+import { Dialog } from "@/components/molecules/Dialog/Dialog";
+import { SubscriptionPlans } from "@/components/organisms/SubscriptionPlans/SubscriptionPlans";
+import { TrialCardContent } from "@/components/organisms/TrialCard/TrialCard";
+import { Logout03Icon } from "@hugeicons/core-free-icons";
import { SwitchTierDialog } from "../settings/billing/components/SubscriptionTab/YourPlanCard/SwitchTierDialog";
+import { PaywallHeader } from "./components/PaywallHeader";
import { usePaywallModal } from "./usePaywallModal";
-import { Logout03Icon, PlayCircleIcon } from "@hugeicons/core-free-icons";
-import { Icon } from "@/components/atoms/Icon/Icon";
-// Non-dismissable Stripe paywall for NO_TIER users. Reuses the onboarding
-// PlanCard + Monthly/Yearly toggle so both surfaces share one visual.
+// Non-dismissable Stripe paywall for NO_TIER users. Renders the same
+// SubscriptionPlans organism as the onboarding paywall, so both surfaces share
+// one visual and one free-trial offer.
export function PaywallModal() {
const {
isLoading,
@@ -21,7 +21,6 @@ export function PaywallModal() {
retryLoadPlans,
isRetryingPlans,
country,
- isYearly,
selectedCycle,
setSelectedCycle,
handleSelectPlan,
@@ -32,6 +31,8 @@ export function PaywallModal() {
confirmPendingTier,
cancelPendingTier,
handleLogout,
+ trial,
+ trialOffer,
} = usePaywallModal();
return (
@@ -54,72 +55,9 @@ export function PaywallModal() {
Log out
</Button>
</div>
- <div className="flex flex-col items-center gap-1 text-center">
- <Text
- variant="h3"
- className="!text-[1.375rem] !leading-[1.6rem] md:!text-[1.75rem] md:!leading-[2.5rem]"
- >
- Choose the plan that&apos;s right for{" "}
- <span className="bg-gradient-to-r from-purple-500 to-indigo-500 bg-clip-text text-transparent">
- you
- </span>
- </Text>
- <Text variant="body" className="!text-zinc-500">
- Pick a plan to start working with experts and running agents.
- </Text>
- <Link
- href="/tour/chat?utm_source=platform_paywall"
- target="_blank"
- className="mt-2 inline-flex items-center gap-2 rounded-full border border-violet-200 bg-violet-50/60 px-4 py-1.5 text-sm text-zinc-700 transition-colors hover:bg-violet-100/60"
- >
- <Icon
- icon={PlayCircleIcon}
- className="size-5 shrink-0 text-violet-600"
- />
- <span>
- Not sure yet?{" "}
- <span className="font-semibold text-violet-700">Try it</span> —
- Instant demo — No signup
- </span>
- </Link>
- </div>
-
- {plans.length > 0 && (
- <div
- role="radiogroup"
- aria-label="Billing cycle"
- className="inline-flex rounded-full border border-[#d8d8d8] bg-zinc-100 p-[3px]"
- >
- {(["monthly", "yearly"] as const).map((cycle) => (
- <button
- key={cycle}
- role="radio"
- aria-checked={selectedCycle === cycle}
- type="button"
- onClick={() => setSelectedCycle(cycle)}
- className={cn(
- "rounded-full border-none px-4 py-1.5 text-xs font-medium transition-all",
- selectedCycle === cycle
- ? "bg-white text-zinc-900 shadow-sm"
- : "bg-transparent text-zinc-500 hover:text-zinc-700",
- )}
- >
- {cycle === "monthly" ? (
- "Monthly billing"
- ) : (
- <>
- Yearly billing{" "}
- <span className="ml-1.5 bg-gradient-to-r from-green-500 via-emerald-500 to-teal-500 bg-clip-text text-[11px] font-semibold text-transparent">
- Save 15%
- </span>
- </>
- )}
- </button>
- ))}
- </div>
- )}
+ <PaywallHeader />
- <div className="relative mt-2 w-full max-w-[75.625rem]">
+ <div className="relative mt-2 w-full">
{isLoading ? (
<div className="grid w-full grid-cols-1 gap-4 px-[1rem] md:grid-cols-3 md:px-0">
<Skeleton className="h-[26rem] rounded-2xl" />
@@ -142,28 +80,28 @@ export function PaywallModal() {
</Button>
</div>
) : (
- <div
- className={cn(
- "grid w-full gap-4 px-[1rem] md:px-0",
- plans.length === 1 && "grid-cols-1",
- plans.length === 2 && "grid-cols-1 md:grid-cols-2",
- plans.length >= 3 && "grid-cols-1 md:grid-cols-3",
- )}
- >
- {plans.map((plan) => (
- <PlanCard
- key={plan.key}
- plan={plan}
- country={country}
- isYearly={isYearly}
- onSelect={() => handleSelectPlan(plan.key)}
- loading={isPending && selectedTier === plan.key}
- disabled={isPending && selectedTier !== plan.key}
- priceCaption="billing-period"
- ctaGoalSurface="upgrade_modal"
- />
- ))}
- </div>
+ <SubscriptionPlans
+ // The modal renders its own title above, so the organism
+ // contributes only the billing toggle.
+ header={null}
+ goalSurface="upgrade_modal"
+ plans={plans}
+ country={country}
+ billing={selectedCycle}
+ onBillingChange={setSelectedCycle}
+ onSelectPlan={handleSelectPlan}
+ isUpdatingTier={isPending}
+ selectedPlan={selectedTier}
+ trialOffer={trialOffer}
+ onStartTrial={trial.startTrial}
+ isStartingTrial={trial.isStarting}
+ trialError={trial.error}
+ trialStatus={
+ !trialOffer && (
+ <TrialCardContent returnTo="billing" controller={trial} />
+ )
+ }
+ />
)}
</div>
</div>
diff --git a/autogpt_platform/frontend/src/app/(platform)/PaywallGate/__tests__/PaywallModal.test.tsx b/autogpt_platform/frontend/src/app/(platform)/PaywallGate/__tests__/PaywallModal.test.tsx
index 5fb3615fa8..09dd366a00 100644
--- a/autogpt_platform/frontend/src/app/(platform)/PaywallGate/__tests__/PaywallModal.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/PaywallGate/__tests__/PaywallModal.test.tsx
@@ -229,7 +229,7 @@ describe("PaywallModal — Monthly/Yearly cycle toggle", () => {
render(<PaywallModal />);
- fireEvent.click(screen.getByRole("radio", { name: /yearly/i }));
+ fireEvent.click(screen.getByRole("button", { name: /yearly/i }));
// PRO yearly = 51000 cents → $42.50/mo, MAX yearly = 326400 cents → $272.00/mo.
await waitFor(() => {
@@ -293,7 +293,7 @@ describe("PaywallModal — upgrade mutation", () => {
render(<PaywallModal />);
- fireEvent.click(screen.getByRole("radio", { name: /yearly/i }));
+ fireEvent.click(screen.getByRole("button", { name: /yearly/i }));
fireEvent.click(screen.getByRole("button", { name: /upgrade to pro/i }));
await waitFor(() => {
diff --git a/autogpt_platform/frontend/src/app/(platform)/PaywallGate/__tests__/PaywallModal.trial.test.tsx b/autogpt_platform/frontend/src/app/(platform)/PaywallGate/__tests__/PaywallModal.trial.test.tsx
new file mode 100644
index 0000000000..2c50e602c9
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/PaywallGate/__tests__/PaywallModal.trial.test.tsx
@@ -0,0 +1,264 @@
+import {
+ getGetTrialsGetTrialStatusMockHandler200,
+ getPostTrialsStartTrialCheckoutMockHandler200,
+} from "@/app/api/__generated__/endpoints/trials/trials.msw";
+import { server } from "@/mocks/mock-server";
+import {
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+ within,
+} from "@/tests/integrations/test-utils";
+import {
+ setTrialUser,
+ trialOffer,
+ trialResponse,
+} from "@/tests/integrations/trial-fixtures";
+import { http, HttpResponse } from "msw";
+import { afterEach, beforeEach, expect, test, vi } from "vitest";
+
+const mockUseGetSubscriptionStatus = vi.fn();
+const mockUseUpdateSubscriptionTier = vi.fn();
+vi.mock("@/app/api/__generated__/endpoints/credits/credits", () => ({
+ useGetSubscriptionStatus: (opts: unknown) =>
+ mockUseGetSubscriptionStatus(opts),
+ useUpdateSubscriptionTier: () => mockUseUpdateSubscriptionTier(),
+}));
+
+const posthog = vi.hoisted(() => ({ capture: vi.fn() }));
+vi.mock("@posthog/react", () => ({
+ useFeatureFlagVariantKey: () => undefined,
+ usePostHog: () => posthog,
+}));
+
+// Radix portals don't render under happy-dom; keep the dialog tree inline.
+function MockDialog({ children }: { children: React.ReactNode }) {
+ return <div role="dialog">{children}</div>;
+}
+function MockDialogContent({ children }: { children: React.ReactNode }) {
+ return <div>{children}</div>;
+}
+function MockDialogFooter({ children }: { children: React.ReactNode }) {
+ return <div>{children}</div>;
+}
+MockDialog.Content = MockDialogContent;
+MockDialog.Footer = MockDialogFooter;
+vi.mock("@/components/molecules/Dialog/Dialog", () => ({
+ Dialog: MockDialog,
+}));
+
+vi.mock("@/lib/auth/hooks/useAuth", () => ({
+ useAuth: () => ({
+ validateSession: vi.fn().mockResolvedValue(true),
+ isLoggedIn: true,
+ }),
+}));
+
+vi.mock("@/providers/onboarding/onboarding-provider", () => ({
+ default: ({ children }: { children: React.ReactNode }) => <>{children}</>,
+}));
+
+vi.mock("next/navigation", () => ({
+ useRouter: () => ({
+ push: vi.fn(),
+ replace: vi.fn(),
+ prefetch: vi.fn(),
+ back: vi.fn(),
+ forward: vi.fn(),
+ refresh: vi.fn(),
+ }),
+ usePathname: () => "/build",
+ useSearchParams: () => new URLSearchParams(),
+ useParams: () => ({}),
+}));
+
+import { PaywallModal } from "../PaywallModal";
+
+const originalLocation = window.location;
+let checkoutLocation = {
+ origin: "https://app.test",
+ href: "https://app.test/build",
+ assign: vi.fn(),
+};
+
+function setSubscription(tierCosts: Record<string, number>) {
+ mockUseGetSubscriptionStatus.mockReturnValue({
+ data: { tier: "NO_TIER", tier_costs: tierCosts },
+ isLoading: false,
+ isFetching: false,
+ refetch: vi.fn(),
+ });
+ mockUseUpdateSubscriptionTier.mockReturnValue({
+ mutateAsync: vi.fn().mockResolvedValue({ status: 200, data: { url: "" } }),
+ isPending: false,
+ });
+}
+
+function eligible(offer = trialOffer) {
+ return trialResponse({ eligible: true, active: false, status: null, offer });
+}
+
+beforeEach(() => {
+ setTrialUser();
+ posthog.capture.mockClear();
+ setSubscription({ PRO: 5000, MAX: 32000 });
+ checkoutLocation = {
+ origin: "https://app.test",
+ href: "https://app.test/build",
+ assign: vi.fn(),
+ };
+ Object.defineProperty(window, "location", {
+ configurable: true,
+ writable: true,
+ value: checkoutLocation,
+ });
+});
+
+afterEach(() => {
+ setTrialUser(null);
+ Object.defineProperty(window, "location", {
+ configurable: true,
+ writable: true,
+ value: originalLocation,
+ });
+ vi.restoreAllMocks();
+});
+
+test.each([
+ ["PRO", "Pro"],
+ ["MAX", "Max"],
+] as const)(
+ "starts the %s trial from the paywall and returns to billing",
+ async (tier, name) => {
+ server.use(
+ getGetTrialsGetTrialStatusMockHandler200(
+ eligible({ ...trialOffer, tier }),
+ ),
+ );
+ const requestBody = vi.fn();
+ server.use(
+ getPostTrialsStartTrialCheckoutMockHandler200(async ({ request }) => {
+ requestBody(await request.json());
+ return { url: "https://checkout.stripe.com/trial" };
+ }),
+ );
+
+ render(<PaywallModal />);
+
+ const card = within(
+ await screen.findByRole("region", { name: `${name} plan` }),
+ );
+ fireEvent.click(
+ await card.findByRole("button", { name: "Start 7-day trial" }),
+ );
+
+ await waitFor(() =>
+ expect(checkoutLocation.assign).toHaveBeenCalledWith(
+ "https://checkout.stripe.com/trial",
+ ),
+ );
+ // The paywall gates every non-exempt route, so Stripe returns the user to
+ // /settings/billing, which confirms the trial. By then the enrollment has
+ // set a real tier and the gate has lifted.
+ expect(requestBody).toHaveBeenCalledExactlyOnceWith({
+ offer_token: trialOffer.token,
+ return_to: "billing",
+ });
+ expect(posthog.capture).toHaveBeenCalledWith(
+ "subscription_trial_checkout_started",
+ { trial_offer_version: trialOffer.version, surface: "billing" },
+ );
+ },
+);
+
+test("reports the offer impression against the billing surface", async () => {
+ server.use(getGetTrialsGetTrialStatusMockHandler200(eligible()));
+
+ render(<PaywallModal />);
+
+ await screen.findByRole("button", { name: "Start 7-day trial" });
+ expect(posthog.capture).toHaveBeenCalledWith(
+ "subscription_trial_offer_viewed",
+ expect.objectContaining({ surface: "billing" }),
+ );
+});
+
+test("keeps paid checkout reporting against the upgrade_modal surface", async () => {
+ server.use(getGetTrialsGetTrialStatusMockHandler200(eligible()));
+
+ render(<PaywallModal />);
+
+ const max = within(await screen.findByRole("region", { name: "Max plan" }));
+ const paid = max.getByRole("button", { name: "Upgrade to Max" });
+ expect(paid.getAttribute("data-fast-goal")).toBe("plan_cta_click");
+ expect(paid.getAttribute("data-fast-goal-surface")).toBe("upgrade_modal");
+
+ const toggle = screen.getByRole("button", { name: /yearly/i });
+ expect(toggle.getAttribute("data-fast-goal-surface")).toBe("upgrade_modal");
+});
+
+test("leaves the paid CTAs alone when the user is not eligible", async () => {
+ server.use(
+ getGetTrialsGetTrialStatusMockHandler200(
+ trialResponse({ eligible: false, converted: true }),
+ ),
+ );
+
+ render(<PaywallModal />);
+
+ const pro = within(await screen.findByRole("region", { name: "Pro plan" }));
+ expect(pro.getByRole("button", { name: "Upgrade to Pro" })).toBeDefined();
+ expect(screen.queryByRole("button", { name: /Start .*trial/ })).toBeNull();
+});
+
+test("leaves the paid CTAs alone when the trial status fails to load", async () => {
+ server.use(
+ http.get("*/api/credits/trial", () =>
+ HttpResponse.json({ detail: "boom" }, { status: 500 }),
+ ),
+ );
+
+ render(<PaywallModal />);
+
+ const pro = within(await screen.findByRole("region", { name: "Pro plan" }));
+ expect(pro.getByRole("button", { name: "Upgrade to Pro" })).toBeDefined();
+ expect(screen.queryByRole("button", { name: /Start .*trial/ })).toBeNull();
+});
+
+test("hides an offer for a tier the backend isn't pricing on this paywall", async () => {
+ // LD can hide MAX from /credits/subscription while a MAX trial offer is
+ // still live — the trial CTA would have no card to sit on.
+ setSubscription({ PRO: 5000 });
+ server.use(
+ getGetTrialsGetTrialStatusMockHandler200(
+ eligible({ ...trialOffer, tier: "MAX" }),
+ ),
+ );
+
+ render(<PaywallModal />);
+
+ const pro = within(await screen.findByRole("region", { name: "Pro plan" }));
+ expect(pro.getByRole("button", { name: "Upgrade to Pro" })).toBeDefined();
+ expect(screen.queryByRole("button", { name: /Start .*trial/ })).toBeNull();
+});
+
+test("offers to switch billing cycle when the trial is priced on the other one", async () => {
+ server.use(
+ getGetTrialsGetTrialStatusMockHandler200(
+ eligible({ ...trialOffer, billing_cycle: "yearly" }),
+ ),
+ );
+
+ render(<PaywallModal />);
+
+ const pro = within(await screen.findByRole("region", { name: "Pro plan" }));
+ const swap = await pro.findByRole("button", {
+ name: "Try Pro for 7 days instead",
+ });
+ fireEvent.click(swap);
+
+ expect(
+ await pro.findByRole("button", { name: "Start 7-day trial" }),
+ ).toBeDefined();
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/PaywallGate/components/PaywallHeader.tsx b/autogpt_platform/frontend/src/app/(platform)/PaywallGate/components/PaywallHeader.tsx
new file mode 100644
index 0000000000..e0ef998cb0
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/PaywallGate/components/PaywallHeader.tsx
@@ -0,0 +1,38 @@
+import { Icon } from "@/components/atoms/Icon/Icon";
+import { Text } from "@/components/atoms/Text/Text";
+import { PlayCircleIcon } from "@hugeicons/core-free-icons";
+import Link from "next/link";
+
+export function PaywallHeader() {
+ return (
+ <div className="flex flex-col items-center gap-1 text-center">
+ <Text
+ variant="h3"
+ className="!text-[1.375rem] !leading-[1.6rem] md:!text-[1.75rem] md:!leading-[2.5rem]"
+ >
+ Choose the plan that&apos;s right for{" "}
+ <span className="bg-gradient-to-r from-purple-500 to-indigo-500 bg-clip-text text-transparent">
+ you
+ </span>
+ </Text>
+ <Text variant="body" className="!text-zinc-500">
+ Pick a plan to start working with experts and running agents.
+ </Text>
+ <Link
+ href="/tour/chat?utm_source=platform_paywall"
+ target="_blank"
+ className="mt-2 inline-flex items-center gap-2 rounded-full border border-violet-200 bg-violet-50/60 px-4 py-1.5 text-sm text-zinc-700 transition-colors hover:bg-violet-100/60"
+ >
+ <Icon
+ icon={PlayCircleIcon}
+ className="size-5 shrink-0 text-violet-600"
+ />
+ <span>
+ Not sure yet?{" "}
+ <span className="font-semibold text-violet-700">Try it</span> —
+ Instant demo — No signup
+ </span>
+ </Link>
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/PaywallGate/usePaywallModal.ts b/autogpt_platform/frontend/src/app/(platform)/PaywallGate/usePaywallModal.ts
index 30c81978c6..da79ecaa86 100644
--- a/autogpt_platform/frontend/src/app/(platform)/PaywallGate/usePaywallModal.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/PaywallGate/usePaywallModal.ts
@@ -18,6 +18,8 @@ import {
type PlanDef,
TEAM_INTAKE_FORM_URL,
} from "@/components/molecules/PlanCard/plans";
+import { getEligibleTrialOffer } from "@/components/organisms/SubscriptionPlans/helpers";
+import { useTrialCard } from "@/components/organisms/TrialCard/useTrialCard";
import {
getSubscriptionValue,
trackAdsConversion,
@@ -97,6 +99,12 @@ export function usePaywallModal() {
subscription?.tier_costs_yearly,
);
+ // Trial checkout returns to /settings/billing, which renders the trial
+ // confirmation. By then the enrollment has set a real tier, so the gate
+ // lifts and the user lands on their active trial rather than back here.
+ const trial = useTrialCard("billing");
+ const trialOffer = getEligibleTrialOffer(trial, plans);
+
const hasActiveStripeSubscription = Boolean(
subscription?.has_active_stripe_subscription,
);
@@ -204,7 +212,6 @@ export function usePaywallModal() {
retryLoadPlans,
isRetryingPlans: isFetching,
country,
- isYearly,
selectedCycle,
setSelectedCycle,
handleSelectPlan,
@@ -215,5 +222,7 @@ export function usePaywallModal() {
confirmPendingTier,
cancelPendingTier,
handleLogout,
+ trial,
+ trialOffer,
};
}
diff --git a/autogpt_platform/frontend/src/components/molecules/PlanCard/PlanCard.tsx b/autogpt_platform/frontend/src/components/molecules/PlanCard/PlanCard.tsx
deleted file mode 100644
index 0daca59697..0000000000
--- a/autogpt_platform/frontend/src/components/molecules/PlanCard/PlanCard.tsx
+++ /dev/null
@@ -1,276 +0,0 @@
-"use client";
-
-import NumberFlow from "@number-flow/react";
-import { motion, useReducedMotion } from "framer-motion";
-
-import { Button } from "@/components/atoms/Button/Button";
-import { Text } from "@/components/atoms/Text/Text";
-import { cn } from "@/lib/utils";
-import { type Country } from "./countries";
-import { PLAN_KEYS, type PlanDef, type PlanKey } from "./plans";
-import { computePlanPricing } from "./computePricing";
-import { StarIcon, Tick02Icon } from "@hugeicons/core-free-icons";
-import { Icon } from "@/components/atoms/Icon/Icon";
-
-const ZERO_DECIMAL_CODES = new Set(["JPY", "KRW", "HUF", "CLP"]);
-
-interface Props {
- plan: PlanDef;
- country: Country;
- isYearly: boolean;
- onSelect: (key: PlanKey) => void;
- className?: string;
- loading?: boolean;
- disabled?: boolean;
- // "charged-today" shows the prorated amount billed now; "billing-period"
- // shows a plain "billed monthly/annually" caption instead (paywall surface).
- priceCaption?: "charged-today" | "billing-period";
- // Names the surface this card is rendered on to tag its CTA for DataFast.
- // Omitted, the card reports nothing — each surface opts in so a shared goal
- // never mixes clicks from the onboarding paywall and the upgrade modal.
- ctaGoalSurface?: string;
-}
-
-export function PlanCard({
- plan,
- country,
- isYearly,
- onSelect,
- className,
- loading = false,
- disabled = false,
- priceCaption = "charged-today",
- ctaGoalSurface,
-}: Props) {
- const { primaryPrice, chargedToday } = computePlanPricing({
- plan,
- country,
- isYearly,
- });
- const hl = plan.highlighted;
- const isTeam = plan.key === PLAN_KEYS.TEAM;
- const reduceMotion = useReducedMotion();
- const decimalDigits = ZERO_DECIMAL_CODES.has(country.currencyCode) ? 0 : 2;
- const moneyFormat = {
- style: "currency",
- currency: country.currencyCode,
- currencyDisplay: "symbol",
- minimumFractionDigits: decimalDigits,
- maximumFractionDigits: decimalDigits,
- } as const;
- const moneyFormatter = new Intl.NumberFormat("en-US", moneyFormat);
-
- return (
- <div
- aria-disabled={disabled || undefined}
- className={cn(
- "relative rounded-2xl p-px transition-opacity",
- hl
- ? "bg-gradient-to-br from-purple-500 via-fuchsia-500 to-indigo-500 shadow-[0_10px_32px_-8px_rgba(119,51,245,0.25)]"
- : "bg-gradient-to-br from-zinc-300 via-zinc-400 to-zinc-500 md:my-5",
- disabled && "pointer-events-none opacity-50",
- className,
- )}
- >
- {plan.badge && hl && (
- <motion.span
- className="absolute -top-3 right-5 z-10 inline-flex overflow-hidden rounded-full p-px shadow-[0_10px_28px_-6px_rgba(124,58,237,0.55)]"
- initial={reduceMotion ? false : { scale: 0, opacity: 0, rotate: -12 }}
- animate={
- reduceMotion ? undefined : { scale: 1, opacity: 1, rotate: 0 }
- }
- transition={
- reduceMotion
- ? undefined
- : { type: "spring", stiffness: 320, damping: 14, delay: 0.45 }
- }
- >
- <span
- aria-hidden
- className="absolute -inset-[150%] animate-[spin_4s_linear_infinite] bg-[conic-gradient(from_0deg,#a855f7,#7c3aed,#4f46e5,#1e40af,#4f46e5,#7c3aed,#a855f7)]"
- />
- <span className="relative inline-flex items-center gap-1 rounded-full bg-gradient-to-r from-indigo-600 via-blue-600 to-blue-500 px-2.5 py-1 text-[10px] font-semibold text-white">
- <motion.span
- className="inline-flex"
- animate={
- reduceMotion
- ? undefined
- : { rotate: [0, 18, -10, 0], scale: [1, 1.25, 0.95, 1] }
- }
- transition={
- reduceMotion
- ? undefined
- : {
- duration: 1.2,
- repeat: Infinity,
- repeatDelay: 2.2,
- ease: "easeInOut",
- }
- }
- >
- <Icon
- icon={StarIcon}
- size={10}
- aria-hidden="true"
- className="text-yellow-300"
- />
- </motion.span>
- {plan.badge}
- </span>
- </motion.span>
- )}
-
- <div
- className={cn(
- "relative flex h-full flex-col overflow-hidden rounded-[15px] bg-white",
- hl ? "p-6" : "p-5",
- )}
- >
- <div
- aria-hidden
- className={cn(
- "pointer-events-none absolute inset-0",
- hl
- ? "bg-[radial-gradient(120%_60%_at_0%_0%,rgba(168,85,247,0.10),transparent_60%),radial-gradient(120%_60%_at_100%_100%,rgba(99,102,241,0.08),transparent_60%)]"
- : "bg-[radial-gradient(140%_70%_at_0%_0%,rgba(244,244,245,0.7),transparent_60%)]",
- )}
- />
-
- <div className="relative flex h-full flex-col">
- <div className="mb-2 flex items-center gap-2">
- <Text
- variant="h5"
- as="h2"
- className="font-poppins !text-[17px] !font-semibold !text-zinc-800"
- >
- {plan.name}
- </Text>
- {plan.usage && (
- <span className="inline-flex items-center gap-1 rounded-full bg-purple-100 px-2 py-0.5 text-[10px] font-medium text-purple-700">
- {plan.usage} usage
- </span>
- )}
- {plan.badge && !hl && (
- <span className="inline-flex items-center gap-1 rounded-full bg-zinc-100 px-2 py-0.5 text-[10px] font-medium text-zinc-500">
- {plan.badge}
- </span>
- )}
- </div>
-
- <div className="mb-1 flex flex-wrap items-baseline gap-x-1.5 gap-y-0.5">
- {primaryPrice !== null ? (
- <>
- <span
- aria-label={moneyFormatter.format(primaryPrice)}
- className={cn(
- "font-poppins font-medium leading-none text-zinc-800",
- hl ? "text-[32px]" : "text-[26px]",
- )}
- >
- <NumberFlow
- value={primaryPrice}
- format={moneyFormat}
- locales="en-US"
- willChange
- />
- </span>
- <span className="text-xs text-zinc-400">/ month</span>
- </>
- ) : (
- <span
- className={cn(
- "font-poppins font-medium leading-none tracking-[-1px] text-zinc-800",
- hl ? "text-[32px]" : "text-[26px]",
- )}
- >
- Contact us
- </span>
- )}
- </div>
-
- {priceCaption === "billing-period"
- ? primaryPrice !== null && (
- <div className="mb-1 text-xs font-medium text-zinc-400">
- {isYearly ? "billed annually" : "billed monthly"}
- </div>
- )
- : chargedToday !== null && (
- <div
- aria-label={`Charged today: ${moneyFormatter.format(chargedToday)}`}
- className="mb-1 flex items-baseline gap-1 text-xs font-medium text-zinc-700"
- >
- <span>Charged today:</span>
- <NumberFlow
- value={chargedToday}
- format={moneyFormat}
- locales="en-US"
- willChange
- />
- </div>
- )}
-
- <p className="mb-3.5 min-h-[30px] text-sm leading-relaxed text-zinc-800">
- {plan.description}
- </p>
-
- <div className="mb-3 h-px bg-zinc-100" />
-
- <div className="mb-4 flex flex-1 flex-col gap-2">
- {plan.features.map((f) => (
- <div key={f} className="flex items-center gap-2">
- <span
- aria-hidden="true"
- className={cn(
- "flex h-4 w-4 items-center justify-center rounded-full",
- isTeam ? "bg-stone-100" : "bg-purple-50",
- )}
- >
- <Icon
- icon={Tick02Icon}
- size={10}
- className={isTeam ? "text-stone-500" : "text-purple-500"}
- />
- </span>
- <span className="text-[13px] text-zinc-800">{f}</span>
- </div>
- ))}
- </div>
-
- <div className="relative isolate mt-5 w-full">
- {hl && (
- <motion.span
- aria-hidden
- className="pointer-events-none absolute -inset-0.5 -z-10 block rounded-[14px] bg-[linear-gradient(90deg,#a855f7,#7c3aed,#4f46e5,#6366f1,#a855f7)] bg-[length:200%_100%] opacity-25 blur-md"
- animate={
- reduceMotion
- ? undefined
- : { backgroundPosition: ["0% 50%", "100% 50%", "0% 50%"] }
- }
- transition={
- reduceMotion
- ? undefined
- : { duration: 8, repeat: Infinity, ease: "linear" }
- }
- />
- )}
- <Button
- variant={plan.buttonVariant}
- onClick={() => onSelect(plan.key)}
- className="w-full"
- loading={loading}
- disabled={disabled}
- {...(ctaGoalSurface && {
- "data-fast-goal": "plan_cta_click",
- "data-fast-goal-plan": plan.key.toLowerCase(),
- "data-fast-goal-cycle": isYearly ? "yearly" : "monthly",
- "data-fast-goal-surface": ctaGoalSurface,
- })}
- >
- {plan.cta}
- </Button>
- </div>
- </div>
- </div>
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/SubscriptionPlans.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/SubscriptionPlans.tsx
index 4c3fd1c340..9c3c823f03 100644
--- a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/SubscriptionPlans.tsx
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/SubscriptionPlans.tsx
@@ -5,18 +5,24 @@ import { PlanDetailsDialog } from "./components/PlanDetailsDialog/PlanDetailsDia
import { PlanFooter } from "./components/PlanFooter";
import { PlanHeader } from "./components/PlanHeader";
import { SubscriptionOffer } from "./components/SubscriptionOffer";
-import type { SubscriptionPlansProps } from "./helpers";
+import { DEFAULT_GOAL_SURFACE, type SubscriptionPlansProps } from "./helpers";
import { useSubscriptionPlans } from "./useSubscriptionPlans";
export function SubscriptionPlans({
trialStatus,
- ...props
-}: SubscriptionPlansProps & { trialStatus?: ReactNode }) {
+ header,
+ goalSurface = DEFAULT_GOAL_SURFACE,
+ ...rest
+}: SubscriptionPlansProps & {
+ trialStatus?: ReactNode;
+ header?: ReactNode;
+}) {
const { dialog, setDialog, setDialogOpen } = useSubscriptionPlans();
+ const props = { ...rest, goalSurface };
return (
<div className="mx-auto w-full max-w-7xl px-5 font-sans sm:px-8">
<section aria-label="Choose your AutoGPT plan">
- <PlanHeader {...props} />
+ <PlanHeader {...props} header={header} />
<div className="grid grid-cols-1 gap-4 lg:grid-cols-3">
{props.plans.map((plan) => (
<SubscriptionOffer
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/BillingToggle.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/BillingToggle.tsx
new file mode 100644
index 0000000000..b8354345b0
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/BillingToggle.tsx
@@ -0,0 +1,47 @@
+import { Button } from "@/components/atoms/Button/Button";
+import { cn } from "@/lib/utils";
+import type { SubscriptionPlansProps } from "../helpers";
+
+type Props = Pick<
+ SubscriptionPlansProps,
+ "billing" | "onBillingChange" | "goalSurface"
+>;
+
+export function BillingToggle({
+ billing,
+ onBillingChange,
+ goalSurface,
+}: Props) {
+ return (
+ <div
+ role="group"
+ aria-label="Billing period"
+ className="mt-3 flex rounded-full border border-zinc-200 bg-zinc-100 p-1"
+ >
+ {(["monthly", "yearly"] as const).map((cycle) => (
+ <Button
+ key={cycle}
+ type="button"
+ variant="ghost"
+ size="xs"
+ aria-pressed={billing === cycle}
+ onClick={() => onBillingChange(cycle)}
+ data-fast-goal="paywall_billing_toggle"
+ data-fast-goal-cycle={cycle}
+ data-fast-goal-surface={goalSurface}
+ className={cn(
+ "rounded-full px-4 text-xs",
+ billing === cycle
+ ? "bg-white text-zinc-900 shadow-sm hover:bg-white"
+ : "text-zinc-500",
+ )}
+ >
+ {cycle === "monthly" ? "Monthly billing" : "Yearly billing"}
+ {cycle === "yearly" && (
+ <span className="text-xs text-emerald-600">Save 15%</span>
+ )}
+ </Button>
+ ))}
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/OfferActions.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/OfferActions.tsx
index fb182eea0f..c0c92c0630 100644
--- a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/OfferActions.tsx
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/OfferActions.tsx
@@ -1,8 +1,12 @@
import { Button } from "@/components/atoms/Button/Button";
import { Text } from "@/components/atoms/Text/Text";
-import { PLAN_KEYS, type PlanDef } from "@/components/molecules/PlanCard/plans";
+import type { PlanDef } from "@/components/molecules/PlanCard/plans";
import { formatTrialPrice } from "@/components/organisms/TrialCard/helpers";
-import { getPlanPresentation, type SubscriptionPlansProps } from "../helpers";
+import {
+ getPlanPresentation,
+ isTeamPlan,
+ type SubscriptionPlansProps,
+} from "../helpers";
interface Props extends SubscriptionPlansProps {
plan: PlanDef;
@@ -35,7 +39,7 @@ export function OfferActions(props: Props) {
<AlternativeTrial {...props} offer={offer} />
) : (
<Text variant="small" tone="muted">
- {props.plan.key === PLAN_KEYS.TEAM
+ {isTeamPlan(props.plan.key)
? "Find the right fit for your team."
: "Manage your plan and billing anytime."}
</Text>
@@ -56,6 +60,7 @@ function PaidPlanAction({
isUpdatingTier,
selectedPlan,
onSelectPlan,
+ goalSurface,
inline = false,
price,
}: Props & { inline?: boolean; price?: string | null }) {
@@ -76,7 +81,7 @@ function PaidPlanAction({
data-fast-goal="plan_cta_click"
data-fast-goal-plan={plan.key.toLowerCase()}
data-fast-goal-cycle={billing}
- data-fast-goal-surface="onboarding_paywall"
+ data-fast-goal-surface={goalSurface}
>
{plan.cta}
{price && ` · ${price}`}
@@ -108,6 +113,7 @@ function AlternativeTrial({
offer,
onBillingChange,
isStartingTrial,
+ goalSurface,
}: Props & {
offer: NonNullable<SubscriptionPlansProps["trialOffer"]>;
}) {
@@ -125,7 +131,7 @@ function AlternativeTrial({
onClick={handleSwitchCycle}
data-fast-goal="paywall_billing_toggle"
data-fast-goal-cycle={offer.billing_cycle}
- data-fast-goal-surface="onboarding_paywall"
+ data-fast-goal-surface={goalSurface}
>
Try {plan.name} for {offer.duration_days} days instead
</Button>
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanHeader.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanHeader.tsx
index 9d72ff2524..4b120e3218 100644
--- a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanHeader.tsx
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanHeader.tsx
@@ -1,15 +1,31 @@
+import type { ReactNode } from "react";
import { AutoGPTLogo } from "@/components/atoms/AutoGPTLogo/AutoGPTLogo";
-import { Button } from "@/components/atoms/Button/Button";
import { Text } from "@/components/atoms/Text/Text";
-import { cn } from "@/lib/utils";
import type { SubscriptionPlansProps } from "../helpers";
+import { BillingToggle } from "./BillingToggle";
-export function PlanHeader({
- billing,
- onBillingChange,
-}: Pick<SubscriptionPlansProps, "billing" | "onBillingChange">) {
+type Props = Pick<
+ SubscriptionPlansProps,
+ "billing" | "onBillingChange" | "goalSurface"
+> & {
+ // A surface with its own title (the platform paywall modal) passes its
+ // heading here, or `null` to keep the heading it already renders outside the
+ // organism. Left undefined, the default onboarding heading renders.
+ header?: ReactNode;
+};
+
+export function PlanHeader({ header, ...billing }: Props) {
return (
<header className="mb-5 flex flex-col items-center text-center">
+ {header === undefined ? <DefaultHeading /> : header}
+ <BillingToggle {...billing} />
+ </header>
+ );
+}
+
+function DefaultHeading() {
+ return (
+ <>
<AutoGPTLogo hideText className="relative right-5 mb-2 h-8 w-20" />
<Text variant="h3" as="h1" className="leading-9">
Choose the plan that&apos;s right for{" "}
@@ -21,36 +37,6 @@ export function PlanHeader({
Upgrade, downgrade, or change plans anytime. All plans include core
features to get you started.
</Text>
- <div
- role="group"
- aria-label="Billing period"
- className="mt-3 flex rounded-full border border-zinc-200 bg-zinc-100 p-1"
- >
- {(["monthly", "yearly"] as const).map((cycle) => (
- <Button
- key={cycle}
- type="button"
- variant="ghost"
- size="xs"
- aria-pressed={billing === cycle}
- onClick={() => onBillingChange(cycle)}
- data-fast-goal="paywall_billing_toggle"
- data-fast-goal-cycle={cycle}
- data-fast-goal-surface="onboarding_paywall"
- className={cn(
- "rounded-full px-4 text-xs",
- billing === cycle
- ? "bg-white text-zinc-900 shadow-sm hover:bg-white"
- : "text-zinc-500",
- )}
- >
- {cycle === "monthly" ? "Monthly billing" : "Yearly billing"}
- {cycle === "yearly" && (
- <span className="text-xs text-emerald-600">Save 15%</span>
- )}
- </Button>
- ))}
- </div>
- </header>
+ </>
);
}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/SubscriptionOffer.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/SubscriptionOffer.tsx
index c45600101a..40c1470856 100644
--- a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/SubscriptionOffer.tsx
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/SubscriptionOffer.tsx
@@ -3,9 +3,13 @@ import type { TrialOfferResponse } from "@/app/api/__generated__/models/trialOff
import { Card } from "@/components/atoms/Card/Card";
import { Icon } from "@/components/atoms/Icon/Icon";
import { Text } from "@/components/atoms/Text/Text";
-import { PLAN_KEYS, type PlanDef } from "@/components/molecules/PlanCard/plans";
+import type { PlanDef } from "@/components/molecules/PlanCard/plans";
import { cn } from "@/lib/utils";
-import { getPlanPresentation, type SubscriptionPlansProps } from "../helpers";
+import {
+ getPlanPresentation,
+ isTeamPlan,
+ type SubscriptionPlansProps,
+} from "../helpers";
import { OfferActions } from "./OfferActions";
interface Props extends SubscriptionPlansProps {
@@ -28,10 +32,7 @@ export function SubscriptionOffer({ plan, onTrialDetails, ...props }: Props) {
<Text variant="body" tone="primary" className="min-h-11">
{plan.description}
</Text>
- <OfferFeatures
- features={plan.features}
- isTeam={plan.key === PLAN_KEYS.TEAM}
- />
+ <OfferFeatures features={plan.features} isTeam={isTeamPlan(plan.key)} />
<OfferActions {...props} plan={plan} onTrialDetails={onTrialDetails} />
</Card>
</section>
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/helpers.ts b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/helpers.ts
index 2a2b2a3569..84b294e9e1 100644
--- a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/helpers.ts
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/helpers.ts
@@ -6,6 +6,7 @@ import {
type PlanDef,
type PlanKey,
} from "@/components/molecules/PlanCard/plans";
+import type { useTrialCard } from "@/components/organisms/TrialCard/useTrialCard";
export interface SubscriptionPlansProps {
plans: PlanDef[];
@@ -19,10 +20,47 @@ export interface SubscriptionPlansProps {
selectedPlan?: string | null;
isStartingTrial: boolean;
trialError: string | null;
+ // Names the surface for DataFast, so a shared goal never mixes clicks from
+ // the onboarding paywall and the platform's upgrade modal. SubscriptionPlans
+ // fills in the default before passing props down.
+ goalSurface?: string;
}
+export const DEFAULT_GOAL_SURFACE = "onboarding_paywall";
+
export type PlanDialog = "compare" | "trial" | null;
+// Team is contact-sales on every surface, but onboarding's static plan list
+// keys it TEAM while the API-driven paywall gets BUSINESS from the backend.
+export function isTeamPlan(planKey: string) {
+ return planKey === PLAN_KEYS.TEAM || planKey === PLAN_KEYS.BUSINESS;
+}
+
+/**
+ * The offer to fold into the plan cards, or null to leave them priced as paid
+ * plans.
+ *
+ * A surface may only advertise a trial it can actually deliver: the status has
+ * to have loaded cleanly, the user has to still be eligible and unconverted,
+ * and the offered tier has to be both trialable and present in the plans on
+ * screen — otherwise the trial CTA would sit on a card the user can't reach,
+ * or nowhere at all.
+ */
+export function getEligibleTrialOffer(
+ controller: Pick<
+ ReturnType<typeof useTrialCard>,
+ "isLoading" | "queryError" | "trial"
+ >,
+ plans: PlanDef[],
+) {
+ const { isLoading, queryError, trial } = controller;
+ const offer = trial?.offer;
+ if (isLoading || queryError || !offer) return null;
+ if (!trial?.eligible || trial.converted) return null;
+ if (!supportsTrialPlan(offer.tier)) return null;
+ return plans.some((plan) => plan.key === offer.tier) ? offer : null;
+}
+
export function formatPlanAmount(amount: number, currency: string) {
return new Intl.NumberFormat("en-US", {
style: "currency",