Skip to content

[CI] (6fb03e7) react-router/react-router-v7-project#1484

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

[CI] (6fb03e7) react-router/react-router-v7-project#1484
wizard-ci-bot[bot] wants to merge 1 commit into
mainfrom
wizard-ci-6fb03e7-react-router-react-router-v7-project

Conversation

@wizard-ci-bot
Copy link
Copy Markdown

@wizard-ci-bot wizard-ci-bot Bot commented May 13, 2026

Automated wizard CI run

Source: scheduled
Trigger ID: 6fb03e7
App: react-router/react-router-v7-project
App directory: apps/react-router/react-router-v7-project
Workbench branch: wizard-ci-6fb03e7-react-router-react-router-v7-project
Wizard branch: main
Context Mill branch: main
PostHog (MCP) branch: master
Timestamp: 2026-05-13T17:38:46.628Z
Duration: 507.8s

@wizard-ci-bot
Copy link
Copy Markdown
Author

wizard-ci-bot Bot commented May 13, 2026


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 tracking in the ErrorBoundary, user identification on login/signup, reset on logout, and custom event captures for country interactions.

Files changed Lines added Lines removed
12 +179 -6

Confidence score: 5/5 🧙

  • Reverse proxy not connected to PostHog init: The Vite dev-server proxy is configured at /ingest but posthog.init() sets api_host to the raw PostHog host URL from env, so the proxy is never used. api_host must be set to '/ingest' (or a conditional value) for the proxy to function. [CRITICAL]
  • Inconsistent distinct_id between login and signup: login.tsx uses username as the distinct_id while signup.tsx uses newUser.id. This creates fragmented user profiles — the same person will have two different identities depending on their entry path. Login should use the user's stable ID, not their username. [MEDIUM]
  • PII (email) in capture event properties: signup.tsx sends { username: newUser.username, email: newUser.email } as properties in posthog.capture('user_signed_up', ...). Email is PII and belongs in identify() person properties (which is already done correctly), not in event properties. [MEDIUM]

File changes

Filename Score Description
app/entry.client.tsx 4/5 Client-side PostHog init with PostHogProvider and tracing headers. Well-structured but api_host doesn't point to the reverse proxy.
app/lib/posthog-middleware.ts 5/5 Server-side middleware follows the docs pattern exactly — per-request client, session/distinct ID from headers, withContext(), and shutdown().
app/root.tsx 4/5 Registers middleware and adds captureException in ErrorBoundary. Missing optional chaining on posthog.captureException().
app/routes/countries.tsx 5/5 Good event captures with enriched properties for claim, like, and visit actions in event handlers.
app/routes/country.tsx 4/5 Captures country_viewed via useEffect on mount — acceptable for a page-view-like event, though the posthog dependency is missing from the useEffect dependency array.
app/routes/login.tsx 3/5 Identifies user with username as distinct_id instead of stable user ID. Also sends username as person property only.
app/routes/profile.tsx 5/5 Clean logout handling — captures event, calls reset(), then calls logout().
app/routes/signup.tsx 3/5 Correct identify with newUser.id but leaks email as PII in the capture event properties.
package.json 5/5 All three packages added: posthog-js, @posthog/react, posthog-node.
react-router.config.ts 5/5 Correctly enables v8_middleware future flag for middleware support.
vite.config.ts 4/5 SSR noExternal and proxy routes configured correctly per docs, but proxy is unused without matching api_host.
posthog-setup-report.md 5/5 Informational report file.

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes Packages installed, SSR noExternal configured, middleware flag enabled
Preserves existing env vars & configs Yes Existing code preserved; logout handler properly wrapped
No syntax or type errors Yes All files syntactically valid
Correct imports/exports Yes All imports resolve correctly (posthog-js, @posthog/react, posthog-node)
Minimal, focused changes Yes All changes directly support PostHog integration
Pre-existing issues None

Issues

  • Missing optional chaining in ErrorBoundary: posthog.captureException(error) in root.tsx should use posthog?.captureException(error) since usePostHog() can return undefined if PostHog isn't initialized. [LOW]

Other completed criteria

  • Environment variables documented in .env file with VITE_PUBLIC_POSTHOG_PROJECT_TOKEN and VITE_PUBLIC_POSTHOG_HOST
  • Build configuration valid — package.json dependencies correct, vite.config.ts properly structured
  • All changes relevant to PostHog integration

PostHog implementation ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js, @posthog/react, and posthog-node added to package.json
PostHog client initialized Yes posthog.init() in entry.client.tsx with PostHogProvider wrapping the app; server middleware creates per-request posthog-node client
capture() Yes 7 meaningful custom events across 5 route files
identify() Yes Called on login and signup, but with inconsistent distinct_id values
Error tracking Yes captureException() in root ErrorBoundary component
Reverse proxy No Vite dev-server proxy configured at /ingest but api_host in posthog.init() still points to us.i.posthog.com, so the proxy is never used

Issues

  • Reverse proxy not connected: The proxy routes in vite.config.ts correctly forward /ingest/static and /ingest/array to us-assets.i.posthog.com and /ingest to the PostHog host. However, posthog.init() sets api_host to import.meta.env.VITE_PUBLIC_POSTHOG_HOST (https://us.i.posthog.com) rather than '/ingest'. The SDK will send requests directly to PostHog, bypassing the proxy entirely. Fix: set api_host: '/ingest' in the init call (at least in dev). [CRITICAL]
  • Inconsistent distinct_id: login.tsx calls posthog?.identify(username, ...) using the username string, while signup.tsx calls posthog?.identify(newUser.id, ...) using the nanoid-based user ID. This means the same user gets different distinct_ids depending on their path. Login should resolve the user object and use user.id as the distinct_id. [MEDIUM]

Other completed criteria

  • API key loaded from environment variable (VITE_PUBLIC_POSTHOG_PROJECT_TOKEN)
  • Host correctly configured from environment variable
  • Server middleware correctly uses withContext() for session correlation
  • posthog.reset() called on logout
  • __add_tracing_headers enabled for client-server correlation

PostHog insights and events ⚠️

Filename PostHog events Description
app/routes/signup.tsx user_signed_up Captured on successful signup with username and email properties
app/routes/login.tsx user_logged_in Captured on successful login with username property
app/routes/profile.tsx user_logged_out Captured before reset on logout
app/routes/countries.tsx country_claimed, country_liked, country_visited User interactions with country cards, includes country name and region
app/routes/country.tsx country_viewed Page-view event for country detail, includes country name and region
app/root.tsx captureException Automatic error tracking in ErrorBoundary

Issues

  • PII in capture event properties: signup.tsx sends email: newUser.email in the capture('user_signed_up', ...) properties. Email is PII and should only appear in person properties via identify() (which is already done correctly one line above). Remove email from the capture properties. [MEDIUM]

Other completed criteria

  • Events represent real user actions (signup, login, logout, country interactions)
  • Events enable product insights — can build signup funnel, engagement trends, retention analysis
  • Events include enriched properties (country, region for interactions)
  • Event names are descriptive and use consistent snake_case convention

Reviewed by wizard workbench PR evaluator

@wizard-ci-bot wizard-ci-bot Bot added the CI/CD label May 13, 2026
@wizard-ci-bot wizard-ci-bot Bot closed this May 13, 2026
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