SIGN IN SIGN UP

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

0 0 73 Python

feat(backend): track subscription conversion events (#13181)

### Why / What / How

Tracks successful subscription payments as conversion events in PostHog
so paid plan conversions can be measured even when subscription credit
grants are disabled.

This adds a subscription payment success analytics event that captures
the user's subscription tier and billing cycle. The event uses Stripe
invoice subscription metadata when available, falls back to the user's
current subscription tier and stored billing cycle, and safely skips
tracking when PostHog is not configured.

### Changes 🏗️

- Add PostHog tracking for successful subscription payment invoices.
- Extract subscription metadata from current and parent invoice shapes.
- Add test coverage for paid plan tracking when credit grants are
disabled.

### Checklist 📋

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
- [x] `cd autogpt_platform/backend && poetry run pytest
backend/data/credit_subscription_test.py::test_handle_subscription_payment_success_tracks_paid_plan_when_grants_disabled
-q` — passed
- [x] `cd autogpt_platform/backend && poetry run ruff check
backend/data/credit.py backend/data/credit_subscription_test.py` —
passed
- [x] `cd autogpt_platform/backend && poetry run ruff format --check
backend/data/credit.py backend/data/credit_subscription_test.py` —
passed
- [x] `cd autogpt_platform/backend && poetry run format --check` —
failed on pre-existing unused variables in
`backend/api/features/store/db_test.py`
- [x] `cd autogpt_platform/backend && poetry run pytest
backend/data/credit_subscription_test.py -q` — timed out after 120s with
unrelated existing failures before completion
S
Swifty committed
39f69e72ebaa0cfeaaebbf08c759d01f946792c0
Parent: 1f22a0b
Committed by GitHub <noreply@github.com> on 5/21/2026, 3:49:52 PM