Skip to content

Commit

Permalink
telemetry: add devspace analytics (#2380)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcurtis authored Oct 24, 2024
1 parent cab9ca6 commit 5c665e5
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions internal/telemetry/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func newTrackMessage(name string, meta Metadata) *segment.Track {
dur = time.Since(meta.EventStart)
}
uid := userID()
return &segment.Track{
track := &segment.Track{
MessageId: newEventID(),
Type: "track",
// Only set anonymous ID if user ID is not set. Otherwise segment will
Expand All @@ -66,17 +66,30 @@ func newTrackMessage(name string, meta Metadata) *segment.Track {
},
},
Properties: segment.Properties{
"cloud_region": meta.CloudRegion,
"command": meta.Command,
"command_args": meta.CommandFlags,
"duration": dur.Milliseconds(),
"nix_version": nixVersion,
"org_id": orgID(),
"packages": meta.Packages,
"shell": os.Getenv(envir.Shell),
"shell_access": shellAccess(),
"nix_version": nixVersion,
},
}

// Property keys match the API events (search "Devspace Created").
insertEnv := func(envKey, propKey string) {
v, ok := os.LookupEnv(envKey)
if ok {
track.Properties[propKey] = v
}
}
insertEnv("_JETIFY_SANDBOX_ID", "devspace")
insertEnv("_JETIFY_GH_REPO", "repo")
insertEnv("_JETIFY_GIT_REF", "ref")
insertEnv("_JETIFY_GIT_SUBDIR", "subdir")

return track
}

// bufferSegmentMessage buffers a Segment message to disk so that Report can
Expand Down

0 comments on commit 5c665e5

Please sign in to comment.