Skip to content

On-demand report generation docs #56

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

Merged
merged 4 commits into from
Jul 9, 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
Binary file added docs/guides/images/api_keys.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions docs/guides/ondemand-reports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: On-demand Reports
sidebar_label: On-demand Reports (Beta)
description:
CodeRabbit offers a way to generate on-demand reports using a simple API request
sidebar_position: 5
---

```mdx-code-block
import ReportSchema from "@site/src/components/ReportSchema";
```

:::info

This feature is in beta

:::

CodeRabbit offers a way to generate on-demand reports using the [CodeRabbit API](https://api.coderabbit.ai/api/swagger/).
You will need an API Key to access the CodeRabbit API and generate an on-demand report.

## Create an API key

Sign in to your CodeRabbit account and navigate to the [**API Keys**](https://app.coderabbit.ai/settings/api-keys) page under 'Organization Settings' in the left sidebar.
Click on the **Create API Key** button and enter a name for the API Key.
Copy the API key, and keep it safe as it won't be visible again.

![API Keys](./images/api_keys.png)

## Generate an On-demand report

Once you have the API key, pass it in the `x-coderabbitai-api-key` header when calling the API:

```sh
curl -X 'POST' \
'https://api.coderabbit.ai/api/v1/report.generate' \
-H 'accept: application/json' \
-H 'x-coderabbitai-api-key: cr-xxxxxxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"from": "2024-05-01",
"to": "2024-05-15"
}'
```

Sample output:

```sh
[
{
"group": "Developer Activity",
"report": "*Developer Activity*:\n\n 🟢 **Update README.md** [#10](https://gitlab.com/master-group123/sub-group/project1/-/merge_requests/10)\n• Summary: The change updates the project description and modifies a section header for clearer instructions.\n• Last activity: 1 day ago, mergeable\n• Insights:\n - :magnifying_glass: @user2 Suggested updating the wording to make it clearer"
}
]
```


:::info

If you get a 401 UNAUTHORIZED error, check if you're passing the right API key in the `x-coderabbitai-api-key` header

:::

The on-demand report generation endpoints take in inputs as per the schema shown below:

```mdx-code-block
<ReportSchema />
```

[API Reference](https://api.coderabbit.ai/api/swagger/)
6 changes: 6 additions & 0 deletions src/components/ReportSchema.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Schema from "@site/static/schema/reporting.json";
import JSONSchemaViewer from "@theme/JSONSchemaViewer";

export default function Viewer(): JSX.Element {
return <JSONSchemaViewer schema={Schema} />;
}
93 changes: 93 additions & 0 deletions static/schema/reporting.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"type": "object",
"properties": {
"scheduleRange": {
"type": "string",
"enum": [
"Dates"
]
},
"from": {
"type": "string",
"format": "date"
},
"to": {
"type": "string",
"format": "date"
},
"prompt": {
"type": "string"
},
"promptTemplate": {
"type": "string",
"enum": [
"Daily Standup Report",
"Sprint Report",
"Release Notes",
"Custom"
]
},
"parameters": {
"type": "array",
"items": {
"type": "object",
"properties": {
"parameter": {
"type": "string",
"enum": [
"REPOSITORY",
"LABEL",
"TEAM",
"USER"
]
},
"operator": {
"type": "string",
"enum": [
"IN",
"ALL"
]
},
"values": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"parameter",
"operator",
"values"
],
"additionalProperties": false
}
},
"groupBy": {
"type": "string",
"enum": [
"NONE",
"REPOSITORY",
"LABEL",
"TEAM",
"USER"
]
},
"subgroupBy": {
"type": "string",
"enum": [
"NONE",
"REPOSITORY",
"LABEL",
"TEAM",
"USER"
]
}
},
"required": [
"from",
"to"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}