Why this matters
Failed payments are often recoverable churn. A dunning funnel shows whether users update cards, retries recover revenue, or accounts silently cancel.
What you get
- Recovery rate after failed invoices
- Time to recovery
- Cancellations after dunning
- Revenue at risk and recovered
Walk through it
How effective is our dunning flow?
I’ll stitch billing webhook events into a recovery funnel.
Endpoint: POST /v1/projects/:project_id/analytics/query
Exact shape: /v1/openapi.json?path=%2Fv1%2Fprojects%2F%7Bproject_id%7D%2Fanalytics%2Fquery&method=post
Custom HogQL goes in the OpenAPI-defined `query` field.
Concept fields:
query: "SELECT event, count(DISTINCT properties.invoice_id) AS invoices, sum(toFloat(properties.amount)) AS amount FROM events WHERE event IN ('invoice_payment_failed','payment_method_updated','invoice_payment_recovered','subscription_canceled') AND timestamp > now() - INTERVAL 60 DAY GROUP BY event ORDER BY invoices DESC"
The output
The agent returns recovery rate, lost revenue, and suggested actions such as improving retry timing or card-update emails.
Setting it up
Emit billing lifecycle events from Stripe or your subscription provider webhook handler.
Variations
- “Segment recovery by plan.”
- “Find accounts with repeated payment failures.”
- “Draft a Slack digest for at-risk revenue.”