Skip to content

[CI] (33127b6) next-js/15-pages-router-saas - #3671

Closed
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-33127b6-next-js-15-pages-router-saas
Closed

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-33127b6-next-js-15-pages-router-saas

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 33127b6
App: next-js/15-pages-router-saas
App directory: apps/next-js/15-pages-router-saas
Workbench branch: wizard-ci-33127b6-next-js-15-pages-router-saas
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-08-28T22:33:08.840Z
Duration: 489.6s

YARA Scanner

✓ 224 tool calls scanned, 0 violations detected

No violations: ✓ 224 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Author

PR Evaluation Report

Summary

This PR integrates PostHog into a Next.js 15 Pages Router SaaS application, adding both client-side (posthog-js) and server-side (posthog-node) analytics. It initializes PostHog via instrumentation-client.ts, identifies users on login and page load, implements a custom error boundary with captureException, and adds server-side event captures across 7 API routes covering auth, billing, account, and team management flows.

Files changed Lines added Lines removed
15 +266 -6

Confidence score: 4/5 👍

  • No reverse proxy configured: next.config.ts has no rewrites to proxy PostHog requests through a first-party domain, making client-side events susceptible to ad blockers. [MEDIUM]
  • Modified API response shapes: The sign-in and sign-up endpoints now return a user object in their JSON responses — this changes the API contract and could break other consumers of those endpoints. [MEDIUM]

File changes

Filename Score Description
instrumentation-client.ts 4/5 Correct Next.js client-side init with env validation; uses defaults: '2026-01-30' instead of latest '2026-05-30'
lib/posthog-server.ts 4/5 Clean singleton pattern for server-side PostHog Node client with flushAt:1/flushInterval:0
pages/_app.tsx 4/5 Custom PostHogIdentify class component for user identification on load, custom PostHogErrorBoundary
components/login.tsx 5/5 Proper identify + capture on login with stable user ID
components/header.tsx 5/5 Correct sign-out flow: capture event then posthog.reset()
package.json 5/5 Both posthog-js and posthog-node added
.env.example 5/5 Both env vars documented
pages/api/auth/sign-in.ts 3/5 Returns user data for client-side identify but modifies existing API response shape
pages/api/auth/sign-up.ts 3/5 Same API response shape modification as sign-in
pages/api/stripe/checkout.ts 5/5 Server-side checkout_completed with plan_name property
pages/api/stripe/create-checkout.ts 5/5 Server-side checkout_started capture
pages/api/stripe/customer-portal.ts 5/5 Server-side billing_portal_opened capture
pages/api/team/invite.ts 5/5 Server-side team_member_invited with role property
pages/api/team/remove-member.ts 5/5 Server-side team_member_removed capture
pages/api/account/update.ts 5/5 Server-side account_updated capture

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes All syntax is valid, imports resolve, no type errors
Preserves existing env vars & configs Yes Existing .env.example entries preserved, additions are additive
No syntax or type errors Yes TypeScript is correct throughout
Correct imports/exports Yes posthog-js on client, posthog-node on server — correct separation
Minimal, focused changes No API response shapes for sign-in/sign-up were modified to include user data
Pre-existing issues None Base app appears functional

Issues

  • API response shape modification: The sign-in and sign-up API endpoints now include a user object in their responses. While necessary for client-side identification, this changes the API contract. Any external consumers of these endpoints would receive unexpected extra fields. [MEDIUM]

Other completed criteria

  • Environment variables documented in .env.example
  • Build configuration valid — package.json has correct dependency entries
  • posthog-node correctly used only in server-side API routes
  • posthog-js correctly used only in client-side components

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js@^1.422.5 and posthog-node@^5.51.4 in package.json
PostHog client initialized Yes Client via instrumentation-client.ts (correct for Next.js), server via singleton in lib/posthog-server.ts
capture() Yes 10+ meaningful capture calls across client and server
identify() Yes posthog.identify(String(user.id), {...}) on login and on page load via PostHogIdentify component
Error tracking Yes Custom PostHogErrorBoundary with captureException + capture_exceptions: true in init config
Reverse proxy No next.config.ts has no rewrites configured for proxying PostHog requests

Issues

  • No reverse proxy: Client-side PostHog requests go directly to us.i.posthog.com, making them susceptible to ad blockers. Next.js rewrites should proxy /ingest/* to us.i.posthog.com and /ingest/static/* to us-assets.i.posthog.com. [MEDIUM]

Other completed criteria

  • API key loaded from NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN env var (not hardcoded)
  • Host correctly configured via NEXT_PUBLIC_POSTHOG_HOST env var
  • User identification uses stable database ID (String(user.id)) — correct approach
  • posthog.reset() called on sign-out — correct
  • Identification on page refresh via PostHogIdentify component fetching /api/user
  • Server-side uses flushAt: 1 and flushInterval: 0 per Next.js docs recommendation
  • Email/name passed as person properties in identify(), not in capture() — correct

PostHog insights and events ✅

Filename PostHog events Description
components/login.tsx user_signed_in, user_signed_up Client-side auth events with identification
components/header.tsx user_signed_out Sign-out event followed by reset()
pages/_app.tsx captureException Error boundary catches React component errors
pages/api/account/update.ts account_updated Server-side account update tracking
pages/api/stripe/checkout.ts checkout_completed Stripe checkout completion with plan name
pages/api/stripe/create-checkout.ts checkout_started Checkout initiation tracking
pages/api/stripe/customer-portal.ts billing_portal_opened Billing portal access tracking
pages/api/team/invite.ts team_member_invited Team invite with role property
pages/api/team/remove-member.ts team_member_removed Team member removal tracking

Issues

No issues — events are well-structured and map to real product flows.

Other completed criteria

  • Events represent real user actions across auth, billing, and team management flows
  • Events enable product insights — full signup → checkout → team management funnel is trackable
  • Several events include enriched properties (plan_name, invited_role, component_stack)
  • No PII in capture properties — email/name only in identify() person properties
  • Event names follow consistent snake_case convention and are descriptive

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