@@ -19,6 +19,7 @@ import (
1919"strings"
2020"sync"
2121"time"
22+ "unicode/utf8"
2223
2324"github.com/elastic/go-sysinfo"
2425"github.com/google/uuid"
@@ -730,6 +731,10 @@ func (r *remoteReporter) createSnapshot() (*Snapshot, error) {
730731}
731732return nil
732733})
734+ eg .Go (func ()error {
735+ // TODO: we need a way to list tasks.
736+ return nil
737+ })
733738
734739err := eg .Wait ()
735740if err != nil {
@@ -914,6 +919,22 @@ func ConvertWorkspaceResourceMetadata(metadata database.WorkspaceResourceMetadat
914919}
915920}
916921
922+ // ConvertTask anonymizes a Task.
923+ func ConvertTask (task database.Task )Task {
924+ return Task {
925+ ID :task .ID ,
926+ OrganizationID :task .OrganizationID ,
927+ OwnerID :task .OwnerID ,
928+ Name :task .Name ,
929+ WorkspaceID :task .WorkspaceID ,
930+ TemplateVersionID :task .TemplateVersionID ,
931+ PromptHash :fmt .Sprintf ("%x" ,sha256 .New ().Sum ([]byte (task .Prompt ))),
932+ PromptLength :utf8 .RuneCountInString (task .Prompt ),
933+ CreatedAt :task .CreatedAt ,
934+ Status :string (task .Status ),
935+ }
936+ }
937+
917938func shouldSendRawModuleSource (source string )bool {
918939return strings .Contains (source ,"registry.coder.com" )
919940}
@@ -1205,6 +1226,7 @@ type Snapshot struct {
12051226Workspaces []Workspace `json:"workspaces"`
12061227NetworkEvents []NetworkEvent `json:"network_events"`
12071228Organizations []Organization `json:"organizations"`
1229+ Tasks []Task `json:"tasks"`
12081230TelemetryItems []TelemetryItem `json:"telemetry_items"`
12091231UserTailnetConnections []UserTailnetConnection `json:"user_tailnet_connections"`
12101232PrebuiltWorkspaces []PrebuiltWorkspace `json:"prebuilt_workspaces"`
@@ -1753,6 +1775,19 @@ type Organization struct {
17531775CreatedAt time.Time `json:"created_at"`
17541776}
17551777
1778+ type Task struct {
1779+ ID uuid.UUID `json:"id"`
1780+ OrganizationID uuid.UUID `json:"organization_id"`
1781+ OwnerID uuid.UUID `json:"owner_id"`
1782+ Name string `json:"name"`
1783+ WorkspaceID uuid.NullUUID `json:"workspace_id"`
1784+ TemplateVersionID uuid.UUID `json:"template_version_id"`
1785+ PromptHash string `json:"hashed_prompt"`
1786+ PromptLength int `json:"prompt_length"`
1787+ CreatedAt time.Time `json:"created_at"`
1788+ Status string `json:"status"`
1789+ }
1790+
17561791type telemetryItemKey string
17571792
17581793// The comment below gets rid of the warning that the name "TelemetryItemKey" has