fix(gh-copilot): update Copilot metrics endpoints & schemas to latest…#9002
Open
bujjibabukatta wants to merge 1 commit into
Open
fix(gh-copilot): update Copilot metrics endpoints & schemas to latest…#9002bujjibabukatta wants to merge 1 commit into
bujjibabukatta wants to merge 1 commit into
Conversation
Contributor
Author
|
Hi @klesh could you please review and approve pull request? |
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.
Closes #8964
Summary
The
gh-copilotplugin pins the correct Copilot metrics API version(
2026-03-10) but is only partially implemented against it: severalresponse fields are dropped on extract, org-level rows lose their
identity, three endpoints aren't called at all, and a response-body
bug silently zeroes out both the enterprise and user report collectors.
Bugfixes
Double-read bug (2 occurrences).
parseRawReportResponseandparseUserMetricsReportResponseeach readres.Bodyonce directly,then again inside
parseReportMetadataResponse. The second readalways came back empty, so
metawas alwaysniland everyenterprise/user report was silently discarded — no error, no rows.
Fixed by reading once in both places.
Org identity.
ExtractOrgMetricshardcodedEnterpriseId: ""andnever set
OrganizationId, so org-level rows in the shared dailymetrics table had no identity of their own. Now stamps
OrganizationIdfrom the report (falling back to the connection'sconfigured org), and passes
EnterpriseIdthrough instead of forcingit blank.
Field gaps
daily/weekly/monthly_active_copilot_cloud_agent_usersused_copilot_coding_agent,used_copilot_cloud_agentai_adoption_phase/totals_by_ai_adoption_phase_tool_copilot_metrics_by_ai_adoption_phasetablepull_requests.copilot_suggestions_by_comment_typetotals_by_cli.last_known_cli_version,.avg_tokens_per_requestCopilotCliMetricsai_adoption_phasefield names (including the 2026-07-07 review-cyclefields and 2026-06-26
total_pull_requests_merged) were checkedagainst GitHub's changelog posts.
Missing endpoints
Implements
enterprise-28-day/latest,organization-28-day/latest,users-28-day/latest. These are single "latest" snapshot calls (noday param, unlike the -1-day reports) whose payload wraps entries in
a
day_totals[]array. Reuses the existingenterpriseDayTotal/userDailyReportshapes for the entries; writes to new, separatetables so this cadence can't silently overwrite -1-day rows for the
same
(connection, scope, day). Per-IDE/feature/language breakdownsare out of scope for 28-day data in this pass — the -1-day breakdowns
already cover those dimensions.
Migrations
20260720_add_copilot_metrics_gaps_v2.go— new columns + AIadoption phase table
20260720_add_copilot_28day_reports.go— the two new 28-day tablesMigration struct field names were cross-checked against the real
model structs field-by-field to make sure
AutoMigrateTablestargetsthe right columns.
Testing
go build ./plugins/gh-copilot/...go vet ./plugins/gh-copilot/...go test ./plugins/gh-copilot/...non-empty daily metrics tables (regression test for the
double-read bug)
day_totals[]shape against a real 28-day report response