track()
Attribute API costs to specific features in your app. This lets you see “my chat feature costs $8/day” instead of just “OpenAI costs $8/day”.
Usage
All API calls made inside the track() callback are tagged with the feature name and metadata.
Parameters
Alternative: startSpan
For cases where a callback wrapper doesn’t fit, use startSpan:
Always call span.end() when done. Forgetting to end a span means subsequent API calls may be attributed to the wrong feature.
Examples
Per-user cost tracking
Per-feature breakdown
Viewing tracked data
Feature and metadata are stored with each event and visible in:
- The dashboard event detail view
burn0 report (coming soon: per-feature breakdown)