Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions github/copilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,22 @@ type CopilotMetricsCLI struct {
LastKnownCLIVersion *CopilotMetricsCLIVersion `json:"last_known_cli_version,omitempty"`
}

// CopilotMetricsThirdPartyAgent represents per-agent app totals in a Copilot usage metrics report.
//
// AgentID is the stable grouping key. AgentName is for display and can change.
// UserInitiatedInteractionCount is agent-app job starts; it is not the same as
// the top-level user_initiated_interaction_count on the parent metrics object.
// SessionCount is included on aggregated enterprise and organization reports
// and omitted from per-user reports.
//
// GitHub API docs: https://docs.github.com/en/copilot/reference/copilot-usage-metrics/copilot-usage-metrics#agent-apps-metrics-fields
type CopilotMetricsThirdPartyAgent struct {
AgentName string `json:"agent_name"`
AgentID string `json:"agent_id"`
UserInitiatedInteractionCount *int `json:"user_initiated_interaction_count,omitempty"`
SessionCount *int `json:"session_count,omitempty"`
Comment on lines +1023 to +1024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought these were unmarshal only types so I'm unsure why they need omitempty?

}

// CopilotDailyMetrics represents the payload downloaded from a 1-day Copilot usage metrics report.
type CopilotDailyMetrics struct {
Day string `json:"day"`
Expand All @@ -1032,6 +1048,7 @@ type CopilotDailyMetrics struct {
TotalsByLanguageModel []*CopilotMetricsLanguageModel `json:"totals_by_language_model,omitempty"`
TotalsByModelFeature []*CopilotMetricsModelFeature `json:"totals_by_model_feature,omitempty"`
TotalsByCLI *CopilotMetricsCLI `json:"totals_by_cli,omitempty"`
TotalsBy3rdPartyAgent []*CopilotMetricsThirdPartyAgent `json:"totals_by_3rd_party_agent,omitempty"`
LOCSuggestedToAddSum *int `json:"loc_suggested_to_add_sum,omitempty"`
LOCSuggestedToDeleteSum *int `json:"loc_suggested_to_delete_sum,omitempty"`
LOCAddedSum *int `json:"loc_added_sum,omitempty"`
Expand Down Expand Up @@ -1092,6 +1109,7 @@ type CopilotUserDailyMetrics struct {
TotalsByLanguageModel []*CopilotMetricsLanguageModel `json:"totals_by_language_model,omitempty"`
TotalsByModelFeature []*CopilotMetricsModelFeature `json:"totals_by_model_feature,omitempty"`
TotalsByCLI *CopilotMetricsCLI `json:"totals_by_cli,omitempty"`
TotalsBy3rdPartyAgent []*CopilotMetricsThirdPartyAgent `json:"totals_by_3rd_party_agent,omitempty"`
UsedAgent *bool `json:"used_agent,omitempty"`
UsedChat *bool `json:"used_chat,omitempty"`
UsedCLI *bool `json:"used_cli,omitempty"`
Expand Down Expand Up @@ -1125,6 +1143,7 @@ type CopilotUserPeriodicMetrics struct {
TotalsByLanguageModel []*CopilotMetricsLanguageModel `json:"totals_by_language_model,omitempty"`
TotalsByModelFeature []*CopilotMetricsModelFeature `json:"totals_by_model_feature,omitempty"`
TotalsByCLI *CopilotMetricsCLI `json:"totals_by_cli,omitempty"`
TotalsBy3rdPartyAgent []*CopilotMetricsThirdPartyAgent `json:"totals_by_3rd_party_agent,omitempty"`
UsedAgent *bool `json:"used_agent,omitempty"`
UsedChat *bool `json:"used_chat,omitempty"`
UsedCLI *bool `json:"used_cli,omitempty"`
Expand Down
25 changes: 24 additions & 1 deletion github/copilot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3064,6 +3064,14 @@ func TestCopilotService_DownloadDailyMetrics(t *testing.T) {
"prompt_tokens_sum": 9494
}
},
"totals_by_3rd_party_agent": [
{
"agent_name": "Claude",
"agent_id": "claude",
"user_initiated_interaction_count": 8,
"session_count": 3
}
],
"loc_added_sum": 100,
"pull_requests": {
"total_reviewed": 1,
Expand Down Expand Up @@ -3121,6 +3129,14 @@ func TestCopilotService_DownloadDailyMetrics(t *testing.T) {
PromptTokensSum: Ptr(9494),
},
},
TotalsBy3rdPartyAgent: []*CopilotMetricsThirdPartyAgent{
{
AgentName: "Claude",
AgentID: "claude",
UserInitiatedInteractionCount: Ptr(8),
SessionCount: Ptr(3),
},
},
LOCAddedSum: Ptr(100),
PullRequests: &CopilotMetricsPullRequests{
TotalReviewed: Ptr(1),
Expand Down Expand Up @@ -3268,7 +3284,7 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) {

mux.HandleFunc("/path/to/users-daily", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"user_id":1,"user_login":"alice","day":"2026-04-01","user_initiated_interaction_count":5,"chat_panel_edit_mode":2,"used_chat":true,"used_cli":true,"used_copilot_code_review_active":true,"totals_by_cli":{"session_count":2,"request_count":2,"prompt_count":1,"last_known_cli_version":{"sampled_at":`+refTimeStr(1136178000)+`,"cli_version":"1.0.8"}},"totals_by_ide":[{"ide":"vscode","user_initiated_interaction_count":5,"last_known_plugin_version":{"sampled_at":`+refTimeStr(1136178001)+`,"plugin":"copilot","plugin_version":"1.0.0"},"last_known_ide_version":{"sampled_at":`+refTimeStr(1136178002)+`,"ide_version":"1.90"}}]}
fmt.Fprint(w, `{"user_id":1,"user_login":"alice","day":"2026-04-01","user_initiated_interaction_count":5,"chat_panel_edit_mode":2,"used_chat":true,"used_cli":true,"used_copilot_code_review_active":true,"totals_by_cli":{"session_count":2,"request_count":2,"prompt_count":1,"last_known_cli_version":{"sampled_at":`+refTimeStr(1136178000)+`,"cli_version":"1.0.8"}},"totals_by_ide":[{"ide":"vscode","user_initiated_interaction_count":5,"last_known_plugin_version":{"sampled_at":`+refTimeStr(1136178001)+`,"plugin":"copilot","plugin_version":"1.0.0"},"last_known_ide_version":{"sampled_at":`+refTimeStr(1136178002)+`,"ide_version":"1.90"}}],"totals_by_3rd_party_agent":[{"agent_name":"Claude","agent_id":"claude","user_initiated_interaction_count":2}]}
{"user_id":2,"user_login":"bob","day":"2026-04-01","used_agent":true,"used_copilot_code_review_passive":true}
`)
})
Expand Down Expand Up @@ -3319,6 +3335,13 @@ func TestCopilotService_DownloadUserDailyMetrics(t *testing.T) {
},
},
},
TotalsBy3rdPartyAgent: []*CopilotMetricsThirdPartyAgent{
{
AgentName: "Claude",
AgentID: "claude",
UserInitiatedInteractionCount: Ptr(2),
},
},
},
{
UserID: 2,
Expand Down
56 changes: 56 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading