Skip to content

Commit 6bf553d

Browse files
calling-telemetry-api-post-valid-login
1 parent ab57cb2 commit 6bf553d

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

internal/commands/auth.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type ClientCreated struct {
3939
Secret string `json:"secret"`
4040
}
4141

42-
func NewAuthCommand(authWrapper wrappers.AuthWrapper) *cobra.Command {
42+
func NewAuthCommand(authWrapper wrappers.AuthWrapper, telemetryWrapper wrappers.TelemetryWrapper) *cobra.Command {
4343
authCmd := &cobra.Command{
4444
Use: "auth",
4545
Short: "Validate authentication and create OAuth2 credentials",
@@ -111,19 +111,25 @@ func NewAuthCommand(authWrapper wrappers.AuthWrapper) *cobra.Command {
111111
`,
112112
),
113113
},
114-
RunE: validLogin(),
114+
RunE: validLogin(telemetryWrapper),
115115
}
116116
authCmd.AddCommand(createClientCmd, validLoginCmd)
117117
return authCmd
118118
}
119119

120-
func validLogin() func(cmd *cobra.Command, args []string) error {
120+
func validLogin(telemetryWrapper wrappers.TelemetryWrapper) func(cmd *cobra.Command, args []string) error {
121121
return func(cmd *cobra.Command, args []string) error {
122122
defer func() {
123123
logger.PrintIfVerbose("Calling GetUniqueId func")
124124
uniqueID := wrappers.GetUniqueID()
125125
if uniqueID != "" {
126126
logger.PrintIfVerbose("Set unique id: " + uniqueID)
127+
err := telemetryWrapper.SendAIDataToLog(&wrappers.DataForAITelemetry{
128+
UniqueID: uniqueID,
129+
})
130+
if err != nil {
131+
logger.PrintIfVerbose("Failed to send telemetry data: " + err.Error())
132+
}
127133
}
128134
}()
129135
clientID := viper.GetString(params.AccessKeyIDConfigKey)

internal/commands/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func NewAstCLI(
205205
)
206206

207207
versionCmd := util.NewVersionCommand()
208-
authCmd := NewAuthCommand(authWrapper)
208+
authCmd := NewAuthCommand(authWrapper, telemetryWrapper)
209209
utilsCmd := util.NewUtilsCommand(
210210
gitHubWrapper,
211211
azureWrapper,

internal/wrappers/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ func GetUniqueID() string {
10281028
if !ok {
10291029
continue
10301030
}
1031-
if strings.EqualFold(engineStr, "Checkmarx Developer Assist") {
1031+
if strings.EqualFold(engineStr, "Checkmarx One Assist") {
10321032
isAllowed = true
10331033
break
10341034
}

0 commit comments

Comments
 (0)