Skip to content

[CI] (0ae2102) next-js/15-pages-router-todo - #1228

Closed
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-0ae2102-next-js-15-pages-router-todo
Closed

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-0ae2102-next-js-15-pages-router-todo

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 0ae2102
App: next-js/15-pages-router-todo
App directory: apps/next-js/15-pages-router-todo
Workbench branch: wizard-ci-0ae2102-next-js-15-pages-router-todo
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-04-15T19:20:04.524Z
Duration: 253.6s

@wizard-ci-bot

wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown
Author

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


PR Evaluation Report

Summary

This PR integrates PostHog into a Next.js 15 Pages Router todo application. It adds both client-side (posthog-js) and server-side (posthog-node) SDKs, initializes the client via instrumentation-client.ts, configures a reverse proxy via Next.js rewrites, and adds event captures for all CRUD operations on todos. Error tracking is implemented via captureException in catch blocks and capture_exceptions: true in the init config.

Files changed Lines added Lines removed
9 +149 -0

Confidence score: 4/5 👍

  • No identify() call anywhere: The app has no user identification — posthog.identify() is never called. While the app lacks an auth system, this is still a gap for a "full-stack" integration. N/A given no auth exists, but worth noting.
  • Server-side fallback to literal 'anonymous' string: All server-side captures use distinctId: distinctId ?? 'anonymous', meaning all requests without the header map to a single "anonymous" user. This merges all anonymous server-side events into one person profile, creating data quality issues. [CRITICAL]
  • No .env.example file committed: .env.local is gitignored but no .env.example documents the required environment variables for other developers. [MEDIUM]
  • Server-side host reads NEXT_PUBLIC_POSTHOG_HOST but client uses /ingest: The server-side client reads process.env.NEXT_PUBLIC_POSTHOG_HOST which is set to https://us.i.posthog.com — this is correct for server-to-server communication. However, the init uses NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN (non-standard env var name) consistently, so this is acceptable.

File changes

Filename Score Description
instrumentation-client.ts 4/5 Correctly initializes posthog-js with reverse proxy, exception autocapture, defaults, and debug mode. Uses the recommended Next.js 15.3+ pattern.
next.config.ts 5/5 Proper reverse proxy rewrites for /ingest to PostHog cloud, including static assets. skipTrailingSlashRedirect added correctly.
lib/posthog-server.ts 4/5 Singleton pattern with flushAt: 1 and flushInterval: 0 for short-lived API routes. Includes shutdown helper.
components/todos/todo-list.tsx 3/5 Captures all CRUD events with properties. Passes distinct_id header to server. Uses captureException in catch blocks. However, directly imports posthog from posthog-js rather than using a hook/provider pattern.
pages/api/todos/index.ts 3/5 Server-side capture on todo creation. Falls back to 'anonymous' literal string which is problematic.
pages/api/todos/[id].ts 3/5 Server-side capture on update/delete. Same 'anonymous' fallback issue.
package.json 5/5 Both posthog-js and posthog-node added with appropriate versions.
.gitignore 5/5 .env.local properly gitignored.
posthog-setup-report.md 4/5 Comprehensive setup report with event table and dashboard suggestions.

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes No syntax errors; all imports resolve to valid packages and paths.
Preserves existing env vars & configs Yes Existing next.config.ts structure preserved; new rewrites added cleanly.
No syntax or type errors Yes TypeScript is valid; all new code uses proper types.
Correct imports/exports Yes posthog-js imported on client, posthog-node on server; no cross-environment imports.
Minimal, focused changes Yes All changes relate to PostHog integration; no scope creep.
Pre-existing issues None Base app is a clean todo app with no pre-existing issues.

Issues

  • No .env.example committed: .env.local is gitignored and contains the actual env vars, but there's no .env.example or equivalent documentation for required environment variables (NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN, NEXT_PUBLIC_POSTHOG_HOST). The setup report mentions them but a committed example file is the standard pattern. [MEDIUM]

Other completed criteria

  • Build configuration is valid — package.json has proper scripts and dependencies
  • All changes are relevant to PostHog integration
  • Code follows existing codebase patterns (TypeScript, consistent formatting)
  • No unnecessary modifications to existing code

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js@^1.369.0 and posthog-node@^5.29.2 added to package.json.
PostHog client initialized Yes Initialized in instrumentation-client.ts using the recommended Next.js 15.3+ pattern with posthog.init(). Server client uses singleton pattern in lib/posthog-server.ts.
capture() Yes Client-side captures for todo created, todo completed, todo reopened, todo deleted. Server-side captures mirror these.
identify() N/A App has no authentication system, so there's no opportunity to call identify().
Error tracking Yes capture_exceptions: true in init config enables automatic exception capture. Manual posthog.captureException(error) calls in all catch blocks.
Reverse proxy Yes Properly configured via Next.js rewrites in next.config.ts: /ingest → https://us.i.posthog.com and /ingest/static → https://us-assets.i.posthog.com. Client api_host set to /ingest.

Issues

  • Server-side distinctId falls back to literal 'anonymous': When the x-posthog-distinct-id header is missing, all server-side events use distinctId: 'anonymous'. This means every anonymous request merges into a single PostHog person profile, corrupting analytics data. The server should either skip the capture or use a per-request unique identifier. [CRITICAL]
  • API key loaded from env var with non-standard name: The env var is NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN instead of the more common NEXT_PUBLIC_POSTHOG_KEY or NEXT_PUBLIC_POSTHOG_TOKEN. This is functional but slightly non-conventional. [LOW]

Other completed criteria

  • API key loaded from environment variable (process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN)
  • Host correctly configured — client uses /ingest (reverse proxy), server uses process.env.NEXT_PUBLIC_POSTHOG_HOST pointing to https://us.i.posthog.com
  • ui_host set to https://us.posthog.com for toolbar access
  • Server client uses flushAt: 1 and flushInterval: 0 appropriate for short-lived API handlers

PostHog insights and events ⚠️

Filename PostHog events Description
components/todos/todo-list.tsx todo created, todo completed, todo reopened, todo deleted, captureException Client-side CRUD event tracking with properties (todo_id, has_description). Exception capture in all error handlers.
pages/api/todos/index.ts todo created Server-side capture on POST with todo_id, has_description, source: 'api' properties.
pages/api/todos/[id].ts todo updated, todo deleted Server-side capture on PATCH/DELETE with todo_id, completed, source: 'api' properties.
instrumentation-client.ts Autocapture, captureException (automatic) Automatic pageviews, clicks, and exception autocapture via capture_exceptions: true.

Issues

  • Duplicate event names between client and server: Both client and server capture todo created and todo deleted events. While the server events include source: 'api', the client events don't include a source property, making deduplication in analytics harder. This could lead to double-counting in dashboards. [MEDIUM]

Other completed criteria

  • Events represent real user actions (create, complete, reopen, delete todos)
  • Events enable product insights — can build funnels (created → completed), trends, and lifecycle analysis
  • Events include relevant properties (todo_id, has_description, completed, source)
  • No PII in event properties — only todo IDs and boolean flags
  • Event names are descriptive and consistently use todo <action> 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