From 48e40b3f10a6dd040248a6bf6d938ccf2b6f191c Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Thu, 26 Oct 2023 19:19:59 +0530 Subject: [PATCH] chore: migrating intercom, braze, marketo_static_list, snapchat_custom_audience, fb, fbpixel, clevertap, criteo_audience --- test/__tests__/proxy.test.ts | 10 +- .../destinations/braze/dataDelivery/data.ts | 488 +++++++++++++++ .../destinations/braze/network.ts | 230 ++++++- .../clevertap/dataDelivery/data.ts | 227 +++++++ .../destinations/clevertap/network.ts | 91 ++- .../criteo_audience/dataDelivery/data.ts | 530 ++++++++++++++++ .../destinations/criteo_audience/network.ts | 230 +++++++ .../facebook_pixel/dataDelivery/data.ts | 585 ++++++++++++++++++ .../destinations/facebook_pixel/network.ts | 190 ++++++ .../destinations/fb/dataDelivery/data.ts | 357 +++++++++++ test/integrations/destinations/fb/network.ts | 52 ++ .../intercom/dataDelivery/data.ts | 90 +++ .../destinations/intercom/network.ts | 54 +- .../marketo_static_list/dataDelivery/data.ts | 368 +++++++++++ .../marketo_static_list/network.ts | 180 ++++++ .../dataDelivery/data.ts | 222 +++++++ .../snapchat_custom_audience/network.ts | 84 +++ 17 files changed, 3976 insertions(+), 12 deletions(-) create mode 100644 test/integrations/destinations/braze/dataDelivery/data.ts create mode 100644 test/integrations/destinations/clevertap/dataDelivery/data.ts create mode 100644 test/integrations/destinations/criteo_audience/dataDelivery/data.ts create mode 100644 test/integrations/destinations/criteo_audience/network.ts create mode 100644 test/integrations/destinations/facebook_pixel/dataDelivery/data.ts create mode 100644 test/integrations/destinations/facebook_pixel/network.ts create mode 100644 test/integrations/destinations/fb/dataDelivery/data.ts create mode 100644 test/integrations/destinations/fb/network.ts create mode 100644 test/integrations/destinations/intercom/dataDelivery/data.ts create mode 100644 test/integrations/destinations/marketo_static_list/dataDelivery/data.ts create mode 100644 test/integrations/destinations/snapchat_custom_audience/dataDelivery/data.ts create mode 100644 test/integrations/destinations/snapchat_custom_audience/network.ts diff --git a/test/__tests__/proxy.test.ts b/test/__tests__/proxy.test.ts index 70fbdfcae2..dabc84bab9 100644 --- a/test/__tests__/proxy.test.ts +++ b/test/__tests__/proxy.test.ts @@ -36,15 +36,7 @@ jest.mock('axios', () => jest.fn(mockedAxiosClient)); const version = '1'; const destinations = [ - 'braze', - 'facebook_pixel', - 'fb', - 'snapchat_custom_audience', - 'clevertap', - 'marketo_static_list', - 'criteo_audience', - 'tiktok_ads', - 'intercom', + 'tiktok_ads' ]; // start of generic tests diff --git a/test/integrations/destinations/braze/dataDelivery/data.ts b/test/integrations/destinations/braze/dataDelivery/data.ts new file mode 100644 index 0000000000..3e1805c01d --- /dev/null +++ b/test/integrations/destinations/braze/dataDelivery/data.ts @@ -0,0 +1,488 @@ +import MockAdapter from "axios-mock-adapter"; + +export const data = [ + { + "name": "braze", + "description": "Test 0", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://rest.iad-03.braze.com/users/identify/test1", + "method": "POST", + "userId": "gabi_userId_45", + "headers": { + "Accept": "application/json", + "Authorization": "Bearer api_key", + "Content-Type": "application/json" + }, + "body": { + "FORM": {}, + "JSON": { + "aliases_to_identify": [ + { + "external_id": "gabi_userId_45", + "user_alias": { + "alias_label": "rudder_id", + "alias_name": "gabi_anonId_45" + } + } + ] + }, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {}, + "params": { + "destination": "braze" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 200, + "body": { + "output": { + "status": 201, + "message": "Request for braze Processed Successfully", + "destinationResponse": { + "response": { + "aliases_processed": 1, + "message": "success" + }, + "status": 201 + } + } + } + } + } + }, + { + "name": "braze", + "description": "Test 1", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://rest.iad-03.braze.com/users/identify/test2", + "method": "POST", + "userId": "gabi_userId_45", + "headers": { + "Accept": "application/json", + "Authorization": "Bearer api_key", + "Content-Type": "application/json" + }, + "body": { + "FORM": {}, + "JSON": { + "aliases_to_identify": [ + { + "external_id": "gabi_userId_45", + "user_alias": { + "alias_label": "rudder_id", + "alias_name": "gabi_anonId_45" + } + } + ] + }, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {}, + "params": { + "destination": "braze" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 200, + "body": { + "output": { + "status": 201, + "message": "Request for braze Processed Successfully", + "destinationResponse": { + "response": { + "message": "success", + "errors": [ + "minor error message" + ] + }, + "status": 201 + } + } + } + } + } + }, + { + "name": "braze", + "description": "Test 2", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://rest.iad-03.braze.com/users/identify/test3", + "method": "POST", + "userId": "gabi_userId_45", + "headers": { + "Accept": "application/json", + "Authorization": "Bearer api_key", + "Content-Type": "application/json" + }, + "body": { + "FORM": {}, + "JSON": { + "aliases_to_identify": [ + { + "external_id": "gabi_userId_45", + "user_alias": { + "alias_label": "rudder_id", + "alias_name": "gabi_anonId_45" + } + } + ] + }, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {}, + "params": { + "destination": "braze" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 200, + "body": { + "output": { + "status": 201, + "message": "Request failed for braze with status: 201", + "destinationResponse": { + "response": { + "message": "fatal error message", + "errors": [ + "minor error message" + ] + }, + "status": 201 + }, + "statTags": { + "destType": "BRAZE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "aborted", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + }, + { + "name": "braze", + "description": "Test 3", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://rest.iad-03.braze.com/users/identify/test4", + "method": "POST", + "userId": "gabi_userId_45", + "headers": { + "Accept": "application/json", + "Authorization": "Bearer api_key", + "Content-Type": "application/json" + }, + "body": { + "FORM": {}, + "JSON": { + "aliases_to_identify": [ + { + "external_id": "gabi_userId_45", + "user_alias": { + "alias_label": "rudder_id", + "alias_name": "gabi_anonId_45" + } + } + ] + }, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {}, + "params": { + "destination": "braze" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 200, + "body": { + "output": { + "status": 201, + "message": "Request for braze Processed Successfully", + "destinationResponse": { + "response": "", + "status": 201 + } + } + } + } + } + }, + { + "name": "braze", + "description": "Test 4", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://rest.iad-03.braze.com/users/identify/test5", + "method": "POST", + "userId": "gabi_userId_45", + "headers": { + "Accept": "application/json", + "Authorization": "Bearer api_key", + "Content-Type": "application/json" + }, + "body": { + "FORM": {}, + "JSON": { + "aliases_to_identify": [ + { + "external_id": "gabi_userId_45", + "user_alias": { + "alias_label": "rudder_id", + "alias_name": "gabi_anonId_45" + } + } + ] + }, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {}, + "params": { + "destination": "braze" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 500, + "body": { + "output": { + "status": 500, + "message": "Request failed for braze with status: 500", + "destinationResponse": { + "response": "", + "status": 500 + }, + "statTags": { + "destType": "BRAZE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "retryable", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + }, + { + "name": "braze", + "description": "Test 5", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://rest.iad-03.braze.com/users/identify/test6", + "method": "POST", + "userId": "gabi_userId_45", + "headers": { + "Accept": "application/json", + "Authorization": "Bearer api_key", + "Content-Type": "application/json" + }, + "body": { + "FORM": {}, + "JSON": { + "aliases_to_identify": [ + { + "external_id": "gabi_userId_45", + "user_alias": { + "alias_label": "rudder_id", + "alias_name": "gabi_anonId_45" + } + } + ] + }, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {}, + "params": { + "destination": "braze" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 500, + "body": { + "output": { + "status": 500, + "message": "Request failed for braze with status: 500", + "destinationResponse": { + "response": "", + "status": 500 + }, + "statTags": { + "destType": "BRAZE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "retryable", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + }, + mockFns: (mockAdapter: MockAdapter) => { + // params has `{ destination: salesforce }` + mockAdapter + .onPost( + 'https://rest.iad-03.braze.com/users/identify/test6', + { + aliases_to_identify: [ + { + external_id: 'gabi_userId_45', + user_alias: { alias_label: 'rudder_id', alias_name: 'gabi_anonId_45' }, + }, + ], + }, + { + Accept: 'application/json', + Authorization: 'Bearer api_key', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + ).replyOnce((config) => { + // @ts-ignore + const err = AxiosError.from('DNS not found', 'ENOTFOUND', config) + return Promise.reject(err); + }); + } + }, + { + "name": "braze", + "description": "Test 6", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://rest.iad-03.braze.com/users/identify/test7", + "method": "POST", + "userId": "gabi_userId_45", + "headers": { + "Accept": "application/json", + "Authorization": "Bearer api_key", + "Content-Type": "application/json" + }, + "body": { + "FORM": {}, + "JSON": { + "aliases_to_identify": [ + { + "external_id": "gabi_userId_45", + "user_alias": { + "alias_label": "rudder_id", + "alias_name": "gabi_anonId_45" + } + } + ] + }, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {}, + "params": { + "destination": "braze" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 500, + "body": { + "output": { + "status": 500, + "message": "Request failed for braze with status: 500", + "destinationResponse": { + "response": "", + "status": 500 + }, + "statTags": { + "destType": "BRAZE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "retryable", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + } +] \ No newline at end of file diff --git a/test/integrations/destinations/braze/network.ts b/test/integrations/destinations/braze/network.ts index 4dfd5fa2a5..b907ce48c9 100644 --- a/test/integrations/destinations/braze/network.ts +++ b/test/integrations/destinations/braze/network.ts @@ -1,3 +1,231 @@ +import { AxiosError } from "axios"; + +const dataDeliveryMocksData = [ + { + httpReq: { + url: 'https://api.amplitude.com/2/httpapi/test5', + data: { + api_key: 'c9d8a13b8bcab46a547f7be5200c483d', + events: [ + { + app_name: 'Rudder-CleverTap_Example', + app_version: '1.0', + time: 1619006730330, + user_id: 'gabi_userId_45', + user_properties: { + Residence: 'Shibuya', + city: 'Tokyo', + country: 'JP', + email: 'gabi29@gmail.com', + gender: 'M', + name: 'User2 Gabi2', + organization: 'Company', + region: 'ABC', + title: 'Owner', + zip: '100-0001', + }, + }, + ], + options: { min_id_length: 1 }, + }, + params: { destination: 'any' }, + headers: { 'Content-Type': 'application/json', 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: { response: {} }, + }, + { + httpReq: { + url: 'https://api.amplitude.com/2/httpapi/test6', + data: { + api_key: 'c9d8a13b8bcab46a547f7be5200c483d', + events: [ + { + app_name: 'Rudder-CleverTap_Example', + app_version: '1.0', + time: 1619006730330, + user_id: 'gabi_userId_45', + user_properties: { + Residence: 'Shibuya', + city: 'Tokyo', + country: 'JP', + email: 'gabi29@gmail.com', + gender: 'M', + name: 'User2 Gabi2', + organization: 'Company', + region: 'ABC', + title: 'Owner', + zip: '100-0001', + }, + }, + ], + options: { min_id_length: 1 }, + }, + params: { destination: 'any' }, + headers: { 'Content-Type': 'application/json', 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: {}, + }, + { + httpReq: { + url: 'https://rest.iad-03.braze.com/users/identify/test1', + data: { + aliases_to_identify: [ + { + external_id: 'gabi_userId_45', + user_alias: { alias_label: 'rudder_id', alias_name: 'gabi_anonId_45' }, + }, + ], + }, + params: { destination: 'braze' }, + headers: { + Accept: 'application/json', + Authorization: 'Bearer api_key', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { data: { aliases_processed: 1, message: 'success' }, status: 201 }, + }, + { + httpReq: { + url: 'https://rest.iad-03.braze.com/users/identify/test2', + data: { + aliases_to_identify: [ + { + external_id: 'gabi_userId_45', + user_alias: { alias_label: 'rudder_id', alias_name: 'gabi_anonId_45' }, + }, + ], + }, + params: { destination: 'braze' }, + headers: { + Accept: 'application/json', + Authorization: 'Bearer api_key', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { data: { message: 'success', errors: ['minor error message'] }, status: 201 }, + }, + { + httpReq: { + url: 'https://rest.iad-03.braze.com/users/identify/test3', + data: { + aliases_to_identify: [ + { + external_id: 'gabi_userId_45', + user_alias: { alias_label: 'rudder_id', alias_name: 'gabi_anonId_45' }, + }, + ], + }, + params: { destination: 'braze' }, + headers: { + Accept: 'application/json', + Authorization: 'Bearer api_key', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { + data: { message: 'fatal error message', errors: ['minor error message'] }, + status: 201, + }, + }, + { + httpReq: { + url: 'https://rest.iad-03.braze.com/users/identify/test4', + data: { + aliases_to_identify: [ + { + external_id: 'gabi_userId_45', + user_alias: { alias_label: 'rudder_id', alias_name: 'gabi_anonId_45' }, + }, + ], + }, + params: { destination: 'braze' }, + headers: { + Accept: 'application/json', + Authorization: 'Bearer api_key', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { data: '', status: 201 }, + }, + { + httpReq: { + url: 'https://rest.iad-03.braze.com/users/identify/test5', + data: { + aliases_to_identify: [ + { + external_id: 'gabi_userId_45', + user_alias: { alias_label: 'rudder_id', alias_name: 'gabi_anonId_45' }, + }, + ], + }, + params: { destination: 'braze' }, + headers: { + Accept: 'application/json', + Authorization: 'Bearer api_key', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: {}, + }, + // { + // httpReq: { + // url: 'https://rest.iad-03.braze.com/users/identify/test6', + // data: { + // aliases_to_identify: [ + // { + // external_id: 'gabi_userId_45', + // user_alias: { alias_label: 'rudder_id', alias_name: 'gabi_anonId_45' }, + // }, + // ], + // }, + // params: { destination: 'braze' }, + // headers: { + // Accept: 'application/json', + // Authorization: 'Bearer api_key', + // 'Content-Type': 'application/json', + // 'User-Agent': 'RudderLabs', + // }, + // method: 'POST', + // }, + // httpRes: AxiosError.from('DNS not found', 'ENOTFOUND'), + // }, + { + httpReq: { + url: 'https://rest.iad-03.braze.com/users/identify/test7', + data: { + aliases_to_identify: [ + { + external_id: 'gabi_userId_45', + user_alias: { alias_label: 'rudder_id', alias_name: 'gabi_anonId_45' }, + }, + ], + }, + params: { destination: 'braze' }, + headers: { + Accept: 'application/json', + Authorization: 'Bearer api_key', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { response: {} }, + }, +]; + const deleteNwData = [ { httpReq: { @@ -188,4 +416,4 @@ const deleteNwData = [ }, }, ]; -export const networkCallsData = [...deleteNwData]; +export const networkCallsData = [...deleteNwData, ...dataDeliveryMocksData]; diff --git a/test/integrations/destinations/clevertap/dataDelivery/data.ts b/test/integrations/destinations/clevertap/dataDelivery/data.ts new file mode 100644 index 0000000000..bc8866823e --- /dev/null +++ b/test/integrations/destinations/clevertap/dataDelivery/data.ts @@ -0,0 +1,227 @@ +export const data = [ + { + "name": "clevertap", + "description": "Test 0", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://api.clevertap.com/1/upload/test1", + "headers": { + "X-CleverTap-Account-Id": "476550467", + "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "Content-Type": "application/json" + }, + "body": { + "JSON": { + "d": [ + { + "type": "profile", + "profileData": { + "Email": "jamesDoe@gmail.com", + "Name": "James Doe", + "Phone": "92374162212", + "Gender": "M", + "Employed": true, + "DOB": "1614775793", + "Education": "Science", + "Married": "Y", + "Customer Type": "Prime", + "graduate": true, + "msg_push": true, + "msgSms": true, + "msgemail": true, + "msgwhatsapp": false, + "custom_tags": "[\"Test_User\",\"Interested_User\",\"DIY_Hobby\"]", + "custom_mappings": "{\"Office\":\"Trastkiv\",\"Country\":\"Russia\"}", + "address": "{\"city\":\"kolkata\",\"country\":\"India\",\"postalCode\":789223,\"state\":\"WB\",\"street\":\"\"}" + }, + "identity": "anon_id" + } + ] + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {}, + "params": { + "destination": "clevertap" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 200, + "body": { + "output": { + "status": 200, + "message": "Request Processed Successfully", + "destinationResponse": { + "response": { + "status": "success", + "processed": 1, + "unprocessed": [] + }, + "status": 200 + } + } + } + } + } + }, + { + "name": "clevertap", + "description": "Test 1", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "FORM": {}, + "JSON": { + "d": [ + { + "identity": "anon-id-new", + "type": "event", + "evtName": "Web Page Viewed: Rudder", + "evtData": { + "title": "Home", + "path": "/" + } + } + ] + } + }, + "type": "REST", + "files": {}, + "method": "POST", + "headers": { + "X-CleverTap-Account-Id": "fakeId123", + "X-CleverTap-Passcode": "fakePasscode123", + "Content-Type": "application/json" + }, + "version": "1", + "endpoint": "https://api.clevertap.com/1/upload/test2", + "params": { + "destination": "clevertap" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 401, + "body": { + "output": { + "status": 401, + "message": "Request failed with status: 401", + "destinationResponse": { + "response": { + "status": "fail", + "error": "Invalid Credentials", + "code": 401 + }, + "status": 401 + }, + "statTags": { + "destType": "CLEVERTAP", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "aborted", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + }, + { + "name": "clevertap", + "description": "Test 2", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "FORM": {}, + "JSON": { + "d": [ + { + "identity": "anon-id-new", + "type": "event", + "evtData": { + "title": "Home", + "path": "/" + } + } + ] + } + }, + "type": "REST", + "files": {}, + "method": "POST", + "headers": { + "X-CleverTap-Account-Id": "476550467", + "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "Content-Type": "application/json" + }, + "version": "1", + "endpoint": "https://api.clevertap.com/1/upload/test3", + "params": { + "destination": "clevertap" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 400, + "body": { + "output": { + "status": 400, + "message": "Request failed with status: 200", + "destinationResponse": { + "response": { + "status": "fail", + "processed": 0, + "unprocessed": [] + }, + "status": 200 + }, + "statTags": { + "destType": "CLEVERTAP", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "aborted", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + } +] \ No newline at end of file diff --git a/test/integrations/destinations/clevertap/network.ts b/test/integrations/destinations/clevertap/network.ts index 458d6faba0..c4eb23ee39 100644 --- a/test/integrations/destinations/clevertap/network.ts +++ b/test/integrations/destinations/clevertap/network.ts @@ -1,3 +1,92 @@ +const dataDeliveryMocksData = [ + { + httpReq: { + url: 'https://api.clevertap.com/1/upload/test1', + data: { + d: [ + { + type: 'profile', + profileData: { + Email: 'jamesDoe@gmail.com', + Name: 'James Doe', + Phone: '92374162212', + Gender: 'M', + Employed: true, + DOB: '1614775793', + Education: 'Science', + Married: 'Y', + 'Customer Type': 'Prime', + graduate: true, + msg_push: true, + msgSms: true, + msgemail: true, + msgwhatsapp: false, + custom_tags: '["Test_User","Interested_User","DIY_Hobby"]', + custom_mappings: '{"Office":"Trastkiv","Country":"Russia"}', + address: + '{"city":"kolkata","country":"India","postalCode":789223,"state":"WB","street":""}', + }, + identity: 'anon_id', + }, + ], + }, + params: { destination: 'clevertap' }, + headers: { + 'X-CleverTap-Account-Id': '476550467', + 'X-CleverTap-Passcode': + 'fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { data: { status: 'success', processed: 1, unprocessed: [] }, status: 200 }, + }, + { + httpReq: { + url: 'https://api.clevertap.com/1/upload/test2', + data: { + d: [ + { + identity: 'anon-id-new', + type: 'event', + evtName: 'Web Page Viewed: Rudder', + evtData: { title: 'Home', path: '/' }, + }, + ], + }, + params: { destination: 'clevertap' }, + headers: { + 'X-CleverTap-Account-Id': 'fakeId123', + 'X-CleverTap-Passcode': 'fakePasscode123', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { + data: { status: 'fail', error: 'Invalid Credentials', code: 401 }, status: 401 + }, + }, + { + httpReq: { + url: 'https://api.clevertap.com/1/upload/test3', + data: { + d: [{ identity: 'anon-id-new', type: 'event', evtData: { title: 'Home', path: '/' } }], + }, + params: { destination: 'clevertap' }, + headers: { + 'X-CleverTap-Account-Id': '476550467', + 'X-CleverTap-Passcode': + 'fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { data: { status: 'fail', processed: 0, unprocessed: [] }, status: 200 }, + }, +]; const deleteNwData = [ { httpReq: { @@ -172,4 +261,4 @@ const deleteNwData = [ }, }, ]; -export const networkCallsData = [...deleteNwData]; +export const networkCallsData = [...deleteNwData, ...dataDeliveryMocksData]; diff --git a/test/integrations/destinations/criteo_audience/dataDelivery/data.ts b/test/integrations/destinations/criteo_audience/dataDelivery/data.ts new file mode 100644 index 0000000000..bc3af8f22d --- /dev/null +++ b/test/integrations/destinations/criteo_audience/dataDelivery/data.ts @@ -0,0 +1,530 @@ +export const data = [ + { + "name": "criteo_audience", + "description": "Test 0", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "PATCH", + "endpoint": "https://api.criteo.com/2022-10/audiences/34894/contactlist", + "headers": { + "Authorization": "Bearer success_access_token", + "Content-Type": "application/json", + "Accept": "application/json" + }, + "body": { + "JSON": { + "data": { + "type": "ContactlistAmendment", + "attributes": { + "operation": "remove", + "identifierType": "gum", + "identifiers": [ + "sample_gum3" + ], + "internalIdentifiers": false, + "gumCallerId": "329739" + } + } + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {}, + "params": { + "destination": "criteo_audience" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 200, + "body": { + "output": { + "status": 200, + "message": "Request Processed Successfully", + "destinationResponse": { + "response": "", + "status": 200 + } + } + } + } + } + }, + { + "name": "criteo_audience", + "description": "Test 1", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "PATCH", + "endpoint": "https://api.criteo.com/2022-10/audiences/3485/contactlist", + "headers": { + "Authorization": "Bearer success_access_token", + "Content-Type": "application/json", + "Accept": "application/json" + }, + "body": { + "JSON": { + "data": { + "type": "ContactlistAmendment", + "attributes": { + "operation": "add", + "identifierType": "madid", + "identifiers": [ + "sample_madid", + "sample_madid_1", + "sample_madid_2" + ], + "internalIdentifiers": false + } + } + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {}, + "params": { + "destination": "criteo_audience" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 401, + "body": { + "output": { + "status": 401, + "authErrorCategory": "REFRESH_TOKEN", + "destinationResponse": { + "errors": [ + { + "traceIdentifier": "80a1a0ba3981b04da847d05700752c77", + "type": "authorization", + "code": "authorization-token-expired", + "instance": "/2022-10/audiences/123/contactlist", + "title": "The authorization token has expired" + } + ] + }, + "message": "The authorization token has expired during criteo_audience response transformation", + "statTags": { + "destType": "CRITEO_AUDIENCE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "aborted", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + }, + { + "name": "criteo_audience", + "description": "Test 2", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "PATCH", + "endpoint": "https://api.criteo.com/2022-10/audiences/34895/contactlist", + "headers": { + "Authorization": "Bearer success_access_token", + "Content-Type": "application/json", + "Accept": "application/json" + }, + "body": { + "JSON": { + "data": { + "type": "ContactlistAmendment", + "attributes": { + "operation": "add", + "identifierType": "madid", + "identifiers": [ + "sample_madid", + "sample_madid_1", + "sample_madid_2" + ], + "internalIdentifiers": false + } + } + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {}, + "params": { + "destination": "criteo_audience" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 401, + "body": { + "output": { + "status": 401, + "authErrorCategory": "REFRESH_TOKEN", + "destinationResponse": { + "errors": [ + { + "traceIdentifier": "80a1a0ba3981b04da847d05700752c77", + "type": "authorization", + "code": "authorization-token-invalid", + "instance": "/2022-10/audiences/123/contactlist", + "title": "The authorization header is invalid" + } + ] + }, + "message": "The authorization header is invalid during criteo_audience response transformation", + "statTags": { + "destType": "CRITEO_AUDIENCE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "aborted", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + }, + { + "name": "criteo_audience", + "description": "Test 3", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "PATCH", + "endpoint": "https://api.criteo.com/2022-10/audiences/34896/contactlist", + "headers": { + "Authorization": "Bearer success_access_token", + "Content-Type": "application/json", + "Accept": "application/json" + }, + "body": { + "JSON": { + "data": { + "type": "ContactlistAmendment", + "attributes": { + "operation": "add", + "identifierType": "madid", + "identifiers": [ + "sample_madid", + "sample_madid_1", + "sample_madid_2" + ], + "internalIdentifiers": false + } + } + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {}, + "params": { + "destination": "criteo_audience" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 400, + "body": { + "output": { + "message": "AudienceId is Invalid. Please Provide Valid AudienceId", + "destinationResponse": { + "response": { + "errors": [ + { + "code": "audience-invalid", + "traceIdentifier": "80a1a0ba3981b04da847d05700752c77", + "type": "authorization" + } + ] + }, + "status": 404 + }, + "statTags": { + "destType": "CRITEO_AUDIENCE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "aborted", + "feature": "dataDelivery", + "implementation": "native", + "meta": "instrumentation", + "module": "destination" + }, + "status": 400 + } + } + } + } + }, + { + "name": "criteo_audience", + "description": "Test 4", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "PATCH", + "endpoint": "https://api.criteo.com/2022-10/audiences/34897/contactlist", + "headers": { + "Authorization": "Bearer success_access_token", + "Content-Type": "application/json", + "Accept": "application/json" + }, + "body": { + "JSON": { + "data": { + "type": "ContactlistAmendment", + "attributes": { + "operation": "add", + "identifierType": "madid", + "identifiers": [ + "sample_madid", + "sample_madid_1", + "sample_madid_2" + ], + "internalIdentifiers": false + } + } + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {}, + "params": { + "destination": "criteo_audience" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 500, + "body": { + "output": { + "destinationResponse": { + "response": { + "errors": [ + { + "code": "audience-invalid", + "traceIdentifier": "80a1a0ba3981b04da847d05700752c77", + "type": "authorization" + } + ] + }, + "status": 503 + }, + "message": "Request Failed: during criteo_audience response transformation (Retryable)", + "statTags": { + "destType": "CRITEO_AUDIENCE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "feature": "dataDelivery", + "implementation": "native", + "errorType": "retryable", + "module": "destination" + }, + "status": 500 + } + } + } + } + }, + { + "name": "criteo_audience", + "description": "Test 5", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "PATCH", + "endpoint": "https://api.criteo.com/2022-10/audiences/34898/contactlist", + "headers": { + "Authorization": "Bearer success_access_token", + "Content-Type": "application/json", + "Accept": "application/json" + }, + "body": { + "JSON": { + "data": { + "type": "ContactlistAmendment", + "attributes": { + "operation": "add", + "identifierType": "madid", + "identifiers": [ + "sample_madid", + "sample_madid_1", + "sample_madid_2" + ], + "internalIdentifiers": false + } + } + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {}, + "params": { + "destination": "criteo_audience" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 429, + "body": { + "output": { + "destinationResponse": { + "response": {}, + "status": 429 + }, + "message": "Request Failed: during criteo_audience response transformation - due to Request Limit exceeded, (Throttled)", + "statTags": { + "destType": "CRITEO_AUDIENCE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "throttled", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + }, + "status": 429 + } + } + } + } + }, + { + "name": "criteo_audience", + "description": "Test 6", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "PATCH", + "endpoint": "https://api.criteo.com/2022-10/audiences/34899/contactlist", + "headers": { + "Authorization": "Bearer success_access_token", + "Content-Type": "application/json", + "Accept": "application/json" + }, + "body": { + "JSON": { + "data": { + "type": "ContactlistAmendment", + "attributes": { + "operation": "add", + "identifierType": "madid", + "identifiers": [ + "sample_madid", + "sample_madid_1", + "sample_madid_2" + ], + "internalIdentifiers": false + } + } + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {}, + "params": { + "destination": "criteo_audience" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 400, + "body": { + "output": { + "destinationResponse": { + "response": { + "message": "unknown error" + }, + "status": 410 + }, + "message": "Request Failed: during criteo_audience response transformation with status \"410\" due to \"{\"message\":\"unknown error\"}\", (Aborted) ", + "statTags": { + "destType": "CRITEO_AUDIENCE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "aborted", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + }, + "status": 400 + } + } + } + } + } +] \ No newline at end of file diff --git a/test/integrations/destinations/criteo_audience/network.ts b/test/integrations/destinations/criteo_audience/network.ts new file mode 100644 index 0000000000..959e8a2112 --- /dev/null +++ b/test/integrations/destinations/criteo_audience/network.ts @@ -0,0 +1,230 @@ +export const networkCallsData = [ + { + httpReq: { + url: 'https://api.criteo.com/2022-10/audiences/34894/contactlist', + data: { + data: { + type: 'ContactlistAmendment', + attributes: { + operation: 'remove', + identifierType: 'gum', + identifiers: ['sample_gum3'], + internalIdentifiers: false, + gumCallerId: '329739', + }, + }, + }, + params: { destination: 'criteo_audience' }, + headers: { + Authorization: 'Bearer success_access_token', + 'Content-Type': 'application/json', + Accept: 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'PATCH', + }, + httpRes: { status: 200 }, + }, + { + httpReq: { + url: 'https://api.criteo.com/2022-10/audiences/3485/contactlist', + data: { + data: { + type: 'ContactlistAmendment', + attributes: { + operation: 'add', + identifierType: 'madid', + identifiers: ['sample_madid', 'sample_madid_1', 'sample_madid_2'], + internalIdentifiers: false, + }, + }, + }, + params: { destination: 'criteo_audience' }, + headers: { + Authorization: 'Bearer success_access_token', + 'Content-Type': 'application/json', + Accept: 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'PATCH', + }, + httpRes: { + code: '400', + data: { + errors: [ + { + traceIdentifier: '80a1a0ba3981b04da847d05700752c77', + type: 'authorization', + code: 'authorization-token-expired', + instance: '/2022-10/audiences/123/contactlist', + title: 'The authorization token has expired', + }, + ], + }, + status: 401, + }, + }, + { + httpReq: { + url: 'https://api.criteo.com/2022-10/audiences/34895/contactlist', + data: { + data: { + type: 'ContactlistAmendment', + attributes: { + operation: 'add', + identifierType: 'madid', + identifiers: ['sample_madid', 'sample_madid_1', 'sample_madid_2'], + internalIdentifiers: false, + }, + }, + }, + params: { destination: 'criteo_audience' }, + headers: { + Authorization: 'Bearer success_access_token', + 'Content-Type': 'application/json', + Accept: 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'PATCH', + }, + httpRes: { + code: '400', + data: { + errors: [ + { + traceIdentifier: '80a1a0ba3981b04da847d05700752c77', + type: 'authorization', + code: 'authorization-token-invalid', + instance: '/2022-10/audiences/123/contactlist', + title: 'The authorization header is invalid', + }, + ], + }, + status: 401, + }, + }, + { + httpReq: { + url: 'https://api.criteo.com/2022-10/audiences/34896/contactlist', + data: { + data: { + type: 'ContactlistAmendment', + attributes: { + operation: 'add', + identifierType: 'madid', + identifiers: ['sample_madid', 'sample_madid_1', 'sample_madid_2'], + internalIdentifiers: false, + }, + }, + }, + params: { destination: 'criteo_audience' }, + headers: { + Authorization: 'Bearer success_access_token', + 'Content-Type': 'application/json', + Accept: 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'PATCH', + }, + httpRes: { + code: '400', + data: { + errors: [ + { + traceIdentifier: '80a1a0ba3981b04da847d05700752c77', + type: 'authorization', + code: 'audience-invalid', + }, + ], + }, + status: 404, + }, + }, + { + httpReq: { + url: 'https://api.criteo.com/2022-10/audiences/34897/contactlist', + data: { + data: { + type: 'ContactlistAmendment', + attributes: { + operation: 'add', + identifierType: 'madid', + identifiers: ['sample_madid', 'sample_madid_1', 'sample_madid_2'], + internalIdentifiers: false, + }, + }, + }, + params: { destination: 'criteo_audience' }, + headers: { + Authorization: 'Bearer success_access_token', + 'Content-Type': 'application/json', + Accept: 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'PATCH', + }, + httpRes: { + code: '500', + data: { + errors: [ + { + traceIdentifier: '80a1a0ba3981b04da847d05700752c77', + type: 'authorization', + code: 'audience-invalid', + }, + ], + }, + status: 503, + }, + }, + { + httpReq: { + url: 'https://api.criteo.com/2022-10/audiences/34898/contactlist', + data: { + data: { + type: 'ContactlistAmendment', + attributes: { + operation: 'add', + identifierType: 'madid', + identifiers: ['sample_madid', 'sample_madid_1', 'sample_madid_2'], + internalIdentifiers: false, + }, + }, + }, + params: { destination: 'criteo_audience' }, + headers: { + Authorization: 'Bearer success_access_token', + 'Content-Type': 'application/json', + Accept: 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'PATCH', + }, + httpRes: { code: '429', data: {}, status: 429 }, + }, + { + httpReq: { + url: 'https://api.criteo.com/2022-10/audiences/34899/contactlist', + data: { + data: { + type: 'ContactlistAmendment', + attributes: { + operation: 'add', + identifierType: 'madid', + identifiers: ['sample_madid', 'sample_madid_1', 'sample_madid_2'], + internalIdentifiers: false, + }, + }, + }, + params: { destination: 'criteo_audience' }, + headers: { + Authorization: 'Bearer success_access_token', + 'Content-Type': 'application/json', + Accept: 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'PATCH', + }, + httpRes: { code: '400', data: { message: 'unknown error' }, status: 410 }, + }, +]; diff --git a/test/integrations/destinations/facebook_pixel/dataDelivery/data.ts b/test/integrations/destinations/facebook_pixel/dataDelivery/data.ts new file mode 100644 index 0000000000..e4e4a7d4c8 --- /dev/null +++ b/test/integrations/destinations/facebook_pixel/dataDelivery/data.ts @@ -0,0 +1,585 @@ +export const data = [ + { + name: 'facebook_pixel', + description: 'Test 0', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + body: { + XML: {}, + FORM: { + data: [ + '{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654773112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}', + ], + }, + JSON: {}, + JSON_ARRAY: {}, + }, + type: 'REST', + files: {}, + method: 'POST', + userId: '', + headers: {}, + version: '1', + endpoint: + 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=invalid_access_token', + params: { + destination: 'facebook_pixel', + }, + }, + method: 'POST', + }, + }, + output: { + response: { + status: 400, + body: { + output: { + status: 400, + message: 'Invalid OAuth 2.0 access token', + destinationResponse: { + error: { + message: 'The access token could not be decrypted', + type: 'OAuthException', + code: 190, + fbtrace_id: 'fbpixel_trace_id', + }, + status: 500, + }, + statTags: { + destType: 'FACEBOOK_PIXEL', + errorCategory: 'network', + destinationId: 'Non-determininable', + workspaceId: 'Non-determininable', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + }, + }, + }, + }, + }, + }, + { + name: 'facebook_pixel', + description: 'Test 1', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + body: { + XML: {}, + FORM: { + data: [ + '{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654773112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}', + ], + }, + JSON: {}, + JSON_ARRAY: {}, + }, + type: 'REST', + files: {}, + method: 'POST', + userId: '', + headers: {}, + version: '1', + endpoint: + 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=my_access_token', + params: { + destination: 'facebook_pixel', + }, + }, + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + status: 200, + message: 'Request Processed Successfully', + destinationResponse: { + events_received: 1, + fbtrace_id: 'facebook_trace_id', + }, + }, + }, + }, + }, + }, + { + name: 'facebook_pixel', + description: 'Test 2', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + body: { + XML: {}, + FORM: { + data: [ + '{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}', + ], + }, + JSON: {}, + JSON_ARRAY: {}, + }, + type: 'REST', + files: {}, + method: 'POST', + userId: '', + headers: {}, + version: '1', + endpoint: + 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=invalid_timestamp_correct_access_token', + params: { + destination: 'facebook_pixel', + }, + }, + method: 'POST', + }, + }, + output: { + response: { + status: 400, + body: { + output: { + status: 400, + message: 'Event Timestamp Too Old', + destinationResponse: { + error: { + message: 'Invalid parameter', + type: 'OAuthException', + code: 100, + error_subcode: 2804003, + is_transient: false, + error_user_title: 'Event Timestamp Too Old', + error_user_msg: + 'The timestamp for this event is too far in the past. Events need to be sent from your server within 7 days of when they occurred. Enter a timestamp that has occurred within the last 7 days.', + fbtrace_id: 'A6UyEgg_HdoiRX9duxcBOjb', + }, + status: 400, + }, + statTags: { + destType: 'FACEBOOK_PIXEL', + errorCategory: 'network', + destinationId: 'Non-determininable', + workspaceId: 'Non-determininable', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + }, + }, + }, + }, + }, + }, + { + name: 'facebook_pixel', + description: 'Test 3', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + body: { + XML: {}, + FORM: { + data: [ + '{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}', + ], + }, + JSON: {}, + JSON_ARRAY: {}, + }, + type: 'REST', + files: {}, + method: 'POST', + userId: '', + headers: {}, + version: '1', + endpoint: + 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=throttled_valid_access_token', + params: { + destination: 'facebook_pixel', + }, + }, + method: 'POST', + }, + }, + output: { + response: { + status: 429, + body: { + output: { + status: 429, + message: 'API User Too Many Calls', + destinationResponse: { + error: { + message: 'User request limit reached', + type: 'OAuthException', + code: 17, + fbtrace_id: 'facebook_px_trace_id_4', + }, + status: 500, + }, + statTags: { + destType: 'FACEBOOK_PIXEL', + errorCategory: 'network', + destinationId: 'Non-determininable', + workspaceId: 'Non-determininable', + errorType: 'throttled', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + }, + }, + }, + }, + }, + }, + { + name: 'facebook_pixel', + description: 'Test 4', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + body: { + XML: {}, + FORM: { + data: [ + '{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}', + ], + }, + JSON: {}, + JSON_ARRAY: {}, + }, + type: 'REST', + files: {}, + method: 'POST', + userId: '', + headers: {}, + version: '1', + endpoint: + 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=invalid_account_id_valid_access_token', + params: { + destination: 'facebook_pixel', + }, + }, + method: 'POST', + }, + }, + output: { + response: { + status: 400, + body: { + output: { + status: 400, + message: + "Object with ID 'PIXEL_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation", + destinationResponse: { + error: { + message: + "Unsupported post request. Object with ID '1234567891234569' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api", + type: 'GraphMethodException', + code: 100, + error_subcode: 33, + fbtrace_id: 'facebook_px_trace_id_5', + }, + status: 400, + }, + statTags: { + destType: 'FACEBOOK_PIXEL', + errorCategory: 'network', + destinationId: 'Non-determininable', + workspaceId: 'Non-determininable', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + }, + }, + }, + }, + }, + }, + { + name: 'facebook_pixel', + description: 'Test 5', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + body: { + XML: {}, + FORM: { + data: [ + '{"user_data":{"external_id":"d58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}', + ], + }, + JSON: {}, + JSON_ARRAY: {}, + }, + type: 'REST', + files: {}, + method: 'POST', + userId: '', + headers: {}, + version: '1', + endpoint: + 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=not_found_access_token', + params: { + destination: 'facebook_pixel', + }, + }, + method: 'POST', + }, + }, + output: { + response: { + status: 400, + body: { + output: { + status: 400, + message: 'Invalid Parameter', + destinationResponse: { + error: { + message: 'Invalid Parameter', + type: 'GraphMethodException', + code: 100, + error_subcode: 34, + fbtrace_id: 'facebook_px_trace_id_6', + }, + status: 404, + }, + statTags: { + destType: 'FACEBOOK_PIXEL', + errorCategory: 'network', + destinationId: 'Non-determininable', + workspaceId: 'Non-determininable', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + }, + }, + }, + }, + }, + }, + { + name: 'facebook_pixel', + description: 'Test 6', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + body: { + XML: {}, + FORM: { + data: [ + '{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}', + ], + }, + JSON: {}, + JSON_ARRAY: {}, + }, + type: 'REST', + files: {}, + method: 'POST', + params: { + destination: 'facebook_pixel', + }, + userId: '', + headers: {}, + version: '1', + endpoint: + 'https://graph.facebook.com/v17.0/1234567891234570/events?access_token=valid_access_token', + }, + method: 'POST', + }, + }, + output: { + response: { + status: 400, + body: { + output: { + status: 400, + message: 'Invalid Parameter', + destinationResponse: { + error: { + message: 'Unsupported post request. some problem with sent parameters', + type: 'GraphMethodException', + code: 100, + error_subcode: 38, + fbtrace_id: 'facebook_px_trace_id_6', + }, + status: 400, + }, + statTags: { + destType: 'FACEBOOK_PIXEL', + errorCategory: 'network', + destinationId: 'Non-determininable', + workspaceId: 'Non-determininable', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + }, + }, + }, + }, + }, + }, + { + name: 'facebook_pixel', + description: 'Test 7', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + body: { + XML: {}, + FORM: { + data: [ + '{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}', + ], + }, + JSON: {}, + JSON_ARRAY: {}, + }, + type: 'REST', + files: {}, + method: 'POST', + params: { + destination: 'facebook_pixel', + }, + userId: '', + headers: {}, + version: '1', + endpoint: + 'https://graph.facebook.com/v17.0/1234567891234571/events?access_token=valid_access_token', + }, + method: 'POST', + }, + }, + output: { + response: { + status: 400, + body: { + output: { + status: 400, + message: 'Capability or permissions issue.', + destinationResponse: { + error: { + message: 'Some error in permission', + type: 'GraphMethodException', + code: 3, + error_subcode: 10, + fbtrace_id: 'facebook_px_trace_id_7', + }, + status: 500, + }, + statTags: { + destType: 'FACEBOOK_PIXEL', + errorCategory: 'network', + destinationId: 'Non-determininable', + workspaceId: 'Non-determininable', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + }, + }, + }, + }, + }, + }, + { + name: 'facebook_pixel', + description: 'Test 8', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + body: { + XML: {}, + FORM: { + data: [ + '{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}', + ], + }, + JSON: {}, + JSON_ARRAY: {}, + }, + type: 'REST', + files: {}, + method: 'POST', + params: { + destination: 'facebook_pixel', + }, + userId: '', + headers: {}, + version: '1', + endpoint: + 'https://graph.facebook.com/v17.0/1234567891234572/events?access_token=valid_access_token_unhandled_response', + }, + method: 'POST', + }, + }, + output: { + response: { + status: 500, + body: { + output: { + status: 500, + message: 'Unhandled random error', + destinationResponse: { + error: { + message: 'Unhandled random error', + type: 'RandomException', + code: 5, + error_subcode: 12, + fbtrace_id: 'facebook_px_trace_id_10', + }, + status: 412, + }, + statTags: { + destType: 'FACEBOOK_PIXEL', + errorCategory: 'network', + destinationId: 'Non-determininable', + workspaceId: 'Non-determininable', + errorType: 'retryable', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', + meta: 'unhandledStatusCode', + }, + }, + }, + }, + }, + }, +]; diff --git a/test/integrations/destinations/facebook_pixel/network.ts b/test/integrations/destinations/facebook_pixel/network.ts new file mode 100644 index 0000000000..a63970c4c6 --- /dev/null +++ b/test/integrations/destinations/facebook_pixel/network.ts @@ -0,0 +1,190 @@ +import { data } from './dataDelivery/data'; +import { getFormData } from '../../../../src/adapters/network'; + +export const networkCallsData = [ + { + httpReq: { + url: 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=invalid_access_token', + data: getFormData(data[0].input.request.body.body.FORM).toString(), + params: { destination: 'facebook_pixel' }, + headers: { 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: { + data: { + error: { + message: 'The access token could not be decrypted', + type: 'OAuthException', + code: 190, + fbtrace_id: 'fbpixel_trace_id', + }, + }, + status: 500, + }, + }, + { + httpReq: { + url: 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=invalid_timestamp_correct_access_token', + data: getFormData(data[2].input.request.body.body.FORM).toString(), + params: { destination: 'facebook_pixel' }, + headers: { 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: { + data: { + error: { + message: 'Invalid parameter', + type: 'OAuthException', + code: 100, + error_subcode: 2804003, + is_transient: false, + error_user_title: 'Event Timestamp Too Old', + error_user_msg: + 'The timestamp for this event is too far in the past. Events need to be sent from your server within 7 days of when they occurred. Enter a timestamp that has occurred within the last 7 days.', + fbtrace_id: 'A6UyEgg_HdoiRX9duxcBOjb', + }, + }, + status: 400, + }, + }, + { + httpReq: { + url: 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=throttled_valid_access_token', + data: getFormData(data[3].input.request.body.body.FORM).toString(), + params: { destination: 'facebook_pixel' }, + headers: { 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: { + data: { + error: { + message: 'User request limit reached', + type: 'OAuthException', + code: 17, + fbtrace_id: 'facebook_px_trace_id_4', + }, + }, + status: 500, + }, + }, + { + httpReq: { + url: 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=invalid_account_id_valid_access_token', + data: getFormData(data[4].input.request.body.body.FORM).toString(), + params: { destination: 'facebook_pixel' }, + headers: { 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: { + data: { + error: { + message: + "Unsupported post request. Object with ID '1234567891234569' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api", + type: 'GraphMethodException', + code: 100, + error_subcode: 33, + fbtrace_id: 'facebook_px_trace_id_5', + }, + }, + status: 400, + }, + }, + { + httpReq: { + url: 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=not_found_access_token', + data: getFormData(data[5].input.request.body.body.FORM).toString(), + params: { destination: 'facebook_pixel' }, + headers: { 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: { + data: { + error: { + message: 'Invalid Parameter', + type: 'GraphMethodException', + code: 100, + error_subcode: 34, + fbtrace_id: 'facebook_px_trace_id_6', + }, + }, + status: 404, + }, + }, + { + httpReq: { + url: 'https://graph.facebook.com/v17.0/1234567891234570/events?access_token=valid_access_token', + data: getFormData(data[6].input.request.body.body.FORM).toString(), + params: { destination: 'facebook_pixel' }, + headers: { 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: { + data: { + error: { + message: 'Unsupported post request. some problem with sent parameters', + type: 'GraphMethodException', + code: 100, + error_subcode: 38, + fbtrace_id: 'facebook_px_trace_id_6', + }, + }, + status: 400, + }, + }, + { + httpReq: { + url: 'https://graph.facebook.com/v17.0/1234567891234571/events?access_token=valid_access_token', + data: getFormData(data[7].input.request.body.body.FORM).toString(), + params: { destination: 'facebook_pixel' }, + headers: { 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: { + data: { + error: { + message: 'Some error in permission', + type: 'GraphMethodException', + code: 3, + error_subcode: 10, + fbtrace_id: 'facebook_px_trace_id_7', + }, + }, + status: 500, + }, + }, + { + httpReq: { + url: 'https://graph.facebook.com/v17.0/1234567891234572/events?access_token=valid_access_token_unhandled_response', + data: getFormData(data[8].input.request.body.body.FORM).toString(), + params: { destination: 'facebook_pixel' }, + headers: { 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: { + data: { + error: { + message: 'Unhandled random error', + type: 'RandomException', + code: 5, + error_subcode: 12, + fbtrace_id: 'facebook_px_trace_id_10', + }, + }, + status: 412, + }, + }, + { + httpReq: { + url: 'https://graph.facebook.com/v17.0/1234567891234567/events?access_token=my_access_token', + data: getFormData(data[1].input.request.body.body.FORM).toString(), + params: { destination: 'facebook_pixel' }, + headers: { 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: { + data: { events_received: 1, fbtrace_id: 'facebook_trace_id' }, + status: 200, + statusText: 'OK', + }, + }, +]; diff --git a/test/integrations/destinations/fb/dataDelivery/data.ts b/test/integrations/destinations/fb/dataDelivery/data.ts new file mode 100644 index 0000000000..70538a6ea0 --- /dev/null +++ b/test/integrations/destinations/fb/dataDelivery/data.ts @@ -0,0 +1,357 @@ +export const data = [ + { + "name": "fb", + "description": "Test 0", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "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" + }, + "JSON": {} + }, + "endpoint": "https://graph.facebook.com/v17.0/RudderFbApp/activities?access_token=invalid_access_token", + "files": {}, + "headers": { + "x-forwarded-for": "1.2.3.4" + }, + "method": "POST", + "statusCode": 200, + "type": "REST", + "userId": "c82cbdff-e5be-4009-ac78-cdeea09ab4b1", + "version": "1", + "params": { + "destination": "fb" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 400, + "body": { + "output": { + "status": 400, + "message": "Invalid OAuth 2.0 access token", + "destinationResponse": { + "error": { + "message": "The access token could not be decrypted", + "type": "OAuthException", + "code": 190, + "fbtrace_id": "fbpixel_trace_id" + }, + "status": 500 + }, + "statTags": { + "destType": "FB", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "aborted", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + }, + { + "name": "fb", + "description": "Test 1", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "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" + }, + "JSON": {} + }, + "endpoint": "https://graph.facebook.com/v17.0/RudderFbApp/activities?access_token=my_access_token", + "files": {}, + "headers": { + "x-forwarded-for": "1.2.3.4" + }, + "method": "POST", + "statusCode": 200, + "type": "REST", + "userId": "c82cbdff-e5be-4009-ac78-cdeea09ab4b1", + "version": "1", + "params": { + "destination": "fb" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 200, + "body": { + "output": { + "status": 200, + "message": "Request Processed Successfully", + "destinationResponse": { + "events_received": 1, + "fbtrace_id": "facebook_trace_id" + } + } + } + } + } + }, + + { + "name": "fb", + "description": "Test 2", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "body": { + "XML": {}, + "JSON_ARRAY": {}, + "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" + }, + "JSON": {} + }, + "endpoint": "https://graph.facebook.com/v17.0/1234567891234567/events?access_token=invalid_timestamp_correct_access_token", + "files": {}, + "headers": { + "x-forwarded-for": "1.2.3.4" + }, + "method": "POST", + "statusCode": 200, + "type": "REST", + "userId": "c82cbdff-e5be-4009-ac78-cdeea09ab4b1", + "version": "1", + "params": { + "destination": "fb" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 400, + "body": { + "output": { + "status": 400, + "message": "Event Timestamp Too Old", + "destinationResponse": { + "error": { + "message": "Invalid parameter", + "type": "OAuthException", + "code": 100, + "error_subcode": 2804003, + "is_transient": false, + "error_user_title": "Event Timestamp Too Old", + "error_user_msg": "The timestamp for this event is too far in the past. Events need to be sent from your server within 7 days of when they occurred. Enter a timestamp that has occurred within the last 7 days.", + "fbtrace_id": "A6UyEgg_HdoiRX9duxcBOjb" + }, + "status": 400 + }, + "statTags": { + "destType": "FB", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "aborted", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + }, + { + "name": "fb", + "description": "Test 3", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://graph.facebook.com/v17.0/1234567891234567/events?access_token=throttled_valid_access_token", + "headers": {}, + "body": { + "JSON": {}, + "XML": {}, + "JSON_ARRAY": {}, + "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" + } + }, + "files": {}, + "userId": "c82cbdff-e5be-4009-ac78-cdeea09ab4b1", + "statusCode": 200, + "params": { + "destination": "fb" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 429, + "body": { + "output": { + "status": 429, + "message": "API User Too Many Calls", + "destinationResponse": { + "error": { + "message": "User request limit reached", + "type": "OAuthException", + "code": 17, + "fbtrace_id": "facebook_px_trace_id_4" + }, + "status": 500 + }, + "statTags": { + "destType": "FB", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "throttled", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + }, + { + "name": "fb", + "description": "Test 4", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://graph.facebook.com/v17.0/1234567891234567/events?access_token=invalid_account_id_valid_access_token", + "headers": {}, + "body": { + "JSON": {}, + "XML": {}, + "JSON_ARRAY": {}, + "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" + } + }, + "files": {}, + "userId": "c82cbdff-e5be-4009-ac78-cdeea09ab4b1", + "statusCode": 200, + "params": { + "destination": "fb" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 400, + "body": { + "output": { + "status": 400, + "message": "Object with ID 'PIXEL_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation", + "destinationResponse": { + "error": { + "message": "Unsupported post request. Object with ID '1234567891234569' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api", + "type": "GraphMethodException", + "code": 100, + "error_subcode": 33, + "fbtrace_id": "facebook_px_trace_id_5" + }, + "status": 400 + }, + "statTags": { + "destType": "FB", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "aborted", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + } +] \ No newline at end of file diff --git a/test/integrations/destinations/fb/network.ts b/test/integrations/destinations/fb/network.ts new file mode 100644 index 0000000000..4bf870f535 --- /dev/null +++ b/test/integrations/destinations/fb/network.ts @@ -0,0 +1,52 @@ +import { getFormData } from '../../../../src/adapters/network'; +import * as fbPixelNw from '../facebook_pixel/network'; +import { data } from './dataDelivery/data'; + +const fbPixelTcs = data + .filter((_, i) => [2, 3, 4].includes(i)) + .map((d) => { + const fbendpoint = d.input.request.body.endpoint; + const fbpTc = fbPixelNw.networkCallsData.filter((nw) => { + return nw.httpReq.url === fbendpoint; + })[0]; + fbpTc.httpReq.data = getFormData(d.input.request.body.body.FORM).toString(); + return fbpTc; + }); + +export const networkCallsData = [ + { + httpReq: { + url: 'https://graph.facebook.com/v17.0/RudderFbApp/activities?access_token=invalid_access_token', + data: getFormData(data[0].input.request.body.body.FORM).toString(), + params: { destination: 'fb' }, + headers: { 'User-Agent': 'RudderLabs' }, + method: 'POST', + }, + httpRes: { + data: { + error: { + message: 'The access token could not be decrypted', + type: 'OAuthException', + code: 190, + fbtrace_id: 'fbpixel_trace_id', + }, + }, + status: 500, + }, + }, + { + httpReq: { + url: 'https://graph.facebook.com/v17.0/RudderFbApp/activities?access_token=my_access_token', + 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', + }, + httpRes: { + data: { events_received: 1, fbtrace_id: 'facebook_trace_id' }, + status: 200, + statusText: 'OK', + }, + }, + ...fbPixelTcs, +]; diff --git a/test/integrations/destinations/intercom/dataDelivery/data.ts b/test/integrations/destinations/intercom/dataDelivery/data.ts new file mode 100644 index 0000000000..23bcdc6af2 --- /dev/null +++ b/test/integrations/destinations/intercom/dataDelivery/data.ts @@ -0,0 +1,90 @@ +export const data = [ + { + "name": "intercom", + "description": "Test 0", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://api.intercom.io/users/test1", + "headers": { + "Content-Type": "application/json", + "Authorization": "Bearer intercomApiKey", + "Accept": "application/json", + "Intercom-Version": "1.4" + }, + "params": {}, + "body": { + "JSON": { + "email": "test_1@test.com", + "phone": "9876543210", + "name": "Test Name", + "signed_up_at": 1601493060, + "last_seen_user_agent": "unknown", + "update_last_request_at": true, + "user_id": "test_user_id_1", + "custom_attributes": { + "anonymousId": "58b21c2d-f8d5-4410-a2d0-b268a26b7e33", + "key1": "value1", + "address.city": "Kolkata", + "address.state": "West Bengal", + "originalArray[0].nested_field": "nested value", + "originalArray[0].tags[0]": "tag_1", + "originalArray[0].tags[1]": "tag_2", + "originalArray[0].tags[2]": "tag_3", + "originalArray[1].nested_field": "nested value", + "originalArray[1].tags[0]": "tag_1", + "originalArray[2].nested_field": "nested value" + } + }, + "XML": {}, + "JSON_ARRAY": {}, + "FORM": {} + }, + "files": {}, + "userId": "58b21c2d-f8d5-4410-a2d0-b268a26b7e33" + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 500, + "body": { + "output": { + "status": 500, + "message": "[Intercom Response Handler] Request failed for destination intercom with status: 408", + "destinationResponse": { + "response": { + "type": "error.list", + "request_id": "000on04msi4jpk7d3u60", + "errors": [ + { + "code": "Request Timeout", + "message": "The server would not wait any longer for the client" + } + ] + }, + "status": 408 + }, + "statTags": { + "destType": "INTERCOM", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "retryable", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + } +] \ No newline at end of file diff --git a/test/integrations/destinations/intercom/network.ts b/test/integrations/destinations/intercom/network.ts index 9f064d63ea..e3bba3f260 100644 --- a/test/integrations/destinations/intercom/network.ts +++ b/test/integrations/destinations/intercom/network.ts @@ -90,4 +90,56 @@ const deleteNwData = [ }, }, ]; -export const networkCallsData = [...deleteNwData]; +const deliveryCallsData = [ + { + httpReq: { + url: 'https://api.intercom.io/users/test1', + data: { + email: 'test_1@test.com', + phone: '9876543210', + name: 'Test Name', + signed_up_at: 1601493060, + last_seen_user_agent: 'unknown', + update_last_request_at: true, + user_id: 'test_user_id_1', + custom_attributes: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + key1: 'value1', + 'address.city': 'Kolkata', + 'address.state': 'West Bengal', + 'originalArray[0].nested_field': 'nested value', + 'originalArray[0].tags[0]': 'tag_1', + 'originalArray[0].tags[1]': 'tag_2', + 'originalArray[0].tags[2]': 'tag_3', + 'originalArray[1].nested_field': 'nested value', + 'originalArray[1].tags[0]': 'tag_1', + 'originalArray[2].nested_field': 'nested value', + }, + }, + params: {}, + headers: { + 'Content-Type': 'application/json', + Authorization: 'Bearer intercomApiKey', + Accept: 'application/json', + 'Intercom-Version': '1.4', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { + data: { + type: 'error.list', + request_id: '000on04msi4jpk7d3u60', + errors: [ + { + code: 'Request Timeout', + message: 'The server would not wait any longer for the client', + }, + ], + }, + status: 408, + }, + }, +]; +export const networkCallsData = [...deleteNwData, ...deliveryCallsData]; + diff --git a/test/integrations/destinations/marketo_static_list/dataDelivery/data.ts b/test/integrations/destinations/marketo_static_list/dataDelivery/data.ts new file mode 100644 index 0000000000..e3deebca9b --- /dev/null +++ b/test/integrations/destinations/marketo_static_list/dataDelivery/data.ts @@ -0,0 +1,368 @@ +export const data = [ + { + "name": "marketo_static_list", + "description": "Test 0", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://marketo_acct_id_success.mktorest.com/rest/v1/lists/1234/leads.json?id=110&id=111&id=112", + "method": "POST", + "userId": "", + "headers": { + "Authorization": "Bearer Incorrect_token", + "Content-Type": "application/json" + }, + "body": { + "FORM": {}, + "JSON": {}, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {}, + "params": { + "destination": "marketo_static_list" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 200, + "body": { + "output": { + "message": "Request Processed Successfully", + "destinationResponse": { + "response": { + "requestId": "b6d1#18a8d2c10e7", + "result": [ + { + "id": 110, + "status": "skipped", + "reasons": [ + { + "code": "1015", + "message": "Lead not in list" + } + ] + }, + { + "id": 111, + "status": "removed" + }, + { + "id": 112, + "status": "removed" + } + ], + "success": true + }, + "status": 200 + }, + "status": 200 + } + } + } + } + }, + { + "name": "marketo_static_list", + "description": "Test 1", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://marketo_acct_id_success.mktorest.com/rest/v1/lists/1234/leads.json?id=1&id=2&id=3", + "method": "POST", + "userId": "", + "headers": { + "Authorization": "Bearer Incorrect_token", + "Content-Type": "application/json" + }, + "body": { + "FORM": {}, + "JSON": {}, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {}, + "params": { + "destination": "marketo_static_list" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 500, + "body": { + "output": { + "status": 500, + "message": "Request Failed for Marketo Static List, Access token invalid (Retryable).during Marketo Static List Response Handling", + "destinationResponse": { + "response": { + "requestId": "68d8#1846058ee27", + "success": false, + "errors": [ + { + "code": "601", + "message": "Access token invalid" + } + ] + }, + "status": 200 + }, + "statTags": { + "destType": "MARKETO_STATIC_LIST", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "retryable", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + }, + { + "name": "marketo_static_list", + "description": "Test 2", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://marketo_acct_id_success.mktorest.com/rest/v1/lists/1234/leads.json?id=1&id=2", + "method": "POST", + "userId": "", + "headers": { + "Authorization": "Bearer token", + "Content-Type": "application/json" + }, + "body": { + "FORM": {}, + "JSON": { + "action": "createOrUpdate", + "input": [ + { + "City": "Tokyo", + "Country": "JP", + "Email": "gabi29@gmail.com", + "PostalCode": "100-0001", + "Title": "Owner", + "id": 1328328, + "userId": "gabi_userId_45" + } + ], + "lookupField": "id" + }, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {}, + "params": { + "destination": "marketo_static_list" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 200, + "body": { + "output": { + "status": 200, + "message": "Request Processed Successfully", + "destinationResponse": { + "response": { + "requestId": "12d3c#1846057dce2", + "success": true, + "result": [ + { + "id": 1, + "status": "added" + }, + { + "id": 2, + "status": "added" + } + ] + }, + "status": 200 + } + } + } + } + } + }, + { + "name": "marketo_static_list", + "description": "Test 3", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://marketo_acct_id_success.mktorest.com/rest/v1/lists/1234/leads.json?id=3&id=4", + "method": "POST", + "userId": "", + "headers": { + "Authorization": "Bearer token", + "Content-Type": "application/json" + }, + "params": {}, + "body": { + "FORM": {}, + "JSON": { + "action": "createOrUpdate", + "input": [ + { + "City": "Tokyo", + "Country": "JP", + "Email": "gabi29@gmail.com", + "PostalCode": "100-0001", + "Title": "Owner", + "id": 1328328, + "userId": "gabi_userId_45" + }, + { + "City": "Tokyo", + "Country": "JP", + "Email": "b@s.com", + "PostalCode": "100-0001", + "Title": "Owner", + "id": 1328329, + "userId": "ben_userId_45" + } + ], + "lookupField": "id" + }, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {} + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 400, + "body": { + "output": { + "destinationResponse": "", + "message": "Request failed during: during Marketo Static List Response Handling, error: [{\"code\":\"1004\",\"message\":\"Lead not found\"}]", + "statTags": { + "destType": "MARKETO_STATIC_LIST", + "errorCategory": "dataValidation", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "instrumentation", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + }, + "status": 400 + } + } + } + } + }, + { + "name": "marketo_static_list", + "description": "Test 4", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "type": "REST", + "endpoint": "https://marketo_acct_id_success.mktorest.com/rest/v1/lists/1234/leads.json?id=5&id=6", + "method": "POST", + "userId": "", + "headers": { + "Authorization": "Bearer token", + "Content-Type": "application/json" + }, + "params": {}, + "body": { + "FORM": {}, + "JSON": { + "action": "createOrUpdate", + "input": [ + { + "City": "Tokyo", + "Country": "JP", + "Email": "gabi29@gmail.com", + "PostalCode": "100-0001", + "Title": "Owner", + "id": 1328328, + "userId": "gabi_userId_45" + }, + { + "City": "Tokyo", + "Country": "JP", + "Email": "b@s.com", + "PostalCode": "100-0001", + "Title": "Owner", + "id": 1328329, + "userId": "ben_userId_45" + } + ], + "lookupField": "id" + }, + "JSON_ARRAY": {}, + "XML": {} + }, + "files": {} + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 200, + "body": { + "output": { + "status": 200, + "message": "Request Processed Successfully", + "destinationResponse": { + "response": { + "requestId": "12d3c#1846057dce2", + "result": { + "id": 5, + "status": "skipped", + "reasons": [ + { + "code": "1015", + "message": "Lead not in list" + } + ] + }, + "success": true + }, + "status": 200 + } + } + } + } + } + } +] \ No newline at end of file diff --git a/test/integrations/destinations/marketo_static_list/network.ts b/test/integrations/destinations/marketo_static_list/network.ts index c369e1af26..5c13273859 100644 --- a/test/integrations/destinations/marketo_static_list/network.ts +++ b/test/integrations/destinations/marketo_static_list/network.ts @@ -1,3 +1,182 @@ +const deliveryCallsData = [ + { + httpReq: { + url: 'https://marketo_acct_id_success.mktorest.com/rest/v1/lists/1234/leads.json?id=110&id=111&id=112', + params: { destination: 'marketo_static_list' }, + headers: { + Authorization: 'Bearer Incorrect_token', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { + data: { + requestId: 'b6d1#18a8d2c10e7', + result: [ + { id: 110, status: 'skipped', reasons: [{ code: '1015', message: 'Lead not in list' }] }, + { id: 111, status: 'removed' }, + { id: 112, status: 'removed' }, + ], + success: true, + }, + status: 200, + }, + }, + { + httpReq: { + url: 'https://marketo_acct_id_success.mktorest.com/rest/v1/lists/1234/leads.json?id=1&id=2&id=3', + params: { destination: 'marketo_static_list' }, + headers: { + Authorization: 'Bearer Incorrect_token', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { + data: { + requestId: '68d8#1846058ee27', + success: false, + errors: [{ code: '601', message: 'Access token invalid' }], + }, + status: 200, + }, + }, + { + httpReq: { + url: 'https://marketo_acct_id_success.mktorest.com/rest/v1/lists/1234/leads.json?id=1&id=2', + data: { + action: 'createOrUpdate', + input: [ + { + City: 'Tokyo', + Country: 'JP', + Email: 'gabi29@gmail.com', + PostalCode: '100-0001', + Title: 'Owner', + id: 1328328, + userId: 'gabi_userId_45', + }, + ], + lookupField: 'id', + }, + params: { destination: 'marketo_static_list' }, + headers: { + Authorization: 'Bearer token', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { + data: { + requestId: '12d3c#1846057dce2', + result: [ + { id: 1, status: 'added' }, + { id: 2, status: 'added' }, + ], + success: true, + }, + status: 200, + }, + }, + { + httpReq: { + url: 'https://marketo_acct_id_success.mktorest.com/rest/v1/lists/1234/leads.json?id=3&id=4', + data: { + action: 'createOrUpdate', + input: [ + { + City: 'Tokyo', + Country: 'JP', + Email: 'gabi29@gmail.com', + PostalCode: '100-0001', + Title: 'Owner', + id: 1328328, + userId: 'gabi_userId_45', + }, + { + City: 'Tokyo', + Country: 'JP', + Email: 'b@s.com', + PostalCode: '100-0001', + Title: 'Owner', + id: 1328329, + userId: 'ben_userId_45', + }, + ], + lookupField: 'id', + }, + params: {}, + headers: { + Authorization: 'Bearer token', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { + data: { + requestId: '12d3c#1846057dce2', + result: [ + { id: 1, status: 'added' }, + { id: 4, status: 'skipped', reasons: [{ code: '1004', message: 'Lead not found' }] }, + ], + success: true, + }, + status: 200, + }, + }, + { + httpReq: { + url: 'https://marketo_acct_id_success.mktorest.com/rest/v1/lists/1234/leads.json?id=5&id=6', + data: { + action: 'createOrUpdate', + input: [ + { + City: 'Tokyo', + Country: 'JP', + Email: 'gabi29@gmail.com', + PostalCode: '100-0001', + Title: 'Owner', + id: 1328328, + userId: 'gabi_userId_45', + }, + { + City: 'Tokyo', + Country: 'JP', + Email: 'b@s.com', + PostalCode: '100-0001', + Title: 'Owner', + id: 1328329, + userId: 'ben_userId_45', + }, + ], + lookupField: 'id', + }, + params: {}, + headers: { + Authorization: 'Bearer token', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { + data: { + requestId: '12d3c#1846057dce2', + result: { + id: 5, + status: 'skipped', + reasons: [{ code: '1015', message: 'Lead not in list' }], + }, + success: true, + }, + status: 200, + }, + }, +]; export const networkCallsData = [ { httpReq: { @@ -19,4 +198,5 @@ export const networkCallsData = [ status: 200, }, }, + ...deliveryCallsData, ]; diff --git a/test/integrations/destinations/snapchat_custom_audience/dataDelivery/data.ts b/test/integrations/destinations/snapchat_custom_audience/dataDelivery/data.ts new file mode 100644 index 0000000000..2ed5625fe8 --- /dev/null +++ b/test/integrations/destinations/snapchat_custom_audience/dataDelivery/data.ts @@ -0,0 +1,222 @@ +export const data = [ + { + "name": "snapchat_custom_audience", + "description": "Test 0", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://adsapi.snapchat.com/v1/segments/123/users", + "headers": { + "Authorization": "Bearer abcd123", + "Content-Type": "application/json" + }, + "body": { + "JSON": { + "users": [ + { + "schema": [ + "EMAIL_SHA256" + ], + "data": [ + [ + "938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c" + ] + ] + } + ] + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {}, + "params": { + "destination": "snapchat_custom_audience" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 200, + "body": { + "output": { + "status": 200, + "message": "Request Processed Successfully", + "destinationResponse": { + "response": { + "request_status": "SUCCESS", + "request_id": "12345", + "users": [ + { + "sub_request_status": "SUCCESS", + "user": { + "number_uploaded_users": 1 + } + } + ] + }, + "status": 200 + } + } + } + } + } + }, + { + "name": "snapchat_custom_audience", + "description": "Test 1", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://adsapi.snapchat.com/v1/segments/456/users", + "headers": { + "Authorization": "Bearer abcd123", + "Content-Type": "application/json" + }, + "body": { + "JSON": { + "users": [ + { + "schema": [ + "EMAIL_SHA256" + ], + "data": [ + [ + "938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c" + ] + ] + } + ] + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {}, + "params": { + "destination": "snapchat_custom_audience" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 500, + "body": { + "output": { + "status": 500, + "destinationResponse": { + "response": "unauthorized", + "status": 401 + }, + "message": "Failed with unauthorized during snapchat_custom_audience response transformation", + "statTags": { + "destType": "SNAPCHAT_CUSTOM_AUDIENCE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "retryable", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + }, + "authErrorCategory": "REFRESH_TOKEN" + } + } + } + } + }, + { + "name": "snapchat_custom_audience", + "description": "Test 2", + "feature": "dataDelivery", + "module": "destination", + "version": "v0", + "input": { + "request": { + "body": { + "version": "1", + "type": "REST", + "method": "DELETE", + "endpoint": "https://adsapi.snapchat.com/v1/segments/789/users", + "headers": { + "Authorization": "Bearer abcd123", + "Content-Type": "application/json" + }, + "body": { + "JSON": { + "users": [ + { + "id": "123456", + "schema": [ + "EMAIL_SHA256" + ], + "data": [ + [ + "938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c" + ] + ] + } + ] + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {}, + "params": { + "destination": "snapchat_custom_audience" + } + }, + "method": "POST" + } + }, + "output": { + "response": { + "status": 400, + "body": { + "output": { + "authErrorCategory": "AUTH_STATUS_INACTIVE", + "status": 400, + "destinationResponse": { + "response": { + "request_status": "ERROR", + "request_id": "98e2a602-3cf4-4596-a8f9-7f034161f89a", + "debug_message": "Caller does not have permission", + "display_message": "We're sorry, but the requested resource is not available at this time", + "error_code": "E3002" + }, + "status": 403 + }, + "message": "undefined during snapchat_custom_audience response transformation", + "statTags": { + "destType": "SNAPCHAT_CUSTOM_AUDIENCE", + "errorCategory": "network", + "destinationId": "Non-determininable", + "workspaceId": "Non-determininable", + "errorType": "aborted", + "feature": "dataDelivery", + "implementation": "native", + "module": "destination" + } + } + } + } + } + } +] \ No newline at end of file diff --git a/test/integrations/destinations/snapchat_custom_audience/network.ts b/test/integrations/destinations/snapchat_custom_audience/network.ts new file mode 100644 index 0000000000..9be134c202 --- /dev/null +++ b/test/integrations/destinations/snapchat_custom_audience/network.ts @@ -0,0 +1,84 @@ +export const networkCallsData = [ + { + httpReq: { + url: 'https://adsapi.snapchat.com/v1/segments/123/users', + data: { + users: [ + { + schema: ['EMAIL_SHA256'], + data: [['938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c']], + }, + ], + }, + params: { destination: 'snapchat_custom_audience' }, + headers: { + Authorization: 'Bearer abcd123', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { + data: { + request_status: 'SUCCESS', + request_id: '12345', + users: [{ sub_request_status: 'SUCCESS', user: { number_uploaded_users: 1 } }], + }, + status: 200, + statusText: 'OK', + }, + }, + { + httpReq: { + url: 'https://adsapi.snapchat.com/v1/segments/456/users', + data: { + users: [ + { + schema: ['EMAIL_SHA256'], + data: [['938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c']], + }, + ], + }, + params: { destination: 'snapchat_custom_audience' }, + headers: { + Authorization: 'Bearer abcd123', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'POST', + }, + httpRes: { data: 'unauthorized', status: 401, statusText: 'Unauthorized' }, + }, + { + httpReq: { + url: 'https://adsapi.snapchat.com/v1/segments/789/users', + data: { + users: [ + { + id: '123456', + schema: ['EMAIL_SHA256'], + data: [['938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c']], + }, + ], + }, + params: { destination: 'snapchat_custom_audience' }, + headers: { + Authorization: 'Bearer abcd123', + 'Content-Type': 'application/json', + 'User-Agent': 'RudderLabs', + }, + method: 'DELETE', + }, + httpRes: { + data: { + request_status: 'ERROR', + request_id: '98e2a602-3cf4-4596-a8f9-7f034161f89a', + debug_message: 'Caller does not have permission', + display_message: "We're sorry, but the requested resource is not available at this time", + error_code: 'E3002', + }, + status: 403, + statusText: 'Forbidden', + }, + }, +];