AforoUsageMeter
Real-time per-metric usage gauges with quota visualization, threshold detection (70/90/100%), and period-progress. Polls every 60s by default; emits threshold_reached events the parent page handles.
What it renders#
A grid of progress bars showing current-period usage vs quota for each metric on the customer's active subscription.
- Per-metric: name, used / quota figures, progress bar (0–100%), status pill (text + color)
- Color thresholds: green ≤70%, amber 70–90%, red ≥90% — color is supplementary; the status pill always carries text alternative
- Optional period-progress strip showing percent of the billing cycle elapsed
- Approximation note: when any metric's pricing model is tiered or allowance-based, the displayed value carries an upper-bound footnote (P14' revenue-estimation contract)
- Unlimited quota handling: metrics with
quota = 0render "Unlimited" (no progress bar) - Polls every 60s by default; configurable via prop
aforo.usage-meter.threshold_reached events the parent page can handle to show upgrade prompts or send notifications. Threshold detection fires once per metric per threshold per mount — re-mounting the widget re-arms the detector.Mount examples#
Props reference#
Compact vs expanded mode#
Compact renders a single horizontal strip with abbreviated metric names and small progress bars — appropriate for a header bar, sidebar widget, or notification rail. Expanded renders a 2-column grid (auto-stacks on narrow viewports) with full metric names, current vs quota figures, and progress bars sized for primary focus.
Thresholds#
The widget tracks three threshold crossings per metric: 70% (warning), 90% (critical), and 100% (exceeded). Crossings fire once per metric per threshold per mount — re-mounting the widget re-arms the detector. Each crossing emits an aforo.usage-meter.threshold_reached event with a typed payload.
Events#
See the for the full event vocabulary. UsageMeter emits:
aforo.usage-meter.ready— once on first paintaforo.usage-meter.threshold_reached— once per metric per threshold per mount (see Thresholds above)aforo.usage-meter.error— fetch failure with typed code (never PII)
Limitations#
- Polling, not SSE (yet). Today the widget polls every
pollIntervalMs(default 60s). Real-time SSE push lands in a subsequent release; until then, the 60s cadence is a sensible default for live-feeling usage without hammering the BFF. - Approximation footnote is fixed. The widget shows a single combined footnote when ANY metric uses tiered or allowance-based pricing. Per-metric flags are Phase 1.
- No magic-link fallback yet. UsageMeter requires a bridge token. Magic link parity with InvoiceList lands in a subsequent minor.
- No historical chart. The widget shows current-period usage only. A per-metric sparkline showing the last N billing cycles is filed as a follow-up.