Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
feat(settings): show the plans in Billing as the pricing page does (#1297)
Cihan46d1fff4d4ff
diff --git a/web/messages/en.json b/web/messages/en.jsonindex 5c529cae1..70b0b8b46 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -4847,11 +4847,6 @@"currentPlan": "Current Plan","month": "mo","year": "yr",- "unlimited": "Unlimited",- "brands": "brands",- "prompts": "prompt locations tracked",- "platforms": "answer engines",- "teamMembers": "team members","renewsOn": "Renews on {date}","cancelsOn": "Subscription ends on {date}","changePlan": "Change Plan",@@ -4880,7 +4875,34 @@"planChanged": "Plan updated successfully.","subscriptionCanceled": "Your subscription has been canceled.","needCustomPlan": "Need a custom plan?",- "customPlanDescription": "Get unlimited brands, custom integrations, dedicated support, and more.",+ "customPlanDescription": "For large companies and agencies managing AI visibility at scale. Starting at $499/month.",+ "customPlanPoints": [+ "Unlimited brands in a custom workspace",+ "All answer engines, Claude included",+ "Custom prompt and location tracking",+ "Custom KPI frameworks and data integrations",+ "Priority support and onboarding sessions",+ "SSO / SAML and custom feature requests"+ ],+ "planCards": {+ "starter": {+ "tagline": "For small teams getting started with AI visibility monitoring and optimization.",+ "engines": "ChatGPT & Microsoft Copilot tracking",+ "extras": ["MCP & API access"]+ },+ "growth": {+ "tagline": "For growing teams that want to monitor AI visibility and optimize content for AI search.",+ "engines": "ChatGPT, Perplexity, Gemini, Microsoft Copilot, Google AI Mode and Google AI Overviews tracking",+ "extras": ["Multi-region tracking", "White-label reports & Looker Studio"]+ },+ "brands": "{count, plural, one {# brand} other {# brands}}",+ "unlimitedBrands": "Unlimited brands",+ "seats": "{count, plural, one {# seat} other {# seats}}",+ "unlimitedSeats": "Unlimited seats",+ "prompts": "{count, number} prompts tracked",+ "briefs": "{count, number} content briefs a month",+ "audits": "{count, number} site audits a month"+ },"contactUs": "Contact Us","integrations": "Integrations","aiProviders": "AI Providers",diff --git a/web/src/components/settings/plan-switcher.test.tsx b/web/src/components/settings/plan-switcher.test.tsxnew file mode 100644index 000000000..ef3d94159--- /dev/null+++ b/web/src/components/settings/plan-switcher.test.tsx@@ -0,0 +1,106 @@+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { NextIntlClientProvider } from 'next-intl';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import messages from '../../../messages/en.json';+import { PlanSwitcher } from './plan-switcher';++vi.mock('sonner', () => ({ toast: Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn() }) }));++(+ globalThis as typeof globalThis & {+ IS_REACT_ACT_ENVIRONMENT: boolean;+ }+).IS_REACT_ACT_ENVIRONMENT = true;++let container: HTMLDivElement;+let root: Root;++async function render(planId = 'starter') {+ await act(async () => {+ root.render(+ <NextIntlClientProvider locale="en" messages={messages}>+ <PlanSwitcher+ subscription={{+ planId,+ status: 'active',+ currentPeriodEnd: null,+ cancelAtPeriodEnd: false,+ priceAmount: 49,+ interval: 'month',+ }}+ onUpdate={vi.fn()}+ />+ </NextIntlClientProvider>,+ );+ });+}++/** Each plan card's name and its list, in order. */+const cards = () =>+ Object.fromEntries(+ [...container.querySelectorAll('[data-slot="card"]')].map((card) => [+ card.querySelector('[data-slot="card-title"]')?.textContent,+ [...card.querySelectorAll('li')].map((li) => li.textContent),+ ]),+ );++beforeEach(() => {+ container = document.createElement('div');+ document.body.appendChild(container);+ root = createRoot(container);+});++afterEach(() => {+ act(() => root.unmount());+ container.remove();+});++describe('the plan cards', () => {+ it('list what each plan includes, as the pricing page does', async () => {+ await render();+ expect(cards()).toEqual({+ Starter: [+ '1 brand',+ 'Unlimited seats',+ '50 prompts tracked',+ 'ChatGPT & Microsoft Copilot tracking',+ '10 content briefs a month',+ '100 site audits a month',+ 'MCP & API access',+ ],+ Growth: [+ '4 brands',+ 'Unlimited seats',+ '200 prompts tracked',+ 'ChatGPT, Perplexity, Gemini, Microsoft Copilot, Google AI Mode and Google AI Overviews tracking',+ '50 content briefs a month',+ '500 site audits a month',+ 'Multi-region tracking',+ 'White-label reports & Looker Studio',+ ],+ });+ expect(container.textContent).not.toContain('8 answer engines');+ expect(container.textContent).toContain(+ 'For small teams getting started with AI visibility monitoring and optimization.',+ );+ });++ it('says what a custom plan adds, with a way to ask', async () => {+ await render('growth');+ expect(container.textContent).toContain('Need a custom plan?');+ expect(container.textContent).toContain(+ 'For large companies and agencies managing AI visibility at scale. Starting at $499/month.',+ );+ for (const point of [+ 'Unlimited brands in a custom workspace',+ 'All answer engines, Claude included',+ 'SSO / SAML and custom feature requests',+ ]) {+ expect(container.textContent).toContain(point);+ }+ expect(+ container.querySelector('a[href="https://www.ansvisor.com/contact-us"]')?.textContent,+ ).toBe('Contact Us');+ });+});diff --git a/web/src/components/settings/plan-switcher.tsx b/web/src/components/settings/plan-switcher.tsxindex 25b015c2a..9dacd39f0 100644--- a/web/src/components/settings/plan-switcher.tsx+++ b/web/src/components/settings/plan-switcher.tsx@@ -17,7 +17,6 @@ import {DialogTrigger,} from '@/components/ui/dialog';import { CONTACT_SALES_URL, PLANS, SUBSCRIBABLE_PLANS, type PlanId } from '@/config/plans';-import { ALL_SCRAPERS } from '@/config/prompt-options';interface SubscriptionData {planId: string;@@ -35,6 +34,7 @@ interface PlanSwitcherProps {export function PlanSwitcher({ subscription, onUpdate }: PlanSwitcherProps) {const t = useTranslations('settings');+ const tCards = useTranslations('settings.planCards');const [loading, setLoading] = useState(false);const [cancelLoading, setCancelLoading] = useState(false);const [portalLoading, setPortalLoading] = useState(false);@@ -135,6 +135,28 @@ export function PlanSwitcher({ subscription, onUpdate }: PlanSwitcherProps) {}}+ /**+ * A plan card's list, as the pricing page puts it: brands, seats, prompts,+ * the answer engines it tracks, content briefs and site audits a month,+ * then what the plan adds.+ */+ function planFeatures(planId: PlanId): string[] {+ const { limits } = PLANS[planId];+ return [+ limits.maxBrands === -1+ ? tCards('unlimitedBrands')+ : tCards('brands', { count: limits.maxBrands }),+ limits.maxTeamMembers === -1+ ? tCards('unlimitedSeats')+ : tCards('seats', { count: limits.maxTeamMembers }),+ tCards('prompts', { count: limits.maxPrompts }),+ tCards(`${planId}.engines`),+ tCards('briefs', { count: limits.maxBriefGenerations }),+ tCards('audits', { count: limits.maxSiteAudits }),+ ...(tCards.raw(`${planId}.extras`) as string[]),+ ];+ }+function isUpgrade(targetPlan: PlanId): boolean {const order = SUBSCRIBABLE_PLANS;return order.indexOf(targetPlan) > order.indexOf(currentPlanId);@@ -161,7 +183,7 @@ export function PlanSwitcher({ subscription, onUpdate }: PlanSwitcherProps) {</Badge>)}</div>- <p className="text-sm text-muted-foreground">{plan.tagline}</p>+ <p className="text-sm text-muted-foreground">{tCards(`${planId}.tagline`)}</p></CardHeader><CardContent><div className="mb-4">@@ -169,37 +191,13 @@ export function PlanSwitcher({ subscription, onUpdate }: PlanSwitcherProps) {<span className="text-sm text-muted-foreground">/{t('month')}</span></div>- <ul className="mb-4 space-y-1 text-sm text-muted-foreground">- <li>- {plan.limits.maxBrands === -1 ? t('unlimited') : plan.limits.maxBrands}{' '}- {t('brands')}- </li>- <li>- {plan.limits.maxPrompts === -1 ? t('unlimited') : plan.limits.maxPrompts}{' '}- {t('prompts')}- </li>- <li>- {plan.limits.maxPlatforms} {t('platforms')}- {plan.limits.allowedScrapers && plan.limits.allowedScrapers.length > 0 && (- <span className="text-xs text-muted-foreground/70">- {' '}- (- {plan.limits.allowedScrapers- .map((id) => {- const s = ALL_SCRAPERS.find((s) => s.id === id);- return s ? s.label.replace(/\s*\(Web\)/i, '') : id;- })- .join(' & ')}- )- </span>- )}- </li>- <li>- {plan.limits.maxTeamMembers === -1- ? t('unlimited')- : plan.limits.maxTeamMembers}{' '}- {t('teamMembers')}- </li>+ <ul className="mb-4 space-y-1.5 text-sm">+ {planFeatures(planId).map((feature) => (+ <li key={feature} className="flex items-start gap-2">+ <Check className="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" />+ <span>{feature}</span>+ </li>+ ))}</ul>{!isCurrent && (@@ -253,21 +251,31 @@ export function PlanSwitcher({ subscription, onUpdate }: PlanSwitcherProps) {})}</div>- {/* Enterprise / Custom Plan CTA */}- <div className="flex items-center justify-between gap-4 rounded-lg border bg-muted/30 p-5">- <div>- <p className="text-sm font-medium">{t('needCustomPlan')}</p>- <p className="text-xs text-muted-foreground">{t('customPlanDescription')}</p>+ {/* Custom plan: what it adds, from the pricing page */}+ <div className="space-y-3 rounded-lg border bg-muted/30 p-5">+ <div className="flex flex-wrap items-start justify-between gap-4">+ <div className="min-w-0 space-y-1">+ <p className="text-sm font-medium">{t('needCustomPlan')}</p>+ <p className="text-xs text-muted-foreground">{t('customPlanDescription')}</p>+ </div>+ <a+ href={CONTACT_SALES_URL}+ target="_blank"+ rel="noopener noreferrer"+ className="inline-flex shrink-0 items-center justify-center rounded-md border bg-background px-5 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground"+ >+ <Mail className="mr-2 h-4 w-4" />+ {t('contactUs')}+ </a></div>- <a- href={CONTACT_SALES_URL}- target="_blank"- rel="noopener noreferrer"- className="inline-flex shrink-0 items-center justify-center rounded-md border bg-background px-5 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground"- >- <Mail className="mr-2 h-4 w-4" />- {t('contactUs')}- </a>+ <ul className="grid gap-x-4 gap-y-1.5 text-xs sm:grid-cols-2">+ {(t.raw('customPlanPoints') as string[]).map((point) => (+ <li key={point} className="flex items-start gap-2">+ <Check className="mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" />+ <span>{point}</span>+ </li>+ ))}+ </ul></div>{/* Cancel / Reactivate + Stripe billing portal */}