Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Copilot usage metrics for Enterprise #734

Merged
merged 3 commits into from
Apr 29, 2024
Merged
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
71 changes: 71 additions & 0 deletions docs/copilot/usageMetricsForEnterprise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: Get a summary of Copilot usage for enterprise members
example: octokit.rest.copilot.usageMetricsForEnterprise({ enterprise })
route: GET /enterprises/{enterprise}/copilot/usage
scope: copilot
type: API method
---

# Get a summary of Copilot usage for enterprise members

**Note**: This endpoint is in beta and is subject to change.

You can use this endpoint to see a daily breakdown of aggregated usage metrics for Copilot completions and Copilot Chat in the IDE
for all users across organizations with access to Copilot within your enterprise, with a further breakdown of suggestions, acceptances,
and number of active users by editor and language for each day. See the response schema tab for detailed metrics definitions.

The response contains metrics for the prior 28 days. Usage metrics are processed once per day for the previous day,
and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics,
they must have telemetry enabled in their IDE.

Only the owners and billing managers of enterprises with a Copilot Business or Enterprise subscription can view Copilot usage
metrics for the enterprise.

OAuth app tokens and personal access tokens (classic) need the `copilot`, `manage_billing:copilot`, `admin:enterprise`, or `manage_billing:enterprise` scope to use this endpoint.

```js
octokit.rest.copilot.usageMetricsForEnterprise({
enterprise,
});
```

## Parameters

<table>
<thead>
<tr>
<th>name</th>
<th>required</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr><td>enterprise</td><td>yes</td><td>

The slug version of the enterprise name. You can also substitute this value with the enterprise id.

</td></tr>
<tr><td>since</td><td>no</td><td>

Show usage metrics since this date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format (`YYYY-MM-DDTHH:MM:SSZ`). Maximum value is 28 days ago.

</td></tr>
<tr><td>until</td><td>no</td><td>

Show usage metrics until this date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format (`YYYY-MM-DDTHH:MM:SSZ`) and should not preceed the `since` date if it is passed.

</td></tr>
<tr><td>page</td><td>no</td><td>

The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."

</td></tr>
<tr><td>per_page</td><td>no</td><td>

The number of days of metrics to display per page (max 28). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."

</td></tr>
</tbody>
</table>

See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/copilot/copilot-usage#get-a-summary-of-copilot-usage-for-enterprise-members).
71 changes: 71 additions & 0 deletions docs/copilot/usageMetricsForOrg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: Get a summary of Copilot usage for organization members
example: octokit.rest.copilot.usageMetricsForOrg({ org })
route: GET /orgs/{org}/copilot/usage
scope: copilot
type: API method
---

# Get a summary of Copilot usage for organization members

**Note**: This endpoint is in beta and is subject to change.

You can use this endpoint to see a daily breakdown of aggregated usage metrics for Copilot completions and Copilot Chat in the IDE
across an organization, with a further breakdown of suggestions, acceptances, and number of active users by editor and language for each day.
See the response schema tab for detailed metrics definitions.

The response contains metrics for the prior 28 days. Usage metrics are processed once per day for the previous day,
and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics,
they must have telemetry enabled in their IDE.

Copilot Business or Copilot Enterprise organization owners, and owners and billing managers of their parent enterprises, can view
Copilot usage metrics.

OAuth app tokens and personal access tokens (classic) need the `copilot`, `manage_billing:copilot`, `admin:org`, `admin:enterprise`, or `manage_billing:enterprise` scope to use this endpoint.

```js
octokit.rest.copilot.usageMetricsForOrg({
org,
});
```

## Parameters

<table>
<thead>
<tr>
<th>name</th>
<th>required</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr><td>org</td><td>yes</td><td>

The organization name. The name is not case sensitive.

</td></tr>
<tr><td>since</td><td>no</td><td>

Show usage metrics since this date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format (`YYYY-MM-DDTHH:MM:SSZ`). Maximum value is 28 days ago.

</td></tr>
<tr><td>until</td><td>no</td><td>

Show usage metrics until this date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format (`YYYY-MM-DDTHH:MM:SSZ`) and should not preceed the `since` date if it is passed.

</td></tr>
<tr><td>page</td><td>no</td><td>

The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."

</td></tr>
<tr><td>per_page</td><td>no</td><td>

The number of days of metrics to display per page (max 28). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."

</td></tr>
</tbody>
</table>

See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/copilot/copilot-usage#get-a-summary-of-copilot-usage-for-organization-members).
79 changes: 79 additions & 0 deletions docs/copilot/usageMetricsForTeam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
name: Get a summary of Copilot usage for a team
example: octokit.rest.copilot.usageMetricsForTeam({ org, team_slug })
route: GET /orgs/{org}/team/{team_slug}/copilot/usage
scope: copilot
type: API method
---

# Get a summary of Copilot usage for a team

**Note**: This endpoint is in beta and is subject to change.

You can use this endpoint to see a daily breakdown of aggregated usage metrics for Copilot completions and Copilot Chat in the IDE
for users within a team, with a further breakdown of suggestions, acceptances, and number of active users by editor and language for each day.
See the response schema tab for detailed metrics definitions.

The response contains metrics for the prior 28 days. Usage metrics are processed once per day for the previous day,
and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics,
they must have telemetry enabled in their IDE.

**Note**: This endpoint will only return results for a given day if the team had five or more members on that day.

Copilot Business or Copilot Enterprise organization owners for the organization that contains this team,
and owners and billing managers of their parent enterprises, can view Copilot usage metrics for a team.

OAuth app tokens and personal access tokens (classic) need the `copilot`, `manage_billing:copilot`, `admin:org`, `admin:enterprise`, or `manage_billing:enterprise` scope to use this endpoint.

```js
octokit.rest.copilot.usageMetricsForTeam({
org,
team_slug,
});
```

## Parameters

<table>
<thead>
<tr>
<th>name</th>
<th>required</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr><td>org</td><td>yes</td><td>

The organization name. The name is not case sensitive.

</td></tr>
<tr><td>team_slug</td><td>yes</td><td>

The slug of the team name.

</td></tr>
<tr><td>since</td><td>no</td><td>

Show usage metrics since this date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format (`YYYY-MM-DDTHH:MM:SSZ`). Maximum value is 28 days ago.

</td></tr>
<tr><td>until</td><td>no</td><td>

Show usage metrics until this date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format (`YYYY-MM-DDTHH:MM:SSZ`) and should not preceed the `since` date if it is passed.

</td></tr>
<tr><td>page</td><td>no</td><td>

The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."

</td></tr>
<tr><td>per_page</td><td>no</td><td>

The number of days of metrics to display per page (max 28). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."

</td></tr>
</tbody>
</table>

See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/copilot/copilot-usage#get-a-summary-of-copilot-usage-for-a-team).
1 change: 0 additions & 1 deletion docs/pulls/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ This endpoint supports the following custom media types. For more information, s
- **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
- **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
- **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
- **`application/vnd.github.diff`**: For more information, see "[git-diff](https://git-scm.com/docs/git-diff)" in the Git documentation. If a diff is corrupt, contact us through the [GitHub Support portal](https://support.github.com/). Include the repository name and pull request ID in your message.

```js
octokit.rest.pulls.create({
Expand Down
2 changes: 0 additions & 2 deletions docs/pulls/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ This endpoint supports the following custom media types. For more information, s
- **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
- **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
- **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
- **`application/vnd.github.diff`**: For more information, see "[git-diff](https://git-scm.com/docs/git-diff)" in the Git documentation. If a diff is corrupt, contact us through the [GitHub Support portal](https://support.github.com/). Include the repository name and pull request ID in your message.
- **`application/vnd.github.patch`**: For more information, see "[git-format-patch](https://git-scm.com/docs/git-format-patch)" in the Git documentation.

```js
octokit.rest.pulls.list({
Expand Down
1 change: 0 additions & 1 deletion docs/pulls/listCommits.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ This endpoint supports the following custom media types. For more information, s
- **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
- **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
- **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
- **`application/vnd.github.diff`**: For more information, see "[git-diff](https://git-scm.com/docs/git-diff)" in the Git documentation. If a diff is corrupt, contact us through the [GitHub Support portal](https://support.github.com/). Include the repository name and pull request ID in your message.

```js
octokit.rest.pulls.listCommits({
Expand Down
1 change: 0 additions & 1 deletion docs/pulls/listFiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ This endpoint supports the following custom media types. For more information, s
- **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
- **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
- **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
- **`application/vnd.github.diff`**: For more information, see "[git-diff](https://git-scm.com/docs/git-diff)" in the Git documentation. If a diff is corrupt, contact us through the [GitHub Support portal](https://support.github.com/). Include the repository name and pull request ID in your message.

```js
octokit.rest.pulls.listFiles({
Expand Down
1 change: 0 additions & 1 deletion docs/pulls/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ This endpoint supports the following custom media types. For more information, s
- **`application/vnd.github.text+json`**: Returns a text only representation of the markdown body. Response will include `body_text`.
- **`application/vnd.github.html+json`**: Returns HTML rendered from the body's markdown. Response will include `body_html`.
- **`application/vnd.github.full+json`**: Returns raw, text, and HTML representations. Response will include `body`, `body_text`, and `body_html`.
- **`application/vnd.github.diff`**: For more information, see "[git-diff](https://git-scm.com/docs/git-diff)" in the Git documentation. If a diff is corrupt, contact us through the [GitHub Support portal](https://support.github.com/). Include the repository name and pull request ID in your message.

```js
octokit.rest.pulls.update({
Expand Down
39 changes: 32 additions & 7 deletions docs/repos/createOrgRuleset.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Create an organization repository ruleset
example: octokit.rest.repos.createOrgRuleset({ org, name, enforcement, bypass_actors[].actor_id, bypass_actors[].actor_type, bypass_actors[].bypass_mode, rules[].type, rules[].parameters.update_allows_fetch_and_merge, rules[].parameters.required_deployment_environments, rules[].parameters.dismiss_stale_reviews_on_push, rules[].parameters.require_code_owner_review, rules[].parameters.require_last_push_approval, rules[].parameters.required_approving_review_count, rules[].parameters.required_review_thread_resolution, rules[].parameters.required_status_checks, rules[].parameters.required_status_checks[].context, rules[].parameters.strict_required_status_checks_policy, rules[].parameters.operator, rules[].parameters.pattern, rules[].parameters.workflows, rules[].parameters.workflows[].path, rules[].parameters.workflows[].repository_id })
example: octokit.rest.repos.createOrgRuleset({ org, name, enforcement, bypass_actors[].actor_type, bypass_actors[].bypass_mode, rules[].type, rules[].parameters.update_allows_fetch_and_merge, rules[].parameters.required_deployment_environments, rules[].parameters.dismiss_stale_reviews_on_push, rules[].parameters.require_code_owner_review, rules[].parameters.require_last_push_approval, rules[].parameters.required_approving_review_count, rules[].parameters.required_review_thread_resolution, rules[].parameters.required_status_checks, rules[].parameters.required_status_checks[].context, rules[].parameters.strict_required_status_checks_policy, rules[].parameters.operator, rules[].parameters.pattern, rules[].parameters.restricted_file_paths, rules[].parameters.max_file_path_length, rules[].parameters.restricted_file_extensions, rules[].parameters.max_file_size, rules[].parameters.workflows, rules[].parameters.workflows[].path, rules[].parameters.workflows[].repository_id })
route: POST /orgs/{org}/rulesets
scope: repos
type: API method
Expand All @@ -15,7 +15,6 @@ octokit.rest.repos.createOrgRuleset({
org,
name,
enforcement,
bypass_actors[].actor_id,
bypass_actors[].actor_type,
bypass_actors[].bypass_mode,
rules[].type,
Expand All @@ -31,6 +30,10 @@ rules[].parameters.required_status_checks[].context,
rules[].parameters.strict_required_status_checks_policy,
rules[].parameters.operator,
rules[].parameters.pattern,
rules[].parameters.restricted_file_paths,
rules[].parameters.max_file_path_length,
rules[].parameters.restricted_file_extensions,
rules[].parameters.max_file_size,
rules[].parameters.workflows,
rules[].parameters.workflows[].path,
rules[].parameters.workflows[].repository_id
Expand Down Expand Up @@ -60,7 +63,9 @@ The name of the ruleset.
</td></tr>
<tr><td>target</td><td>no</td><td>

The target of the ruleset.
The target of the ruleset

**Note**: The `push` target is in beta and is subject to change.

</td></tr>
<tr><td>enforcement</td><td>yes</td><td>
Expand All @@ -73,19 +78,19 @@ The enforcement level of the ruleset. `evaluate` allows admins to test rules bef
The actors that can bypass the rules in this ruleset

</td></tr>
<tr><td>bypass_actors[].actor_id</td><td>yes</td><td>
<tr><td>bypass_actors[].actor_id</td><td>no</td><td>

The ID of the actor that can bypass a ruleset. If `actor_type` is `OrganizationAdmin`, this should be `1`.
The ID of the actor that can bypass a ruleset. If `actor_type` is `OrganizationAdmin`, this should be `1`. If `actor_type` is `DeployKey`, this should be null. `OrganizationAdmin` is not applicable for personal repositories.

</td></tr>
<tr><td>bypass_actors[].actor_type</td><td>yes</td><td>

The type of actor that can bypass a ruleset
The type of actor that can bypass a ruleset.

</td></tr>
<tr><td>bypass_actors[].bypass_mode</td><td>yes</td><td>

When the specified actor can bypass the ruleset. `pull_request` means that an actor can only bypass rules on pull requests.
When the specified actor can bypass the ruleset. `pull_request` means that an actor can only bypass rules on pull requests. `pull_request` is not applicable for the `DeployKey` actor type.

</td></tr>
<tr><td>conditions</td><td>no</td><td>
Expand Down Expand Up @@ -178,6 +183,26 @@ The operator to use for matching.

The pattern to match with.

</td></tr>
<tr><td>rules[].parameters.restricted_file_paths</td><td>yes</td><td>

The file paths that are restricted from being pushed to the commit graph.

</td></tr>
<tr><td>rules[].parameters.max_file_path_length</td><td>yes</td><td>

The maximum amount of characters allowed in file paths

</td></tr>
<tr><td>rules[].parameters.restricted_file_extensions</td><td>yes</td><td>

The file extensions that are restricted from being pushed to the commit graph.

</td></tr>
<tr><td>rules[].parameters.max_file_size</td><td>yes</td><td>

The maximum file size allowed in megabytes. This limit does not apply to Git Large File Storage (Git LFS).

</td></tr>
<tr><td>rules[].parameters.workflows</td><td>yes</td><td>

Expand Down
Loading