Skip to content

Commit 3b7238c

Browse files
authored
Merge pull request #49 from vanchaudhary/feature/user-metrics-module
Added User Metrics Analytics Row, looks great, merged
2 parents 7eced05 + e45d5e8 commit 3b7238c

12 files changed

Lines changed: 14624 additions & 23 deletions

.env.template

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# ============================================================================
2+
# Copilot Usage Advanced Dashboard - Environment Configuration Template
3+
# ============================================================================
4+
# Copy this file to .env and fill in your values
5+
# Command: cp .env.template .env
6+
#
7+
# IMPORTANT: Never commit .env file to git (it's in .gitignore)
8+
# ============================================================================
9+
10+
# ----------------------------------------------------------------------------
11+
# REQUIRED: GitHub Configuration
12+
# ----------------------------------------------------------------------------
13+
# GitHub Personal Access Token with 'manage_billing:copilot' scope
14+
# Create at: https://github.com/settings/tokens
15+
GITHUB_PAT=ghp_your_token_here
16+
17+
# Your GitHub Organization or Enterprise slug(s)
18+
# Single org: ORGANIZATION_SLUGS=myorg
19+
# Multiple orgs: ORGANIZATION_SLUGS=org1,org2,org3
20+
ORGANIZATION_SLUGS=your-org-name
21+
22+
# ----------------------------------------------------------------------------
23+
# OPTIONAL: Elasticsearch Configuration
24+
# ----------------------------------------------------------------------------
25+
# Elasticsearch endpoint URL (default works for Docker Compose)
26+
ELASTICSEARCH_URL=http://elasticsearch:9200
27+
28+
# Elasticsearch authentication (if enabled)
29+
# ELASTICSEARCH_USER=elastic
30+
# ELASTICSEARCH_PASS=your-password
31+
32+
# ----------------------------------------------------------------------------
33+
# OPTIONAL: Execution Configuration
34+
# ----------------------------------------------------------------------------
35+
# How often to fetch data from GitHub APIs (in hours)
36+
# Default: 1 (fetches data every hour)
37+
EXECUTION_INTERVAL_HOURS=1
38+
39+
# ----------------------------------------------------------------------------
40+
# OPTIONAL: Custom Index Names
41+
# ----------------------------------------------------------------------------
42+
# Override default Elasticsearch index names if needed
43+
# INDEX_SEAT_INFO=copilot_seat_info_settings
44+
# INDEX_SEAT_ASSIGNMENTS=copilot_seat_assignments
45+
# INDEX_NAME_TOTAL=copilot_usage_total
46+
# INDEX_NAME_BREAKDOWN=copilot_usage_breakdown
47+
# INDEX_NAME_BREAKDOWN_CHAT=copilot_usage_breakdown_chat
48+
# INDEX_USER_METRICS=copilot_user_metrics
49+
# INDEX_USER_ADOPTION=copilot_user_adoption
50+
51+
# ----------------------------------------------------------------------------
52+
# OPTIONAL: Timezone Configuration
53+
# ----------------------------------------------------------------------------
54+
# Set your timezone (default: UTC)
55+
# TZ=America/New_York
56+
# TZ=Europe/London
57+
# TZ=Asia/Tokyo
58+
59+
# ----------------------------------------------------------------------------
60+
# OPTIONAL: Logging Configuration
61+
# ----------------------------------------------------------------------------
62+
# LOG_PATH=logs

README.md

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
|1.5| Add daily usage history for each user, old version upgrade guide refer to [this issue](https://github.com/satomic/copilot-usage-advanced-dashboard/issues/10) | 20250404 |
2020
|1.6| refactor timezone handling in main.py & Docker run ENV paras |20250410|
2121
|1.7| [Add Elasticsearch authentication](https://github.com/satomic/copilot-usage-advanced-dashboard/pull/19) |20250411|
22+
|1.8| **User Metrics Analytics Module**: Added 5th data source with user adoption leaderboard, Top 10 visualization, hourly automation, and production-ready deployment |20251120|
2223

2324
## Table of contents
2425

26+
- [🚀 Quick Start](#-quick-start-5-minutes)
2527
- [Introduction](#Introduction)
2628
- [Online Demo Environment ✨](#Online-Demo-Environment)
2729
- [Copilot Usage Advanced Dashboard](#Copilot-Usage-Advanced-Dashboard)
@@ -36,6 +38,7 @@
3638
- [5. Copilot Chat](#5-Copilot-Chat)
3739
- [6. Seat Analysis](#6-Seat-Analysis)
3840
- [7. Breakdown Heatmap](#7-Breakdown-Heatmap)
41+
- [8. User Metrics Analytics](#8-User-Metrics-Analytics)
3942
- [Copilot Usage Advanced Dashboard Original](#Copilot-Usage-Advanced-Dashboard-Original)
4043
- [1. Copilot Seat Info & Top Languages](#1-Copilot-Seat-Info--Top-Languages)
4144
- [2. Copilot Usage Total Insight](#2-Copilot-Usage-Total-Insight)
@@ -48,6 +51,64 @@
4851

4952
---
5053

54+
## 🚀 Quick Start (5 Minutes)
55+
56+
### Prerequisites
57+
- Docker Desktop installed ([Download](https://www.docker.com/products/docker-desktop))
58+
- GitHub Personal Access Token with `manage_billing:copilot` scope ([Create Token](https://github.com/settings/tokens))
59+
- Your GitHub Organization/Enterprise slug
60+
61+
### Setup Steps
62+
63+
1. **Clone the repository**
64+
```bash
65+
git clone https://github.com/satomic/copilot-usage-advanced-dashboard.git
66+
cd copilot-usage-advanced-dashboard
67+
```
68+
69+
2. **Configure environment**
70+
```bash
71+
cp .env.template .env
72+
# Edit .env file with your GitHub PAT and organization slug
73+
```
74+
75+
Minimal required configuration:
76+
```env
77+
GITHUB_PAT=ghp_your_token_here
78+
ORGANIZATION_SLUGS=your-org-name
79+
```
80+
81+
3. **Start the dashboard**
82+
```bash
83+
docker-compose up -d
84+
```
85+
86+
4. **Access Grafana**
87+
- URL: **http://localhost:8080**
88+
- Username: `admin`
89+
- Password: `copilot`
90+
- ✨ Dashboard loads automatically - no manual import needed!
91+
92+
### What Happens Automatically
93+
✅ Elasticsearch starts and creates 7 indexes
94+
✅ Grafana starts with pre-configured datasources
95+
✅ Dashboard provisions automatically from `/grafana-provisioning/dashboards/`
96+
`cpuad-updater` fetches data from 5 GitHub APIs every hour
97+
✅ User metrics populate in "User Metrics" row (9 panels)
98+
✅ System self-heals if any container crashes
99+
100+
### Environment Variables
101+
102+
| Variable | Required | Description | Default |
103+
|----------|----------|-------------|---------|
104+
| `GITHUB_PAT` | ✅ Yes | GitHub Personal Access Token | - |
105+
| `ORGANIZATION_SLUGS` | ✅ Yes | Comma-separated org slugs | - |
106+
| `ELASTICSEARCH_URL` | No | Elasticsearch endpoint | `http://elasticsearch:9200` |
107+
| `EXECUTION_INTERVAL_HOURS` | No | Data fetch frequency (hours) | `1` |
108+
| `INDEX_USER_METRICS` | No | User metrics index name | `copilot_user_metrics` |
109+
| `INDEX_USER_ADOPTION` | No | Adoption leaderboard index | `copilot_user_adoption` |
110+
111+
---
51112

52113
# Introduction
53114

@@ -57,6 +118,7 @@
57118
- [Get a summary of Copilot metrics for a team](https://docs.github.com/en/enterprise-cloud@latest/rest/copilot/copilot-metrics?apiVersion=2022-11-28#get-copilot-metrics-for-a-team)
58119
- [Get Copilot seat information and settings for an organization](https://docs.github.com/en/enterprise-cloud@latest/rest/copilot/copilot-user-management?apiVersion=2022-11-28#get-copilot-seat-information-and-settings-for-an-organization)
59120
- [List all Copilot seat assignments for an organization](https://docs.github.com/en/enterprise-cloud@latest/rest/copilot/copilot-user-management?apiVersion=2022-11-28#list-all-copilot-seat-assignments-for-an-organization)
121+
- [**NEW in v1.8** - Get Copilot User Metrics (28-day rolling window)](https://docs.github.com/en/enterprise-cloud@latest/rest/copilot/copilot-usage?apiVersion=2022-11-28#get-a-summary-of-copilot-user-metrics)
60122

61123
representing Copilot usage in multi organizations & teams from different dimensions. The features are summarized as follows:
62124
- Data is persisted in Elasticsearch and visualized in Grafana, **not just the past 28 days**. So you can freely choose the time period you want to visualize, such as the past year or a specific month.
@@ -197,7 +259,57 @@ The choice of variables is dynamically associated with the data display
197259

198260
![](image/image_i7-wXGj-UA.png)
199261

200-
## Copilot Usage Advanced Dashboard Original
262+
### 8. User Metrics Analytics
263+
264+
> **NEW in v1.8**: Complete user-level analytics powered by GitHub Copilot User Metrics API. Track individual user adoption, engagement patterns, and feature utilization with automated hourly updates.
265+
266+
Based on the data from [Get Copilot User Metrics](https://docs.github.com/en/enterprise-cloud@latest/rest/copilot/copilot-usage?apiVersion=2022-11-28#get-a-summary-of-copilot-user-metrics), this module provides comprehensive per-user analytics including:
267+
268+
**Key Metrics:**
269+
- **Total Users** = `cardinality(user_login)` - Unique users with Copilot activity
270+
- **Total Suggestions** = `sum(code_generation_activity_count)` - Code suggestions generated across all users
271+
- **Total Acceptances** = `sum(code_acceptance_activity_count)` - Code suggestions accepted by users
272+
- **Acceptance Rate** = `sum(code_acceptance_activity_count) / sum(code_generation_activity_count)` - Overall acceptance percentage
273+
- **Active Days** = `cardinality(day)` - Distinct days each user engaged with Copilot
274+
- **Adoption Score** = `(active_days / total_days_in_period) × 100` - User engagement percentage
275+
276+
**Per-User Analytics Table:**
277+
- User-initiated Interactions = `sum(user_initiated_interaction_count)`
278+
- Code Suggestions Generated = `sum(code_generation_activity_count)`
279+
- Code Suggestions Accepted = `sum(code_acceptance_activity_count)`
280+
- Average LOC Suggested = `avg(loc_suggested_to_add_sum)`
281+
- Average LOC Added = `avg(loc_added_sum)`
282+
- Agent Usage = `sum(used_agent)` - Copilot Agent feature usage count
283+
- Chat Usage = `sum(used_chat)` - Copilot Chat feature usage count
284+
- Active Days = `cardinality(day)` - Days with any Copilot activity
285+
286+
**Top 10 Copilot Users Leaderboard:**
287+
- Visualizes top 10 users by adoption percentage
288+
- Color-coded gradient from red (low adoption) to blue (high adoption)
289+
- 🔴 Red (0-40%): Needs attention
290+
- 🟠 Orange (40-60%): Moderate usage
291+
- 🟡 Yellow (60-80%): Good engagement
292+
- 🟢 Green (80-95%): Excellent adoption
293+
- 🔵 Blue (95-100%): Power user
294+
295+
**Automated Data Collection:**
296+
- Runs every hour (configurable via `EXECUTION_INTERVAL_HOURS`)
297+
- Fetches 28-day rolling window data from GitHub API
298+
- Calculates adoption scores automatically
299+
- Stores in 2 Elasticsearch indexes: `copilot_user_metrics` (raw data) and `copilot_user_adoption` (leaderboard scores)
300+
- No manual intervention required
301+
302+
![](image/user-metrics-dashboard.png)
303+
304+
**Use Cases:**
305+
- Identify power users and champions for Copilot evangelism
306+
- Track onboarding progress for new Copilot users
307+
- Spot users who need additional training or support
308+
- Measure team-level adoption trends over time
309+
- Monitor Chat and Agent feature adoption rates
310+
- Correlate active days with productivity metrics
311+
312+
201313

202314
### 1. Copilot Seat Info & Top Languages
203315

docker-compose.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ services:
2626
mem_limit: 1g
2727
cpus: 0.5
2828
ports:
29-
- "3000:80"
29+
- "8080:80"
3030
depends_on:
3131
- elasticsearch
3232
volumes:
3333
- grafana:/var/lib/grafana
34+
- ./grafana-provisioning/dashboards:/var/lib/grafana/dashboards
35+
- ./grafana-provisioning/dashboard.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml
36+
- ./user_advance_metrics_dashboard.json:/var/lib/grafana/dashboards/user_advance_metrics_dashboard.json
3437
environment:
3538
GF_LOG_LEVEL: debug
3639
GF_SERVER_HTTP_PORT: 80
@@ -69,10 +72,18 @@ services:
6972
- elasticsearch
7073
environment:
7174
GITHUB_PAT: ${GITHUB_PAT}
72-
ORGANIZATION_SLUGS: cody-test-org
75+
ORGANIZATION_SLUGS: ${ORGANIZATION_SLUGS:-standalone:octodemo-copilot-standalone}
7376
ELASTICSEARCH_URL: http://elasticsearch:9200
77+
INDEX_USER_METRICS: copilot_user_metrics
78+
INDEX_USER_ADOPTION: copilot_user_adoption
79+
EXECUTION_INTERVAL_HOURS: ${EXECUTION_INTERVAL_HOURS:-1}
7480
# Add other environment variables as needed
75-
restart: "no"
81+
restart: unless-stopped
82+
healthcheck:
83+
test: ["CMD", "pgrep", "-f", "python"]
84+
interval: 5m
85+
timeout: 10s
86+
retries: 3
7687

7788
volumes:
7889
data:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: 1
2+
providers:
3+
- name: 'default'
4+
orgId: 1
5+
folder: ''
6+
type: file
7+
disableDeletion: false
8+
editable: true
9+
options:
10+
path: /var/lib/grafana/dashboards
11+
foldersFromFilesStructure: true
12+
allowUiUpdates: true

0 commit comments

Comments
 (0)