diff --git a/backup.go b/backup.go index 5c30dd7b6..8efbdf3fa 100644 --- a/backup.go +++ b/backup.go @@ -8,7 +8,6 @@ import ( "github.com/appscode/go/log" "github.com/appscode/kutil/meta" - "github.com/appscode/kutil/tools/analytics" cs "github.com/appscode/stash/client/typed/stash/v1alpha1" "github.com/appscode/stash/pkg/backup" "github.com/appscode/stash/pkg/util" @@ -43,10 +42,6 @@ func NewCmdBackup() *cobra.Command { kubeClient := kubernetes.NewForConfigOrDie(config) stashClient := cs.NewForConfigOrDie(config) - if meta.PossiblyInCluster() { - sendAnalytics(cmd, analytics.ClientID(kubeClient.CoreV1().Nodes())) - } - opt.NodeName = os.Getenv("NODE_NAME") if opt.NodeName == "" { log.Fatalln(`Missing ENV var "NODE_NAME"`) diff --git a/check.go b/check.go index acc7c8736..d3bd7b8e1 100644 --- a/check.go +++ b/check.go @@ -3,7 +3,6 @@ package cmds import ( "github.com/appscode/go/log" "github.com/appscode/kutil/meta" - "github.com/appscode/kutil/tools/analytics" cs "github.com/appscode/stash/client/typed/stash/v1alpha1" "github.com/appscode/stash/pkg/check" "github.com/spf13/cobra" @@ -32,10 +31,6 @@ func NewCmdCheck() *cobra.Command { kubeClient := kubernetes.NewForConfigOrDie(config) stashClient := cs.NewForConfigOrDie(config) - if meta.PossiblyInCluster() { - sendAnalytics(cmd, analytics.ClientID(kubeClient.CoreV1().Nodes())) - } - c := check.New(kubeClient, stashClient, opt) if err = c.Run(); err != nil { log.Fatal(err) diff --git a/recover.go b/recover.go index dd0f5fae4..64a18a91c 100644 --- a/recover.go +++ b/recover.go @@ -3,7 +3,6 @@ package cmds import ( "github.com/appscode/go/log" "github.com/appscode/kutil/meta" - "github.com/appscode/kutil/tools/analytics" cs "github.com/appscode/stash/client/typed/stash/v1alpha1" "github.com/appscode/stash/pkg/recovery" "github.com/spf13/cobra" @@ -30,10 +29,6 @@ func NewCmdRecover() *cobra.Command { kubeClient := kubernetes.NewForConfigOrDie(config) stashClient := cs.NewForConfigOrDie(config) - if meta.PossiblyInCluster() { - sendAnalytics(cmd, analytics.ClientID(kubeClient.CoreV1().Nodes())) - } - c := recovery.New(kubeClient, stashClient, meta.Namespace(), recoveryName) c.Run() }, diff --git a/root.go b/root.go index 1cb3a17d8..d667bfeec 100644 --- a/root.go +++ b/root.go @@ -5,9 +5,8 @@ import ( "log" "strings" - "github.com/appscode/go/analytics" v "github.com/appscode/go/version" - "github.com/appscode/kutil/meta" + "github.com/appscode/kutil/tools/analytics" "github.com/appscode/stash/client/scheme" "github.com/jpillora/go-ogle-analytics" "github.com/spf13/cobra" @@ -20,6 +19,9 @@ const ( ) func NewRootCmd() *cobra.Command { + var ( + enableAnalytics = true + ) var rootCmd = &cobra.Command{ Use: "stash", Short: `Stash by AppsCode - Backup your Kubernetes Volumes`, @@ -29,8 +31,12 @@ func NewRootCmd() *cobra.Command { c.Flags().VisitAll(func(flag *pflag.Flag) { log.Printf("FLAG: --%s=%q", flag.Name, flag.Value) }) - if !meta.PossiblyInCluster() { - sendAnalytics(c, analytics.ClientID()) + if enableAnalytics && gaTrackingCode != "" { + if client, err := ga.NewClient(gaTrackingCode); err == nil { + client.ClientID(analytics.ClientID()) + parts := strings.Split(c.CommandPath(), " ") + client.Send(ga.NewEvent(parts[0], strings.Join(parts[1:], "/")).Label(v.Version.Version)) + } } scheme.AddToScheme(clientsetscheme.Scheme) }, @@ -47,17 +53,3 @@ func NewRootCmd() *cobra.Command { rootCmd.AddCommand(NewCmdCheck()) return rootCmd } - -var ( - enableAnalytics = true -) - -func sendAnalytics(c *cobra.Command, clientID string) { - if enableAnalytics && gaTrackingCode != "" { - if client, err := ga.NewClient(gaTrackingCode); err == nil { - client.ClientID(clientID) - parts := strings.Split(c.CommandPath(), " ") - client.Send(ga.NewEvent(parts[0], strings.Join(parts[1:], "/")).Label(v.Version.Version)) - } - } -} diff --git a/run.go b/run.go index 70582453e..389508b79 100644 --- a/run.go +++ b/run.go @@ -8,8 +8,6 @@ import ( "github.com/appscode/go/log" stringz "github.com/appscode/go/strings" v "github.com/appscode/go/version" - "github.com/appscode/kutil/meta" - "github.com/appscode/kutil/tools/analytics" "github.com/appscode/pat" api "github.com/appscode/stash/apis/stash" cs "github.com/appscode/stash/client/typed/stash/v1alpha1" @@ -53,10 +51,6 @@ func NewCmdRun() *cobra.Command { stashClient := cs.NewForConfigOrDie(config) crdClient := crd_cs.NewForConfigOrDie(config) - if meta.PossiblyInCluster() { - sendAnalytics(cmd, analytics.ClientID(kubeClient.CoreV1().Nodes())) - } - // get kube api server version version, err := kubeClient.Discovery().ServerVersion() if err != nil {