feat(highperformer): load Google Analytics from backend-supplied config - #308
Merged
Merged
Conversation
The measurement id comes from /api/info at runtime, not a build-time VITE_ variable: one image is deployed to several environments, so a baked-in id could not differ between them. No id means no script — that is how a deployment opts out, and why the GitHub Pages build stays untracked. The tag is injected once and guarded by a ref, because the hook re-runs on every navigation and loading gtag.js repeatedly would register duplicate handlers. gtag's own page_view is disabled via send_page_view: false and each route change sends one explicitly, so the first view is not counted twice. Full paths including query strings are reported deliberately, so which dataset was opened is visible. Also regenerates the API client, which corrects obs_columns on the catalogue response from string[] to ObsColumnInfo[] — stale since the facet work landed.
Merged
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.
Loads Google Analytics when the backend supplies a measurement id. Pairs with cBioPortal/cell-explorer-py#194, which adds the id to
/api/info.How the id arrives
At runtime from
/api/info, not a build-timeVITE_variable. The frontend is built into the backend image, and one image is deployed to several environments — a baked-in id could not differ between them./api/infoalready carries runtime config the app reads on boot (auth_enabled,chat_enabled), so this travels the same proven path.No id means no script is loaded at all. That is how a deployment opts out, and why the GitHub Pages build stays untracked: it has no backend to ask.
Two details worth reviewing
The tag is injected once, guarded by a ref. The hook re-runs on every navigation, and loading
gtag.jsrepeatedly would register duplicate handlers and double-count.gtag's own page view is disabled (
send_page_view: false) and each route change sends one explicitly. Otherwise the tag fires its own on load and the first view is counted twice.What gets reported
Full paths including query strings, so which dataset was opened is visible in the reports. That was a deliberate call — dataset identity, including private datasets a user authenticated to reach, leaves our infrastructure.
Embedded views
Not special-cased. The iframe loads this same app from the same origin, so it reports to the same property as a standalone visit. That is not double-counting: the embedding page reports to its own property, which counts a different thing. Iframe sessions will show
cbioportal.orgas referrer, and browser cookie partitioning means embedded users may be over-counted as new — a reporting caveat rather than something to engineer around.Also
Regenerates the API client, which corrects
obs_columnson the catalogue response fromstring[]toObsColumnInfo[]— stale since the facet work landed, and wrong in a way TypeScript would not have caught at build time sincebuilddoes not typecheck.Typecheck is unchanged at the 13 pre-existing errors; 632 tests pass.