Skip to content

Commit

Permalink
chore: Remove analytics for login (#372)
Browse files Browse the repository at this point in the history
Remove analytics for login
  • Loading branch information
dbolson authored Jul 8, 2024
1 parent a14c11c commit 6487e85
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
33 changes: 2 additions & 31 deletions cmd/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,21 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

cmdAnalytics "github.com/launchdarkly/ldcli/cmd/analytics"
"github.com/launchdarkly/ldcli/cmd/cliflags"
configcmd "github.com/launchdarkly/ldcli/cmd/config"
"github.com/launchdarkly/ldcli/internal/analytics"
"github.com/launchdarkly/ldcli/internal/config"
"github.com/launchdarkly/ldcli/internal/login"
"github.com/launchdarkly/ldcli/internal/resources"
)

func NewLoginCmd(
analyticsTrackerFn analytics.TrackerFn,
client resources.UnauthenticatedClient,
) *cobra.Command {
func NewLoginCmd(client resources.UnauthenticatedClient) *cobra.Command {
cmd := cobra.Command{
Long: "",
PreRun: func(cmd *cobra.Command, args []string) {
analyticsTrackerFn(
viper.GetString(cliflags.AccessTokenFlag),
viper.GetString(cliflags.BaseURIFlag),
viper.GetBool(cliflags.AnalyticsOptOut),
).SendCommandRunEvent(cmdAnalytics.CmdRunEventProperties(cmd, "login", nil))
},
Long: "",
RunE: run(client),
Short: "Log in to your LaunchDarkly account to set up the CLI",
Use: "login",
}

helpFun := cmd.HelpFunc()
cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
analyticsTrackerFn(
viper.GetString(cliflags.AccessTokenFlag),
viper.GetString(cliflags.BaseURIFlag),
viper.GetBool(cliflags.AnalyticsOptOut),
).SendCommandRunEvent(cmdAnalytics.CmdRunEventProperties(
cmd,
"login",
map[string]interface{}{
"action": "help",
},
))

helpFun(cmd, args)
})

return &cmd
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func NewRootCommand(
configCmd := configcmd.NewConfigCmd(configService, analyticsTrackerFn)
cmd.AddCommand(configCmd.Cmd())
cmd.AddCommand(NewQuickStartCmd(analyticsTrackerFn, clients.EnvironmentsClient, clients.FlagsClient))
cmd.AddCommand(logincmd.NewLoginCmd(analyticsTrackerFn, resources.NewClient(version)))
cmd.AddCommand(logincmd.NewLoginCmd(resources.NewClient(version)))
cmd.AddCommand(resourcecmd.NewResourcesCmd())
resourcecmd.AddAllResourceCmds(cmd, clients.ResourcesClient, analyticsTrackerFn)

Expand Down
2 changes: 1 addition & 1 deletion internal/analytics/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ func (c *Client) sendEvent(eventName string, properties map[string]interface{})
c.wg.Done()
return
}
resp.Body.Close()

_, err = io.ReadAll(resp.Body)
if err != nil { //nolint:staticcheck
// TODO: log error
}
resp.Body.Close()
c.wg.Done()
}()
}
Expand Down

0 comments on commit 6487e85

Please sign in to comment.