Skip to content

[CI] (edaca63) django/django3-saas - #2878

Closed
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-edaca63-django-django3-saas
Closed

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-edaca63-django-django3-saas

Conversation

@wizard-ci-bot

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

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: edaca63
App: django/django3-saas
App directory: apps/django/django3-saas
Workbench branch: wizard-ci-edaca63-django-django3-saas
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-07-16T16:57:46.068Z
Duration: 210.0s

YARA Scanner

✓ 72 tool calls scanned, 0 violations detected

No violations: ✓ 72 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown
Author

The .env.example was NOT updated with PostHog env vars. Now let me check the settings for os.environ['POSTHOG_PROJECT_TOKEN'] — using bare os.environ[] (not .get()) means the app will crash on startup if the env var is missing.


PR Evaluation Report

Summary

This PR integrates PostHog into a Django 3 SaaS application using the Python SDK. It initializes a PostHog client in accounts/posthog.py, adds the PosthogContextMiddleware, registers atexit shutdown, and adds capture calls for user registration, login, subscription lifecycle, and project creation events. Person properties are set via posthog.set().

Files changed Lines added Lines removed
8 +133 -1

Confidence score: 4/5 👍

  • .env.example not updated: POSTHOG_PROJECT_TOKEN and POSTHOG_HOST are loaded via os.environ[] (hard crash if missing) but .env.example does not document them. [MEDIUM]
  • No context API usage in views: All capture calls use explicit distinct_id instead of the recommended new_context() + identify_context() pattern. The PosthogContextMiddleware is installed but views bypass its context entirely by passing distinct_id directly. This works but misses out on session linking and middleware tags. [MEDIUM]
  • PII in posthog.set() person properties: Email, username, and company_name are set via posthog.set() which is the correct person-property method — no issue here. However, the login view creates a new context via middleware but then calls set() and capture() outside that context pattern, which is a minor inconsistency.

File changes

Filename Score Description
accounts/posthog.py 5/5 Clean PostHog client initialization with Posthog() constructor, env-based config, and enable_exception_autocapture=True
accounts/apps.py 5/5 Registers atexit.register(posthog_client.shutdown) in AppConfig.ready()
accounts/views.py 4/5 Adds login and registration events with person properties via set(). Uses explicit distinct_id rather than context API
billing/views.py 5/5 Well-instrumented subscription lifecycle events with relevant metadata properties
dashboard/views.py 4/5 Project creation event captured with relevant properties
config/settings.py 4/5 Adds middleware correctly after auth, adds env vars. Uses os.environ[] which will crash if vars are missing
requirements.txt 5/5 posthog added to dependencies
posthog-setup-report.md 4/5 Helpful setup report documenting events and next steps

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes All imports are valid, syntax is correct, SDK is in requirements.txt
Preserves existing env vars & configs Yes Existing settings and functionality preserved; only PostHog additions
No syntax or type errors Yes All code is syntactically valid Python
Correct imports/exports Yes from posthog import Posthog, from .posthog import posthog_client, etc. are all correct
Minimal, focused changes Yes All changes relate to PostHog integration
Pre-existing issues None No pre-existing issues observed

Issues

  • .env.example not updated with PostHog vars: POSTHOG_PROJECT_TOKEN and POSTHOG_HOST are required (bare os.environ[] will crash the app if missing) but .env.example has no entries for them. Add POSTHOG_PROJECT_TOKEN= and POSTHOG_HOST=https://us.i.posthog.com to .env.example. [MEDIUM]

Other completed criteria

  • App builds without syntax errors
  • Existing functionality is preserved
  • All imports resolve correctly
  • Build configuration (requirements.txt) is valid
  • Changes are minimal and focused on PostHog

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog added to requirements.txt
PostHog client initialized Yes Posthog() constructor in accounts/posthog.py with API key and host from Django settings (env vars), enable_exception_autocapture=True
capture() Yes 6 meaningful capture calls across accounts, billing, and dashboard views
identify() N/A Server-only app
Error tracking Yes enable_exception_autocapture=True in constructor + PosthogContextMiddleware captures exceptions
Reverse proxy N/A Server-only app

Issues

  • Views bypass context API: All views use explicit distinct_id in capture() calls rather than using new_context() + identify_context(). While the PosthogContextMiddleware is correctly installed and creates contexts automatically, the views don't leverage the context pattern for their explicit captures. This means events captured directly won't benefit from middleware-injected tags (session ID, URL, etc.) unless those tags are inherited by the middleware's context. Since the middleware does wrap the request, the explicit distinct_id captures should still inherit context tags, so this is functional but not idiomatic. [MEDIUM]

Other completed criteria

  • API key loaded from environment variable via settings.POSTHOG_PROJECT_TOKEN
  • Host configured from environment variable via settings.POSTHOG_HOST
  • atexit.register(posthog_client.shutdown) ensures clean shutdown
  • PosthogContextMiddleware placed correctly after AuthenticationMiddleware
  • AccountsConfig registered in INSTALLED_APPS to trigger ready()

PostHog insights and events ✅

Filename PostHog events Description
accounts/views.py user_registered, user_logged_in Captures registration and login with person properties set via posthog.set()
billing/views.py subscription_started, subscription_plan_changed, subscription_canceled Full subscription lifecycle with plan slug, billing interval, and provider metadata
dashboard/views.py project_created Project creation with active status property

Issues

None — events are well-designed and meaningful.

Other completed criteria

  • Events represent real user actions (registration, login, subscription lifecycle, project creation)
  • Events enable product insights (can build signup→subscription funnel, retention by plan, churn analysis)
  • Events include relevant properties (plan_slug, billing_interval, billing_provider, login_method, etc.)
  • No PII in capture() event properties — email/username set via posthog.set() person properties only
  • Event names follow consistent snake_case [noun]_[verb] 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