Skip to content
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

fix: active_campaign error handler #2895

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/v0/destinations/active_campaign/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
feature: 'transformation',
});
if (res.success === false) {
errorHandler(res.response, 'Failed to create new contact');
errorHandler(res, 'Failed to create new contact');
koladilip marked this conversation as resolved.
Show resolved Hide resolved
}
const createdContact = get(res, 'response.data.contact'); // null safe
if (!createdContact) {
errorHandler(res.response, 'Failed to create new contact');
errorHandler(res, 'Failed to create new contact');

Check warning on line 69 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L69

Added line #L69 was not covered by tests
}
return createdContact.id;
};
Expand Down Expand Up @@ -404,11 +404,11 @@
feature: 'transformation',
});
if (res.success === false) {
errorHandler(res.response, 'Failed to retrieve events');
errorHandler(res, 'Failed to retrieve events');

Check warning on line 407 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L407

Added line #L407 was not covered by tests
}

if (res?.response?.status !== 200) {
errorHandler(res.response, 'Unable to create event');
errorHandler(res, 'Unable to create event');

Check warning on line 411 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L411

Added line #L411 was not covered by tests
}

const storedEventsArr = res.response?.data?.eventTrackingEvents;
Expand Down
124 changes: 124 additions & 0 deletions test/integrations/destinations/active_campaign/processor/data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import MockAdapter from 'axios-mock-adapter';
import { isMatch } from 'lodash';

export const data = [
{
name: 'active_campaign',
Expand Down Expand Up @@ -765,4 +768,125 @@ export const data = [
},
},
},

{
name: 'active_campaign',
description:
'Test 7: node error(ECONNABORTED) where there is no response coming from dest. server',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
destination: {
Config: {
apiKey: 'dummyApiKey',
apiUrl: 'https://active.campaigns.dumber.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: '[email protected]',
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,\\"[ECONNABORTED] :: Connection aborted\\")","destinationResponse":"[ECONNABORTED] :: Connection aborted"}',
statTags: {
destType: 'ACTIVE_CAMPAIGN',
errorCategory: 'network',
errorType: 'retryable',
feature: 'processor',
implementation: 'native',
module: 'destination',
},
statusCode: 500,
},
],
},
},
mockFns: (mockAdapter: MockAdapter) => {
mockAdapter
.onPost(
'https://active.campaigns.dumber.com/api/3/contact/sync',
{
asymmetricMatch: (actual) => {
return isMatch(actual, {
contact: {
email: '[email protected]',
phone: '92374162213',
},
});
},
},
{
asymmetricMatch: (actual) => {
return isMatch(actual, {
'Api-Token': 'dummyApiKey',
'Content-Type': 'application/json',
});
},
},
)
.abortRequest();
},
},
];
Loading