Skip to content

[CI] (3393d57) flask/flask3-social-media#876

Closed
wizard-ci-bot[bot] wants to merge 1 commit intomainfrom
wizard-ci-3393d57-flask-flask3-social-media
Closed

[CI] (3393d57) flask/flask3-social-media#876
wizard-ci-bot[bot] wants to merge 1 commit intomainfrom
wizard-ci-3393d57-flask-flask3-social-media

Conversation

@wizard-ci-bot
Copy link

@wizard-ci-bot wizard-ci-bot bot commented Mar 17, 2026

Automated wizard CI run

Source: wizard-pr
Trigger ID: 3393d57
App: flask/flask3-social-media
App directory: apps/flask/flask3-social-media
Workbench branch: wizard-ci-3393d57-flask-flask3-social-media
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-03-17T00:05:44.267Z
Duration: 478.7s

@wizard-ci-bot
Copy link
Author

wizard-ci-bot bot commented Mar 17, 2026

Now I have all the evidence I need. Two critical issues found:

  1. api_key= keyword argument is incorrect — The constructor parameter is project_api_key, not api_key. Since it's passed as a keyword argument (api_key=...), Python will raise a TypeError: __init__() got an unexpected keyword argument 'api_key'. This will crash the app on startup.

  2. posthog_client.set() called with positional arguments — The method signature is def set(self, **kwargs), so posthog_client.set(str(user.id), {'username': user.username}) will raise a TypeError since positional arguments are not accepted. It should be posthog_client.set(distinct_id=str(user.id), properties={'username': user.username}).

  3. No explicit capture_exception() in Flask error handlers — The Flask docs specifically say autocapture won't work and you need manual capture_exception() calls.

  4. No .env.example — The .env file exists but is gitignored; there's no .env.example for documentation.


PR Evaluation Report

Summary

This PR integrates PostHog analytics into a Flask social media microblog application. It adds the posthog Python SDK, initializes a Posthog client in the application factory, and instruments 12 events across auth, social interactions, content creation, and API endpoints. Person properties are set via posthog_client.set() for user identity.

Files changed Lines added Lines removed
8 +103 -3

Confidence score: 3/5 🤔

  • Incorrect constructor keyword argument api_key=: The Posthog() constructor's first parameter is named project_api_key, not api_key. Since the PR passes it as a keyword argument (api_key=app.config[...]), Python will raise TypeError: __init__() got an unexpected keyword argument 'api_key' at app startup. This breaks the app entirely. [CRITICAL]
  • posthog_client.set() called with positional arguments: The set() method accepts only **kwargs (keyword-only arguments), but the PR calls it as posthog_client.set(str(user.id), {'username': user.username}) with two positional args. This will raise TypeError: set() takes 1 positional argument but 3 were given at every login, registration, and API user creation. Fix: use posthog_client.set(distinct_id=str(user.id), properties={'username': user.username}). [CRITICAL]
  • No manual capture_exception() in Flask error handlers: The Flask docs explicitly state that PostHog's default exception autocapture won't work with Flask's built-in error handlers. The existing app/errors/handlers.py has @bp.app_errorhandler(500) but no posthog_client.capture_exception(error) call. enable_exception_autocapture=True alone is insufficient. [MEDIUM]
  • No .env.example file: The .env file is gitignored (correctly), but there is no .env.example to document the required POSTHOG_PROJECT_TOKEN and POSTHOG_HOST environment variables for other developers. [MEDIUM]

File changes

Filename Score Description
app/__init__.py 2/5 PostHog initialization with incorrect api_key= keyword; should be project_api_key=. atexit.register for shutdown is good.
app/auth/routes.py 3/5 Good event coverage (login, logout, signup, password reset) but set() calls use invalid positional arguments.
app/main/routes.py 4/5 Comprehensive event tracking for social actions (posts, follows, messages, exports) with enriched properties.
app/api/users.py 3/5 API user creation event captured with properties, but set() call uses invalid positional arguments.
config.py 5/5 Clean config additions loading from env vars with sensible defaults.
requirements.txt 5/5 posthog dependency added correctly.
.gitignore 5/5 .env correctly added to gitignore.
posthog-setup-report.md 4/5 Helpful setup report documenting all events and suggesting dashboards.

App sanity check ❌

Criteria Result Description
App builds and runs No Posthog(api_key=...) will crash on startup — the parameter is project_api_key
Preserves existing env vars & configs Yes All existing config values and functionality preserved
No syntax or type errors No api_key= is wrong keyword; set() positional args will raise TypeError
Correct imports/exports Yes from posthog import Posthog and from app import posthog_client are correct
Minimal, focused changes Yes All changes are PostHog-related, no scope creep
Pre-existing issues None Base app appears clean

Issues

  • Incorrect api_key keyword argument in Posthog constructor: Posthog(api_key=app.config['POSTHOG_PROJECT_TOKEN'], ...) will raise TypeError because the constructor parameter is project_api_key, not api_key. Fix: change to Posthog(project_api_key=app.config['POSTHOG_PROJECT_TOKEN'], ...) or pass it as a positional argument Posthog(app.config['POSTHOG_PROJECT_TOKEN'], ...). [CRITICAL]
  • set() called with positional arguments: All calls to posthog_client.set(str(user.id), {'username': user.username}) will fail because set() only accepts **kwargs. Fix: use posthog_client.set(distinct_id=str(user.id), properties={'username': user.username}). [CRITICAL]
  • No .env.example file: New POSTHOG_PROJECT_TOKEN and POSTHOG_HOST environment variables are not documented in a .env.example file. The .env is gitignored, so developers won't know what variables are required. [MEDIUM]

Other completed criteria

  • Environment variables loaded from config via os.environ.get() with sensible defaults
  • atexit.register(posthog_client.shutdown) ensures events are flushed on exit
  • posthog added to requirements.txt
  • .env added to .gitignore to prevent secret leakage
  • Blueprint registration happens after PostHog initialization in create_app()

PostHog implementation ❌

Criteria Result Description
PostHog SDKs installed Yes posthog added to requirements.txt
PostHog client initialized No Uses incorrect keyword api_key= instead of project_api_key=; will crash on startup. enable_exception_autocapture=True and atexit.register are correct patterns.
capture() Yes 12 meaningful events captured across auth, social, and API flows with correct distinct_id and properties
identify() N/A Server-only app
Error tracking No Flask docs require manual capture_exception() in error handlers since Flask's built-in handlers prevent autocapture from working. No capture_exception() calls in app/errors/handlers.py.
Reverse proxy N/A Server-only app

Issues

  • Incorrect constructor parameter name: api_key= is not a valid parameter for Posthog(). The correct parameter name is project_api_key. This prevents the app from starting. [CRITICAL]
  • Missing manual capture_exception() in Flask error handlers: The Flask docs explicitly state that enable_exception_autocapture=True is insufficient for Flask because Flask's built-in error handlers catch exceptions before PostHog can. The 500 error handler in app/errors/handlers.py should call posthog_client.capture_exception(error). [MEDIUM]
  • posthog_client.set() uses invalid positional argument syntax: The set() method signature is def set(self, **kwargs) — it only accepts keyword arguments. The calls posthog_client.set(str(user.id), {'username': user.username}) will raise TypeError. [CRITICAL]

Other completed criteria

  • API key loaded from environment variable via app.config['POSTHOG_PROJECT_TOKEN']
  • Host correctly configured to https://us.i.posthog.com with env var override
  • atexit.register(posthog_client.shutdown) ensures clean shutdown
  • Instance-based Posthog() constructor used (not module-level config)
  • enable_exception_autocapture=True passed (correct intent, insufficient for Flask)

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 coverage with signup_method and login_method properties
app/main/routes.py post_created, profile_edited, user_followed, user_unfollowed, message_sent, posts_export_started Comprehensive social engagement tracking with contextual properties (language, recipient/followed user IDs, message_length)
app/api/users.py api_user_created API user creation with signup_method: 'api' property

Issues

  • username set via set() with invalid syntax: Person property setting ({'username': user.username}) is a good idea but will fail at runtime due to the positional argument issue. Even if fixed, username is borderline PII — however since it's set via person properties (not event properties), this is acceptable. [CRITICAL]

Other completed criteria

  • Events represent real user actions mapping to actual product flows (signup, login, post, follow, message)
  • Events enable product insights — can build registration funnels, engagement trends, retention analysis
  • Events include relevant enriched properties (login_method, signup_method, language, followed_user_id, recipient_user_id, message_length)
  • No PII in event properties — user IDs are database IDs, not emails; username is in person properties via set(), not in capture() event properties
  • Event naming is descriptive and consistent using snake_case 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