Repository navigation
Conversation
Article view counts and public usage stats need exact, all-time numbers that no analytics vendor gives on this plan, so views are recorded in our own database. Nothing reads them yet. - `chia_page_view` stores one row per counted view: path without the locale prefix, the post or note it resolves to, locale, a visitor hash, external referrer host and Cloudflare's country. - `stats.view` is public. The visitor is a SHA-256 of address and user agent with a salt kept one UTC day in KV, so it never links days and no cookie is set. Repeats of a page within 30 minutes, crawlers (`isbot`), API-key callers and the operator are dropped. A post or note path resolves to its feed inside the insert. - www's `PageViewTracker` reports each page from the browser, and skips readers sending Do Not Track or Global Privacy Control. Migration 20260927164701_page_view must run before the service deploys. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Warning Review limit reachedNext included review available in 12 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (19)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Chia1104
marked this pull request as draft
September 27, 2026 18:59
This branch was successfully deployed
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.
Why
The site should later show article view counts and public usage stats. Analytics vendors cannot supply exact all-time numbers on this plan: Vercel Hobby's query API covers 31 days, and Cloudflare Web Analytics covers about 6 months, sampled. So views are recorded first-party. This PR only collects; nothing reads or displays the data until enough has accumulated.
What changes
Storage
chia_page_view(migration20260927164701_page_view) holds one row per counted view:path, without the locale prefix;feed_id, set when the path is a post or note page, andSET NULLwhen the feed is deleted;locale;visitor, a daily-salted hash;referrer_host, external referrers only;country, fromcf-ipcountry.created_at,(feed_id, created_at)and(path, created_at).@chia/db/repos/statsinsertPageViewresolves/posts/<slug>or/notes/<slug>to the feed id inside the same insert, via a subselect.Service (
packages/services/stats)stats.viewis public, behindcallerGuard()and a newstatsbudget: 60/min for anonymous and guest callers, 120/min for sessions.isbot, a new catalog dependency) and requests without a user agent;Root).www
PageViewTrackerin the[locale]layout sends{ path, locale, referrer }on every page.pathcomes from next-intl'susePathname, so it has no prefix, andreferreris sent only on the landing page. Readers with Do Not Track or Global Privacy Control are skipped. Failures are ignored.packages/services/AGENTS.mdandapps/AGENTS.mdrecord the privacy rules.Deploy order
20260927164701_page_view.service.www.A www build that reaches an older service gets an unknown-procedure error, which the tracker ignores.
Test plan
type:checkfor@chia/db,@chia/services, service, www and dash; oxlint on changed code@chia/services(143, 10 new instats/__tests__/view.service.test.ts), service (120), www (70). The new tests cover:insertPageViewdirectly:NULL;feed_idtoNULLand keeps the row./contact,enand the external referrer;/projectswithout a referrer;🤖 Generated with Claude Code