Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pinterest and algolia cdk test cases #1681

Merged
merged 4 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cdk/v2/bindings/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { TransformationError } = require("../../../v0/util");
const { InstrumentationError } = require("../../../v0/util/errorTypes");

const SUPPORTED_EVENT_TYPES = [
"track",
Expand Down Expand Up @@ -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);
}
}

Expand Down
60 changes: 30 additions & 30 deletions src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -131,7 +131,7 @@ steps:
"item_price": String(.price ?? prop.price)
})[]
}
else:
else:
name: singleProductFields
template: |
const props = .message.properties;
Expand Down Expand Up @@ -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
Expand Down