Conversation
alvincrespo
left a comment
There was a problem hiding this comment.
This looks pretty amazing! I don't work at Customer.io anymore, but as the original author of this library - this should totally be approved.
Thanks for making this happen - you rock!
| @@ -1,13 +1,13 @@ | |||
| [](https://travis-ci.org/alvincrespo/ember-cli-customerio) | |||
| [](https://travis-ci.org/customerio/customerio-node) | |||
|
|
||
| ``` | ||
| npm install --save customerio-node | ||
| npm i customerio-node |
There was a problem hiding this comment.
Should these be updated to yarn instead of npm?
There was a problem hiding this comment.
I don't think so - npm is still the default so probably best to leave it. Although of course yarn will work as well!
| return typeof id === 'object' | ||
| ? this.request.post(`${root}/events`, id) | ||
| : this.request.post(`${root}/customers/${id}/events`, data) | ||
| } |
There was a problem hiding this comment.
Do you think it's worth making to methods: trackAsObject and trackAsId. I always worry about checking against types.
There was a problem hiding this comment.
Yeah we could definitely separate them into different methods. I'd probably go with track and trackAnonymous or something like this. This API is a little bit smoother though, and I can't really think of an instance where someone would pass an object as the id and not expect something to go horribly wrong.
I'm open to either though tbh
There was a problem hiding this comment.
Anonymous event tracking isn't exposed well by our API libraries. The Ruby library is the only one to have a method for anonymous event tracking today.
I'm in favor of being explicit in separating these API calls into their own methods, track and trackAnonymous. This is more inline with our approach with the Ruby lib and our API documentation which separates anonymous events into their own resource.
| "directories": { | ||
| "test": "tests" | ||
| "version": "0.2.0", | ||
| "author": "Alvin Crespo", |
There was a problem hiding this comment.
This should probably be CustomerIO?
There was a problem hiding this comment.
🤷♂️I can change it to this if you want!
| "type": "git", | ||
| "url": "https://github.com/customerio/customerio-node.git" | ||
| "devDependencies": { | ||
| "ava": "^0.25.0", |
|
@alvincrespo 👬 💖 |
|
Hey also, I feel like we should probably ask @liamdon if he would mind giving us the primary customer.io namespace, especially if this one is hosted/maintained by the company itself. |
joepurdy
left a comment
There was a problem hiding this comment.
Thank you so much @jescalan for giving our node library some much needed TLC! 😍
I've left a couple comments for you to review, but we're also going to have one of our front end engineers review this PR since they're more well versed in JS. 😀
| return typeof id === 'object' | ||
| ? this.request.post(`${root}/events`, id) | ||
| : this.request.post(`${root}/customers/${id}/events`, data) | ||
| } |
There was a problem hiding this comment.
Anonymous event tracking isn't exposed well by our API libraries. The Ruby library is the only one to have a method for anonymous event tracking today.
I'm in favor of being explicit in separating these API calls into their own methods, track and trackAnonymous. This is more inline with our approach with the Ruby lib and our API documentation which separates anonymous events into their own resource.
| } | ||
|
|
||
| triggerBroadcast(id, data, recipients) { | ||
| return this.request.post(`${root}/campaigns/${id}/triggers`, { |
There was a problem hiding this comment.
This won't actually work for triggered broadcasts because they use a different API endpoint. https://api.customer.io/v1/api/campaigns/${id}/triggers instead of https://track.customer.io/api/v1/campaigns/${id}/triggers
For now only track.customer.io API methods are in the libraries because we're still determining the best path forward to supporting the two distinct APIs we provide.
There was a problem hiding this comment.
Good catch! I'll update this now, and will also separate the track method in the way you described. I considered this initially, but decided to go the way I did because it's the same endpoint, and it was a little smoother of an interface. But the rationale you have there makes perfect sense and I'll change it over.
|
Hey guys! Great to see all this activity on the library. I would definitely like to give you the npm namespace. What's the best way to do this? Could I add someone as an owner on npm to make the required changes? |
| const Request = require('./request') | ||
| const root = 'https://track.customer.io/api/v1' | ||
| const trackRoot = 'https://track.customer.io/api/v1' | ||
| const apiRoot = 'https://api.customer.io/v1' |
There was a problem hiding this comment.
You just need to add /api to change the apiRoot to 'https://api.customer.io/v1/api' here and in test/index.js. Beyond that the changes look spectacular. 🤩
There was a problem hiding this comment.
Oh wow, don't know how I missed that one. Fix incoming!
| const Request = require('./request') | ||
| const root = 'https://track.customer.io/api/v1' | ||
| const trackRoot = 'https://track.customer.io/api/v1' | ||
| const apiRoot = 'https://api.customer.io/api/v1' |
There was a problem hiding this comment.
Still not quite right, it's a bit confusing because the order of api/v1/ gets flipped on the apiRoot endpoint. So instead of 'https://api.customer.io/api/v1' it should be 'https://api.customer.io/v1/api'.
In your defense when I originally added triggered broadcasts to our API documentation I also mixed up the order about five or six times before getting it right. 😂
There was a problem hiding this comment.
hahah good lord, who was responsible for this decision?! oook one more update coming soon
There was a problem hiding this comment.
ook let's see if this round did it!
kevinkucharczyk
left a comment
There was a problem hiding this comment.
Oh wow, thank you soo much for this amazing PR! Looks great to me 🙂
|
@jescalan We're going to merge this PR and bump the minor version on Monday. 🍾 @liamdon Thanks for the offer to transition the |
|
🙌 🎉 |
|
Excited to see this land! Could you do me a favor and let me know when it has been released to NPM, just so I can update our code from using the fork to the official? 🥇 |
|
fyi @jescalan v0.3.0 has landed! 🙌🎉😤 |
Hey friends,
So I rewrote this library almost completely. I know this is exactly the type of PR that I don't particularly enjoy seeing myself, but I felt like it was justified for a couple reasons:
Here's what I did:
_this = thiseliminated through arrow functions, all code formatted using prettier, etc.nycpackage for test coverage, is a little smaller and more clear, and doesn't pipe in a bunch of globals that you need to guess. The tests themselves are effectively the same despite this.triggerBroadcastendpoint, and added test coverage for these as wellAll tests are passing, test coverage has been improved, and I'm hoping you guys will accept this. I would be happy to maintain it to the best of my ability as things change - I know that I will be relying on this code for my job regardless, so it's a good fit.
Thank you for making an awesome email platform, and sending over much love from HashiCorp 💖
Also, this closes #12, and incorporates the suggestion