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
fix(billing): use a hand-set Enterprise AI budget only when it's a number, and word the custom line "from 10x" (#1598)
Cihan17701a9e52d5
diff --git a/server/src/lib/plan-guard.js b/server/src/lib/plan-guard.jsindex 87ce12f3e..fbb466b55 100644--- a/server/src/lib/plan-guard.js+++ b/server/src/lib/plan-guard.js@@ -38,7 +38,7 @@ export class PlanLimitError extends Error {* organizations.plan_overrides (jsonb) — mirrors web getOrgPlan().** The AI budget is the plan's $50 unless Ansvisor sets a customer's own in- * `improveMonthlyBudgetUsd` (2026-10-27: over $50, set per customer); the+ * `improveMonthlyBudgetUsd` (2026-10-27: $50 or more, a finite number, set per customer); the* contract's value doesn't raise it. `contractMonthlyUsd` is the contract's* monthly value, entered when the deal is signed. It sets the relevance* budget (VIS-011) to 0.1% of the contract (never below the plan default),@@ -54,6 +54,13 @@ export function applyPlanOverrides(plan, org) {) {const overrides = org.plan_overrides;const limits = { ...plan.limits, ...overrides };+ // A budget set by hand is used only as a number: null would read as+ // unlimited, and "80$" would fail every AI call. Anything else keeps+ // the plan's.+ const own = overrides.improveMonthlyBudgetUsd;+ if (own !== undefined && !(typeof own === 'number' && Number.isFinite(own))) {+ limits.improveMonthlyBudgetUsd = plan.limits.improveMonthlyBudgetUsd;+ }const usd = Number(overrides.contractMonthlyUsd);if (overrides.relevanceMonthlyBudgetUsd === undefined && Number.isFinite(usd) && usd > 0) {limits.relevanceMonthlyBudgetUsd = Math.max(diff --git a/server/src/lib/plan-guard.test.js b/server/src/lib/plan-guard.test.jsindex 9aedd301c..428366a3b 100644--- a/server/src/lib/plan-guard.test.js+++ b/server/src/lib/plan-guard.test.js@@ -68,6 +68,13 @@ describe('applyPlanOverrides — the Enterprise AI budget', () => {expect(budget({ contractMonthlyUsd: 2000, improveMonthlyBudgetUsd: 7 })).toBe(7);});+ it('keeps the plan’s budget when the one set by hand isn’t a number', () => {+ // null would read as unlimited, and "80$" would fail every AI call.+ for (const own of [null, '80', '80$', Number.NaN, Infinity, {}]) {+ expect(budget({ improveMonthlyBudgetUsd: own })).toBe(4.99);+ }+ });+it('keeps the default without a usable contract value', () => {expect(budget({ maxPrompts: 900 })).toBe(4.99);expect(budget({ contractMonthlyUsd: 'n/a' })).toBe(4.99);diff --git a/web/messages/en.json b/web/messages/en.jsonindex 0d7980744..270416616 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -7777,8 +7777,9 @@"briefs": "{count, number} content briefs a month","audits": "{count, number} site audits a month","aiUsage": "{count}x AI usage",- "aiUsageCustom": "Custom AI usage, over {count}x",- "aiUsageHint": "A monthly allowance for Ansvisor's AI features: Improve suggestions, the Content Editor's AI and the Action Center's task writing. Agent Chat runs on your own AI key. The free trial comes with a smaller allowance."+ "aiUsageCustom": "Custom AI usage, from {count}x",+ "aiUsageHint": "A monthly allowance for Ansvisor's AI features: Improve suggestions, the Content Editor's AI and the Action Center's task writing. Agent Chat runs on your own AI key. The free trial comes with a smaller allowance.",+ "aiUsageCustomHint": "A monthly allowance for Ansvisor's AI features: Improve suggestions, the Content Editor's AI and the Action Center's task writing. Agent Chat runs on your own AI key. Ansvisor sets the amount with you."},"contactUs": "Contact Us","integrations": "Integrations",diff --git a/web/src/components/settings/plan-switcher.test.tsx b/web/src/components/settings/plan-switcher.test.tsxindex 99af0e778..f61c4c90d 100644--- a/web/src/components/settings/plan-switcher.test.tsx+++ b/web/src/components/settings/plan-switcher.test.tsx@@ -137,11 +137,14 @@ describe('the plan cards', () => {expect(container.textContent).toContain('For large companies and agencies managing AI visibility at scale. Starting at $499/month.',);- // Its AI usage is set per customer, above Enterprise's $50 floor (10x Starter's).+ // Its AI usage is set per customer, from Enterprise's $50 (10x Starter's).const ai = [...container.querySelectorAll('li span')].find(- (el) => el.textContent === 'Custom AI usage, over 10x',+ (el) => el.textContent === 'Custom AI usage, from 10x',);expect(ai?.getAttribute('title')).toContain('A monthly allowance for Ansvisor');+ // The trial's smaller allowance isn't Enterprise's.+ expect(ai?.getAttribute('title')).not.toContain('free trial');+ expect(ai?.getAttribute('title')).toContain('Ansvisor sets the amount with you.');expect(container.textContent).not.toContain('10x AI usage');for (const point of ['Unlimited brands in a custom workspace',diff --git a/web/src/components/settings/plan-switcher.tsx b/web/src/components/settings/plan-switcher.tsxindex e7829ef4a..df2f2162a 100644--- a/web/src/components/settings/plan-switcher.tsx+++ b/web/src/components/settings/plan-switcher.tsx@@ -217,7 +217,7 @@ export function PlanSwitcher({ subscription, onUpdate }: PlanSwitcherProps) {const aiUsage = aiMultiple(PLANS.enterprise.limits.improveMonthlyBudgetUsd);return [...(aiUsage- ? [{ text: tCards('aiUsageCustom', { count: aiUsage }), hint: tCards('aiUsageHint') }]+ ? [{ text: tCards('aiUsageCustom', { count: aiUsage }), hint: tCards('aiUsageCustomHint') }]: []),...(t.raw('customPlanPoints') as string[]).map((text) => ({ text })),];