Skip to content

[CI] (3f39e0e) next-js/15-pages-router-saas - #4168

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

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

Conversation

@wizard-ci-bot

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

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 3f39e0e
App: next-js/15-pages-router-saas
App directory: apps/next-js/15-pages-router-saas
Workbench branch: wizard-ci-3f39e0e-next-js-15-pages-router-saas
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-09-23T22:10:39.861Z
Duration: 574.3s

YARA Scanner

✓ 222 tool calls scanned, 0 violations detected

No violations: ✓ 222 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown
Author

Now I have enough context to produce the full evaluation.


PR Evaluation Report

Summary

This PR integrates PostHog into a Next.js 15 Pages Router SaaS app, adding both client-side (posthog-js) and server-side (posthog-node) tracking. It includes PostHog initialization in _app.tsx, user identification with reset on logout, an error boundary with captureException, server-side event capture across seven API routes, and an OpenTelemetry-based logging integration.

Files changed Lines added Lines removed
15 +279 -3

Confidence score: 5/5 🧙

  • No reverse proxy configured — the next.config.ts has no rewrites to proxy PostHog requests, making client-side events susceptible to ad blockers [MEDIUM]
  • OpenTelemetry dependency versions ^0.222.0 appear unusually high and may not resolve during install, potentially breaking the build [MEDIUM]

File changes

Filename Score Description
pages/_app.tsx 4/5 PostHog client-side init with env vars, capture_exceptions, tracing_headers, and ErrorBoundary wrapper
components/error-boundary.tsx 5/5 Class-based React error boundary calling posthog.captureException
components/header.tsx 5/5 User identification with stable ID, deduplication via ref, reset on logout
lib/posthog-server.ts 5/5 Server-side PostHog Node client with singleton pattern, flushAt: 1, flushInterval: 0
lib/posthog-logs.ts 3/5 OpenTelemetry log exporter — functional but dependency versions suspect
package.json 4/5 Adds posthog-js, posthog-node, and OpenTelemetry packages
.env.example 5/5 Documents NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST
pages/api/auth/sign-in.ts 5/5 Server-side user_signed_in event with properties
pages/api/auth/sign-up.ts 5/5 Server-side user_signed_up event with properties
pages/api/account/update.ts 4/5 Server-side account_updated event (no properties)
pages/api/stripe/create-checkout.ts 5/5 Server-side checkout_started event
pages/api/stripe/customer-portal.ts 5/5 Server-side subscription_portal_opened event
pages/api/team/invite.ts 5/5 Server-side team_member_invited with invited_role property
pages/api/team/remove-member.ts 4/5 Server-side team_member_removed event (no properties)
.gitignore 5/5 Adds .env to gitignore

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes Code is syntactically correct; structure follows Next.js Pages Router conventions
Preserves existing env vars & configs Yes Only additive changes to .env.example and _app.tsx; existing functionality untouched
No syntax or type errors Yes All TypeScript code is valid; proper typing throughout
Correct imports/exports Yes posthog-js imported client-side, posthog-node server-side; server-only guard on logs module
Minimal, focused changes Yes All changes directly support PostHog integration
Pre-existing issues None No pre-existing issues observed

Issues

  • OpenTelemetry package versions: The @opentelemetry/* packages at ^0.222.0 are unusually high version numbers. If these versions don't exist in the npm registry, npm install will fail. Verify these versions resolve correctly. [MEDIUM]

Other completed criteria

  • Environment variables documented in .env.example
  • Build configuration (package.json) is structurally valid
  • .gitignore properly excludes .env

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js@^1.434.12 and posthog-node@^5.53.0 added to package.json
PostHog client initialized Yes posthog.init() in _app.tsx with api_host, defaults, tracing_headers, capture_exceptions
capture() Yes Client-side user_signed_out + 7 server-side events across API routes
identify() Yes posthog.identify(String(user.id), { email, name, role }) in header.tsx with ref-based deduplication
Error tracking Yes Custom ErrorBoundary with posthog.captureException() + capture_exceptions: true in init config
Reverse proxy No No reverse proxy configured in next.config.ts; no rewrites for PostHog endpoints

Issues

  • No reverse proxy: The next.config.ts does not configure rewrites to proxy PostHog requests through the app's domain. This means client-side events from posthog-js can be blocked by ad blockers. Add Next.js rewrites per the PostHog Next.js proxy docs. [MEDIUM]

Other completed criteria

  • API key loaded from NEXT_PUBLIC_POSTHOG_KEY environment variable (not hardcoded)
  • API host loaded from NEXT_PUBLIC_POSTHOG_HOST environment variable
  • posthog.reset() called on sign-out with user_signed_out capture beforehand
  • Identify uses stable user.id (not email) as distinct_id — correct per best practices
  • Ref-based deduplication prevents redundant identify calls
  • Server-side client uses flushAt: 1 and flushInterval: 0 for immediate event delivery (correct for Next.js short-lived functions)
  • tracing_headers configured with window.location.hostname for client-server session linking
  • Screen views: N/A (web framework — posthog-js autocaptures pageviews)
  • All targets initialized: N/A (single-target project)

PostHog insights and events ✅

Filename PostHog events Description
components/header.tsx user_signed_out, identify, reset Client-side sign-out tracking with identity management
components/error-boundary.tsx captureException Captures React rendering errors
pages/api/auth/sign-in.ts user_signed_in Server-side sign-in with checkout_redirect_requested property
pages/api/auth/sign-up.ts user_signed_up Server-side sign-up with invitation_accepted, checkout_redirect_requested
pages/api/account/update.ts account_updated Server-side account update tracking
pages/api/stripe/create-checkout.ts checkout_started Server-side checkout session creation
pages/api/stripe/customer-portal.ts subscription_portal_opened Server-side Stripe portal access
pages/api/team/invite.ts team_member_invited Server-side team invite with invited_role property
pages/api/team/remove-member.ts team_member_removed Server-side team member removal

Issues

No issues.

Other completed criteria

  • Events represent real user actions mapped to actual SaaS product flows (auth, billing, team management)
  • Events enable product insights: can build sign-up → sign-in → checkout funnel, team growth analysis
  • Key events enriched with contextual properties (checkout_redirect_requested, invitation_accepted, invited_role)
  • No PII in capture() properties — email/name only 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