Skip to content

[eas-cli] Add tiered build-credit usage warnings (approaching/at/over)#3882

Open
sarahlane8 wants to merge 2 commits into
mainfrom
sarah/build-credit-warning-tiers
Open

[eas-cli] Add tiered build-credit usage warnings (approaching/at/over)#3882
sarahlane8 wants to merge 2 commits into
mainfrom
sarah/build-credit-warning-tiers

Conversation

@sarahlane8

Copy link
Copy Markdown

Why

The existing pre-build warning fires at a single 85% threshold and gives Free vs paid plan messaging but doesn't distinguish between approaching the limit, reaching it, and exceeding it. As users move through those states, the message they need to see changes — and the current single-tier message is technically inaccurate once they hit 100%.

This PR splits the warning into three tiers, lowers the threshold to 80% to match Expo's email warning cadence, and standardizes the wording across the existing dashboard's "billing period" language.

How

  • Expanded the existing warning GraphQL query (AccountUsageForOverageWarning) to also return overageMetrics { value } and totalCost. These already exist on the schema; the query just wasn't asking for them.
  • Added classifyUsageTier: returns 'approaching' | 'at' | 'over' | null based on plan value, limit, and overage count. over wins if any overage is recorded; at if planValue >= limit with no overage; approaching if >= 80%.
  • Rewrote displayOverageWarning with tier-specific messaging:
    • Approaching: progress bar + percent + "you'll be charged / blocked" warning
    • At: "you've reached your limit" + plan-specific consequence
    • Over (paid): overage count + dollar amount accrued
    • Over (Free): defensively renders the at message since Free can't accumulate overage (blocked at the limit). Kept as a safety net for data inconsistencies.
  • Standardized wording: all three tiers now say "this billing period" (was "for this month"), matching the existing eas account:usage dashboard.
  • Did not change the call site logic in runBuildAndSubmit.ts — the warning still fires once per eas build invocation, before the first build, and is skipped for --local builds.

Test Plan

  • 26 unit tests pass, covering every (tier × plan) combination plus the classifier, progress bar, and account-name billing URL.

  • Local preview script (not committed; lives in gitignored packages/eas-cli/tmp/) renders every variant for visual inspection. Sample output:

    === Approaching · Paid (90%) ===
    You've used 90% of your included build credits this billing period. ███████████████████████████░░░
    Additional usage beyond your limit will be charged at pay-as-you-go rates. See usage in billing.: https://expo.dev/accounts/demo-account/settings/billing
    
    === At limit · Free (100%) ===
    You've reached your included build credits this billing period.
    New builds are blocked until your billing period resets. Upgrade your plan to continue building.: https://expo.dev/accounts/demo-account/settings/billing
    
    === Over · Paid (multiple overage builds) ===
    You've used 12 builds beyond your included credits this billing period ($18.00 in overages so far).
    Additional builds continue at pay-as-you-go rates. See usage in billing.: https://expo.dev/accounts/demo-account/settings/billing
    
  • Not yet verified end-to-end against a real account on staging — the GraphQL fields already exist on the schema, but it would be good to confirm the query returns expected data against a real over-limit account before merging.

Copy review

Public-facing customer warning copy. Would appreciate eyes from PM / customer success / growth before merging.

Lowers the warning threshold from 85% to 80% to match email
notifications. Adds two new tiers beyond the existing "approaching":
one when the user has reached their included credits, and one when
they've exceeded them on a paid plan. Free plans collapse the "over"
case into the "at" message since Free is blocked at the limit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Subscribed to pull request

File Patterns Mentions
**/* @douglowder

Generated by CodeMention

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.61905% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 58.94%. Comparing base (0986682) to head (e9bde3e).

Files with missing lines Patch % Lines
...ckages/eas-cli/src/utils/usage/checkForOverages.ts 97.62% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3882      +/-   ##
==========================================
+ Coverage   58.91%   58.94%   +0.03%     
==========================================
  Files         932      932              
  Lines       40744    40772      +28     
  Branches     8593     8601       +8     
==========================================
+ Hits        24002    24029      +27     
- Misses      16646    16647       +1     
  Partials       96       96              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

✅ Thank you for adding the changelog entry!

@sarahlane8 sarahlane8 requested a review from keith-kurak June 18, 2026 22:49
Comment thread packages/eas-cli/src/utils/usage/checkForOverages.ts
@sarahlane8 sarahlane8 requested a review from sjchmiela June 19, 2026 00:45
@sarahlane8 sarahlane8 self-assigned this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants