feat(stats): collect CDN access logs and publish download statistics #251
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/download-stats"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds visibility into how cran.rpkgs.com is actually used, from the Bunny access logs, without sending anything to a third party.
What it does
.crow/download-stats.yamlruns hourly:stats/collect.tsreads the last 70 hours of cran-rpkgs logs (Bunny keeps three days) into a newdownload_statsschema in the build metadata database, thenstats/publish.tswrites aggregated counts tostats/downloads.jsonin the binaries bucket and purges the CDN copy.stats/classify.tslabels each request (download, index, redirect reason, renv/pak probe, scanner noise) by mirroringedge/rpkgs-router.ts, and splits cloud/CI networks (by ASN) from everything else.STATS_OWN_NETWORKS) are excluded; collection windows are recorded so the dashboard can show gaps.cdn.tfdeclares the zone's existing logging settings and addsjsonto the CORS extensions so rpkgs.com can read the file.stats/README.mddocuments every rule.The rpkgs.com
/statspage that renders this is in rpkgs/website.Before merging
STATS_CLIENT_SALTandSTATS_OWN_NETWORKS(values in OpenBao atdevelopment/agent-dev/rpkgs-download-stats).tofu applyfor the CORS change.download-statscron (0 * * * *).Verification
bun test stats: 15 tests pass.collect.tslocally against the live API and database: 14,273 events inserted, a second run inserted 0.publish.ts --outproduced the JSON the website was previewed with; the upload and purge path has only run in CI so far (B2 credentials are CI-only).🤖 Generated with Claude Code
2614d40bd9toa4c32725fd