-
Notifications
You must be signed in to change notification settings - Fork 113
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
feat(INT-177): intercom refactor #2612
Conversation
should we use cdkv2 ? |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #2612 +/- ##
===========================================
- Coverage 86.93% 86.91% -0.02%
===========================================
Files 605 604 -1
Lines 28164 28182 +18
Branches 6702 6693 -9
===========================================
+ Hits 24484 24495 +11
- Misses 3347 3353 +6
- Partials 333 334 +1
☔ View full report in Codecov by Sentry. |
const { apiServer } = destination.Config; | ||
if (apiServer === 'eu') { | ||
return BASE_EU_ENDPOINT; | ||
} | ||
if (apiServer === 'au') { | ||
return BASE_AU_ENDPOINT; | ||
} | ||
return BASE_ENDPOINT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use switch case
const fetchContactId = async (message, destination, lookupField) => { | ||
const lookupFieldValue = getFieldValueFromMessage(message, lookupField); | ||
const data = JSON.stringify({ | ||
query: { | ||
operator: 'AND', | ||
value: [ | ||
{ | ||
field: lookupField, | ||
operator: '=', | ||
value: lookupFieldValue, | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
const headers = getHeaders(destination); | ||
const baseEndPoint = getBaseEndpoint(destination); | ||
const endpoint = `${baseEndPoint}/${SEARCH_CONTACT_ENDPOINT}`; | ||
const response = await httpPOST(endpoint, data, { | ||
headers, | ||
destType: 'intercom', | ||
feature: 'transformation', | ||
}); | ||
|
||
const processedUserResponse = processAxiosResponse(response); | ||
if (isHttpStatusSuccess(processedUserResponse.status)) { | ||
return processedUserResponse.response?.data.length > 0 | ||
? processedUserResponse.response?.data[0]?.id | ||
: null; | ||
} | ||
|
||
return null; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to do 1 search api call for the group of events we are getting in router transform to make it efficient and pass the state to transformation
payload.custom_attributes = filterCustomAttributes(payload, ReservedCompanyAttributes); | ||
const companyId = await createOrUpdateCompany(payload, destination); | ||
const lookupField = getLookUpField(message); | ||
const contactId = await fetchContactId(message, destination, lookupField); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do this for all the inputs in router transform together for efficiency
Kudos, SonarCloud Quality Gate passed! |
This PR is considered to be stale. It has been open for 20 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the PR. |
Description of the change
Type of change
Related issues
Checklists
Development
Code review