@@ -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,16 @@ func (r *remoteReporter) createSnapshot() (*Snapshot, error) {
730731}
731732return nil
732733})
734+ eg .Go (func ()error {
735+ dbTasks ,err := r .options .Database .ListTasks (ctx , database.ListTasksParams {})
736+ if err != nil {
737+ return err
738+ }
739+ for _ ,dbTask := range dbTasks {
740+ snapshot .Tasks = append (snapshot .Tasks ,ConvertTask (dbTask ))
741+ }
742+ return nil
743+ })
733744
734745err := eg .Wait ()
735746if err != nil {
@@ -914,6 +925,22 @@ func ConvertWorkspaceResourceMetadata(metadata database.WorkspaceResourceMetadat
914925}
915926}
916927
928+ // ConvertTask anonymizes a Task.
929+ func ConvertTask (task database.Task )Task {
930+ return Task {
931+ ID :task .ID ,
932+ OrganizationID :task .OrganizationID ,
933+ OwnerID :task .OwnerID ,
934+ Name :task .Name ,
935+ WorkspaceID :task .WorkspaceID ,
936+ TemplateVersionID :task .TemplateVersionID ,
937+ PromptHash :fmt .Sprintf ("%x" ,sha256 .New ().Sum ([]byte (task .Prompt ))),
938+ PromptLength :utf8 .RuneCountInString (task .Prompt ),
939+ CreatedAt :task .CreatedAt ,
940+ Status :string (task .Status ),
941+ }
942+ }
943+
917944func shouldSendRawModuleSource (source string )bool {
918945return strings .Contains (source ,"registry.coder.com" )
919946}
@@ -1205,6 +1232,7 @@ type Snapshot struct {
12051232Workspaces []Workspace `json:"workspaces"`
12061233NetworkEvents []NetworkEvent `json:"network_events"`
12071234Organizations []Organization `json:"organizations"`
1235+ Tasks []Task `json:"tasks"`
12081236TelemetryItems []TelemetryItem `json:"telemetry_items"`
12091237UserTailnetConnections []UserTailnetConnection `json:"user_tailnet_connections"`
12101238PrebuiltWorkspaces []PrebuiltWorkspace `json:"prebuilt_workspaces"`
@@ -1753,6 +1781,19 @@ type Organization struct {
17531781CreatedAt time.Time `json:"created_at"`
17541782}
17551783
1784+ type Task struct {
1785+ ID uuid.UUID `json:"id"`
1786+ OrganizationID uuid.UUID `json:"organization_id"`
1787+ OwnerID uuid.UUID `json:"owner_id"`
1788+ Name string `json:"name"`
1789+ WorkspaceID uuid.NullUUID `json:"workspace_id"`
1790+ TemplateVersionID uuid.UUID `json:"template_version_id"`
1791+ PromptHash string `json:"hashed_prompt"`
1792+ PromptLength int `json:"prompt_length"`
1793+ CreatedAt time.Time `json:"created_at"`
1794+ Status string `json:"status"`
1795+ }
1796+
17561797type telemetryItemKey string
17571798
17581799// The comment below gets rid of the warning that the name "TelemetryItemKey" has