Skip to content

[CI] (4c70a79) django/django3-saas - #3855

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

[CI] (4c70a79) django/django3-saas#3855
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-4c70a79-django-django3-saas

Conversation

@wizard-ci-bot

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

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 4c70a79
App: django/django3-saas
App directory: apps/django/django3-saas
Workbench branch: wizard-ci-4c70a79-django-django3-saas
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-09-09T22:13:51.245Z
Duration: 450.1s

YARA Scanner

✓ 158 tool calls scanned, 0 violations detected

No violations: ✓ 158 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown
Author

PR Evaluation Report

Summary

This PR integrates PostHog into a Django 3 SaaS application by adding the Python SDK, initializing it in AccountsConfig.ready(), adding the PosthogContextMiddleware, wiring the user_logged_in signal for identification, and instrumenting account, billing, and dashboard views with meaningful capture calls.

Files changed Lines added Lines removed
7 +151 -1

Confidence score: 5/5 🧙

  • No critical or medium issues identified. This is a thorough, well-structured integration that follows Django and PostHog SDK best practices.

File changes

Filename Score Description
accounts/apps.py 5/5 New file: initializes Posthog() instance in ready(), registers atexit shutdown, connects user_logged_in signal for identify_context() and set() person properties
accounts/views.py 5/5 Adds capture calls for login, logout, registration, and settings update
billing/views.py 5/5 Adds capture calls for checkout, subscription activation, plan changes, cancellation, and payment failures; webhook handlers correctly use explicit distinct_id
dashboard/views.py 5/5 Adds capture calls for project CRUD operations
config/settings.py 5/5 Adds PosthogContextMiddleware after AuthenticationMiddleware, adds POSTHOG_PROJECT_TOKEN and POSTHOG_HOST settings from env, updates INSTALLED_APPS to use explicit AccountsConfig
requirements.txt 5/5 Adds posthog dependency
.env.example 5/5 Documents POSTHOG_PROJECT_TOKEN and POSTHOG_HOST env vars

App sanity check ✅

Criteria Result Description
App builds and runs Yes No syntax errors, all imports resolve, valid Django configuration
Preserves existing env vars & configs Yes All existing settings, middleware, and INSTALLED_APPS entries preserved; only PostHog additions
No syntax or type errors Yes Clean Python syntax throughout all changed files
Correct imports/exports Yes from posthog import Posthog, identify_context, from .apps import posthog_client, from accounts.apps import posthog_client all valid
Minimal, focused changes Yes Every change directly serves the PostHog integration
Pre-existing issues None

Issues

No issues found.

Other completed criteria

  • Environment variables documented in .env.example with POSTHOG_PROJECT_TOKEN and POSTHOG_HOST
  • Build configuration valid — posthog added to requirements.txt without version pinning (acceptable)
  • Settings correctly loaded from os.environ.get() with no defaults (correctly None when unconfigured)

PostHog implementation ✅

Criteria Result Description
PostHog SDKs installed Yes posthog added to requirements.txt
PostHog client initialized Yes Posthog() constructor in AccountsConfig.ready() with enable_exception_autocapture=True; atexit.register(posthog_client.shutdown) ensures flush on exit
capture() Yes 13 meaningful capture calls across accounts, billing, and dashboard views
identify() N/A Server-only app; uses identify_context() via user_logged_in signal (correct Django pattern)
Error tracking Yes enable_exception_autocapture=True in constructor + PosthogContextMiddleware captures Django view exceptions
Reverse proxy N/A Server-only app

Issues

No issues found.

Other completed criteria

  • API key loaded from settings.POSTHOG_PROJECT_TOKENos.environ.get('POSTHOG_PROJECT_TOKEN'), never hardcoded
  • Host loaded from settings.POSTHOG_HOSTos.environ.get('POSTHOG_HOST'), never hardcoded
  • PosthogContextMiddleware correctly placed after AuthenticationMiddleware in MIDDLEWARE
  • user_logged_in signal correctly calls identify_context(str(user.pk)) to fix context on login requests where the middleware sees an anonymous user
  • Person properties (email, username, name) set via posthog_client.set() — the correct person-property method, not in event properties
  • Webhook handlers (_handle_checkout_completed, _handle_payment_failed) correctly pass explicit distinct_id=str(user.pk) since Stripe webhooks are unauthenticated
  • Null-safe if posthog_client: guards prevent crashes when PostHog is not configured
  • Debug-mode validation raises RuntimeError if env vars are missing, preventing silent event loss during development

PostHog insights and events ✅

Filename PostHog events Description
accounts/apps.py identify_context, set() Identifies user context on login via user_logged_in signal; sets person properties (email, username, name)
accounts/views.py user_logged_in, user_logged_out, user_registered, account_settings_updated Core authentication lifecycle and profile management events
billing/views.py checkout_started, subscription_activated, subscription_plan_changed, subscription_canceled, subscription_payment_failed Complete billing funnel from checkout through cancellation and payment failures
dashboard/views.py project_created, project_updated, project_deleted Project CRUD operations with description metadata

Issues

No issues found.

Other completed criteria

  • Events represent real user actions mapping to actual SaaS product flows (registration → login → checkout → subscribe → manage → cancel)
  • Events enable product insights: clear funnel from user_registeredcheckout_startedsubscription_activated; retention via project_created/project_updated; churn via subscription_canceled
  • Events enriched with contextual properties: plan_slug, billing_interval, checkout_provider, activation_source, change_source, cancellation_source, has_company_name, has_description, login_method
  • No PII in event properties — all properties are metadata (slugs, booleans, source identifiers)
  • Event names follow consistent snake_case [noun]_[verb_past] convention: descriptive and meaningful

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