Skip to content

Commit

Permalink
feat: add notrack global flag to avoid sending events to posthog
Browse files Browse the repository at this point in the history
  • Loading branch information
acarranoqovery committed Feb 26, 2025
1 parent 04a27b1 commit 00a796e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package cmd
import (
// "github.com/getsentry/sentry-go"
// "github.com/qovery/qovery-cli/pkg"
"os"

"github.com/qovery/qovery-cli/utils"
"github.com/qovery/qovery-cli/variable"
"github.com/spf13/cobra"
"os"
// "time"
)

Expand All @@ -26,6 +27,7 @@ func Execute() {
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().BoolVar(&variable.Verbose, "verbose", false, "Verbose output")
rootCmd.PersistentFlags().BoolVar(&variable.NoTrack, "notrack", false, "Do not track the command execution in Qovery telemetry")
}

func initConfig() {
Expand Down
7 changes: 7 additions & 0 deletions utils/posthog.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/posthog/posthog-go"
"github.com/qovery/qovery-cli/variable"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
Expand All @@ -15,6 +16,12 @@ const EndOfExecutionEventName = "cli-command-execution-end"
const EndOfExecutionErrorEventName = "cli-command-execution-error"

func Capture(command *cobra.Command) {

// Do not track the command execution in Qovery telemetry
if flag := command.Flags().Lookup(variable.NoTrackFlag); flag != nil {
return
}

CaptureWithEvent(command, DefaultEventName)
}

Expand Down
4 changes: 4 additions & 0 deletions variable/notrack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package variable

var NoTrack bool
var NoTrackFlag = "notrack"

0 comments on commit 00a796e

Please sign in to comment.