Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added drift integration #41

Merged
merged 2 commits into from
Oct 11, 2016
Merged

Added drift integration #41

merged 2 commits into from
Oct 11, 2016

Conversation

jonashelgemo
Copy link
Collaborator

Feedback appreciated :)

Copy link
Owner

@jipiboily jipiboily left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @helgeblod! Only a few tiny things regarding logging. Really nicely done 😀

@@ -36,6 +36,12 @@ To send to [Drip][drip]:

**Please note** that you need to send an "email" property to be able to get the Drip integration working.

To send to Drift:

- set `DRIFT_ORG_ID=456` (ATM only possible to find by contacting the drift support dept)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know!

s.Attributes["forwardlyticsTimestamp"] = identification.Timestamp
payload, err := json.Marshal(s)

err = d.api.request("POST", "identify", payload)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is an error, please log an error using logrus. I just improved it for the other integrations. See 798c7c1

Can you do something similar? It adds more context to the Bugsnag report and is super useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. More logging is a good idea in general. It's a bit hard to know what went wrong per now because of the logging that is a bit minimal. I'll add it everywhere you mentioned as a start.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

if err != nil {
logrus.WithField("err", err).Fatal("Error marshalling drift event to json")
}
err = d.api.request("POST", "track", payload)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here.

e.CreatedAt = event.Timestamp
payload, err := json.Marshal(e)
if err != nil {
logrus.WithField("err", err).Fatal("Error marshalling drift event to json")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the logging I just mentioned here too. It's not your fault, I did not do a good job originally and when I faced a bug with the Drip integration (not your fault, I was not sending an email for a specific event), I had to add more context.

if resp.StatusCode != http.StatusOK {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
logrus.WithField("err", err).Error("Error reading body in Drift response")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here for logging.

resp, err := client.Do(req)
defer resp.Body.Close()
if err != nil {
logrus.WithField("err", err).Error("Error sending request to Drift api")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here for logging.

logrus.WithField("err", err).Error("Error reading body in Drift response")
return err
}
logrus.WithFields(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here for logging.

Copy link
Owner

@jipiboily jipiboily left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides that one, it's ready to 🚢


err = d.api.request("POST", "identify", payload)
if err != nil {
logrus.WithError(err).WithField("identify", identification).WithField("payload", payload)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot the .Error part 😬

@jonashelgemo
Copy link
Collaborator Author

I think this is finished, but I force pushed some changes to my branch, so I might have broken some of the review feedback. I'll try to avoid this on the next one. Anything else that needs fixing, or are we ready to merge this?

@jipiboily jipiboily merged commit 8037010 into jipiboily:master Oct 11, 2016
@jipiboily jipiboily mentioned this pull request Oct 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants