mirror of
https://github.com/coder/coder.git
synced 2025-07-21 01:28:49 +00:00
feat(site): Add deployment-wide DAU chart (#5810)
This commit is contained in:
28
codersdk/insights.go
Normal file
28
codersdk/insights.go
Normal file
@ -0,0 +1,28 @@
|
||||
package codersdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
)
|
||||
|
||||
type DeploymentDAUsResponse struct {
|
||||
Entries []DAUEntry `json:"entries"`
|
||||
}
|
||||
|
||||
func (c *Client) DeploymentDAUs(ctx context.Context) (*DeploymentDAUsResponse, error) {
|
||||
res, err := c.Request(ctx, http.MethodGet, "/api/v2/insights/daus", nil)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("execute request: %w", err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return nil, readBodyAsError(res)
|
||||
}
|
||||
|
||||
var resp DeploymentDAUsResponse
|
||||
return &resp, json.NewDecoder(res.Body).Decode(&resp)
|
||||
}
|
Reference in New Issue
Block a user