diff --git a/src/cdk/v2/destinations/smartly/data/trackMapping.json b/src/cdk/v2/destinations/smartly/data/trackMapping.json index 87d5a6538a..55ba437f12 100644 --- a/src/cdk/v2/destinations/smartly/data/trackMapping.json +++ b/src/cdk/v2/destinations/smartly/data/trackMapping.json @@ -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"], diff --git a/src/cdk/v2/destinations/smartly/procWorkflow.yaml b/src/cdk/v2/destinations/smartly/procWorkflow.yaml index 318c8a79b8..43c4783783 100644 --- a/src/cdk/v2/destinations/smartly/procWorkflow.yaml +++ b/src/cdk/v2/destinations/smartly/procWorkflow.yaml @@ -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) diff --git a/src/cdk/v2/destinations/smartly/utils.js b/src/cdk/v2/destinations/smartly/utils.js index c317bbe642..b2d6fd3f87 100644 --- a/src/cdk/v2/destinations/smartly/utils.js +++ b/src/cdk/v2/destinations/smartly/utils.js @@ -17,17 +17,17 @@ 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; }; @@ -35,7 +35,7 @@ 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; }); @@ -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; }; diff --git a/src/features.json b/src/features.json index 94e36a2416..8b3b0c4006 100644 --- a/src/features.json +++ b/src/features.json @@ -76,7 +76,8 @@ "WUNDERKIND": true, "CLICKSEND": true, "ZOHO": true, - "CORDIAL": true + "CORDIAL": true, + "SMARTLY": true }, "regulations": [ "BRAZE",