-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add extra device data to attributes object in addDevice
#115
Add extra device data to attributes object in addDevice
#115
Conversation
addDevice
addDevice
lib/track.ts
Outdated
@@ -116,7 +116,7 @@ export class TrackClient { | |||
} | |||
|
|||
return this.request.put(`${this.trackRoot}/customers/${encodeURIComponent(customerId)}/devices`, { | |||
device: { id: device_id, platform, ...data }, | |||
device: { id: device_id, platform, attributes: { ...data } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're here @xanderberkein, let's add support for last_used
here:
device: { id: device_id, platform, attributes: { ...data } }, | |
let { last_used, ...attributes } = data; | |
device: { id: device_id, platform, last_used, attributes }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mike-engel added in my latest commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xanderberkein!
@mike-engel I've made it so that |
Thanks @xanderberkein, this should be available in |
Great, thanks! |
@mike-engel It seems like you didn't include the build ( |
Hmm, looks like npm doesn't run the |
Should be fixed in |
@mike-engel Works now, thanks! |
To add extra data to a device, we should use the
attributes
param in the add/update device API call (see the official docs)Currently, extra data gets spread out over the request params and it doesn't arrive in customer.io.
This PR makes sure that data that's passed along through the
data
param in theaddDevice
function, is properly sent to the API by putting it in the requiredattributes
param.