[CI] (3393d57) next-js/15-pages-router-saas#887
Closed
wizard-ci-bot[bot] wants to merge 1 commit intomainfrom
Closed
[CI] (3393d57) next-js/15-pages-router-saas#887wizard-ci-bot[bot] wants to merge 1 commit intomainfrom
wizard-ci-bot[bot] wants to merge 1 commit intomainfrom
Conversation
Author
|
Now I have all the context I need. Let me produce the evaluation report. PR Evaluation ReportSummaryThis PR integrates PostHog into a Next.js 15 Pages Router SaaS application with both client-side (
Confidence score: 4/5 👍
File changes
App sanity check
|
| Criteria | Result | Description |
|---|---|---|
| App builds and runs | Yes | No syntax or type errors detected; all imports resolve |
| Preserves existing env vars & configs | Yes | Existing next.config.ts settings preserved; only PostHog additions |
| No syntax or type errors | Yes | All TypeScript code appears valid |
| Correct imports/exports | Yes | posthog-js imported client-side, posthog-node server-side — correct separation |
| Minimal, focused changes | Yes | All changes are PostHog-related |
| Pre-existing issues | None | No pre-existing issues observed |
Issues
- Environment variables not documented in .env.example:
NEXT_PUBLIC_POSTHOG_PROJECT_TOKENandNEXT_PUBLIC_POSTHOG_HOSTare not added to.env.example. Developers will not know these variables are required. Add them to.env.example. [MEDIUM]
Other completed criteria
- Build configuration is valid —
package.jsonhas both PostHog packages listed - All imports correctly reference the right packages for their execution context
- No unrelated changes or scope creep
PostHog implementation ⚠️
| Criteria | Result | Description |
|---|---|---|
| PostHog SDKs installed | Yes | posthog-js@^1.360.2 and posthog-node@^5.28.2 added to package.json |
| PostHog client initialized | Yes | Client initialized in instrumentation-client.ts with env token, reverse proxy host, defaults, and capture_exceptions; server singleton in lib/posthog-server.ts |
| capture() | Yes | Multiple meaningful capture calls across client (sign-out, checkout_initiated, account_updated) and server (sign-in, sign-up, checkout_completed, subscription_updated, team events) |
| identify() | No | Client-side identify() uses raw email as distinct_id, while server-side uses String(user.id). This mismatch prevents proper identity merging and fragments user data. |
| Error tracking | Yes | capture_exceptions: true enabled in instrumentation-client.ts init config |
| Reverse proxy | Yes | Next.js rewrites properly configured in next.config.ts pointing /ingest/* to us.i.posthog.com and /ingest/static/* to us-assets.i.posthog.com |
Issues
- Client-server distinct_id mismatch:
login.tsxcallsposthog.identify(data.email, ...)using raw email, while server routes useString(foundUser.id). PostHog will treat these as separate persons. The client-side identify should use the user's database ID (returned from the API response) as thedistinct_id. [CRITICAL] - API key env var name inconsistency: Client init uses
NEXT_PUBLIC_POSTHOG_PROJECT_TOKENwhile server uses bothNEXT_PUBLIC_POSTHOG_PROJECT_TOKEN(for the token) andNEXT_PUBLIC_POSTHOG_HOST(for host). The clientapi_hostis hardcoded to'/ingest'rather than using the env var — this is actually fine for the reverse proxy pattern, but the server client'shostreferencesNEXT_PUBLIC_POSTHOG_HOSTwhich is never defined in.env.example. [LOW]
Other completed criteria
- API key loaded from environment variable, not hardcoded
- Host correctly configured — client uses reverse proxy
/ingest, server uses env var for PostHog host posthog.reset()called on sign-out (best practice)- Server-side singleton pattern with
flushAt: 1andflushInterval: 0follows Next.js docs
PostHog insights and events ⚠️
| Filename | PostHog events | Description |
|---|---|---|
components/header.tsx |
user_signed_out |
Client-side sign-out tracking with proper posthog.reset() |
components/login.tsx |
identify |
Client-side user identification on sign-in/sign-up success |
pages/pricing.tsx |
checkout_initiated |
Captures plan selection with name, price_id, price, interval |
pages/dashboard/general.tsx |
account_updated |
Captures account settings save with name and email |
pages/api/auth/sign-in.ts |
user_signed_in, identify |
Server-side sign-in tracking with person properties |
pages/api/auth/sign-up.ts |
user_signed_up, identify |
Server-side sign-up tracking with role, team, invite info |
pages/api/stripe/checkout.ts |
checkout_completed |
Server-side checkout completion with plan/subscription details |
pages/api/stripe/webhook.ts |
subscription_updated |
Webhook-triggered subscription status changes |
pages/api/team/invite.ts |
team_member_invited |
Server-side team invitation tracking |
pages/api/team/remove-member.ts |
team_member_removed |
Server-side team member removal tracking |
Issues
- PII in event properties: Email addresses appear in
capture()event properties insign-in.ts,sign-up.ts,invite.ts, andgeneral.tsx. Email is PII and should only be set viaidentify()person properties, not sent with every event capture. Removeemailfrom capture properties. [CRITICAL] - Email in account_updated event:
general.tsxsends{ name: data.name, email: data.email }inaccount_updatedcapture — both name and email are PII. [MEDIUM] - Webhook distinct_id is Stripe customer ID:
webhook.tsusessubscription.customer(Stripe customer ID likecus_xxx) asdistinctId. This won't match the app's user ID (String(user.id)), so these events won't be linked to the same person. [MEDIUM]
Other completed criteria
- Events represent real user actions (sign-up, sign-in, checkout, team management)
- Events enable meaningful product insights — can build sign-up funnel, checkout conversion, team growth trends
- Events include enriched properties (plan names, subscription IDs, roles, etc.)
- Event naming is descriptive and uses 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: wizard-pr
Trigger ID:
3393d57App:
next-js/15-pages-router-saasApp directory:
apps/next-js/15-pages-router-saasWorkbench branch:
wizard-ci-3393d57-next-js-15-pages-router-saasWizard branch:
release-please--branches--main--components--wizardContext Mill branch:
mainPostHog (MCP) branch:
masterTimestamp: 2026-03-17T00:20:47.893Z
Duration: 385.5s