Skip to content

fix: port analytics review improvements from website PR - #1463

Open
ajbozarth wants to merge 1 commit into
generative-computing:mainfrom
ajbozarth:fix/docs-analytics-review-parity
Open

fix: port analytics review improvements from website PR#1463
ajbozarth wants to merge 1 commit into
generative-computing:mainfrom
ajbozarth:fix/docs-analytics-review-parity

Conversation

@ajbozarth

Copy link
Copy Markdown
Contributor

Issue

Fixes #

Description

The website analytics script (mellea-website#72) was forked from this repo's docs analytics script, then refined during review. This ports those improvements back:

  • Restrict to production host — analytics now runs only on docs.mellea.ai. Previously it ran everywhere except localhost/127.0.0.1, so the planetf1.github.io fork/preview build reported to the prod siteId.
  • Poll for ibmStats instead of a single 100ms wait, so the initial pageview isn't dropped on a cold cache.
  • Track pushState/replaceState navigations so non-Chromium browsers (Firefox/Safari, which lack the Navigation API) record in-app page views, not just the entry page. Docusaurus is a client-side SPA, so this was previously losing nearly all navigation events on those browsers.
  • Remove dead script.defer on the dynamically injected script tag (no effect on injected scripts).

The website PR's basePath fix does not apply here — the config already loads the script via ${BASE_URL}analytics.js.

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code was added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Client-side analytics script; no automated test coverage. Verified the host gate, ibmStats poll, and history-patching logic by inspection against the reviewed website script.

Attribution

  • AI coding assistants used

  • Component
  • Requirement
  • Sampling Strategy
  • Tool

The website (mellea-website#72) forked its analytics script from this
repo's docs script, then refined it during review. Bring those fixes back:

- Restrict analytics to the docs.mellea.ai production host so localhost
  and the planetf1.github.io preview build no longer report to the prod
  siteId
- Poll for ibmStats instead of a single 100ms wait, so the initial
  pageview isn't dropped on a cold cache
- Track pushState/replaceState navigations so non-Chromium browsers
  record in-app page views, not just the entry page
- Remove dead script.defer on the dynamically injected script tag

Assisted-by: Claude Code
Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth
ajbozarth requested a review from a team as a code owner July 28, 2026 20:52
@ajbozarth ajbozarth self-assigned this Jul 28, 2026
@github-actions github-actions Bot added the bug Something isn't working label Jul 28, 2026
@ajbozarth ajbozarth added the documentation Improvements or additions to documentation label Jul 28, 2026

@markstur markstur left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Verdict: ✅ Faithful port — The PR correctly adapts the mellea-website fixes:

  1. Host check properly changed from mellea.ai → docs.mellea.ai (correct for this repo's deployment)
  2. Polling logic is byte-for-byte identical
  3. History API fallback is identical
  4. script.defer removal is included
    The only difference is the production hostname, which is correct since this repo's docs deploy to docs.mellea.ai, not mellea.ai.

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

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants