BillingMeter
Source:
src/Stripe/BillingMeter.ts
A Stripe Billing Meter — how usage events are aggregated over a billing
period for usage-based prices. eventName, defaultAggregation,
customerMapping, eventTimeWindow, and valueSettings are immutable.
Changing eventName replaces the meter. Display name updates in place;
status is changed with Stripe’s activate/deactivate endpoints.
Billing meters have no metadata field and cannot be hard-deleted.
Destroying this resource deactivates the meter. Deactivated meters
still occupy their eventName, so a later deploy with the same event
name reactivates the existing meter.
Creating a Billing Meter
Section titled “Creating a Billing Meter”Sum aggregation
const apiCalls = yield* Stripe.BillingMeter("api-calls", { displayName: "API Calls", eventName: "api_call", defaultAggregation: { formula: "sum" },});Count with custom value key
const tokens = yield* Stripe.BillingMeter("tokens", { displayName: "Tokens", eventName: "token_used", defaultAggregation: { formula: "count" }, valueSettings: { eventPayloadKey: "tokens" }, customerMapping: { type: "by_id", eventPayloadKey: "stripe_customer_id", },});Updating a Billing Meter
Section titled “Updating a Billing Meter”const apiCalls = yield* Stripe.BillingMeter("api-calls", { displayName: "API Calls (updated)", eventName: "api_call", defaultAggregation: { formula: "sum" },});Deactivating a Billing Meter
Section titled “Deactivating a Billing Meter”// stack.destroy() / resource removal calls deactivateconst apiCalls = yield* Stripe.BillingMeter("api-calls", { displayName: "API Calls", eventName: "api_call", defaultAggregation: { formula: "sum" },});