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: add error handling for tiktok ads #3144

Merged
merged 5 commits into from Mar 4, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/v0/destinations/tiktok_ads/transform.js
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');
anantjain45823 marked this conversation as resolved.
Show resolved Hide resolved
}

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
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: 'Testing if the event name provided as a string or not',
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',
},
},
],
},
},
},
];