Skip to content

📦🔧:update the vendored analytics script - #1864

Merged
openinf-commit-queue[bot] merged 1 commit into
livefrom
chore/update-goatcounter
Aug 26, 2026
Merged

openinf-commit-queue[bot] merged 1 commit into
livefrom
chore/update-goatcounter

Conversation

@DerekNonGeneric

@DerekNonGeneric DerekNonGeneric commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

The vendored copy was taken in 2024 and upstream has moved six times
since. This replaces it with what gc.zgo.at/count.js serves today.

Provenance, established rather than assumed

what we had byte for byte upstream at 10d7e6e2 (2024-06-03)
what we ship now byte for byte upstream at 478f026e (2026-04-07)
gc.zgo.at/count.js today byte for byte upstream master

The old copy had no local edits, so this is a clean swap with
nothing of ours to preserve. Every one of the 34 changed lines maps to
a real upstream commit:

commit date what it does
6ebd8067 2025-05-23 clearer "append not found" warning
b41aa43a 2025-05-30 drops the window.goatcounter.vars shim
c8f63598 2025-06-04 drops the window.counter shim
6731d117 2025-06-21 removes the sizes table
d8d8b7a9 2026-03-04 checks navigator.sendBeacon exists
478f026e 2026-04-07 per-hit no_session

One of them is the reason to do this now

Upstream stopped collecting screen size beyond the width. Our copy did
not, so every visit has been sending screen height and device pixel
ratio to a server that removed the table they went in.

Measured on a phone viewport, building each version and reading what
goatcounter.url() produces:

previous (2024-06 copy):    s = "390,844,3"     width, height, pixel ratio
updated  (upstream master): s = "390"           width

Height and pixel ratio are a fingerprinting surface, and they were
being sent for nothing.

Second most useful: navigator.sendBeacon was called unguarded, so an
environment without it threw instead of falling back to the image
beacon.

Verified

  • the published file is byte for byte upstream master
  • the script loads with no page errors, and goatcounter.count is
    defined
  • nps test passes

Size is near enough unchanged: 9,148 → 9,213 bytes, slightly larger.

Keeping it in sync

#1865 watches this file weekly and opens an issue when it drifts. Kept
separate because it is a mechanism rather than a version bump, and
because this diff should read as nothing but what upstream changed.

Refs #1548

Summary by CodeRabbit

  • Bug Fixes
    • Improved analytics tracking reliability when browser features such as navigator or sendBeacon are unavailable.
    • Preserved existing tracking configuration during initialization.
    • Added support for excluding session data from tracking requests.
    • Updated visit-count warning messaging.

The copy here was taken in 2024 and upstream has moved six times since.
It is replaced with what `gc.zgo.at/count.js` serves today, which is
byte for byte what the project has at
478f026eb9deacb9378a46b96db72e11e9f20557.

One of those six matters beyond the byte count. Upstream removed the
sizes table, and the script now sends the screen width alone; the copy
here still sent the height and the pixel ratio with every visit, to a
server with nowhere left to put them. Measured on a phone viewport,
`s` went from `390,844,3` to `390`.

The rest: `navigator.sendBeacon` is checked before it is called rather
than assumed, two compatibility shims for versions long gone are out,
a warning reads better, and a per-hit way to skip a session arrived.

The file stays byte for byte upstream's, with no local edits, so
telling whether it has drifted is one `diff` away.

Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is>
Assisted-by: Claude-Code:claude-opus-5
Refs: #1548
@netlify

netlify Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for gh-pages-openinf ready!

Name Link
🔨 Latest commit c47f6df
🔍 Latest deploy log https://app.netlify.com/projects/gh-pages-openinf/deploys/6a8e237a06183d0008725d8e
😎 Deploy Preview https://deploy-preview-1864--gh-pages-openinf.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@DerekNonGeneric

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c97b23f-4d32-4526-8ba1-20248eb0e554

📥 Commits

Reviewing files that changed from the base of the PR and between 1cddc7b and c47f6df.

📒 Files selected for processing (1)
  • _assets/js/vendor/count.js

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The GoatCounter script now preserves the existing global object, exposes request helpers, adds no-session fields, reduces screen data, removes the legacy endpoint fallback, and handles missing beacon APIs before using image requests.

Changes

GoatCounter tracking

Layer / File(s) Summary
Public tracking API and request data
_assets/js/vendor/count.js
Initialization preserves window.goatcounter. get_data and filter are exposed publicly. Request data supports no_session and records screen width only.
Request and click tracking flow
_assets/js/vendor/count.js
Endpoint resolution no longer uses window.counter. Beacon handling checks for unavailable browser APIs. Click requests include the element’s no-session setting. The visit-count warning text identifies the target as an element.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c47f6

This localized vendor refresh removes unnecessary screen-height and pixel-ratio data and adds a safe beacon fallback without changing local application code; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: updating the vendored analytics script. It is concise and related to the pull request, although the emojis are unnecessary.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/update-goatcounter

Comment @coderabbitai help to get the list of available commands.

@OpenINFbot OpenINFbot added the 🚀 Status: Commit Queue Land this pull request when its checks pass label Aug 26, 2026
@openinf-commit-queue
openinf-commit-queue Bot merged commit 6fcfdfd into live Aug 26, 2026
18 checks passed
@openinf-commit-queue openinf-commit-queue Bot removed the 🚀 Status: Commit Queue Land this pull request when its checks pass label Aug 26, 2026
@DerekNonGeneric
DerekNonGeneric deleted the chore/update-goatcounter branch September 6, 2026 21:15
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.

2 participants