[CI] (tune-mini-xhigh) next-js/15-app-router-saas#2407
Closed
wizard-ci-bot[bot] wants to merge 1 commit into
Closed
[CI] (tune-mini-xhigh) next-js/15-app-router-saas#2407wizard-ci-bot[bot] wants to merge 1 commit into
wizard-ci-bot[bot] wants to merge 1 commit into
Conversation
Author
PR Evaluation ReportSummaryThis PR adds PostHog integration to a Next.js 15 App Router SaaS application. It installs both
Confidence score: 3/5 🤔
File changes
App sanity check
|
| Criteria | Result | Description |
|---|---|---|
| App builds and runs | Yes | No syntax or type errors that would prevent build |
| Preserves existing env vars & configs | Yes | Existing code and configs untouched |
| No syntax or type errors | Yes | Code is syntactically valid |
| Correct imports/exports | Yes | All imports resolve correctly |
| Minimal, focused changes | No | Non-functional /api/posthog/capture endpoint adds dead code; posthog-js installed but unused |
| Pre-existing issues | None | No pre-existing issues noted |
Issues
- Non-functional capture endpoint:
/api/posthog/capture/route.tsparses the request body then discards it, returning{ ok: true }. This creates a false impression that client-side events are being captured. Either forward events to PostHog or remove this endpoint and useposthog-jsdirectly. [CRITICAL] - posthog-js installed but unused: The package is in
package.jsonbut never imported or initialized. This is dead weight. [MEDIUM] - Redundant double try/catch: In
actions.ts, sign-in, sign-up, and sign-out captures are wrapped in two nested try/catch blocks catching the same error — the outer catch is unreachable. [LOW] - .env.example not updated: PostHog environment variables (
NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN,NEXT_PUBLIC_POSTHOG_HOST) are not documented in.env.example. [MEDIUM]
Other completed criteria
- App builds without errors
- Existing app code and configs preserved
- No syntax or type errors introduced
- All imports resolve correctly
PostHog implementation ❌
| Criteria | Result | Description |
|---|---|---|
| PostHog SDKs installed | Yes | posthog-js and posthog-node added to package.json |
| PostHog client initialized | No | Server-side singleton exists but posthog-js is never initialized — no instrumentation-client.ts, no PostHogProvider, no posthog.init() |
| capture() | Yes | Multiple server-side capture() calls for auth and Stripe events (client-side captures are broken) |
| identify() | No | No posthog.identify() calls anywhere; no posthog.reset() on logout |
| Error tracking | No | No captureException(), no error boundary, no exception autocapture |
| Reverse proxy | No | No reverse proxy configured in next.config.ts |
Issues
- Missing client-side initialization: Per Next.js docs, PostHog should be initialized via
instrumentation-client.tswithposthog.init(), and optionally wrapped in aPostHogProviderfor React hooks. Neither exists. Without client-side initialization, autocapture (pageviews, clicks) is completely absent. [CRITICAL] - No user identification:
posthog.identify()is never called — not on login, not on page load for returning users. Server-side captures use database IDs asdistinctId, but these are never linked to client-side anonymous sessions. [CRITICAL] - No error tracking: No
PostHogErrorBoundary, nocaptureException(), nocapture_exceptions: truein init config. [MEDIUM] - No reverse proxy: Recommended for Next.js to avoid ad blockers. No rewrites configured. [MEDIUM]
- Inconsistent client instantiation:
lib/payments/stripe.tscreates a newPostHoginstance withnew PostHog(...)instead of using thegetPostHogClient()singleton, leading to potential connection overhead and inconsistency. [LOW] - Missing shutdown() on singleton: The singleton
posthogClientinposthog-server.tsis never shut down after captures inactions.tsorcheckout/route.ts. In short-lived Next.js server functions, events may be lost. [LOW]
Other completed criteria
- Both PostHog SDKs added to dependencies
- API key loaded from environment variable (
NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN) - Host correctly configured via environment variable (
NEXT_PUBLIC_POSTHOG_HOST)
PostHog insights and events ⚠️
| Filename | PostHog events | Description |
|---|---|---|
app/(login)/actions.ts |
user_signed_up, user_signed_in, user_signed_out |
Server-side auth lifecycle events with email in properties (PII concern) |
app/api/stripe/checkout/route.ts |
checkout_completed |
Captures successful Stripe checkout with subscription details |
app/api/stripe/webhook/route.ts |
subscription_webhook_received |
Captures subscription changes from Stripe webhooks; uses Stripe customer ID as distinctId |
lib/payments/stripe.ts |
manage_subscription_clicked |
Captures portal access; uses team.id as distinctId (not a user ID) |
app/(dashboard)/dashboard/page.tsx |
team_member_removed |
Non-functional — sends to dead endpoint that discards events |
Issues
- PII in event properties:
user_signed_inanduser_signed_upincludeemaildirectly incapture()properties. Per PostHog best practices, email should be set via person properties (``) in anidentify()call, not in event properties. [MEDIUM] - Setup report lists phantom events: The
posthog-setup-report.mdclaimsteam_member_invitedanduser_profile_updatedevents exist, but they are not present in the diff or any changed files. [LOW] - Inconsistent distinctId values: Different events use different ID types — user database IDs (
String(user.id)), Stripe customer IDs (String(subscription.customer)), and team IDs (String(team.id)). This fragments data across unlinked persons in PostHog. [MEDIUM]
Other completed criteria
- Events represent real user actions (sign up, sign in, checkout, subscription management)
- Events enable product insights (signup → sign in → checkout funnel is possible)
- Events include contextual properties (team IDs, subscription IDs, product IDs)
- Event names are descriptive and follow consistent snake_case convention
Reviewed by wizard workbench PR evaluator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated wizard CI run
Source: manual
Trigger ID:
tune-mini-xhighApp:
next-js/15-app-router-saasApp directory:
apps/next-js/15-app-router-saasWorkbench branch:
wizard-ci-tune-mini-xhigh-next-js-15-app-router-saasWizard branch:
02e5d9e3b5f62084508a42f545c78f7e6bfa865bContext Mill branch:
mainPostHog (MCP) branch:
masterTimestamp: 2026-07-03T17:13:44.698Z
Duration: 932.0s
YARA Scanner