From e85725eb1d6360486e894b431963c06370b10845 Mon Sep 17 00:00:00 2001 From: Tens1de Date: Wed, 26 Aug 2026 02:05:30 +0300 Subject: [PATCH 1/2] feat: Add Copilot code review active user counts to metrics structs Add daily/weekly/monthly active and passive Copilot code review user counts to CopilotDailyMetrics for aggregated usage metrics reports. Fixes #NNNN --- github/copilot.go | 32 +++++++++------- github/copilot_test.go | 34 +++++++++++++---- github/github-accessors.go | 48 ++++++++++++++++++++++++ github/github-accessors_test.go | 66 +++++++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+), 20 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 9dd24eb8ea3..2f0b8d901d7 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -1064,19 +1064,25 @@ type CopilotMetricsAIAdoptionPhaseTotals struct { // CopilotDailyMetrics represents the payload downloaded from a 1-day Copilot usage metrics report. type CopilotDailyMetrics struct { - Day string `json:"day"` - OrganizationID *string `json:"organization_id,omitempty"` - EnterpriseID *string `json:"enterprise_id,omitempty"` - DailyActiveCLIUsers *int `json:"daily_active_cli_users,omitempty"` - DailyActiveUsers *int `json:"daily_active_users,omitempty"` - DailyActiveCopilotCloudAgentUsers *int `json:"daily_active_copilot_cloud_agent_users,omitempty"` - WeeklyActiveUsers *int `json:"weekly_active_users,omitempty"` - WeeklyActiveCopilotCloudAgentUsers *int `json:"weekly_active_copilot_cloud_agent_users,omitempty"` - MonthlyActiveUsers *int `json:"monthly_active_users,omitempty"` - MonthlyActiveChatUsers *int `json:"monthly_active_chat_users,omitempty"` - MonthlyActiveAgentUsers *int `json:"monthly_active_agent_users,omitempty"` - MonthlyActiveCopilotCloudAgentUsers *int `json:"monthly_active_copilot_cloud_agent_users,omitempty"` - UserInitiatedInteractionCount *int `json:"user_initiated_interaction_count,omitempty"` + Day string `json:"day"` + OrganizationID *string `json:"organization_id,omitempty"` + EnterpriseID *string `json:"enterprise_id,omitempty"` + DailyActiveCLIUsers *int `json:"daily_active_cli_users,omitempty"` + DailyActiveUsers *int `json:"daily_active_users,omitempty"` + DailyActiveCopilotCloudAgentUsers *int `json:"daily_active_copilot_cloud_agent_users,omitempty"` + WeeklyActiveUsers *int `json:"weekly_active_users,omitempty"` + WeeklyActiveCopilotCloudAgentUsers *int `json:"weekly_active_copilot_cloud_agent_users,omitempty"` + MonthlyActiveUsers *int `json:"monthly_active_users,omitempty"` + MonthlyActiveChatUsers *int `json:"monthly_active_chat_users,omitempty"` + MonthlyActiveAgentUsers *int `json:"monthly_active_agent_users,omitempty"` + MonthlyActiveCopilotCloudAgentUsers *int `json:"monthly_active_copilot_cloud_agent_users,omitempty"` + DailyActiveCopilotCodeReviewUsers *int `json:"daily_active_copilot_code_review_users,omitempty"` + WeeklyActiveCopilotCodeReviewUsers *int `json:"weekly_active_copilot_code_review_users,omitempty"` + MonthlyActiveCopilotCodeReviewUsers *int `json:"monthly_active_copilot_code_review_users,omitempty"` + DailyPassiveCopilotCodeReviewUsers *int `json:"daily_passive_copilot_code_review_users,omitempty"` + WeeklyPassiveCopilotCodeReviewUsers *int `json:"weekly_passive_copilot_code_review_users,omitempty"` + MonthlyPassiveCopilotCodeReviewUsers *int `json:"monthly_passive_copilot_code_review_users,omitempty"` + UserInitiatedInteractionCount *int `json:"user_initiated_interaction_count,omitempty"` CopilotMetricsChatPanel CodeGenerationActivityCount *int `json:"code_generation_activity_count,omitempty"` CodeAcceptanceActivityCount *int `json:"code_acceptance_activity_count,omitempty"` diff --git a/github/copilot_test.go b/github/copilot_test.go index bf3453cf442..827b2e2a2ce 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -3035,8 +3035,14 @@ func TestCopilotService_DownloadDailyMetrics(t *testing.T) { "organization_id": "123", "daily_active_cli_users": 2, "daily_active_users": 10, + "daily_active_copilot_code_review_users": 3, + "daily_passive_copilot_code_review_users": 1, "weekly_active_users": 20, + "weekly_active_copilot_code_review_users": 8, + "weekly_passive_copilot_code_review_users": 2, "monthly_active_users": 30, + "monthly_active_copilot_code_review_users": 15, + "monthly_passive_copilot_code_review_users": 4, "chat_panel_ask_mode": 4, "totals_by_ide": [ {"ide": "vscode", "user_initiated_interaction_count": 5, "loc_added_sum": 100} @@ -3115,10 +3121,16 @@ func TestCopilotService_DownloadDailyMetrics(t *testing.T) { want := &CopilotDailyMetrics{ Day: "2026-04-01", OrganizationID: Ptr("123"), - DailyActiveCLIUsers: Ptr(2), - DailyActiveUsers: Ptr(10), - WeeklyActiveUsers: Ptr(20), - MonthlyActiveUsers: Ptr(30), + DailyActiveCLIUsers: Ptr(2), + DailyActiveUsers: Ptr(10), + DailyActiveCopilotCodeReviewUsers: Ptr(3), + DailyPassiveCopilotCodeReviewUsers: Ptr(1), + WeeklyActiveUsers: Ptr(20), + WeeklyActiveCopilotCodeReviewUsers: Ptr(8), + WeeklyPassiveCopilotCodeReviewUsers: Ptr(2), + MonthlyActiveUsers: Ptr(30), + MonthlyActiveCopilotCodeReviewUsers: Ptr(15), + MonthlyPassiveCopilotCodeReviewUsers: Ptr(4), CopilotMetricsChatPanel: CopilotMetricsChatPanel{ ChatPanelAskMode: Ptr(4), }, @@ -3228,6 +3240,10 @@ func TestCopilotService_DownloadPeriodicMetrics(t *testing.T) { "day": "2026-03-05", "daily_active_cli_users": 2, "daily_active_users": 5, + "daily_active_copilot_code_review_users": 2, + "daily_passive_copilot_code_review_users": 1, + "weekly_active_copilot_code_review_users": 6, + "monthly_active_copilot_code_review_users": 12, "totals_by_cli": { "session_count": 1, "request_count": 2, @@ -3266,9 +3282,13 @@ func TestCopilotService_DownloadPeriodicMetrics(t *testing.T) { CreatedAt: refTimestamp(1136178000), DayTotals: []*CopilotDailyMetrics{ { - Day: "2026-03-05", - DailyActiveCLIUsers: Ptr(2), - DailyActiveUsers: Ptr(5), + Day: "2026-03-05", + DailyActiveCLIUsers: Ptr(2), + DailyActiveUsers: Ptr(5), + DailyActiveCopilotCodeReviewUsers: Ptr(2), + DailyPassiveCopilotCodeReviewUsers: Ptr(1), + WeeklyActiveCopilotCodeReviewUsers: Ptr(6), + MonthlyActiveCopilotCodeReviewUsers: Ptr(12), TotalsByCLI: &CopilotMetricsCLI{ SessionCount: Ptr(1), RequestCount: Ptr(2), diff --git a/github/github-accessors.go b/github/github-accessors.go index 6b15a7c02f7..9425b67e944 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -9126,6 +9126,14 @@ func (c *CopilotDailyMetrics) GetDailyActiveCopilotCloudAgentUsers() int { return *c.DailyActiveCopilotCloudAgentUsers } +// GetDailyActiveCopilotCodeReviewUsers returns the DailyActiveCopilotCodeReviewUsers field if it's non-nil, zero value otherwise. +func (c *CopilotDailyMetrics) GetDailyActiveCopilotCodeReviewUsers() int { + if c == nil || c.DailyActiveCopilotCodeReviewUsers == nil { + return 0 + } + return *c.DailyActiveCopilotCodeReviewUsers +} + // GetDailyActiveUsers returns the DailyActiveUsers field if it's non-nil, zero value otherwise. func (c *CopilotDailyMetrics) GetDailyActiveUsers() int { if c == nil || c.DailyActiveUsers == nil { @@ -9134,6 +9142,14 @@ func (c *CopilotDailyMetrics) GetDailyActiveUsers() int { return *c.DailyActiveUsers } +// GetDailyPassiveCopilotCodeReviewUsers returns the DailyPassiveCopilotCodeReviewUsers field if it's non-nil, zero value otherwise. +func (c *CopilotDailyMetrics) GetDailyPassiveCopilotCodeReviewUsers() int { + if c == nil || c.DailyPassiveCopilotCodeReviewUsers == nil { + return 0 + } + return *c.DailyPassiveCopilotCodeReviewUsers +} + // GetDay returns the Day field. func (c *CopilotDailyMetrics) GetDay() string { if c == nil { @@ -9206,6 +9222,14 @@ func (c *CopilotDailyMetrics) GetMonthlyActiveCopilotCloudAgentUsers() int { return *c.MonthlyActiveCopilotCloudAgentUsers } +// GetMonthlyActiveCopilotCodeReviewUsers returns the MonthlyActiveCopilotCodeReviewUsers field if it's non-nil, zero value otherwise. +func (c *CopilotDailyMetrics) GetMonthlyActiveCopilotCodeReviewUsers() int { + if c == nil || c.MonthlyActiveCopilotCodeReviewUsers == nil { + return 0 + } + return *c.MonthlyActiveCopilotCodeReviewUsers +} + // GetMonthlyActiveUsers returns the MonthlyActiveUsers field if it's non-nil, zero value otherwise. func (c *CopilotDailyMetrics) GetMonthlyActiveUsers() int { if c == nil || c.MonthlyActiveUsers == nil { @@ -9214,6 +9238,14 @@ func (c *CopilotDailyMetrics) GetMonthlyActiveUsers() int { return *c.MonthlyActiveUsers } +// GetMonthlyPassiveCopilotCodeReviewUsers returns the MonthlyPassiveCopilotCodeReviewUsers field if it's non-nil, zero value otherwise. +func (c *CopilotDailyMetrics) GetMonthlyPassiveCopilotCodeReviewUsers() int { + if c == nil || c.MonthlyPassiveCopilotCodeReviewUsers == nil { + return 0 + } + return *c.MonthlyPassiveCopilotCodeReviewUsers +} + // GetOrganizationID returns the OrganizationID field if it's non-nil, zero value otherwise. func (c *CopilotDailyMetrics) GetOrganizationID() string { if c == nil || c.OrganizationID == nil { @@ -9310,6 +9342,14 @@ func (c *CopilotDailyMetrics) GetWeeklyActiveCopilotCloudAgentUsers() int { return *c.WeeklyActiveCopilotCloudAgentUsers } +// GetWeeklyActiveCopilotCodeReviewUsers returns the WeeklyActiveCopilotCodeReviewUsers field if it's non-nil, zero value otherwise. +func (c *CopilotDailyMetrics) GetWeeklyActiveCopilotCodeReviewUsers() int { + if c == nil || c.WeeklyActiveCopilotCodeReviewUsers == nil { + return 0 + } + return *c.WeeklyActiveCopilotCodeReviewUsers +} + // GetWeeklyActiveUsers returns the WeeklyActiveUsers field if it's non-nil, zero value otherwise. func (c *CopilotDailyMetrics) GetWeeklyActiveUsers() int { if c == nil || c.WeeklyActiveUsers == nil { @@ -9318,6 +9358,14 @@ func (c *CopilotDailyMetrics) GetWeeklyActiveUsers() int { return *c.WeeklyActiveUsers } +// GetWeeklyPassiveCopilotCodeReviewUsers returns the WeeklyPassiveCopilotCodeReviewUsers field if it's non-nil, zero value otherwise. +func (c *CopilotDailyMetrics) GetWeeklyPassiveCopilotCodeReviewUsers() int { + if c == nil || c.WeeklyPassiveCopilotCodeReviewUsers == nil { + return 0 + } + return *c.WeeklyPassiveCopilotCodeReviewUsers +} + // GetDownloadLinks returns the DownloadLinks slice if it's non-nil, nil otherwise. func (c *CopilotDailyMetricsReport) GetDownloadLinks() []string { if c == nil || c.DownloadLinks == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 7e7bea2b941..b66d7caa46b 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -11644,6 +11644,17 @@ func TestCopilotDailyMetrics_GetDailyActiveCopilotCloudAgentUsers(tt *testing.T) c.GetDailyActiveCopilotCloudAgentUsers() } +func TestCopilotDailyMetrics_GetDailyActiveCopilotCodeReviewUsers(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &CopilotDailyMetrics{DailyActiveCopilotCodeReviewUsers: &zeroValue} + c.GetDailyActiveCopilotCodeReviewUsers() + c = &CopilotDailyMetrics{} + c.GetDailyActiveCopilotCodeReviewUsers() + c = nil + c.GetDailyActiveCopilotCodeReviewUsers() +} + func TestCopilotDailyMetrics_GetDailyActiveUsers(tt *testing.T) { tt.Parallel() var zeroValue int @@ -11655,6 +11666,17 @@ func TestCopilotDailyMetrics_GetDailyActiveUsers(tt *testing.T) { c.GetDailyActiveUsers() } +func TestCopilotDailyMetrics_GetDailyPassiveCopilotCodeReviewUsers(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &CopilotDailyMetrics{DailyPassiveCopilotCodeReviewUsers: &zeroValue} + c.GetDailyPassiveCopilotCodeReviewUsers() + c = &CopilotDailyMetrics{} + c.GetDailyPassiveCopilotCodeReviewUsers() + c = nil + c.GetDailyPassiveCopilotCodeReviewUsers() +} + func TestCopilotDailyMetrics_GetDay(tt *testing.T) { tt.Parallel() c := &CopilotDailyMetrics{} @@ -11751,6 +11773,17 @@ func TestCopilotDailyMetrics_GetMonthlyActiveCopilotCloudAgentUsers(tt *testing. c.GetMonthlyActiveCopilotCloudAgentUsers() } +func TestCopilotDailyMetrics_GetMonthlyActiveCopilotCodeReviewUsers(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &CopilotDailyMetrics{MonthlyActiveCopilotCodeReviewUsers: &zeroValue} + c.GetMonthlyActiveCopilotCodeReviewUsers() + c = &CopilotDailyMetrics{} + c.GetMonthlyActiveCopilotCodeReviewUsers() + c = nil + c.GetMonthlyActiveCopilotCodeReviewUsers() +} + func TestCopilotDailyMetrics_GetMonthlyActiveUsers(tt *testing.T) { tt.Parallel() var zeroValue int @@ -11762,6 +11795,17 @@ func TestCopilotDailyMetrics_GetMonthlyActiveUsers(tt *testing.T) { c.GetMonthlyActiveUsers() } +func TestCopilotDailyMetrics_GetMonthlyPassiveCopilotCodeReviewUsers(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &CopilotDailyMetrics{MonthlyPassiveCopilotCodeReviewUsers: &zeroValue} + c.GetMonthlyPassiveCopilotCodeReviewUsers() + c = &CopilotDailyMetrics{} + c.GetMonthlyPassiveCopilotCodeReviewUsers() + c = nil + c.GetMonthlyPassiveCopilotCodeReviewUsers() +} + func TestCopilotDailyMetrics_GetOrganizationID(tt *testing.T) { tt.Parallel() var zeroValue string @@ -11888,6 +11932,17 @@ func TestCopilotDailyMetrics_GetWeeklyActiveCopilotCloudAgentUsers(tt *testing.T c.GetWeeklyActiveCopilotCloudAgentUsers() } +func TestCopilotDailyMetrics_GetWeeklyActiveCopilotCodeReviewUsers(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &CopilotDailyMetrics{WeeklyActiveCopilotCodeReviewUsers: &zeroValue} + c.GetWeeklyActiveCopilotCodeReviewUsers() + c = &CopilotDailyMetrics{} + c.GetWeeklyActiveCopilotCodeReviewUsers() + c = nil + c.GetWeeklyActiveCopilotCodeReviewUsers() +} + func TestCopilotDailyMetrics_GetWeeklyActiveUsers(tt *testing.T) { tt.Parallel() var zeroValue int @@ -11899,6 +11954,17 @@ func TestCopilotDailyMetrics_GetWeeklyActiveUsers(tt *testing.T) { c.GetWeeklyActiveUsers() } +func TestCopilotDailyMetrics_GetWeeklyPassiveCopilotCodeReviewUsers(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &CopilotDailyMetrics{WeeklyPassiveCopilotCodeReviewUsers: &zeroValue} + c.GetWeeklyPassiveCopilotCodeReviewUsers() + c = &CopilotDailyMetrics{} + c.GetWeeklyPassiveCopilotCodeReviewUsers() + c = nil + c.GetWeeklyPassiveCopilotCodeReviewUsers() +} + func TestCopilotDailyMetricsReport_GetDownloadLinks(tt *testing.T) { tt.Parallel() zeroValue := []string{} From c6ffcb4c187593329123682b0042a72e1a34f1d7 Mon Sep 17 00:00:00 2001 From: Tens1de Date: Wed, 26 Aug 2026 02:11:28 +0300 Subject: [PATCH 2/2] style: Fix formatting in Copilot metrics tests --- github/copilot_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/copilot_test.go b/github/copilot_test.go index 827b2e2a2ce..9a1c2eac7b0 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -3119,8 +3119,8 @@ func TestCopilotService_DownloadDailyMetrics(t *testing.T) { } want := &CopilotDailyMetrics{ - Day: "2026-04-01", - OrganizationID: Ptr("123"), + Day: "2026-04-01", + OrganizationID: Ptr("123"), DailyActiveCLIUsers: Ptr(2), DailyActiveUsers: Ptr(10), DailyActiveCopilotCodeReviewUsers: Ptr(3),