Skip to content
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

cli: use the gitpod endpoint for analytics #19109

Merged
merged 5 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions components/local-app/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ var rootCmd = &cobra.Command{
}
cmd.SetContext(config.ToContext(context.Background(), cfg))

host := "https://gitpod.io"
telemetryEnabled := !telemetry.DoNotTrack()
telemetryEnabled = telemetryEnabled && cfg.Telemetry.Enabled
// For now we only enable telemetry on gitpod.io
if gpctx, err := cfg.GetActiveContext(); err == nil && gpctx != nil {
telemetryEnabled = telemetryEnabled && gpctx.Host.String() == "https://gitpod.io"
gpctx, err := cfg.GetActiveContext()
if err == nil && gpctx != nil {
host = gpctx.Host.String()
}
telemetry.Init(telemetryEnabled, cfg.Telemetry.Identity, constants.Version.String(), level)
telemetry.Init(telemetryEnabled, cfg.Telemetry.Identity, constants.Version.String(), level, host)
telemetry.RecordCommand(cmd)

if !isVersionCommand(cmd) {
Expand Down
7 changes: 4 additions & 3 deletions components/local-app/pkg/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

// Injected at build time
filiptronicek marked this conversation as resolved.
Show resolved Hide resolved
var segmentKey = "TgiJIVvFsBGwmxbnnt5NeeDaian9nr3n"
var segmentKey = "untrusted-dummy-key"

var opts struct {
Enabled bool
Expand All @@ -36,7 +36,7 @@ var opts struct {
}

// Init initializes the telemetry
func Init(enabled bool, identity, version string, logLevel slog.Level) {
func Init(enabled bool, identity, version string, logLevel slog.Level, host string) {
opts.Enabled = enabled
if !enabled {
return
Expand All @@ -56,7 +56,8 @@ func Init(enabled bool, identity, version string, logLevel slog.Level) {
logger = segment.StdLogger(log)
}
opts.client, _ = segment.NewWithConfig(segmentKey, segment.Config{
Logger: logger,
Logger: logger,
Endpoint: host + "/analytics",
})
}
}
Expand Down
Loading