Repository navigation
[CI] (0ae2102) flask/flask3-social-media - #1218
wizard-ci-bot[bot] wants to merge 1 commit into
Conversation
|
This is a critical bug. Every single Now I have all the information needed. Let me write the full review. PR Evaluation ReportSummaryThis PR integrates PostHog analytics into a Flask 3 social media application (Microblog). It installs the Python SDK, initializes a
Confidence score: 4/5 👍
File changes
App sanity check
|
| Criteria | Result | Description |
|---|---|---|
| App builds and runs | Yes | No syntax errors; TypeError from capture calls is silently caught by no_throw() decorator, so the app runs without crashing |
| Preserves existing env vars & configs | Yes | All existing config vars and env vars are preserved |
| No syntax or type errors | No | All capture() and set() calls throw TypeError at runtime due to wrong positional argument usage — 14 calls affected |
| Correct imports/exports | Yes | from posthog import Posthog is correct; current_app properly imported in all modified files |
| Minimal, focused changes | Yes | All changes are focused on PostHog integration |
| Pre-existing issues | None | No pre-existing issues identified |
Issues
- All capture/set calls throw TypeError: The PostHog Python SDK v7+ uses
capture(event: str, **kwargs)wheredistinct_idmust be passed as a keyword argument. The PR passes arguments positionally likecapture(str(user.id), 'event_name', {props}), which causesTypeError: Client.capture() takes 2 positional arguments but 3/4 were given. Same issue withset()which takes only**kwargs. Theno_throw()decorator silently swallows these errors, making the app appear functional while capturing zero events. Every call should use keyword args:capture('event_name', distinct_id=str(user.id), properties={...})andset(distinct_id=str(user.id), properties={...}). [CRITICAL]
Other completed criteria
- App preserves all existing functionality
- Changes are focused and minimal
- Imports are correct (
Posthog,current_app,atexit) .envis properly gitignoredposthogadded torequirements.txt
PostHog implementation ⚠️
| Criteria | Result | Description |
|---|---|---|
| PostHog SDKs installed | Yes | posthog added to requirements.txt |
| PostHog client initialized | Yes | Posthog() constructor used in create_app() with api_key, host, and enable_exception_autocapture=True. Client stored on app.posthog_client. atexit.register(posthog_client.shutdown) ensures flush on exit. |
| capture() | No | 13 capture calls present but ALL use wrong positional argument pattern and silently fail at runtime |
| identify() | N/A | Server-only app |
| Error tracking | No | enable_exception_autocapture=True is set, but Flask docs explicitly state this won't work because Flask has built-in error handlers that catch exceptions before PostHog can. Manual capture_exception(e) should be added to the error handlers in errors/handlers.py. |
| Reverse proxy | N/A | Server-only app |
Issues
- Wrong capture() argument pattern: All 13
capture()calls usecapture(distinct_id, event_name, properties)positional pattern instead of the v7 SDK'scapture(event_name, distinct_id=..., properties=...)keyword pattern. This causesTypeErrorsilently swallowed byno_throw(). Zero events are captured. [CRITICAL] - Wrong set() argument pattern: All 3
set()calls useset(distinct_id, properties)positional pattern instead ofset(distinct_id=..., properties=...). Same silent failure. [CRITICAL] - Flask error handler not integrated with capture_exception(): Per Flask PostHog docs,
enable_exception_autocapturedoes NOT work in Flask because Flask intercepts exceptions via its built-in error handlers. Must addposthog.capture_exception(e)inside a@app.errorhandler(Exception)handler. The existingerrors/handlers.pyonly handles 404/500 and doesn't capture exceptions to PostHog. [MEDIUM]
Other completed criteria
- PostHog SDK installed in
requirements.txt - Client correctly initialized using
Posthog()class constructor (instance-based, not module-level) - API key loaded from environment variable (
POSTHOG_PROJECT_TOKEN) - Host configured via environment variable with correct default (
https://us.i.posthog.com) atexit.register(posthog_client.shutdown)ensures event flush on exitenable_exception_autocapture=Trueis set (though ineffective in Flask)- Blueprint registration happens after PostHog initialization
PostHog insights and events ⚠️
| Filename | PostHog events | Description |
|---|---|---|
app/auth/routes.py |
user_signed_up, user_logged_in, user_logged_out, password_reset_requested, password_reset_completed |
Full auth lifecycle tracked — signup with signup_method, login with login_method, logout (with auth check), password reset flow |
app/main/routes.py |
post_created, profile_updated, user_followed, user_unfollowed, message_sent, posts_export_started |
Social engagement events — post creation with language, profile edits with has_about_me, follow/unfollow, messaging, exports |
app/api/users.py |
api_user_created |
API user registration with signup_method: api property, plus person property set for username |
app/api/tokens.py |
api_token_issued |
API token issuance tracking |
Issues
- All events silently fail due to argument pattern bug: Despite excellent event selection and naming, no events are actually captured due to the wrong argument pattern in all calls. This makes the entire event layer non-functional. [CRITICAL]
- Some events lack enriched properties:
user_followed,user_unfollowed,message_sent,posts_export_started,api_token_issued,user_logged_out,password_reset_requested,password_reset_completedhave no properties. Adding properties likefollowed_user_id,recipient_id, etc. would improve analytics value. [LOW]
Other completed criteria
- Event names are descriptive and use consistent
snake_casenaming convention - Events represent real user actions in the social media app flow
- Events would enable product insights (signup→post→follow funnel, engagement trends, churn signals)
- No PII in event properties (username set via
set()on person profile, not in event properties) signup_method,login_method,language,has_about_meare useful contextual properties on events that have them
Reviewed by wizard workbench PR evaluator
Automated wizard CI run
Source: wizard-pr
Trigger ID:
0ae2102App:
flask/flask3-social-mediaApp directory:
apps/flask/flask3-social-mediaWorkbench branch:
wizard-ci-0ae2102-flask-flask3-social-mediaWizard branch:
release-please--branches--main--components--wizardContext Mill branch:
mainPostHog (MCP) branch:
masterTimestamp: 2026-04-15T19:06:57.532Z
Duration: 482.5s