Skip to content

[CI] (359d82a) next-js/15-pages-router-todo - #2457

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

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-359d82a-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: 359d82a
App: next-js/15-pages-router-todo
App directory: apps/next-js/15-pages-router-todo
Workbench branch: wizard-ci-359d82a-next-js-15-pages-router-todo
Wizard branch: chore/bump-warlock-0.2.3
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-07-07T20:21:36.748Z
Duration: 436.7s

YARA Scanner

✓ 37 tool calls scanned, 0 violations detected

No violations: ✓ 37 clean scans

@wizard-ci-bot

wizard-ci-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown
Author

Now I have all the information I need to produce the evaluation.


PR Evaluation Report

Summary

This PR integrates PostHog into a Next.js 15 Pages Router todo app, adding both client-side (posthog-js) and server-side (posthog-node) SDKs. It initializes PostHog via instrumentation-client.ts, configures a reverse proxy through Next.js rewrites, captures CRUD events on both client and server, and includes exception handling. However, it lacks user identification (identify/reset), has no .env.example for documenting env vars, and the server-side client never calls shutdown().

Files changed Lines added Lines removed
9 +147 -0

Confidence score: 4/5 👍

  • No posthog.identify() or posthog.reset() calls anywhere in the app — events are all anonymous on the client side, and the server falls back to 'anonymous' string as distinct_id, which causes all unauthenticated users to merge into one person. [CRITICAL]
  • No .env.example file committed — .env.local is gitignored (correctly), but there is no .env.example or equivalent to document the required NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN and NEXT_PUBLIC_POSTHOG_HOST env vars for other developers. [MEDIUM]
  • Server-side PostHog client never calls shutdown() — the singleton posthog-node client in Pages Router API routes never flushes; with flushAt: 1 this mostly works but is not guaranteed, and the docs explicitly recommend calling shutdown(). [MEDIUM]

File changes

Filename Score Description
instrumentation-client.ts 4/5 Initializes posthog-js with reverse proxy host, exception capture, and defaults. Clean implementation.
next.config.ts 5/5 Correct reverse proxy rewrites for /ingest/*, /ingest/static/*, and /ingest/array/* with proper asset host routing.
lib/posthog-server.ts 3/5 Singleton server client with flushAt: 1, flushInterval: 0. No shutdown() call pattern.
components/todos/todo-list.tsx 4/5 Good client-side event captures with properties, exception handling, and tracing headers. No identify calls.
pages/api/todos/index.ts 3/5 Server-side server_todo_created capture. Falls back to 'anonymous' string as distinct_id. No shutdown.
pages/api/todos/[id].ts 3/5 Server-side server_todo_updated and server_todo_deleted captures. Same issues as above.
package.json 5/5 Both posthog-js and posthog-node added correctly.
.gitignore 5/5 Correctly ignores .env.local.
posthog-setup-report.md N/A Documentation file, not evaluated for code quality.

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes No syntax errors; all imports resolve to installed packages
Preserves existing env vars & configs Yes Existing next.config.ts structure preserved; rewrites added cleanly
No syntax or type errors Yes All TypeScript is valid; ! assertions used appropriately for env vars
Correct imports/exports Yes posthog-js imported client-side, posthog-node server-side; no cross-environment contamination
Minimal, focused changes Yes All changes relate to PostHog integration
Pre-existing issues None Base app appears functional

Issues

  • No .env.example file: The .env.local is gitignored but no .env.example is committed to document the required environment variables (NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN, NEXT_PUBLIC_POSTHOG_HOST). The setup report mentions this as a TODO but doesn't resolve it. [MEDIUM]

Other completed criteria

  • Build configuration is valid — package.json has correct dependency entries
  • All changes are relevant to PostHog integration
  • Code follows existing codebase patterns (TypeScript, consistent formatting)

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js@^1.398.2 and posthog-node@^5.40.0 added to package.json
PostHog client initialized Yes instrumentation-client.ts calls posthog.init() with env var token and /ingest proxy host — correct Next.js 15 pattern
capture() Yes Client: todo_created, todo_completed, todo_uncompleted, todo_deleted. Server: server_todo_created, server_todo_updated, server_todo_deleted
identify() No No posthog.identify() or posthog.reset() calls anywhere. The docs state "Identifying users is required."
Error tracking Yes capture_exceptions: true in init config, plus manual posthog.captureException(error) in catch blocks
Reverse proxy Yes Next.js rewrites correctly proxy /ingest/* to us.i.posthog.com and /ingest/static/*, /ingest/array/* to us-assets.i.posthog.com

Issues

  • No user identification: There are zero calls to posthog.identify() or posthog.reset() in the entire codebase. Per PostHog docs, "Identifying users is required" to connect frontend events, session replays, and error tracking to the same person. Without this, all analytics are anonymous. [CRITICAL]
  • Server-side fallback to 'anonymous' string: When no X-POSTHOG-DISTINCT-ID header is present, the server code uses the literal string 'anonymous' as distinctId. This merges all unauthenticated requests into a single PostHog person, corrupting data. It should either use the anonymous distinct_id from the header or skip server capture. [MEDIUM]
  • No shutdown() on server-side client: The singleton posthog-node client is never shut down after API route handling. The docs recommend await posthog.shutdown() to ensure all events are flushed. With flushAt: 1 the events likely flush immediately, but this is not guaranteed. [MEDIUM]

Other completed criteria

  • API key loaded from NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN environment variable (not hardcoded)
  • Host correctly configured via /ingest reverse proxy with ui_host set to https://us.posthog.com
  • Both client and server SDKs correctly installed and initialized in appropriate contexts
  • Tracing headers (X-POSTHOG-DISTINCT-ID, X-POSTHOG-SESSION-ID) manually passed from client to server for session correlation

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 actions with todo_id and has_description properties. Exception capture in all error handlers.
pages/api/todos/index.ts server_todo_created Server-side creation event with todo_id and has_description properties
pages/api/todos/[id].ts server_todo_updated, server_todo_deleted Server-side update/delete events with todo_id and completed status

Issues

  • No issues with event quality — events are well-named, map to real user actions, and include relevant properties.

Other completed criteria

  • Events represent real user actions (create, complete, uncomplete, delete todos)
  • Events enable product insights — can build create→complete funnels, deletion trends, completion rates
  • Events include relevant properties (todo_id, has_description, completed)
  • No PII in event properties
  • Event names are descriptive and use consistent snake_case 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