Skip to content

[CI] (624abe2) laravel/laravel12-saas - #4463

Closed
wizard-ci-bot[bot] wants to merge 2 commits into
mainfrom
wizard-ci-624abe2-laravel-laravel12-saas
Closed

wizard-ci-bot[bot] wants to merge 2 commits into
mainfrom
wizard-ci-624abe2-laravel-laravel12-saas

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 624abe2
App: laravel/laravel12-saas
App directory: apps/laravel/laravel12-saas
Workbench branch: wizard-ci-624abe2-laravel-laravel12-saas
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-10-08T09:18:07.873Z
Duration: 518.4s

YARA Scanner

✓ 250 tool calls scanned, 0 violations detected

No violations: ✓ 250 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown
Author

PR Evaluation Report

Summary

This PR integrates PostHog into a Laravel 12 SaaS application by adding a dedicated PostHogService class, request context middleware, error tracking, and event capture across authentication, subscription, and profile flows. The implementation is comprehensive but has a significant structural issue: the PostHogRequestContext middleware class is crammed into EnsureUserIsSubscribed.php instead of its own file, requiring a require_once hack to work around PSR-4 autoloading.

Files changed Lines added Lines removed
18 +272 -17

Confidence score: 5/5 🧙

  • PostHogRequestContext class placed in wrong file: The PostHogRequestContext middleware is defined inside EnsureUserIsSubscribed.php instead of its own file. Since Laravel uses PSR-4 autoloading (class name → file name), App\Http\Middleware\PostHogRequestContext would not autoload from EnsureUserIsSubscribed.php. A require_once was added to bootstrap/app.php to work around this — a fragile hack that bypasses Composer autoloading. [CRITICAL]
  • Request context middleware omits request properties: The withRequestContext method doesn't attach , , , , or `` to the context properties, unlike the documented Laravel middleware pattern. These enrichments help correlate server-side events with session context. [MEDIUM]

File changes

Filename Score Description
app/Services/PostHogService.php 4/5 New dedicated service class wrapping PostHog SDK with capture, identify, captureException, and request context methods. Clean implementation with disabled/unconfigured guards.
app/Http/Middleware/EnsureUserIsSubscribed.php 1/5 PostHogRequestContext class incorrectly added to this file — should be its own file per PSR-4 conventions.
bootstrap/app.php 2/5 Registers middleware and exception reporting correctly, but includes a require_once hack to load the misplaced middleware class.
config/posthog.php 5/5 Clean config file with env-backed values for api_key, host, disabled, and debug.
.env.example 5/5 PostHog environment variables properly documented with placeholder values.
composer.json 5/5 posthog/posthog-php added as dependency.
app/Providers/AppServiceProvider.php 5/5 Registers PostHogService as a singleton.
app/Models/User.php 5/5 Adds getPostHogPersonProperties() helper — clean pattern for person properties.
Blade/Controller files (10 files) 4/5 Consistent PostHog capture/identify calls across auth, subscription, and profile flows.
routes/auth.php 4/5 Refactors logout route to use Logout action class, ensuring PostHog tracking fires on logout.

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes App would function due to require_once workaround, though the autoloading approach is fragile.
Preserves existing env vars & configs Yes All existing configs preserved; PostHog additions are additive.
No syntax or type errors Yes All PHP syntax is valid.
Correct imports/exports Yes All use statements reference correct classes and packages.
Minimal, focused changes Yes All changes are PostHog-related. The logout route refactor is justified to centralize tracking.
Pre-existing issues None No pre-existing issues observed in the modified files.

Issues

  • Two classes in one file violates PSR-4: PostHogRequestContext is defined inside EnsureUserIsSubscribed.php. Composer's PSR-4 autoloader maps App\Http\Middleware\PostHogRequestContext to PostHogRequestContext.php, which doesn't exist. The require_once __DIR__.'/../app/Http/Middleware/EnsureUserIsSubscribed.php' in bootstrap/app.php is a workaround but bypasses the standard autoloading mechanism and is fragile. Move PostHogRequestContext to its own file at app/Http/Middleware/PostHogRequestContext.php. [CRITICAL]

Other completed criteria

  • Environment variables documented in .env.example with POSTHOG_PROJECT_TOKEN, POSTHOG_HOST, and POSTHOG_DISABLED
  • Build configuration valid — composer.json has correct package name and version constraint
  • Config file config/posthog.php uses env() helpers correctly

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog/posthog-php: ^4.12.1 added to composer.json.
PostHog client initialized Yes PostHog::init() called in PostHogService constructor with api_key, host, debug, and error_tracking config. Singleton registration ensures one-time init.
capture() Yes 10 distinct events captured across auth, subscription, and profile flows.
identify() N/A Server-only app.
Error tracking Yes Automatic error tracking enabled via error_tracking.enabled => true in init config, plus explicit captureException() in Laravel's exception handler in bootstrap/app.php.
Reverse proxy N/A Server-only app.

Issues

  • Request context middleware omits standard request properties: The documented Laravel middleware pattern includes , , , , and `` in the context properties. The withRequestContext() method only extracts headers via `contextFromHeaders()` and sets `distinctId` from the authenticated user — the request enrichment properties are missing. This means server-side events won't have URL/method context unless manually added per capture call. [MEDIUM]

Other completed criteria

  • API key loaded from environment via config('posthog.api_key') → env('POSTHOG_PROJECT_TOKEN')
  • Host configured via config('posthog.host') → env('POSTHOG_HOST')
  • Graceful degradation when PostHog is disabled or unconfigured
  • Error tracking context_provider returns authenticated user's distinct ID
  • PostHogService registered as singleton to prevent multiple PostHog::init() calls

PostHog insights and events ✅

Filename PostHog events Description
login.blade.php user_logged_in Captures password login with login_method property; identifies user with person properties.
register.blade.php user_registered Captures registration with signup_method property; identifies user.
SocialiteController.php user_logged_in Captures social login with provider as login_method; identifies user.
VerifyEmailController.php email_verified Captures email verification event.
SubscriptionController.php subscription_checkout_started, subscription_plan_changed, billing_portal_opened Subscription events with plan_id and plan_amount properties.
Logout.php user_logged_out Captures logout before session invalidation.
delete-user-form.blade.php account_deleted Captures account deletion before user is removed.
update-password-form.blade.php password_updated Captures password change.
update-profile-information-form.blade.php profile_updated Captures profile update with email_changed boolean; re-identifies user.
bootstrap/app.php captureException Captures all Laravel-reported exceptions with authenticated user context.

Issues

No event quality issues found.

Other completed criteria

  • Events represent real user actions across authentication, subscription, and profile management flows
  • Events enable product insights — login → subscribe → plan change funnels are possible
  • Events include relevant properties (login_method, signup_method, plan_id, plan_amount, email_changed)
  • No PII in event properties — email and name only passed through identify() as person properties
  • Event names follow consistent snake_case naming convention with descriptive [object]_[verb] pattern

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