Recording Usage
Keep track of your customer’s feature usage with the event
route
When customers use features in your product, you’ll need to record their usage so Autumn can track it against their limits or bill them for usage.
There are two ways to record usage: sending events or setting usage directly.
Sending Events
The event route is recommended for tracking consumable features, like AI messages, credits or API calls. Each time a customer uses a feature, send an event to count their usage.
Before recording usage, you may want to check if the customer is allowed to use the feature. This prevents them from exceeding usage limits defined in the product.
You can also send a negative value
to increase the balance counter, which is
useful for increasing a feature limit (eg, if a customer removes a seat).
Setting Usage Directly
For other features (such as seats or workspaces), you may find it easier to set usage directly, rather than incrementing Autumn’s feature balance. The usage route lets you do this directly.
The usage route overwrites the current usage value. Use this carefully, as it can reset or override incremental usage recorded through events.
Using Event Names
In the above examples, we used the feature_id
to identify the feature. You can instead use the event_name
parameter to link usage to different events in your application. This can be useful when:
- Multiple features are affected by the same user action
- Different actions should count toward the same feature limit
- You need to write SQL queries on events in order to get a feature’s usage [coming soon!]
Example Use Case:
Let’s imagine you have an AI writing assistant that can generate emails, social media posts, and blog posts. You want to have a limit of 100 generations per month, but of that, you only want to allow 10 blog posts.
In this case, you can have 3 events: email_generation
, social_media_generation
, and blog_post_generation
.
These events will be linked to 2 features: total-generations
and blog-posts
.
total_generations
will be tied to all 3 events, while blog_posts
will only be tied to the blog_post_generation
event.
You can define event names in the Autumn dashboard:
- Go to the Products Page and click the “Features” tab.
- Click on the feature you want to add an event to.
- In the popup, click the “event_name” button.
- Add all of the events you want to link to the feature.
- Click “Update Feature”.
You can then record usage for these events from your application:
You can only use one of event_name
or feature_id
when recording usage.
Check that you’re sending the correct one in the request, especially if you’re
using a mix of snake_case
and kebab-case
.