Skip to content

Commit

Permalink
fix: edit after primary dev testing
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Aug 19, 2024
1 parent 09d8437 commit 921fb38
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/cdk/v2/destinations/smartly/data/trackMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
{
"sourceKeys": ["properties.adUnitId", "properties.ad_unit_id"],
"required": true,
"destKey": "ad_unit_id"
"destKey": "ad_unit_id",
"metadata": {
"type": "toString"
}
},
{
"sourceKeys": ["properties.platform"],
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/smartly/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ steps:
- name: preparePayload
template: |
const payload = $.removeUndefinedAndNullValues($.constructPayload(.message, $.TRACK_CONFIG));
$.context.payloadList = $.getPayloads(.message.event, .destination.Config.eventsMapping, payload)
$.context.payloadList = $.getPayloads(.message.event, .destination.Config, payload)
- name: buildResponse
template: |
const response = $.buildResponseList($.context.payloadList)
Expand Down
11 changes: 6 additions & 5 deletions src/cdk/v2/destinations/smartly/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ const {
* @param {*} payload
* @returns
*/
const getPayloads = (event, eventsMapping, payload) => {
const getPayloads = (event, Config, payload) => {
if (!isDefinedAndNotNull(event) || typeof event !== 'string') {
throw new InstrumentationError('Event is not defined or is not String');
}
const eventsMap = getHashFromArrayWithDuplicate(eventsMapping);
const eventsMap = getHashFromArrayWithDuplicate(Config.eventsMapping);
// eventsMap = hashmap {"prop1":["val1","val2"],"prop2":["val2"]}
const eventList = Array.isArray(eventsMap[event.toLowerCase()])
? eventsMap[event.toLowerCase()]
: Array.from(eventsMap[event.toLowerCase()] || [event]);

const payloadLists = eventList.map((ev) => ({ ...payload, event: ev }));
const payloadLists = eventList.map((ev) => ({ ...payload, event_name: ev }));
return payloadLists;
};

const buildResponseList = (payloadList) =>
payloadList.map((payload) => {
const response = defaultRequestConfig();
response.body.JSON = payload;
response.endpoint = config.singleEventEndpoint;
response.endpoint = config.batchEndpoint;
response.method = 'POST';
return response;
});
Expand Down Expand Up @@ -78,7 +78,8 @@ const batchResponseBuilder = (events) => {
const batches = BatchUtils.chunkArrayBySizeAndLength(events, { maxItems: config.MAX_BATCH_SIZE });
const response = [];
batches.items.forEach((batch) => {
response.push(batchBuilder(batch, destination));
const batchedResponse = batchBuilder(batch, destination);
response.push(batchedResponse);
});
return response;
};
Expand Down
3 changes: 2 additions & 1 deletion src/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"WUNDERKIND": true,
"CLICKSEND": true,
"ZOHO": true,
"CORDIAL": true
"CORDIAL": true,
"SMARTLY": true
},
"regulations": [
"BRAZE",
Expand Down

0 comments on commit 921fb38

Please sign in to comment.