Skip to content

[CI] (a5131dd) next-js/15-pages-router-todo - #2473

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

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

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: a5131dd
App: next-js/15-pages-router-todo
App directory: apps/next-js/15-pages-router-todo
Workbench branch: wizard-ci-a5131dd-next-js-15-pages-router-todo
Wizard branch: fix/warlock-smoke-test-remove-killswitch
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-07-07T21:45:40.097Z
Duration: 401.0s

YARA Scanner

✓ 42 tool calls scanned, 0 violations detected

No violations: ✓ 42 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown
Author

Now I have enough context. Let me produce the evaluation.


PR Evaluation Report

Summary

This PR integrates PostHog into a Next.js 15 Pages Router todo application, adding both client-side (posthog-js via instrumentation-client.ts) and server-side (posthog-node) analytics. It includes a reverse proxy configuration, custom event captures for CRUD operations on todos, exception tracking, and server-side event capture in API routes.

Files changed Lines added Lines removed
9 +129 -2

Confidence score: 4/5 👍

  • No user identification implemented: There are no posthog.identify() or posthog.reset() calls anywhere in the codebase. The docs explicitly state "Identifying users is required." This is a significant gap for linking events to known users. [CRITICAL]
  • No .env.example file: The PR adds .env.local to .gitignore but does not create a .env.example to document required environment variables (NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN, NEXT_PUBLIC_POSTHOG_HOST). The setup report even calls this out as a TODO. [MEDIUM]
  • Server-side events never call shutdown(): The getPostHogClient() singleton is used in API routes but posthog.shutdown() is never called after capturing. In Next.js pages router API routes (which are short-lived), events may be lost despite flushAt: 1 and flushInterval: 0 since the process can terminate before the async flush completes. [MEDIUM]

File changes

Filename Score Description
instrumentation-client.ts 4/5 New file initializing posthog-js with reverse proxy, exception capture, and env vars
lib/posthog-server.ts 3/5 Server-side PostHog singleton — correct pattern but missing shutdown calls at usage sites
next.config.ts 5/5 Reverse proxy rewrites properly configured with static/array/catch-all routes
components/todos/todo-list.tsx 4/5 Good event captures and exception tracking in all CRUD handlers
pages/api/todos/[id].ts 3/5 Server-side events added but no shutdown, fallback 'anonymous' distinct_id is problematic
pages/api/todos/index.ts 3/5 Same pattern as [id].ts with same issues
package.json 5/5 Both posthog-js and posthog-node added correctly
.gitignore 5/5 Properly ignores .env.local
posthog-setup-report.md 4/5 Informational setup report, not scored for integration quality

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes No syntax errors; imports are valid, TypeScript is correct
Preserves existing env vars & configs Yes Only adds PostHog-related rewrites and dependencies
No syntax or type errors Yes All files are syntactically valid TypeScript
Correct imports/exports Yes posthog-js imported client-side, posthog-node server-side — correct separation
Minimal, focused changes Yes All changes are PostHog-related
Pre-existing issues None Base app appears clean

Issues

  • No .env.example file: Required environment variables (NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN, NEXT_PUBLIC_POSTHOG_HOST) are not documented in any committed file. New developers won't know what to set. [MEDIUM]

Other completed criteria

  • All imports resolve correctly — posthog-js on client, posthog-node on server
  • Dependencies added to package.json with appropriate version ranges
  • Build configuration (next.config.ts) is valid with proper rewrite rules
  • Existing app code and functionality preserved

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js ^1.398.2 and posthog-node ^5.40.0 in package.json
PostHog client initialized Yes Correctly initialized in instrumentation-client.ts using the Next.js 15.3+ pattern
capture() Yes Multiple meaningful capture calls for todo CRUD operations on both client and server
identify() No No posthog.identify() call anywhere — no user identification implemented
Error tracking Yes capture_exceptions: true in init config + manual posthog.captureException() in all catch blocks
Reverse proxy Yes Properly configured via Next.js rewrites with /ingest/* routing to us.i.posthog.com and us-assets.i.posthog.com

Issues

  • No user identification: posthog.identify() is never called. The PostHog docs explicitly state this is required for linking frontend captures, session replays, and error tracking to known users. The app should call identify() when a user is known (e.g., on login/app load). [CRITICAL]
  • Server-side distinct_id fallback to 'anonymous': When x-posthog-distinct-id header is missing, the code falls back to the hardcoded string 'anonymous', which will merge all unauthenticated server events into a single person. This creates fragmented/merged data. [MEDIUM]
  • No posthog.shutdown() in API routes: Server-side capture calls don't await shutdown(). The docs warn: "Make sure to always call await client.shutdown() after sending events from the server-side." With the singleton pattern, shutdown() should be called per-request or await posthog.flush() should be used instead. [MEDIUM]

Other completed criteria

  • API key loaded from NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN environment variable — not hardcoded
  • Host configured correctly pointing to us.i.posthog.com via reverse proxy
  • Reverse proxy correctly routes /ingest/static/* and /ingest/array/* to us-assets.i.posthog.com
  • Client initialization follows the recommended instrumentation-client.ts pattern for Next.js 15.3+
  • Server-side client uses correct singleton pattern with flushAt: 1 and flushInterval: 0

PostHog insights and events ✅

Filename PostHog events Description
components/todos/todo-list.tsx todo_created, todo_completed, todo_uncompleted, todo_deleted, captureException Client-side CRUD events with properties (has_description, was_completed); exception tracking in all catch blocks
pages/api/todos/index.ts server_todo_created Server-side event on successful POST with has_description property
pages/api/todos/[id].ts server_todo_updated, server_todo_deleted Server-side events on successful PATCH and DELETE with completed property

Issues

No critical issues with event quality.

Other completed criteria

  • Events represent real user actions (create, complete, uncomplete, delete todos)
  • Events enable product insights — can build a create→complete funnel, track deletion patterns
  • Events include relevant properties (has_description, was_completed, completed)
  • No PII in event properties — only boolean flags and completion status
  • Event names are descriptive, consistent snake_case (todo_created, server_todo_updated, etc.)

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