Skip to content

[CI] (9da603e) next-js/15-app-router-saas - #4396

Closed
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-9da603e-next-js-15-app-router-saas
Closed

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-9da603e-next-js-15-app-router-saas

Conversation

@wizard-ci-bot

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

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 9da603e
App: next-js/15-app-router-saas
App directory: apps/next-js/15-app-router-saas
Workbench branch: wizard-ci-9da603e-next-js-15-app-router-saas
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-10-06T15:48:58.737Z
Duration: 416.3s

YARA Scanner

✓ 176 tool calls scanned, 0 violations detected

No violations: ✓ 176 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown
Author

Now I have all the context needed. Let me produce the evaluation.


PR Evaluation Report

Summary

This PR integrates PostHog into a Next.js 15 App Router SaaS application. It adds posthog-js for client-side event capture, user identification, and error tracking via instrumentation-client.ts and global-error.tsx. It also sets up OpenTelemetry-based server-side logging to PostHog. Multiple custom events are captured across dashboard pages. No posthog-node SDK is installed, and no reverse proxy is configured.

Files changed Lines added Lines removed
13 +175 -9

Confidence score: 5/5 🧙

  • No reverse proxy configured: Next.js rewrites are not set up, so client-side PostHog requests are vulnerable to ad-blocker interception. The Next.js docs explicitly recommend configuring a reverse proxy. [MEDIUM]
  • No posthog-node for server-side event capture: The server-side route (app/api/stripe/checkout/route.ts) uses a custom OpenTelemetry log emitter instead of posthog-node capture() calls. These are logs, not PostHog analytics events — they won't appear in PostHog's event stream for funnels or insights. This means there's no server-side event capture for important actions like checkout completion. [MEDIUM]
  • identify() called inside useEffect reacting to state changes: The useEffect in layout.tsx watches user state from SWR and calls posthog.identify(). Per React rules, analytics capture should happen in event handlers (e.g., after login), not in effects reacting to state. However, for identify on page load (when user is already logged in), this is an acceptable pattern since there's no event handler to hook into. [LOW]
  • defaults date is '2026-01-30': The docs show '2026-05-30' as the current defaults date. Using an older date means the SDK may use older default configurations. [LOW]

File changes

Filename Score Description
instrumentation-client.ts 4/5 Client-side PostHog init with env vars, error checking, and capture_exceptions enabled. Good pattern overall, though defaults date is slightly outdated.
instrumentation.ts 3/5 Server-side OpenTelemetry log setup. Functional but not a standard PostHog server-side integration — uses OTLP logs, not posthog-node.
lib/posthog-logs.ts 3/5 Utility for emitting logs. Works but these are OTel logs, not PostHog events.
app/global-error.tsx 4/5 Error boundary with posthog.captureException(). Correct pattern for Next.js App Router.
app/(dashboard)/layout.tsx 4/5 Adds posthog.identify() and posthog.reset(). Correct placement.
app/(dashboard)/dashboard/general/page.tsx 5/5 Adds account_update_submitted capture on form submit. Clean.
app/(dashboard)/dashboard/page.tsx 5/5 Adds captures for subscription management, team member removal, and team invitation. Clean.
app/(dashboard)/dashboard/security/page.tsx 5/5 Adds captures for password update and account deletion. Clean.
app/(dashboard)/pricing/submit-button.tsx 5/5 Adds checkout_started capture on button click. Clean.
app/api/stripe/checkout/route.ts 3/5 Uses OTel log emitter instead of PostHog capture(). These are logs, not analytics events.
.env.example 5/5 Documents PostHog env vars.
.gitignore 5/5 Adds .env to gitignore.
package.json 4/5 Adds posthog-js and OTel dependencies. Missing posthog-node for server-side.

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes No syntax errors, valid imports, dependencies added
Preserves existing env vars & configs Yes Existing env vars preserved, only PostHog additions made
No syntax or type errors Yes All TypeScript is valid
Correct imports/exports Yes posthog-js imported correctly in client components, OTel imports are valid
Minimal, focused changes Yes All changes relate to PostHog integration
Pre-existing issues None —

Issues

  • OTel log dependencies may have version issues: The @opentelemetry packages use ^0.223.0 and ^2.12.0 — these are very high version numbers that may not exist yet. This could cause install failures. [LOW]

Other completed criteria

  • Environment variables documented in .env.example
  • .gitignore updated to exclude .env
  • Build configuration is valid

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js added to package.json
PostHog client initialized Yes Correctly initialized in instrumentation-client.ts using posthog.init() with env vars — the recommended Next.js pattern
capture() Yes Multiple meaningful posthog.capture() calls across dashboard pages
identify() Yes posthog.identify() called with user.id.toString() and person properties (email, name, role). posthog.reset() called on sign-out. Uses a stable ID from the database.
Error tracking Yes capture_exceptions: true in init config, plus global-error.tsx with posthog.captureException()
Reverse proxy No No Next.js rewrites or middleware proxy configured. PostHog docs recommend setting up a reverse proxy for Next.js apps.

Issues

  • No reverse proxy configured: The next.config.ts has no rewrites for PostHog. Client-side requests go directly to us.i.posthog.com, making them susceptible to ad blockers. Add Next.js rewrites or use the managed reverse proxy. [MEDIUM]
  • No posthog-node for server-side capture: The checkout route uses OTel logs instead of posthog-node capture(). These logs won't generate PostHog events for funnels/insights. For a full-stack Next.js app, posthog-node should be used for server-side event capture. [MEDIUM]

Other completed criteria

  • API key loaded from NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN environment variable
  • API host loaded from NEXT_PUBLIC_POSTHOG_HOST environment variable
  • PostHog initialized before any capture calls via instrumentation-client.ts
  • posthog.reset() correctly called on logout

PostHog insights and events ✅

Filename PostHog events Description
instrumentation-client.ts autocapture, `` Client SDK initialized with autocapture and exception tracking
app/(dashboard)/layout.tsx identify, reset User identification on load, reset on sign-out
app/(dashboard)/dashboard/general/page.tsx account_update_submitted Tracks account info form submissions
app/(dashboard)/dashboard/page.tsx subscription_management_opened, team_member_removal_submitted, team_invitation_submitted Tracks subscription and team management actions
app/(dashboard)/dashboard/security/page.tsx password_update_submitted, account_deletion_submitted Tracks security-related actions
app/(dashboard)/pricing/submit-button.tsx checkout_started Tracks checkout initiation
app/global-error.tsx captureException Captures unhandled errors
app/api/stripe/checkout/route.ts OTel logs only checkout_return_processing_started, checkout_subscription_activated, checkout_return_processing_failed — these are OTel logs, not PostHog events

Issues

  • Server-side "events" are OTel logs, not PostHog captures: The checkout route emits OpenTelemetry log records, not posthog.capture() events. While these may appear in PostHog's logs feature, they won't be usable in funnels, trends, or retention analysis. A checkout completion funnel (checkout_started → subscription activated) cannot be built with the current setup since checkout_started is a client event and checkout_subscription_activated is an OTel log. [MEDIUM]

Other completed criteria

  • Events represent real user actions (account updates, team management, checkout, security actions)
  • Events enable product insights (can build funnels for checkout, team management, security flows)
  • Event names are descriptive and use consistent snake_case convention
  • No PII in event properties — email/name correctly placed in identify() person properties
  • Events are captured in form onSubmit and button onClick handlers, not in useEffect

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