Skip to content

[CI] (4c70a79) next-js/15-pages-router-saas - #3866

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

[CI] (4c70a79) next-js/15-pages-router-saas#3866
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-4c70a79-next-js-15-pages-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-pages-router-saas
App directory: apps/next-js/15-pages-router-saas
Workbench branch: wizard-ci-4c70a79-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-09T22:25:56.841Z
Duration: 476.7s

YARA Scanner

✓ 180 tool calls scanned, 0 violations detected

No violations: ✓ 180 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 Pages Router SaaS app by adding posthog-js with initialization via instrumentation-client.ts, user identification on login/page load, event captures across key product flows (auth, checkout, team management), and exception autocapture. The API routes for sign-in and sign-up were modified to return user data to enable client-side identify().

Files changed Lines added Lines removed
10 +132 -6

Confidence score: 5/5 🧙

  • No reverse proxy configured: Next.js Pages Router supports rewrites natively, making proxy setup straightforward. Without it, client-side events may be blocked by ad blockers. [MEDIUM]
  • Outdated defaults date: Uses '2026-01-30' in instrumentation-client.ts, while the latest docs recommend '2026-05-30'. [LOW]

File changes

Filename Score Description
instrumentation-client.ts 4/5 New file; initializes PostHog with env vars, exception capture, and dev-mode debug. Uses slightly outdated defaults date.
package.json 5/5 Adds posthog-js dependency
.env.example 5/5 Documents NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST
components/header.tsx 4/5 Adds identify() via useEffect when user loads, reset() and capture on sign-out
components/login.tsx 5/5 Adds identify() and capture on sign-in/sign-up in event handler
pages/api/auth/sign-in.ts 4/5 Modified to return user object in API response for client-side identify
pages/api/auth/sign-up.ts 4/5 Modified to return user object in API response for client-side identify
pages/dashboard/general.tsx 5/5 Captures account_updated event
pages/dashboard/index.tsx 5/5 Captures subscription, team member, and invite events
pages/pricing.tsx 5/5 Captures checkout_started with plan details

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes No syntax or import errors; all files are valid TypeScript
Preserves existing env vars & configs Yes Existing env vars preserved; new PostHog vars added to .env.example
No syntax or type errors Yes All code is syntactically valid
Correct imports/exports Yes posthog-js correctly imported in client-side files only
Minimal, focused changes Yes API route changes are justified to enable client-side identify()
Pre-existing issues None

Issues

  • API response shape modified: sign-in.ts and sign-up.ts now return a user object in their responses. While needed for client-side identify, this changes the API contract. Any external consumers of these endpoints would receive additional data. [LOW]

Other completed criteria

  • Environment variables documented in .env.example
  • Build configuration valid with posthog-js added to dependencies
  • PostHog guard checks (process.env.NEXT_PUBLIC_POSTHOG_KEY) prevent errors when env vars are missing

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js@^1.429.0 added to package.json
PostHog client initialized Yes Initialized in instrumentation-client.ts with env-based key/host, exception capture, and dev debug
capture() Yes 7 meaningful capture calls across auth, dashboard, and pricing flows
identify() Yes Called on login (event handler) and on page load when user is available (useEffect); uses String(user.id) as distinct_id with email/name/role as person properties
Error tracking Yes capture_exceptions: true in init config enables automatic exception capture
Reverse proxy No No reverse proxy configured via Next.js rewrites or middleware

Issues

  • No reverse proxy: The app uses Next.js Pages Router which supports rewrites in next.config.ts. A reverse proxy should be configured to prevent ad blockers from intercepting PostHog requests. Add rewrites for /ingest/* to the PostHog host. [MEDIUM]
  • Outdated defaults date: defaults: '2026-01-30' should be '2026-05-30' per current docs. [LOW]

Other completed criteria

  • API key loaded from NEXT_PUBLIC_POSTHOG_KEY environment variable
  • Host correctly configured from NEXT_PUBLIC_POSTHOG_HOST environment variable
  • posthog.reset() called on sign-out
  • Identify uses stable database user ID, not email
  • Identify guard prevents redundant calls when distinct_id already matches

PostHog insights and events ✅

Filename PostHog events Description
components/login.tsx user_signed_in, user_signed_up Auth events with auth_method property; enables sign-up funnel
components/header.tsx user_signed_out Tracks sign-out and calls reset()
pages/pricing.tsx checkout_started Tracks checkout initiation with plan_name, billing_interval, trial_days
pages/dashboard/index.tsx subscription_management_opened, team_member_removed, team_member_invited Team and subscription management with invited_role property
pages/dashboard/general.tsx account_updated Tracks account settings changes
instrumentation-client.ts captureException (auto) Automatic exception capture via capture_exceptions: true

Issues

  • No issues — events are well-structured and actionable.

Other completed criteria

  • Events represent real user actions in the SaaS product flow
  • Events enable product insights: sign-up → checkout funnel, team management analysis, retention via sign-in frequency
  • Events include relevant properties (plan details on checkout, role on invite)
  • 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