diff --git a/cmd/atlas/atlas.go b/cmd/atlas/atlas.go index f2af1c9707..8a32aa543d 100644 --- a/cmd/atlas/atlas.go +++ b/cmd/atlas/atlas.go @@ -32,7 +32,11 @@ import ( func Execute() { ctx := telemetry.NewContext() rootCmd := atlas.Builder() - if err := rootCmd.ExecuteContext(ctx); err != nil { + if cmd, err := rootCmd.ExecuteContextC(ctx); err != nil { + if !telemetry.StartedTrackingCommand() { + telemetry.StartTrackingCommand(cmd, os.Args[1:]) + } + telemetry.FinishTrackingCommand(telemetry.TrackOptions{ Err: err, }) diff --git a/internal/telemetry/command.go b/internal/telemetry/command.go index 173ff5892b..fd7bd2a989 100644 --- a/internal/telemetry/command.go +++ b/internal/telemetry/command.go @@ -27,6 +27,10 @@ type TrackOptions struct { var currentTracker *tracker +func StartedTrackingCommand() bool { + return currentTracker != nil +} + func StartTrackingCommand(cmd *cobra.Command, args []string) { if !config.TelemetryEnabled() { return