Skip to content

Add admin analytics for environment records and Agent sessions - #253

Merged
vmelikyan merged 9 commits into
mainfrom
admin-analytics-api
Oct 7, 2026
Merged

vmelikyan merged 9 commits into
mainfrom
admin-analytics-api

Conversation

@vmelikyan

@vmelikyan vmelikyan commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Administrators can review environment records, repository and PR activity, current health, components, and Agent session usage from retained Lifecycle data.

Environment activity supports repository stacks over time and previous-period comparisons. Up to five repositories remain separate. Other repositories and Unattributed preserve each date total. Creation counts include records that never deployed. PR record coverage measures linked records, not deployment adoption.

Unique components count each configured component once within its owning repository. Ready components count recorded READY components separately in each current environment. Current inventory and component totals ignore the date window.

API record duration uses creation and recorded deletion. PR record duration estimates use creation and last update for torn-down records. Both can include records that never deployed. PR estimates can include waiting time, later edits, and reuse gaps. Current record age has separate statistics. Records and scatter points return complete names. Scatter includes all measured points up to 5,000 records. Larger results request a narrower scope.

Agent session rows include all matching submissions before pagination. Each row shows runs, outcomes, tokens, recorded repositories, and separate reported and estimated costs. Run records support a session filter. Time windows select submission dates. Usage can include later execution.

Access requires administrator permission. Results support filters, comparisons, and paged records. Migration 036 adds an index for active deployment lookups. Repository stacks avoid per-repository scans. Each Analytics SQL statement has a 10-second limit. Confirmed timeouts return HTTP 503 with a retry action. Invalid retained dates return null without failing the inventory. Invalid Agent queue dates and an invalid earliest run date also return null. The queue date field permits null without changing submission dates or counts.

Validation: 9,651 API tests and 55 gateway tests passed. Eleven existing API tests remain skipped. Lint, runtime TypeScript, scoped formatting, and the normal production build passed. Actual SQL ran against temporary PostgreSQL fixtures with 200,000 environment records, 500,000 deployment records, and 50,000 Agent runs. All measured statements completed within their limit. Seventeen payloads passed schema validation. Ten checks confirmed related metric totals agree. Seven additional checks cover invalid dates and unchanged submission cohorts. These local measurements do not establish production capacity.

Commit and PR text review: passed against the project writing standard, final change, and validation evidence.

UI text review: passed for API text shown in Analytics. Record measures preserve their estimates and data limits.

Deploy this API before the UI analytics change.

@vmelikyan
vmelikyan requested a review from a team as a code owner October 3, 2026 08:23
Add recorded API lifetimes and estimated lifetimes for torn-down PR environments.
Show unique components by repository and ready components across current environments.
Keep missing measurements unavailable.
Exclude incomplete identities from unique component counts.
@vmelikyan vmelikyan changed the title Add admin analytics for environments and Agent usage Add admin analytics for environments, components, and Agent usage Oct 3, 2026
The inventory query can reach its time limit as the number of current environments increases.
Read the selected component rows once and keep their latest deployment state for the result.
Counts and filters stay the same.

Return HTTP503 with analytics_timeout when PostgreSQL confirms a statement time limit.
Keep other failures unchanged and exclude database details from the response.
Count enabled optional components in current inventory.
Add complete lifetime scatter data and current age groups.
Add session summaries and exact session run filters.
@vmelikyan vmelikyan changed the title Add admin analytics for environments, components, and Agent usage Add admin analytics for environments, components, and Agent sessions Oct 4, 2026
Return repository groups for environment activity when requested.
Keep date totals complete and existing responses unchanged by default.
Return complete names through the existing record and scatter responses.

Describe record duration without implying deployed resources.
Keep existing query counts and measurement limits.
@vmelikyan vmelikyan changed the title Add admin analytics for environments, components, and Agent sessions Add admin analytics for environment records and Agent sessions Oct 4, 2026
Return null for invalid retained dates instead of failing inventory.
Keep valid records and current phase counts available.
Return null for invalid queue and earliest run dates.
Permit a null queue date without changing submission dates or counts.
@vmelikyan
vmelikyan merged commit f922754 into main Oct 7, 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