-
Notifications
You must be signed in to change notification settings - Fork 0
[CI] (afd8cc2) next-js/15-pages-router-todo #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Evaluation ReportSummaryThis PR integrates PostHog analytics into a Next.js 15 Pages Router todo application. It adds client-side initialization via
Confidence score: 3/5 🤔
File changes
App sanity check: 3/5
|
| Criteria | Result | Description |
|---|---|---|
| App builds and runs | Likely No | The instrumentation-client.ts approach won't work for Pages Router without explicit import |
| Preserves existing env vars & configs | Yes | Only adds new config, doesn't remove existing settings |
| No syntax or type errors | Yes | Code is syntactically correct TypeScript |
| Correct imports/exports | Yes | All imports are valid and properly structured |
| Minimal, focused changes | Yes | Changes are focused on PostHog integration only |
Issues
- Client initialization won't auto-load:
instrumentation-client.tsis an App Router pattern. Pages Router requires PostHog initialization inpages/_app.tsxor imported at the entry point. PostHog client will not be initialized when the app runs. [CRITICAL] - Missing
.envfile: The setup report claims.envwas created, but it's not included in the PR diff. Users won't know required env vars at runtime. [MEDIUM] - Redundant PostHog client instantiation: In
pages/api/todos/[id].tsline 74,getPostHogClient()is called again whenposthogis already in scope from line 39. [LOW]
Other completed criteria
- TypeScript types are properly used throughout
- Zod validation preserved in API routes
- No PII exposed in event properties
- Existing app logic (todo CRUD) unchanged
- Import statements are correct
PostHog implementation: 3/5 ⚠️
| Criteria | Result | Description |
|---|---|---|
| PostHog SDKs installed | Yes | posthog-js@^1.325.0 and posthog-node@^5.21.0 added to package.json |
| PostHog client initialized | Partial | Client config exists but won't auto-load in Pages Router |
| capture() | Yes | Multiple capture calls for todo events on client and server |
| identify() | No | No user identification implemented - server uses 'anonymous' fallback |
| Error tracking | Yes | captureException() on client, api_error events on server |
| Reverse proxy | Yes | Properly configured in next.config.ts with rewrites to /ingest |
Issues
- Initialization pattern incompatible with Pages Router: The
instrumentation-client.tsfile is the correct approach for App Router (Next.js 15.3+), but this is a Pages Router app (pages/directory). PostHog needs to be initialized in_app.tsxor via a provider. Without this, no client-side events will be captured. [CRITICAL] - No
posthog.identify()calls: User identification is completely absent. Server-side events fall back to 'anonymous' distinctId, and client events have no user linking. This limits analytics value significantly. [MEDIUM] - Server host configuration inconsistency: Server-side client uses
NEXT_PUBLIC_POSTHOG_HOSTenvironment variable while client uses/ingestproxy. Server should either use the proxy endpoint or explicitly define the host. [MEDIUM] defaults: '2025-05-24'is unusual: This option format appears non-standard for posthog-js. It may be ignored or cause issues. [LOW]
Other completed criteria
capture_exceptions: trueenabled for automatic error tracking- Debug mode enabled in development
- Proper API host pointing to proxy (
/ingest) - UI host correctly set to
https://us.posthog.com - Server-side singleton pattern prevents multiple client instantiations
- Shutdown function provided for graceful cleanup
PostHog insights and events: 4/5 ✅
| Filename | PostHog events | Description |
|---|---|---|
todo-list.tsx |
todo_created, todo_completed, todo_uncompleted, todo_deleted, captureException |
Client-side tracking of all user actions with todo_id property. Exception capture on errors. |
pages/api/todos/index.ts |
server_todo_created, api_error |
Server-side creation tracking with has_description property. Validation and server errors tracked. |
pages/api/todos/[id].ts |
server_todo_updated, server_todo_deleted, api_error |
Server-side update/delete tracking with updated_fields and is_completion_change properties. |
Issues
- No pageview tracking: Automatic pageview capture is not configured. Without initialization working, pageviews won't be tracked anyway. [MEDIUM]
- Duplicate event tracking: Both client and server capture similar events (e.g.,
todo_createdandserver_todo_created). This may cause confusion in analytics unless intentional for client/server comparison. [LOW] - No
orfor user properties: Events lack user property enrichment that would enable cohort analysis. [LOW]
Other completed criteria
- Events represent real user actions (create, complete, delete todos)
- Events enriched with relevant properties (todo_id, has_description, updated_fields)
- Error events include error_type, endpoint, method, and error_message
- Events can build funnels (creation → completion → deletion lifecycle)
- API error monitoring enables reliability tracking
- Source property distinguishes API vs client events
Reviewed by wizard workbench PR evaluator
Automated wizard CI run
Source: manual
Trigger ID:
afd8cc2App:
next-js/15-pages-router-todoApp directory:
apps/next-js/15-pages-router-todoWorkbench branch:
wizard-ci-afd8cc2-next-js-15-pages-router-todoWizard branch:
mainExamples branch:
mainPostHog (MCP) branch:
masterTimestamp: 2026-01-16T13:58:25.115Z
Duration: 245.9s