From 1e18ed4c35ce1ee5133ca682a80abe59abd811aa Mon Sep 17 00:00:00 2001 From: Dilip Kola Date: Mon, 9 Dec 2024 17:53:12 +0530 Subject: [PATCH] refactor: garl record transform --- .../recordTransform.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/v0/destinations/google_adwords_remarketing_lists/recordTransform.js b/src/v0/destinations/google_adwords_remarketing_lists/recordTransform.js index c039ff1486..c3bf27a75d 100644 --- a/src/v0/destinations/google_adwords_remarketing_lists/recordTransform.js +++ b/src/v0/destinations/google_adwords_remarketing_lists/recordTransform.js @@ -32,7 +32,6 @@ const processRecordEventArray = (records, context, operationType) => { personalizationConsent, } = context; - const outputPayloads = {}; const fieldsArray = records.map((record) => record.message.fields); const metadata = records.map((record) => record.metadata); @@ -44,24 +43,18 @@ const processRecordEventArray = (records, context, operationType) => { ); const outputPayload = constructPayload(message, offlineDataJobsMapping); - outputPayload.operations = []; const userIdentifierChunks = returnArrayOfSubarrays(userIdentifiersList, 20); - userIdentifierChunks.forEach((chunk) => { - const operation = { - [operationType]: { userIdentifiers: chunk }, - }; - outputPayload.operations.push(operation); - }); - - outputPayloads[operationType] = outputPayload; + outputPayload.operations = userIdentifierChunks.map((chunk) => ({ + [operationType]: { userIdentifiers: chunk }, + })); const consentObj = populateConsentFromConfig( { userDataConsent, personalizationConsent }, consentConfigMap, ); - const toSendEvents = Object.values(outputPayloads).map((data) => + const toSendEvents = [outputPayload].map((data) => responseBuilder(accessToken, developerToken, data, destination, audienceId, consentObj), );