Skip to content

[CI] (a5131dd) next-js/15-app-router-saas - #2475

Closed
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-a5131dd-next-js-15-app-router-saas
Closed

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-a5131dd-next-js-15-app-router-saas

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: a5131dd
App: next-js/15-app-router-saas
App directory: apps/next-js/15-app-router-saas
Workbench branch: wizard-ci-a5131dd-next-js-15-app-router-saas
Wizard branch: fix/warlock-smoke-test-remove-killswitch
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-07-07T21:48:04.347Z
Duration: 689.9s

YARA Scanner

✓ 63 tool calls scanned, 0 violations detected

No violations: ✓ 63 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown
Author

PR Evaluation Report

Summary

This PR integrates PostHog into a Next.js 15 App Router SaaS application with comprehensive client-side and server-side tracking. Client-side initialization uses instrumentation-client.ts (the recommended Next.js 15.3+ pattern), a reverse proxy is configured via Next.js rewrites, and a server-side singleton client captures events across auth flows, Stripe checkout, subscription webhooks, and team management actions.

Files changed Lines added Lines removed
11 +423 -145

Confidence score: 4/5 👍

  • .env.example not updated with NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN and NEXT_PUBLIC_POSTHOG_HOST — collaborators won't know which env vars to set [MEDIUM]
  • Massive quote-style reformatting (single → double quotes) throughout actions.ts adds ~200 lines of noise unrelated to PostHog [MEDIUM]

File changes

Filename Score Description
instrumentation-client.ts 5/5 Client-side PostHog init with reverse proxy host, error tracking, debug mode
lib/posthog-server.ts 5/5 Server-side singleton client with flushAt: 1, flushInterval: 0 for immediate flushing
next.config.ts 5/5 Reverse proxy rewrites correctly routing /ingest/static/* and /ingest/array/* to assets origin
package.json 5/5 Both posthog-js and posthog-node added
app/(dashboard)/layout.tsx 5/5 Client-side identify() with user.id and reset() on sign-out
app/(login)/actions.ts 3/5 Comprehensive server-side events but polluted with ~150 lines of unnecessary quote reformatting
app/api/stripe/checkout/route.ts 4/5 Checkout completion event with plan/subscription properties; some quote reformatting noise
app/api/stripe/webhook/route.ts 5/5 Subscription change events tied to team owner's distinct ID
lib/payments/actions.ts 5/5 Checkout initiated event with price/plan context
.env.example N/A Not modified — missing PostHog env vars
posthog-setup-report.md 2/5 Wizard report file; not part of integration code

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes No syntax errors; all imports resolve to existing modules
Preserves existing env vars & configs Yes Existing configs untouched except adding rewrites and skipTrailingSlashRedirect
No syntax or type errors Yes Valid TypeScript throughout
Correct imports/exports Yes posthog-js imported client-side, posthog-node server-side; getTeamByStripeCustomerId exists in queries
Minimal, focused changes No Gratuitous single-to-double quote reformatting across actions.ts and other files
Pre-existing issues None Base app is clean

Issues

  • Env vars not documented: .env.example is missing NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN and NEXT_PUBLIC_POSTHOG_HOST. New developers or CI pipelines won't know these are required. Add them to .env.example. [MEDIUM]
  • Quote style reformatting: actions.ts and other files have hundreds of lines changed from single to double quotes. This obscures the actual PostHog changes and makes code review harder. [MEDIUM]

Other completed criteria

  • Build configuration is valid — package.json properly lists both PostHog dependencies
  • .gitignore correctly excludes .env.local

PostHog implementation ✅

Criteria Result Description
PostHog SDKs installed Yes posthog-js@^1.398.2 and posthog-node@^5.40.0 in package.json
PostHog client initialized Yes Client via instrumentation-client.ts with posthog.init(); server via singleton in lib/posthog-server.ts with flushAt: 1, flushInterval: 0
capture() Yes 12 distinct server-side events plus client-side autocapture
identify() Yes Client-side posthog.identify(String(user.id), {email, name, role}) in dashboard layout; server-side posthog.identify() on sign-in/sign-up; posthog.reset() on sign-out
Error tracking Yes capture_exceptions: true in client init config
Reverse proxy Yes Next.js rewrites in next.config.ts: /ingest/static/* and /ingest/array/* → us-assets.i.posthog.com, /ingest/* → us.i.posthog.com

Issues

  • Older defaults date: instrumentation-client.ts uses defaults: "2026-01-30" while current docs recommend "2026-05-30". This means slightly older default configuration. [LOW]

Other completed criteria

  • API key loaded from NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN environment variable (not hardcoded)
  • Host correctly configured — client uses /ingest reverse proxy, server uses NEXT_PUBLIC_POSTHOG_HOST env var
  • ui_host correctly set to https://us.posthog.com when using reverse proxy (needed for toolbar/surveys)
  • skipTrailingSlashRedirect: true added for reverse proxy compatibility
  • Server-side client uses singleton pattern appropriate for Next.js App Router
  • posthog.reset() called on logout in client-side code

PostHog insights and events ✅

Filename PostHog events Description
app/(dashboard)/layout.tsx identify, reset Identifies authenticated user on dashboard load with user.id, resets on sign-out
app/(login)/actions.ts user_signed_in, user_signed_up, user_signed_out, invitation_accepted, password_updated, account_updated, account_deleted, team_member_removed, team_member_invited Full auth and team management lifecycle tracked server-side with team context
app/api/stripe/checkout/route.ts checkout_completed Captures plan name, subscription ID, and team ID on successful checkout
app/api/stripe/webhook/route.ts subscription_updated Tracks subscription status changes from Stripe webhooks with subscription details
lib/payments/actions.ts checkout_initiated Captures when user starts checkout with price ID and current plan
instrumentation-client.ts captureException (automatic) Error tracking via capture_exceptions: true

Issues

None — events are well-structured and cover the complete user lifecycle.

Other completed criteria

  • Events represent real user actions (signup, login, checkout, subscription changes, team management)
  • Events enable product insights — signup → checkout → subscription funnel is fully instrumented
  • All events include enriched properties (team_id, plan_name, role, subscription_status, etc.)
  • No PII in capture properties — email/name only set via identify() person properties
  • Event names follow consistent snake_case convention and are descriptive of the action

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