Skip to content

[CI] (0ae2102) react-router/shopper - #1239

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

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

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

@wizard-ci-bot

wizard-ci-bot Bot commented Apr 15, 2026

Copy link
Copy Markdown
Author

PR Evaluation Report

Summary

This PR integrates PostHog into a React Router v7 (framework mode) e-commerce "Shopper" app. It adds client-side initialization via entry.client.tsx with PostHogProvider, server-side middleware using posthog-node, error tracking in the ErrorBoundary, a reverse proxy configuration in Vite, and comprehensive e-commerce event tracking across product, cart, and checkout routes.

Files changed Lines added Lines removed
11 +229 -4

Confidence score: 5/5 🧙

  • Reverse proxy only works in dev server: The Vite server.proxy config only applies during vite dev. In production, requests to /ingest will not be proxied — a separate production proxy (e.g., server middleware or hosting-level rewrite) is needed. Additionally, the posthog.init() call never sets api_host to /ingest, so even in dev the proxy is unused. [MEDIUM]
  • product_searched fires on every keystroke: The handleSearch function captures product_searched on every call with a non-empty term, which likely fires on every keystroke as the user types — producing excessive, low-value events. A debounce or submit-based approach would be more appropriate. [MEDIUM]
  • product_viewed captured in useEffect without proper deps: The useEffect in products..tsx lists [product.id] but omits posthog from the dependency array. While functionally this works (posthog reference is stable), it violates React's exhaustive-deps rule and the useEffect pattern is acceptable here since it's synchronizing with an external system (PostHog analytics). [LOW]

File changes

Filename Score Description
app/entry.client.tsx 5/5 New file initializing posthog-js with env vars, tracing headers, and PostHogProvider — matches React Router v7 framework mode docs exactly
app/lib/posthog-middleware.ts 5/5 Server-side middleware using posthog-node with context-based session/distinct ID extraction, matching docs pattern
app/root.tsx 4/5 Exports middleware array and adds error tracking via captureException in ErrorBoundary — correct pattern
app/routes/cart.tsx 5/5 Well-structured event captures for cart actions in event handlers
app/routes/checkout.tsx 4/5 Captures order_placed with rich properties inside setTimeout callback
app/routes/products..tsx 4/5 Captures product_viewed and product_added_to_cart with good properties
app/routes/products.tsx 3/5 Good events but product_searched fires too frequently without debounce
package.json 5/5 Correctly adds posthog-js, @posthog/react, and posthog-node
posthog-setup-report.md 5/5 Thorough documentation of all changes and events
react-router.config.ts 5/5 Correctly enables v8_middleware future flag
vite.config.ts 3/5 SSR noExternal is correct, but proxy config is dev-only and not referenced by init

App sanity check ⚠️

Criteria Result Description
App builds and runs Yes All syntax is valid, dependencies added, configs correct
Preserves existing env vars & configs Yes Existing code in root.tsx and route files preserved; only PostHog additions
No syntax or type errors Yes TypeScript/JSX syntax is correct throughout
Correct imports/exports Yes All imports from posthog-js, @posthog/react, posthog-node, and react-router are correct
Minimal, focused changes Yes All changes relate to PostHog integration
Pre-existing issues None Base app appears clean

Issues

  • Vite proxy is dev-only: The server.proxy in vite.config.ts only functions during local development with vite dev. Production builds served via @react-router/serve won't have this proxy. The posthog.init() also doesn't point api_host to /ingest, so the proxy is effectively unused even in dev. [MEDIUM]

Other completed criteria

  • Environment variables documented via .env.local pattern (uses VITE_PUBLIC_POSTHOG_PROJECT_TOKEN and VITE_PUBLIC_POSTHOG_HOST)
  • Build configuration is valid — SSR noExternal correctly configured for posthog-js and @posthog/react
  • react-router.config.ts correctly enables middleware with future: { v8_middleware: true }

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 Client: posthog.init() in entry.client.tsx with env vars, defaults, and tracing headers. Server: new PostHog() in middleware with flushAt: 1, flushInterval: 0
capture() Yes 9 meaningful capture calls across 4 route files
identify() No No posthog.identify() call found anywhere — no user identification on login or page load
Error tracking Yes posthog.captureException(error) in ErrorBoundary in root.tsx
Reverse proxy No Vite server.proxy is dev-only and api_host in posthog.init() is not set to /ingest, so the proxy is never actually used

Issues

  • No user identification: There is no posthog.identify() call anywhere in the codebase. The PostHog docs explicitly state "Identifying users is required." Without identify, all events are anonymous and cannot be associated with specific users across sessions. This is especially important for an e-commerce app where understanding per-user purchase behavior is critical. [CRITICAL]
  • Reverse proxy not functional: The Vite dev server proxy at /ingest is configured, but posthog.init() sets api_host to the raw PostHog host URL, not /ingest. The proxy is never hit. In production, Vite's server.proxy doesn't exist at all. A proper production reverse proxy (e.g., via React Router server middleware or hosting rewrites) is needed, and api_host should be set to /ingest to use it. [MEDIUM]

Other completed criteria

  • API key loaded from environment variables (import.meta.env.VITE_PUBLIC_POSTHOG_PROJECT_TOKEN on client, process.env.VITE_PUBLIC_POSTHOG_PROJECT_TOKEN on server)
  • API host correctly configured from environment variables
  • Server-side middleware correctly extracts session/distinct ID headers and uses posthog.withContext()
  • Tracing headers enabled with __add_tracing_headers for client-server correlation
  • posthog.shutdown() called after middleware completes

PostHog insights and events ✅

Filename PostHog events Description
app/routes/products..tsx product_viewed, product_added_to_cart Top-of-funnel product detail view and add-to-cart action with product properties
app/routes/products.tsx product_added_to_cart_from_listing, product_searched, category_filter_changed Product listing interactions including search and category filtering
app/routes/cart.tsx product_removed_from_cart, cart_quantity_updated, checkout_started Cart management events with item details and cart totals
app/routes/checkout.tsx order_placed Bottom-of-funnel purchase completion with order total and items
app/root.tsx captureException Unhandled error tracking via ErrorBoundary

Issues

  • product_searched fires too frequently: The search event fires on every call to handleSearch, which is likely triggered on every keystroke. This will flood PostHog with noisy, incomplete search terms. Should debounce or capture on form submit / blur instead. [MEDIUM]

Other completed criteria

  • Events represent real user actions mapping to a complete e-commerce funnel (view → add to cart → checkout → purchase)
  • Events enable product insights — a full purchase funnel can be built from product_viewed → product_added_to_cart → checkout_started → order_placed
  • Events include rich contextual properties (product_id, product_name, category, price, quantity, cart totals, item arrays)
  • No PII in event properties — no emails, names, or personal data in capture calls
  • Event names are descriptive, consistent snake_case, and clearly describe the action

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