Skip to content

[CI] (0ae2102) django/django3-saas - #1213

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

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

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 0ae2102
App: django/django3-saas
App directory: apps/django/django3-saas
Workbench branch: wizard-ci-0ae2102-django-django3-saas
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-04-15T19:03:52.320Z
Duration: 316.4s

@wizard-ci-bot

wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown
Author

Now I have enough context. Let me produce the evaluation.


PR Evaluation Report

Summary

This PR integrates PostHog into a Django 3 SaaS application. It initializes the PostHog SDK in AppConfig.ready(), adds the Django context middleware, and captures 12 meaningful events across accounts, billing, and dashboard views. The .env.example file was NOT updated with the new PostHog variables (only .env was, which is not committed).

Files changed Lines added Lines removed
7 +166 -1

Confidence score: 4/5 👍

  • Module-level API init instead of instance-based Posthog() constructor: The SDK is initialized via posthog.api_key / posthog.host module-level config in apps.py instead of using the recommended Posthog() class constructor. The framework rules state: "Always use the Posthog() class constructor (instance-based API) instead of module-level posthog.api_key config." However, the Django docs do show the module-level pattern, making this borderline. The instance-based API is preferred for enable_exception_autocapture support. [MEDIUM]
  • Missing enable_exception_autocapture=True: The framework rules require including enable_exception_autocapture=True in the constructor. Since module-level init is used, autocapture is not enabled. Manual capture_exception() calls exist for Stripe errors, but unhandled exceptions in non-billing views won't be tracked. [MEDIUM]
  • .env.example not updated: The .env.example file lacks POSTHOG_PROJECT_TOKEN and POSTHOG_HOST entries. The .env file was modified but is not committed. Other developers cloning the repo won't know about the required PostHog env vars. [MEDIUM]

File changes

Filename Score Description
accounts/apps.py 3/5 New file. Initializes PostHog in AppConfig.ready() using module-level API. Missing instance-based Posthog() constructor and enable_exception_autocapture.
accounts/views.py 4/5 Adds PostHog events for login, logout, registration, and profile settings update with proper context API usage.
billing/views.py 5/5 Comprehensive PostHog integration with subscription lifecycle events, exception capture on Stripe errors, and enriched properties.
config/settings.py 5/5 Adds PostHog config from env vars, registers AccountsConfig, adds PosthogContextMiddleware.
dashboard/views.py 4/5 Adds events for project CRUD operations with properties. project_deleted lacks properties.
posthog-setup-report.md 4/5 Useful setup report documenting events and next steps.
requirements.txt 5/5 Adds posthog dependency.

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes All syntax is valid, imports resolve, no breaking changes
Preserves existing env vars & configs Yes All existing settings preserved; only PostHog additions made
No syntax or type errors Yes All Python code is syntactically valid
Correct imports/exports Yes All imports (posthog, new_context, identify_context, capture, tag) are valid module-level imports from the PostHog Python SDK
Minimal, focused changes Yes Only PostHog-related additions; no unrelated refactors
Pre-existing issues None No pre-existing issues detected

Issues

  • .env.example not updated: The .env.example file does not include POSTHOG_PROJECT_TOKEN or POSTHOG_HOST. The .env file was updated but is not committed in the PR. Developers cloning the repo won't discover the required env vars. Add them to .env.example. [MEDIUM]

Other completed criteria

  • App config correctly registered as accounts.apps.AccountsConfig in INSTALLED_APPS
  • PosthogContextMiddleware correctly placed at end of middleware list
  • posthog added to requirements.txt
  • Build configuration remains valid

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog added to requirements.txt
PostHog client initialized Yes Initialized in AppConfig.ready() using module-level posthog.api_key and posthog.host. However, uses module-level config instead of recommended Posthog() constructor.
capture() Yes 12 meaningful capture() calls across accounts, billing, and dashboard views
identify() N/A Server-only Django app
Error tracking No posthog.capture_exception(e) is used for Stripe errors, but enable_exception_autocapture=True is not set (impossible with module-level init). The Django middleware handles exception capture by default, but the SDK-level autocapture is missing. The capture_exception() calls in billing also don't pass distinct_id, relying on context — but they are called outside a new_context() block.
Reverse proxy N/A Server-only Django app

Issues

  • Module-level init instead of Posthog() constructor: apps.py uses posthog.api_key and posthog.host module-level assignments. The framework rules require the Posthog() class constructor, which also enables enable_exception_autocapture=True. The Django docs show the module-level pattern, but the Python SDK rules explicitly prefer instance-based init. [MEDIUM]
  • Missing enable_exception_autocapture=True: Exception autocapture is not enabled because the module-level init pattern doesn't support this parameter. The middleware does capture exceptions by default, but uncaught exceptions outside request contexts won't be tracked. [MEDIUM]
  • capture_exception() outside context in billing: In billing/views.py, posthog.capture_exception(e) is called outside a new_context() block (in the except clause), meaning there's no identify_context set for these exception events. They won't be associated with the user. Should be inside the context block or a new context should wrap the try/except. [LOW]

Other completed criteria

  • API key loaded from environment variable via settings.POSTHOG_PROJECT_TOKEN
  • Host correctly configured via settings.POSTHOG_HOST with default https://us.i.posthog.com
  • PosthogContextMiddleware added to middleware for automatic session/distinct ID extraction
  • Context API (new_context(), identify_context()) used correctly throughout
  • identify_context(str(user.id)) uses real user IDs from Django auth

PostHog insights and events ✅

Filename PostHog events Description
accounts/views.py user_logged_in, user_logged_out, user_registered, profile_settings_updated Auth lifecycle events with login/registration method properties
billing/views.py subscription_started, plan_changed, subscription_canceled, checkout_completed, payment_failed, capturedException Full subscription lifecycle with plan properties; exception capture on Stripe errors
dashboard/views.py project_created, project_updated, project_deleted Core product CRUD events with project properties

Issues

  • project_deleted missing properties: The project_deleted event is captured without any properties (no project_id). Other project events include project_id and is_active. [LOW]
  • PII in context tags: tag('username', user.username) in accounts/views.py adds the username to all events in that context. While tag() sets context properties (not direct event properties), these still propagate to event data. This is borderline — usernames are semi-PII. [LOW]

Other completed criteria

  • Events represent real user actions mapping to actual product flows (auth, billing, project management)
  • Events enable product insights: registration → subscription funnel, churn tracking, plan change breakdown
  • Events include relevant contextual properties (plan_name, plan_slug, plan_interval, via_stripe, login_method, project_id)
  • Event names use consistent snake_case convention with descriptive [noun]_[verb] format
  • No direct PII (emails, names, phones) in capture() event properties

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