isLoading: boolean and error: Error | null (see Introduction); the sections below list each hook’s specific returns.
useUsageMeter
Reads a single metric’s current-period usage against its entitlement limit — the live “X of Y used” reading that powers progress bars and quota warnings. It hitsGET /v1/usage?metricId=… scoped to the portal customer.
Parameters
The billable metric to meter. The query stays disabled until a non-empty
metricId (and a customer) is present.meter— theUsageMeterfor this metric, ornullwhile loading:
The metric identifier.
Human-readable metric name for display.
Units consumed this period.
The period allowance, or
null when unlimited.true when the plan grants unlimited usage of this metric.Server-computed percent consumed (
0–100). 0 when unlimited.useUsageHistory
Returns daily usage totals over a trailing window, one continuous series per event name. It reads the server-aggregatedGET /v1/usage/aggregate endpoint (one row per UTC day × event, summed in Postgres) so it’s correct at any event volume — a customer with a million events returns the same ~30 rows as one with ten. The hook returns the raw series only; charting is the caller’s job.
Parameters
Window length in trailing UTC days. The series is zero-filled across the whole window so charts render a continuous day axis even on quiet days.
series—Record<eventName, Array<{ date, total }>>— for each event name, a continuous daily series ordered oldest → today. Each point hasdate(UTC day,YYYY-MM-DD) andtotal(total quantity for that event on that day,0on days with no events). Day buckets are UTC-pinned on the server and the axis is built in UTC too, so they line up exactly.hasData—truewhen the server returned at least one aggregate row in the window. Use it to switch between an empty state and a populated chart.
useCreditBurn
Reports how fast one credit wallet is being consumed over a trailing window. It reads the server-aggregatedGET /v1/credits/stats endpoint scoped to a single credit currency — the daily consumed series is summed in Postgres from the append-only ledger, so it’s correct at any ledger volume.
Parameters
The credit wallet (currency) to measure. The query stays disabled until this and a customer are present.
Window length in trailing UTC days. The series is zero-filled across the whole window.
series—Array<{ date, consumed }>— zero-filled daily consumption ordered oldest → today.dateis the UTC day (YYYY-MM-DD),consumedis credits consumed that day (0on quiet days).avgPerDay—number— mean consumed per day over the window (windowSum / days, including zero days). The honest steady-state rate, not a cherry-picked active-day average.windowSum—number— total consumed across the window.peak—number— highest single-day consumption in the window.days—number— the window length echoed back.hasBurn—boolean—truewhenwindowSum > 0. Use it to switch between an idle-wallet state and the burn chart.
Runway is intentionally left to the caller: divide the wallet balance you already show on the card by
avgPerDay, so the number matches the displayed balance exactly. Read the balance from useCreditAccounts.See also
Credits & wallets
Wallet balances and the ledger
useCreditBurn aggregates.Entitlements & gates
The entitlement limit
useUsageMeter reads against.