Skip to content

Commit

Permalink
refactor: garl record transform
Browse files Browse the repository at this point in the history
  • Loading branch information
koladilip committed Dec 9, 2024
1 parent 0f5f4d4 commit 1e18ed4
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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),
);

Expand Down

0 comments on commit 1e18ed4

Please sign in to comment.