Repository navigation
feat: cookieless web analytics (script, ingest, sessions, GeoIP) - #9
Merged
Merged
Conversation
Web keys accept Track/TrackStream only from allowed origins. The server derives anon_id from a daily shared salt, assigns sessions after 30 min idle, never stores the IP, and rate limits per key and client IP.
CreateKey validates kind/allowed_origins and stores them; CreateKey and ListKeys return them. Client IP is now the X-Forwarded-For entry appended by the outermost trusted proxy, not the client-controlled leftmost one.
Cache today's and yesterday's salt; when today's visitor id has no live session, adopt one found under yesterday's id. Stored anon_id stays today's.
Mount GET /js/script.js on the ingest port and start the DB-IP City Lite downloader when GEOIP_SOURCE=dbip-lite.
…ns, drop bot sessions
Web keys reject reserved $-events except $pageview, store minimised URLs/referrers, keep sessions per team, and rate limit IPv6 by /64. RotateKey now rotates server keys only. Document TRUSTED_PROXY_HOPS.
RotateKey revoked server keys one by one before saving the new key, so a database error part-way could leave a team without an active key. Revoke and insert now run in one statement. README shows the new GeoIP cache default.
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.
Plausible-style web analytics on top of Lumen events.
/js/script.js: tiny tracker; pageviews, SPA navigation, outbound/file clicks and custom events.kind='web',allowed_origins): Origin must match, Track only,$pageviewor non-$events.w1_+ sha256(daily salt, team, host, IP, UA); salts rotate daily (today + yesterday kept inlumen_web_salts); the IP is never stored.utm_*and hash routes.TRUSTED_PROXY_HOPS(default 1).web_pageviews,web_sessions,referrer_sources, fixedsessions_v; persons views skipw1_ids.GEOIP_SOURCE=dbip-litedownloads DB-IP City Lite intoGEOIP_CACHE_DIR.RotateKeynow rotates only the server key, atomically, and leaves website keys alone.Tests:
go test -race ./...and the Postgres live tests pass.