Skip to content

[CI] (f51b3be) flask/flask3-social-media - #2625

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

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

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: f51b3be
App: flask/flask3-social-media
App directory: apps/flask/flask3-social-media
Workbench branch: wizard-ci-f51b3be-flask-flask3-social-media
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-07-09T22:19:23.916Z
Duration: 251.3s

YARA Scanner

✓ 80 tool calls scanned, 0 violations detected

No violations: ✓ 80 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Author

PR Evaluation Report

Summary

This PR integrates the PostHog Python SDK into a Flask 3 social media application (Microblog). It adds the posthog package, initializes the client in the app factory with exception autocapture, instruments 16 events across authentication, social features, messaging, API, background tasks, and error handling, and adds atexit-based shutdown.

Files changed Lines added Lines removed
9 +317 -6

Confidence score: 4/5 👍

  • Duplicated helper function: capture_posthog_event is copy-pasted identically across 3 files (api/users.py, auth/routes.py, main/routes.py) instead of being defined once in a shared utility module. [MEDIUM]
  • Hardcoded distinct_id in error handler: The server_error_handled event uses distinct_id='anonymous_server_error', a fabricated hardcoded string that creates a phantom person profile aggregating all server errors. Should either use the authenticated user's ID if available, or omit the distinct_id to let the SDK generate an anonymous one. [MEDIUM]
  • No .env.example for new env vars: POSTHOG_PROJECT_TOKEN and POSTHOG_HOST are added to config.py but no .env.example file is created or updated to document them for collaborators. [MEDIUM]

File changes

Filename Score Description
app/__init__.py 5/5 Correctly initializes PostHog client in create_app() with Posthog() constructor, enable_exception_autocapture=True, and atexit.register(shutdown)
app/api/users.py 4/5 Adds api_user_created and api_user_updated events with good properties; contains duplicated helper
app/auth/routes.py 4/5 Instruments login, logout, signup, password reset flows with meaningful events; contains duplicated helper
app/errors/handlers.py 3/5 Adds capture_exception for error tracking and a server_error_handled event, but uses hardcoded distinct_id='anonymous_server_error'
app/main/routes.py 4/5 Instruments post creation, profile updates, follow/unfollow, messaging, export with good properties; contains duplicated helper
app/tasks.py 5/5 Adds posts_export_completed event and capture_exception in background task error handling
config.py 5/5 Adds env var configuration for PostHog token and host
requirements.txt 5/5 Adds posthog dependency
posthog-setup-report.md 5/5 Setup report documenting all events and next steps

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes No syntax errors; all imports resolve correctly
Preserves existing env vars & configs Yes Existing config untouched; error handler return format change is correct (api_error_response returns a tuple)
No syntax or type errors Yes All code is syntactically valid
Correct imports/exports Yes from posthog import Posthog, new_context are valid imports
Minimal, focused changes Yes All changes relate directly to PostHog integration
Pre-existing issues .env file with actual API key exists in repo (not introduced by this PR) The .env contains a real PostHog project token — pre-existing, not a PR issue

Issues

  • No .env.example file: POSTHOG_PROJECT_TOKEN and POSTHOG_HOST are added to config.py but no .env.example documents these for other developers. The setup report even lists this as a todo. [MEDIUM]

Other completed criteria

  • Build configuration is valid — posthog added correctly to requirements.txt
  • All existing functionality preserved — error handler correctly unpacks api_error_response(500) tuple

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 enable_exception_autocapture=True; stored on app.posthog_client; atexit.register(shutdown) ensures flush on exit
capture() Yes 16 meaningful capture calls across auth, social, API, tasks, and error handling
identify() N/A Server-only Flask app
Error tracking Yes enable_exception_autocapture=True in constructor + manual capture_exception() in Flask error handler and background task exception handler
Reverse proxy N/A Server-only app

Issues

  • Hardcoded distinct_id in error handler: server_error_handled event uses distinct_id='anonymous_server_error' — a fabricated string that creates a single phantom person profile. Should use current_user.id if authenticated or omit distinct_id entirely. [MEDIUM]

Other completed criteria

  • API key loaded from environment variable via os.environ.get('POSTHOG_PROJECT_TOKEN') — not hardcoded
  • Host configured from environment variable via os.environ.get('POSTHOG_HOST') — SDK defaults to US endpoint if None
  • Graceful shutdown handled via atexit.register(app.posthog_client.shutdown)

PostHog insights and events ✅

Filename PostHog events Description
app/auth/routes.py user_logged_in, user_logged_out, user_signed_up, password_reset_requested, password_reset_completed Full authentication lifecycle tracking with login method, remember_me flag, and request context
app/main/routes.py post_created, profile_updated, user_followed, user_unfollowed, message_sent, messages_viewed, posts_export_requested Social features instrumented with enriched properties (post_length, language, target_user_id, message_length, unread_message_count)
app/api/users.py api_user_created, api_user_updated API user management with boolean flags for which fields were updated
app/tasks.py posts_export_completed, capturedException Background task completion tracking and exception capture
app/errors/handlers.py server_error_handled, capturedException Flask 500 error handler with exception capture returning error_id

Issues

  • Duplicated helper function: capture_posthog_event is defined identically in api/users.py, auth/routes.py, and main/routes.py. Should be extracted to a shared utility module (e.g., app/posthog_utils.py). [MEDIUM]

Other completed criteria

  • Events represent real user actions mapping to actual product flows (signup → login → post → follow → message)
  • Events enable product insights — funnels (signup → first post), retention (follow/unfollow), engagement (messaging)
  • Events include rich contextual properties (post_length, language, target_user_id, message_length, etc.)
  • No PII in event properties — email and username are correctly set via client.set() (person-property method)
  • Event names follow consistent snake_case convention with descriptive [noun]_[verb] format

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