Skip to content

[CI] (22322bc) next-js/15-pages-router-saas - #3649

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

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-22322bc-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: 22322bc
App: next-js/15-pages-router-saas
App directory: apps/next-js/15-pages-router-saas
Workbench branch: wizard-ci-22322bc-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-28T19:25:52.638Z
Duration: 539.9s

YARA Scanner

✓ 218 tool calls scanned, 0 violations detected

No violations: ✓ 218 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. It adds both client-side (posthog-js) and server-side (posthog-node) SDKs, initializes PostHog in _app.tsx, implements user identification on login/page load, captures server-side events across auth, billing, and team management API routes, and enables exception autocapture.

Files changed Lines added Lines removed
14 +179 -6

Confidence score: 5/5 🧙

  • No reverse proxy configured — client-side events are vulnerable to ad blockers [MEDIUM]

File changes

Filename Score Description
pages/_app.tsx 4/5 Client-side PostHog initialization with env vars, error tracking, and dev guard
lib/posthog-server.ts 5/5 Server-side PostHog singleton with graceful fallback when env vars missing
components/header.tsx 5/5 User identification on page load via useEffect, reset on sign-out
components/login.tsx 5/5 User identification in login event handler
pages/api/auth/sign-in.ts 4/5 Server-side sign-in event capture; modifies API response to include user object
pages/api/auth/sign-up.ts 4/5 Server-side sign-up event capture; modifies API response to include user object
pages/api/stripe/checkout.ts 5/5 Captures subscription_activated event
pages/api/stripe/create-checkout.ts 5/5 Captures checkout_started event with price_id
pages/api/stripe/customer-portal.ts 5/5 Captures subscription_management_opened event
pages/api/team/invite.ts 5/5 Captures team_member_invited with role
pages/api/team/remove-member.ts 5/5 Captures team_member_removed event
pages/api/account/update.ts 5/5 Captures account_updated event
package.json 5/5 Adds posthog-js and posthog-node dependencies
.env.example 5/5 Documents NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN and NEXT_PUBLIC_POSTHOG_HOST

App sanity check ✅

Criteria Result Description
App builds and runs Yes No syntax errors; all imports resolve to installed packages
Preserves existing env vars & configs Yes Existing env vars and configs preserved; API responses extended with user object without breaking existing fields
No syntax or type errors Yes All TypeScript is valid; correct usage of types
Correct imports/exports Yes posthog-js imported client-side, posthog-node imported server-side
Minimal, focused changes Yes All changes are PostHog-related; API response modifications are necessary for client-side identify
Pre-existing issues None

Other completed criteria

  • Environment variables documented in .env.example
  • Build configuration valid — package.json deps are correct
  • Server-side singleton pattern avoids re-creating clients per request

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js ^1.422.5 and posthog-node ^5.51.4 added to package.json
PostHog client initialized Yes Client initialized in _app.tsx at module scope with defaults: '2026-01-30'; server initialized as singleton in lib/posthog-server.ts with flushAt: 1, flushInterval: 0
capture() Yes 9 server-side captures across API routes; 1 client-side capture (user_signed_out)
identify() Yes posthog.identify(String(user.id), { email, name, role }) in login handler and on page load via useEffect in header component
Error tracking Yes capture_exceptions: true in client init; enableExceptionAutocapture: true in server config
Reverse proxy No No reverse proxy configured for client-side events

Issues

  • No reverse proxy configured: Client-side PostHog events sent directly to NEXT_PUBLIC_POSTHOG_HOST will be blocked by ad blockers. Configure Next.js rewrites or use PostHog's managed reverse proxy. [MEDIUM]

Other completed criteria

  • API key loaded from NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN environment variable
  • Host configured from NEXT_PUBLIC_POSTHOG_HOST environment variable
  • posthog.reset() called on sign-out to clear identity
  • Identify uses stable user.id (not email) as distinct_id
  • PII (email, name) correctly placed in identify person properties, not in capture event properties

PostHog insights and events ✅

Filename PostHog events Description
components/header.tsx identify, user_signed_out, reset Identifies user on page load; captures sign-out and resets identity
components/login.tsx identify Identifies user immediately after successful login/signup
pages/api/auth/sign-in.ts user_signed_in Server-side sign-in with checkout_flow property
pages/api/auth/sign-up.ts user_signed_up Server-side sign-up with checkout_flow and joined_via_invitation properties
pages/api/stripe/create-checkout.ts checkout_started Captures checkout initiation with price_id
pages/api/stripe/checkout.ts subscription_activated Captures successful subscription with subscription_status
pages/api/stripe/customer-portal.ts subscription_management_opened Captures billing portal access
pages/api/account/update.ts account_updated Captures account profile updates
pages/api/team/invite.ts team_member_invited Captures team invitations with role
pages/api/team/remove-member.ts team_member_removed Captures team member removal

Other completed criteria

  • Events represent real user actions across the full SaaS lifecycle (auth → billing → team management)
  • Events enable product funnels: sign_up → checkout_started → subscription_activated
  • Events include relevant properties (checkout_flow, price_id, subscription_status, role, joined_via_invitation)
  • No PII in event properties — emails and names only in identify() person properties
  • Consistent snake_case naming convention

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