Skip to content

Commit 9d1f7e9

Browse files
committed
Add USAGE_API.md for legacy API and update README to include latest instructions. Add some image assets for documentation and the latest PBIX files.
1 parent bbcbb19 commit 9d1f7e9

7 files changed

+142
-28
lines changed

README.md

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,106 @@
11
# GitHub Copilot Metrics Viewer for Power BI
22

3-
With the release of the [GitHub Copilot Metrics API](https://github.blog/changelog/2024-04-23-github-copilot-metrics-api-now-available-in-public-beta/) many teams are looking to leverage this data to help monitor usage against their KPIs. For some, the Copilot Metrics Viewer ([github-copilot-resources/copilot-metrics-viewer](https://github.com/github-copilot-resources/copilot-metrics-viewer)) might be a great option.
3+
With the release of the latest [GitHub Copilot Metrics API](https://github.com/orgs/community/discussions/141071) many teams are looking to leverage this data to help monitor usage against their KPIs. For some, the Copilot Metrics Viewer ([github-copilot-resources/copilot-metrics-viewer](https://github.com/github-copilot-resources/copilot-metrics-viewer)) might be a great option.
44

55
However, many organizations that we work with already have established Power BI teams. If your organization is **already using Power BI, please read on!**
66

7-
Located in the `./samples` directory you'll find sample JSON and PBIX files used to create the dashboard below.
7+
Located in the `./samples` directory you'll find sample JSON and PBIX files used to create the *new* dashboard below.
8+
> Note: The legacy GitHub Copilot Usage API is still available and can be used with the legacy PBIX file. For instructions, see [Usage_API.md](USAGE_API.md).
89
9-
![Image of a Power BI dashboard with GitHuub Copilot Metrics API data displayed.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Sample_PBI.png)
10+
![Image of the Power BI dashboard with sample GitHub Copilot Metrics API data displayed.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Sample_Metrics_PBI.png)
1011

1112
## Setup
1213

1314
### Test: Modify the local JSON data source
1415
> Note: This example provided a proof of concept for loading metrics data and requires an exported JSON file. If you have access to the REST API you can configure the **Source** accordingly.
1516
16-
1. Download and open the sample `GitHub Copilot - Telemetry Sample (DM).pbix` file.
17+
1. Download and open the sample `GitHub Copilot - Telemetry Sample (Metrics with KPIs).pbix` file.
1718
2. The file contains three data sources on the right hand side.
1819

1920
| Name | Description |
2021
| :-------------------- | :----------------------------------------------------- |
21-
| GH Copilot - Details | Detailed breakdown of metrics data by language and editor. |
22-
| GH Copilot - Summary | Daily summary of metrics data. |
23-
| Last Refresh | Used to display the data time of data refresh on the top-right corner of the dashboard. |
24-
25-
3. Open the **Power Query Editor** by right clicking the `GH Copilot - Details` and selecting **Edit query**.
26-
4. Modify the **Source** step by clicking the settings icon, selecting your JSON file and clicking **OK**.
22+
| config | Configuration used to display date of refresh and for setting up KPI dashboard |
23+
| source | Base source used to connect to API or local JSON files. |
24+
| GH Copilot - dotcom chat | Detailed metrics of code completions using chat on the web. |
25+
| GH Copilot - ide chat | Detailed metrics of code completions using chat within the IDE. |
26+
| GH Copilot - ide code completions | Detailed metrics of code completions within the IDE. |
27+
| GH Copilot - pull requests | Detailed metrics of pull requests. |
28+
| GH Copilot - summary | Daily summary of active and egnaged user. |
29+
30+
3. Open the **Power Query Editor** by clicking **Transform data** in the top-menu and selecting **Tranform data**.
31+
4. Click on **source** query in the left-menu, then under APPLIED STEPS in the right-menu click the gear (settings) icon, selecting your JSON file and clicking **OK**.
2732
![Image of a data source selector in Power Query Editor.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Modify_JSON_source.png)
28-
6. Repeat steps 3 and 4 for the `GH Copilot - Summary` **Source**.
29-
7. Click **Close and Apply** in the top-left of the **Power Query Editor**.
30-
8. On the **Report View** page click **Refresh** to load the new data into your dashboard.
31-
9. **Happy Customizing!**
33+
5. Click **Close and Apply** in the top-left of the **Power Query Editor**.
34+
6. On the **Report View** page click **Refresh** to load the new data into your dashboard.
35+
7. **Happy Customizing!**
3236

3337
### Connect to Metrics API
34-
> Notes: The REST API provides metrics for the previous 28 days and is refreshed daily with data from the previous day. This is currently in beta, so please ensure you are using the latest version of the [REST API](https://docs.github.com/en/rest/copilot/copilot-usage).
38+
> Notes: The REST API provides metrics for the previous 28 days and is refreshed daily with data from the previous day. Please ensure you are using the latest version of the [REST API](https://docs.github.com/en/enterprise-cloud@latest/rest/copilot/copilot-metrics).
3539
3640
In order to connect we'll need to generate a token and link to your metrics data:
37-
1. Download and open the sample `GitHub Copilot - Telemetry Sample (DM).pbix` file.
38-
2. Determine if you'll be using the `Enterprise` or `Organization` URL.
41+
1. Download and open the sample `GitHub Copilot - Telemetry Sample (Metrics with KPI).pbix` file.
42+
2. Determine if you'll be using the `Enterprise`, `Organization` or `Team` URL.
3943
3. Follow the instructions below to generate a token with permissions to access the API:
4044
[REST API endpoints for GitHub Copilot usage metrics - GitHub Docs](https://docs.github.com/en/rest/copilot/copilot-usage)
4145
>**IMPORTANT: Do not share this token and ensure you follow you organizations security policies.**
42-
4. Open the **Power Query Editor** by right clicking the `GH Copilot - Details` and selecting **Edit query**.
43-
5. Select **Advanced editor**.
46+
4. Open the **Power Query Editor** by clicking **Transform data** in the top-menu and selecting **Tranform data**.
47+
5. Click on **source** in the left-menu
48+
6. Select **Advanced editor**.
4449
![Image of Power Query Advanced Editor.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Advanced_editor.png)
45-
6. Replace the first 2 lines with following, ensure to replace <YOUR-TOKEN> and <ORG> with the values from step 1 and 2.
50+
7. Replace the first 2 lines with following, ensure to replace <YOUR-TOKEN> and <ORG> with the values from step 1 and 2.
4651

52+
**Enterprise**
53+
```powerquery
54+
let
55+
// Replace <YOUR-TOKEN> and <ENTERPRISE> with your actual token and enterprise name.
56+
url = "https://api.github.com/enterprises/<ENTERPRISE>/copilot/metrics",
57+
headers = [
58+
#"Accept" = "application/vnd.github+json",
59+
#"Authorization" = "Bearer <YOUR-TOKEN>",
60+
#"X-GitHub-Api-Version" = "2022-11-28"
61+
],
62+
Source = Json.Document(Web.Contents(url, [Headers=headers])),
63+
```
64+
65+
**Enterprise Team**
66+
```powerquery
67+
let
68+
// Replace <YOUR-TOKEN>, <ENTERPRISE> and <TEAM_SLUG> with your actual token and enterprise name.
69+
url = "https://api.github.com/enterprises/<ENTERPRISE>/team/<TEAM_SLUG>/copilot/metrics
70+
headers = [
71+
#"Accept" = "application/vnd.github+json",
72+
#"Authorization" = "Bearer <YOUR-TOKEN>",
73+
#"X-GitHub-Api-Version" = "2022-11-28"
74+
],
75+
Source = Json.Document(Web.Contents(url, [Headers=headers])),
76+
```
4777
**Organization**
4878
```powerquery
4979
let
5080
// Replace <YOUR-TOKEN> and <ORG> with your actual token and org name.
51-
url = "https://api.github.com/orgs/<ORG>/copilot/usage",
81+
url = "https://api.github.com/orgs/<ORG>/copilot/metrics",
5282
headers = [
5383
#"Accept" = "application/vnd.github+json",
5484
#"Authorization" = "Bearer <YOUR-TOKEN>",
5585
#"X-GitHub-Api-Version" = "2022-11-28"
5686
],
5787
Source = Json.Document(Web.Contents(url, [Headers=headers])),
5888
```
59-
**Enterprise**
89+
**Team**
6090
```powerquery
6191
let
62-
// Replace <YOUR-TOKEN> and <ENTERPRISE> with your actual token and enterprise name.
63-
url = "https://api.github.com/enterprises/<ENTERPRISE>/copilot/usage",
92+
// Replace <YOUR-TOKEN>, <ORG> and <TEAM_SLUG> with your actual token and enterprise name.
93+
url = "https://api.github.com/orgs/<ORG>/team/<TEAM_SLUG>/copilot/metrics",
6494
headers = [
6595
#"Accept" = "application/vnd.github+json",
6696
#"Authorization" = "Bearer <YOUR-TOKEN>",
6797
#"X-GitHub-Api-Version" = "2022-11-28"
6898
],
6999
Source = Json.Document(Web.Contents(url, [Headers=headers])),
70100
```
71-
7. Your Power Query will look something like this:
72-
![Image of Power Query Advanced Editor.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Advanced_editor_query.png)
73-
8. Click **OK** to close the editor and select `Anonymous` authentication if prompted.
74-
9. Repeat steps 4 and 8 for the `GH Copilot - Summary` **Source**.
101+
8. Your Power Query will look something like this:
102+
![Image of Power Query Advanced Editor.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Advanced_editor_metrics_query.png)
103+
9. Click **OK** to close the editor and select `Anonymous` authentication if prompted.
75104
10. Click **Close and Apply** in the top-left of the **Power Query Editor**.
76105
11. On the **Report View** page click **Refresh** to load the new data into your dashboard.
77106

USAGE_API.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# GitHub Copilot Metrics Viewer for Power BI
2+
3+
> **Note:** The legacy GitHub Copilot Usage API is deprecated. Please refer to the new [GitHub Copilot Metrics API](https://github.com/orgs/community/discussions/141071).
4+
5+
Located in the `./samples` directory you'll find sample JSON and PBIX files used to create the dashboard below.
6+
7+
![Image of a Power BI dashboard with GitHuub Copilot Metrics API data displayed.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Sample_PBI.png)
8+
9+
## Setup
10+
11+
### Test: Modify the local JSON data source
12+
> Note: This example provided a proof of concept for loading metrics data and requires an exported JSON file. If you have access to the REST API you can configure the **Source** accordingly.
13+
14+
1. Download and open the sample `GitHub Copilot - Telemetry Sample (Usage).pbix` file.
15+
2. The file contains three data sources on the right hand side.
16+
17+
| Name | Description |
18+
| :-------------------- | :----------------------------------------------------- |
19+
| GH Copilot - Details | Detailed breakdown of metrics data by language and editor. |
20+
| GH Copilot - Summary | Daily summary of metrics data. |
21+
| Last Refresh | Used to display the data time of data refresh on the top-right corner of the dashboard. |
22+
23+
3. Open the **Power Query Editor** by right clicking the `GH Copilot - Details` and selecting **Edit query**.
24+
4. Modify the **Source** step by clicking the settings icon, selecting your JSON file and clicking **OK**.
25+
![Image of a data source selector in Power Query Editor.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Modify_JSON_source.png)
26+
6. Repeat steps 3 and 4 for the `GH Copilot - Summary` **Source**.
27+
7. Click **Close and Apply** in the top-left of the **Power Query Editor**.
28+
8. On the **Report View** page click **Refresh** to load the new data into your dashboard.
29+
9. **Happy Customizing!**
30+
31+
### Connect to Metrics API
32+
> Notes: The REST API provides metrics for the previous 28 days and is refreshed daily with data from the previous day. This is currently in beta, so please ensure you are using the latest version of the [REST API](https://docs.github.com/en/rest/copilot/copilot-usage).
33+
34+
In order to connect we'll need to generate a token and link to your metrics data:
35+
1. Download and open the sample `GitHub Copilot - Telemetry Sample (DM).pbix` file.
36+
2. Determine if you'll be using the `Enterprise` or `Organization` URL.
37+
3. Follow the instructions below to generate a token with permissions to access the API:
38+
[REST API endpoints for GitHub Copilot usage metrics - GitHub Docs](https://docs.github.com/en/rest/copilot/copilot-usage)
39+
>**IMPORTANT: Do not share this token and ensure you follow you organizations security policies.**
40+
4. Open the **Power Query Editor** by right clicking the `GH Copilot - Details` and selecting **Edit query**.
41+
5. Select **Advanced editor**.
42+
![Image of Power Query Advanced Editor.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Advanced_editor.png)
43+
6. Replace the first 2 lines with following, ensure to replace <YOUR-TOKEN> and <ORG> with the values from step 1 and 2.
44+
45+
**Organization**
46+
```powerquery
47+
let
48+
// Replace <YOUR-TOKEN> and <ORG> with your actual token and org name.
49+
url = "https://api.github.com/orgs/<ORG>/copilot/usage",
50+
headers = [
51+
#"Accept" = "application/vnd.github+json",
52+
#"Authorization" = "Bearer <YOUR-TOKEN>",
53+
#"X-GitHub-Api-Version" = "2022-11-28"
54+
],
55+
Source = Json.Document(Web.Contents(url, [Headers=headers])),
56+
```
57+
**Enterprise**
58+
```powerquery
59+
let
60+
// Replace <YOUR-TOKEN> and <ENTERPRISE> with your actual token and enterprise name.
61+
url = "https://api.github.com/enterprises/<ENTERPRISE>/copilot/usage",
62+
headers = [
63+
#"Accept" = "application/vnd.github+json",
64+
#"Authorization" = "Bearer <YOUR-TOKEN>",
65+
#"X-GitHub-Api-Version" = "2022-11-28"
66+
],
67+
Source = Json.Document(Web.Contents(url, [Headers=headers])),
68+
```
69+
7. Your Power Query will look something like this:
70+
![Image of Power Query Advanced Editor.](https://github.com/jasonmoodie/pbi-4-ghcopilot/blob/main/assets/Advanced_editor_query.png)
71+
8. Click **OK** to close the editor and select `Anonymous` authentication if prompted.
72+
9. Repeat steps 4 and 8 for the `GH Copilot - Summary` **Source**.
73+
10. Click **Close and Apply** in the top-left of the **Power Query Editor**.
74+
11. On the **Report View** page click **Refresh** to load the new data into your dashboard.
75+
76+
## Publishing
77+
If you need help deploying or publishing this script, please see: [Publish README](/publish/README.md)
78+
79+
## Maintainers
80+
81+
@jasonmoodie, @Eldrick19
82+
83+
## Support
84+
85+
These are just files for you to download and use as you see fit. If you have questions about how to use them, please reach out to the maintainers, but we cannot guarantee a response with SLAs.
35.9 KB
Loading

assets/Sample_Metrics_PBI.png

158 KB
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)