fix(recombee): Fix API inconsistencies#3767
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes timestamp handling for the Recombee destination, ensuring delete interactions send timestamps in seconds (as required by Recombee) and aligning action field schemas to use the datetime field type.
Changes:
- Update
Delete Bookmark/Delete Cart AdditionURL construction to sendtimestampas epoch seconds (converting from ms/ISO when needed). - Change
timestampinput fields across Recombee actions fromstringtodatetime(and update generated types accordingly). - Update unit tests/snapshots to reflect the new timestamp expectations and payload shapes.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/destination-actions/src/destinations/recombee/setViewPortionFromWatchTime/index.ts | Switch timestamp field to datetime. |
| packages/destination-actions/src/destinations/recombee/setViewPortionFromWatchTime/generated-types.ts | Update timestamp payload type to string | number. |
| packages/destination-actions/src/destinations/recombee/setViewPortionFromWatchTime/tests/snapshots/snapshot.test.ts.snap | Snapshot update for timestamp value shape. |
| packages/destination-actions/src/destinations/recombee/setViewPortion/index.ts | Switch timestamp field to datetime. |
| packages/destination-actions/src/destinations/recombee/setViewPortion/generated-types.ts | Update timestamp payload type to string | number. |
| packages/destination-actions/src/destinations/recombee/setViewPortion/tests/snapshots/snapshot.test.ts.snap | Snapshot update for timestamp value shape. |
| packages/destination-actions/src/destinations/recombee/recombeeApiClient.ts | Convert delete timestamp to epoch seconds and build query via URLSearchParams. |
| packages/destination-actions/src/destinations/recombee/deleteCartAddition/index.ts | Switch timestamp field to datetime. |
| packages/destination-actions/src/destinations/recombee/deleteCartAddition/generated-types.ts | Update timestamp payload type to string | number. |
| packages/destination-actions/src/destinations/recombee/deleteCartAddition/tests/index.test.ts | Update tests to expect 10-digit (seconds) timestamps and seconds-based URL assertions. |
| packages/destination-actions/src/destinations/recombee/deleteCartAddition/tests/snapshots/snapshot.test.ts.snap | Snapshot update for timestamp value shape. |
| packages/destination-actions/src/destinations/recombee/deleteBookmark/index.ts | Switch timestamp field to datetime. |
| packages/destination-actions/src/destinations/recombee/deleteBookmark/generated-types.ts | Update timestamp payload type to string | number. |
| packages/destination-actions/src/destinations/recombee/deleteBookmark/tests/index.test.ts | Update tests to expect 10-digit (seconds) timestamps and seconds-based URL assertions. |
| packages/destination-actions/src/destinations/recombee/deleteBookmark/tests/snapshots/snapshot.test.ts.snap | Snapshot update for timestamp value shape. |
| packages/destination-actions/src/destinations/recombee/addRating/index.ts | Switch timestamp field to datetime. |
| packages/destination-actions/src/destinations/recombee/addRating/generated-types.ts | Update timestamp payload type to string | number. |
| packages/destination-actions/src/destinations/recombee/addRating/tests/snapshots/snapshot.test.ts.snap | Snapshot update for timestamp value shape. |
| packages/destination-actions/src/destinations/recombee/addPurchase/index.ts | Switch timestamp field to datetime. |
| packages/destination-actions/src/destinations/recombee/addPurchase/generated-types.ts | Update timestamp payload type to string | number. |
| packages/destination-actions/src/destinations/recombee/addPurchase/tests/snapshots/snapshot.test.ts.snap | Snapshot update for timestamp value shape. |
| packages/destination-actions/src/destinations/recombee/addDetailView/index.ts | Switch timestamp field to datetime. |
| packages/destination-actions/src/destinations/recombee/addDetailView/generated-types.ts | Update timestamp payload type to string | number. |
| packages/destination-actions/src/destinations/recombee/addDetailView/tests/snapshots/snapshot.test.ts.snap | Snapshot update for timestamp value shape. |
| packages/destination-actions/src/destinations/recombee/addCartAddition/index.ts | Switch timestamp field to datetime. |
| packages/destination-actions/src/destinations/recombee/addCartAddition/generated-types.ts | Update timestamp payload type to string | number. |
| packages/destination-actions/src/destinations/recombee/addCartAddition/tests/snapshots/snapshot.test.ts.snap | Snapshot update for timestamp value shape. |
| packages/destination-actions/src/destinations/recombee/addBookmark/index.ts | Switch timestamp field to datetime. |
| packages/destination-actions/src/destinations/recombee/addBookmark/generated-types.ts | Update timestamp payload type to string | number. |
| packages/destination-actions/src/destinations/recombee/addBookmark/tests/snapshots/snapshot.test.ts.snap | Snapshot update for timestamp value shape. |
| packages/destination-actions/src/destinations/recombee/tests/snapshots/snapshot.test.ts.snap | Update destination-level snapshots for timestamp value shape across actions. |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR fixes Recombee delete-interaction timestamp handling (seconds vs. milliseconds) and updates Recombee action field schemas so timestamp is modeled as a datetime (and thus typed as string | number) across the destination.
Changes:
- Fix
Delete Cart AdditionandDelete BookmarkURL timestamp to send Unix seconds (and add more robust timestamp parsing/normalization for deletes). - Change
timestampinput field type fromstring→datetimeacross Recombee actions and update generated payload types accordingly. - Update unit tests and snapshots to reflect the
datetimefield behavior and the corrected delete timestamp semantics.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/destination-actions/src/destinations/recombee/recombeeApiClient.ts | Normalize delete URL query params via URLSearchParams; convert/delete timestamp to epoch seconds and validate invalid timestamps. |
| packages/destination-actions/src/destinations/recombee/deleteCartAddition/index.ts | Change timestamp field type to datetime. |
| packages/destination-actions/src/destinations/recombee/deleteCartAddition/generated-types.ts | Update payload timestamp type to string | number. |
| packages/destination-actions/src/destinations/recombee/deleteCartAddition/tests/index.test.ts | Update delete URL expectations to 10-digit seconds timestamps. |
| packages/destination-actions/src/destinations/recombee/deleteCartAddition/tests/snapshots/snapshot.test.ts.snap | Snapshot update for datetime timestamp example. |
| packages/destination-actions/src/destinations/recombee/deleteBookmark/index.ts | Change timestamp field type to datetime. |
| packages/destination-actions/src/destinations/recombee/deleteBookmark/generated-types.ts | Update payload timestamp type to string | number. |
| packages/destination-actions/src/destinations/recombee/deleteBookmark/tests/index.test.ts | Update delete URL expectations to 10-digit seconds timestamps. |
| packages/destination-actions/src/destinations/recombee/deleteBookmark/tests/snapshots/snapshot.test.ts.snap | Snapshot update for datetime timestamp example. |
| packages/destination-actions/src/destinations/recombee/addBookmark/index.ts | Change timestamp field type to datetime. |
| packages/destination-actions/src/destinations/recombee/addBookmark/generated-types.ts | Update payload timestamp type to string | number. |
| packages/destination-actions/src/destinations/recombee/addBookmark/tests/snapshots/snapshot.test.ts.snap | Snapshot update for datetime timestamp example. |
| packages/destination-actions/src/destinations/recombee/addCartAddition/index.ts | Change timestamp field type to datetime. |
| packages/destination-actions/src/destinations/recombee/addCartAddition/generated-types.ts | Update payload timestamp type to string | number. |
| packages/destination-actions/src/destinations/recombee/addCartAddition/tests/snapshots/snapshot.test.ts.snap | Snapshot update for datetime timestamp example. |
| packages/destination-actions/src/destinations/recombee/addDetailView/index.ts | Change timestamp field type to datetime. |
| packages/destination-actions/src/destinations/recombee/addDetailView/generated-types.ts | Update payload timestamp type to string | number. |
| packages/destination-actions/src/destinations/recombee/addDetailView/tests/snapshots/snapshot.test.ts.snap | Snapshot update for datetime timestamp example. |
| packages/destination-actions/src/destinations/recombee/addPurchase/index.ts | Change timestamp field type to datetime. |
| packages/destination-actions/src/destinations/recombee/addPurchase/generated-types.ts | Update payload timestamp type to string | number. |
| packages/destination-actions/src/destinations/recombee/addPurchase/tests/snapshots/snapshot.test.ts.snap | Snapshot update for datetime timestamp example. |
| packages/destination-actions/src/destinations/recombee/addRating/index.ts | Change timestamp field type to datetime. |
| packages/destination-actions/src/destinations/recombee/addRating/generated-types.ts | Update payload timestamp type to string | number. |
| packages/destination-actions/src/destinations/recombee/addRating/tests/snapshots/snapshot.test.ts.snap | Snapshot update for datetime timestamp example. |
| packages/destination-actions/src/destinations/recombee/setViewPortion/index.ts | Change timestamp field type to datetime. |
| packages/destination-actions/src/destinations/recombee/setViewPortion/generated-types.ts | Update payload timestamp type to string | number. |
| packages/destination-actions/src/destinations/recombee/setViewPortion/tests/snapshots/snapshot.test.ts.snap | Snapshot update for datetime timestamp example. |
| packages/destination-actions/src/destinations/recombee/setViewPortionFromWatchTime/index.ts | Change timestamp field type to datetime. |
| packages/destination-actions/src/destinations/recombee/setViewPortionFromWatchTime/generated-types.ts | Update payload timestamp type to string | number. |
| packages/destination-actions/src/destinations/recombee/setViewPortionFromWatchTime/tests/snapshots/snapshot.test.ts.snap | Snapshot update for datetime timestamp example. |
| packages/destination-actions/src/destinations/recombee/tests/snapshots/snapshot.test.ts.snap | Aggregate snapshot updates for datetime timestamp examples across actions. |
|
Hi @mstieranka please ping me when this PR is ready for review. |
| // 10,000,000,000 is the year 2286 in seconds, anything larger is likely in milliseconds | ||
| if (numValue >= 10000000000) { | ||
| return numValue / 1000 | ||
| } else { | ||
| return numValue |
| function getDeleteUrl(interactionType: string, params: DeleteParams): string { | ||
| const query = new URLSearchParams({ | ||
| userId: params.userId, | ||
| itemId: params.itemId | ||
| }) | ||
|
|
||
| if (params.timestamp !== undefined && params.timestamp !== null) { | ||
| query.append('timestamp', String(datetimeToEpochSeconds(params.timestamp))) | ||
| } | ||
| return url | ||
|
|
||
| return `/${interactionType}/?${query.toString()}` | ||
| } |
61b9364 to
9b20518
Compare
|
Hi @joe-ayoub-segment , this PR has had some changes added to it and is now ready for review. |
| // 10,000,000,000 is the year 2286 in seconds, anything larger is likely in milliseconds | ||
| if (numValue >= 10000000000) { | ||
| return numValue / 1000 | ||
| } else { | ||
| return numValue |
Hi, we have identified several issues with out Recombee destination, and this pull request fixes all of them.
Delete Cart AdditionandDelete Bookmark, the request to our API was incorrectly setting the timestamp to milliseconds since epoch where seconds were expected. The following changes were made:timestamphas been modified to use thedatetimetype instead ofstring, which more accurately reflects the intended values.HTTP 400(the API rejects this parameter), whereas this version returnsHTTP 500(the validation already fails in Segment). I'm not sure if this is a breaking change, since both requests would have failed and the field itself is optional in all mappings. This is why the "Tested for backwards compatibility" task below is not yet marked as complete.timestamphandling has generally been made more robust to accept any form of date string parseable bynew Date(str)or a number representing either seconds or milliseconds since epoch. The field description has been changed to reflect this fact.$.timestamp) is corrected for clock skew, however, that means that the Recombee API receives a different timestamp than the user sent. Since theDelete Bookmarkaction expects the exact same timestamp as when sending the request, this meant that such a use case wouldn't work. The following changes were made:timestampmapping inAdd*events has been changed to use$.properties.timestampby default, falling back to$.timestampif not present.timestampmapping inDelete*events now also uses$.properties.timestamp.pricefield is stated per-unit, however, the Recombee API expects thepriceandprofitfields to be stated per the given quantity. Therefore, the destination now multipliespricebyamountto match the expectation of the Recombee API.Testing
Include any additional information about the testing you have completed to
ensure your changes behave as expected. For a speedy review, please check
any of the tasks you completed below during your testing.
Security Review
Please ensure sensitive data is properly protected in your integration.
type: 'password'New Destination Checklist
verioning-info.tsfile. example