Only track analytics on the production hostname - #46
Merged
Conversation
Secrets belong to the Worker rather than to a single version, so branch previews deployed with wrangler versions upload inherit them and were logging preview traffic as real dubsector.dev visits. Checking location.hostname before loading the tracker keeps previews and local wrangler dev out of the stats.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
terminal | 249b960 | Commit Preview URL Branch Preview URL |
Aug 02 2026, 03:37 AM |
disableCookies traded returning-visitor accuracy for skipping a consent banner; keep the cookies and the accurate visitor counts instead.
Cookies only bought returning-visitor identification, which is close to meaningless on a single-page site with no accounts, and buying it meant adding a consent banner. Cookieless plus anonymized IPs on a self-hosted install keeps the exemption and skips the banner.
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.
Follow-up to #45.
Worker secrets belong to the Worker, not to a single version, so branch previews deployed with
wrangler versions uploadinheritMATOMO_ORIGIN/MATOMO_SITE_IDand would log preview traffic as real dubsector.dev visits. The client now checkslocation.hostnamebefore loading the tracker, so previews and localwrangler devstay silent.Testing
Ran
wrangler devlocally with both vars set in.dev.vars:PRODUCTION_HOST = "dubsector.dev") onlocalhost: no_paq, no tracker script, zero requests to/mtm/*— while/api/analyticsstill returns{"siteId":"1"}, confirming the gate is what stops it and not a missing configPRODUCTION_HOSTtemporarily flipped to"localhost"and rebuilt:/mtm/mtm.js200, pageview hit to/mtm/mtm.phpaccepted 204 by Matomo, then reverted