From 3bc290059ebe030b30bcca60877d4e07f1e75dd9 Mon Sep 17 00:00:00 2001 From: sandeepdigumarty Date: Wed, 28 Feb 2024 10:23:15 +0530 Subject: [PATCH 1/4] chore: fb app events v1 tests --- src/services/destination/nativeIntegration.ts | 6 +- .../destinations/fb/dataDelivery/business.ts | 287 ++++++++++++++++++ .../destinations/fb/dataDelivery/data.ts | 5 +- test/integrations/destinations/fb/network.ts | 6 +- 4 files changed, 299 insertions(+), 5 deletions(-) create mode 100644 test/integrations/destinations/fb/dataDelivery/business.ts diff --git a/src/services/destination/nativeIntegration.ts b/src/services/destination/nativeIntegration.ts index c33772d01d..2bb82fc602 100644 --- a/src/services/destination/nativeIntegration.ts +++ b/src/services/destination/nativeIntegration.ts @@ -209,7 +209,11 @@ export class NativeIntegrationDestinationService implements DestinationService { const jobStates = (deliveryRequest as ProxyV1Request).metadata.map( (metadata) => ({ - error: JSON.stringify(v0Response.destinationResponse?.response), + error: JSON.stringify( + v0Response.destinationResponse?.response === undefined + ? v0Response.destinationResponse + : v0Response.destinationResponse?.response, + ), statusCode: v0Response.status, metadata, }) as DeliveryJobState, diff --git a/test/integrations/destinations/fb/dataDelivery/business.ts b/test/integrations/destinations/fb/dataDelivery/business.ts new file mode 100644 index 0000000000..c87266b6b6 --- /dev/null +++ b/test/integrations/destinations/fb/dataDelivery/business.ts @@ -0,0 +1,287 @@ +import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; +import { ProxyV1TestData } from '../../../testTypes'; +import { VERSION } from '../../../../../src/v0/destinations/fb/config'; + +const statTags = { + destType: 'FB_CUSTOM_AUDIENCE', + destinationId: 'default-destinationId', + errorCategory: 'network', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + workspaceId: 'default-workspaceId', +}; + +const params = { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], + data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], + }, +}; + +export const testScenariosForV1API: ProxyV1TestData[] = [ + { + id: 'fb_v1_scenario_1', + name: 'fb', + description: 'app event fails due to access token error', + successCriteria: 'Should return 400 with invalid access token error', + scenario: 'Business', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=invalid_access_token`, + headers: { + 'x-forwarded-for': '1.2.3.4', + }, + params: { + destination: 'fb', + }, + FORM: { + event: 'CUSTOM_APP_EVENTS', + advertiser_id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R', + 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', + 'ud[fn]': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', + 'ud[ge]': '62c66a7a5dd70c3146618063c344e531e6d4b59e379808443ce962b3abd63c5a', + 'ud[ln]': '3547cb112ac4489af2310c0626cdba6f3097a2ad5a3b42ddd3b59c76c7a079a3', + 'ud[ph]': '588211a01b10feacbf7988d97a06e86c18af5259a7f457fd8759b7f7409a7d1f', + extinfo: + '["a2","","","","8.1.0","Redmi 6","","","Banglalink",640,480,"1.23",0,0,0,"Europe/Berlin"]', + app_user_id: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', + custom_events: + '[{"_logTime":1567333011693,"_eventName":"spin_result","_valueToSum":400,"fb_currency":"GBP","additional_bet_index":0,"battle_id":"N/A","bet_amount":9,"bet_level":1,"bet_multiplier":1,"coin_balance":9466052,"current_module_name":"CasinoGameModule","days_in_game":0,"extra_param":"N/A","fb_profile":"0","featureGameType":"N/A","game_fps":30,"game_id":"fireEagleBase","game_name":"FireEagleSlots","gem_balance":0,"graphicsQuality":"HD","idfa":"2bf99787-33d2-4ae2-a76a-c49672f97252","internetReachability":"ReachableViaLocalAreaNetwork","isLowEndDevice":"False","is_auto_spin":"False","is_turbo":"False","isf":"False","ishighroller":"False","jackpot_win_amount":90,"jackpot_win_type":"Silver","level":6,"lifetime_gem_balance":0,"no_of_spin":1,"player_total_battles":0,"player_total_shields":0,"start_date":"2019-08-01","total_payments":0,"tournament_id":"T1561970819","userId":"c82cbdff-e5be-4009-ac78-cdeea09ab4b1","versionSessionCount":2,"win_amount":0,"fb_content_id":["123","345","567"]}]', + advertiser_tracking_enabled: '0', + application_tracking_enabled: '0', + }, + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + status: 400, + message: 'Invalid OAuth 2.0 access token', + statTags: { + destType: 'FB', + errorCategory: 'dataValidation', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', + errorType: 'configuration', + meta: 'accessTokenExpired', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + }, + response: [ + { + error: 'Invalid OAuth 2.0 access token', + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + }, + }, + { + id: 'fb_v1_scenario_2', + name: 'fb', + description: 'app event sent successfully', + successCriteria: 'Should return 200', + scenario: 'Business', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=my_access_token`, + headers: { + 'x-forwarded-for': '1.2.3.4', + }, + params: { + destination: 'fb', + }, + FORM: { + event: 'CUSTOM_APP_EVENTS', + advertiser_id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R', + 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', + 'ud[fn]': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', + 'ud[ge]': '62c66a7a5dd70c3146618063c344e531e6d4b59e379808443ce962b3abd63c5a', + 'ud[ln]': '3547cb112ac4489af2310c0626cdba6f3097a2ad5a3b42ddd3b59c76c7a079a3', + 'ud[ph]': '588211a01b10feacbf7988d97a06e86c18af5259a7f457fd8759b7f7409a7d1f', + extinfo: + '["a2","","","","8.1.0","Redmi 6","","","Banglalink",640,480,"1.23",0,0,0,"Europe/Berlin"]', + app_user_id: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', + custom_events: + '[{"_logTime":1567333011693,"_eventName":"spin_result","_valueToSum":400,"fb_currency":"GBP","additional_bet_index":0,"battle_id":"N/A","bet_amount":9,"bet_level":1,"bet_multiplier":1,"coin_balance":9466052,"current_module_name":"CasinoGameModule","days_in_game":0,"extra_param":"N/A","fb_profile":"0","featureGameType":"N/A","game_fps":30,"game_id":"fireEagleBase","game_name":"FireEagleSlots","gem_balance":0,"graphicsQuality":"HD","idfa":"2bf99787-33d2-4ae2-a76a-c49672f97252","internetReachability":"ReachableViaLocalAreaNetwork","isLowEndDevice":"False","is_auto_spin":"False","is_turbo":"False","isf":"False","ishighroller":"False","jackpot_win_amount":90,"jackpot_win_type":"Silver","level":6,"lifetime_gem_balance":0,"no_of_spin":1,"player_total_battles":0,"player_total_shields":0,"start_date":"2019-08-01","total_payments":0,"tournament_id":"T1561970819","userId":"c82cbdff-e5be-4009-ac78-cdeea09ab4b1","versionSessionCount":2,"win_amount":0,"fb_content_id":["123","345","567"]}]', + advertiser_tracking_enabled: '0', + application_tracking_enabled: '0', + }, + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + status: 200, + message: 'Request Processed Successfully', + response: [ + { + error: '{"events_received":1,"fbtrace_id":"facebook_trace_id"}', + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + }, + }, + { + id: 'fb_v1_scenario_3', + name: 'fb', + description: 'app event fails due to invalid timestamp', + successCriteria: 'Should return 400 with invalid timestamp error', + scenario: 'Business', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=invalid_timestamp_correct_access_token`, + headers: { + 'x-forwarded-for': '1.2.3.4', + }, + params: { + destination: 'fb', + }, + FORM: { + event: 'CUSTOM_APP_EVENTS', + advertiser_id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R', + 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', + 'ud[fn]': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', + 'ud[ge]': '62c66a7a5dd70c3146618063c344e531e6d4b59e379808443ce962b3abd63c5a', + 'ud[ln]': '3547cb112ac4489af2310c0626cdba6f3097a2ad5a3b42ddd3b59c76c7a079a3', + 'ud[ph]': '588211a01b10feacbf7988d97a06e86c18af5259a7f457fd8759b7f7409a7d1f', + extinfo: + '["a2","","","","8.1.0","Redmi 6","","","Banglalink",640,480,"1.23",0,0,0,"Europe/Berlin"]', + app_user_id: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', + custom_events: + '[{"_logTime":1567333011693,"_eventName":"spin_result","_valueToSum":400,"fb_currency":"GBP","additional_bet_index":0,"battle_id":"N/A","bet_amount":9,"bet_level":1,"bet_multiplier":1,"coin_balance":9466052,"current_module_name":"CasinoGameModule","days_in_game":0,"extra_param":"N/A","fb_profile":"0","featureGameType":"N/A","game_fps":30,"game_id":"fireEagleBase","game_name":"FireEagleSlots","gem_balance":0,"graphicsQuality":"HD","idfa":"2bf99787-33d2-4ae2-a76a-c49672f97252","internetReachability":"ReachableViaLocalAreaNetwork","isLowEndDevice":"False","is_auto_spin":"False","is_turbo":"False","isf":"False","ishighroller":"False","jackpot_win_amount":90,"jackpot_win_type":"Silver","level":6,"lifetime_gem_balance":0,"no_of_spin":1,"player_total_battles":0,"player_total_shields":0,"start_date":"2019-08-01","total_payments":0,"tournament_id":"T1561970819","userId":"c82cbdff-e5be-4009-ac78-cdeea09ab4b1","versionSessionCount":2,"win_amount":0,"fb_content_id":["123","345","567"]}]', + advertiser_tracking_enabled: '0', + application_tracking_enabled: '0', + }, + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + status: 400, + message: 'Event Timestamp Too Old', + statTags: { + destType: 'FB', + errorCategory: 'network', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + }, + response: [ + { + error: 'Event Timestamp Too Old', + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + }, + }, + { + id: 'fb_v1_scenario_4', + name: 'fb', + description: 'app event fails due to missing permissions', + successCriteria: 'Should return 400 with missing permissions error', + scenario: 'Business', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=invalid_account_id_valid_access_token`, + headers: { + 'x-forwarded-for': '1.2.3.4', + }, + params: { + destination: 'fb', + }, + FORM: { + extinfo: '["a2","","","","8.1.0","Redmi 6","","","Banglalink",0,100,"50.00",0,0,0,""]', + custom_events: + '[{"_logTime":1567333011693,"_eventName":"Viewed Screen","fb_description":"Main.1233"}]', + 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', + advertiser_tracking_enabled: '0', + application_tracking_enabled: '0', + event: 'CUSTOM_APP_EVENTS', + }, + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + status: 400, + message: + "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", + statTags: { + destType: 'FB', + errorCategory: 'network', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + }, + response: [ + { + error: + "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", + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + }, + }, +]; diff --git a/test/integrations/destinations/fb/dataDelivery/data.ts b/test/integrations/destinations/fb/dataDelivery/data.ts index 3b37d03f46..b2aa6a967a 100644 --- a/test/integrations/destinations/fb/dataDelivery/data.ts +++ b/test/integrations/destinations/fb/dataDelivery/data.ts @@ -1,6 +1,7 @@ import { VERSION } from '../../../../../src/v0/destinations/fb/config'; +import { testScenariosForV1API } from './business'; -export const data = [ +export const existingTestData = [ { name: 'fb', description: 'Test 0', @@ -371,3 +372,5 @@ export const data = [ }, }, ]; + +export const data = [...existingTestData, ...testScenariosForV1API]; diff --git a/test/integrations/destinations/fb/network.ts b/test/integrations/destinations/fb/network.ts index 1a2f114d74..31bbaf0b6e 100644 --- a/test/integrations/destinations/fb/network.ts +++ b/test/integrations/destinations/fb/network.ts @@ -12,7 +12,7 @@ const fbPixelTcs = data return nw.httpReq.url === fbendpoint; })[0]; const clonedFbpTc = cloneDeep(fbpTc); - const clonedFormData = cloneDeep(d.input.request.body.body.FORM); + const clonedFormData = cloneDeep(d.input.request.body.body?.FORM); clonedFbpTc.httpReq.data = getFormData(clonedFormData).toString(); return clonedFbpTc; }); @@ -21,7 +21,7 @@ export const networkCallsData = [ { httpReq: { url: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=invalid_access_token`, - data: getFormData(data[0].input.request.body.body.FORM).toString(), + data: getFormData(data[0].input.request.body.body?.FORM).toString(), params: { destination: 'fb' }, headers: { 'User-Agent': 'RudderLabs' }, method: 'POST', @@ -41,7 +41,7 @@ export const networkCallsData = [ { httpReq: { url: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=my_access_token`, - data: getFormData(data[1].input.request.body.body.FORM).toString(), + data: getFormData(data[1].input.request.body.body?.FORM).toString(), params: { destination: 'fb' }, headers: { 'x-forwarded-for': '1.2.3.4', 'User-Agent': 'RudderLabs' }, method: 'POST', From efbd8d122c7bde4093397ad5bd82fb1e5f49c869 Mon Sep 17 00:00:00 2001 From: sandeepdigumarty Date: Wed, 28 Feb 2024 10:32:46 +0530 Subject: [PATCH 2/4] chore: fb app events v1 tests --- .../destinations/fb/dataDelivery/data.ts | 3 +- .../destinations/fb/dataDelivery/other.ts | 64 +++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 test/integrations/destinations/fb/dataDelivery/other.ts diff --git a/test/integrations/destinations/fb/dataDelivery/data.ts b/test/integrations/destinations/fb/dataDelivery/data.ts index b2aa6a967a..9ee19af265 100644 --- a/test/integrations/destinations/fb/dataDelivery/data.ts +++ b/test/integrations/destinations/fb/dataDelivery/data.ts @@ -1,5 +1,6 @@ import { VERSION } from '../../../../../src/v0/destinations/fb/config'; import { testScenariosForV1API } from './business'; +import { otherScenariosV1 } from './other'; export const existingTestData = [ { @@ -373,4 +374,4 @@ export const existingTestData = [ }, ]; -export const data = [...existingTestData, ...testScenariosForV1API]; +export const data = [...existingTestData, ...testScenariosForV1API, ...otherScenariosV1]; diff --git a/test/integrations/destinations/fb/dataDelivery/other.ts b/test/integrations/destinations/fb/dataDelivery/other.ts new file mode 100644 index 0000000000..28363d5a92 --- /dev/null +++ b/test/integrations/destinations/fb/dataDelivery/other.ts @@ -0,0 +1,64 @@ +import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; +import { ProxyV1TestData } from '../../../testTypes'; +import { VERSION } from '../../../../../src/v0/destinations/fb/config'; + +export const otherScenariosV1: ProxyV1TestData[] = [ + { + id: 'fb_v1_other_scenario_1', + name: 'fb', + description: 'user update request is throttled due to too many calls', + successCriteria: 'Should return 429 with message there have been too many calls', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=throttled_valid_access_token`, + params: { + destination: 'fb', + }, + FORM: { + extinfo: '["a2","","","","8.1.0","Redmi 6","","","Banglalink",0,100,"50.00",0,0,0,""]', + custom_events: + '[{"_logTime":1567333011693,"_eventName":"Viewed Screen","fb_description":"Main.1233"}]', + 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', + advertiser_tracking_enabled: '0', + application_tracking_enabled: '0', + event: 'CUSTOM_APP_EVENTS', + }, + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + status: 429, + message: 'API User Too Many Calls', + statTags: { + destType: 'FB', + errorCategory: 'network', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', + errorType: 'throttled', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + }, + response: [ + { + error: 'API User Too Many Calls', + statusCode: 429, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + }, + }, +]; From d5402a7d1fce20dbe0e6f8ed535fb2cac6996a7b Mon Sep 17 00:00:00 2001 From: sandeepdigumarty Date: Thu, 29 Feb 2024 11:10:19 +0530 Subject: [PATCH 3/4] chore: removed unused constants --- .../destinations/fb/dataDelivery/business.ts | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/test/integrations/destinations/fb/dataDelivery/business.ts b/test/integrations/destinations/fb/dataDelivery/business.ts index c87266b6b6..91a994a550 100644 --- a/test/integrations/destinations/fb/dataDelivery/business.ts +++ b/test/integrations/destinations/fb/dataDelivery/business.ts @@ -2,29 +2,6 @@ import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; import { ProxyV1TestData } from '../../../testTypes'; import { VERSION } from '../../../../../src/v0/destinations/fb/config'; -const statTags = { - destType: 'FB_CUSTOM_AUDIENCE', - destinationId: 'default-destinationId', - errorCategory: 'network', - errorType: 'aborted', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', - workspaceId: 'default-workspaceId', -}; - -const params = { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], - data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], - }, -}; - export const testScenariosForV1API: ProxyV1TestData[] = [ { id: 'fb_v1_scenario_1', From 78129d4580474e20414be74f5a2489b9443bc2eb Mon Sep 17 00:00:00 2001 From: sandeepdigumarty Date: Fri, 1 Mar 2024 19:27:42 +0530 Subject: [PATCH 4/4] chore: updated tests --- .../destinations/fb/dataDelivery/business.ts | 128 ++++++------------ .../destinations/fb/dataDelivery/other.ts | 19 +-- 2 files changed, 48 insertions(+), 99 deletions(-) diff --git a/test/integrations/destinations/fb/dataDelivery/business.ts b/test/integrations/destinations/fb/dataDelivery/business.ts index 91a994a550..156dc26572 100644 --- a/test/integrations/destinations/fb/dataDelivery/business.ts +++ b/test/integrations/destinations/fb/dataDelivery/business.ts @@ -2,6 +2,44 @@ import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; import { ProxyV1TestData } from '../../../testTypes'; import { VERSION } from '../../../../../src/v0/destinations/fb/config'; +export const testData1 = { + event: 'CUSTOM_APP_EVENTS', + advertiser_id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R', + 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', + 'ud[fn]': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', + 'ud[ge]': '62c66a7a5dd70c3146618063c344e531e6d4b59e379808443ce962b3abd63c5a', + 'ud[ln]': '3547cb112ac4489af2310c0626cdba6f3097a2ad5a3b42ddd3b59c76c7a079a3', + 'ud[ph]': '588211a01b10feacbf7988d97a06e86c18af5259a7f457fd8759b7f7409a7d1f', + extinfo: + '["a2","","","","8.1.0","Redmi 6","","","Banglalink",640,480,"1.23",0,0,0,"Europe/Berlin"]', + app_user_id: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', + custom_events: + '[{"_logTime":1567333011693,"_eventName":"spin_result","_valueToSum":400,"fb_currency":"GBP","additional_bet_index":0,"battle_id":"N/A","bet_amount":9,"bet_level":1,"bet_multiplier":1,"coin_balance":9466052,"current_module_name":"CasinoGameModule","days_in_game":0,"extra_param":"N/A","fb_profile":"0","featureGameType":"N/A","game_fps":30,"game_id":"fireEagleBase","game_name":"FireEagleSlots","gem_balance":0,"graphicsQuality":"HD","idfa":"2bf99787-33d2-4ae2-a76a-c49672f97252","internetReachability":"ReachableViaLocalAreaNetwork","isLowEndDevice":"False","is_auto_spin":"False","is_turbo":"False","isf":"False","ishighroller":"False","jackpot_win_amount":90,"jackpot_win_type":"Silver","level":6,"lifetime_gem_balance":0,"no_of_spin":1,"player_total_battles":0,"player_total_shields":0,"start_date":"2019-08-01","total_payments":0,"tournament_id":"T1561970819","userId":"c82cbdff-e5be-4009-ac78-cdeea09ab4b1","versionSessionCount":2,"win_amount":0,"fb_content_id":["123","345","567"]}]', + advertiser_tracking_enabled: '0', + application_tracking_enabled: '0', +}; + +export const testData2 = { + extinfo: '["a2","","","","8.1.0","Redmi 6","","","Banglalink",0,100,"50.00",0,0,0,""]', + custom_events: + '[{"_logTime":1567333011693,"_eventName":"Viewed Screen","fb_description":"Main.1233"}]', + 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', + advertiser_tracking_enabled: '0', + application_tracking_enabled: '0', + event: 'CUSTOM_APP_EVENTS', +}; + +export const statTags = { + destType: 'FB', + errorCategory: 'network', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', +}; + export const testScenariosForV1API: ProxyV1TestData[] = [ { id: 'fb_v1_scenario_1', @@ -22,22 +60,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ params: { destination: 'fb', }, - FORM: { - event: 'CUSTOM_APP_EVENTS', - advertiser_id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R', - 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', - 'ud[fn]': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', - 'ud[ge]': '62c66a7a5dd70c3146618063c344e531e6d4b59e379808443ce962b3abd63c5a', - 'ud[ln]': '3547cb112ac4489af2310c0626cdba6f3097a2ad5a3b42ddd3b59c76c7a079a3', - 'ud[ph]': '588211a01b10feacbf7988d97a06e86c18af5259a7f457fd8759b7f7409a7d1f', - extinfo: - '["a2","","","","8.1.0","Redmi 6","","","Banglalink",640,480,"1.23",0,0,0,"Europe/Berlin"]', - app_user_id: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', - custom_events: - '[{"_logTime":1567333011693,"_eventName":"spin_result","_valueToSum":400,"fb_currency":"GBP","additional_bet_index":0,"battle_id":"N/A","bet_amount":9,"bet_level":1,"bet_multiplier":1,"coin_balance":9466052,"current_module_name":"CasinoGameModule","days_in_game":0,"extra_param":"N/A","fb_profile":"0","featureGameType":"N/A","game_fps":30,"game_id":"fireEagleBase","game_name":"FireEagleSlots","gem_balance":0,"graphicsQuality":"HD","idfa":"2bf99787-33d2-4ae2-a76a-c49672f97252","internetReachability":"ReachableViaLocalAreaNetwork","isLowEndDevice":"False","is_auto_spin":"False","is_turbo":"False","isf":"False","ishighroller":"False","jackpot_win_amount":90,"jackpot_win_type":"Silver","level":6,"lifetime_gem_balance":0,"no_of_spin":1,"player_total_battles":0,"player_total_shields":0,"start_date":"2019-08-01","total_payments":0,"tournament_id":"T1561970819","userId":"c82cbdff-e5be-4009-ac78-cdeea09ab4b1","versionSessionCount":2,"win_amount":0,"fb_content_id":["123","345","567"]}]', - advertiser_tracking_enabled: '0', - application_tracking_enabled: '0', - }, + FORM: testData1, }), method: 'POST', }, @@ -50,15 +73,10 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ status: 400, message: 'Invalid OAuth 2.0 access token', statTags: { - destType: 'FB', + ...statTags, errorCategory: 'dataValidation', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', errorType: 'configuration', meta: 'accessTokenExpired', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', }, response: [ { @@ -91,22 +109,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ params: { destination: 'fb', }, - FORM: { - event: 'CUSTOM_APP_EVENTS', - advertiser_id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R', - 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', - 'ud[fn]': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', - 'ud[ge]': '62c66a7a5dd70c3146618063c344e531e6d4b59e379808443ce962b3abd63c5a', - 'ud[ln]': '3547cb112ac4489af2310c0626cdba6f3097a2ad5a3b42ddd3b59c76c7a079a3', - 'ud[ph]': '588211a01b10feacbf7988d97a06e86c18af5259a7f457fd8759b7f7409a7d1f', - extinfo: - '["a2","","","","8.1.0","Redmi 6","","","Banglalink",640,480,"1.23",0,0,0,"Europe/Berlin"]', - app_user_id: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', - custom_events: - '[{"_logTime":1567333011693,"_eventName":"spin_result","_valueToSum":400,"fb_currency":"GBP","additional_bet_index":0,"battle_id":"N/A","bet_amount":9,"bet_level":1,"bet_multiplier":1,"coin_balance":9466052,"current_module_name":"CasinoGameModule","days_in_game":0,"extra_param":"N/A","fb_profile":"0","featureGameType":"N/A","game_fps":30,"game_id":"fireEagleBase","game_name":"FireEagleSlots","gem_balance":0,"graphicsQuality":"HD","idfa":"2bf99787-33d2-4ae2-a76a-c49672f97252","internetReachability":"ReachableViaLocalAreaNetwork","isLowEndDevice":"False","is_auto_spin":"False","is_turbo":"False","isf":"False","ishighroller":"False","jackpot_win_amount":90,"jackpot_win_type":"Silver","level":6,"lifetime_gem_balance":0,"no_of_spin":1,"player_total_battles":0,"player_total_shields":0,"start_date":"2019-08-01","total_payments":0,"tournament_id":"T1561970819","userId":"c82cbdff-e5be-4009-ac78-cdeea09ab4b1","versionSessionCount":2,"win_amount":0,"fb_content_id":["123","345","567"]}]', - advertiser_tracking_enabled: '0', - application_tracking_enabled: '0', - }, + FORM: testData1, }), method: 'POST', }, @@ -149,22 +152,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ params: { destination: 'fb', }, - FORM: { - event: 'CUSTOM_APP_EVENTS', - advertiser_id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R', - 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', - 'ud[fn]': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', - 'ud[ge]': '62c66a7a5dd70c3146618063c344e531e6d4b59e379808443ce962b3abd63c5a', - 'ud[ln]': '3547cb112ac4489af2310c0626cdba6f3097a2ad5a3b42ddd3b59c76c7a079a3', - 'ud[ph]': '588211a01b10feacbf7988d97a06e86c18af5259a7f457fd8759b7f7409a7d1f', - extinfo: - '["a2","","","","8.1.0","Redmi 6","","","Banglalink",640,480,"1.23",0,0,0,"Europe/Berlin"]', - app_user_id: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', - custom_events: - '[{"_logTime":1567333011693,"_eventName":"spin_result","_valueToSum":400,"fb_currency":"GBP","additional_bet_index":0,"battle_id":"N/A","bet_amount":9,"bet_level":1,"bet_multiplier":1,"coin_balance":9466052,"current_module_name":"CasinoGameModule","days_in_game":0,"extra_param":"N/A","fb_profile":"0","featureGameType":"N/A","game_fps":30,"game_id":"fireEagleBase","game_name":"FireEagleSlots","gem_balance":0,"graphicsQuality":"HD","idfa":"2bf99787-33d2-4ae2-a76a-c49672f97252","internetReachability":"ReachableViaLocalAreaNetwork","isLowEndDevice":"False","is_auto_spin":"False","is_turbo":"False","isf":"False","ishighroller":"False","jackpot_win_amount":90,"jackpot_win_type":"Silver","level":6,"lifetime_gem_balance":0,"no_of_spin":1,"player_total_battles":0,"player_total_shields":0,"start_date":"2019-08-01","total_payments":0,"tournament_id":"T1561970819","userId":"c82cbdff-e5be-4009-ac78-cdeea09ab4b1","versionSessionCount":2,"win_amount":0,"fb_content_id":["123","345","567"]}]', - advertiser_tracking_enabled: '0', - application_tracking_enabled: '0', - }, + FORM: testData1, }), method: 'POST', }, @@ -176,16 +164,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ output: { status: 400, message: 'Event Timestamp Too Old', - statTags: { - destType: 'FB', - errorCategory: 'network', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', - errorType: 'aborted', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', - }, + statTags, response: [ { error: 'Event Timestamp Too Old', @@ -217,15 +196,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ params: { destination: 'fb', }, - FORM: { - extinfo: '["a2","","","","8.1.0","Redmi 6","","","Banglalink",0,100,"50.00",0,0,0,""]', - custom_events: - '[{"_logTime":1567333011693,"_eventName":"Viewed Screen","fb_description":"Main.1233"}]', - 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', - advertiser_tracking_enabled: '0', - application_tracking_enabled: '0', - event: 'CUSTOM_APP_EVENTS', - }, + FORM: testData2, }), method: 'POST', }, @@ -238,16 +209,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ status: 400, message: "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", - statTags: { - destType: 'FB', - errorCategory: 'network', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', - errorType: 'aborted', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', - }, + statTags, response: [ { error: diff --git a/test/integrations/destinations/fb/dataDelivery/other.ts b/test/integrations/destinations/fb/dataDelivery/other.ts index 28363d5a92..9ac3f14fb5 100644 --- a/test/integrations/destinations/fb/dataDelivery/other.ts +++ b/test/integrations/destinations/fb/dataDelivery/other.ts @@ -1,6 +1,7 @@ import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; import { ProxyV1TestData } from '../../../testTypes'; import { VERSION } from '../../../../../src/v0/destinations/fb/config'; +import { testData2 as testData, statTags } from './business'; export const otherScenariosV1: ProxyV1TestData[] = [ { @@ -19,15 +20,7 @@ export const otherScenariosV1: ProxyV1TestData[] = [ params: { destination: 'fb', }, - FORM: { - extinfo: '["a2","","","","8.1.0","Redmi 6","","","Banglalink",0,100,"50.00",0,0,0,""]', - custom_events: - '[{"_logTime":1567333011693,"_eventName":"Viewed Screen","fb_description":"Main.1233"}]', - 'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', - advertiser_tracking_enabled: '0', - application_tracking_enabled: '0', - event: 'CUSTOM_APP_EVENTS', - }, + FORM: testData, }), method: 'POST', }, @@ -40,14 +33,8 @@ export const otherScenariosV1: ProxyV1TestData[] = [ status: 429, message: 'API User Too Many Calls', statTags: { - destType: 'FB', - errorCategory: 'network', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', + ...statTags, errorType: 'throttled', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', }, response: [ {