Skip to content

Commit

Permalink
chore: propagate metadata to api call fn in intercom dest
Browse files Browse the repository at this point in the history
  • Loading branch information
Sai Sankeerth committed Jun 18, 2024
1 parent 6ce30f0 commit 9a39d67
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cdk/v2/destinations/intercom/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ steps:
- name: searchContact
condition: ($.outputs.messageType === {{$.EventType.IDENTIFY}} || $.outputs.messageType === {{$.EventType.GROUP}}) && $.outputs.apiVersion !== "v1"
template: |
const contactId = await $.searchContact(.message, .destination);
const contactId = await $.searchContact(.message, .destination, .metadata);
contactId;
- name: identifyTransformationForLatestVersion
Expand Down Expand Up @@ -176,7 +176,7 @@ steps:
condition: $.isDefinedAndNotNull($.outputs.searchContact)
template: |
const contactId = $.outputs.searchContact;
const companyId = await $.createOrUpdateCompany($.context.payload, .destination);
const companyId = await $.createOrUpdateCompany($.context.payload, .destination, .metadata);
$.assert(companyId, "Unable to create or update company");
$.context.payload = {
id: companyId,
Expand Down
6 changes: 4 additions & 2 deletions src/cdk/v2/destinations/intercom/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const filterCustomAttributes = (payload, type, destination) => {
* @param {*} destination
* @returns
*/
const searchContact = async (message, destination) => {
const searchContact = async (message, destination, metadata) => {
const lookupField = getLookUpField(message);
const lookupFieldValue = getFieldValueFromMessage(message, lookupField);
const data = JSON.stringify({
Expand Down Expand Up @@ -258,6 +258,7 @@ const searchContact = async (message, destination) => {
endpointPath: '/contacts/search',
requestMethod: 'POST',
module: 'router',
metadata,
},
);
const processedUserResponse = processAxiosResponse(response);
Expand All @@ -284,7 +285,7 @@ const searchContact = async (message, destination) => {
* @param {*} destination
* @returns
*/
const createOrUpdateCompany = async (payload, destination) => {
const createOrUpdateCompany = async (payload, destination, metadata) => {
const headers = getHeaders(destination);
const finalPayload = JSON.stringify(removeUndefinedAndNullValues(payload));
const baseEndPoint = getBaseEndpoint(destination);
Expand All @@ -296,6 +297,7 @@ const createOrUpdateCompany = async (payload, destination) => {
headers,
},
{
metadata,
destType: 'intercom',
feature: 'transformation',
endpointPath: '/companies',
Expand Down

0 comments on commit 9a39d67

Please sign in to comment.