Skip to content

Commit

Permalink
Remove analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
neuralsandwich committed May 27, 2020
1 parent 9787e7c commit ee876d3
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 116 deletions.
14 changes: 1 addition & 13 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
log "github.com/sirupsen/logrus"

"github.com/99designs/keyring"
analytics "github.com/segmentio/analytics-go"
"github.com/segmentio/aws-okta/lib"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -44,17 +43,6 @@ func add(cmd *cobra.Command, args []string) error {
log.Fatal(err)
}

if analyticsEnabled && analyticsClient != nil {
analyticsClient.Enqueue(analytics.Track{
UserId: username,
Event: "Ran Command",
Properties: analytics.NewProperties().
Set("backend", backend).
Set("aws-okta-version", version).
Set("command", "add"),
})
}

// Ask Okta organization details if not given in command line argument
if oktaDomain == "" {
organization, err = lib.Prompt("Okta organization", false)
Expand Down Expand Up @@ -91,7 +79,7 @@ func add(cmd *cobra.Command, args []string) error {
return err
}
}

if oktaAccountName == "" {
oktaAccountName = "okta-creds"
} else {
Expand Down
13 changes: 0 additions & 13 deletions cmd/cred-process.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

"github.com/99designs/keyring"
analytics "github.com/segmentio/analytics-go"
"github.com/segmentio/aws-okta/lib"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -92,18 +91,6 @@ func credProcessRun(cmd *cobra.Command, args []string) error {
return err
}

if analyticsEnabled && analyticsClient != nil {
analyticsClient.Enqueue(analytics.Track{
UserId: username,
Event: "Ran Command",
Properties: analytics.NewProperties().
Set("backend", backend).
Set("aws-okta-version", version).
Set("profile", profile).
Set("command", "cred-process"),
})
}

opts.SessionCacheSingleItem = flagSessionCacheSingleItem

p, err := lib.NewProvider(kr, profile, opts)
Expand Down
13 changes: 0 additions & 13 deletions cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/99designs/keyring"
"github.com/alessio/shellescape"
analytics "github.com/segmentio/analytics-go"
"github.com/segmentio/aws-okta/lib"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -80,18 +79,6 @@ func envRun(cmd *cobra.Command, args []string) error {
return err
}

if analyticsEnabled && analyticsClient != nil {
analyticsClient.Enqueue(analytics.Track{
UserId: username,
Event: "Ran Command",
Properties: analytics.NewProperties().
Set("backend", backend).
Set("aws-okta-version", version).
Set("profile", profile).
Set("command", "env"),
})
}

opts.SessionCacheSingleItem = flagSessionCacheSingleItem

p, err := lib.NewProvider(kr, profile, opts)
Expand Down
13 changes: 0 additions & 13 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"time"

"github.com/99designs/keyring"
analytics "github.com/segmentio/analytics-go"
"github.com/segmentio/aws-okta/lib"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -181,18 +180,6 @@ func execRun(cmd *cobra.Command, args []string) error {
return err
}

if analyticsEnabled && analyticsClient != nil {
analyticsClient.Enqueue(analytics.Track{
UserId: username,
Event: "Ran Command",
Properties: analytics.NewProperties().
Set("backend", backend).
Set("aws-okta-version", version).
Set("profile", profile).
Set("command", "exec"),
})
}

opts.SessionCacheSingleItem = flagSessionCacheSingleItem

p, err := lib.NewProvider(kr, profile, opts)
Expand Down
12 changes: 0 additions & 12 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"sort"
"text/tabwriter"

analytics "github.com/segmentio/analytics-go"
"github.com/segmentio/aws-okta/lib"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -68,16 +67,5 @@ func listRun(cmd *cobra.Command, args []string) error {
}
w.Flush()

if analyticsEnabled && analyticsClient != nil {
analyticsClient.Enqueue(analytics.Track{
UserId: username,
Event: "Listed Profiles",
Properties: analytics.NewProperties().
Set("backend", backend).
Set("aws-okta-version", version).
Set("profile-count", len(profiles)).
Set("command", "list"),
})
}
return nil
}
13 changes: 0 additions & 13 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"github.com/99designs/keyring"
analytics "github.com/segmentio/analytics-go"
"github.com/segmentio/aws-okta/lib"
"github.com/skratchdot/open-golang/open"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -101,18 +100,6 @@ func loginRun(cmd *cobra.Command, args []string) error {
return err
}

if analyticsEnabled && analyticsClient != nil {
analyticsClient.Enqueue(analytics.Track{
UserId: username,
Event: "Ran Command",
Properties: analytics.NewProperties().
Set("backend", backend).
Set("aws-okta-version", version).
Set("profile", profile).
Set("command", "login"),
})
}

opts.SessionCacheSingleItem = flagSessionCacheSingleItem

p, err := lib.NewProvider(kr, profile, opts)
Expand Down
26 changes: 0 additions & 26 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"

"github.com/99designs/keyring"
analytics "github.com/segmentio/analytics-go"
"github.com/segmentio/aws-okta/lib"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -35,9 +34,6 @@ var (
mfaConfig lib.MFAConfig
debug bool
version string
analyticsWriteKey string
analyticsEnabled bool
analyticsClient analytics.Client
username string
flagSessionCacheSingleItem bool
)
Expand All @@ -51,15 +47,12 @@ var RootCmd = &cobra.Command{
SilenceUsage: true,
SilenceErrors: true,
PersistentPreRunE: prerunE,
PersistentPostRun: postrun,
}

// Execute adds all child commands to the root command sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute(vers string, writeKey string) {
version = vers
analyticsWriteKey = writeKey
analyticsEnabled = analyticsWriteKey != ""
if err := RootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
switch err {
Expand Down Expand Up @@ -94,28 +87,9 @@ func prerunE(cmd *cobra.Command, args []string) error {
}
}

if analyticsEnabled {
// set up analytics client
analyticsClient, _ = analytics.NewWithConfig(analyticsWriteKey, analytics.Config{
BatchSize: 1,
})

usr := os.Getenv("USER")
analyticsClient.Enqueue(analytics.Identify{
UserId: usr,
Traits: analytics.NewTraits().
Set("aws-okta-version", version),
})
}
return nil
}

func postrun(cmd *cobra.Command, args []string) {
if analyticsEnabled && analyticsClient != nil {
analyticsClient.Close()
}
}

func init() {
backendsAvailable := []string{}
for _, backendType := range keyring.AvailableBackends() {
Expand Down
13 changes: 0 additions & 13 deletions cmd/write-to-credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"time"

"github.com/99designs/keyring"
analytics "github.com/segmentio/analytics-go"
"github.com/segmentio/aws-okta/lib"
"github.com/spf13/cobra"
ini "gopkg.in/ini.v1"
Expand Down Expand Up @@ -92,18 +91,6 @@ func writeToCredentialsRun(cmd *cobra.Command, args []string) error {
return err
}

if analyticsEnabled && analyticsClient != nil {
analyticsClient.Enqueue(analytics.Track{
UserId: username,
Event: "Ran Command",
Properties: analytics.NewProperties().
Set("backend", backend).
Set("aws-okta-version", version).
Set("profile", profile).
Set("command", "writeToCredentials"),
})
}

opts.SessionCacheSingleItem = flagSessionCacheSingleItem

p, err := lib.NewProvider(kr, profile, opts)
Expand Down

0 comments on commit ee876d3

Please sign in to comment.