Skip to content

Commit

Permalink
fix: Version still run if you have no telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFaucherre committed Aug 1, 2023
1 parent 7f0184b commit 7e7f1ee
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func newVersionCommand(config *settings.Config) *cobra.Command {
Short: "Display version information",
PersistentPreRun: func(_ *cobra.Command, _ []string) {
telemetryClient = create_telemetry.CreateTelemetry(config)
defer telemetryClient.Close()
_ = telemetryClient.Track(telemetry.CreateVersionEvent(version.Version))

opts.cfg.SkipUpdateCheck = true
},
PreRun: func(cmd *cobra.Command, args []string) {
Expand All @@ -34,11 +37,5 @@ func newVersionCommand(config *settings.Config) *cobra.Command {
Run: func(_ *cobra.Command, _ []string) {
fmt.Printf("%s+%s (%s)\n", version.Version, version.Commit, version.PackageManager())
},
PersistentPreRunE: func(_ *cobra.Command, _ []string) error {
if err := telemetryClient.Track(telemetry.CreateVersionEvent(version.Version)); err != nil {
return err
}
return telemetryClient.Close()
},
}
}

0 comments on commit 7e7f1ee

Please sign in to comment.