Skip to content

[ CONVEX COMPONENT · STABLE · MIT ]

@vllnt/convex-metering

Metered usage records — idempotent usage events rolled up per billing period

STABLE 0.1.0 · 2 GitHub stars

Package details

Install

The untagged install gets the latest stable version (0.1.0). The canary tag tracks main (0.1.1-canary.8b4806c).

terminal
pnpm add @vllnt/convex-metering
pnpm add @vllnt/convex-metering@canary

Register the component

Add it to your app’s convex/convex.config.ts, then run npx convex dev to generate the references.

convex/convex.config.ts
import { defineApp } from "convex/server";
import metering from "@vllnt/convex-metering/convex.config";
const app = defineApp();
app.use(metering);
export default app;

Use it

Usage, options and examples are in the package README.

Read the README

Downloads

Last 7 days
42
Since first publish
3,598

Downloads per week since 17 June 2026, oldest on the left. Weeks count back from 23 November 2026, so the first one may be shorter than seven days.

42 downloads in the last 7 days. 3,598 downloads since 17 June 2026. Source: npm, counted through 23 November 2026.

Show downloads per week as a table
WeekDownloads
17 June 2026 to 22 June 2026418
23 June 2026 to 29 June 202615
30 June 2026 to 6 July 202684
7 July 2026 to 13 July 202645
14 July 2026 to 20 July 202619
21 July 2026 to 27 July 20268
28 July 2026 to 3 August 202612
4 August 2026 to 10 August 202623
11 August 2026 to 17 August 2026132
18 August 2026 to 24 August 202658
25 August 2026 to 31 August 2026394
1 September 2026 to 7 September 2026480
8 September 2026 to 14 September 2026242
15 September 2026 to 21 September 2026257
22 September 2026 to 28 September 2026640
29 September 2026 to 5 October 202644
6 October 2026 to 12 October 202648
13 October 2026 to 19 October 202625
20 October 2026 to 26 October 2026288
27 October 2026 to 2 November 2026173
3 November 2026 to 9 November 202695
10 November 2026 to 16 November 202656
17 November 2026 to 23 November 202642

Release history

Every release on a timeline, oldest on the left. A tall mark with its version is a stable release; a short mark is a canary build. The time axis is the one of the downloads chart, so a release stands above the week it shipped in.

1 stable release and 9 canary builds since 17 June 2026. Latest stable: 0.1.0 on 1 September 2026.

Show every release as a table
VersionKindPublished
0.1.1-canary.8b4806ccanary31 October 2026
0.1.0stable1 September 2026
0.1.0-canary.12576b5canary1 September 2026
0.1.0-canary.4c0f067canary31 August 2026
0.1.0-canary.d30a2d9canary31 August 2026
0.1.0-canary.86ece96canary31 August 2026
0.1.0-canary.0c63a9fcanary17 June 2026
0.1.0-canary.1748317canary17 June 2026
0.1.0-canary.f3d0963canary17 June 2026
0.1.0-canary.a0e1e08canary17 June 2026

Changelog

The newest stable releases of @vllnt/convex-metering, with the notes from its changelog.

  1. 0.1.0

    Added
    • First release of @vllnt/convex-metering.
    • defineMeter registers a meter with a per-meter aggregation rule (sum | max | last) and a display unit; record writes a usage event and folds it into the (meter, subject, period) rollup on write.
    • Idempotent recording: passing an idempotencyKey makes a retried record a safe no-op ({ recorded: false, reason: "duplicate" }), so at-least-once delivery never double-counts.
    • Records + rollups split: raw records are the append-only audit trail and idempotency source; rollups are the O(1) per-period read for billing and limit checks (the billable truth, never pruned).
    • usage / listUsage read a subject's rollups; reset clears one (meter, subject, period).
    • pruneRecords deletes raw records older than a required before cutoff (no default-to-now footgun), bounded and self-rescheduling; rollups are untouched.
    • period is a host-supplied opaque string — the component never parses dates, keeping it locale- and calendar-agnostic. Scopes namespace meters per tenant; server-sourced timestamps throughout.
    • Fully typed end to end — quantities, periods, units, and refs are concrete types; no v.any().
    • record rejects a negative or non-finite quantity with INVALID_QUANTITY, and an undefined meter with METER_NOT_FOUND.
    • Optional @vllnt/convex-metering/react entry — useUsage (a live usage meter deriving remaining/fraction/exceeded from an optional limit) and useUsageList. Thin useQuery wrappers over the host's re-exported refs; react is an optional peer dep; render-tested in jsdom at 100%.
    • adjust — signed corrections (refund/credit/void) on sum meters; appends a reversing record, keeps the rollup equal to the sum of records and never negative (ADJUST_BELOW_ZERO).
    • recordWithLimit — atomic check-and-record against a limit (closes the read-then-write overage race); returns limit_exceeded without recording when it would cross.
    • closePeriod + closed on the usage reads — freeze a billed period so a late event can't restate it (record/adjust/recordWithLimit then throw PERIOD_CLOSED).
    • eraseSubject (GDPR, across all meters/periods), listMeters, listSubjectUsage, and verify (reconcile the rollup against surviving records). reset is now bounded + self-rescheduling (returns a count) and pruneSeen prunes the idempotency ledger. Optional actorRef on records.
    Changed
    • Idempotency dedup moved to a dedicated seen table. A meter's aggregation is now locked once usage exists (AGGREGATION_LOCKED), and an idempotencyKey on a non-sum gauge is rejected (IDEMPOTENCY_NOT_SUPPORTED).
    • Treat Convex _generated output as CLI-owned and expose a dedicated codegen script.
    • Require convex@^1.45.0.
    Fixed
    • Prune-vs-dedup double-count. Dedup previously read the records table that pruneRecords deletes, so a redelivered event after a prune re-counted the billable rollup. Dedup now lives in the separate seen ledger (pruned independently via pruneSeen), so pruning audit rows never re-opens a duplicate. The earlier docs ("retried record is a safe no-op", "rollups never touched") implied prune was consequence-free; corrected.
    • Return duplicate before quota projection for retried limited records, even when later usage would now exceed the supplied limit.
    • Reject negative or non-finite quota limits and unsafe maintenance batch/cutoff values, preventing stalled self-scheduling loops and oversized transactions.
All releases of @vllnt/convex-metering
Stable releases
RSSAtomJSON Feed
Canary builds
RSSAtomJSON Feed

Licence

Released under the MIT licence. The full text is in the source repository.

[ PACKAGE ]

Stable
0.1.0
Canary
0.1.1-canary.8b4806c
GitHub stars
2 GitHub stars
Licence
MIT

Theme