Skip to content

[CI] (0ae2102) flask/flask3-social-media - #1218

Closed
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-0ae2102-flask-flask3-social-media
Closed

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-0ae2102-flask-flask3-social-media

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 0ae2102
App: flask/flask3-social-media
App directory: apps/flask/flask3-social-media
Workbench branch: wizard-ci-0ae2102-flask-flask3-social-media
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-04-15T19:06:57.532Z
Duration: 482.5s

@wizard-ci-bot

wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown
Author

This is a critical bug. Every single capture() and set() call in the PR uses incorrect positional arguments that throw TypeError at runtime. The no_throw() decorator silently swallows these errors, so the app won't crash, but no events will ever be captured and no person properties will be set.

Now I have all the information needed. Let me write the full review.


PR Evaluation Report

Summary

This PR integrates PostHog analytics into a Flask 3 social media application (Microblog). It installs the Python SDK, initializes a Posthog client in create_app(), and adds capture/set calls across auth, main, and API routes. However, every single capture() and set() call uses the wrong argument signature, passing positional arguments where keyword arguments are required, causing silent TypeError failures (swallowed by the SDK's no_throw() decorator). No events will ever actually be sent.

Files changed Lines added Lines removed
9 +82 -3

Confidence score: 4/5 👍

  • All capture() calls use wrong argument order: The v7 SDK's capture() method signature is capture(event: str, **kwargs) where event is the first positional arg and distinct_id must be a keyword argument. The PR passes capture(distinct_id, event_name, ...) as positional arguments, causing TypeError on every call. The no_throw() decorator silently swallows these errors, so the app doesn't crash but zero events are ever captured. [CRITICAL]
  • All set() calls use wrong argument order: set() takes only **kwargs (no positional args). The PR calls set(str(user.id), {'username': user.username}) which throws TypeError silently. Should be set(distinct_id=str(user.id), properties={'username': user.username}). [CRITICAL]
  • No Flask error handler integration for capture_exception(): Flask docs explicitly state that Flask's built-in error handlers prevent enable_exception_autocapture from working, and capture_exception(e) must be manually called in Flask's @app.errorhandler(Exception). The existing errors/handlers.py only handles 404 and 500 errors and doesn't call capture_exception(). [MEDIUM]
  • No .env.example file committed: The .env file is correctly gitignored and not committed, and env vars are mentioned in the setup report, but there is no .env.example for developers cloning the repo to know which PostHog env vars to set. [LOW]

File changes

Filename Score Description
app/__init__.py 4/5 PostHog client initialized correctly in create_app() with Posthog() constructor, enable_exception_autocapture=True, atexit.register(shutdown). Well done.
config.py 4/5 Env vars loaded via os.environ.get() with sensible defaults.
requirements.txt 5/5 posthog dependency added.
app/auth/routes.py 1/5 All capture() and set() calls use wrong positional argument pattern — none will work.
app/main/routes.py 1/5 All capture() calls use wrong positional argument pattern — none will work.
app/api/users.py 1/5 Both set() and capture() use wrong argument pattern.
app/api/tokens.py 1/5 capture() uses wrong argument pattern.
.gitignore 5/5 .env added correctly.
posthog-setup-report.md 3/5 Useful documentation, but no .env.example for other developers.

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) where distinct_id must be passed as a keyword argument. The PR passes arguments positionally like capture(str(user.id), 'event_name', {props}), which causes TypeError: Client.capture() takes 2 positional arguments but 3/4 were given. Same issue with set() which takes only **kwargs. The no_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={...}) and set(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)
  • .env is properly gitignored
  • posthog added to requirements.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 use capture(distinct_id, event_name, properties) positional pattern instead of the v7 SDK's capture(event_name, distinct_id=..., properties=...) keyword pattern. This causes TypeError silently swallowed by no_throw(). Zero events are captured. [CRITICAL]
  • Wrong set() argument pattern: All 3 set() calls use set(distinct_id, properties) positional pattern instead of set(distinct_id=..., properties=...). Same silent failure. [CRITICAL]
  • Flask error handler not integrated with capture_exception(): Per Flask PostHog docs, enable_exception_autocapture does NOT work in Flask because Flask intercepts exceptions via its built-in error handlers. Must add posthog.capture_exception(e) inside a @app.errorhandler(Exception) handler. The existing errors/handlers.py only 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 exit
  • enable_exception_autocapture=True is 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_completed have no properties. Adding properties like followed_user_id, recipient_id, etc. would improve analytics value. [LOW]

Other completed criteria

  • Event names are descriptive and use consistent snake_case naming 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_me are useful contextual properties on events that have them

Reviewed by wizard workbench PR evaluator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants