Skip to content

Commit

Permalink
fix: tiktok remove lowercasing for custom events
Browse files Browse the repository at this point in the history
  • Loading branch information
anantjain45823 committed Dec 18, 2023
1 parent 44755f3 commit 4063796
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/v0/destinations/tiktok_ads/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ const trackResponseBuilder = async (message, { Config }) => {
return responseList;
}
// Doc https://ads.tiktok.com/help/article/standard-events-parameters?lang=en
event = eventNameMapping[event] || event;
// For custom event we do not want to lower case the event or trim it we just want to send those as it is
event = eventNameMapping[event] || message.event;
// if there exists no event mapping we will build payload with custom event recieved
responseList.push(getTrackResponse(message, Config, event));

Expand Down
172 changes: 172 additions & 0 deletions test/integrations/destinations/tiktok_ads/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4952,4 +4952,176 @@ export const data = [
},
},
},
{
name: 'tiktok_ads',
description: 'Test 29 -> Camel Case Custom Event Pass',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
message: {
anonymousId: '21e13f4bc7ceddad',
channel: 'web',
context: {
app: {
build: '1.0.0',
name: 'RudderLabs JavaScript SDK',
namespace: 'com.rudderlabs.javascript',
version: '1.0.0',
},
library: {
name: 'RudderLabs JavaScript SDK',
version: '1.0.0',
},
userAgent:
'Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion',
ip: '13.57.97.131',
locale: 'en-US',
os: {
name: '',
version: '',
},
screen: {
density: 2,
},
externalId: [
{
type: 'tiktokExternalId',
id: 'f0e388f53921a51f0bb0fc8a2944109ec188b59172935d8f23020b1614cc44bc',
},
],
},
messageId: '84e26acc-56a5-4835-8233-591137fca468',
session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22',
originalTimestamp: '2019-10-14T09:03:17.562Z',
timestamp: '2020-09-17T19:49:27Z',
type: 'track',
event: 'customEvent',
properties: {
eventId: '1616318632825_357',
contents: [
{
price: 8,
quantity: 2,
content_type: 'socks',
content_id: '1077218',
},
{
price: 30,
quantity: 1,
content_type: 'dress',
content_id: '1197218',
},
],
clickId: 'dummyclickId',
currency: 'USD',
value: 46,
context: {
ad: {
callback: '123ATXSfe',
},
page: {
url: 'http://demo.mywebsite.com/purchase',
referrer: 'http://demo.mywebsite.com',
},
user: {
phone_number:
'2f9d2b4df907e5c9a7b3434351b55700167b998a83dc479b825096486ffcf4ea',
email: 'dd6ff77f54e2106661089bae4d40cdb600979bf7edc9eb65c0942ba55c7c2d7f',
},
},
},
integrations: {
All: true,
},
sentAt: '2019-10-14T09:03:22.563Z',
},
destination: {
Config: {
accessToken: 'dummyAccessToken',
pixelCode: 'A1T8T4UYGVIQA8ORZMX9',
hashUserProperties: false,
sendCustomEvents: true,
},
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
output: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://business-api.tiktok.com/open_api/v1.3/pixel/track/',
headers: {
'Access-Token': 'dummyAccessToken',
'Content-Type': 'application/json',
},
params: {},
body: {
JSON: {
pixel_code: 'A1T8T4UYGVIQA8ORZMX9',
event: 'customEvent',
event_id: '1616318632825_357',
timestamp: '2020-09-17T19:49:27Z',
properties: {
contents: [
{
price: 8,
quantity: 2,
content_type: 'socks',
content_id: '1077218',
},
{
price: 30,
quantity: 1,
content_type: 'dress',
content_id: '1197218',
},
],
currency: 'USD',
value: 46,
},
context: {
ad: {
callback: 'dummyclickId',
},
page: {
url: 'http://demo.mywebsite.com/purchase',
referrer: 'http://demo.mywebsite.com',
},
user: {
phone_number:
'2f9d2b4df907e5c9a7b3434351b55700167b998a83dc479b825096486ffcf4ea',
email: 'dd6ff77f54e2106661089bae4d40cdb600979bf7edc9eb65c0942ba55c7c2d7f',
external_id:
'f0e388f53921a51f0bb0fc8a2944109ec188b59172935d8f23020b1614cc44bc',
},
ip: '13.57.97.131',
user_agent:
'Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion',
},
partner_name: 'RudderStack',
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
userId: '',
},
statusCode: 200,
},
],
},
},
},
];

0 comments on commit 4063796

Please sign in to comment.