TemplateDAUs requires a tzOffset in hours. Use 0 for UTC, and TimezoneOffsetHour(time.Local) for the local timezone.
(ctx context.Context, templateID uuid.UUID, tzOffset int)
| 474 | // TemplateDAUs requires a tzOffset in hours. Use 0 for UTC, and TimezoneOffsetHour(time.Local) for the |
| 475 | // local timezone. |
| 476 | func (c *Client) TemplateDAUs(ctx context.Context, templateID uuid.UUID, tzOffset int) (*DAUsResponse, error) { |
| 477 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/templates/%s/daus", templateID), nil, DAURequest{ |
| 478 | TZHourOffset: tzOffset, |
| 479 | }.asRequestOption()) |
| 480 | if err != nil { |
| 481 | return nil, xerrors.Errorf("execute request: %w", err) |
| 482 | } |
| 483 | defer res.Body.Close() |
| 484 | |
| 485 | if res.StatusCode != http.StatusOK { |
| 486 | return nil, ReadBodyAsError(res) |
| 487 | } |
| 488 | |
| 489 | var resp DAUsResponse |
| 490 | return &resp, json.NewDecoder(res.Body).Decode(&resp) |
| 491 | } |
| 492 | |
| 493 | // AgentStatsReportRequest is a WebSocket request by coderd |
| 494 | // to the agent for stats. |