Skip to content

Commit

Permalink
chore: update default case handling in facebook destinations
Browse files Browse the repository at this point in the history
  • Loading branch information
Sai Sankeerth committed Nov 26, 2024
1 parent ed9fe55 commit bf9ef2a
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/v0/util/facebookUtils/networkHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ const errorDetailsMap = {
"Object with ID 'PIXEL_ID' / 'DATASET_ID' / 'AUDIENCE_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation",
)
.build(),
default: new ErrorDetailsExtractorBuilder().setStatus(400).setMessageField('message').build(),
default: new ErrorDetailsExtractorBuilder()
.setStatus(400)
.setMessageField('error_user_msg')
.build(),
},
1: {
// An unknown error occurred.
Expand Down
60 changes: 60 additions & 0 deletions test/integrations/destinations/facebook_pixel/dataDelivery/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,66 @@ export const v0TestData = [
},
},

{
name: 'facebook_pixel',
description: 'Test 10: should handle error with code: 100 & subcode: 2804009',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: {
body: {
XML: {},
FORM: testFormData,
JSON: {},
JSON_ARRAY: {},
},
type: 'REST',
files: {},
method: 'POST',
userId: '',
headers: {},
version: '1',
endpoint: `https://graph.facebook.com/${VERSION}/12345678912804009/events?access_token=2804009_valid_access_token`,
params: {
destination: 'facebook_pixel',
},
},
method: 'POST',
},
},
output: {
response: {
status: 400,
body: {
output: {
status: 400,
message:
'Your purchase event doesn’t include a value parameter. Enter a value. For example: 1.99',
destinationResponse: {
error: {
message: 'Invalid parameter',
type: 'OAuthException',
code: 100,
error_user_msg:
'Your purchase event doesn’t include a value parameter. Enter a value. For example: 1.99',
error_user_title: 'Missing Value for Purchase Event',
error_subcode: 2804009,
is_transient: false,
fbtrace_id: 'AP4G-xxxxxxxx',
},
status: 400,
},
statTags: {
...statTags,
errorType: 'aborted',
},
},
},
},
},
},
{
name: 'facebook_pixel',
description: 'Test 9: should handle error with code: 21009',
Expand Down
25 changes: 25 additions & 0 deletions test/integrations/destinations/facebook_pixel/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,29 @@ export const networkCallsData = [
statusText: 'OK',
},
},
{
httpReq: {
url: `https://graph.facebook.com/${VERSION}/12345678912804009/events?access_token=2804009_valid_access_token`,
data: getFormData(testFormData).toString(),
params: { destination: 'facebook_pixel' },
headers: { 'User-Agent': 'RudderLabs' },
method: 'POST',
},
httpRes: {
status: 400,
data: {
error: {
code: 100,
error_subcode: 2804009,
error_user_msg:
'Your purchase event doesn’t include a value parameter. Enter a value. For example: 1.99',
error_user_title: 'Missing Value for Purchase Event',
fbtrace_id: 'AP4G-xxxxxxxx',
is_transient: false,
message: 'Invalid parameter',
type: 'OAuthException',
},
},
},
},
];

0 comments on commit bf9ef2a

Please sign in to comment.