unitpay.usage.track; for firehose volumes, use the stateful UnitPayIngestion batcher.
unitpay.usage.track
Tracks one billable event, or an array of them in a single request. Also exposed asunitpay.track(...).
Parameters — TrackEventInput | TrackEventInput[]:
Returns — Promise<TrackEventResult> with accepted: number, rejected: number, and optional rejections ({ index, reason, message }[]).
UnitPayIngestion
A separate, stateful client for high-throughput pipelines. Events are buffered and auto-flushed on an interval or when the batch fills; retries and buffer overflow are handled for you. Construct it once and keep it alive for the process lifetime. Constructor —UnitPayIngestionConfig:
Methods
track(event)— buffer one event (TrackEventParams); non-blocking. Fills inquantity,timestamp, andidempotencyKeyif omitted.flush()— force-flush the buffer now. ReturnsPromise<FlushResult>({ accepted, rejected, rejections }).check(params)— synchronous entitlement check, bypassing the buffer. Takes{ customerId, featureSlug, requestedUsage? }, returnsPromise<CheckResponse>({ access: boolean, deniedReason? }).shutdown()— stop the timer and flush what’s left. Call on process exit.bufferSize— current number of buffered events.
See also
Customers & subscriptions
Read who you’re billing.
Errors & pagination
Typed errors and retry behavior.