Skip to content

[CI] (359d82a) next-js/15-app-router-todo - #2459

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

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

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 everything I need to evaluate this PR.


PR Evaluation Report

Summary

This PR integrates PostHog into a Next.js 15 App Router todo application. It adds client-side initialization via instrumentation-client.ts, server-side tracking via posthog-node, a reverse proxy via Next.js rewrites, and custom event captures for todo CRUD operations on both client and server. Exception autocapture is enabled via capture_exceptions: true.

Files changed Lines added Lines removed
9 +137 -1

Confidence score: 4/5 👍

  • No user identification implemented: The app has no posthog.identify() call anywhere. While this is a simple todo app without auth, the docs are explicit that identifying users is required. The server-side fallback to 'anonymous' as a hardcoded distinctId is particularly problematic — it will merge all unauthenticated users into a single person profile. [CRITICAL]
  • No .env.example file created: The .env.local file is gitignored (correctly), but no .env.example was created to document NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN and NEXT_PUBLIC_POSTHOG_HOST for collaborators. The setup report itself acknowledges this as a todo item. [MEDIUM]
  • Hardcoded API key committed in .env.local: The .env.local file contains the full PostHog project token phc_nmum54dVqUBEAmNrWgHdnRF8HRSCVQhxL6kRhy4GCV6a. While .env.local is gitignored, this is a workbench/CI environment so the key is visible in the PR description context. [LOW]
  • posthog-server.ts uses singleton without shutdown: The server-side client uses a singleton pattern which is fine for long-lived processes, but none of the API routes call await posthog.shutdown() after capturing. Per the Next.js docs, server-side functions can be short-lived, so events may be lost. The flushAt: 1 and flushInterval: 0 settings mitigate this somewhat but shutdown() is still recommended. [MEDIUM]

File changes

Filename Score Description
instrumentation-client.ts 4/5 Client-side PostHog initialization using recommended Next.js 15.3+ pattern with reverse proxy host
lib/posthog-server.ts 3/5 Server-side PostHog singleton; missing shutdown calls in routes
next.config.ts 5/5 Reverse proxy rewrites correctly configured with /ingest prefix
package.json 5/5 Both posthog-js and posthog-node added as dependencies
components/todos/todo-list.tsx 4/5 Client-side event captures and exception tracking added to todo operations
app/api/todos/route.ts 3/5 Server-side todo_created capture; no shutdown call
app/api/todos/[id]/route.ts 3/5 Server-side todo_updated and todo_deleted captures; no shutdown call
.gitignore 5/5 .env.local correctly added to gitignore
posthog-setup-report.md 5/5 Comprehensive setup report with event table and dashboard links

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes No syntax errors, valid TypeScript, all imports resolve
Preserves existing env vars & configs Yes Existing app logic preserved; only PostHog additions made
No syntax or type errors Yes All code is syntactically valid
Correct imports/exports Yes posthog-js on client, posthog-node on server — correct separation
Minimal, focused changes Yes All changes relate to PostHog integration
Pre-existing issues None Base app appears functional

Issues

  • No .env.example file: Environment variables NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN and NEXT_PUBLIC_POSTHOG_HOST are not documented in any example file. New contributors won't know what to set. [MEDIUM]

Other completed criteria

  • Build configuration is valid — package.json scripts intact, new dependencies properly added
  • Existing functionality preserved — todo CRUD operations unchanged, PostHog additions are additive

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 instrumentation-client.ts uses posthog.init() with env var token and /ingest reverse proxy host — correct Next.js 15.3+ pattern
capture() Yes Multiple meaningful capture() calls on both client and server for todo CRUD operations
identify() No No posthog.identify() call anywhere in the codebase. Server-side routes fall back to 'anonymous' string as distinctId, which merges all unauthenticated users into one person
Error tracking Yes capture_exceptions: true enabled in init config; posthog.captureException(error) called in catch blocks
Reverse proxy Yes Next.js rewrites correctly route /ingest/static/* and /ingest/array/* to us-assets.i.posthog.com and /ingest/* to us.i.posthog.com

Issues

  • No identify() implementation: No posthog.identify() is called anywhere. The docs state "Identifying users is required." While this todo app may lack auth, the server-side fallback to the hardcoded string 'anonymous' as distinctId will cause all unauthenticated server events to be attributed to one person, creating data quality issues. Even without auth, the client posthog.get_distinct_id() header should be used exclusively (and is — but the ?? 'anonymous' fallback is problematic). [CRITICAL]
  • No posthog.shutdown() in API routes: Per the Next.js docs, server-side functions can be short-lived. The singleton pattern with flushAt: 1 partially mitigates this, but shutdown() should still be called. Events could be lost in serverless/edge environments. [MEDIUM]
  • ui_host uses wrong domain: ui_host is set to 'https://us.posthog.com' but should be 'https://us.posthog.com' — actually this is correct for the PostHog UI. No issue. [LOW]

Other completed criteria

  • API key loaded from NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN environment variable — not hardcoded in source
  • API host correctly configured via reverse proxy at /ingest
  • Both client and server SDKs properly separated — posthog-js only in client components, posthog-node only in server code
  • Reverse proxy correctly routes both /ingest/static/* and /ingest/array/* to the assets origin

PostHog insights and events ⚠️

Filename PostHog events Description
components/todos/todo-list.tsx todo_created, todo_completed, todo_uncompleted, todo_deleted, captureException Client-side captures for all CRUD operations with todo_id and has_description properties. Exception tracking in all catch blocks.
app/api/todos/route.ts todo_created Server-side capture with todo_id, has_description, and `` properties
app/api/todos/[id]/route.ts todo_updated, todo_deleted Server-side captures with todo_id, completed status, and `` properties
instrumentation-client.ts autocapture, captureException (global) capture_exceptions: true enables global exception autocapture

Issues

  • Duplicate events on client and server: todo_created and todo_deleted are captured on both client and server for the same action. This leads to double-counting in funnels and trends. Typically, you'd capture on one side or the other, not both. [MEDIUM]

Other completed criteria

  • Events represent real user actions — creating, completing, uncompleting, and deleting todos map to actual product flows
  • Events enable product insights — can build a create→complete funnel, track task churn (deletions vs creations), measure completion rates
  • Events include relevant properties — todo_id, has_description, completed status provide context
  • No PII in event properties — only IDs and boolean flags
  • Event names are descriptive and consistent — snake_case convention used throughout (todo_created, todo_completed, 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