-
Notifications
You must be signed in to change notification settings - Fork 943
feat: Add anonymized telemetry to report product usage #2273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
17e9900
9ed5ecd
5293285
9a31eb3
e09a673
09fdade
9b690bd
b74d127
9e8b696
35aac55
67a567e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CREATE TABLE IF NOT EXISTS site_config ( | ||
CREATE TABLE IF NOT EXISTS site_configs ( | ||
key varchar(256) NOT NULL UNIQUE, | ||
value varchar(8192) NOT NULL | ||
); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
-- name: InsertDeploymentID :exec | ||
INSERT INTO site_config (key, value) VALUES ('deployment_id', $1); | ||
INSERT INTO site_configs (key, value) VALUES ('deployment_id', $1); | ||
|
||
-- name: GetDeploymentID :one | ||
SELECT value FROM site_config WHERE key = 'deployment_id'; | ||
SELECT value FROM site_configs WHERE key = 'deployment_id'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ import ( | |
type Options struct { | ||
Database database.Store | ||
Logger slog.Logger | ||
URL *url.URL | ||
// URL is an endpoint to direct telemetry towards! | ||
URL *url.URL | ||
|
||
DeploymentID string | ||
DevMode bool | ||
|
@@ -155,9 +156,13 @@ func (r *Reporter) runSnapshotter() { | |
case <-ticker.C: | ||
} | ||
// Skip the ticker on the first run to report instantly! | ||
first = false | ||
} | ||
first = false | ||
r.closeMutex.Lock() | ||
if r.isClosed() { | ||
r.closeMutex.Unlock() | ||
return | ||
} | ||
r.report() | ||
r.closeMutex.Unlock() | ||
} | ||
|
@@ -345,6 +350,8 @@ func (r *Reporter) createSnapshot() (*Snapshot, error) { | |
emailHashed := "" | ||
atSymbol := strings.LastIndex(dbUser.Email, "@") | ||
if atSymbol >= 0 { | ||
// We hash the beginning of the user to allow for indexing users | ||
// by email between deployments. | ||
hash := sha256.Sum256([]byte(dbUser.Email[:atSymbol])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This hash seems easily reversible tbh. What if we just used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want it to be traceable across deployments. We could use a greater hash, but I agree it's still crackable regardless. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 10000Ah yeah, I forgot about that. This seems reasonable then. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add a comment here for that |
||
emailHashed = fmt.Sprintf("%x%s", hash[:], dbUser.Email[atSymbol:]) | ||
} | ||
|
@@ -366,6 +373,7 @@ func (r *Reporter) createSnapshot() (*Snapshot, error) { | |
snapshot.Workspaces = make([]Workspace, 0, len(workspaces)) | ||
for _, dbWorkspace := range workspaces { | ||
snapshot.Workspaces = append(snapshot.Workspaces, Workspace{ | ||
ID: dbWorkspace.ID, | ||
OrganizationID: dbWorkspace.OrganizationID, | ||
OwnerID: dbWorkspace.OwnerID, | ||
TemplateID: dbWorkspace.TemplateID, | ||
|
@@ -475,10 +483,10 @@ type Snapshot struct { | |
|
||
// Deployment contains information about the host running Coder. | ||
type Deployment struct { | ||
ID string `json:"id" validate:"required"` | ||
ID string `json:"id"` | ||
Architecture string `json:"architecture"` | ||
Containerized bool `json:"containerized"` | ||
DevMode bool `json:"dev_mode" validate:"required"` | ||
DevMode bool `json:"dev_mode"` | ||
OSType string `json:"os_type"` | ||
OSFamily string `json:"os_family"` | ||
OSPlatform string `json:"os_platform"` | ||
|
@@ -487,7 +495,7 @@ type Deployment struct { | |
CPUCores int `json:"cpu_cores"` | ||
MemoryTotal uint64 `json:"memory_total"` | ||
MachineID string `json:"machine_id"` | ||
Version string `json:"version" validate:"required"` | ||
Version string `json:"version"` | ||
StartedAt time.Time `json:"started_at"` | ||
ShutdownAt *time.Time `json:"shutdown_at"` | ||
} | ||
|
@@ -537,6 +545,7 @@ type WorkspaceBuild struct { | |
} | ||
|
||
type Workspace struct { | ||
ID uuid.UUID `json:"id"` | ||
OrganizationID uuid.UUID `json:"organization_id"` | ||
OwnerID uuid.UUID `json:"owner_id"` | ||
TemplateID uuid.UUID `json:"template_id"` | ||
|
@@ -578,7 +587,7 @@ type ProvisionerJob struct { | |
} | ||
|
||
type ParameterSchema struct { | ||
ID uuid.UUID `json:"parameter_schema"` | ||
ID uuid.UUID `json:"id"` | ||
JobID uuid.UUID `json:"job_id"` | ||
Name string `json:"name"` | ||
ValidationCondition string `json:"validation_condition"` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
jsonb
as the value would make it much easier in the future to do migrations on structured data. We've needed to do this a couple times in v1.