Skip to content

[CI] (9f92c68) next-js/15-app-router-saas - #2540

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

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

Conversation

@wizard-ci-bot

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

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 9f92c68
App: next-js/15-app-router-saas
App directory: apps/next-js/15-app-router-saas
Workbench branch: wizard-ci-9f92c68-next-js-15-app-router-saas
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-07-08T17:01:33.540Z
Duration: 497.1s

YARA Scanner

✓ 64 tool calls scanned, 0 violations detected

No violations: ✓ 64 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Author

PR Evaluation Report

Summary

This PR integrates PostHog into a Next.js 15 App Router SaaS starter application. It adds client-side initialization via instrumentation-client.ts, a server-side PostHog Node client, a reverse proxy through Next.js rewrites, user identification tied to the SWR-fetched user session, and comprehensive event capture across authentication, team management, and Stripe subscription flows.

Files changed Lines added Lines removed
11 +227 -22

Confidence score: 4/5 👍

  • Webhook uses fabricated distinct_id: The Stripe webhook handler uses stripe_customer_ as the distinctId, which won't link to any real PostHog user profile, causing fragmented data. Should resolve the Stripe customer to the actual user ID via a database lookup. [MEDIUM]
  • Environment variables not documented in .env.example: NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN and NEXT_PUBLIC_POSTHOG_HOST are required but no .env.example file is created or updated. The setup report mentions them as a TODO, but they're not actually documented in a standard location. [MEDIUM]

File changes

Filename Score Description
instrumentation-client.ts 5/5 Client-side PostHog init using the recommended Next.js 15.3+ pattern with env vars, reverse proxy, error tracking, and debug mode
lib/posthog-server.ts 5/5 Server-side PostHog Node client factory with correct flushAt: 1 and flushInterval: 0 for short-lived serverless functions
next.config.ts 5/5 Reverse proxy via Next.js rewrites with correct routing for /ingest/static/*, /ingest/array/*, and /ingest/*
package.json 5/5 Both posthog-js and posthog-node added to dependencies
app/(dashboard)/layout.tsx 5/5 User identification with posthog.identify() using real user ID, plus posthog.reset() on sign-out
app/(dashboard)/pricing/submit-button.tsx 5/5 Client-side checkout_started event in click handler
app/(login)/actions.ts 4/5 Comprehensive server-side event capture for all auth and team actions with proper shutdown() calls
app/api/stripe/checkout/route.ts 5/5 Server-side checkout_completed event with enriched properties
app/api/stripe/webhook/route.ts 3/5 Subscription events captured but uses fabricated distinct_id
.gitignore 5/5 Correctly ignores .env.local
posthog-setup-report.md 5/5 Comprehensive setup report with event table and next steps

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes No syntax errors or missing dependencies; all imports resolve correctly
Preserves existing env vars & configs Yes Existing next.config.ts, package.json, and app code preserved; PostHog additions are additive
No syntax or type errors Yes TypeScript types are correct; posthog-node and posthog-js APIs used correctly
Correct imports/exports Yes posthog-js only on client ('use client' components + instrumentation-client.ts), posthog-node only on server
Minimal, focused changes Yes All changes are PostHog-related; existing logic patterns maintained
Pre-existing issues None Base app appears functional

Issues

  • Missing .env.example update: NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN and NEXT_PUBLIC_POSTHOG_HOST are required for the integration to work, but no .env.example file is created or updated. Collaborators won't know what environment variables to set. [MEDIUM]

Other completed criteria

  • Build configuration is valid — package.json has correct dependency entries and next.config.ts exports valid config
  • All file modifications follow existing codebase patterns (indentation, naming conventions, import ordering)
  • .gitignore correctly excludes .env.local to prevent secret leakage

PostHog implementation ✅

Criteria Result Description
PostHog SDKs installed Yes posthog-js (^1.398.6) and posthog-node (^5.40.0) added to package.json
PostHog client initialized Yes Client via instrumentation-client.ts (recommended Next.js 15.3+ pattern); server via getPostHogClient() factory with flushAt: 1, flushInterval: 0
capture() Yes 12 distinct events captured across client and server
identify() Yes Client-side posthog.identify(String(user.id)) in UserMenu useEffect on user load; server-side identify in sign-in/sign-up actions; posthog.reset() on logout
Error tracking Yes capture_exceptions: true in posthog.init() config enables automatic exception capture
Reverse proxy Yes Next.js rewrites route /ingest/* through proxy; /ingest/static/* and /ingest/array/* correctly routed to us-assets.i.posthog.com

Issues

  • Webhook distinct_id is fabricated: In app/api/stripe/webhook/route.ts, the distinctId is set to stripe_customer_ which is a Stripe customer ID, not a real PostHog user identifier. These events will create orphaned profiles unlinked to actual users. Fix by looking up the user from the Stripe customer ID in the database, or by extracting metadata attached during checkout session creation. [MEDIUM]
  • Older defaults date: instrumentation-client.ts uses defaults: '2026-01-30' while the current recommended value is '2026-05-30'. This means the client won't pick up newer default configuration improvements. [LOW]

Other completed criteria

  • API key loaded from process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN — 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 for toolbar/feature flag UI
  • posthog.shutdown() called after every server-side capture to ensure events are flushed
  • skipTrailingSlashRedirect: true added to next.config.ts to prevent redirect loops with the proxy

PostHog insights and events ✅

Filename PostHog events Description
instrumentation-client.ts captureException (auto) Automatic exception capture enabled via capture_exceptions: true
app/(dashboard)/layout.tsx identify, reset User identification on session load, reset on logout
app/(dashboard)/pricing/submit-button.tsx checkout_started Tracks when user initiates checkout from pricing page
app/(login)/actions.ts user_signed_in, user_signed_up, user_signed_out, password_updated, account_deleted, account_updated, team_member_removed, team_member_invited Comprehensive server-side event tracking for all auth and team management actions
app/api/stripe/checkout/route.ts checkout_completed Tracks successful Stripe checkout with plan name and subscription status
app/api/stripe/webhook/route.ts subscription_updated, subscription_cancelled Tracks subscription lifecycle changes from Stripe webhooks

Issues

  • No critical or medium issues with event quality.

Other completed criteria

  • Events represent real user actions mapping to actual SaaS product flows (auth, billing, team management)
  • Events enable clear product insights: signup→checkout→completed funnel, sign-in vs sign-up trends, team collaboration metrics
  • Events enriched with contextual properties: team_id, plan_name, subscription_status, via_invitation, invited_role, removed_member_id
  • No PII in capture properties — name and role are set via identify() person properties, not in capture() calls
  • Event naming is consistent snake_case and 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