Skip to content

feat(highperformer): load Google Analytics from backend-supplied config - #308

Merged
hweej merged 1 commit into
mainfrom
feat/google-analytics
Aug 31, 2026
Merged

hweej merged 1 commit into
mainfrom
feat/google-analytics

Conversation

@hweej

@hweej hweej commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

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-time VITE_ 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/info already 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.js repeatedly 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.org as 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_columns on the catalogue response from string[] to ObsColumnInfo[] — stale since the facet work landed, and wrong in a way TypeScript would not have caught at build time since build does not typecheck.

Typecheck is unchanged at the 13 pre-existing errors; 632 tests pass.

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.
@hweej hweej added the enhancement New feature or request label Aug 31, 2026
@hweej hweej self-assigned this Aug 31, 2026
@hweej
hweej merged commit 8759a9d into main Aug 31, 2026
6 checks passed
@hweej
hweej deleted the feat/google-analytics branch August 31, 2026 14:40
@github-actions github-actions Bot mentioned this pull request Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant