Skip to content

Conversation

@wizard-ci-bot
Copy link

@wizard-ci-bot wizard-ci-bot bot commented Jan 16, 2026

Automated wizard CI run

Source: manual
Trigger ID: afd8cc2
App: react-router/shopper
App directory: apps/react-router/shopper
Workbench branch: wizard-ci-afd8cc2-react-router-shopper
Wizard branch: main
Examples branch: main
PostHog (MCP) branch: master
Timestamp: 2026-01-16T13:59:31.386Z
Duration: 309.5s

@wizard-ci-bot
Copy link
Author

wizard-ci-bot bot commented Jan 16, 2026

Now I have all the information needed to write the evaluation. Let me compile the PR review:


PR Evaluation Report

Summary

This PR adds PostHog analytics integration to a React Router 7 e-commerce application (Shopper). The integration includes client-side SDK initialization, server-side middleware with posthog-node, error tracking via ErrorBoundary, and comprehensive e-commerce event tracking across the shopping funnel. The implementation is well-structured but has notable issues with the client initialization config and the proxy setup only works in dev mode.

Files changed Lines added Lines removed
13 +766 -8

Confidence score: 3/5 🤔

  • Invalid PostHog init config: The defaults: '2025-11-30' option in entry.client.tsx is not a valid PostHog configuration option. This should be removed or replaced with valid config. [CRITICAL]
  • Reverse proxy only works in development: The Vite proxy configuration in vite.config.ts only applies during dev server, not in production builds. Production deployments will not have adblock circumvention. [MEDIUM]
  • Search event fires on every keystroke: The product_searched event fires on every character typed, which will create excessive event volume. Consider debouncing or firing on blur/submit. [MEDIUM]

File changes

Filename Score Description
app/entry.client.tsx 3/5 New file - PostHog client-side initialization with PostHogProvider wrapper. Has invalid defaults config option and tracing headers setup
app/lib/posthog-middleware.ts 4/5 New file - Server-side middleware using posthog-node with session/distinct ID context propagation
app/root.tsx 4/5 Adds middleware export and error tracking via captureException in ErrorBoundary
app/routes/cart.tsx 5/5 Adds cart events: product_removed_from_cart, cart_quantity_updated, checkout_started with rich properties
app/routes/checkout.tsx 5/5 Adds order_completed event and posthog.identify() for user identification during checkout
app/routes/home.tsx 4/5 Adds start_shopping_clicked event for CTA tracking
app/routes/products..tsx 4/5 Adds product_viewed (via useEffect) and product_added_to_cart events
app/routes/products.tsx 3/5 Adds product_added_to_cart, product_searched (no debounce), and category_filtered events
package.json 5/5 Adds @posthog/react, posthog-js, and posthog-node dependencies
react-router.config.ts 5/5 Enables v8_middleware future flag for middleware support
vite.config.ts 3/5 Adds SSR noExternal config and proxy setup, but proxy only works in dev mode
package-lock.json 5/5 Lock file updated with PostHog and dependencies
posthog-setup-report.md 4/5 Documentation of implemented events and setup instructions

App sanity check: 4/5 ✅

Criteria Result Description
App builds and runs Yes Build completes successfully with both client and server bundles
Preserves existing env vars & configs Yes Original configs preserved, only additive changes
No syntax or type errors Yes Build passes, TypeScript types are correct
Correct imports/exports Yes All imports from @posthog/react, posthog-js, posthog-node are correct
Minimal, focused changes Yes Changes are scoped to PostHog integration only

Issues

  • Invalid init config option: The defaults: '2025-11-30' in entry.client.tsx is not a valid PostHog configuration option and will be ignored or could cause issues. Remove this option. [MEDIUM]

Other completed criteria

  • Environment variables documented in .env file
  • Build configuration is valid
  • Consistent with existing patterns (uses React Router conventions)
  • Clear, readable code throughout
  • No unnecessary modifications to existing logic

PostHog implementation: 3/5 ⚠️

Criteria Result Description
PostHog SDKs installed Yes posthog-js: ^1.325.0, posthog-node: ^5.21.0, @posthog/react: ^1.5.2
PostHog client initialized Partial Client initialized in entry.client.tsx with PostHogProvider, but has invalid defaults config
capture() Yes Multiple capture calls across all routes with rich event properties
identify() Yes User identified during checkout with email and name
Error tracking Yes ErrorBoundary uses posthog?.captureException(error)
Reverse proxy Partial Vite dev proxy configured for /ingest, but doesn't work in production

Issues

  • Invalid defaults config: defaults: '2025-11-30' is not a valid PostHog init option. Remove this line from entry.client.tsx. [CRITICAL]
  • Production proxy missing: The Vite server proxy only works during development. Production deployments need a separate reverse proxy configuration (e.g., in nginx, Cloudflare, or framework-specific rewrites). Events in production will be blocked by adblockers. [MEDIUM]
  • api_host not pointing to proxy: The api_host is set to VITE_PUBLIC_POSTHOG_HOST (direct PostHog URL) but should use /ingest to leverage the proxy for adblock circumvention. [MEDIUM]
  • Page view tracking: No explicit pageview tracking setup. PostHog autocapture may handle this, but manual `` capture or capture_pageview: true init option would be more explicit. [LOW]

Other completed criteria

  • Server-side middleware properly initializes posthog-node with flush settings
  • Session and distinct ID context propagation via headers
  • PostHogProvider wraps the entire app in entry.client.tsx
  • No PII in event properties (email only used in identify, not capture)
  • SSR configuration properly excludes posthog-js from server bundle
  • __add_tracing_headers configured for session correlation

PostHog insights and events: 4/5 ✅

Filename PostHog events Description
app/routes/home.tsx start_shopping_clicked Top-of-funnel CTA engagement tracking
app/routes/products.tsx product_added_to_cart, product_searched, category_filtered Product discovery and shopping behavior
app/routes/products..tsx product_viewed, product_added_to_cart Product detail page engagement with source differentiation
app/routes/cart.tsx product_removed_from_cart, cart_quantity_updated, checkout_started Cart management and checkout funnel entry
app/routes/checkout.tsx order_completed Conversion event with full order details
app/root.tsx captureException Error tracking for application errors

Issues

  • Search event fires too frequently: product_searched fires on every keystroke which will create noisy data and high event volume. Implement debouncing (e.g., 500ms) or fire on search submit/blur instead. [MEDIUM]
  • No cart viewed event: Missing a cart_viewed event when users navigate to the cart page, which would help complete the funnel analysis. [LOW]

Other completed criteria

  • Complete e-commerce funnel coverage from discovery to purchase
  • Events enriched with relevant properties (product_id, product_name, price, category, quantity)
  • Source differentiation (products_listing vs product_detail) for add-to-cart events
  • Order details captured comprehensively (items, totals, tax, shipping info)
  • User identification enables cohort analysis and user property tracking
  • Category and search filtering tracked for product discovery insights
  • Quantity change tracking captures both previous and new values with delta

Reviewed by wizard workbench PR evaluator

@wizard-ci-bot wizard-ci-bot bot added the CI/CD label Jan 16, 2026
@wizard-ci-bot wizard-ci-bot bot closed this Jan 16, 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.

1 participant