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

feat(INT-177): intercom refactor #2612

Closed
wants to merge 8 commits into from
Closed

Conversation

mihir-4116
Copy link
Contributor

Description of the change

Description here

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

Fix #1

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers mentioned in a comment
  • Changes have been reviewed by at least one other engineer
  • Issue from task tracker has a link to this pull request

@mihir-4116 mihir-4116 requested a review from a team as a code owner September 14, 2023 08:40
@mihir-4116 mihir-4116 self-assigned this Sep 14, 2023
@mihir-4116 mihir-4116 marked this pull request as draft September 14, 2023 08:41
@koladilip
Copy link
Contributor

should we use cdkv2 ?

@mihir-4116 mihir-4116 marked this pull request as ready for review September 15, 2023 06:43
@mihir-4116 mihir-4116 requested a review from a team as a code owner September 15, 2023 06:44
@codecov
Copy link

codecov bot commented Sep 15, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (c0ab19a) 86.93% compared to head (e3a269f) 86.91%.

❗ Current head e3a269f differs from pull request most recent head 071a395. Consider uploading reports for the commit 071a395 to get more accurate results

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     
Files Coverage Δ
src/constants/destinationCanonicalNames.js 100.00% <ø> (ø)
src/v0/destinations/intercom/config.js 100.00% <100.00%> (ø)
src/v0/destinations/intercom/util.js 95.34% <94.36%> (-4.66%) ⬇️
src/v0/destinations/intercom/transform.js 94.04% <92.85%> (-2.49%) ⬇️

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +72 to +79
const { apiServer } = destination.Config;
if (apiServer === 'eu') {
return BASE_EU_ENDPOINT;
}
if (apiServer === 'au') {
return BASE_AU_ENDPOINT;
}
return BASE_ENDPOINT;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use switch case

Comment on lines +140 to +172
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;
};
Copy link
Member

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);
Copy link
Member

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

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

88.8% 88.8% Coverage
0.0% 0.0% Duplication

@devops-github-rudderstack
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants