@ai-billing/polar / PolarDestinationOptions
Interface: PolarDestinationOptions<TTags>
Defined in: polar-destination.ts:19 Options for createPolarDestination. Polar ingests events keyed by acustomerId (and optionally an externalId) plus a metadata map. This
destination extracts identity from billing event tags, builds default metadata from the event (usage +
tags), and includes cost when present.
Type Parameters
TTags
TTags extends DefaultTags = DefaultTags
The shape of the tags object, extending DefaultTags.
Properties
client?
Defined in: polar-destination.ts:26 Optional pre-configured Polar SDK client. When omitted, a client is constructed fromoptionalclient?:Polar
accessToken and
server.
accessToken?
Defined in: polar-destination.ts:28 Access token used when creating a Polar SDK client.optionalaccessToken?:string
server?
Defined in: polar-destination.ts:30 Polar environment used when creating a Polar SDK client.optionalserver?:"sandbox"|"production"
eventName
eventName:Defined in: polar-destination.ts:36 Event name to ingest into Polar, or a function that derives the name from the billing event. Use a function when you want different Polar events per model/provider while keeping one destination.string| ((event) =>string)
customerIdKey?
Defined in: polar-destination.ts:41 Tag key used to read the PolaroptionalcustomerIdKey?: keyofTTags
customerId (internal ID). When omitted, common tag keys are checked:
customerId, polarCustomerId, customer_id.
externalCustomerIdKey?
Defined in: polar-destination.ts:46 Tag key used to read the PolaroptionalexternalCustomerIdKey?: keyofTTags
externalId. When omitted, common tag keys are checked: userId,
externalId, user_id.
mapMetadata?
Defined in: polar-destination.ts:56 Optional override for the metadata payload sent to Polar. When omitted, metadata is built from buildMeterMetadata and includes:optionalmapMetadata?: (event) =>Record<string,string|number|boolean>
- token/usage dimensions
tag_*values from event tagscost_nanos/cost_currencywhenevent.costis present
Parameters
event
BillingEvent<TTags>
Returns
Record<string, string | number | boolean>