Skip to content

feat: search/404 analytics tracking + deploy-workflow hardening#88

Merged
enoch85 merged 1 commit into
mainfrom
feat/analytics-tracking-ci-hardening
Jun 5, 2026
Merged

feat: search/404 analytics tracking + deploy-workflow hardening#88
enoch85 merged 1 commit into
mainfrom
feat/analytics-tracking-ci-hardening

Conversation

@enoch85

@enoch85 enoch85 commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds two consent-gated analytics signals and hardens the deploy workflow (from the codebase security review).

Why site-search tracking

The goal is to learn what people are looking for in the docs — and what they can't find. Search queries are the most direct signal of intent and of content gaps: recurring searches point to topics worth adding or surfacing better, and (via Matomo's Search Keywords with No Results) show where the docs fall short.

Design reasoning:

  • JS trackSiteSearch API rather than Matomo's URL-parameter detection — the docs search (@easyops-cn/docusaurus-search-local) is an instant as-you-type dropdown and never navigates to a /search?q= page, so Matomo's automatic URL-based detection would never fire. Hooking the input is the only way to capture queries.
  • Debounce (1.5s) + min length (3) + dedupe — as-you-type fires on every keystroke; debouncing records the settled, intended query instead of i, in, ins, … and trims noise.
  • Also fire on Enter — captures fast typers who submit before the debounce.
  • Listener is scoped to .navbar__search-input, so no other field is read.

Analytics (cookieless, only after Accept)

  • Site-search tracking — docs-search queries sent via Matomo trackSiteSearch (debounced + on Enter, min 3 chars, deduped).
  • 404 tracking — a swizzled NotFound page flags the next page view so it's tagged with Matomo's standard 404/URL = …/From = referrer convention (shows broken URLs + referrers in the 404 report).

Both stay within the existing "privacy-friendly, cookieless" model (disableCookies, consent-gated).

CI hardening (docusaurus_ci.yml)

Defense-in-depth from the security review (not an externally exploitable bug — both paths require contents: write):

  • Release-dispatch builds now check out the trusted default branch instead of an externally supplied client_payload.ref (removes "privileged build pointed at arbitrary code").
  • The version-snapshot push passes the branch name via env:, format-validates it, and uses a quoted refs/heads/ refspec instead of ${{ }} shell interpolation.

Verification

  • npm run build ✅ · npm run format:check
  • Workflow YAML validated.

Matomo-side note

Site Search is already enabled for site 2 (Maintainerr Docs). Result count is sent as unset, so the Search Keywords with No Results report won't populate yet — a follow-up could read the dropdown's result count to enable content-gap analysis.

Analytics (consent-gated, cookieless):
- Track docs-search queries via Matomo trackSiteSearch (debounced + on Enter,
  min length, deduped) — listener scoped to the search input only.
- Tag 404 page views using Matomo's "404/URL = ..." convention via a swizzled
  NotFound page that flags the next page view.

CI hardening (docusaurus_ci.yml):
- Release-dispatch builds now check out the trusted default branch instead of
  an externally supplied client_payload.ref.
- The version-snapshot push uses an env var + format-validated, quoted
  refs/heads/ refspec instead of interpolating the branch name into the shell.
@enoch85 enoch85 merged commit 0391dac into main Jun 5, 2026
3 checks passed
@enoch85 enoch85 deleted the feat/analytics-tracking-ci-hardening branch June 5, 2026 23:06
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.

1 participant