Repository navigation
[CI] (38ef7e6) next-js/15-app-router-saas - #2597
Closed
wizard-ci-bot[bot] wants to merge 1 commit into
Closed
wizard-ci-bot[bot] wants to merge 1 commit into
wizard-ci-bot[bot] wants to merge 1 commit into
Conversation
Author
|
Good — the 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
|
| Criteria | Result | Description |
|---|---|---|
| App builds and runs | Yes | No syntax errors, all imports resolve, TypeScript types are correct |
| Preserves existing env vars & configs | Yes | All existing code preserved; PostHog additions are purely additive |
| No syntax or type errors | Yes | Valid TypeScript throughout, non-null assertions on env vars are standard Next.js pattern |
| Correct imports/exports | Yes | posthog-js used client-side only, posthog-node used server-side only |
| Minimal, focused changes | Yes | All changes directly serve PostHog integration |
| Pre-existing issues | None | Base app appears clean |
Issues
- PostHog env vars missing from
.env.example: The existing.env.examplefile lists Postgres, Stripe, and auth env vars but was not updated withNEXT_PUBLIC_POSTHOG_PROJECT_TOKENandNEXT_PUBLIC_POSTHOG_HOST. Add these to ensure discoverability for new developers. [MEDIUM]
Other completed criteria
- Build configuration is valid —
next.config.tsrewrites are syntactically correct withskipTrailingSlashRedirect - Package.json dependencies are properly formatted with valid version ranges
PostHog implementation ✅
| Criteria | Result | Description |
|---|---|---|
| PostHog SDKs installed | Yes | posthog-js@^1.399.1 and posthog-node@^5.40.0 in package.json |
| PostHog client initialized | Yes | Client via instrumentation-client.ts (correct Next.js 15.3+ pattern), server via singleton factory in lib/posthog-server.ts with flushAt:1, flushInterval:0 |
| capture() | Yes | 12+ meaningful server-side capture calls plus client-side autocapture |
| identify() | Yes | Client-side identify in dashboard layout using user.id; server-side identify on sign-in and sign-up with person properties; posthog.reset() on logout |
| Error tracking | Yes | capture_exceptions: true in client init for automatic exception capture; manual captureException() in Stripe checkout error handler |
| Reverse proxy | Yes | Next.js rewrites route /ingest/static/* and /ingest/array/* to us-assets.i.posthog.com, /ingest/* to us.i.posthog.com; ui_host set correctly |
Issues
- Stripe webhook distinct_id mismatch: The webhook handler uses
subscription.customer(Stripe customer ID likecus_xxx) asdistinctIdforsubscription_updatedandsubscription_canceledevents. All other events use the user's database ID. This creates separate person profiles in PostHog, breaking funnels and user timelines. SincehandleSubscriptionChangealready resolves the team viagetTeamByStripeCustomerId(), the handler should look up the user ID from the team and use that as thedistinctId. [MEDIUM]
Other completed criteria
- API key loaded from
process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKENenvironment variable (not hardcoded) - Host correctly configured — client uses
/ingest(reverse proxy), server usesprocess.env.NEXT_PUBLIC_POSTHOG_HOST defaults: '2026-01-30'is slightly older than the latest'2026-05-30'shown in docs, but still a valid configuration snapshot
PostHog insights and events ✅
| Filename | PostHog events | Description |
|---|---|---|
instrumentation-client.ts |
autocapture, , , captureException |
Client-side init with automatic event capture and exception tracking |
app/(dashboard)/layout.tsx |
identify, reset |
Identifies authenticated users on page load; resets on sign-out |
app/(login)/actions.ts |
user_signed_in, user_signed_up, user_signed_out, invitation_accepted, password_updated, account_deleted, team_member_removed, team_member_invited |
Comprehensive auth and team management funnel events with team_id, role, and contextual properties |
app/api/stripe/checkout/route.ts |
subscription_checkout_completed, captureException |
Tracks successful checkout with plan, product, and subscription details; captures checkout errors |
app/api/stripe/webhook/route.ts |
subscription_updated, subscription_canceled |
Tracks subscription lifecycle changes (uses Stripe customer ID as distinct_id — see issue above) |
lib/payments/actions.ts |
checkout_started |
Tracks checkout initiation with price_id and team context |
Issues
- No additional event quality issues beyond the webhook distinct_id problem noted above.
Other completed criteria
- Events represent real user actions mapping to SaaS product flows (signup → checkout → subscription lifecycle)
- Events enable product insights — can build signup-to-checkout funnel, track subscription churn, measure team collaboration
- Events include relevant properties (team_id, role, subscription_status, plan_name, etc.)
- No PII in capture() properties — name and role are correctly placed in identify() person properties only
- Event names are descriptive and 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:
38ef7e6App:
next-js/15-app-router-saasApp directory:
apps/next-js/15-app-router-saasWorkbench branch:
wizard-ci-38ef7e6-next-js-15-app-router-saasWizard branch:
release-please--branches--main--components--wizardContext Mill branch:
mainPostHog (MCP) branch:
masterTimestamp: 2026-07-09T19:19:45.713Z
Duration: 472.9s
YARA Scanner