diff --git a/src/v0/destinations/iterable/util.js b/src/v0/destinations/iterable/util.js index b61687536d..8e8cf5aff3 100644 --- a/src/v0/destinations/iterable/util.js +++ b/src/v0/destinations/iterable/util.js @@ -803,11 +803,13 @@ const checkIfEventIsAbortableAndExtractErrorMessage = (event, destinationRespons ITERABLE_RESPONSE_EMAIL_PATHS.find((emailPath) => isValueInResponseArray(emailPath, eventValues.email, destinationResponse.response), ) || - isValueInResponseArray( + (isValueInResponseArray( 'disallowedEventNames', eventValues.eventName, destinationResponse.response, - ); + ) + ? 'disallowedEventNames' + : null); if (matchingPath) { const responseValueArray = getValueFromResponse(matchingPath, destinationResponse.response); @@ -818,7 +820,7 @@ const checkIfEventIsAbortableAndExtractErrorMessage = (event, destinationRespons if (ITERABLE_RESPONSE_USER_ID_PATHS.some((userIdPath) => matchingPath.includes(userIdPath))) { return value === eventValues.userId; } - if (matchingPath.includes('disallowedEventNames')) { + if (matchingPath === 'disallowedEventNames') { return value === eventValues.eventName; } return false; diff --git a/src/v0/destinations/iterable/util.test.js b/src/v0/destinations/iterable/util.test.js index ea3d7ef617..6a9881027a 100644 --- a/src/v0/destinations/iterable/util.test.js +++ b/src/v0/destinations/iterable/util.test.js @@ -864,7 +864,7 @@ describe('iterable utils test', () => { // Returns appropriate error message for abortable event - it('should find the right value for which it should fail and passes otherwise', () => { + it('should find the right value for which it should fail and passes otherwise for emails', () => { const event = { email: 'test', userId: 'user123', @@ -905,5 +905,51 @@ describe('iterable utils test', () => { expect(result.isAbortable).toBe(false); expect(result.errorMsg).toBe(''); }); + + it('should find the right value for which it should fail and passes otherwise for userIds', () => { + const event = { + email: 'test', + userId: 'user123', + eventName: 'purchase', + dataFields: { customField1: 'value1', customField2: 'value2' }, + }; + const destinationResponse = { + response: { + failCount: 1, + failedUpdates: { + invalidUserIds: ['user123'], + }, + }, + }; + const result = checkIfEventIsAbortableAndExtractErrorMessage(event, destinationResponse); + expect(result).toEqual({ + isAbortable: true, + errorMsg: + 'Request failed for value "user123" because it is "failedUpdates.invalidUserIds".', + }); + }); + + it('should find the right value for which it should fail and passes otherwise for disallowed events', () => { + const event = { + email: 'test', + userId: 'user123', + eventName: 'purchase', + dataFields: { customField1: 'value1', customField2: 'value2' }, + }; + const destinationResponse = { + response: { + failCount: 1, + disallowedEventNames: ['purchase'], + failedUpdates: { + invalidUserIds: [], + }, + }, + }; + const result = checkIfEventIsAbortableAndExtractErrorMessage(event, destinationResponse); + expect(result).toEqual({ + isAbortable: true, + errorMsg: 'Request failed for value "purchase" because it is "disallowedEventNames".', + }); + }); }); });