Repository navigation
[CI] (38ef7e6) fastapi/fastapi3-ai-saas - #2587
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 into a FastAPI AI SaaS application by adding the Python SDK, creating a custom ASGI middleware for user context identification, and instrumenting nine business-critical events across auth, content generation, API key management, and settings routes. However, a critical initialization mismatch means no events will actually be sent.
Confidence score: 4/5 👍
File changes
App sanity check
|
| Criteria | Result | Description |
|---|---|---|
| App builds and runs | Yes | No syntax errors; all imports resolve to valid posthog package exports |
| Preserves existing env vars & configs | Yes | Existing app code, configs, and env vars are preserved |
| No syntax or type errors | Yes | All changed files have valid Python syntax |
| Correct imports/exports | Yes | Imports resolve correctly (posthog exports capture, new_context, identify_context, Posthog) |
| Minimal, focused changes | Yes | Changes are focused on PostHog integration only |
| Pre-existing issues | None | No pre-existing issues noted |
Issues
.env.examplemissing PostHog variables:POSTHOG_PROJECT_TOKENandPOSTHOG_HOSTare not documented in.env.example. Collaborators won't know to set these. Add them to.env.example. [MEDIUM]
Other completed criteria
- Build configuration is valid —
requirements.txtis parseable with correct package specifier - All changes are relevant to PostHog integration
- Code follows existing codebase patterns (Pydantic Settings, router structure, middleware pattern)
PostHog implementation ❌
| Criteria | Result | Description |
|---|---|---|
| PostHog SDKs installed | Yes | posthog>=3.0.0 added to requirements.txt |
| PostHog client initialized | No | Posthog() instance created in main.py but never used — all routes use module-level capture() which relies on unconfigured global client |
| capture() | No | 9 capture() calls exist but all use module-level function bound to unconfigured global client — events are silently dropped |
| identify() | N/A | Server-only app |
| Error tracking | No | enable_exception_autocapture=True is set on the instance, but middleware's new_context() uses module-level function not connected to that instance |
| Reverse proxy | N/A | Server-only app |
Issues
- Instance/module-level client mismatch — no events sent:
main.pycreatesposthog_client = Posthog(settings.posthog_project_token, ...)but all route handlers importfrom posthog import capture(the module-level function). Module-level functions internally callsetup(), which checksposthog.api_key— never set in this PR. Per SDK docs: "Ifapi_keyis missing or blank, the client is disabled and module-level calls become no-ops." Fix: Either (a) switch routes to useposthog_client.capture()/posthog_client.new_context()via dependency injection, or (b) replace thePosthog()constructor with module-level config (import posthog; posthog.api_key = ...; posthog.host = ...) and use module-level functions throughout. [CRITICAL] - Middleware
new_context()also disconnected: ThePostHogMiddlewareusesfrom posthog import new_context, identify_context— module-level functions that won't use theposthog_clientinstance. Context identification and exception autocapture within the middleware are non-functional. [CRITICAL]
Other completed criteria
- API key loaded from environment variable via Pydantic Settings (
posthog_project_token) - Host correctly configured (
https://us.i.posthog.comdefault, configurable viaposthog_host) atexit.register(posthog_client.shutdown)correctly registered for clean shutdownposthog_client.flush()called in lifespan shutdown
PostHog insights and events ⚠️
| Filename | PostHog events | Description |
|---|---|---|
app/routers/auth.py |
user_signed_up, user_logged_in, user_logged_out |
Full auth lifecycle; signup/login include `` for person properties and method metadata |
app/routers/generate.py |
content_generated, content_generation_failed |
AI content generation success and failure (insufficient credits) with rich properties |
app/routers/api_keys.py |
api_key_created, api_key_revoked |
API key lifecycle tracking with active key count |
app/routers/settings.py |
settings_updated, password_changed |
Account management events |
Issues
- Events are well-designed but non-functional: All 9 events have good names, meaningful properties, and enable funnels (signup → login → generate), but none will actually be sent due to the client initialization mismatch. [CRITICAL]
Other completed criteria
- Events represent real user actions across the full product journey
- Events enable product insights (signup-to-generation funnel, credit usage trends, auth patterns)
- Events include relevant contextual properties (generation_type, credits_used, prompt_length, login_method)
- No PII in event properties — user ID (integer) used for identification, not email
- Event names are descriptive and consistent (snake_case,
[noun]_[verb]pattern)
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:
38ef7e6App:
fastapi/fastapi3-ai-saasApp directory:
apps/fastapi/fastapi3-ai-saasWorkbench branch:
wizard-ci-38ef7e6-fastapi-fastapi3-ai-saasWizard branch:
release-please--branches--main--components--wizardContext Mill branch:
mainPostHog (MCP) branch:
masterTimestamp: 2026-07-09T19:06:30.211Z
Duration: 474.0s
YARA Scanner