File tree Expand file tree Collapse file tree 5 files changed +11020
-13
lines changed Expand file tree Collapse file tree 5 files changed +11020
-13
lines changed Original file line number Diff line number Diff line change
1
+ VUE_APP_MOCKED_DATA = true
2
+
1
3
VUE_APP_GITHUB_ORG =
4
+
2
5
VUE_APP_GITHUB_TOKEN =
Original file line number Diff line number Diff line change @@ -54,7 +54,13 @@ Your organization must be enrolled in the GitHub Copilot API private alpha.
54
54
## Setup instructions
55
55
56
56
- Instructions on how to authenticate are provided in the API documentation - available if you have access to the private alpha.
57
- - Edit the .env file in the root directory of the project and add the following variables:
57
+
58
+ ### .env file setup
59
+ - To utilize mocked data stored in a JSON file, simply set the following boolean environment variable to true:
60
+ ```
61
+ VUE_APP_MOCKED_DATA=true
62
+ ```
63
+ - To access Copilot metrics through the API, update your configuration by adding the following variables:
58
64
59
65
```
60
66
VUE_APP_GITHUB_ORG=
Original file line number Diff line number Diff line change 5
5
//Return the response from the API
6
6
7
7
import axios from "axios" ;
8
+
8
9
import { Metrics } from "../model/MetricsData" ;
10
+ import data from '../assets/copilot_metrics_response_sample.json' ;
9
11
10
12
export const getGitHubCopilotMetricsApi = async ( ) : Promise < Metrics [ ] > => {
11
- const response = await axios . get (
12
- `https://api.github.com/orgs/${ process . env . VUE_APP_GITHUB_ORG } /copilot/usage` ,
13
- {
14
- headers : {
15
- Accept : "application/vnd.github+json" ,
16
- Authorization : `Bearer ${ process . env . VUE_APP_GITHUB_TOKEN } ` ,
17
- "X-GitHub-Api-Version" : "2022-11-28" ,
18
- } ,
19
- }
20
- ) ;
13
+
14
+ let response ;
15
+ let metricsData ;
21
16
22
- // Map the response data to an array of Metrics objects
23
- const metricsData = response . data . map ( ( item : any ) => new Metrics ( item ) ) ;
17
+ if ( process . env . VUE_APP_MOCKED_DATA === "true" ) {
18
+ response = data ;
19
+ metricsData = response . map ( ( item : any ) => new Metrics ( item ) ) ;
20
+ } else {
21
+ response = await axios . get (
22
+ `https://api.github.com/orgs/${ process . env . VUE_APP_GITHUB_ORG } /copilot/usage` ,
23
+ {
24
+ headers : {
25
+ Accept : "application/vnd.github+json" ,
26
+ Authorization : `Bearer ${ process . env . VUE_APP_GITHUB_TOKEN } ` ,
27
+ "X-GitHub-Api-Version" : "2022-11-28" ,
28
+ } ,
29
+ }
30
+ ) ;
24
31
32
+ metricsData = response . data . map ( ( item : any ) => new Metrics ( item ) ) ;
33
+ }
25
34
return metricsData ;
26
35
} ;
You can’t perform that action at this time.
0 commit comments