diff --git a/src/v0/destinations/active_campaign/transform.js b/src/v0/destinations/active_campaign/transform.js index 8dcde244e6..70caf47ea8 100644 --- a/src/v0/destinations/active_campaign/transform.js +++ b/src/v0/destinations/active_campaign/transform.js @@ -98,7 +98,7 @@ const customTagProcessor = async (message, category, destination, contactId) => feature: 'transformation', }); if (res.success === false) { - errorHandler(res.response, 'Failed to fetch already created tags'); + errorHandler(res, 'Failed to fetch already created tags'); } const storedTags = {}; @@ -169,7 +169,7 @@ const customTagProcessor = async (message, category, destination, contactId) => feature: 'transformation', }); if (res.success === false) { - errorHandler(res.response, 'Failed to create new tag'); + errorHandler(res, 'Failed to create new tag'); // For each tags successfully created the response id is pushed to tagIds } if (res.response.status === 201) tagIds.push(res.response.data.tag.id); @@ -201,7 +201,7 @@ const customTagProcessor = async (message, category, destination, contactId) => ); responsesArr.forEach((respItem) => { if (respItem.success === false) - errorHandler(respItem.response, 'Failed to merge created contact with created tags'); + errorHandler(respItem, 'Failed to merge created contact with created tags'); }); }; @@ -219,7 +219,7 @@ const customFieldProcessor = async (message, category, destination) => { // Step - 2 // Get the existing field data from dest and store it in responseStaging // Ref - https://developers.activecampaign.com/reference/retrieve-fields - let endpoint = `${destination.Config.apiUrl}${`${category.fieldEndPoint}?limit=100`}`; + let endpoint = `${destination.Config.apiUrl}${category.fieldEndPoint}?limit=100`; const requestOptions = { headers: { 'Api-Token': destination.Config.apiKey, @@ -230,7 +230,7 @@ const customFieldProcessor = async (message, category, destination) => { feature: 'transformation', }); if (res.success === false) { - errorHandler(res.response, 'Failed to get existing field data'); + errorHandler(res, 'Failed to get existing field data'); } responseStaging.push(res.response.status === 200 ? res.response.data.fields : []); @@ -257,7 +257,7 @@ const customFieldProcessor = async (message, category, destination) => { if (resp.success === true && resp.response.status === 200) { responseStaging.push(resp.response.data.fields); } else { - errorHandler(resp.response, 'Failed to get existing field data'); + errorHandler(resp, 'Failed to get existing field data'); } }); } @@ -352,7 +352,7 @@ const customListProcessor = async (message, category, destination, contactId) => const responses = await Promise.all(promises); responses.forEach((respItem) => { if (respItem.success === false) { - errorHandler(respItem.response, 'Failed to map created contact with the list'); + errorHandler(respItem, 'Failed to map created contact with the list'); } }); }; @@ -431,11 +431,11 @@ const screenRequestHandler = async (message, category, destination) => { feature: 'transformation', }); if (res.success === false) { - errorHandler(res.response, 'Failed to create event'); + errorHandler(res, 'Failed to create event'); } if (res.response.status !== 201) { - errorHandler(res.response, 'Unable to create event'); + errorHandler(res, 'Unable to create event'); } } // Previous operations successfull then @@ -468,11 +468,11 @@ const trackRequestHandler = async (message, category, destination) => { }); if (res.success === false) { - errorHandler(res.response, 'Failed to retrieve events'); + errorHandler(res, 'Failed to retrieve events'); } if (res.response.status !== 200) { - errorHandler(res.response, 'Unable to fetch events. Aborting'); + errorHandler(res, 'Unable to fetch events. Aborting'); } const storedEventsArr = res.response?.data?.eventTrackingEvents; @@ -495,7 +495,7 @@ const trackRequestHandler = async (message, category, destination) => { feature: 'transformation', }); if (res.response?.status !== 201) { - errorHandler(res.response, 'Unable to create event. Aborting'); + errorHandler(res, 'Unable to create event. Aborting'); } } diff --git a/test/integrations/destinations/active_campaign/processor/data.ts b/test/integrations/destinations/active_campaign/processor/data.ts index 15a11260ad..cef8c2a3a8 100644 --- a/test/integrations/destinations/active_campaign/processor/data.ts +++ b/test/integrations/destinations/active_campaign/processor/data.ts @@ -889,4 +889,268 @@ export const data = [ .abortRequest(); }, }, + { + name: 'active_campaign', + description: 'Test 8: erreneous response from active_campaign server(5xx)', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'dummyApiKey', + apiUrl: 'https://active.campaigns.dumber2.com', + actid: '476550467', + eventKey: 'f8a866fddc721350fdc2fbbd2e5c43a6dddaaa03', + }, + }, + message: { + channel: 'web', + context: { + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-US', + ip: '0.0.0.0', + os: { name: '', version: '' }, + screen: { density: 2 }, + }, + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: 'anon_id', + userId: '123456', + type: 'identify', + traits: { + anonymousId: 'anon_id', + email: 'patjane1@gmail.com', + phone: '92374162213', + tags: ['Test_User', 'Interested_User', 'DIY_Hobby'], + fieldInfo: { + Office: 'Trastkiv', + Country: 'Russia', + Likes: ['Potato', 'Onion'], + Random: 'random', + }, + lists: [ + { id: 2, status: 'subscribe' }, + { id: 3, status: 'unsubscribe' }, + { id: 3, status: 'unsubscribexyz' }, + ], + address: { + city: 'kolkata', + country: 'India', + postalCode: 789223, + state: 'WB', + street: '', + }, + }, + integrations: { All: true }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + '{"message":"Failed to create new contact (undefined,\\"\\\\\\\\n\\\\\\\\n\\\\\\\\n\\\\\\\\n \\\\\\\\n
\\\\\\\\n\\\\\\\\n\\\\\\\\nThe web server reported a gateway time-out error.
\\\\\\\\nPlease try again in a few minutes.
\\\\\\\\nThe web server reported a gateway time-out error.
\\\\nPlease try again in a few minutes.
\\\\nThe web server reported a gateway time-out error.
\\nPlease try again in a few minutes.
\\n