Skip to content

Align website package stats with authoritative providers and clarify metric semantics - #31

Merged
sahiljagtap08 merged 2 commits into
mainfrom
copilot/fix-install-download-statistics
Sep 22, 2026
Merged

sahiljagtap08 merged 2 commits into
mainfrom
copilot/fix-install-download-statistics

Conversation

Copilot AI commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Website hero stats were drifting from registry totals due to provider mismatch (PyPI) and expensive/risky aggregation logic (npm). This updates stat sourcing, caching, and UI wording so displayed values stay current and accurately represent what is being measured.

  • PyPI: source of truth aligned to Pepy

    • GET /api/pypi-stats now reads api.pepy.tech total downloads (the same provider linked from the UI), with validated fallback to pypistats if Pepy is unavailable.
    • Added structured null-on-failure behavior and cache headers (s-maxage + stale-while-revalidate) to avoid per-request provider fan-out.
  • npm: true all-time downloads without range paging

    • GET /api/npm-stats replaced sequential range summing with a single all-time downloads/point/{start}:{today} request.
    • Start date is derived from npm package metadata (time.created) with safe fallback.
    • Confirms and keeps the intended package: @agentbudget/agentbudget (unscoped agentbudget does not match published package metadata).
  • Go: preserve honesty of proxy metric

    • GET /api/go-stats remains GitHub traffic-based and explicitly returns proxy metadata (is_proxy, window_days).
    • Missing/invalid GITHUB_TOKEN gracefully returns null metric (no misleading install count), with non-sensitive server logging and cache policy.
  • Hero badges: clearer semantics + resilient client fetch

    • Replaced one-shot metric fetches with a shared client hook that validates payloads, handles transient failures, and refreshes periodically.
    • Updated badge copy:
      • PyPI/npm: downloads
      • Go: 14d clone proxy
      • Aggregate badge: total downloads (PyPI + npm), avoiding mixing all-time downloads with 14-day proxy traffic.
// npm all-time downloads in one request
const pointRes = await fetch(
  `https://api.npmjs.org/downloads/point/${ymd(start)}:${ymd(new Date())}/${PKG_ENC}`,
  { next: { revalidate: 3600 }, headers: { "User-Agent": "agentbudget-website/1.0" } }
);

@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agentbudget Ready Ready Preview Sep 22, 2026 6:15pm UTC
agentbudget-landing Ready Ready Preview Sep 22, 2026 6:15pm UTC

Co-authored-by: sahiljagtap08 <95201277+sahiljagtap08@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix website's install/download statistics for accuracy Align website package stats with authoritative providers and clarify metric semantics Sep 22, 2026
Copilot AI requested a review from sahiljagtap08 September 22, 2026 18:16
@sahiljagtap08
sahiljagtap08 marked this pull request as ready for review September 22, 2026 18:17
@sahiljagtap08
sahiljagtap08 merged commit 3a47c90 into main Sep 22, 2026
11 checks passed

This branch was successfully deployed

2 active (1 outdated) deployments
Preview – agentbudget-landing — 274e5ce9 Deployed Sep 22, 2026 by vercel[bot]
Preview – agentbudget — b5e75248 Deployed Sep 22, 2026 by vercel[bot]
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.

2 participants