[CI] (d819646) next-js/15-pages-router-saas#1496
Closed
wizard-ci-bot[bot] wants to merge 1 commit into
Closed
Conversation
Author
|
The PR Evaluation ReportSummaryThis PR integrates PostHog into a Next.js 15 Pages Router SaaS application, 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, all imports resolve |
| 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 package names |
| Minimal, focused changes | Yes | All changes are PostHog-related |
| Pre-existing issues | None | Base app appears well-structured |
Issues
.env.examplenot updated with PostHog vars: The.env.examplefile does not includeNEXT_PUBLIC_POSTHOG_KEYorNEXT_PUBLIC_POSTHOG_HOST. Other developers cloning the repo won't know these are needed. [MEDIUM]- Missing
await posthog.shutdown()in API routes: Server-side API routes (sign-in,sign-up,sign-out,create-checkout,webhook) don't callawait posthog.shutdown(). The Next.js Pages Router docs require this because server-side functions can be short-lived and events may be lost. [MEDIUM]
Other completed criteria
- App builds without syntax or type errors
- Existing app code and configs preserved correctly
- Changes are minimal and focused on PostHog integration
- All imports resolve correctly (posthog-js client-side, posthog-node server-side)
- Build configuration (package.json, next.config.ts) is valid
PostHog implementation ⚠️
| Criteria | Result | Description |
|---|---|---|
| PostHog SDKs installed | Yes | posthog-js@^1.373.4 and posthog-node@^5.34.1 added to package.json |
| PostHog client initialized | Yes | instrumentation-client.ts uses posthog.init() with env var, reverse proxy, defaults, and capture_exceptions |
| capture() | Yes | 11 meaningful custom events across auth, checkout, subscription, and team management flows |
| identify() | No | Uses raw email as distinct_id instead of stable database user ID; webhook uses Stripe customer ID causing fragmented data |
| Error tracking | Yes | captureException() in all client-side catch blocks + capture_exceptions: true in init for autocapture |
| Reverse proxy | Yes | Next.js rewrites correctly route /ingest/static/* and /ingest/array/* to us-assets.i.posthog.com, /ingest/* to us.i.posthog.com, with skipTrailingSlashRedirect |
Issues
- Email used as distinct_id:
posthog.identify(data.email, ...)on client andposthog.identify({ distinctId: foundUser.email, ... })on server use raw email as the distinct_id. Emails are PII, can change, and are not stable identifiers. The app has database user IDs (foundUser.id,createdUser.id) that should be used instead. [CRITICAL] - Fragmented identity in Stripe webhook: The webhook handler uses
subscription.customer(Stripe'scus_xxxID) as thedistinctId. This won't match the email-based distinct_id used in all other routes, creating separate person profiles in PostHog for the same user. [CRITICAL] - No
posthog.reset()on sign-out client-side: The client-side sign-out flow doesn't callposthog.reset(). The docs explicitly recommend calling reset on logout to unlink future events from the current user. [MEDIUM]
Other completed criteria
- PostHog SDKs correctly installed in package.json
- Client initialized via
instrumentation-client.tsfollowing Next.js 15.3+ pattern - API key loaded from
NEXT_PUBLIC_POSTHOG_KEYenvironment variable - Reverse proxy correctly configured with both static/array asset routes and main ingest route
- Server-side singleton pattern with
flushAt: 1andflushInterval: 0for immediate flushing - Exception autocapture enabled via
capture_exceptions: true
PostHog insights and events ⚠️
| Filename | PostHog events | Description |
|---|---|---|
components/login.tsx |
user_signed_in, user_signed_up, captureException |
Client-side auth events with identify on login/signup |
pages/api/auth/sign-in.ts |
user_signed_in |
Server-side sign-in tracking with identify |
pages/api/auth/sign-up.ts |
user_signed_up |
Server-side sign-up tracking with identify |
pages/api/auth/sign-out.ts |
user_signed_out |
Server-side sign-out event |
pages/pricing.tsx |
checkout_started, captureException |
Client-side checkout initiation with plan details |
pages/api/stripe/create-checkout.ts |
checkout_session_created |
Server-side checkout session creation |
pages/api/stripe/webhook.ts |
subscription_updated, subscription_cancelled |
Stripe webhook subscription lifecycle events |
pages/dashboard/index.tsx |
customer_portal_opened, team_member_removed, team_member_invited, captureException |
Dashboard team management and billing events |
pages/dashboard/general.tsx |
account_updated, captureException |
Account settings update event |
Issues
- PII (email) in capture event properties:
user_signed_in,user_signed_up,account_updated, andteam_member_invitedevents include email addresses in event properties. Emails are PII and should only be set viaidentify()person properties, never incapture()event properties. This applies to both client-side ({ email: data.email }) and server-side ({ email: foundUser.email }) captures. [CRITICAL]
Other completed criteria
- Events represent real user actions mapping to actual SaaS product flows (auth, checkout, subscription, team management)
- Events enable product insights: sign-up → checkout → subscription funnel, churn tracking via subscription_cancelled, team growth via invites
- Events include relevant contextual properties (price_id, plan_name, subscription_id, member_id, etc.)
- Event names are descriptive, consistent snake_case, and clearly describe the action
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:
d819646App:
next-js/15-pages-router-saasApp directory:
apps/next-js/15-pages-router-saasWorkbench branch:
wizard-ci-d819646-next-js-15-pages-router-saasWizard branch:
mainContext Mill branch:
mainPostHog (MCP) branch:
masterTimestamp: 2026-05-14T16:43:33.784Z
Duration: 730.8s