Repository navigation
Conversation
The unique-visitor key was date|path|country|browser|screen_width, so one person browsing five pages counted as five visitors. Drop path from the key and define it once in src/lib/visitorKey.ts instead of seven inline copies across dashboard, public, API, insights and goals. Goal event converters had the same per-page key; with the smaller visitor denominator that could push event-goal conversion rates past 100%, so the event key drops path too. Public copy on / and /how-it-works no longer lists path, and the landing page no longer calls the tuple a hash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
The unique-visitor key was
date|path|country|browser|screen_width, so one person browsing five pages in a day counted as five visitors. Headline "Unique Visitors" overcounted on any multi-page site, and the dashboard disagreed with the weekly digest (which already left outpath).Fix
src/lib/visitorKey.tsdefines the key once:date|country|browser|screen_width. It replaces seven inline copies across the dashboard, public dashboard, API, insights and goals.date|path|country|referrer). With the smaller visitor denominator, an event fired on several pages could have pushed event-goal conversion rates past 100%, so the event key dropspathtoo./and/how-it-worksno longer lists path, and the landing page no longer calls the tuple a "hash" (nothing is hashed).Impact
Visitor counts will drop for every site, most on sites where people view several pages. Counts are computed when a page loads, so historical periods drop too: trends stay internally consistent, with no step change at deploy. Worth a changelog note or email to customers before this ships.
Not included:
src/scheduled.ts(weekly digest), to avoid conflicting with the unmergedfix/weekly-digest-cronbranch. The digest already leaves outpath; it can switch toPAGEVIEW_VISITOR_KEY_SQLafter both merge.Testing
test/visitor-key.test.tsruns the real SQL against in-memory SQLite: multi-page visitor counts once, differing attributes count separately, the key rotates daily, an event goal on 3 pages converts once (100%, not 300%). Withpathtemporarily put back in the key, 3 of the 5 tests fail.npm test: 163 pass, 0 fail, 4 skipped (WordPress plugin, separate repo)npm run typecheck: cleannpm run test:smoke, which the deploy checklist requires🤖 Generated with Claude Code