Skip to content

Commit

Permalink
fix: add error handling for tiktok ads
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSudip committed Feb 29, 2024
1 parent 2761786 commit 5edd586
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/v0/destinations/tiktok_ads/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,10 @@ const getTrackResponse = (message, Config, event) => {

const trackResponseBuilder = async (message, { Config }) => {
const { eventsToStandard, sendCustomEvents } = Config;

let event = message.event?.toLowerCase().trim();
if (!event) {
throw new InstrumentationError('Event name is required');
if (!message.event || typeof message.event !== 'string') {
throw new InstrumentationError('Either event name is not present or it is not a string');
}

let event = message.event?.toLowerCase().trim();
const standardEventsMap = getHashFromArrayWithDuplicate(eventsToStandard);

if (!sendCustomEvents && eventNameMapping[event] === undefined && !standardEventsMap[event]) {
Expand Down
47 changes: 46 additions & 1 deletion test/integrations/destinations/tiktok_ads/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ export const data = [
body: [
{
statusCode: 400,
error: 'Event name is required',
error: 'Either event name is not present or it is not a string',
statTags: {
errorCategory: 'dataValidation',
errorType: 'instrumentation',
Expand Down Expand Up @@ -6973,4 +6973,49 @@ export const data = [
},
},
},
{
name: 'tiktok_ads',
description: 'Test 8',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
message: {
type: 'track',
event: 123,
},
destination: {
Config: {
accessToken: 'dummyAccessToken',
pixelCode: '{{PIXEL-CODE}}',
hashUserProperties: false,
},
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
statusCode: 400,
error: 'Either event name is not present or it is not a string',
statTags: {
errorCategory: 'dataValidation',
errorType: 'instrumentation',
destType: 'TIKTOK_ADS',
module: 'destination',
implementation: 'native',
feature: 'processor',
},
},
],
},
},
},
];

0 comments on commit 5edd586

Please sign in to comment.