Skip to content

[CI] (cc5471b) next-js/15-pages-router-saas - #4782

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

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

Conversation

@wizard-ci-bot

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

Copy link
Copy Markdown

Automated wizard CI run

Source: scheduled
Trigger ID: cc5471b
App: next-js/15-pages-router-saas
App directory: apps/next-js/15-pages-router-saas
Workbench branch: wizard-ci-cc5471b-next-js-15-pages-router-saas
Wizard branch: main
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-10-28T16:53:14.332Z
Duration: 503.6s

YARA Scanner

✓ 218 tool calls scanned, 0 violations detected

No violations: ✓ 218 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown
Author

Now I have everything I need. Let me produce the evaluation report.


PR Evaluation Report

Summary

This PR integrates PostHog into a Next.js 15 Pages Router SaaS application. It adds client-side initialization via instrumentation-client.ts, user identification through a dedicated component in _app.tsx and the login flow, custom event captures across multiple pages (checkout, team management, auth), a custom error boundary with captureException, and server-side OpenTelemetry log emission to PostHog. No reverse proxy is configured, and no posthog-node SDK is used for server-side event capture.

Files changed Lines added Lines removed
15 +284 -10

Confidence score: 4/5 👍

  • No reverse proxy configured: Next.js supports rewrites for a PostHog reverse proxy, but next.config.ts is untouched. Client-side events are sent directly to PostHog and will be blocked by ad blockers. [MEDIUM]
  • No posthog-node for server-side capture: Server-side API routes use OpenTelemetry log emission instead of posthog-node capture calls. These are logs, not PostHog events, and won't appear in the activity feed or be usable for funnels/insights. [MEDIUM]
  • Suspicious OpenTelemetry package versions: @opentelemetry/api-logs: ^0.223.0, @opentelemetry/exporter-logs-otlp-http: ^0.300.0, @opentelemetry/resources: ^3.0.0 — these versions look unrealistically high and may not resolve during npm install, potentially breaking the build. [MEDIUM]

File changes

Filename Score Description
instrumentation-client.ts 4/5 Client-side PostHog init with env var guards and error tracking. Uses older defaults: '2025-05-24' instead of latest.
instrumentation.ts 3/5 Server-side OTel log provider — functional but uses PostHog logs endpoint instead of posthog-node for event capture.
pages/_app.tsx 4/5 Adds ErrorBoundary wrapper and user identification component with proper reset/identify logic.
components/login.tsx 4/5 Identifies users on login with stable user.id, sets person properties correctly.
components/header.tsx 4/5 Captures sign-out event. Reset handled by _app.tsx identification component.
components/error-boundary.tsx 4/5 Custom error boundary with posthog.captureException().
package.json 3/5 Adds posthog-js correctly, but OTel dependency versions look potentially invalid. Missing posthog-node.
pages/dashboard/index.tsx 5/5 Good event captures with properties for team and subscription actions.
pages/pricing.tsx 5/5 Captures checkout_started with enriched properties (plan, interval, trial days).
pages/api/stripe/create-checkout.ts 3/5 Uses OTel log emission instead of proper PostHog event capture.
.env.example 4/5 Documents both required PostHog env vars.

App sanity check ⚠️

Criteria Result Description
App builds and runs ⚠️ OpenTelemetry package versions (^0.223.0, ^0.300.0, ^3.0.0) are unrealistically high and may not exist on npm, causing install failure.
Preserves existing env vars & configs Yes All existing env vars and configs are preserved. New PostHog vars are additive.
No syntax or type errors Yes All TypeScript code is syntactically valid with correct type usage.
Correct imports/exports Yes All imports resolve correctly. @/instrumentation import in API routes will resolve via the tsconfig path alias.
Minimal, focused changes Yes All changes relate to PostHog integration with no scope creep.
Pre-existing issues None Base app appears clean.

Issues

  • Potentially invalid OTel package versions: @opentelemetry/api-logs: ^0.223.0 and similar versions appear hallucinated. If these don't exist on npm, npm install will fail and the app won't build. Verify and pin to actual published versions. [MEDIUM]

Other completed criteria

  • Environment variables documented in .env.example
  • Build configuration (package.json) has valid structure
  • .gitignore properly excludes .env.local and .env

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js: ^1.441.2 added to dependencies
PostHog client initialized Yes instrumentation-client.ts calls posthog.init() with env-var-based key and host, matching the Next.js docs pattern
capture() Yes Multiple meaningful captures: checkout_started, user_signed_in, user_signed_up, user_signed_out, account_updated, team_member_removed, team_invitation_sent, subscription_management_opened
identify() Yes posthog.identify(String(user.id), { email, role, name }) called in both login handler and _app.tsx on app load with stable database ID. posthog.reset() called on user change and logout.
Error tracking Yes Custom ErrorBoundary with posthog.captureException() plus capture_exceptions: true in init config
Reverse proxy No next.config.ts has no rewrites or proxy configuration for PostHog

Issues

  • No reverse proxy: The Next.js docs recommend configuring rewrites in next.config.ts to proxy PostHog requests through a first-party domain. Without this, ad blockers will intercept client-side events. Add rewrites() in next.config.ts pointing /ingest/* to us.i.posthog.com (and /ingest/static/* to us-assets.i.posthog.com) and update api_host accordingly. [MEDIUM]
  • No posthog-node for server-side: The PR uses OpenTelemetry logs for server-side tracking instead of posthog-node. These are not PostHog events — they won't show in Activity, can't be used in funnels, and don't carry distinct_id. For proper server-side event capture, install posthog-node and use posthog.capture(). [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
  • Identify uses stable user.id from database, not email as distinct_id
  • PII (email, name) correctly placed in person properties via identify(), not in event properties
  • posthog.reset() called on logout and user switching

PostHog insights and events ✅

Filename PostHog events Description
instrumentation-client.ts (init, autocapture) Initializes PostHog with exception autocapture and default autocapture for pageviews/clicks
components/login.tsx user_signed_in, user_signed_up Captures auth events after successful login/signup with user identification
components/header.tsx user_signed_out Captures sign-out action
pages/pricing.tsx checkout_started Captures checkout initiation with plan_name, billing_interval, trial_days properties
pages/dashboard/index.tsx subscription_management_opened, team_member_removed, team_invitation_sent Team management events; invitation includes invited_role property
pages/dashboard/general.tsx account_updated Captures profile update
components/error-boundary.tsx captureException Catches React errors with component stack
pages/api/stripe/create-checkout.ts (OTel log: checkout_session_created) Server-side log emission, not a PostHog event
pages/api/stripe/customer-portal.ts (OTel log: customer_portal_session_created) Server-side log emission
pages/api/team/invite.ts (OTel log: team_invitation_created) Server-side log emission with invited_role attribute

Issues

  • Server-side logs are not PostHog events: The emitPostHogLog() calls in API routes send OTel log records, not PostHog capture() events. These won't appear in PostHog's event stream or be usable for product analytics (funnels, trends, retention). Replace with posthog-node capture calls for actionable analytics. [MEDIUM]

Other completed criteria

  • Events represent real user actions across the full SaaS lifecycle (auth → dashboard → billing)
  • Event names are descriptive and use consistent snake_case convention
  • Events include relevant properties (plan details on checkout, role on invitation)
  • No PII in event properties — email/name set via identify() person properties only
  • Events enable product insights: sign-up → checkout funnel, team activity trends, subscription management

Reviewed by wizard workbench PR evaluator

@wizard-ci-bot wizard-ci-bot Bot added the CI/CD label Oct 28, 2026
@wizard-ci-bot wizard-ci-bot Bot closed this Oct 28, 2026
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