Skip to content

[CI] (c212e50) next-js/15-app-router-saas - #4325

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

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

Conversation

@wizard-ci-bot

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

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: c212e50
App: next-js/15-app-router-saas
App directory: apps/next-js/15-app-router-saas
Workbench branch: wizard-ci-c212e50-next-js-15-app-router-saas
Wizard branch: posthog/functional-r9-19-bring-docs-readmes-and-skills-in-line-wi
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-10-01T19:37:50.362Z
Duration: 538.8s

YARA Scanner

✓ 203 tool calls scanned, 0 violations detected

No violations: ✓ 203 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Oct 1, 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 adds user identification, error tracking via global-error.tsx and capture_exceptions, server-side event capture for key user actions (sign-in, sign-up, checkout, account management), and OpenTelemetry-based logging to PostHog. The integration follows the recommended instrumentation-client.ts pattern.

Files changed Lines added Lines removed
13 +211 -4

Confidence score: 5/5 🧙

  • No reverse proxy configured: next.config.ts has no rewrites for PostHog. Client-side events may be blocked by ad blockers. Add Next.js rewrites to proxy /ingest to the PostHog host. [MEDIUM]
  • Outdated defaults date: instrumentation-client.ts uses defaults: '2026-01-30' instead of the latest '2026-05-30' from the docs. This may miss newer default configuration improvements. [LOW]

File changes

Filename Score Description
instrumentation-client.ts 4/5 Client-side PostHog init with env var validation, exception autocapture, and debug mode. Uses slightly outdated defaults date.
lib/posthog-server.ts 5/5 Server-side PostHog singleton with flushAt: 1 / flushInterval: 0 pattern correct for Next.js. Includes graceful env var fallback.
app/(dashboard)/layout.tsx 5/5 Identifies user with stable user.id, sets person properties (email, name, role), resets on sign-out.
app/(login)/actions.ts 5/5 Server-side captures for sign-in, sign-up, password update, account deletion, account update, team member management.
app/global-error.tsx 5/5 Global error boundary with posthog.captureException().
instrumentation.ts 4/5 OpenTelemetry LoggerProvider for PostHog logs endpoint. Good addition.
lib/posthog-logs.ts 5/5 Clean utility for emitting structured logs via OTel.
app/api/stripe/checkout/route.ts 5/5 Captures checkout_completed event and logs Stripe events.
app/api/stripe/webhook/route.ts 5/5 Logs webhook verification failures and subscription changes.
lib/payments/stripe.ts 5/5 Captures checkout_started and subscription_portal_opened events.
package.json 5/5 Adds posthog-js, posthog-node, and OTel dependencies.
.env.example 5/5 Documents both NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN and NEXT_PUBLIC_POSTHOG_HOST.
.gitignore 5/5 Ensures .env is not committed.

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes No syntax errors, valid TypeScript, correct module resolution
Preserves existing env vars & configs Yes Existing env vars and configs untouched; only PostHog additions
No syntax or type errors Yes All files use valid syntax and types
Correct imports/exports Yes All imports resolve correctly — posthog-js client-only, posthog-node server-only, server-only guard on logs
Minimal, focused changes Yes All changes relate to PostHog integration
Pre-existing issues None No pre-existing issues observed

Issues

  • Outdated defaults date: instrumentation-client.ts uses defaults: '2026-01-30' instead of the latest '2026-05-30' from PostHog docs. Update to the latest date to ensure optimal default configuration. [LOW]

Other completed criteria

  • Environment variables documented in .env.example
  • .gitignore prevents .env from being committed
  • package.json dependencies are valid with proper version ranges
  • import 'server-only' guard on posthog-logs.ts prevents accidental client-side import
  • use import correctly replaced with useEffect since the new identify logic requires it

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js ^1.435.6 and posthog-node ^5.55.0 added to package.json
PostHog client initialized Yes Client: instrumentation-client.ts with posthog.init(). Server: singleton in lib/posthog-server.ts with flushAt: 1, flushInterval: 0
capture() Yes 9 server-side events + client-side autocapture enabled
identify() Yes Uses stable String(user.id) with email, name, role as person properties. Fires in useEffect when SWR loads user data. posthog.reset() called on sign-out
Error tracking Yes global-error.tsx with captureException(), plus capture_exceptions: true in init config
Reverse proxy No next.config.ts has no rewrites. PostHog requests go directly to us.i.posthog.com

Issues

  • No reverse proxy configured: The next.config.ts is empty — no PostHog rewrites are set up. Client-side PostHog requests will go directly to us.i.posthog.com and may be blocked by ad blockers. Add rewrites per the Next.js proxy docs. [MEDIUM]

Other completed criteria

  • API key loaded from NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN environment variable (not hardcoded)
  • API host loaded from NEXT_PUBLIC_POSTHOG_HOST environment variable
  • Env var validation with clear error messages in development mode
  • Server-side client correctly uses flushAt: 1 and flushInterval: 0 per Next.js docs
  • enableExceptionAutocapture: true on server-side client
  • OpenTelemetry logging integration sends structured logs to PostHog

PostHog insights and events ✅

Filename PostHog events Description
app/(login)/actions.ts user_signed_in, user_signed_up, password_updated, account_deleted, account_updated, team_member_removed, team_member_invited Server-side events covering the full user lifecycle and team management
app/api/stripe/checkout/route.ts checkout_completed Captures successful Stripe checkout with subscription status
lib/payments/stripe.ts checkout_started, subscription_portal_opened Captures checkout initiation and billing portal access
app/global-error.tsx captureException Captures unhandled client-side errors
app/api/stripe/webhook/route.ts OTel logs Logs webhook events (signature failures, subscription changes)
instrumentation-client.ts autocapture, captureException Automatic pageviews, clicks, and exception autocapture

Issues

No issues.

Other completed criteria

  • Events represent real user actions mapped to actual product flows (signup → checkout → subscription management)
  • Events enable product insights: sign-up → sign-in → checkout funnel, team management analytics, subscription tracking
  • Events include relevant properties: joined_via_invitation, role, has_existing_customer, subscription_status
  • No PII in event properties — email/name only in identify() person properties
  • Event names use consistent snake_case convention with descriptive action names

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