[CI] (6fb03e7) next-js/15-pages-router-saas#1475
Closed
wizard-ci-bot[bot] wants to merge 1 commit into
Closed
Conversation
Author
|
Now I have all the context needed. Let me produce the evaluation. PR Evaluation ReportSummaryThis PR integrates PostHog into a Next.js 15 Pages Router SaaS app, adding both client-side (
Confidence score: 4/5 👍
File changes
App sanity check
|
| Criteria | Result | Description |
|---|---|---|
| App builds and runs | Yes | No syntax errors, valid TypeScript, correct imports |
| Preserves existing env vars & configs | Yes | Existing next.config.ts extended, no existing code removed |
| No syntax or type errors | Yes | All changes are syntactically valid |
| Correct imports/exports | Yes | posthog-js imported client-side, posthog-node server-side — correct separation |
| Minimal, focused changes | Yes | All changes relate to PostHog integration |
| Pre-existing issues | None | Base app appears clean |
Issues
- Env vars not documented:
.env.examplewas not updated withNEXT_PUBLIC_POSTHOG_KEYandNEXT_PUBLIC_POSTHOG_HOST. New developers cloning the repo won't know these env vars are needed. [MEDIUM]
Other completed criteria
- Build configuration is valid — package.json and next.config.ts are well-formed
- posthog-js is only imported in client-side components, posthog-node in server-side files
- Existing functionality (auth flow, Stripe webhooks) is preserved
PostHog implementation ⚠️
| Criteria | Result | Description |
|---|---|---|
| PostHog SDKs installed | Yes | posthog-js@^1.373.4 and posthog-node@^5.34.1 in package.json |
| PostHog client initialized | Yes | instrumentation-client.ts calls posthog.init() with env var key, reverse proxy host, defaults, and exception capture. Server-side singleton in lib/posthog-server.ts |
| capture() | Yes | 10 meaningful events across client and server |
| identify() | Yes | Called on sign-in/sign-up both client and server-side, with alias for anonymous→identified linking. However, uses email as distinct_id instead of database user ID |
| Error tracking | Yes | capture_exceptions: true in init config for automatic exception capture, plus manual captureException() calls in catch blocks |
| Reverse proxy | Yes | Next.js rewrites in next.config.ts with correct /ingest/static/*, /ingest/array/*, and /ingest/* routes pointing to correct PostHog origins |
Issues
- Email used as distinct_id:
posthog.identify(data.email, { email: data.email })and all server-side captures use email as the distinct ID. Should use a stable database user ID (e.g.,foundUser.id). If a user changes their email, events will fragment across different identities. [MEDIUM] - Webhook distinct_id mismatch:
pages/api/stripe/webhook.tsusessubscription.customer(Stripe customer ID likecus_xxx) asdistinctId. This doesn't match the email-based distinct_id used everywhere else, so subscription events won't be associated with the correct user profile. Should resolve the Stripe customer to the app's user and use the same identifier. [CRITICAL]
Other completed criteria
- API key loaded from
NEXT_PUBLIC_POSTHOG_KEYenvironment variable, not hardcoded - Host correctly configured — client uses
/ingestreverse proxy, server usesNEXT_PUBLIC_POSTHOG_HOST posthog.reset()correctly called on logout in header.tsx- Server-side alias pattern links anonymous pre-login events to identified user
- Session/distinct ID headers passed from client to server for session correlation
PostHog insights and events ⚠️
| Filename | PostHog events | Description |
|---|---|---|
components/login.tsx |
user_signed_in, user_signed_up, captureException |
Tracks auth events on successful login/signup; captures exceptions on error. |
components/header.tsx |
reset() |
Unlinks session on logout |
pages/pricing.tsx |
checkout_started, captureException |
Tracks plan selection with plan name, price_id, and interval |
pages/dashboard/index.tsx |
manage_subscription_clicked, team_member_removed, team_member_invited, captureException |
Tracks subscription management and team operations. team_member_invited includes invited_email |
pages/dashboard/general.tsx |
account_updated, captureException |
Tracks profile updates. |
pages/api/auth/sign-in.ts |
identify, alias |
Server-side user identification and anonymous→identified linking |
pages/api/auth/sign-up.ts |
identify, alias |
Server-side new user identification |
pages/api/stripe/create-checkout.ts |
checkout_session_created |
Server-side checkout tracking with price_id, team context |
pages/api/stripe/webhook.ts |
subscription_updated, subscription_cancelled |
Server-side Stripe webhook events. |
Issues
- PII in event properties: Email appears in event properties of
user_signed_in,user_signed_up,account_updated, andteam_member_invited. Names appear inaccount_updated. PII must be set via person properties (e.g., inidentify()calls or ``), not incapture()event properties. Remove `email` and `name` from these capture calls. [CRITICAL] - Webhook distinct_id fragmentation: Subscription events use Stripe customer ID, making them impossible to associate with the user's PostHog profile. Look up the app user from the Stripe customer and use the same distinct_id. [CRITICAL]
Other completed criteria
- Events represent real user actions mapped to actual product flows (auth, checkout, subscription, team management)
- Events enable product insights — can build signup→checkout funnel, track churn, monitor team growth
- Most events include relevant contextual properties (plan name, price_id, team_id, subscription_status)
- Event names are descriptive and use 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: scheduled
Trigger ID:
6fb03e7App:
next-js/15-pages-router-saasApp directory:
apps/next-js/15-pages-router-saasWorkbench branch:
wizard-ci-6fb03e7-next-js-15-pages-router-saasWizard branch:
mainContext Mill branch:
mainPostHog (MCP) branch:
masterTimestamp: 2026-05-13T17:25:49.770Z
Duration: 550.4s