feat: expose insights into user activity (#9807)

This commit is contained in:
Marcin Tojek
2023-09-26 18:42:16 +02:00
committed by GitHub
parent 1f4335733c
commit 4c3b579f58
38 changed files with 2148 additions and 70 deletions
+44
View File
@@ -115,6 +115,50 @@ curl -X GET http://coder-server:8080/api/v2/insights/templates \
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Get insights about user activity
### Code samples
```shell
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/insights/user-activity \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```
`GET /insights/user-activity`
### Example responses
> 200 Response
```json
{
"report": {
"end_time": "2019-08-24T14:15:22Z",
"start_time": "2019-08-24T14:15:22Z",
"template_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"],
"users": [
{
"avatar_url": "http://example.com",
"seconds": 80500,
"template_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"],
"user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
"username": "string"
}
]
}
}
```
### Responses
| Status | Meaning | Description | Schema |
| ------ | ------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------------------- |
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.UserActivityInsightsResponse](schemas.md#codersdkuseractivityinsightsresponse) |
To perform this operation, you must be authenticated. [Learn more](authentication.md).
## Get insights about user latency
### Code samples
+77
View File
@@ -5183,6 +5183,83 @@ If the schedule is empty, the user will be updated to use the default schedule.|
| `status` | `active` |
| `status` | `suspended` |
## codersdk.UserActivity
```json
{
"avatar_url": "http://example.com",
"seconds": 80500,
"template_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"],
"user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
"username": "string"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
| -------------- | --------------- | -------- | ------------ | ----------- |
| `avatar_url` | string | false | | |
| `seconds` | integer | false | | |
| `template_ids` | array of string | false | | |
| `user_id` | string | false | | |
| `username` | string | false | | |
## codersdk.UserActivityInsightsReport
```json
{
"end_time": "2019-08-24T14:15:22Z",
"start_time": "2019-08-24T14:15:22Z",
"template_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"],
"users": [
{
"avatar_url": "http://example.com",
"seconds": 80500,
"template_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"],
"user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
"username": "string"
}
]
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
| -------------- | ------------------------------------------------------- | -------- | ------------ | ----------- |
| `end_time` | string | false | | |
| `start_time` | string | false | | |
| `template_ids` | array of string | false | | |
| `users` | array of [codersdk.UserActivity](#codersdkuseractivity) | false | | |
## codersdk.UserActivityInsightsResponse
```json
{
"report": {
"end_time": "2019-08-24T14:15:22Z",
"start_time": "2019-08-24T14:15:22Z",
"template_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"],
"users": [
{
"avatar_url": "http://example.com",
"seconds": 80500,
"template_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"],
"user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
"username": "string"
}
]
}
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
| -------- | -------------------------------------------------------------------------- | -------- | ------------ | ----------- |
| `report` | [codersdk.UserActivityInsightsReport](#codersdkuseractivityinsightsreport) | false | | |
## codersdk.UserLatency
```json