Skip to content

Commit 441bf42

Browse files
Merge pull request #616 from onflow/bugfix/remove-sentry-exception
Remove sentry capture exception from mixpanel
2 parents aa3fd26 + 431fb08 commit 441bf42

File tree

2 files changed

+1
-59
lines changed

2 files changed

+1
-59
lines changed

internal/command/command.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,7 @@ func (c Command) handleUserTracking() {
8282
if util.MIXPANEL_SERVICE_ACCOUNT_SECRET == "" || util.MIXPANEL_PROJECT_TOKEN == "" {
8383
return
8484
}
85-
optedIn, err := util.IsUserOptedIn()
86-
if err != nil {
87-
sentry.CaptureException(err)
88-
}
89-
if optedIn {
90-
err = util.TrackCommandUsage(c.Cmd)
91-
if err != nil {
92-
sentry.CaptureException(err)
93-
}
94-
}
85+
_ = util.TrackCommandUsage(c.Cmd)
9586
}
9687

9788
// AddToParent add new command to main parent cmd

pkg/flowkit/util/mixpanel.go

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import (
2525
"github.com/spf13/cobra"
2626
"io/ioutil"
2727
"net/http"
28-
"net/url"
29-
"strings"
3028
)
3129

3230
const (
@@ -124,50 +122,3 @@ type MixPanelResponse struct {
124122
} `json:"$properties"`
125123
} `json:"results"`
126124
}
127-
128-
//User is opted in by default
129-
//If distinct id can't be found through query api, return true to reflect that user is opted in
130-
func IsUserOptedIn() (bool, error) {
131-
distinctId, err := generateNewDistinctId()
132-
if err != nil {
133-
return false, err
134-
}
135-
136-
queryPayload := "distinct_id=" + url.QueryEscape(distinctId)
137-
payload := strings.NewReader(queryPayload)
138-
req, err := http.NewRequest("POST", MIXPANEL_QUERY_URL, payload)
139-
if err != nil {
140-
return false, err
141-
}
142-
143-
mixpanelAuth := "Basic " + MIXPANEL_SERVICE_ACCOUNT_SECRET
144-
req.Header.Add("Accept", "application/json")
145-
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
146-
req.Header.Add("Authorization", mixpanelAuth)
147-
148-
res, err := http.DefaultClient.Do(req)
149-
if err != nil {
150-
return false, err
151-
}
152-
153-
defer res.Body.Close()
154-
body, err := ioutil.ReadAll(res.Body)
155-
156-
var queryResponse MixPanelResponse
157-
err = json.Unmarshal(body, &queryResponse)
158-
159-
if err != nil {
160-
return false, err
161-
}
162-
if res.StatusCode >= 400 {
163-
if res.StatusCode == 429 {
164-
//tracking is enabled by default if there is rate limit error from mixpanel
165-
return true, nil
166-
}
167-
return false, fmt.Errorf("invalid response status code %d for tracking command usage", res.StatusCode)
168-
}
169-
if len(queryResponse.Results) == 0 {
170-
return true, nil
171-
}
172-
return queryResponse.Results[0].Properties.OptIn, nil
173-
}

0 commit comments

Comments
 (0)