From 4aa93d94698b21adb9cb9c5812871cb91461b756 Mon Sep 17 00:00:00 2001 From: charles-ramos Date: Thu, 5 Nov 2026 10:17:02 -0300 Subject: [PATCH] Only Pay As You Go usage warnings name the overage price Every other paid plan (MVP, Advanced and the legacy plans) is told an upgrade is required: "At 100%, an upgrade is required." near the limit and "An upgrade is required." over it. Free keeps its own messages. Co-Authored-By: Claude Opus 5.5 --- src/dashboard/Data/AppOverview/usageAlert.js | 22 +++++++++--------- src/lib/tests/usageAlert.test.js | 24 ++++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/dashboard/Data/AppOverview/usageAlert.js b/src/dashboard/Data/AppOverview/usageAlert.js index 533068da4..49707a977 100644 --- a/src/dashboard/Data/AppOverview/usageAlert.js +++ b/src/dashboard/Data/AppOverview/usageAlert.js @@ -4,10 +4,9 @@ import { getUsagePercent } from '../../AppPlan/usageClassUtils'; const WARNING_PERCENT = 70; const DANGER_PERCENT = 90; -// Over-quota prices from the pricing page FAQ. Requests depend on the plan. Only the current -// MVP and Pay As You Go publish them, and Advanced has the same limits and prices as -// Pay As You Go: the other legacy plans get the warning without a price. -const EXTRA_REQUESTS_PRICE = { MVP: '$5', 'Pay As You Go': '$2', Advanced: '$2' }; +// Over-quota prices from the pricing page FAQ. Only Pay As You Go is billed for the overage: +// every other paid plan is told an upgrade is required instead. +const EXTRA_REQUESTS_PRICE = { 'Pay As You Go': '$2' }; // The next plan up, by kind. Legacy plans follow the current plan of their size. const UPGRADE_TARGET = { free: 'MVP', starter: 'MVP', mvp: 'Pay As You Go', payg: 'Dedicated' }; @@ -65,8 +64,9 @@ const planLabelOf = planData => { return /pay\s*as\s*you\s*go/i.test(name) ? 'Pay As You Go' : name; }; -// " Above 100%, extra requests are billed at ..." when the plan publishes its overage price. -const overageOf = (worst, plan, lead) => (plan in EXTRA_REQUESTS_PRICE ? ` ${lead}${worst.overage(plan)}.` : ''); +// " Above 100%, extra requests are billed at ..." on Pay As You Go, the upgrade notice on the other plans. +const overageOf = (worst, plan, lead, upgradeRequired) => + plan in EXTRA_REQUESTS_PRICE ? ` ${lead}${worst.overage(plan)}.` : ` ${upgradeRequired}`; // The limit to talk about: most urgent first (over 100%, then red, then yellow) and, within // the same level, the list order above. Also returns the others, most urgent first. @@ -92,7 +92,7 @@ export const upgradeTargetOf = planData => UPGRADE_TARGET[planKindOf(planData)]; // or { level, message, action, actionLabel }. The action is 'checkout' with the `plan` to sell // (the next one up) or, when there is no next plan to name, 'plans' for the Plan Usage page. // Every plan follows the Free thresholds: yellow above 70%, red above 90%. Only the consequence -// changes: Free stops responding at 100%, paid plans keep running and pay the overage. +// changes: Free stops responding at 100%, Pay As You Go pays the overage, other paid plans must upgrade. // The app is really blocked only when the server answers 402 or the plan is paused // ("Free Plan - Paused"); a Free app over its limit still serves requests until then. export const getUsageAlert = (planData, blocked = false) => { @@ -138,12 +138,12 @@ export const getUsageAlert = (planData, blocked = false) => { }; } - // Paid plans keep running over their limits and pay the overage, so the message names the - // price instead of an outage. Legacy plans have no published price and point at the next plan up. + // Pay As You Go keeps running over its limits and pays the overage, so the message names the + // price. The other paid plans are told an upgrade is required. const plan = planLabelOf(planData); const message = worst.percent >= 100 - ? `This app used ${percent}% of its ${plan} ${worst.label} ${amount}.${overageOf(worst, plan, 'It keeps running, and ')}` - : `${usageSummary(worst, percent, amount, ` on ${plan}`)}${othersClose(usage)}${overageOf(worst, plan, 'Above 100%, ')}`; + ? `This app used ${percent}% of its ${plan} ${worst.label} ${amount}.${overageOf(worst, plan, 'It keeps running, and ', 'An upgrade is required.')}` + : `${usageSummary(worst, percent, amount, ` on ${plan}`)}${othersClose(usage)}${overageOf(worst, plan, 'Above 100%, ', 'At 100%, an upgrade is required.')}`; return { level, message, ...upgrade }; }; diff --git a/src/lib/tests/usageAlert.test.js b/src/lib/tests/usageAlert.test.js index 3aa068fb4..af19ae056 100644 --- a/src/lib/tests/usageAlert.test.js +++ b/src/lib/tests/usageAlert.test.js @@ -88,28 +88,28 @@ describe('getUsageAlert', () => { expect(getUsageAlert(mvp({ apiCallUsed: '490 K' })).level).toBe('danger'); }); - it('names the overage price and opens the Pay As You Go checkout', () => { + it('says an upgrade is required at 100% and opens the Pay As You Go checkout', () => { const alert = getUsageAlert(mvp({ apiCallUsed: '490 K' })); expect(alert.message).toBe( - 'You\'ve used 98% of this month\'s API requests on MVP (490 K of 500 K). Above 100%, extra requests are billed at $5 per 100K.' + 'You\'ve used 98% of this month\'s API requests on MVP (490 K of 500 K). At 100%, an upgrade is required.' ); expect(alert.action).toBe('checkout'); expect(alert.plan).toBe('Pay As You Go'); expect(alert.actionLabel).toBe('Upgrade to Pay As You Go'); }); - it('past 100% it keeps running and pays the overage', () => { + it('past 100% says an upgrade is required, without an overage price', () => { const alert = getUsageAlert(mvp({ apiCallUsed: '520 K' })); expect(alert.level).toBe('danger'); expect(alert.message).toBe( - 'This app used 104% of its MVP API requests (520 K of 500 K). It keeps running, and extra requests are billed at $5 per 100K.' + 'This app used 104% of its MVP API requests (520 K of 500 K). An upgrade is required.' ); expect(alert.message).not.toMatch(/stop/i); }); - it('uses the storage overage prices', () => { - expect(getUsageAlert(mvp({ dataStorageUsed: '1.1 GB' })).message).toContain('extra database storage is billed at $15 per GB'); - expect(getUsageAlert(mvp({ fileStorageUsed: '55 GB' })).message).toContain('extra file storage is billed at $1 per 10 GB'); + it('never names a storage overage price', () => { + expect(getUsageAlert(mvp({ dataStorageUsed: '1.1 GB' })).message).not.toMatch(/billed/); + expect(getUsageAlert(mvp({ fileStorageUsed: '55 GB' })).message).not.toMatch(/billed/); }); it('a blocked app is offered the Pay As You Go checkout', () => { @@ -158,10 +158,10 @@ describe('getUsageAlert', () => { expect(alert.message).not.toMatch(/billed/); }); expect(getUsageAlert(legacy('Starter Plan', { apiCallUsed: '49 K' })).message).toBe( - 'You\'ve used 98% of this month\'s API requests on Starter (49 K of 50 K).' + 'You\'ve used 98% of this month\'s API requests on Starter (49 K of 50 K). At 100%, an upgrade is required.' ); expect(getUsageAlert(legacy('Starter Plan', { apiCallUsed: '52 K' })).message).toBe( - 'This app used 104% of its Starter API requests (52 K of 50 K).' + 'This app used 104% of its Starter API requests (52 K of 50 K). An upgrade is required.' ); }); @@ -175,17 +175,17 @@ describe('getUsageAlert', () => { }); }); - it('Advanced follows Pay As You Go: same thresholds, overage price and next plan', () => { + it('Advanced follows Pay As You Go thresholds and next plan, but is told to upgrade instead of billed', () => { const advanced = overrides => legacy('Advanced Plan', { apiCallLimit: '5 M', dataStorageLimit: '4 GB', fileStorageLimit: '250 GB', ...overrides }); expect(getUsageAlert(advanced({ apiCallUsed: '3.5 M' }))).toBe(null); expect(getUsageAlert(advanced({ apiCallUsed: '4 M' })).level).toBe('warning'); const alert = getUsageAlert(advanced({ apiCallUsed: '5.5 M' })); expect(alert.level).toBe('danger'); expect(alert.message).toBe( - 'This app used 110% of its Advanced API requests (5.5 M of 5 M). It keeps running, and extra requests are billed at $2 per 100K.' + 'This app used 110% of its Advanced API requests (5.5 M of 5 M). An upgrade is required.' ); expect(alert.plan).toBe('Dedicated'); - expect(getUsageAlert(advanced({ dataStorageUsed: '4.5 GB' })).message).toContain('and extra database storage is billed at $15 per GB'); + expect(getUsageAlert(advanced({ dataStorageUsed: '4.5 GB' })).message).not.toMatch(/billed/); }); it('a blocked legacy app is told which plan to move to', () => {