Skip to content

About

Multi-source analytics tracker for open-source projects. Preserves GitHub traffic beyond 14 days and aggregates npm, PyPI, and Docker download stats with a Next.js dashboard.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

GitHub Analytics Tracker

Status: experimental CI License: Apache-2.0

OpenA2A: CLI · HackMyAgent · Secretless · AIM · Browser Guard · DVAA

Website · Discord

A self-hosted analytics tracker that keeps a copy of GitHub repository traffic, which the GitHub traffic API returns for the last 14 days only, and collects download statistics from npm, PyPI and Docker Hub into one dashboard.

Why this exists

GitHub's repo Insights → Traffic page is great — for two weeks. After that, the data is gone. If you don't check daily, you never see it again. There's no historical chart, no alert, no export.

This tracker runs once a day (via GitHub Actions), pulls the API, stores everything in a local SQLite database, and gives you a Next.js dashboard with the historical chart you wish GitHub provided. It also pulls download stats from npm, PyPI, and Docker Hub so you have one place to see ecosystem adoption across all your release channels.

What it tracks

Source What Retention
GitHub traffic Daily views + clones, with deduplicated 14-day uniques Unlimited (this tracker)
GitHub referrers Top traffic sources, snapshot per day 90+ days (configurable)
GitHub popular paths Most-visited files, snapshot per day 90+ days (configurable)
GitHub stars + forks Daily totals across all tracked repos Unlimited
GitHub contributors Top contributors per repo, snapshot per day Unlimited
GitHub release downloads Per-tag download counts Unlimited
npm Daily + last-30-day downloads per package Unlimited
npm by version Per-version download splits Unlimited
PyPI Daily downloads, by Python version, by OS Unlimited
PyPI by country Country-level downloads via BigQuery (optional) Unlimited
Docker Hub Pull counts + tag history per image Unlimited
HuggingFace Model downloads (all-time + rolling 30d) and likes per model Unlimited
First-party CLI Active users (distinct installs → WAU/MAU), version + country splits, from the Registry's coarse public adoption feed Daily snapshots

First-party CLI telemetry is active users, not downloads — a download is not a user — so it is shown distinctly and never summed into the download adoption total (same as Chrome weekly-active users).

How it works

GitHub API ──┐
npm API ─────┤
PyPI API ────┤
Docker Hub ──┼──► collect-*.js ──► SQLite (data/analytics.db) ──► Next.js dashboard
HuggingFace ─┤                                                ╲
BigQuery ────┤                                                 ╲──► static JSON (data/*.json)
Registry ────┘                                                      consumable by external sites
(CLI telemetry)                                                     via raw.githubusercontent.com

A daily GitHub Actions cron (6:00 AM UTC) runs the collectors, regenerates the SQLite DB, and commits the data plus per-source static JSON artifacts back to the repo. Your dashboard reads from the DB; external sites can read the JSON directly without spinning up the dashboard.

Quick start

git clone https://github.com/opena2a-org/github-analytics-tracker.git
cd github-analytics-tracker
npm install
cp .env.example .env       # add your GITHUB_TOKEN
npm run setup-db
npm run collect            # fetch from GitHub
npm run collect-npm        # fetch npm download stats
npm run dev                # dashboard at http://localhost:3000

That's it. The dashboard renders whatever's been collected so far. After running for a few days, the historical charts start filling in.

Configure data sources

In .env:

GITHUB_TOKEN=ghp_...                                          # required for GitHub
GITHUB_ORG=opena2a-org,opena2a-standards,ecolibria           # auto-discovers all public repos
REPOS_TO_TRACK=owner/repo,owner/repo                          # optional extra repos
NPM_AUTHOR=ecolibria                                          # auto-discovers all packages by this user
NPM_PACKAGES=hackmyagent,opena2a-cli                          # optional extra packages
PYPI_PACKAGES=cryptoserve,aim-sdk                             # comma-separated
DOCKER_IMAGES=opena2a/aim-server,opena2a/dvaa                 # comma-separated
HF_AUTHOR=opena2a                                             # auto-discovers all HuggingFace models by this org/user
HF_MODELS=org/model,org/other                                 # optional extra models
HF_TOKEN=hf_...                                               # optional, raises HF rate limits / private repos
GOOGLE_APPLICATION_CREDENTIALS=/path/to/gcp-key.json          # optional for BigQuery country stats
REGISTRY_URL=https://api.oa2a.org                             # optional; enables first-party CLI telemetry
REGISTRY_TELEMETRY_TOKEN=...                                  # optional; SA token for the gated detail view (server-side only)
ANALYTICS_TRACKER_PASSWORD=...                                # optional; gates the fine-grained telemetry view on THIS dashboard
TELEMETRY_STALE_AFTER_DAYS=2                                  # optional; consecutive failure days tolerated before the collector exits 1

The collector persists only the coarse, anonymous adoption feed. The fine-grained view (command usage, reliability, by-day) is fetched live from the Registry's authenticated endpoint behind ANALYTICS_TRACKER_PASSWORD and is never written to the committed database.

BigQuery country stats and their byte caps

npm run collect:pypi-countries queries the public bigquery-public-data.pypi.file_downloads table, one closed day per query and at most three days per run. It is not part of the scheduled workflow. Two caps bound what it can bill: 128 GiB per query (checked against a dry run first, then sent to BigQuery as maximumBytesBilled, so BigQuery refuses a job that would bill more; such a refusal bills nothing and ends the run with status refused_cap) and 768 GiB per calendar month (a ledger in data/pypi-country-budget.json). The month-to-date figure is never lower than the bytes the database's fetch records show billed that month, so a checkout without the ledger file still counts the days landed earlier that month. Without the ledger file it does not count a billed query that failed, since only the ledger records that charge.

To see what the next run would scan before paying for it:

npm run collect:pypi-countries -- --dry-run

This issues only BigQuery dry runs, which are not billed, prints each day's scan size against both caps, and writes nothing. It exits 0 only when the next run would clear both caps. When every day in the window is already fetched, the next run bills nothing; the dry run then measures yesterday as a sample and reports whether a new day of that size would clear both caps. npm run collect:pypi-countries --dry-run (without the --) is also a dry run, as is npm_config_dry_run set in the environment to any value but false, 0 or empty, with the name and the value in any letter case. npm run collect:pypi-countries -- --help (or -h) prints the usage and exits 0, even when other arguments are given with it. Without the --, --help goes to npm, which prints its own usage and runs nothing. Any other argument after the -- is refused with a usage message and exit code 2. A flag given without the -- goes to npm. npm 8 through 11 pass an unknown one on as an npm_config_ variable rather than as an argument; one that looks like a mistyped --dry-run, such as npm run collect:pypi-countries --dryrun, is refused the same way before anything runs, and any other is left to npm, so the run collects as normal. npm 12 refuses an unknown flag itself and exits 1 before the script starts.

Automated daily collection

The included workflow (.github/workflows/collect-stats.yml) runs daily at 6:00 AM UTC. To enable it:

  1. Settings → Secrets and variables → Actions → New secret.
  2. Add GH_STATS_TOKEN (a Personal Access Token with repo or public_repo scope).
  3. Optionally set the REGISTRY_URL Actions variable to enable first-party CLI telemetry collection. Unset, the collector warns and skips.

The workflow does not collect BigQuery country stats, so it needs no Google Cloud credentials; run npm run collect:pypi-countries where your credentials are (see above).

When telemetry collection stops

A collector that fails quietly is worse than one that fails outright. Two different failures are checked, because they look nothing alike.

The feed can't be retrieved. A blip is tolerated; an outage is not:

Situation Result
REGISTRY_URL unset, nothing ever collected warning, exit 0 — legitimately not provisioned
REGISTRY_URL unset, but telemetry was collected before error, exit 1 — the variable was removed
REGISTRY_URL set, nothing ever collected error, exit 1 — broken feed or wrong URL
Failing for ≤ TELEMETRY_STALE_AFTER_DAYS (default 2) warning, exit 0 — transient
Failing for longer error, exit 1 — the dashboard is serving stale numbers

The feed responds fine but the numbers drained. This is the shape a broken ingest path actually takes: the adoption feed keeps answering 200 with a structurally valid payload while the active-user counts empty out. A retrieval check sees a healthy response and happily persists the zeros. So the collector also errors when the feed reports mau=0 while the last snapshot with any activity had users — real users do not all vanish overnight.

Two details that matter, both learned the hard way:

  • It keys on MAU alone, not on "MAU and installs are both zero". total_installs is a 90-day window and mau is 30-day, so a broken ingest empties MAU at T+30 while installs coasts to T+90. Requiring both would wave through ~60 days of a dead pipeline. Installs still reporting while actives are zero is corroboration, not a reason to stay quiet.
  • It compares against the last snapshot that had users, not yesterday. Comparing to yesterday makes the alert self-silencing: day one fires, its zeros become the baseline, and every later day sees zero-following-zero and reports healthy. Keying on the last live snapshot keeps the alarm ringing and states the growing gap.

The zeros are still recorded as reported (we don't suppress what the feed said); the point is to raise the alarm. A real decline is not an outage — only reaching zero is. A fleet that has never reported an active user is not an outage either.

Failures emit GitHub Actions annotations so they surface in the run summary, and a final step re-raises the failure after the day's data is committed — so the run goes red and the scheduled-run notification fires, without a telemetry outage costing the other collectors their data. A failed run never writes: zeros must not overwrite a good snapshot.

Untrusted feed text (HTTP error bodies) is sanitized before it reaches any log line — the Actions runner parses ::command:: lines on both stdout and stderr, so an unsanitized response body could otherwise forge or suppress these very annotations.

The workflow auto-discovers public repos in the orgs listed in GITHUB_ORG. Add a new repo to the org, the next run picks it up. No manual list maintenance.

Architectural notes (so you can audit it)

  • DB is SQLite. No external database. The full DB ships with the repo as data/analytics.db (~7 MB for 30+ repos at one year of history).
  • API endpoints are unauthenticated because the data is already public — with one exception: /api/telemetry-detail (fine-grained CLI usage) is gated by ANALYTICS_TRACKER_PASSWORD and only served when that is set.
  • No visitor tracking, no analytics scripts, no third-party scripts in the dashboard itself. (The "First-party CLI" source is aggregate active-user data reported by the org's own CLIs — not tracking of this dashboard's viewers.)
  • No PII. GitHub's referrer + popular-paths APIs return only aggregate counts — no IPs, no user agents, no session data.
  • Static JSON is the canonical export. data/summary.json carries cross-source totals; data/*-stats-*.json carry per-source per-package details. Consume directly via raw.githubusercontent.com if you don't want to run the dashboard.
  • Every headline series is defined once. lib/series.js is the registry (downloads, downloadsExCrypto, adoption, adoptionExCrypto: key, label, method, scope, definition). summary.json repeats the flat total.* fields for existing consumers and adds series.<key> (definition, per-source window read from the database, components, status of ok or partial) and collectors.<name> (ran / ok / error per collector for the run that wrote the file, plus GitHub discovery vs traffic coverage). A failed collector marks every series that sums it partial; the workflow's final verify-run step turns the run red after the data is committed, and also fails when the published summary is older than 48 hours. adoption is a mixed-window sum (package, image and model download events plus GitHub's rolling 14-day distinct cloners) and is never described as deduplicated.
  • An absent Hugging Face count is never a measured zero. When the Hugging Face API omits a count, or returns something other than a non-negative integer, the collector stores NULL with the reason in absent_reason and leaves the model's badge unchanged. Each model then keeps its last measured all-time count under that count's own date, series.<key>.window.huggingface.gaps names every model whose newest snapshot has no measured count, and the series is partial. If nothing has been measured, total.hf and the huggingface component are null and left out of the sums. npm run setup-db, and npm run collect-hf before it writes, rebuild an older huggingface_stats table with nullable counts and keep every row. The model list and detail from /api/huggingface-stats and the overview's Hugging Face all-time, 30-day and likes totals use each model's last measured counts too, and are null when nothing has been measured. A 0 in a row written before the nullable schema may be an absent count stored as 0. /api/trends measures hfDownloads the same way: each period gets the growth of every model's measured all-time count above the highest count measured for that model before it, so a daily period is not 0 for holding one snapshot and a count that dips and recovers is not counted twice. A count that falls and stays below its earlier high adds nothing until it passes that high again, so its rise back up to the high is never counted (100, then 80, then 110 adds 10, not 30). A period with no growth measurement is null (a gap in the dashboard's install trend, shown as not measured in its tooltip) and adds nothing to totalDownloads, while a period whose measured growth is 0 is 0. The overview's channel mix draws only counts above 0, so when models are tracked and none has a measured all-time count it leaves Hugging Face out and says so in its subtitle; with no model tracked, or a measured 0, it leaves Hugging Face out without a note.
  • Growth is measured on anchored windows. summary.json and the overview API carry a momentum block (lib/momentum.js): week-over-week, month-over-month and quarter-over-quarter growth (7, 30 and 90-day windows against the equal window before), the change in the weekly rate (acceleration) and a compound annual growth rate, per source (npm, PyPI, clones, Docker, Hugging Face, stars) and for gross downloads combined. Windows end at each series' latest collected day with data, never at today, so a collection lag cannot produce a false drop. Every figure sits next to the two window totals and dates it came from; a figure that cannot be measured (series too young, previous window zero, span under a year for CAGR) is null with a reason, never an estimate. For the snapshot sources (stars, Docker, Hugging Face), a repository, image or model first collected inside a window adds only what it gained after its first snapshot; the count it already had that day is reported beside the window totals as carriedIn and is not growth, the same rule the community star trend uses. A transferred repository's series starts at the first snapshot under its current name, so stars gained under the earlier name before the transfer are not in these figures.
  • Reach is rolled up across the ecosystem. summary.json and the overview API carry a reach block (lib/reach.js). githubReferrers sums GitHub's top-10 referrers per repository over the newest 14-day referrer window, one snapshot per canonical repo, and groups them into channels (github, search, ai-assistant, social, package-registry, own-site, other) with the raw referrer rows alongside so the grouping can be checked; uniques is a sum of per-repo distinct visitors. pypiPlatforms sums the pypistats.org Python-version and operating-system breakdowns across PyPI packages on the newest snapshot. Shares cover downloads pypistats attributed; the OS block reports the unattributed count, and the Python-version block reports it as null because the collector does not store it. The pypistats response window is not stored, so use the shares rather than comparing these totals with the daily download series.
  • Community and shipping cadence come from the same tables. summary.json and the overview API carry a community block (lib/community.js), counted per calendar month or quarter (UTC). contributors gives, per month, the distinct commit authors seen so far (cumulative), the ones first seen that month and the ones whose commit count on a repository rose (active); [bot] accounts are left out, maintainers are included, and the first month (baseline) also holds everyone who contributed before tracking began. stars and forks give the month-end total per canonical repo, with the count a repository already had when it was first collected reported as carriedIn, never as growth. releases counts each release once per canonical repo and tag in the quarter it was published, plus the trailing 90 days. The collector reads the newest 30 releases per repository, so any range a full read may have cut off is listed in coverage.truncated and a quarter touching it is complete: false; perQuarter is the newest complete quarter. breadth counts tracked repositories, packages, images, models and extensions per ecosystem.

How the GitHub metrics actually work

GitHub's traffic API has subtleties worth knowing:

  1. Daily uniques cannot be summed. A visitor on three different days appears as uniques=1 on each of those days; summing gives 3, not 1. We store daily counts AND the 14-day rolling summary (which GitHub deduplicates correctly) so consumers can pick the right one.
  2. Today's data is partial. The current day is still being written. We skip it on collection and only persist completed days.
  3. Referrers and popular paths are 14-day rolling snapshots, not daily breakdowns. We store one snapshot per day; on re-runs for the same day, we replace.
  4. All-time uniques are unreported because they would be wrong for the reason above. We surface the 14-day API figure instead.

Database schema

Table Purpose
repositories Tracked repos
traffic_views, traffic_clones Daily counts (completed days)
traffic_summary 14-day deduplicated uniques
referrers, popular_paths Daily snapshots of 14-day rolling data
stargazers, forks Daily totals
github_contributors, github_releases Per-repo extras
npm_packages, npm_downloads, npm_version_downloads npm
pypi_packages, pypi_downloads, pypi_python_versions, pypi_system_stats, pypi_country_downloads PyPI
docker_images, docker_pulls, docker_tags Docker Hub
huggingface_models, huggingface_stats HuggingFace model downloads + likes (daily snapshots)
telemetry_snapshots, telemetry_tool_snapshots, telemetry_version_snapshots, telemetry_country_snapshots First-party CLI active users (coarse daily snapshots)

Run sqlite3 data/analytics.db .schema for the full DDL.

API endpoints

All read-only, no auth. JSON responses.

GET /api/repos                       # list of tracked repos
GET /api/stats?repo_id=1&days=30     # per-repo stats (days: 7|14|30|90|365|all)
GET /api/overview                    # cross-source totals
GET /api/trends?repo_id=1            # daily trend data for charts
GET /api/npm-stats                   # npm package stats
GET /api/pypi-stats                  # PyPI package stats
GET /api/docker-stats                # Docker image stats
GET /api/huggingface-stats           # HuggingFace model stats
GET /api/huggingface-stats?model_id=1&days=30  # one model (days: a positive integer or all; other values are a 400)
GET /api/telemetry                   # first-party CLI active users (coarse, public)
GET /api/telemetry-detail            # fine-grained CLI usage (gated by ANALYTICS_TRACKER_PASSWORD)

Comparison

This ungh.cc Manual
GitHub history beyond 14 days ✓ ✗ ✗
npm + PyPI + Docker ✓ ✗ partial
Self-hosted (no third party sees your token) ✓ ✗ ✓
Dashboard included ✓ ✗ ✗
BigQuery country stats ✓ optional ✗ ✗

FAQ

How far back can I see data? As far back as when you started collecting. The first run captures the available 14 days; subsequent runs append.

What if I miss a day? GitHub keeps 14 days, so you have a 2-week buffer. Run the collector again to backfill.

How much storage? ~10-20 MB per year per 20 repos.

Can I track private repos? Yes, if your GITHUB_TOKEN has access. Auto-discovery via GITHUB_ORG only picks up public repos; add private ones to REPOS_TO_TRACK explicitly.

Why not all-time unique visitors? Daily uniques can't be summed (a visitor on 5 days = 5 in the sum, not 1). The 14-day API figure is the most accurate unique count GitHub will give you.

Contributing

See CONTRIBUTING.md. For security issues, see SECURITY.md.

License

MIT — built by OpenA2A.

About

Multi-source analytics tracker for open-source projects. Preserves GitHub traffic beyond 14 days and aggregates npm, PyPI, and Docker download stats with a Next.js dashboard.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages