Skip to content

HGP-66: Add repository traffic insight sensors - #65

Merged
JtheGunner merged 4 commits into
mainfrom
feat/HGP-66-repository-traffic-insight-sensors
Nov 22, 2026
Merged

JtheGunner merged 4 commits into
mainfrom
feat/HGP-66-repository-traffic-insight-sensors

Conversation

@JtheGunner

Copy link
Copy Markdown
Owner

HGP-66

Adds nine per-repository traffic sensors (GitHub traffic API, last 14 days). All of them are disabled by default, and the data is only fetched while at least one of them is enabled.

Sensors

  • Unique visitors, page views, unique cloners and clones over 14 days
  • Peak visitor day (visitors and views as attributes)
  • Top referrer and top page (top 5 as attributes)
  • Visitor trend (last 7 complete days vs. the earlier days of the window)
  • Cloners per visitor

Changes

  • analytics/traffic.py: pure parsing and summary logic
  • traffic_fetch.py: four REST calls per repository; 403 and 404 map to None, other errors propagate
  • repository_coordinator.py: new demand-based traffic data group
  • sensor_repository.py, sensor.py: sensor descriptions; traffic sensors are unavailable for a repository whose traffic cannot be read
  • translations/en.json, de.json, README.md

Traffic needs write access to the repository; GitHub documents no fine-grained permission for it, so the README recommends a classic token with repo. There are no all-time totals because GitHub only reports 14 days.

Test plan

  • pytest, ruff check ., ruff format --check . and mypy custom_components pass locally
  • New tests cover parsing and edge cases, 403/404 handling, default-disabled sensors, and the group not being fetched while every traffic sensor is off
  • Reviewer: enable the traffic sensors of a repository you can push to and compare the values with the Insights, Traffic page on GitHub

@JtheGunner
JtheGunner merged commit f4411c6 into main Nov 22, 2026
4 checks passed
@JtheGunner
JtheGunner deleted the feat/HGP-66-repository-traffic-insight-sensors branch November 22, 2026 21:41
@JtheGunner JtheGunner mentioned this pull request Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant