Skip to content

[CI] (7f79337) next-js/15-pages-router-todo#331

Closed
wizard-ci-bot[bot] wants to merge 1 commit intomainfrom
wizard-ci-7f79337-next-js-15-pages-router-todo
Closed

[CI] (7f79337) next-js/15-pages-router-todo#331
wizard-ci-bot[bot] wants to merge 1 commit intomainfrom
wizard-ci-7f79337-next-js-15-pages-router-todo

Conversation

@wizard-ci-bot
Copy link

@wizard-ci-bot wizard-ci-bot bot commented Feb 12, 2026

Automated wizard CI run

Source: context-mill-pr
Trigger ID: 7f79337
App: next-js/15-pages-router-todo
App directory: apps/next-js/15-pages-router-todo
Workbench branch: wizard-ci-7f79337-next-js-15-pages-router-todo
Wizard branch: main
Context Mill branch: clarify-next-provider
PostHog (MCP) branch: master
Timestamp: 2026-02-12T21:00:35.666Z
Duration: 425.2s

@wizard-ci-bot
Copy link
Author

wizard-ci-bot bot commented Feb 12, 2026

Now I have all the information I need. Let me write my evaluation report:


PR Evaluation Report

Summary

This PR adds PostHog analytics integration to a Next.js 15 Pages Router todo application. It includes client-side event tracking for CRUD operations, server-side error tracking in API routes, a reverse proxy configuration to bypass ad blockers, and automatic exception capture. However, the implementation has a critical issue: instrumentation-client.ts is not imported or executed anywhere, making the client-side PostHog initialization non-functional.

Files changed Lines added Lines removed
10 +531 -2

Confidence score: 2/5 ❌

  • PostHog client never initialized: The instrumentation-client.ts file exists but is never imported. For Next.js Pages Router, PostHog must be initialized in _app.tsx or a custom component, not via instrumentation-client.ts which is an App Router feature. This means no client-side events will be captured. [CRITICAL]
  • No user identification: No posthog.identify() calls exist in the codebase, making all events anonymous with no way to tie them to specific users. [MEDIUM]
  • Missing pageview tracking: Without proper initialization, automatic pageviews won't be tracked. Additionally, the SPA router events are not being tracked for client-side navigation. [MEDIUM]

File changes

Filename Score Description
instrumentation-client.ts 2/5 Creates PostHog client initialization with correct config, but this file is never imported in Pages Router apps. It's an App Router pattern.
lib/posthog-server.ts 4/5 Proper singleton pattern for server-side PostHog client. Missing shutdown() calls in API routes.
next.config.ts 5/5 Correct reverse proxy rewrites for PostHog ingest endpoint to bypass ad blockers.
components/todos/todo-list.tsx 3/5 Adds posthog.capture() calls for CRUD events, but since PostHog is never initialized, these will fail silently or throw errors.
pages/api/todos/index.ts 4/5 Adds server-side error tracking for todo creation failures. Good pattern but uses 'anonymous' fallback for distinctId.
pages/api/todos/[id].ts 4/5 Adds server-side error tracking for update/delete failures. Same anonymous fallback pattern.
package.json 5/5 Correctly adds posthog-js and posthog-node dependencies.
.gitignore 5/5 Correctly ignores .env.local.
pnpm-lock.yaml 5/5 Lock file updated with PostHog dependencies.
posthog-setup-report.md 4/5 Good documentation but describes a setup that won't work as implemented.

App sanity check: 3/5 ⚠️

Criteria Result Description
App builds and runs Yes Build completes successfully with pnpm build
Preserves existing env vars & configs Yes Existing code preserved, new configs added
No syntax or type errors Yes TypeScript compilation passes
Correct imports/exports No instrumentation-client.ts is never imported anywhere
Minimal, focused changes Yes Changes are focused on PostHog integration

Issues

  • PostHog client import missing: instrumentation-client.ts is not imported in _app.tsx or any other file. In Pages Router, you must import the PostHog initialization in _app.tsx to ensure it runs. The current implementation will result in posthog calls failing or using an uninitialized client. [CRITICAL]
  • Missing .env.local in commit: The .env.local file is mentioned but not committed (correctly gitignored). However, no .env.example or documentation shows required env vars NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST. [LOW]

Other completed criteria

  • App structure preserved
  • No unnecessary file modifications
  • Clean, readable code additions
  • Consistent with existing patterns
  • Appropriate error handling added

PostHog implementation: 2/5 ❌

Criteria Result Description
PostHog SDKs installed Yes posthog-js@^1.347.0 and posthog-node@^5.24.15 added to package.json
PostHog client initialized No instrumentation-client.ts exists but is never imported. For Pages Router, initialization must be in _app.tsx.
capture() Partial Calls exist in todo-list.tsx but will fail without initialization
identify() No No posthog.identify() calls anywhere in the codebase
Error tracking Partial capture_exceptions: true set but won't work without initialization; server-side error tracking works
Reverse proxy Yes Correctly configured in next.config.ts with /ingest rewrites

Issues

  • Client-side PostHog never runs: The instrumentation-client.ts pattern is for Next.js App Router. For Pages Router, you need to import PostHog initialization in _app.tsx:
    import '@/instrumentation-client'; // Add this import
    Or initialize directly in _app.tsx. Without this, all client-side posthog.capture() calls will fail. [CRITICAL]
  • No user identification: No posthog.identify() calls exist. Users remain anonymous, limiting analytics value for user journey analysis. [MEDIUM]
  • Server-side client never shutdown: shutdownPostHog() is exported but never called. In serverless environments, this can cause event loss. Consider using flushAt: 1 (already set) or ensuring flush happens. [LOW]

Other completed criteria

  • API key via environment variable (not hardcoded)
  • capture_exceptions: true for error tracking (when initialized)
  • Debug mode in development
  • Reverse proxy with correct PostHog US endpoints
  • Server-side singleton pattern

PostHog insights and events: 3/5 ⚠️

Filename PostHog events Description
todo-list.tsx todo_created, todo_completed, todo_uncompleted, todo_deleted, captureException Tracks full CRUD lifecycle with relevant properties (todo_id, has_description)
pages/api/todos/index.ts todo_create_failed Server-side error tracking with error message and source
pages/api/todos/[id].ts todo_update_failed, todo_delete_failed Server-side error tracking with todo_id, error message, and source

Issues

  • Events won't fire client-side: Since PostHog is not initialized, client-side events (todo_created, todo_completed, etc.) won't actually be captured. [CRITICAL]
  • No pageview tracking: Missing SPA page navigation tracking. For Pages Router, you'd want to track route changes. [MEDIUM]
  • Limited event properties: Events could include more context like todo_title_length, timestamp, or session_id. [LOW]

Other completed criteria

  • Events represent meaningful user actions (create, complete, delete)
  • Good event naming convention (todo_* prefix)
  • Server-side error events include error context
  • has_description property useful for understanding user behavior
  • Distinct events for completion vs uncompletion

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