Repository navigation
feat(ui): track solve_run analytics event - #20
Open
aeronauty-flexcompute wants to merge 3 commits into
Open
aeronauty-flexcompute wants to merge 3 commits into
aeronauty-flexcompute wants to merge 3 commits into
Conversation
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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=truewhen starting or buildingflexfoil-uito 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.gtaghelper sendssolve_runat dispatch:solve_modesingle_alpha/single_clpolarsweep_1d/sweep_2dEach event carries only
solver_modeandn_panelsalongside 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.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 inSolvePanelcall a newtrackEventhelper to emit GA4solve_runwith onlysolve_mode,solver_mode, andn_panels; solver work and results are unchanged when the flag is off.Introduces Vitest coverage for the flag gate and
gtagforwarding, plus an isolated Playwright suite that mounts realSolvePanelwith 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 ignorese2e/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.