stats: self-host stargazers chart (fix broken starchart.cc embed)#59
Conversation
…estriction) GitHub now restricts the stargazers API to a repo's admins/collaborators (github.blog/changelog/2026-06-30-...), so the third-party starchart.cc embed on /stats/ no longer renders. We already track star counts in ActivityWatch/stats (data/stats.csv, every 6h, complete history from 0 in 2016 to ~18k today), so render the chart ourselves via analyze_stats.py --column stars, matching the other stats images. Removes the external dependency entirely; links to the GitHub stargazers page instead of starchart.cc.
Greptile SummaryThis PR replaces the broken hosted stargazer chart with a locally generated stats image.
Confidence Score: 4/5The local chart path works with the existing stats image flow, but the new stargazer chart omits the earliest history.
Makefile Important Files Changed
Reviews (1): Last reviewed commit: "stats: self-host stargazers chart (starc..." | Re-trigger Greptile |
| mkdir -p img/stats | ||
| mkdir -p stats/out | ||
| cd stats && poetry run python analyze_stats.py --since 2017-07-01 --column downloads --per-week --save ../img/stats/downloads.png | ||
| cd stats && poetry run python analyze_stats.py --since 2017-07-01 --column stars --title 'GitHub Stargazers' --save ../img/stats/stars.png |
There was a problem hiding this comment.
The new local stars chart is generated with --since 2017-07-01, so /stats/ will drop the 2016-to-mid-2017 stargazer history that the replacement is meant to preserve. The page now shows a truncated cumulative curve instead of the full project history from the first stars.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 02f4628779
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| div.img-center | ||
| a(href="https://starchart.cc/ActivityWatch/activitywatch") | ||
| img.width-700(title="Stargazers over time" src="https://starchart.cc/ActivityWatch/activitywatch.svg") | ||
| a(href="https://github.com/ActivityWatch/activitywatch/stargazers") |
There was a problem hiding this comment.
Avoid linking the chart to the restricted stargazers view
The replacement chart no longer depends on starchart, but this new click target is the same GitHub /stargazers UI view affected by the access restriction this change is trying to work around; GitHub's changelog says that repository stargazers views may return empty responses or 403s for non-admin/non-collaborator users. For those public visitors, clicking the chart still lands on a broken/restricted page, so link to the repository or the stats data instead.
Useful? React with 👍 / 👎.
Problem
The Stargazers chart on
/stats/is broken: it embedsstarchart.cc/ActivityWatch/activitywatch.svg, and GitHub now restricts the stargazers API to a repo's admins/collaborators — third-party services like starchart.cc / star-history.com can't read it anymore without a per-user token.Fix
We already collect star counts in ActivityWatch/stats —
data/stats.csv, every 6h, with complete history from 0 stars (2016) to ~18k today (daily granularity 2017–2020, 6-hourly since). So render the chart ourselves viaanalyze_stats.py --column stars, exactly like the downloads/Chrome/Firefox/Android images. No external dependency, no token needed.stars.pngrender step.<img>for/img/stats/stars.png, linking to the GitHub stargazers page.Rendered output is a clean cumulative curve identical in shape to what starchart.cc showed.
On backfilling: not needed — our tracked data already covers the full history from project start. (If we ever wanted to reconstruct/verify, the GitHub stargazers endpoint with
Accept: application/vnd.github.star+jsonreturns each stargazer'sstarred_atand still works for repo admins with a token — but it only counts current stargazers, so it's actually less accurate than our point-in-time tracking.)