[CI] (d819646) next-js/15-app-router-saas#1497
Closed
wizard-ci-bot[bot] wants to merge 1 commit into
Closed
Conversation
Author
PR Evaluation ReportSummaryThis PR integrates PostHog into a Next.js 15 App Router SaaS application with both client-side (posthog-js via
Confidence score: 4/5 👍
File changes
App sanity check ✅
Issues
|
| 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 | Client via instrumentation-client.ts (correct for Next.js 15.3+), server via getPostHogClient() factory with flushAt: 1, flushInterval: 0 |
| capture() | Yes | 12 meaningful events across auth, payments, and team management |
| identify() | No | Client-side uses raw email as distinct_id; server-side uses String(user.id) — identity mismatch causes fragmented user profiles |
| Error tracking | Yes | capture_exceptions: true in posthog.init() enables automatic exception capture |
| Reverse proxy | Yes | Three rewrite rules in next.config.ts: /ingest/static/* and /ingest/array/* → us-assets.i.posthog.com, /ingest/* → us.i.posthog.com. skipTrailingSlashRedirect: true included. |
Issues
- Client/server distinct_id mismatch: In
login.tsx,posthog.identify(email, { email })uses the user's email asdistinct_id, while all server-side calls useString(user.id)(numeric database ID). PostHog will create two separate person profiles for the same user. Fix: the client-side identify should use the same numeric user ID returned from the server after successful authentication, or the server should alias the email to the user ID. [CRITICAL] - Webhook fabricated distinct_id:
app/api/stripe/webhook/route.tsusesstripe_customer_asdistinctId. This synthetic ID won't merge with actual user profiles, making these events (subscription_updated, subscription_cancelled) invisible in user-level analysis. Fix: look up the user by their Stripe customer ID from the teams/users table and use the actual user ID. [MEDIUM]
Other completed criteria
- API key loaded from environment variable
NEXT_PUBLIC_POSTHOG_KEY - Host correctly configured — client uses
/ingestreverse proxy, server usesNEXT_PUBLIC_POSTHOG_HOST posthog.reset()correctly called on sign-out inlayout.tsx- Server-side
posthog.shutdown()called after every capture block ui_hostset tohttps://us.posthog.comfor toolbar/survey access through reverse proxy
PostHog insights and events ✅
| Filename | PostHog events | Description |
|---|---|---|
app/(login)/actions.ts |
user_signed_in, user_signed_up, user_signed_out, password_updated, account_deleted, account_updated, team_member_removed, team_member_invited |
Core auth and account lifecycle events with server-side capture. Includes via_invitation, role, removed_member_id properties. |
app/(login)/login.tsx |
identify (client) |
Client-side identify on form submit (but uses email as distinct_id) |
lib/payments/actions.ts |
checkout_initiated |
Captures start of Stripe checkout flow with plan_name and price_id |
app/api/stripe/checkout/route.ts |
checkout_completed |
Captures successful checkout with plan_name, subscription_status, stripe_subscription_id |
app/api/stripe/webhook/route.ts |
subscription_updated, subscription_cancelled |
Webhook-driven subscription lifecycle events |
app/(dashboard)/layout.tsx |
reset |
Clears PostHog identity on sign-out |
Issues
- Webhook events orphaned from users:
subscription_updatedandsubscription_cancelledusestripe_customer_as distinct_id, so these events won't appear in any real user's event stream. [MEDIUM]
Other completed criteria
- Events represent real user actions across the full SaaS lifecycle (signup → checkout → subscription management → churn)
- Events enable product insights — signup-to-checkout funnel, subscription health, team engagement metrics are all possible
- Events include relevant contextual properties (plan_name, subscription_status, role, via_invitation)
- No PII in event properties — email and name only set via
identify()person properties - Event names follow consistent snake_case convention with descriptive action names
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-app-router-saasApp directory:
apps/next-js/15-app-router-saasWorkbench branch:
wizard-ci-d819646-next-js-15-app-router-saasWizard branch:
mainContext Mill branch:
mainPostHog (MCP) branch:
masterTimestamp: 2026-05-14T16:44:43.440Z
Duration: 817.9s