Skip to content

[CI] (1cca5f3) flask/flask3-social-media - #3546

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

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

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 1cca5f3
App: flask/flask3-social-media
App directory: apps/flask/flask3-social-media
Workbench branch: wizard-ci-1cca5f3-flask-flask3-social-media
Wizard branch: brandon/gateway-token-flow
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-08-24T18:42:58.020Z
Duration: 756.2s

YARA Scanner

✓ 174 tool calls scanned, 0 violations detected

No violations: ✓ 174 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown
Author

PR Evaluation Report

Summary

This PR integrates PostHog into a Flask 3 social media application using the Python SDK's instance-based API (Posthog() constructor). It adds request-scoped context management via before_request/teardown_request hooks, user identification on authentication, error tracking via a 500 error handler, and 14 meaningful event captures across auth, social, and API flows.

Files changed Lines added Lines removed
11 +159 -11

Confidence score: 5/5 🧙

  • Context teardown suppresses exceptions: The teardown_request hook calls context.__exit__(None, None, None) regardless of whether the request raised an exception. It should pass the actual exception info so the context can capture it — otherwise enable_exception_autocapture=True only catches exceptions raised inside the with block, which this manual enter/exit pattern bypasses. [MEDIUM]
  • PII in set() call: identify_posthog_user() sends email and username via posthog_client.set() as person properties, which is the correct place for PII (person profile, not event properties). No issue here.

File changes

Filename Score Description
app/__init__.py 4/5 Core PostHog setup: Posthog() init, atexit shutdown, before_request/teardown_request context management, identify helper
app/auth/routes.py 5/5 Captures login, logout, registration, password reset events with properties
app/main/routes.py 5/5 Captures post_created, profile_updated, follow/unfollow, translation, search, message, export events
app/errors/handlers.py 4/5 Manual capture_exception in 500 handler — correct Flask pattern
app/api/auth.py 5/5 Identifies users on basic auth and token auth verification
app/api/tokens.py 5/5 Captures api_token_created and api_token_revoked events
app/api/users.py 5/5 Captures api_user_registered with registration_method property
config.py 5/5 Adds POSTHOG_PROJECT_TOKEN and POSTHOG_HOST from env vars
.env.example 5/5 Documents both required env vars
requirements.txt 5/5 Adds posthog dependency
.gitignore 5/5 Adds .venv to gitignore — minor housekeeping

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes All imports valid, posthog added to requirements.txt
Preserves existing env vars & configs Yes Existing config untouched, PostHog vars appended
No syntax or type errors Yes All code is syntactically valid
Correct imports/exports Yes Posthog from posthog, current_app, g, flask_login imports correct
Minimal, focused changes Yes Only PostHog-related additions, no unrelated refactoring
Pre-existing issues None —

Issues

  • Context teardown ignores exceptions: close_posthog_request_context always passes (None, None, None) to __exit__, so exceptions raised during the request are not forwarded to the context for autocapture. The enable_exception_autocapture=True flag relies on the context seeing the exception. The manual capture_exception in the 500 handler partially compensates, but unhandled exceptions in non-500 scenarios may be missed. [MEDIUM]

Other completed criteria

  • All changes are relevant to PostHog integration
  • Correct files modified for Flask framework
  • Code follows existing codebase patterns (same indentation, Flask idioms, blueprint structure)
  • .venv added to .gitignore is a minor but reasonable housekeeping addition

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog added to requirements.txt
PostHog client initialized Yes Posthog() constructor with token, host, and enable_exception_autocapture=True in create_app()
capture() Yes 14 meaningful capture calls across auth, social, API, and error flows
identify() N/A Server-only app
Error tracking Yes Manual capture_exception() in 500 error handler + enable_exception_autocapture=True on client
Reverse proxy N/A Server-only app

Issues

  • Context exception forwarding: As noted above, the manual context __exit__ call doesn't pass exception info. While the 500 handler covers HTTP errors, this weakens the autocapture for non-HTTP exceptions. [MEDIUM]

Other completed criteria

  • API key loaded from environment variable via Config class
  • Host correctly configured from environment variable
  • atexit.register(posthog_client.shutdown) ensures clean flush on exit
  • Request context properly opened in before_request and closed in teardown_request
  • User identification via identify_context() on authenticated requests and auth events
  • Person properties set via posthog_client.set() (correct method for Python SDK)
  • Tracing headers (X-POSTHOG-DISTINCT-ID, X-POSTHOG-SESSION-ID) supported

PostHog insights and events ✅

Filename PostHog events Description
app/auth/routes.py user_logged_in, user_logged_out, user_registered, password_reset_completed Auth lifecycle with remember_me and registration_method properties
app/main/routes.py post_created, profile_updated, user_followed, user_unfollowed, translation_requested, search_performed, message_sent, posts_export_requested Social interactions with contextual properties (language, result_count, message_length)
app/api/tokens.py api_token_created, api_token_revoked API token lifecycle
app/api/users.py api_user_registered API registration with registration_method property
app/errors/handlers.py capturedException 500 errors captured via capture_exception()

Issues

No issues.

Other completed criteria

  • Events represent real user actions mapping to actual product flows
  • Events enable product insights — can build signup funnel, retention by registration method, social engagement metrics
  • Events include relevant contextual properties (remember_me, registration_method, has_detected_language, result_count, message_length, source/destination language)
  • No PII in event properties — email and username set only via posthog_client.set() on person profile
  • Event names are descriptive, consistent snake_case convention

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