feat(get): count installs with analytics engine - #32
Merged
Conversation
3 tasks
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.
Adds aggregate install counting to the
get.univerlab.orgWorker, so a launch produces data instead of guesses.Why
The Worker deliberately counted nothing. That was the right call at zero users, but it stops being right the week we start publishing: a traffic spike would teach us nothing about whether anyone actually installed anything.
What it records
One data point per request: tool, platform (
sh/ps1), coarse client class (curl/powershell/browser), country, referrer host, and outcome (redirect/unknown-tool/no-windows).Not recorded: IP addresses, full user-agents, cookies, anything tied to a person. The client class is a bucket, not the raw header.
unknown-toolis worth calling out — it captures 404s, so we learn which tools people expected to exist.Why Analytics Engine
Writes are fire-and-forget, so no latency is added to the redirect, and there is no database to provision. KV would need read-modify-write and rate-limits at 1 write/sec/key — it would break exactly during a launch spike. D1 would put a SQL write in the hot path of every install.
Included in the Workers free plan (100k data points/day), and the dataset is created automatically on first write.
Safety
The binding is optional in code and the write sits in a
try/catch. If Analytics Engine is unavailable, the install still works. Verified locally withwrangler dev: all five paths unchanged (302install.sh, 302install.ps1, 404 no-Windows, 404 unknown tool, 302 root).The supply-chain argument is unchanged: the Worker still proxies nothing, and scripts still come from GitHub.
Known gap
curl | shsends noReferer, so referrer is only populated for browser visits. Launch attribution is by time correlation, not referrer.Reading the data is also unsolved: Analytics Engine has no dashboard and
wranglerhas no command for it, so the SQL API is the only way in and it needs a long-lived token. Query tooling is deliberately kept out of this repo (workers/get/scripts/, gitignored) rather than shipping a pattern that encourages plaintext credentials on a laptop. Options are written up in the README.In the meantime the Workers dashboard shows total requests, which is enough to spot a launch spike without any token.
Docs
The README previously promised "no counting" as a trust guarantee. It now states exactly what is recorded and what is not.