Skip to content

[CI] (0ae2102) react-router/react-router-v7-project - #1238

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

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

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/react-router-v7-project
App directory: apps/react-router/react-router-v7-project
Workbench branch: wizard-ci-0ae2102-react-router-react-router-v7-project
Wizard branch: release-please--branches--main--components--wizard
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-04-15T19:34:01.014Z
Duration: 478.4s

@wizard-ci-bot

wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown
Author

Now I have all the context I need. Let me compile the evaluation.

Key observations from my analysis:

  1. Login identify uses username as distinct_id — In login.tsx, posthog?.identify(username, { username }) uses the raw username string as the distinct_id. The FakeUser has an id field that would be better. Signup correctly uses newUser.id.
  2. No .env.example committed — The .env is gitignored (correctly), but there's no .env.example file committed to document the required env vars.
  3. country_detail_viewed uses useEffect — The country.tsx file uses useEffect to capture a view event, which is acceptable for page load tracking (syncing with external system).
  4. Login identify: username as distinct_id — Using username instead of user ID creates inconsistency with signup which uses newUser.id.
  5. PII check — username appears in capture event properties (user_logged_in, user_signed_up). Username could be considered PII-adjacent but is not email/name/phone. The email is correctly passed only in identify() person properties in signup.
  6. No identify on page refresh — When a logged-in user refreshes, there's no identify call to re-link the session.

PR Evaluation Report

Summary

This PR integrates PostHog into a React Router v7 framework-mode app (CountryExplorer). It adds client-side initialization via entry.client.tsx with PostHogProvider, server-side middleware using posthog-node, error boundary exception capture, user identification on login/signup, reset on logout, and custom event tracking across multiple routes.

Files changed Lines added Lines removed
13 +161 -19

Confidence score: 4/5 👍

  • Inconsistent distinct_id between login and signup: Login uses raw username as the distinct_id while signup uses newUser.id. This will create fragmented user profiles — the same user will have two different distinct IDs depending on whether they signed up or logged in. Login should use the user's id field for consistency. [CRITICAL]
  • No identify call on page refresh/app load: When an already-logged-in user refreshes the page, identify() is never called again. PostHog docs recommend calling identify "every time your app loads for the first time" if a user is already authenticated. This means returning users will generate anonymous events. [MEDIUM]
  • No .env.example committed: The .env file is gitignored (correctly), but no .env.example or equivalent is committed to document the required environment variables for other developers. [MEDIUM]

File changes

Filename Score Description
app/entry.client.tsx 5/5 Correct PostHog initialization with PostHogProvider, env vars, tracing headers, and defaults option
app/lib/posthog-middleware.ts 5/5 Well-structured server-side middleware with proper session/distinct ID extraction and shutdown
app/root.tsx 4/5 Middleware registration and error boundary capture are correct
app/routes/countries.tsx 5/5 Good event captures in click handlers with enriched properties
app/routes/country.tsx 4/5 View event in useEffect is acceptable for page-load tracking
app/routes/home.tsx 5/5 Clean CTA click tracking in event handler
app/routes/login.tsx 2/5 Uses username as distinct_id instead of user ID; inconsistent with signup
app/routes/profile.tsx 5/5 Proper logout flow with capture + reset
app/routes/signup.tsx 5/5 Correct identify with newUser.id, error capture in catch block
package.json 5/5 All three PostHog packages added correctly
react-router.config.ts 5/5 Middleware future flag enabled correctly
vite.config.ts 5/5 SSR noExternal config for PostHog packages
posthog-setup-report.md 4/5 Helpful setup report documenting all changes

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes All syntax is valid, dependencies added, config files updated correctly
Preserves existing env vars & configs Yes Existing code and configs preserved; only PostHog additions made
No syntax or type errors Yes All TypeScript/JSX is syntactically valid
Correct imports/exports Yes All imports from posthog-js, @posthog/react, and posthog-node are correct
Minimal, focused changes Yes All changes directly serve PostHog integration
Pre-existing issues None No pre-existing issues detected

Issues

  • No .env.example file: The .env is correctly gitignored, but there is no .env.example or similar file committed to the repo to document the required VITE_PUBLIC_POSTHOG_PROJECT_TOKEN and VITE_PUBLIC_POSTHOG_HOST variables. Other developers cloning the repo won't know which env vars are needed. [MEDIUM]

Other completed criteria

  • Build configuration is valid — package.json dependencies, vite.config.ts SSR settings, and react-router.config.ts middleware flag are all properly configured
  • All changes are relevant to PostHog integration
  • Code follows existing codebase patterns (naming, structure, indentation)

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 package.json
PostHog client initialized Yes posthog.init() called in entry.client.tsx with env vars, defaults, and __add_tracing_headers; server middleware creates posthog-node client per request with flushAt: 1 and flushInterval: 0
capture() Yes Multiple meaningful capture calls across routes for user actions
identify() Yes Called on login and signup, with reset() on logout. However, login uses username as distinct_id while signup uses newUser.id, creating inconsistency
Error tracking Yes captureException() in root ErrorBoundary and in signup catch block
Reverse proxy No No reverse proxy configured (no Next.js rewrites or Vercel rewrites set up)

Issues

  • Inconsistent distinct_id in identify calls: In login.tsx, posthog?.identify(username, { username }) uses the raw username string as the distinct_id. In signup.tsx, posthog?.identify(newUser.id, ...) correctly uses the user's id field. This means the same user will have two different distinct IDs depending on whether they signed up or logged in, causing fragmented person profiles in PostHog. Fix: In login.tsx, retrieve the logged-in user object and use its id field (the login() function returns a boolean, but getCurrentUser() is already imported and can be called after successful login). [CRITICAL]
  • No identify on page refresh: The PostHog docs recommend calling identify() every time the app loads if the user is already authenticated. Currently, if a user refreshes while logged in, no identify() is called, so events will be attributed to a new anonymous ID. A good location would be in the AuthProvider or a top-level component that checks for an existing user on mount. [MEDIUM]

Other completed criteria

  • API key loaded from environment variables (VITE_PUBLIC_POSTHOG_PROJECT_TOKEN)
  • API host correctly configured via VITE_PUBLIC_POSTHOG_HOST pointing to https://us.i.posthog.com
  • Server-side middleware properly extracts session/distinct ID headers and uses withContext()
  • posthog.reset() correctly called on logout
  • __add_tracing_headers configured for client-server session linking
  • SSR noExternal config correctly set for PostHog packages

PostHog insights and events ⚠️

Filename PostHog events Description
app/routes/signup.tsx user_signed_up, captureException Tracks signup with username property; identifies user with newUser.id; captures exceptions in catch block
app/routes/login.tsx user_logged_in Tracks login with username property; identifies user (but with wrong distinct_id)
app/routes/profile.tsx user_logged_out Tracks logout and calls posthog.reset() to clear identity
app/routes/countries.tsx country_claimed, country_liked, country_visited Tracks three country interactions with country_name and region properties
app/routes/country.tsx country_detail_viewed Tracks country detail page views with country_name and region properties
app/routes/home.tsx explore_now_clicked Tracks CTA click on homepage
app/root.tsx captureException Captures unhandled errors in ErrorBoundary

Issues

  • username in event properties: The user_logged_in and user_signed_up events include username as an event property. While username is borderline (not as sensitive as email/phone), it's a user identifier that would be more appropriate as a person property via identify(). This is a minor concern since it's already being set via identify. [LOW]

Other completed criteria

  • Events represent real user actions (signup, login, logout, claiming/liking/visiting countries, viewing details, CTA clicks)
  • Events enable product insights — can build signup→login funnels, country engagement breakdowns, CTA→detail→claim conversion funnels
  • Events include relevant contextual properties (country_name, region)
  • Event names are descriptive and use consistent snake_case convention

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