intercom / intercom-node

Node.js bindings for the Intercom API
https://developers.intercom.com
Other
366 stars 116 forks source link

Breaking changes in version 4? #342

Closed hugihlynsson closed 1 year ago

hugihlynsson commented 1 year ago

Hi! We just noticed that you've released version 4 of intercom-node but we're having some issues identifying whether we are able to upgrade without modifications or not.

The major version updates hints at this being a breaking update but the release entry for v4.0.0 doesn't really help us understand what parts we should need to update. The Breaking Changes section on the project Readme and the migration doc only mentions version 3.

Can you help us understand what changes we might have to make to upgrade from version 3 to 4?

colmdoyle commented 1 year ago

Great callout @hugihlynsson, and definitely on us to fix for you.

tldr - Yes, 4.0.0 is definitely a breaking change, the biggest ones being that as of API v2.6 client.conversations.list now uses a cursor based pagination system instead of just page numbers.

Also we spotted a typo in one of our enum value, so if you rely on that you'll start seeing TS errors

SeanHealy33 commented 1 year ago

Hi @hugihlynsson to go a bit deeper on the specific changes to conversations

OLD

const response = await client.conversations.list({
    order: Order.DESC,
    sort: SortBy.UpdatedAt,
    page: 1,
    perPage: 10,
});

NEW

const response = await client.conversations.list({
    startingAfter: 'WzE2NzA0MjI1MjkwMDAsMjQzMTY3NzA2ODcsMl0=',
    perPage: 10,
});

The new list uses a startingAfter param to get the next page instead of the old page parameter (the next starting_after key is provided on each page as you get it). As of 4.0 we also removed page order and sort from the list method here since they no longer do anything as of API Version 2.6

colmdoyle commented 1 year ago

Hope that clears it up a bit more for you @hugihlynsson, feel free to reopen this issue and tag me if you've any more questions

hugihlynsson commented 1 year ago

That's the info we needed. Thanks!