From 13c54693c4ce5d5379cdea5e83cda20d79e136d0 Mon Sep 17 00:00:00 2001 From: yeshwanth vuppu <16932584+vyeshwanth@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:40:39 +0530 Subject: [PATCH] fix: audienceId not found error --- src/v0/destinations/fb_custom_audience/recordTransform.js | 7 ++----- src/v0/destinations/fb_custom_audience/transform.js | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/v0/destinations/fb_custom_audience/recordTransform.js b/src/v0/destinations/fb_custom_audience/recordTransform.js index f115c49346..b771f2d7a2 100644 --- a/src/v0/destinations/fb_custom_audience/recordTransform.js +++ b/src/v0/destinations/fb_custom_audience/recordTransform.js @@ -21,7 +21,6 @@ const { responseBuilderSimple, getDataSource, } = require('./util'); -const logger = require('../../../logger'); const processRecordEventArray = ( recordChunksArray, @@ -105,7 +104,7 @@ async function processRecordInputs(groupedRecordInputs) { const { message } = groupedRecordInputs[0]; const { isHashRequired, accessToken, disableFormat, type, subType, isRaw, maxUserCount } = destination.Config; - const audienceId = get(connection, 'Config.destination.audienceId'); + const audienceId = get(connection, 'config.destination.audienceId'); const prepareParams = { access_token: accessToken, }; @@ -117,11 +116,9 @@ async function processRecordInputs(groupedRecordInputs) { } // audience id validation - logger.debug('Connection_object', JSON.stringify(connection)); - logger.debug('Event_object', JSON.stringify(message)); let operationAudienceId = audienceId; const mappedToDestination = get(message, MappedToDestinationKey); - if (mappedToDestination) { + if (mappedToDestination && !operationAudienceId) { const { objectType } = getDestinationExternalIDInfoForRetl(message, 'FB_CUSTOM_AUDIENCE'); operationAudienceId = objectType; } diff --git a/src/v0/destinations/fb_custom_audience/transform.js b/src/v0/destinations/fb_custom_audience/transform.js index f8bf8b4fbb..26180cb2f9 100644 --- a/src/v0/destinations/fb_custom_audience/transform.js +++ b/src/v0/destinations/fb_custom_audience/transform.js @@ -159,7 +159,7 @@ const processEvent = (message, destination, connection) => { let toSendEvents = []; let { userSchema } = destination.Config; const { isHashRequired, maxUserCount } = destination.Config; - const audienceId = get(connection, 'Config.destination.audienceId'); + const audienceId = get(connection, 'config.destination.audienceId'); if (!message.type) { throw new InstrumentationError('Message Type is not present. Aborting message.'); } @@ -248,7 +248,6 @@ const processRouterDest = async (inputs, reqMetadata) => { const eventTypes = ['record', 'audiencelist']; const unsupportedEventList = checkForUnsupportedEventTypes(groupedInputs, eventTypes); if (unsupportedEventList.length > 0) { - logger.info(`unsupported events found ${unsupportedEventList}`); throw new ConfigurationError('unsupported events present in the event'); }