Skip to content

[CI] (0ae2102) react-router/saas-template - #1240

Closed
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-0ae2102-react-router-saas-template
Closed

wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-0ae2102-react-router-saas-template

Conversation

@wizard-ci-bot

@wizard-ci-bot wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown

Automated wizard CI run

Source: wizard-pr
Trigger ID: 0ae2102
App: react-router/saas-template
App directory: apps/react-router/saas-template
Workbench branch: wizard-ci-0ae2102-react-router-saas-template
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-04-15T19:37:50.189Z
Duration: 639.3s

@wizard-ci-bot

wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown
Author

Now I have all the information needed to produce the full evaluation.


PR Evaluation Report

Summary

This PR integrates PostHog into a React Router v7 (framework mode) SaaS template application. It adds both client-side (posthog-js, @posthog/react) and server-side (posthog-node) SDKs, creates a server middleware for per-request PostHog client initialization with session correlation, implements user identification on authenticated pages, adds error tracking via captureException, and instruments 12 meaningful business events across billing, onboarding, authentication, and team management flows.

Files changed Lines added Lines removed
17 +324 -11

Confidence score: 4/5 👍

  • PII in capture event properties: The user_logged_in and user_signed_up events include email directly in event properties (properties: { : { email }, email }). The email key outside `` is PII leaking into event properties. Similarly, contact_sales_submitted includes `work_email` and `invited_email` in event properties. [MEDIUM]
  • posthog.reset() not called on logout: The client-side posthog.reset() call is missing on logout. The server-side user_logged_out event is captured, but the browser SDK is never told to unlink the user, which means the next user on the same device will be associated with the previous user's identity. [MEDIUM]
  • .env.example not updated: The .env.example file was not updated with VITE_PUBLIC_POSTHOG_PROJECT_TOKEN and VITE_PUBLIC_POSTHOG_HOST placeholder entries, though the .env file was created and added to .gitignore. [LOW]

File changes

Filename Score Description
app/entry.client.tsx 5/5 Initializes posthog-js with env vars from window.ENV, wraps app with PostHogProvider, adds tracing headers for session correlation
app/utils/posthog-middleware.server.ts 5/5 New server middleware creating per-request PostHog Node client with withContext() for session/distinct ID correlation and proper shutdown()
app/root.tsx 5/5 Registers posthog middleware, adds captureException in ErrorBoundary for non-404 errors
app/utils/env.server.ts 4/5 Adds PostHog env vars to schema validation and getEnv() for client exposure
app/routes/.../auth.callback.ts 3/5 Captures user_logged_in and user_signed_up events but leaks email as a top-level event property
app/routes/.../logout.ts 4/5 Captures user_logged_out server-side with proper error handling; missing client-side posthog.reset()
app/routes/.../_sidebar-layout.tsx 4/5 Implements posthog.identify() with userId, email, and name; uses useEffect which is acceptable for syncing with external PostHog system
app/features/billing/billing-action.server.ts 5/5 Adds 4 billing events with appropriate properties
app/features/billing/stripe-event-handlers.server.ts 5/5 Adds subscription_checkout_completed webhook event with standalone PostHog client and proper shutdown
app/features/billing/contact-sales/contact-sales-action.server.ts 3/5 Captures contact sales event but uses workEmail as distinctId — not a real user ID
app/features/onboarding/organization/onboarding-organization-action.server.ts 5/5 Captures org onboarding completion with user ID and org details
app/features/organizations/create-organization/create-organization-action.server.ts 5/5 Captures org creation event
app/features/organizations/settings/team-members/team-members-action.server.tsx 4/5 Captures member invite event but includes invited_email PII in event properties
package.json 5/5 Adds all three PostHog packages
vite.config.ts 5/5 Adds ssr.noExternal for PostHog packages
.gitignore 5/5 Adds .env to gitignore
posthog-setup-report.md 5/5 Comprehensive setup report with event table and next steps

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes All imports resolve correctly, TypeScript types are consistent, dependencies added
Preserves existing env vars & configs Yes Existing env vars, configs, and middleware untouched; PostHog additions are additive
No syntax or type errors Yes All files use valid TypeScript syntax, types are properly cast
Correct imports/exports Yes posthog-js imported client-side, posthog-node imported server-side with .server.ts suffix
Minimal, focused changes Yes All changes are PostHog-related; minor formatting change in _sidebar-layout.tsx is inconsequential
Pre-existing issues None .env.example doesn't have PostHog vars but this is a new addition issue, not pre-existing

Issues

  • .env.example not updated with PostHog vars: The .env.example file was not updated with placeholder entries for VITE_PUBLIC_POSTHOG_PROJECT_TOKEN and VITE_PUBLIC_POSTHOG_HOST. Developers cloning the repo won't know these are needed until the Zod schema validation fails at startup. Add placeholder entries to .env.example. [LOW]

Other completed criteria

  • All PostHog SDK packages correctly added to package.json with appropriate versions
  • vite.config.ts correctly updated with ssr.noExternal for SSR compatibility
  • .env added to .gitignore to prevent secret leakage
  • window.ENV pattern correctly used to pass server env vars to client (matching existing app pattern)
  • Build configuration remains valid

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js ^1.369.0, @posthog/react ^1.9.0, and posthog-node ^5.29.2 added to dependencies
PostHog client initialized Yes Client-side: posthog.init() in entry.client.tsx with window.ENV vars and defaults: '2026-01-30'; Server-side: per-request PostHog Node client in middleware with withContext()
capture() Yes 12 meaningful capture calls across client and server
identify() Yes posthog.identify(userId, { email, name }) called in sidebar layout via useEffect on authenticated pages; uses real database user IDs
Error tracking Yes posthog.captureException(error) in root ErrorBoundary for non-404 errors
Reverse proxy No No reverse proxy configured; __add_tracing_headers is set but no Next.js rewrites or equivalent proxy configuration

Issues

  • Missing posthog.reset() on logout: The logout route captures a server-side user_logged_out event but does not call posthog.reset() on the client side. Per PostHog docs, reset() should be called on logout to unlink future events from the current user. Since logout is a server-side action that redirects, a client-side mechanism (e.g., checking auth state change) should trigger posthog.reset(). [MEDIUM]
  • contact_sales_submitted uses email as distinctId: In contact-sales-action.server.ts, submissionData.workEmail is used as the distinctId. This is a raw email address, not a real user/session ID, which will create fragmented person profiles and is a PII concern. Should use a session or anonymous ID if user is not authenticated. [MEDIUM]
  • No reverse proxy configured: No reverse proxy is set up to route PostHog requests through the app's domain. The __add_tracing_headers option is correctly configured for session correlation, but browser requests to us.i.posthog.com may be blocked by ad blockers. Consider adding React Router rewrites. [LOW]

Other completed criteria

  • API key loaded from environment variable via window.ENV (client) and process.env (server) — not hardcoded
  • API host correctly configured to https://us.i.posthog.com
  • Server middleware properly uses posthog.withContext() for session correlation
  • posthog.shutdown() called after each server request
  • Stripe webhook handler creates standalone PostHog client with proper lifecycle
  • ssr.noExternal correctly configured for SSR compatibility
  • defaults: '2026-01-30' correctly set per docs

PostHog insights and events ⚠️

Filename PostHog events Description
auth.callback.ts user_signed_up, user_logged_in Tracks new user registration and returning user authentication with user ID and email person properties
logout.ts user_logged_out Tracks user logout server-side with proper user resolution from Supabase
_sidebar-layout.tsx identify() Identifies authenticated users with email and name as person properties
root.tsx captureException Captures non-404 errors in the root error boundary
billing-action.server.ts subscription_cancelled, subscription_checkout_started, subscription_resumed, subscription_plan_switched Full billing lifecycle tracking with org ID, subscription ID, price ID properties
stripe-event-handlers.server.ts subscription_checkout_completed Webhook-driven event for completed checkouts with amount, currency, Stripe customer ID
contact-sales-action.server.ts contact_sales_submitted Enterprise contact form submission tracking
onboarding-organization-action.server.ts onboarding_organization_completed Onboarding funnel step completion
create-organization-action.server.ts organization_created New organization creation tracking
team-members-action.server.tsx member_invited_by_email Team growth tracking with invited role and org ID

Issues

  • PII in event properties: Multiple events include email addresses directly in event properties: user_logged_in and user_signed_up have email as a top-level property (outside ), `contact_sales_submitted` includes `work_email`, and `member_invited_by_email` includes `invited_email`. Emails should only appear in person properties (via or identify()), not in event properties. The : { email } usage is correct for setting person properties, but the bare email field alongside it leaks PII into event data. [MEDIUM]

Other completed criteria

  • Events represent real user actions mapping to actual SaaS product flows (signup, login, billing, team management)
  • Events enable product insights: can build signup-to-subscription funnel, track churn via cancellation events, measure team growth
  • Events include enriched contextual properties (org IDs, price IDs, subscription IDs, lookup keys)
  • Event names are descriptive and use consistent snake_case naming convention
  • 12 distinct events covering the full user journey from signup through billing

Reviewed by wizard workbench PR evaluator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants