Repository navigation
[CI] (8dccaac) fastapi/fastapi3-ai-saas - #2354
Closed
wizard-ci-bot[bot] wants to merge 1 commit into
Closed
wizard-ci-bot[bot] wants to merge 1 commit into
wizard-ci-bot[bot] wants to merge 1 commit into
Conversation
Author
PR Evaluation ReportSummaryThis PR integrates PostHog analytics into a FastAPI-based AI SaaS application. It adds a PostHog client module with instance-based initialization and exception autocapture, a custom ASGI middleware that wraps requests in PostHog contexts, and 11 meaningful capture events across auth, content generation, API key management, settings, and usage routes. Environment variables are properly configured via Pydantic Settings.
Confidence score: 5/5 🧙
File changes
App sanity check ✅
Issues
|
| Criteria | Result | Description |
|---|---|---|
| PostHog SDKs installed | Yes | posthog>=3.0.0 in requirements.txt |
| PostHog client initialized | Yes | Instance-based Posthog() constructor with enable_exception_autocapture=True, host from env, atexit.register(shutdown) |
| capture() | Yes | 11 meaningful capture calls across all route modules |
| identify() | N/A | Server-only app |
| Error tracking | Yes | enable_exception_autocapture=True set on client; middleware wraps requests in new_context() which auto-captures exceptions |
| Reverse proxy | N/A | Server-only app |
Issues
- Email used as distinct_id throughout:
identify_context(user.email)is called inmiddleware.py(line 37),auth.pylogin (line 40), andauth.pysignup (line 84). Email is PII and should not be used as distinct_id — it exposes the email on every event and causes data fragmentation if the user changes their email. Usestr(user.id)instead, and set email via `` person properties (which the signup event already partially does withis_active). [MEDIUM]
Other completed criteria
- API key loaded from
POSTHOG_PROJECT_TOKENenvironment variable via Pydantic Settings — not hardcoded - Host correctly configured, defaults to
https://us.i.posthog.com, configurable viaPOSTHOG_HOST posthog_client.flush()called in FastAPI lifespan shutdownposthog_disabledflag allows disabling PostHog without code changes- Middleware correctly wraps requests in
new_context()so route captures inherit context
PostHog insights and events ✅
| Filename | PostHog events | Description |
|---|---|---|
app/routers/auth.py |
user_signed_up, user_logged_in, user_logged_out |
Auth lifecycle events; signup includes `` person properties, signup_method, and `credits_granted` |
app/routers/generate.py |
content_generated, content_generation_failed |
Core product events with generation type, credits used/remaining, prompt length, and failure reason |
app/routers/api_keys.py |
api_key_created, api_key_revoked |
API key lifecycle with active key count |
app/routers/pages.py |
dashboard_viewed |
Page view with total generations and API key count |
app/routers/settings.py |
settings_updated, password_changed |
Account management events with field changed |
app/routers/usage.py |
usage_stats_viewed |
Usage analytics with period, generation count, and credits used |
app/middleware.py |
capturedException (via autocapture) |
Middleware context enables automatic exception capture for all requests |
Issues
No issues — event naming is consistent (snake_case), events map to real user actions, properties are enriched with contextual metadata, and no PII appears in event properties.
Other completed criteria
- Events enable clear product funnels:
user_signed_up→dashboard_viewed→content_generated - Failure events (
content_generation_failed) with reason properties enable churn analysis - Properties include actionable metadata (credits, generation types, counts) without PII
- Event naming follows consistent
object_verbsnake_case convention
Reviewed by wizard workbench PR evaluator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated wizard CI run
Source: wizard-pr
Trigger ID:
8dccaacApp:
fastapi/fastapi3-ai-saasApp directory:
apps/fastapi/fastapi3-ai-saasWorkbench branch:
wizard-ci-8dccaac-fastapi-fastapi3-ai-saasWizard branch:
release-please--branches--main--components--wizardContext Mill branch:
mainPostHog (MCP) branch:
masterTimestamp: 2026-07-03T00:33:33.106Z
Duration: 759.1s
YARA Scanner