lago
lago copied to clipboard
[BUG]: Ingested event not counted in usage metrics (events_count = 0)
Describe the bug
Events are successfully ingested and visible in the developer events UI, but they are not being counted in the usage API response. When creating an event for an existing user and subscription, the event appears in /developer/events but the events_count remains 0 when fetching current usage via the API.
To Reproduce
- Customer ID:
stripe-customer-test - Subscription ID:
test_id - Billable Metric: "Chat Number" (code:
chat_number, aggregation:count_agg)
Steps to reproduce the behavior:
-
Create an event for an existing user and subscription:
curl --location --request POST '${LAGO_URL}/api/v1/events' \ --header 'Authorization: Bearer ••••••' \ --header 'Content-Type: application/json' \ --data '{ "event": { "transaction_id": "random-id-1", "external_subscription_id": "test_id", "code": "chat_number" } }' -
Verify the event was created successfully (returns event with
lago_id) -
Check the event appears in the developer events UI at
/developer/events -
Retrieve current usage for the customer:
curl --location --request GET '${LAGO_URL}/api/v1/customers/stripe-customer-test/current_usage?external_subscription_id=test_id' \ --header 'Authorization: Bearer •••••' \ --header 'Content-Type: application/json' -
Observe that
events_countis 0 instead of 1
Expected behavior
After successfully creating an event, the usage API should reflect the event in the count. Specifically, events_count should be 1 for the billable metric "Chat Number" with code "chat_number".
Actual behavior
- Event creation API returns success with
lago_id: "0b46a06c-5b14-4a63-bb3a-5054df47ebc9" - Event is visible in
/developer/eventsUI with correct payload - Usage API returns
"events_count": 0instead of expected"events_count": 1 lago_customer_idandlago_subscription_idarenullin the event response
API Responses
Event creation response:
{
"event": {
"lago_id": "0b46a06c-5b14-4a63-bb3a-5054df47ebc9",
"transaction_id": "random-id-1",
"lago_customer_id": null,
"code": "chat_number",
"timestamp": "2025-05-26T22:53:00.937Z",
"precise_total_amount_cents": null,
"properties": {},
"lago_subscription_id": null,
"external_subscription_id": "test_id",
"created_at": "2025-05-26T22:53:01Z"
}
}
Usage API response:
{
"customer_usage": {
"from_datetime": "2025-05-26T00:00:00Z",
"to_datetime": "2025-06-25T23:59:59Z",
"issuing_date": "2025-06-25",
"currency": "USD",
"amount_cents": 0,
"total_amount_cents": 0,
"taxes_amount_cents": 0,
"lago_invoice_id": null,
"charges_usage": [{
"units": "0.0",
"events_count": 0,
"amount_cents": 0,
"amount_currency": "USD",
"charge": {
"lago_id": "a85ad6d7-9476-45a0-9558-f2f898424ed8",
"charge_model": "standard",
"invoice_display_name": null
},
"billable_metric": {
"lago_id": "affa4df0-8978-4546-a9f9-a90f2938e8d9",
"name": "Chat Number",
"code": "chat_number",
"aggregation_type": "count_agg"
},
"filters": [],
"grouped_usage": []
}]
}
}
Environment
- Lago Version: v1.28.1 (Docker Hub)
- Deployment: Railway
Additional context
- The event shows
lago_customer_id: nullandlago_subscription_id: nullin the response, which might be related to the issue - The billable metric uses
count_aggaggregation type - The charge model is "standard"
- Events are visible in the UI but not reflected in usage calculations