Skip to content

[CI] (7c90ff9) next-js/15-pages-router-todo#150

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

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

Conversation

@wizard-ci-bot
Copy link

@wizard-ci-bot wizard-ci-bot bot commented Jan 14, 2026

Automated wizard CI run

Trigger ID: 7c90ff9
App: next-js/15-pages-router-todo
App directory: apps/next-js/15-pages-router-todo
Workbench branch: wizard-ci-7c90ff9-next-js-15-pages-router-todo
Wizard branch: feat-skill-based-integration
Examples branch: rearchitect-generator
PostHog (MCP) branch: feat-mcp-skill-deployment
Timestamp: 2026-01-14T21:14:14.709Z
Duration: 272.8s

@wizard-ci-bot
Copy link
Author

wizard-ci-bot bot commented Jan 14, 2026

Now I have all the information needed to write a comprehensive PR evaluation. Let me analyze the issues:


PR Evaluation Report

Summary

This PR integrates PostHog analytics into a Next.js 15 Pages Router todo application. It adds client-side event tracking for todo CRUD operations, server-side API error tracking, and configures a reverse proxy to bypass ad blockers. The implementation uses instrumentation-client.ts for initialization, but the client-side PostHog SDK is never actually loaded because the Pages Router doesn't automatically import this file.

Files changed Lines added Lines removed
9 +561 -2

Confidence score: 2/5 ❌

  • Client-side PostHog initialization is broken: The instrumentation-client.ts file is created but never imported anywhere. In Pages Router, you must import this in _app.tsx or use a custom provider component. PostHog will NOT be initialized on the client, and all posthog.capture() calls in todo-list.tsx will fail silently or throw errors. [CRITICAL]
  • Server-side distinctId is hardcoded to 'server': All API error events use distinctId: 'server', making it impossible to correlate server errors with specific users. Should use a request-based identifier or anonymous ID. [MEDIUM]
  • No automatic pageview tracking configured: The instrumentation-client.ts doesn't enable capture_pageview or capture_pageleave, missing automatic page view tracking. [MEDIUM]

File changes

Filename Score Description
components/todos/todo-list.tsx 2/5 Adds PostHog import and capture calls for todo CRUD events, but will fail at runtime since PostHog is never initialized
instrumentation-client.ts 2/5 New file with PostHog initialization code, but uses defaults option which is invalid for posthog-js. File is never imported in Pages Router
lib/posthog-server.ts 3/5 Proper singleton pattern for server-side PostHog client. Uses aggressive flush settings (flushAt: 1, flushInterval: 0) which may impact performance
next.config.ts 4/5 Correct reverse proxy configuration for PostHog with proper rewrite rules and skipTrailingSlashRedirect
package.json 5/5 Correctly adds posthog-js and posthog-node dependencies
pages/api/todos/[id].ts 3/5 Adds server-side error tracking, but uses hardcoded 'server' distinctId and doesn't await/flush the capture call
pages/api/todos/index.ts 3/5 Same issues as [id].ts - hardcoded distinctId and no awaiting of PostHog calls
pnpm-lock.yaml 5/5 Lock file properly updated with PostHog dependencies
posthog-setup-report.md 4/5 Good documentation of the integration, but claims .env.local setup which wasn't in the PR diff

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 Original app logic preserved, PostHog additions are additive
No syntax or type errors Partial defaults: '2025-05-24' is not a valid posthog-js config option
Correct imports/exports No instrumentation-client.ts is never imported in _app.tsx
Minimal, focused changes Yes Changes are focused on PostHog integration

Issues

  • Client initialization never loaded: The instrumentation-client.ts file exists but is never imported. In Next.js Pages Router, instrumentation-client.ts is NOT automatically loaded (that's an App Router feature). Must import in _app.tsx like: import '../instrumentation-client'. [CRITICAL]
  • Invalid posthog-js config option: The defaults: '2025-05-24' option doesn't exist in posthog-js. This should be removed or replaced with valid options. [MEDIUM]
  • No pageview tracking: Missing capture_pageview: true in PostHog config to enable automatic page view tracking. [MEDIUM]

Other completed criteria

  • Build compiles successfully
  • TypeScript types are correct
  • Existing functionality preserved
  • Lock file properly updated

PostHog implementation: 2/5 ❌

Criteria Result Description
PostHog SDKs installed Yes posthog-js ^1.321.2 and posthog-node ^5.21.0 added to package.json
PostHog client initialized No instrumentation-client.ts exists but is never imported in Pages Router - initialization code will never execute
capture() Partial Client-side capture calls exist but will fail since PostHog isn't initialized. Server-side calls work but aren't awaited
Identify() No No user identification implemented
Error tracking Partial capture_exceptions: true configured but won't work without initialization. Server-side error events exist
Reverse proxy Yes Properly configured in next.config.ts with rewrites to /ingest path

Issues

  • PostHog never initialized on client: The instrumentation-client.ts file is not imported anywhere. In Pages Router, you must explicitly import it in _app.tsx. All client-side tracking will fail. [CRITICAL]
  • Server-side captures not awaited: PostHog capture calls in API routes are not awaited, meaning events may be lost if the serverless function terminates before flushing. Should use await posthog.capture() or call await posthog.flush() before returning. [MEDIUM]
  • Hardcoded distinctId: Server-side events use distinctId: 'server' instead of deriving from request context. Cannot correlate errors with users. [MEDIUM]
  • Invalid defaults option: The defaults: '2025-05-24' is not a valid posthog-js configuration option and will be ignored or cause issues. [LOW]

Other completed criteria

  • Correct API host configuration via reverse proxy (/ingest)
  • ui_host correctly set to https://us.posthog.com
  • Debug mode enabled in development
  • Server-side singleton pattern implemented correctly
  • Environment variables documented

PostHog insights and events: 3/5 ⚠️

Filename PostHog events Description
todo-list.tsx todo created, todo completed, todo uncompleted, todo deleted Core CRUD events that would enable funnel analysis and user engagement tracking - but won't fire without initialization
pages/api/todos/index.ts api error Server-side error tracking for GET and POST failures on /api/todos
pages/api/todos/[id].ts api error Server-side error tracking for GET, PATCH, DELETE failures on individual todos

Issues

  • Events enriched but not firing: The event properties (todo_id, has_description, endpoint, method) are well-chosen for analysis, but client-side events won't actually fire due to initialization failure. [CRITICAL]
  • No success tracking on server: Only errors are tracked server-side. Could add todo created server-side event for more reliable tracking. [LOW]
  • No timing/duration properties: Events don't capture timing information that would help identify performance issues. [LOW]

Other completed criteria

  • Events follow good naming conventions (lowercase, descriptive)
  • Event properties are non-PII (only IDs, not user data)
  • Events capture actionable user behaviors
  • Good coverage of CRUD operations

Reviewed by wizard workbench PR evaluator

@wizard-ci-bot wizard-ci-bot bot added the CI/CD label Jan 14, 2026
@wizard-ci-bot wizard-ci-bot bot closed this Jan 14, 2026
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