Skip to content

[CI] (4c70a79) next-js/15-app-router-saas - #3864

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

[CI] (4c70a79) next-js/15-app-router-saas#3864
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-4c70a79-next-js-15-app-router-saas

Conversation

@wizard-ci-bot

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

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 4c70a79
App: next-js/15-app-router-saas
App directory: apps/next-js/15-app-router-saas
Workbench branch: wizard-ci-4c70a79-next-js-15-app-router-saas
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-09-09T22:23:37.998Z
Duration: 443.6s

YARA Scanner

✓ 169 tool calls scanned, 0 violations detected

No violations: ✓ 169 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown
Author

PR Evaluation Report

Summary

This PR integrates PostHog into a Next.js 15 app-router SaaS application with both client-side (posthog-js) and server-side (posthog-node) SDKs. It initializes the client via instrumentation-client.ts, identifies users in the dashboard layout, captures server-side events for key user actions (sign-in, sign-up, checkout, etc.), and adds error tracking through a global-error.tsx boundary and capture_exceptions.

Files changed Lines added Lines removed
9 +157 -2

Confidence score: 5/5 🧙

  • No reverse proxy configured: Neither next.config.ts rewrites nor middleware are set up to proxy PostHog requests. This means client-side events are vulnerable to ad blockers. A Next.js rewrite or Vercel proxy should be added. [MEDIUM]
  • Outdated defaults date: instrumentation-client.ts uses defaults: '2026-01-30' instead of the current recommended '2026-05-30', which means slightly older default configuration values. [LOW]

File changes

Filename Score Description
instrumentation-client.ts 4/5 Client-side PostHog init with env guards, tracing headers, exception capture, and debug mode. Uses slightly older defaults date.
lib/posthog-server.ts 5/5 Server-side PostHog singleton with lazy init, env validation, flushAt: 1/flushInterval: 0 for short-lived functions, and a clean captureServerEvent helper.
app/(dashboard)/layout.tsx 5/5 Identifies users via useEffect reacting to SWR user data. Uses a ref to prevent duplicate identify calls. Resets on sign-out. Stable DB ID (user.id) used as distinct_id.
app/(login)/actions.ts 5/5 Server-side event capture for sign-in, sign-up, sign-out, password update, account deletion, account update, team member removal, and invitation.
app/api/stripe/checkout/route.ts 5/5 Captures subscription_activated with subscription status property.
lib/payments/stripe.ts 5/5 Captures subscription_checkout_started before creating Stripe session.
app/global-error.tsx 4/5 Error boundary with captureException. Guards on env vars before calling.
.env.example 5/5 Documents both PostHog env vars with placeholder values.
package.json 5/5 Both posthog-js and posthog-node added.

App sanity check ✅

Criteria Result Description
App builds and runs Yes No syntax errors; all imports resolve correctly
Preserves existing env vars & configs Yes Existing env vars and app code untouched; only PostHog additions
No syntax or type errors Yes TypeScript is valid; User type has id, email, name, role fields matching usage
Correct imports/exports Yes posthog-js used client-side, posthog-node used server-side; no cross-environment imports
Minimal, focused changes Yes All changes are strictly PostHog integration
Pre-existing issues None

Issues

No issues.

Other completed criteria

  • Environment variables documented in .env.example
  • Build configuration valid with correct package versions

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js ^1.429.0 and posthog-node ^5.51.8 in package.json
PostHog client initialized Yes instrumentation-client.ts with posthog.init() using env vars, correct Next.js pattern
capture() Yes 10 server-side captureServerEvent calls + client-side autocapture enabled
identify() Yes posthog.identify(String(user.id), { email, name, role }) with stable DB ID; posthog.reset() on sign-out; ref guard prevents duplicate calls
Error tracking Yes global-error.tsx with posthog.captureException(error) + capture_exceptions: true in init config
Reverse proxy No No rewrites in next.config.ts, no middleware proxy. Client-side events will be blocked by ad blockers.

Issues

  • No reverse proxy: The integration does not configure a reverse proxy for PostHog. Next.js rewrites in next.config.ts or Vercel rewrites should be added to route /ingest/* to PostHog, ensuring both /static/* and /array/* paths are proxied. [MEDIUM]

Other completed criteria

  • API key loaded from environment variable (NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN)
  • Host correctly configured from environment variable (NEXT_PUBLIC_POSTHOG_HOST)
  • Tracing headers configured with window.location.hostname for client-server session linking
  • Server-side client uses flushAt: 1 and flushInterval: 0 per Next.js best practices
  • Identify uses stable database ID, not email

PostHog insights and events ✅

Filename PostHog events Description
instrumentation-client.ts autocapture, , Client-side initialization with autocapture enabled by default
app/(dashboard)/layout.tsx identify, reset User identification on dashboard load; reset on sign-out
app/(login)/actions.ts user_signed_in, account_signed_up, user_signed_out, password_updated, account_deleted, account_updated, team_member_removed, team_member_invited Server-side capture of all key auth and account management actions
app/api/stripe/checkout/route.ts subscription_activated Tracks successful Stripe checkout with subscription status
lib/payments/stripe.ts subscription_checkout_started Tracks when checkout session creation begins
app/global-error.tsx captureException Captures uncaught errors at the app boundary

Issues

No issues.

Other completed criteria

  • Events represent real user actions mapping to actual SaaS product flows (auth → subscription → team management)
  • Events enable product insights: sign-up → sign-in → checkout → subscription funnel; team growth tracking
  • Events include relevant properties (joined_via_invitation, role, subscription_status)
  • No PII in event properties; email and name correctly placed in identify() person properties
  • Consistent snake_case naming convention across all events

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