Skip to content

Commit

Permalink
fix: small edit and adding test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Dec 18, 2023
1 parent 0c91d9c commit 8bbae29
Show file tree
Hide file tree
Showing 4 changed files with 3,564 additions and 166 deletions.
11 changes: 6 additions & 5 deletions src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ bindings:
path: ../../../../v0/util
- name: removeUndefinedAndNullAndEmptyValues
path: ../../../../v0/util
- name: validateEventName
path: ../../../../v0/util
steps:
- name: checkIfProcessed
condition: .message.statusCode
Expand Down Expand Up @@ -175,13 +177,13 @@ steps:
name: eventNamesForOthers
template: |
let event = .message.event ?? .message.name;
let stringifiedEvent = event.toString();
let eventInLowerCase = stringifiedEvent.toLowerCase();
$.validateEventName(event);
let eventInLowerCase = event.toLowerCase();
let eventNames = .destination.Config.eventsMapping.(){.from === event}.to[] ?? [];
eventNames = $.convertToSnakeCase(eventNames);
eventNames.length === 0 ? eventNames = $.ecomEventMaps.(){eventInLowerCase in .src}.dest[] ?? [];
(eventNames.length === 0 && .destination.Config.sendAsCustomEvent) ? eventNames = ["custom"];
eventNames.length === 0 ? eventNames = [event.toString()];
eventNames.length === 0 ? eventNames = [event];
eventNames;
- name: payload
Expand Down Expand Up @@ -227,7 +229,6 @@ steps:
name: buildResponseForProcessTransformationV5
description: build response using V5 API
template: |
console.log(JSON.stringify($.outputs.payload))
$.outputs.payload.().({
"body": {
"JSON": .,
Expand All @@ -245,4 +246,4 @@ steps:
},
"params": $.outputs.checkSendTestEventConfig,
"files": {}
})[]
})[]
4 changes: 3 additions & 1 deletion src/v0/destinations/pinterest_tag/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
isDefined,
getHashFromArrayWithDuplicate,
removeUndefinedAndNullValues,
validateEventName,
} = require('../../util');
const { COMMON_CONFIGS, CUSTOM_CONFIGS, API_VERSION } = require('./config');

Expand Down Expand Up @@ -166,10 +167,11 @@ const deduceTrackScreenEventName = (message, Config) => {
let eventName;
const { event, name } = message;
const { eventsMapping, sendAsCustomEvent } = Config;
const trackEventOrScreenName = event.toString() || name.toString();
const trackEventOrScreenName = event || name;
if (!trackEventOrScreenName) {
throw new InstrumentationError('event_name could not be mapped. Aborting');
}
validateEventName(trackEventOrScreenName);

/*
Step 1: If the event is not amongst the above list of ecommerce events, will look for
Expand Down
Loading

0 comments on commit 8bbae29

Please sign in to comment.