Skip to content

[CI] (3f39e0e) django/django3-saas - #4153

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

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

Conversation

@wizard-ci-bot

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

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 3f39e0e
App: django/django3-saas
App directory: apps/django/django3-saas
Workbench branch: wizard-ci-3f39e0e-django-django3-saas
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-09-23T21:53:36.028Z
Duration: 498.2s

YARA Scanner

✓ 164 tool calls scanned, 0 violations detected

No violations: ✓ 164 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown
Author

Now I have all the context I need. Let me produce the evaluation.


PR Evaluation Report

Summary

This PR integrates PostHog into a Django SaaS application by adding the Python SDK, initializing it via AppConfig.ready(), adding the PosthogContextMiddleware, capturing events across accounts/billing/dashboard views, and wiring up user identification via the user_logged_in signal. It also adds an OpenTelemetry-based log exporter, which is scope creep beyond the core PostHog integration.

Files changed Lines added Lines removed
8 +195 -0

Confidence score: 3/5 🤔

  • RuntimeError crashes app in DEBUG mode: The settings.py check raises RuntimeError at import time if POSTHOG_PROJECT_TOKEN or POSTHOG_HOST are not set while DEBUG=True. This breaks any existing developer environment that doesn't have PostHog env vars configured. Should be a warning log, not a crash. [CRITICAL]
  • OTel log exporter is scope creep: The PR adds opentelemetry-sdk and opentelemetry-exporter-otlp-proto-http as dependencies plus ~30 lines of OTel log export configuration. This is beyond a basic PostHog integration and adds unnecessary complexity and dependency surface. [MEDIUM]
  • Events in webhook handlers lack context middleware coverage: _handle_checkout_completed and _handle_payment_failed are called from the Stripe webhook handler. These correctly pass explicit distinct_id, but they run outside authenticated user context — this is handled properly. [LOW]

File changes

Filename Score Description
config/apps.py 3/5 New file. Initializes PostHog with Posthog() constructor, enable_exception_autocapture=True, atexit shutdown — all correct. But also adds unnecessary OTel log exporter setup.
config/settings.py 2/5 Adds env var loading and middleware — correct. But the RuntimeError in DEBUG mode breaks existing setups.
.env.example 5/5 Properly documents POSTHOG_PROJECT_TOKEN and POSTHOG_HOST
accounts/models.py 5/5 Correctly uses user_logged_in signal with identify_context() and posthog.set() for person properties
accounts/views.py 4/5 Good event captures for login, logout, registration, settings update with relevant properties
billing/views.py 5/5 Comprehensive billing event tracking with plan metadata properties
dashboard/views.py 4/5 Good CRUD events for projects; includes OTel logger usage which is scope creep
requirements.txt 3/5 Adds posthog (correct), but also opentelemetry-sdk and opentelemetry-exporter-otlp-proto-http (unnecessary)

App sanity check ⚠️

Criteria Result Description
App builds and runs No RuntimeError in settings.py crashes the app in DEBUG mode if PostHog env vars are missing
Preserves existing env vars & configs No Existing dev environments without PostHog env vars will crash on startup
No syntax or type errors Yes All syntax is valid
Correct imports/exports Yes All imports are correct — posthog, identify_context, Posthog from correct packages
Minimal, focused changes No OTel log exporter adds 2 dependencies and ~30 lines beyond core PostHog integration
Pre-existing issues None —

Issues

  • RuntimeError breaks existing dev setups: settings.py raises RuntimeError during module load if POSTHOG_PROJECT_TOKEN or POSTHOG_HOST are empty and DEBUG=True. This crashes the app before it can start. Replace with logging.warning() or remove the check — the AppConfig.ready() already has a guard clause that skips initialization when tokens are missing. [CRITICAL]
  • OTel log exporter is unnecessary scope creep: The _configure_posthog_log_capture method, OTel dependencies, and posthog_logger usage in dashboard/views.py go beyond the core PostHog SDK integration. This adds two heavy dependencies (opentelemetry-sdk, opentelemetry-exporter-otlp-proto-http) that are not needed for analytics, error tracking, or event capture. [MEDIUM]

Other completed criteria

  • Environment variables documented in .env.example
  • Build configuration (requirements.txt) is parseable

PostHog implementation ✅

Criteria Result Description
PostHog SDKs installed Yes posthog added to requirements.txt
PostHog client initialized Yes Posthog() constructor in ConfigConfig.ready() with enable_exception_autocapture=True, set as posthog.default_client, with atexit.register(posthog_client.shutdown)
capture() Yes 13 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

No PostHog implementation issues.

Other completed criteria

  • API key loaded from os.environ.get('POSTHOG_PROJECT_TOKEN') — not hardcoded
  • Host loaded from os.environ.get('POSTHOG_HOST') — correctly configured
  • PosthogContextMiddleware placed after AuthenticationMiddleware — correct ordering per docs
  • user_logged_in signal correctly calls identify_context(str(user.pk)) to fix login request context per Django docs
  • posthog.set() correctly used for person properties (Python SDK's equivalent of identify)
  • atexit.register(posthog_client.shutdown) ensures events flush on exit

PostHog insights and events ✅

Filename PostHog events Description
accounts/views.py user_logged_in, user_logged_out, user_registered, account_settings_updated Auth lifecycle and profile management events
accounts/models.py Person properties via posthog.set() Sets email, username, name, company on login signal
billing/views.py subscription_checkout_started, subscription_started, subscription_plan_changed, subscription_canceled, subscription_activated, subscription_payment_failed Full billing funnel coverage with plan metadata
dashboard/views.py project_created, project_updated, project_deleted CRUD events for core project entity

Issues

No event quality issues.

Other completed criteria

  • Events represent real user actions (registration, login, subscription, project CRUD)
  • Events enable product insights — full signup → subscribe → use funnel possible
  • Events include relevant properties (plan_slug, plan_interval, billing_mode, has_company_name, updated_fields, is_active)
  • No PII in capture() properties — email/name only set via posthog.set() (person property method)
  • Event names are descriptive, consistent snake_case 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