devxy/build-cran-binaries
Watch
1
0
Fork
You've already forked build-cran-binaries
0
build-cran-binaries/.crow
Repository files (latest commit first)
Filename Latest commit message Latest commit date
pat-s 72440f9cf5
All checks were successful
ci/crow/manual/download-stats Pipeline was successful
ci/crow/cron/download-stats Pipeline was successful
feat(stats): collect CDN access logs and publish download statistics (#251)
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.yaml` runs hourly: `stats/collect.ts` reads the last 70 hours of cran-rpkgs logs (Bunny keeps three days) into a new `download_stats` schema in the build metadata database, then `stats/publish.ts` writes aggregated counts to `stats/downloads.json` in the binaries bucket and purges the CDN copy.
- `stats/classify.ts` labels each request (download, index, redirect reason, renv/pak probe, scanner noise) by mirroring `edge/rpkgs-router.ts`, and splits cloud/CI networks (by ASN) from everything else.
- Downloads are de-duplicated per client, package version and UTC day; clients are a salted HMAC of the anonymized /24 prefix, ASN and R platform, so no IP is stored or published.
- Our own CI runners (`STATS_OWN_NETWORKS`) are excluded; collection windows are recorded so the dashboard can show gaps.
- `cdn.tf` declares the zone's existing logging settings and adds `json` to the CORS extensions so rpkgs.com can read the file.
- `stats/README.md` documents every rule.

The rpkgs.com `/stats` page that renders this is in rpkgs/website.

## Before merging

- Add Crow secrets `STATS_CLIENT_SALT` and `STATS_OWN_NETWORKS` (values in OpenBao at `development/agent-dev/rpkgs-download-stats`).
- `tofu apply` for the CORS change.
- After merge, register the `download-stats` cron (`0 * * * *`).

## Verification

- `bun test stats`: 15 tests pass.
- Ran `collect.ts` locally against the live API and database: 14,273 events inserted, a second run inserted 0.
- `publish.ts --out` produced 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](https://claude.com/claude-code)

Reviewed-on: #251
2026-11-14 12:10:59 +00:00
..
archive-missed-packages.yaml chore(alpine): drop the deprecated Alpine 3.22 slot (#213) 2026-09-11 07:27:03 +00:00
auto-apply-patches.yaml fix(ci): install RPostgres for audit workflows (#172) 2026-08-30 07:31:28 +00:00
backfill-abi-classification.yaml fix(ci): install the R packages pipelines use instead of relying on the image (#238) 2026-10-20 08:51:06 +00:00
backfill-flat-safety.yaml fix(ci): install the R packages pipelines use instead of relying on the image (#238) 2026-10-20 08:51:06 +00:00
build-all-versions-install-deps.yaml perf: seed pure-R binaries into a new slot, interleave shards, and stop builds before the timeout (#242) 2026-10-24 02:04:06 +00:00
build-all-versions.yaml perf: seed pure-R binaries into a new slot, interleave shards, and stop builds before the timeout (#242) 2026-10-24 02:04:06 +00:00
download-stats.yaml feat(stats): collect CDN access logs and publish download statistics (#251) 2026-11-14 12:10:59 +00:00
process-updates.yaml perf: use ccache and parallel make, and skip already-built newer-R candidates in bulk (#240) 2026-10-23 13:17:59 +00:00
prune-stale-flat-binaries.yaml fix(ci): install the R packages pipelines use instead of relying on the image (#238) 2026-10-20 08:51:06 +00:00
rebuild-abi-gap.yaml fix(ci): install the R packages pipelines use instead of relying on the image (#238) 2026-10-20 08:51:06 +00:00
reindex.yaml fix(ci): install the R packages pipelines use instead of relying on the image (#238) 2026-10-20 08:51:06 +00:00
repair-built-stamp.yaml fix(repair-built-stamp): patch the published PACKAGES.rds once bincraft drops cranlike (#236) 2026-10-18 11:55:21 +00:00
repair-unsafe-flat-objects.yaml fix(ci): install the R packages pipelines use instead of relying on the image (#238) 2026-10-20 08:51:06 +00:00
retire-slot.yaml feat(slots): add a retirement workflow and a drift check (#214) 2026-09-11 13:14:17 +00:00
trial-build-registry.yaml chore(alpine): drop the deprecated Alpine 3.22 slot (#213) 2026-09-11 07:27:03 +00:00
verify-repo-routing.yaml chore(alpine): drop the deprecated Alpine 3.22 slot (#213) 2026-09-11 07:27:03 +00:00
weekly-audit-missing.yaml fix(ci): install the R packages pipelines use instead of relying on the image (#238) 2026-10-20 08:51:06 +00:00
weekly-patch-proposals.yaml fix(ci): install RPostgres for audit workflows (#172) 2026-08-30 07:31:28 +00:00
weekly-rebuild-missing.yaml perf: use ccache and parallel make, and skip already-built newer-R candidates in bulk (#240) 2026-10-23 13:17:59 +00:00
weekly-rebuild-reindex.yaml fix(ci): install the R packages pipelines use instead of relying on the image (#238) 2026-10-20 08:51:06 +00:00