Repository navigation
Conversation
GitHub keeps clone and view traffic for 14 days only. Save it daily to CSV files on the orphan stats branch so the history is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Vxxv9fVFGupLXEnmx5bSq
Comment on lines
+6
to
+8
| # The traffic API needs a token with push access to the repo, which the default | ||
| # GITHUB_TOKEN does not have for this endpoint. TRAFFIC_STATS_TOKEN must be a | ||
| # fine-grained token scoped to this repo with "Administration: read". |
Member
There was a problem hiding this comment.
"Push access" and "Administration: read" disagree. Only the read-only scope is needed, so drop the push-access wording so nobody creates an over-scoped token.
Suggested change
| # The traffic API needs a token with push access to the repo, which the default | |
| # GITHUB_TOKEN does not have for this endpoint. TRAFFIC_STATS_TOKEN must be a | |
| # fine-grained token scoped to this repo with "Administration: read". | |
| # The traffic API is not readable with the default GITHUB_TOKEN. | |
| # TRAFFIC_STATS_TOKEN must be a fine-grained token scoped to this repo with | |
| # "Administration: read". |
Comment on lines
+36
to
+41
| if git fetch --depth=1 origin stats; then | ||
| git checkout -B stats FETCH_HEAD | ||
| else | ||
| git checkout --orphan stats | ||
| git rm -rfq . | ||
| fi |
Member
There was a problem hiding this comment.
Any git fetch failure, including a network error, sends the job into the orphan path, and the run then fails later at push with a non-fast-forward error. Check whether the branch exists explicitly so a real fetch error fails right here.
Suggested change
| if git fetch --depth=1 origin stats; then | |
| git checkout -B stats FETCH_HEAD | |
| else | |
| git checkout --orphan stats | |
| git rm -rfq . | |
| fi | |
| if git ls-remote --exit-code --heads origin stats >/dev/null; then | |
| git fetch --depth=1 origin stats | |
| git checkout -B stats FETCH_HEAD | |
| else | |
| git checkout --orphan stats | |
| git rm -rfq . | |
| fi |
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.
Description
GitHub keeps clone, view, and referrer traffic for 14 days only. This adds a daily
traffic_statsworkflow that saves it to CSV files on the orphanstatsbranch, so we keep a history of how the plugin is being picked up.traffic.csv: one row per day with clones, unique cloners, views, and unique viewers. Each run rewrites the days still in GitHub's window, so today's partial count is corrected the next day, and older rows are kept.referrers.csv: a dated snapshot of the top referrers, which GitHub only reports as a 14-day total. A second run on the same day replaces that day's snapshot.The
statsbranch is already seeded with Oct 21 to Nov 3 and Nov 12 to Nov 25. Nov 4 to Nov 11 is lost. Pushes tostatsdon't trigger CI, which runs on pull requests only.Setup before merging: the traffic API isn't readable with the default
GITHUB_TOKEN, so the workflow needs aTRAFFIC_STATS_TOKENrepo secret: a fine-grained token scoped to this repo with Administration: Read-only. Until it is set, the job fails at the fetch step.The merge step was tested locally against the live API, run twice to check that a second run adds no duplicates. The workflow itself has not run on GitHub yet.
Type of Change
feat)fix)refactor)docs)ci)chore)🤖 Generated with Claude Code
https://claude.ai/code/session_017Vxxv9fVFGupLXEnmx5bSq