Skip to content

Commit

Permalink
chore: refactor code and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwal-ab committed Oct 20, 2023
1 parent dbe89bf commit 6529776
Show file tree
Hide file tree
Showing 5 changed files with 831 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/cdk/v2/destinations/ortto/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ steps:
customEvent = event === .rsEventName ? .orttoEventName : null;
)
$.assert(customEvent, "Event names is not mapped");
customEvent = "act:cm:"+customEvent.trim().toLowerCase().replace(new RegExp('\\s+', 'g'),'-');
"act:cm:"+customEvent.trim().toLowerCase().replace(new RegExp('\\s+', 'g'),'-');
- name: getAttributes
template: |
Expand All @@ -101,8 +101,8 @@ steps:
"activity_id": $.outputs.prepareTrackPayload.getTrimmedEvent,
"attributes": $.outputs.prepareTrackPayload.getAttributes,
"location": {"source_ip": .message.context.ip}
}
const trackPayoad = {
};
{
"activities":[activityObj],
"merge_by": ["str::ei", "str::email"]
}
Expand All @@ -122,4 +122,4 @@ steps:
"X-Api-Key": .destination.Config.privateApiKey,
"Content-Type": "application/json"
};
finalResponse = response;
response;
15 changes: 10 additions & 5 deletions src/cdk/v2/destinations/ortto/rtWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ steps:
loopOverInput: true
- name: successfulEvents
template: |
$.outputs.transform#idx{ "output" in .}.({
"message": .output[],
$.outputs.transform#idx.output.({
"message": .[],
"destination": ^ [idx].destination,
"metadata": ^ [idx].metadata
})[]
Expand All @@ -34,12 +34,14 @@ steps:
- name: batchSuccessfulEvents
description: Batches the successfulEvents using V3 API
condition: $.outputs.successfulEvents.length
template: |
let batches = $.batchEvents($.outputs.successfulEvents);
console.log("abc",JSON.stringify(batches,null,2))
batches@batch.({
"batchedRequest": {
"body": {
"JSON": ~r batch.message,
"JSON": batch.message,
"JSON_ARRAY": {},
"XML": {},
"FORM": {}
Expand All @@ -55,11 +57,14 @@ steps:
"params": {},
"files": {}
},
"metadata": ~r batch.metadata,
"metadata": batch.metadata,
"batched": true,
"statusCode": 200,
"destination": ~r batch.destination
"destination": batch.destination
})[];
else:
name: returnEmptyOuput
template: '[]'

- name: finalPayload
template: |
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/ortto/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const groupEventsByEndpoint = (events) => {
const { destination, metadata } = result;
const message = CommonUtils.toArray(result.message);
message.forEach((msg) => {
const endpoint = Object.keys(eventMap).find((key) => msg.endpoint.includes(key));
const endpoint = Object.keys(eventMap).find((key) => msg.endpoint?.includes(key));
if (endpoint) {
eventMap[endpoint].push({ message: msg.body.JSON, destination, metadata });
}
Expand Down
3 changes: 2 additions & 1 deletion src/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"BRAZE": true,
"OPTIMIZELY_FULLSTACK": true,
"TWITTER_ADS": true,
"CLEVERTAP": true
"CLEVERTAP": true,
"ORTTO": true
}
}
Loading

0 comments on commit 6529776

Please sign in to comment.