diff --git a/src/cdk/v2/bindings/default.js b/src/cdk/v2/bindings/default.js index fee8ede10ab..3bb0e285eb6 100644 --- a/src/cdk/v2/bindings/default.js +++ b/src/cdk/v2/bindings/default.js @@ -1,4 +1,4 @@ -const { TransformationError } = require("../../../v0/util"); +const { InstrumentationError } = require("../../../v0/util/errorTypes"); const SUPPORTED_EVENT_TYPES = [ "track", @@ -26,7 +26,7 @@ function isValidEventType(event) { function assert(val, message, status, statTags, destination) { if (!val) { - throw new TransformationError(message, status, statTags, destination); + throw new InstrumentationError(message, status, statTags, destination); } } diff --git a/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml b/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml index 825994c8a40..6f814935530 100644 --- a/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml +++ b/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml @@ -24,12 +24,12 @@ steps: $.assert(messageType, "Message type is not present. Aborting message."); $.assert(messageType in {{$.EventType.([.TRACK, .PAGE, .SCREEN])}}, "message type " + messageType + " is not supported") - + - name: validateInputForTrack description: Additional validation for Track events condition: $.outputs.messageType === {{$.EventType.TRACK}} template: | - $.assert(.message.event || .message.name, "event_name could not be mapped. Aborting.") + $.assert(.message.event || .message.name, "event_name could not be mapped. Aborting.") - name: commonFields description: | Builds common fields in destination payload. @@ -72,36 +72,36 @@ steps: - name: userFields description: Personally identifiable fields template: | - let gender = .message.traits.gender ?? .message.context.traits.gender; - gender = gender && ( - (gender in ["f", "F", "Female", "female", "FEMALE"] ? "f") ?? - (gender in ["m", "M", "Male", "male", "MALE"] ? "m": gender) - ); - let userFields = .message.().({ - "em": {{{{$.getGenericPaths("email")}}}}, - "ph": {{{{$.getGenericPaths("phone")}}}}, - "ge": gender, - "db": {{{{$.getGenericPaths("birthday")}}}}, - "ln": {{{{$.getGenericPaths("lastName")}}}}, - "fn": {{{{$.getGenericPaths("firstName")}}}}, - "ct": (.traits.address.city ?? .context.traits.address.city).toLowerCase(), - "st": (.traits.address.state ?? .context.traits.address.state).toLowerCase(), - "zp": .traits.address.zip ?? .context.traits.address.zip, - "country": (.traits.address.country ?? .context.traits.address.country).toLowerCase(), - "hashed_maids": .context.device.advertisingId, - "client_ip_address": .context.ip ?? .request_ip, - "client_user_agent": .context.userAgent - }); - userFields = $.removeUndefinedValues(userFields); - .destination.Config.sendingUnHashedData ? - $.processUserPayload(userFields) : - $.processHashedUserPayload(userFields, .message) + let gender = .message.traits.gender ?? .message.context.traits.gender; + gender = gender && ( + (gender in ["f", "F", "Female", "female", "FEMALE"] ? "f") ?? + (gender in ["m", "M", "Male", "male", "MALE"] ? "m": gender) + ); + let userFields = .message.().({ + "em": {{{{$.getGenericPaths("email")}}}}, + "ph": {{{{$.getGenericPaths("phone")}}}}, + "ge": gender, + "db": {{{{$.getGenericPaths("birthday")}}}}, + "ln": {{{{$.getGenericPaths("lastName")}}}}, + "fn": {{{{$.getGenericPaths("firstName")}}}}, + "ct": (.traits.address.city ?? .context.traits.address.city).toLowerCase(), + "st": (.traits.address.state ?? .context.traits.address.state).toLowerCase(), + "zp": .traits.address.zip ?? .context.traits.address.zip, + "country": (.traits.address.country ?? .context.traits.address.country).toLowerCase(), + "hashed_maids": .context.device.advertisingId, + "client_ip_address": .context.ip ?? .request_ip, + "client_user_agent": .context.userAgent + }); + userFields = $.removeUndefinedValues(userFields); + .destination.Config.sendingUnHashedData ? + $.processUserPayload(userFields) : + $.processHashedUserPayload(userFields, .message) - name: validateUserFields template: | const requiredFieldsCondition = $.outputs.userFields.().(.em || .hashed_maids || (.client_ip_address && .client_user_agent)); $.assert(requiredFieldsCondition, "It is required at least one of em, hashed_maids or" + - " pair of client_ip_address and client_user_agent.") - + " pair of client_ip_address and client_user_agent") + - name: ecomFields condition: $.outputs.messageType === {{$.EventType.TRACK}} steps: @@ -131,7 +131,7 @@ steps: "item_price": String(.price ?? prop.price) })[] } - else: + else: name: singleProductFields template: | const props = .message.properties; @@ -171,7 +171,7 @@ steps: - name: payload template: | $.outputs.eventNames.().({...$.outputs.basePayload, event_name: .})[] - + - name: buildResponse description: In batchMode we return payload directly condition: $.batchMode