Repository navigation
[CI] (0e81558) django/django3-saas - #4238
Closed
wizard-ci-bot[bot] wants to merge 1 commit into
Closed
wizard-ci-bot[bot] wants to merge 1 commit into
wizard-ci-bot[bot] wants to merge 1 commit into
Conversation
Author
PR Evaluation ReportSummaryThis PR integrates PostHog into a Django 3 SaaS application by adding the Python SDK with instance-based initialization in
Confidence score: 4/5 👍
File changes
App sanity check
|
| Criteria | Result | Description |
|---|---|---|
| App builds and runs | Yes | All imports resolve; OTEL packages are real and installable |
| Preserves existing env vars & configs | Yes | No existing settings removed; PostHog additions are additive |
| No syntax or type errors | Yes | All files are syntactically valid Python |
| Correct imports/exports | Yes | from config.apps import get_posthog_client resolves; from posthog import Posthog is correct |
| Minimal, focused changes | No | OTEL logging exporter adds 3 heavy dependencies and ~30 lines of setup + per-view boilerplate unrelated to PostHog analytics |
| Pre-existing issues | None | Base app is clean |
Issues
- OTEL logging adds unnecessary dependencies and complexity: The
opentelemetry-exporter-otlppackage pulls in gRPC and protobuf. The log exporter imports from private modules (opentelemetry._logs,opentelemetry.sdk._logs). This is not part of a standard PostHog integration and adds significant surface area for breakage. Remove the OTEL setup andget_posthog_log_logger()calls. [MEDIUM] ImproperlyConfiguredraised in DEBUG mode: WhenPOSTHOG_PROJECT_API_KEYorPOSTHOG_HOSTis missing andDEBUG=True, the app refuses to start. This is overly aggressive for an analytics integration — a warning log would be more appropriate than crashing the app. [LOW]
Other completed criteria
- App builds without errors — all dependencies are valid packages
- Existing env vars and configurations preserved unchanged
- No syntax errors in any changed file
- All import statements resolve correctly
- Environment variables documented in
.env.example requirements.txtis parseable and valid
PostHog implementation ⚠️
| Criteria | Result | Description |
|---|---|---|
| PostHog SDKs installed | Yes | posthog added to requirements.txt |
| PostHog client initialized | Yes | Posthog() constructor in AppConfig.ready() with enable_exception_autocapture=True and atexit.register(posthog_client.shutdown) |
| capture() | Yes | 12+ meaningful capture calls across accounts, billing, and dashboard views |
| identify() | N/A | Server-only app |
| Error tracking | Yes | enable_exception_autocapture=True set on client; middleware added (though middleware may not function — see issues) |
| Reverse proxy | N/A | Server-only app |
Issues
- Middleware likely non-functional due to client mismatch:
PosthogContextMiddlewareuses the module-levelposthogclient (viaposthog.setup()), but the PR only configures an instance-basedPosthog()client and never setsposthog.api_keyorposthog.host. The middleware's context creation, exception capture, automatic distinct-ID extraction fromrequest.user.pk, session/IP/user-agent tagging, and header-based identification all depend on the module-level client being configured. With a disabled module-level client, the middleware becomes a no-op — capture calls still fire via the instance but without proper context attribution. Fix: either setposthog.api_keyandposthog.hostat the module level (the Django docs pattern), or ensure thePosthog()instance is registered as the default client that the middleware can use. [CRITICAL] - Repetitive get_posthog_client() / null-check pattern: Every view repeats
posthog_client = get_posthog_client(); if posthog_client: .... This creates unnecessary coupling and boilerplate. The Django SDK rules state: "Do NOT create custom middleware, distinct_id helpers, or conditional checks — the SDK handles these." If the middleware and module-level API were used correctly, a bareposthog.capture()would suffice. [MEDIUM] user_logged_insignal handler correctly used: Theidentify_logged_in_usersignal handler callsidentify_context()andset()with person properties — this is the correct Django pattern for login attribution per the docs. [POSITIVE]
Other completed criteria
- API key loaded from
os.environ.get('POSTHOG_PROJECT_API_KEY')— not hardcoded - Host loaded from
os.environ.get('POSTHOG_HOST')— correctly configured atexit.register(posthog_client.shutdown)ensures events flush on exitenable_exception_autocapture=Trueenables automatic exception tracking- Person properties (
email,name,company_name) correctly placed inset(), not incapture()properties - Middleware placed after
AuthenticationMiddlewareas required
PostHog insights and events ✅
| Filename | PostHog events | Description |
|---|---|---|
accounts/views.py |
user_logged_in, user_logged_out, user_registered, account_settings_updated |
Auth lifecycle events; login includes login_method property |
billing/views.py |
checkout_started, subscription_started, subscription_plan_changed, subscription_canceled |
Full billing funnel with plan_slug and billing_provider properties |
dashboard/views.py |
project_created, project_updated, project_deleted |
Project CRUD events with has_description property |
config/apps.py |
Person properties via set() |
Sets email, name, username, company_name, is_staff on person profile at login |
Issues
No event quality issues found.
Other completed criteria
- Events represent real user actions mapping to actual product flows (registration → subscription → project creation)
- Events enable product insights — can build registration-to-subscription funnel, track plan changes and cancellations
- Events include relevant contextual properties (
plan_slug,billing_provider,has_description,login_method) - No PII in capture properties — email/name only in
set()person properties - Event names are descriptive, consistent snake_case convention (
user_logged_in,subscription_started,project_created)
Reviewed by wizard workbench PR evaluator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated wizard CI run
Source: wizard-pr
Trigger ID:
0e81558App:
django/django3-saasApp directory:
apps/django/django3-saasWorkbench branch:
wizard-ci-0e81558-django-django3-saasWizard branch:
release-please--branches--main--components--wizardContext Mill branch:
mainPostHog (MCP) branch:
masterTimestamp: 2026-09-29T08:20:05.504Z
Duration: 387.9s
YARA Scanner