Skip to content

Commit

Permalink
always send diags with authenticated client
Browse files Browse the repository at this point in the history
  • Loading branch information
gandarez committed Aug 11, 2023
1 parent 31f8e1a commit c274a17
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"bytes"
"errors"
"fmt"
"io"
"os"
Expand All @@ -23,7 +22,6 @@ import (
"github.com/wakatime/wakatime-cli/cmd/params"
"github.com/wakatime/wakatime-cli/cmd/today"
"github.com/wakatime/wakatime-cli/cmd/todaygoal"
"github.com/wakatime/wakatime-cli/pkg/api"
"github.com/wakatime/wakatime-cli/pkg/diagnostic"
"github.com/wakatime/wakatime-cli/pkg/exitcode"
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down Expand Up @@ -342,25 +340,15 @@ func saveHeartbeats(v *viper.Viper) {

func sendDiagnostics(v *viper.Viper, d diagnostics) error {
paramAPI, err := params.LoadAPIParams(v)
// prevent sending diags for api key errors
if err != nil && !errors.As(err, &api.ErrAuth{}) {
if err != nil {
return fmt.Errorf("failed to load API parameters: %s", err)
}

c, err := cmdapi.NewClient(paramAPI)
if err != nil {
log.Warnf("failed to initialize api client: %s", err)

// try without authencation
c, err = cmdapi.NewClientWithoutAuth(paramAPI)
if err != nil {
return fmt.Errorf("failed to initialize api client without auth: %s", err)
}
return fmt.Errorf("failed to initialize api client: %s", err)
}

// foce disable ssl verification
api.WithDisableSSLVerify()(c)

diagnostics := []diagnostic.Diagnostic{
diagnostic.Error(d.OriginalError),
diagnostic.Logs(d.Logs),
Expand Down

0 comments on commit c274a17

Please sign in to comment.