Skip to content

feat(ui): track solve_run analytics event - #20

Open
aeronauty-flexcompute wants to merge 3 commits into
mainfrom
harry/solve-run-analytics
Open

aeronauty-flexcompute wants to merge 3 commits into
mainfrom
harry/solve-run-analytics

Conversation

@aeronauty-flexcompute

@aeronauty-flexcompute aeronauty-flexcompute commented Jul 25, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Vera asked whether FlexFoil is actually being used. Page views and engagement cannot tell us how many solves people request. This adds that measurement as an explicit opt-in.

What

Solve analytics are off by default. Set VITE_SOLVE_RUN_ANALYTICS=true when starting or building flexfoil-ui to enable them. Without that exact setting, the solve paths skip both the event call and event parameter construction.

With the flag on, the existing optional window.gtag helper sends solve_run at dispatch:

solve_mode Trigger
single_alpha / single_cl Single point, alpha or CL targeting
polar Alpha polar sweep
sweep_1d / sweep_2d Parameter sweep

Each event carries only solver_mode and n_panels alongside the mode. It measures solves requested, regardless of convergence. Existing consent behavior is unchanged; geometry, coordinates and filenames are not added to the event.

Validation

At 3e71453f610403b7596ec38f40dd169ca7d5633e:

  • cd flexfoil-ui && npx vitest run --maxWorkers=1: 71 tests across six files passed, including missing/false/non-true settings and explicit true.
  • cd flexfoil-ui && npx tsc -b: passed.
  • npx playwright test --config e2e/analytics/playwright.config.mts: 10 Chrome checks passed. The real SolvePanel runs all five modes with analytics off and on, using an offline solver and in-memory persistence. They check identical deterministic dispatch/results, no default events and the exact enabled payload.
  • Temporarily forcing the flag on makes the default browser test fail. Restoring the source returns all 10 checks to passing.
  • Analytics file lint and diff checks passed. SolvePanel retains the same six lint errors and two warnings as the incoming PR head, compared by rule, severity and diagnostic.

The browser fixture verifies UI dispatch and analytics, not solver accuracy. This isolated clone has no built WASM package, so a full production bundle and live solver validation were not rerun.

Activation after merge

A normal build stays off. Enabling analytics requires the explicit build setting above. GA4 event breakdowns still require registering the mode parameters as custom dimensions; the event counts do not. No deployment or merge was performed here.

Original analytics change by Claude Code; opt-in gate and regression checks by Codex.


Note

Low Risk
Analytics are build-time opt-in and send only coarse solve metadata through existing consent-gated gtag; solve execution paths are unchanged unless the flag is explicitly enabled.

Overview
Adds opt-in solve usage analytics behind VITE_SOLVE_RUN_ANALYTICS=true (off by default). When enabled, single-point, polar, and sweep dispatches in SolvePanel call a new trackEvent helper to emit GA4 solve_run with only solve_mode, solver_mode, and n_panels; solver work and results are unchanged when the flag is off.

Introduces Vitest coverage for the flag gate and gtag forwarding, plus an isolated Playwright suite that mounts real SolvePanel with an offline WASM stub—verifying identical solve dispatch for all five modes with analytics off vs. the exact event payload when on. Root Playwright config ignores e2e/analytics/**; README documents activation and how to run the regression checks.

Reviewed by Cursor Bugbot for commit 4339827. Bugbot is set up for automated code reviews on this repo. Configure here.

aeronauty and others added 2 commits July 26, 2026 00:49
GA4 carried only the six default events, so we could measure that people
opened FlexFoil but not that they ran anything. Engagement time was the
closest available proxy.

Add a trackEvent helper to lib/analytics and fire solve_run from the three
user-initiated solve paths in SolvePanel: single-point (alpha and CL
targeting), alpha polar, and parameter sweeps. Params record which mode was
used, viscous vs inviscid, and panel count.

Fired at dispatch rather than completion so the count reflects solves
requested, independent of convergence. Consent Mode still gates delivery,
so this collects nothing extra from users who decline cookies.

Co-Authored-By: claude-flow <ruv@ruv.net>
Keep solve event dispatch and parameter allocation disabled unless VITE_SOLVE_RUN_ANALYTICS=true. Cover all five solve modes with isolated default-off and explicit-on browser acceptance.

Co-Authored-By: Codex <noreply@openai.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Analytics specs leak into root suite
    • The root Playwright config now ignores e2e/analytics/**, so npm run test:e2e no longer runs the fixture specs against the Vite app while the dedicated analytics config still collects them.

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 3e71453. Configure here.

Comment thread e2e/analytics/solve-analytics.spec.ts
The root config uses e2e/ as testDir, so solve-analytics.spec.ts ran
against the Vite app and failed looking for fixture.html.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants