Skip to content

Commit

Permalink
feat: introduces new user fields in titkok ads (#3575)
Browse files Browse the repository at this point in the history
* feat: introduces new user fields in titkok ads

* fix: add hashing 256 to first name , last name and zip code

* chore: address comments

* chore: fix lint
  • Loading branch information
anantjain45823 authored Jul 19, 2024
1 parent 1bef212 commit 6304abb
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/v0/destinations/tiktok_ads/data/TikTokTrackV2.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,41 @@
"destKey": "user.user_agent",
"sourceKeys": ["properties.context.user.userAgent", "context.userAgent"],
"required": false
},
{
"destKey": "user.first_name",
"sourceKeys": "firstName",
"metadata": {
"type": ["trim", "toLower", "hashToSha256"]
},
"sourceFromGenericMap": true
},
{
"destKey": "user.last_name",
"sourceKeys": "lastName",
"metadata": {
"type": ["trim", "toLower", "hashToSha256"]
},
"sourceFromGenericMap": true
},
{
"destKey": "user.city",
"sourceKeys": ["context.traits.city", "context.traits.address.city", "properties.city"]
},
{
"destKey": "user.country",
"sourceKeys": ["context.traits.country", "context.traits.address.country", "properties.country"]
},
{
"destKey": "user.state",
"sourceKeys": ["context.traits.address.state", "context.traits.state", "properties.state"]
},
{
"destKey": "user.zip_code",
"sourceKeys": "zipcode",
"sourceFromGenericMap": true,
"metadata": {
"type": ["removeSpacesAndDashes", "hashToSha256"]
}
}
]
1 change: 1 addition & 0 deletions src/v0/destinations/tiktok_ads/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const getContents = (message, getContentType = true) => {
price: product.price,
quantity: product.quantity,
description: product.description,
brand: product.brand,
};
contents.push(removeUndefinedAndNullValues(singleProduct));
});
Expand Down
5 changes: 5 additions & 0 deletions src/v0/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,11 @@ function formatValues(formattedVal, formattingType, typeFormat, integrationsObj)
curFormattedVal = formattedVal.trim();
}
},
removeSpacesAndDashes: () => {
if (typeof formattedVal === 'string') {
curFormattedVal = formattedVal.replace(/ /g, '').replace(/-/g, '');
}
},
};

if (formattingType in formattingFunctions) {
Expand Down
17 changes: 17 additions & 0 deletions test/integrations/destinations/tiktok_ads/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4619,6 +4619,7 @@ export const data = [
content_name: 'Monopoly',
price: 14,
quantity: 1,
brand: 'brand_name',
},
{
content_type: 'product_group',
Expand Down Expand Up @@ -6354,6 +6355,12 @@ export const data = [
context: {
traits: {
email: '[email protected]',
firstName: ' test',
lastName: 'user ',
country: 'dummycountry',
city: 'dummycity',
state: 'dummystate',
zip: ' US - 1234-',
},
page: {
url: 'http://demo.mywebsite.com/purchase',
Expand Down Expand Up @@ -6474,6 +6481,7 @@ export const data = [
{
price: 14,
quantity: 1,
brand: 'adidas',
content_category: 'Games',
content_id: '123',
content_name: 'Monopoly',
Expand All @@ -6493,6 +6501,15 @@ export const data = [
referrer: 'http://demo.mywebsite.com',
},
user: {
first_name:
'9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08',
last_name:
'04f8996da763b7a969b1028ee3007569eaf3a635486ddab211d512c85b9df8fb',
country: 'dummycountry',
zip_code:
'2a29b91aca86ff48c3defb1bbc2d33bf1da5ee5a235391322478fe7ff4503b77',
city: 'dummycity',
state: 'dummystate',
email: 'ee278943de84e5d6243578ee1a1057bcce0e50daad9755f45dfa64b60b13bc5d',
external_id: [
'3e0c7a51acd326b87f29596e38c22cbeb732df37bc5c8f5f524c14b55d3472db',
Expand Down

0 comments on commit 6304abb

Please sign in to comment.