Skip to content

feat(analytics): add admin analytics for hosted sites - #262

Merged
vigneshrajsb merged 3 commits into
mainfrom
sites-admin-analytics
Oct 13, 2026
Merged

vigneshrajsb merged 3 commits into
mainfrom
sites-admin-analytics

Conversation

@vigneshrajsb

Copy link
Copy Markdown
Contributor

Description

  • Adds GET /api/v2/admin/analytics/sites (administrator only) for a new Sites view in Analytics.
  • Reports publishing activity (new sites, content updates, publishers) over the shared calendar window with previous-period comparison, plus owner types and visibility per bucket.
  • Reports current state at request time: live sites, storage used (live plus restorable), current site states, and the top publishers and largest live sites.
  • Reports endings, TTL extensions, and site lifetimes in the window, using the existing site audit trail for restores and extensions.
  • Filters: ownerKind, visibility, and owner (an opaque publisher key returned in publisherOptions).
  • No migrations or new tracking. Five read-only queries run in one repeatable-read transaction with the shared timeout. JIT compilation is turned off for that transaction.

Test plan

  • Service, route, and OpenAPI contract tests, including 401/403/400 paths, no-store, NUL rejection, and bound filter values. Full Jest suite and lint pass.
  • Checked results against a hand-computed fixture on a local PostgreSQL with the full migrated schema.
  • EXPLAIN ANALYZE on a synthetic dataset with 50k sites, 200k versions, and 500k audit events: about 0.9 s for all queries combined, with a 180-day scan.
  • In a preview environment, open Analytics > Sites as an administrator and compare a few numbers with the Sites list.

Serve GET /api/v2/admin/analytics/sites for administrators: publishing
activity, publishers, current site states, endings, TTL extensions,
lifetimes, visibility, and the largest live sites. The endpoint reads
existing site, version, and audit records and adds no migrations.
Reject NUL characters in Sites filters, end expired sites at their
expiry time rather than the cleanup time, and keep negative lifetimes
in the first bin.
@vigneshrajsb
vigneshrajsb marked this pull request as ready for review October 13, 2026 00:17
@vigneshrajsb
vigneshrajsb requested a review from a team as a code owner October 13, 2026 00:17
@vigneshrajsb
vigneshrajsb merged commit 64fd9ad into main Oct 13, 2026
5 checks passed
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