From 4987948d7a847a4d99618a5c1aef8616ab87497e Mon Sep 17 00:00:00 2001 From: shrouti1507 Date: Thu, 23 May 2024 21:49:56 +0530 Subject: [PATCH 1/5] feat: initial commit --- src/v0/destinations/af/config.js | 2 ++ src/v0/destinations/af/transform.js | 44 +++++++++++++++++++++++------ 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/v0/destinations/af/config.js b/src/v0/destinations/af/config.js index bc49706959..eb3b191950 100644 --- a/src/v0/destinations/af/config.js +++ b/src/v0/destinations/af/config.js @@ -57,6 +57,7 @@ const Event = { }; const ENDPOINT = 'https://api2.appsflyer.com/inappevent/'; +const ENDPOINT_V2 = 'https://api3.appsflyer.com/inappevent/'; const mappingConfig = getMappingConfig(ConfigCategory, __dirname); @@ -69,6 +70,7 @@ events.forEach((event) => { module.exports = { ConfigCategory, ENDPOINT, + ENDPOINT_V2, Event, mappingConfig, nameToEventMap, diff --git a/src/v0/destinations/af/transform.js b/src/v0/destinations/af/transform.js index 72ba47a227..a611dcc249 100644 --- a/src/v0/destinations/af/transform.js +++ b/src/v0/destinations/af/transform.js @@ -17,20 +17,32 @@ const { simpleProcessRouterDest, } = require('../../util'); -const { Event, ENDPOINT, ConfigCategory, mappingConfig, nameToEventMap } = require('./config'); +const { + Event, + ENDPOINT, + ENDPOINT_V2, + ConfigCategory, + mappingConfig, + nameToEventMap, +} = require('./config'); const { JSON_MIME_TYPE } = require('../../util/constant'); function responseBuilderSimple(payload, message, destination) { - const { androidAppId, appleAppId } = destination.Config; + const { androidAppId, appleAppId, sharingFilter, devKey, s2sKey, authVersion } = + destination.Config; let endpoint; const os = get(message, 'context.os.name'); // if ((os && os.toLowerCase() === "android") || (os && isAppleFamily(os))){ // if() // } + + const finalEndPoint = + isDefinedAndNotNull(authVersion) && authVersion === 'v2' ? ENDPOINT_V2 : ENDPOINT; + if (os && os.toLowerCase() === 'android' && androidAppId) { - endpoint = `${ENDPOINT}${androidAppId}`; + endpoint = `${finalEndPoint}${androidAppId}`; } else if (os && isAppleFamily(os) && appleAppId) { - endpoint = `${ENDPOINT}id${appleAppId}`; + endpoint = `${finalEndPoint}id${appleAppId}`; } else { throw new ConfigurationError( 'os name is required along with the respective appId eg. (os->android & Android App Id is required) or (os->ios & Apple App Id is required)', @@ -87,16 +99,19 @@ function responseBuilderSimple(payload, message, destination) { updatedPayload.bundleIdentifier = bundleIdentifier; } - const { sharingFilter, devKey } = destination.Config; + // const { sharingFilter, devKey } = destination.Config; if (isDefinedAndNotNullAndNotEmpty(sharingFilter)) { updatedPayload.sharing_filter = sharingFilter; } + const finalAuthentication = + isDefinedAndNotNull(authVersion) && authVersion === 'v2' ? s2sKey : devKey; + const response = defaultRequestConfig(); response.endpoint = endpoint; response.headers = { 'Content-Type': JSON_MIME_TYPE, - authentication: devKey, + authentication: finalAuthentication, }; response.method = defaultPostRequestConfig.requestMethod; response.body.JSON = removeUndefinedAndNullValues(updatedPayload); @@ -203,6 +218,19 @@ function processEventTypeTrack(message, config) { } function processSingleMessage(message, destination) { + const { devKey, s2sKey, authVersion, useRichEventName } = destination.Config; + + if (!isDefinedAndNotNull(authVersion) && !isDefinedAndNotNull(devKey)) { + throw new ConfigurationError('No authentication key is present. Aborting.'); + } + + if (isDefinedAndNotNull(authVersion) && authVersion === 'v2' && !isDefinedAndNotNull(s2sKey)) { + throw new ConfigurationError('s2s key is mandatory for v2 authorization. Aborting.'); + } + + if (isDefinedAndNotNull(authVersion) && authVersion === 'v1' && !isDefinedAndNotNull(devKey)) { + throw new ConfigurationError('dev key is mandatory for v1 authorization. Aborting.'); + } const messageType = message.type.toLowerCase(); let payload; switch (messageType) { @@ -212,7 +240,7 @@ function processSingleMessage(message, destination) { } case EventType.SCREEN: { let eventName; - if (destination.Config.useRichEventName === true) { + if (useRichEventName === true) { eventName = `Viewed ${ message.name || message.event || get(message, 'properties.name') || '' } Screen`; @@ -224,7 +252,7 @@ function processSingleMessage(message, destination) { } case EventType.PAGE: { let eventName; - if (destination.Config.useRichEventName === true) { + if (useRichEventName === true) { eventName = `Viewed ${message.name || get(message, 'properties.name') || ''} Page`; } else { eventName = EventType.PAGE; From a98e9d1d882efdc3eb3bb7f7b851ab605306b9d1 Mon Sep 17 00:00:00 2001 From: shrouti1507 <60211312+shrouti1507@users.noreply.github.com> Date: Fri, 24 May 2024 14:38:58 +0530 Subject: [PATCH 2/5] feat: onboarding adjust source (#3395) * fix: onboard adjust source * feat: onboard adjust source * feat: small edit * feat: small edit --- src/v0/sources/adjust/config.ts | 16 +++ src/v0/sources/adjust/mapping.json | 52 ++++++++++ src/v0/sources/adjust/transform.js | 61 ++++++++++++ test/integrations/sources/adjust/data.ts | 122 +++++++++++++++++++++++ 4 files changed, 251 insertions(+) create mode 100644 src/v0/sources/adjust/config.ts create mode 100644 src/v0/sources/adjust/mapping.json create mode 100644 src/v0/sources/adjust/transform.js create mode 100644 test/integrations/sources/adjust/data.ts diff --git a/src/v0/sources/adjust/config.ts b/src/v0/sources/adjust/config.ts new file mode 100644 index 0000000000..d1c6ab8242 --- /dev/null +++ b/src/v0/sources/adjust/config.ts @@ -0,0 +1,16 @@ +export const excludedFieldList = [ + 'activity_kind', + 'event', + 'event_name', + 'gps_adid', + 'idfa', + 'idfv', + 'adid', + 'tracker', + 'tracker_name', + 'app_name', + 'ip_address', + 'tracking_enabled', + 'tracker_token', + 'created_at', +]; diff --git a/src/v0/sources/adjust/mapping.json b/src/v0/sources/adjust/mapping.json new file mode 100644 index 0000000000..60ea66281e --- /dev/null +++ b/src/v0/sources/adjust/mapping.json @@ -0,0 +1,52 @@ +[ + { + "sourceKeys": "activity_kind", + "destKeys": "properties.activity_kind" + }, + { + "sourceKeys": "event", + "destKeys": "properties.event_token" + }, + { + "sourceKeys": "event_name", + "destKeys": "event" + }, + { + "sourceKeys": "gps_adid", + "destKeys": "properties.gps_adid" + }, + { + "sourceKeys": "idfa", + "destKeys": "context.device.advertisingId" + }, + { + "sourceKeys": "idfv", + "destKeys": "context.device.id" + }, + { + "sourceKeys": "adid", + "destKeys": "context.device.id " + }, + { + "sourceKeys": "tracker", + "destKeys": "properties.tracker" + }, + { + "sourceKeys": "tracker_name", + "destKeys": "properties.tracker_name" + }, + { "sourceKeys": "tracker_token", "destKeys": "properties.tracker_token" }, + + { + "sourceKeys": "app_name", + "destKeys": "context.app.name" + }, + { + "sourceKeys": "ip_address", + "destKeys": ["context.ip", "request_ip"] + }, + { + "sourceKeys": "tracking_enabled", + "destKeys": "properties.tracking_enabled" + } +] diff --git a/src/v0/sources/adjust/transform.js b/src/v0/sources/adjust/transform.js new file mode 100644 index 0000000000..8568622aeb --- /dev/null +++ b/src/v0/sources/adjust/transform.js @@ -0,0 +1,61 @@ +const lodash = require('lodash'); +const path = require('path'); +const fs = require('fs'); +const { TransformationError, structuredLogger: logger } = require('@rudderstack/integrations-lib'); +const Message = require('../message'); +const { CommonUtils } = require('../../../util/common'); +const { excludedFieldList } = require('./config'); +const { extractCustomFields, generateUUID } = require('../../util'); + +// ref : https://help.adjust.com/en/article/global-callbacks#general-recommended-placeholders +// import mapping json using JSON.parse to preserve object key order +const mapping = JSON.parse(fs.readFileSync(path.resolve(__dirname, './mapping.json'), 'utf-8')); + +const formatProperties = (input) => { + const { query_parameters: qParams } = input; + logger.debug(`[Adjust] Input event: query_params: ${JSON.stringify(qParams)}`); + if (!qParams) { + throw new TransformationError('Query_parameters is missing'); + } + const formattedOutput = {}; + Object.entries(qParams).forEach(([key, [value]]) => { + formattedOutput[key] = value; + }); + return formattedOutput; +}; + +const processEvent = (inputEvent) => { + const message = new Message(`Adjust`); + const event = lodash.cloneDeep(inputEvent); + const formattedPayload = formatProperties(event); + // event type is always track + const eventType = 'track'; + message.setEventType(eventType); + message.setPropertiesV2(formattedPayload, mapping); + let customProperties = {}; + customProperties = extractCustomFields( + formattedPayload, + customProperties, + 'root', + excludedFieldList, + ); + message.properties = { ...message.properties, ...customProperties }; + + if (formattedPayload.created_at) { + const ts = new Date(formattedPayload.created_at * 1000).toISOString(); + message.setProperty('originalTimestamp', ts); + message.setProperty('timestamp', ts); + } + + // adjust does not has the concept of user but we need to set some random anonymousId in order to make the server accept the message + message.anonymousId = generateUUID(); + return message; +}; + +// This fucntion just converts the incoming payload to array of already not and sends it to processEvent +const process = (events) => { + const eventsArray = CommonUtils.toArray(events); + return eventsArray.map(processEvent); +}; + +module.exports = { process }; diff --git a/test/integrations/sources/adjust/data.ts b/test/integrations/sources/adjust/data.ts new file mode 100644 index 0000000000..975543fbec --- /dev/null +++ b/test/integrations/sources/adjust/data.ts @@ -0,0 +1,122 @@ +import utils from '../../../../src/v0/util'; + +const defaultMockFns = () => { + jest.spyOn(utils, 'generateUUID').mockReturnValue('97fcd7b2-cc24-47d7-b776-057b7b199513'); +}; + +export const data = [ + { + name: 'adjust', + description: 'Simple track call', + module: 'source', + version: 'v0', + input: { + request: { + body: [ + { + id: 'adjust', + query_parameters: { + gps_adid: ['38400000-8cf0-11bd-b23e-10b96e40000d'], + adid: ['18546f6171f67e29d1cb983322ad1329'], + tracker_token: ['abc'], + custom: ['custom'], + tracker_name: ['dummy'], + created_at: ['1404214665'], + event_name: ['Click'], + }, + updated_at: '2023-02-10T12:16:07.251Z', + created_at: '2023-02-10T12:05:04.402Z', + }, + ], + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + body: [ + { + output: { + batch: [ + { + context: { + library: { + name: 'unknown', + version: 'unknown', + }, + integration: { + name: 'Adjust', + }, + device: { + 'id ': '18546f6171f67e29d1cb983322ad1329', + }, + }, + integrations: { + Adjust: false, + }, + type: 'track', + event: 'Click', + originalTimestamp: '2014-07-01T11:37:45.000Z', + timestamp: '2014-07-01T11:37:45.000Z', + properties: { + gps_adid: '38400000-8cf0-11bd-b23e-10b96e40000d', + tracker_token: 'abc', + custom: 'custom', + tracker_name: 'dummy', + }, + anonymousId: '97fcd7b2-cc24-47d7-b776-057b7b199513', + }, + ], + }, + }, + ], + }, + }, + mockFns: () => { + defaultMockFns(); + }, + }, + { + name: 'adjust', + description: 'Simple track call with no query parameters', + module: 'source', + version: 'v0', + input: { + request: { + body: [ + { + id: 'adjust', + updated_at: '2023-02-10T12:16:07.251Z', + created_at: '2023-02-10T12:05:04.402Z', + }, + ], + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + error: 'Query_parameters is missing', + statTags: { + destinationId: 'Non determinable', + errorCategory: 'transformation', + implementation: 'native', + module: 'source', + workspaceId: 'Non determinable', + }, + statusCode: 400, + }, + }, + mockFns: () => { + defaultMockFns(); + }, + }, +]; From 3da5e8abfefd584d005e9d91dc73fe2d4447c8db Mon Sep 17 00:00:00 2001 From: AASHISH MALIK Date: Mon, 27 May 2024 12:08:59 +0530 Subject: [PATCH 3/5] fix: fb custom audience html response (#3402) --- src/v0/util/facebookUtils/index.js | 6 ++ src/v0/util/facebookUtils/index.test.js | 51 ++++++++++++++++ src/v0/util/facebookUtils/networkHandler.js | 13 ++++ .../fb_custom_audience/dataDelivery/other.ts | 47 ++++++++++++++- .../fb_custom_audience/network.ts | 60 +++++++++++++++++++ 5 files changed, 175 insertions(+), 2 deletions(-) diff --git a/src/v0/util/facebookUtils/index.js b/src/v0/util/facebookUtils/index.js index c7753d255f..7462320cca 100644 --- a/src/v0/util/facebookUtils/index.js +++ b/src/v0/util/facebookUtils/index.js @@ -292,7 +292,13 @@ const formingFinalResponse = ( throw new TransformationError('Payload could not be constructed'); }; +const isHtmlFormat = (string) => { + const htmlTags = /<(?!(!doctype\s*html|html))\b[^>]*>[\S\s]*?<\/[^>]*>/i; + return htmlTags.test(string); +}; + module.exports = { + isHtmlFormat, getContentType, getContentCategory, transformedPayloadData, diff --git a/src/v0/util/facebookUtils/index.test.js b/src/v0/util/facebookUtils/index.test.js index 20c4ee59f2..1a2de4ed12 100644 --- a/src/v0/util/facebookUtils/index.test.js +++ b/src/v0/util/facebookUtils/index.test.js @@ -3,6 +3,7 @@ const { fetchUserData, deduceFbcParam, getContentType, + isHtmlFormat, } = require('./index'); const sha256 = require('sha256'); const { MAPPING_CONFIG, CONFIG_CATEGORIES } = require('../../destinations/facebook_pixel/config'); @@ -639,3 +640,53 @@ describe('getContentType', () => { expect(result).toBe(defaultValue); }); }); + +describe('isHtmlFormat', () => { + it('should return false for Json', () => { + expect(isHtmlFormat('{"a": 1, "b":2}')).toBe(false); + }); + + it('should return false for empty Json', () => { + expect(isHtmlFormat('{}')).toBe(false); + }); + + it('should return false for undefined', () => { + expect(isHtmlFormat(undefined)).toBe(false); + }); + + it('should return false for null', () => { + expect(isHtmlFormat(null)).toBe(false); + }); + + it('should return false for empty array', () => { + expect(isHtmlFormat([])).toBe(false); + }); + + it('should return true for html doctype', () => { + expect( + isHtmlFormat( + '

Sorry, something went wrong.

We\'re working on it and we\'ll get it fixed as soon as we can.

Go Back

', + ), + ).toBe(true); + }); + + it('should return true for html', () => { + expect( + isHtmlFormat( + ' Hello, World!

Hello World!

', + ), + ).toBe(true); + }); + + it('should return true for html', () => { + expect( + isHtmlFormat( + '

Hello World!

', + ), + ).toBe(true); + }); + + it('should return false json type', () => { + expect(isHtmlFormat('{"": 12, "b": "test, "arr": [1,2]}')).toBe(false); + }); +}); diff --git a/src/v0/util/facebookUtils/networkHandler.js b/src/v0/util/facebookUtils/networkHandler.js index d5a731067f..a84128e140 100644 --- a/src/v0/util/facebookUtils/networkHandler.js +++ b/src/v0/util/facebookUtils/networkHandler.js @@ -14,6 +14,7 @@ const { } = require('../../../adapters/utils/networkUtils'); const { prepareProxyRequest, proxyRequest } = require('../../../adapters/network'); const { ErrorDetailsExtractorBuilder } = require('../../../util/error-extractor'); +const { isHtmlFormat } = require('./index'); /** * Only under below mentioned scenario(s), add the errorCodes, subCodes etc,. to this map @@ -277,6 +278,18 @@ const errorResponseHandler = (destResponse) => { const destResponseHandler = (responseParams) => { const { destinationResponse } = responseParams; + + // check If the response is in html format + if (isHtmlFormat(destinationResponse.response) || isHtmlFormat(destinationResponse)) { + throw new NetworkError( + 'Invalid response format (HTML) during response transformation', + 500, + { + [TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(destinationResponse.status), + }, + destinationResponse, + ); + } errorResponseHandler(destinationResponse); return { destinationResponse: destinationResponse.response, diff --git a/test/integrations/destinations/fb_custom_audience/dataDelivery/other.ts b/test/integrations/destinations/fb_custom_audience/dataDelivery/other.ts index 52138604b0..2ad5964934 100644 --- a/test/integrations/destinations/fb_custom_audience/dataDelivery/other.ts +++ b/test/integrations/destinations/fb_custom_audience/dataDelivery/other.ts @@ -1,6 +1,6 @@ -import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; -import { ProxyV1TestData } from '../../../testTypes'; import { getEndPoint } from '../../../../../src/v0/destinations/fb_custom_audience/config'; +import { ProxyV1TestData } from '../../../testTypes'; +import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; import { statTags, testParams2 as testParams } from './business'; export const otherScenariosV1: ProxyV1TestData[] = [ @@ -50,4 +50,47 @@ export const otherScenariosV1: ProxyV1TestData[] = [ }, }, }, + { + id: 'fbca_v1_other_scenario_2', + name: 'fb_custom_audience', + description: 'got invalid response format (not-json) from facebook', + successCriteria: 'should throw retyable error', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + method: 'DELETE', + endpoint: getEndPoint('aud1'), + headers: { + 'test-dest-response-key': 'htmlResponse', + }, + params: testParams, + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + status: 500, + message: 'Invalid response format (HTML) during response transformation', + statTags, + response: [ + { + error: + '"

My First Heading

My first paragraph.

"', + statusCode: 500, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + }, + }, ]; diff --git a/test/integrations/destinations/fb_custom_audience/network.ts b/test/integrations/destinations/fb_custom_audience/network.ts index 9b498bc07e..3331f874a3 100644 --- a/test/integrations/destinations/fb_custom_audience/network.ts +++ b/test/integrations/destinations/fb_custom_audience/network.ts @@ -523,4 +523,64 @@ export const networkCallsData = [ status: 400, }, }, + { + httpReq: { + version: '1', + type: 'REST', + method: 'DELETE', + endpoint: getEndPoint('aud1'), + headers: { + 'test-dest-response-key': 'htmlResponse', + }, + params: { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: [ + 'EMAIL', + 'DOBM', + 'DOBD', + 'DOBY', + 'PHONE', + 'GEN', + 'FI', + 'MADID', + 'ZIP', + 'ST', + 'COUNTRY', + ], + data: [ + [ + 'shrouti@abc.com', + '2', + '13', + '2013', + '@09432457768', + 'f', + 'Ms.', + 'ABC', + 'ZIP ', + '123abc ', + 'IN', + ], + ], + }, + }, + userId: '', + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + }, + httpRes: { + data: '

My First Heading

My first paragraph.

', + status: 400, + }, + }, ]; From 9f7fa84474c996a7ac6d398574b4c583d089aab0 Mon Sep 17 00:00:00 2001 From: shrouti1507 Date: Tue, 28 May 2024 20:46:27 +0530 Subject: [PATCH 4/5] fix: adding test cases for old and new config --- .../destinations/af/processor/data.ts | 445 ++++++++++++++++++ 1 file changed, 445 insertions(+) diff --git a/test/integrations/destinations/af/processor/data.ts b/test/integrations/destinations/af/processor/data.ts index 210f04331d..d4ae5eac7b 100644 --- a/test/integrations/destinations/af/processor/data.ts +++ b/test/integrations/destinations/af/processor/data.ts @@ -1838,4 +1838,449 @@ export const data = [ }, }, }, + { + name: 'af', + description: 'No authentication key is present', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + source: 'test', + app: { namespace: 'com.rudderlabs.javascript' }, + os: { name: 'android' }, + traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, + library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, + }, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: { + tax: 2, + total: 27.5, + coupon: 'hasbros', + revenue: 48, + price: 25, + quantity: 2, + }, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + addPropertiesAtRoot: true, + }, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'No authentication key is present. Aborting.', + statTags: { + destType: 'AF', + errorCategory: 'dataValidation', + errorType: 'configuration', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'with authentication process v1, dev key is mandatory', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + source: 'test', + app: { namespace: 'com.rudderlabs.javascript' }, + os: { name: 'android' }, + traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, + library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, + }, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: { + tax: 2, + total: 27.5, + coupon: 'hasbros', + revenue: 48, + price: 25, + quantity: 2, + }, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + authVersion: 'v1', + s2sKey: 'dummy', + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + addPropertiesAtRoot: true, + }, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'dev key is mandatory for v1 authorization. Aborting.', + statTags: { + destType: 'AF', + errorCategory: 'dataValidation', + errorType: 'configuration', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'with authentication process v2, s2s key is mandatory', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + source: 'test', + app: { namespace: 'com.rudderlabs.javascript' }, + os: { name: 'android' }, + traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, + library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, + }, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: { + tax: 2, + total: 27.5, + coupon: 'hasbros', + revenue: 48, + price: 25, + quantity: 2, + }, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + authVersion: 'v2', + devKey: 'dummy', + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + addPropertiesAtRoot: true, + }, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 's2s key is mandatory for v2 authorization. Aborting.', + statTags: { + destType: 'AF', + errorCategory: 'dataValidation', + errorType: 'configuration', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'New Config and old way of authentication', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + source: 'test', + app: { namespace: 'com.rudderlabs.javascript' }, + os: { name: 'android' }, + traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, + library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, + }, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: { + tax: 2, + total: 27.5, + coupon: 'hasbros', + revenue: 48, + price: 25, + quantity: 2, + currency: 'ZAR', + discount: 2.5, + order_id: '50314b8e9bcf000000000000', + products: [ + { + sku: '45790-32', + url: 'https://www.example.com/product/path', + name: 'Monopoly: 3rd Edition', + price: 19, + category: 'Games', + quantity: 1, + image_url: 'https:///www.example.com/product/path.jpg', + product_id: '507f1f77bcf86cd799439011', + }, + { + sku: '46493-32', + name: 'Uno Card Game', + price: 3, + category: 'Games', + quantity: 2, + product_id: '505bd76785ebb509fc183733', + }, + ], + shipping: 3, + subtotal: 22.5, + affiliation: 'Google Store', + checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', + }, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + authVersion: 'v1', + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + addPropertiesAtRoot: true, + }, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', + headers: { 'Content-Type': 'application/json', authentication: 'abcde' }, + params: {}, + body: { + JSON: { + bundleIdentifier: 'com.rudderlabs.javascript', + eventValue: + '{"tax":2,"total":27.5,"coupon":"hasbros","revenue":48,"price":25,"quantity":2,"currency":"ZAR","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"sku":"45790-32","url":"https://www.example.com/product/path","name":"Monopoly: 3rd Edition","price":19,"category":"Games","quantity":1,"image_url":"https:///www.example.com/product/path.jpg","product_id":"507f1f77bcf86cd799439011"},{"sku":"46493-32","name":"Uno Card Game","price":3,"category":"Games","quantity":2,"product_id":"505bd76785ebb509fc183733"}],"shipping":3,"subtotal":22.5,"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","af_revenue":48,"af_price":[19,3],"af_quantity":[1,2],"af_order_id":"50314b8e9bcf000000000000","af_content_id":["507f1f77bcf86cd799439011","505bd76785ebb509fc183733"]}', + eventName: 'Order Completed', + eventCurrency: 'ZAR', + eventTime: '2020-08-14T05:30:30.118Z', + appsflyer_id: 'afUid', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'New Config and new way of authentication', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + source: 'test', + app: { namespace: 'com.rudderlabs.javascript' }, + os: { name: 'android' }, + traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, + library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, + }, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: { + tax: 2, + total: 27.5, + coupon: 'hasbros', + revenue: 48, + price: 25, + quantity: 2, + currency: 'ZAR', + discount: 2.5, + order_id: '50314b8e9bcf000000000000', + products: [ + { + sku: '45790-32', + url: 'https://www.example.com/product/path', + name: 'Monopoly: 3rd Edition', + price: 19, + category: 'Games', + quantity: 1, + image_url: 'https:///www.example.com/product/path.jpg', + product_id: '507f1f77bcf86cd799439011', + }, + { + sku: '46493-32', + name: 'Uno Card Game', + price: 3, + category: 'Games', + quantity: 2, + product_id: '505bd76785ebb509fc183733', + }, + ], + shipping: 3, + subtotal: 22.5, + affiliation: 'Google Store', + checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', + }, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + authVersion: 'v2', + s2sKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + addPropertiesAtRoot: true, + }, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api3.appsflyer.com/inappevent/com.rudderlabs.javascript', + headers: { 'Content-Type': 'application/json', authentication: 'abcde' }, + params: {}, + body: { + JSON: { + bundleIdentifier: 'com.rudderlabs.javascript', + eventValue: + '{"tax":2,"total":27.5,"coupon":"hasbros","revenue":48,"price":25,"quantity":2,"currency":"ZAR","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"sku":"45790-32","url":"https://www.example.com/product/path","name":"Monopoly: 3rd Edition","price":19,"category":"Games","quantity":1,"image_url":"https:///www.example.com/product/path.jpg","product_id":"507f1f77bcf86cd799439011"},{"sku":"46493-32","name":"Uno Card Game","price":3,"category":"Games","quantity":2,"product_id":"505bd76785ebb509fc183733"}],"shipping":3,"subtotal":22.5,"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","af_revenue":48,"af_price":[19,3],"af_quantity":[1,2],"af_order_id":"50314b8e9bcf000000000000","af_content_id":["507f1f77bcf86cd799439011","505bd76785ebb509fc183733"]}', + eventName: 'Order Completed', + eventCurrency: 'ZAR', + eventTime: '2020-08-14T05:30:30.118Z', + appsflyer_id: 'afUid', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, ]; From c9ce77b5c77aa7a81a60c78f08796d4f24deef8f Mon Sep 17 00:00:00 2001 From: shrouti1507 Date: Fri, 7 Jun 2024 16:06:47 +0530 Subject: [PATCH 5/5] fix: review comments addressed --- .../destinations/af/processor/data.ts | 783 +------ .../destinations/af/processor/validation.ts | 2048 +++++++++++++++++ test/integrations/testUtils.ts | 2 + 3 files changed, 2159 insertions(+), 674 deletions(-) create mode 100644 test/integrations/destinations/af/processor/validation.ts diff --git a/test/integrations/destinations/af/processor/data.ts b/test/integrations/destinations/af/processor/data.ts index d4ae5eac7b..9812f7f902 100644 --- a/test/integrations/destinations/af/processor/data.ts +++ b/test/integrations/destinations/af/processor/data.ts @@ -1,4 +1,56 @@ -export const data = [ +import { newConfigValidationTests } from './validation'; + +const commonPropertiesWithProduct = { + tax: 2, + total: 27.5, + coupon: 'hasbros', + revenue: 48, + price: 25, + quantity: 2, + currency: 'ZAR', + discount: 2.5, + order_id: '50314b8e9bcf000000000000', + products: [ + { + sku: '45790-32', + url: 'https://www.example.com/product/path', + name: 'Monopoly: 3rd Edition', + price: 19, + category: 'Games', + quantity: 1, + image_url: 'https:///www.example.com/product/path.jpg', + product_id: '507f1f77bcf86cd799439011', + }, + { + sku: '46493-32', + name: 'Uno Card Game', + price: 3, + category: 'Games', + quantity: 2, + product_id: '505bd76785ebb509fc183733', + }, + ], + shipping: 3, + subtotal: 22.5, + affiliation: 'Google Store', + checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', +}; + +const commonContextWithExternalId = { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + source: 'test', + app: { namespace: 'com.rudderlabs.javascript' }, + os: { name: 'android' }, + traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, + library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, +}; + +const commonHeader = { 'Content-Type': 'application/json', authentication: 'abcde' }; + +const commonV2EndPoint = 'https://api3.appsflyer.com/inappevent/com.rudderlabs.javascript'; +const commonV1EndPoint = 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript'; + +export const existingTestCases = [ { name: 'af', description: 'Test 0', @@ -43,7 +95,7 @@ export const data = [ integrations: { AF: { af_uid: 'afUid' } }, }, destination: { - Config: { devKey: 'ef1d42390426e3f7c90ac78272e74344', androidAppId: 'appId' }, + Config: { devKey: 'abcde', androidAppId: 'appId' }, Enabled: true, addPropertiesAtRoot: false, }, @@ -117,7 +169,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', addPropertiesAtRoot: false, }, @@ -136,11 +188,8 @@ export const data = [ output: { version: '1', type: 'REST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { - 'Content-Type': 'application/json', - authentication: 'ef1d42390426e3f7c90ac78272e74344', - }, + endpoint: commonV1EndPoint, + headers: commonHeader, method: 'POST', params: {}, body: { @@ -208,7 +257,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', }, Enabled: true, @@ -227,11 +276,8 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { - 'Content-Type': 'application/json', - authentication: 'ef1d42390426e3f7c90ac78272e74344', - }, + endpoint: commonV1EndPoint, + headers: commonHeader, params: {}, body: { JSON: { @@ -305,7 +351,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', addPropertiesAtRoot: false, }, @@ -397,7 +443,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', }, Enabled: true, @@ -474,7 +520,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', }, Enabled: true, @@ -493,11 +539,8 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { - 'Content-Type': 'application/json', - authentication: 'ef1d42390426e3f7c90ac78272e74344', - }, + endpoint: commonV1EndPoint, + headers: commonHeader, params: {}, body: { JSON: { @@ -568,7 +611,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', }, Enabled: true, @@ -586,11 +629,8 @@ export const data = [ output: { version: '1', type: 'REST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { - 'Content-Type': 'application/json', - authentication: 'ef1d42390426e3f7c90ac78272e74344', - }, + endpoint: commonV1EndPoint, + headers: commonHeader, method: 'POST', params: {}, body: { @@ -661,7 +701,7 @@ export const data = [ integrations: { AF: { af_uid: 'afUid' } }, }, destination: { - Config: { devKey: 'ef1d42390426e3f7c90ac78272e74344', appleAppId: '123456789' }, + Config: { devKey: 'abcde', appleAppId: '123456789' }, Enabled: true, }, }, @@ -678,10 +718,7 @@ export const data = [ version: '1', type: 'REST', endpoint: 'https://api2.appsflyer.com/inappevent/id123456789', - headers: { - 'Content-Type': 'application/json', - authentication: 'ef1d42390426e3f7c90ac78272e74344', - }, + headers: commonHeader, method: 'POST', params: {}, body: { @@ -722,51 +759,10 @@ export const data = [ type: 'track', event: 'Order Completed', sentAt: '2020-08-14T05:30:30.118Z', - context: { - externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], - source: 'test', - app: { namespace: 'com.rudderlabs.javascript' }, - os: { name: 'android' }, - traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, - library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, - }, + context: commonContextWithExternalId, messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', timestamp: '2020-08-14T05:30:30.118Z', - properties: { - tax: 2, - total: 27.5, - coupon: 'hasbros', - revenue: 48, - price: 25, - quantity: 2, - currency: 'ZAR', - discount: 2.5, - order_id: '50314b8e9bcf000000000000', - products: [ - { - sku: '45790-32', - url: 'https://www.example.com/product/path', - name: 'Monopoly: 3rd Edition', - price: 19, - category: 'Games', - quantity: 1, - image_url: 'https:///www.example.com/product/path.jpg', - product_id: '507f1f77bcf86cd799439011', - }, - { - sku: '46493-32', - name: 'Uno Card Game', - price: 3, - category: 'Games', - quantity: 2, - product_id: '505bd76785ebb509fc183733', - }, - ], - shipping: 3, - subtotal: 22.5, - affiliation: 'Google Store', - checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', - }, + properties: commonPropertiesWithProduct, anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', integrations: { AF: { af_uid: 'afUid' } }, }, @@ -794,8 +790,8 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { 'Content-Type': 'application/json', authentication: 'abcde' }, + endpoint: commonV1EndPoint, + headers: commonHeader, params: {}, body: { JSON: { @@ -834,14 +830,7 @@ export const data = [ type: 'track', event: 'Order Completed', sentAt: '2020-08-14T05:30:30.118Z', - context: { - externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], - source: 'test', - app: { namespace: 'com.rudderlabs.javascript' }, - os: { name: 'android' }, - traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, - library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, - }, + context: commonContextWithExternalId, messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', timestamp: '2020-08-14T05:30:30.118Z', properties: { @@ -886,8 +875,8 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { 'Content-Type': 'application/json', authentication: 'abcde' }, + endpoint: commonV1EndPoint, + headers: commonHeader, params: {}, body: { JSON: { @@ -926,14 +915,7 @@ export const data = [ type: 'track', event: 'Order Completed', sentAt: '2020-08-14T05:30:30.118Z', - context: { - externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], - source: 'test', - app: { namespace: 'com.rudderlabs.javascript' }, - os: { name: 'android' }, - traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, - library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, - }, + context: commonContextWithExternalId, messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', timestamp: '2020-08-14T05:30:30.118Z', anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', @@ -963,8 +945,8 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { 'Content-Type': 'application/json', authentication: 'abcde' }, + endpoint: commonV1EndPoint, + headers: commonHeader, params: {}, body: { JSON: { @@ -1001,51 +983,10 @@ export const data = [ type: 'track', event: 'normal track event', sentAt: '2020-08-14T05:30:30.118Z', - context: { - externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], - source: 'test', - app: { namespace: 'com.rudderlabs.javascript' }, - os: { name: 'android' }, - traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, - library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, - }, + context: commonContextWithExternalId, messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', timestamp: '2020-08-14T05:30:30.118Z', - properties: { - tax: 2, - total: 27.5, - coupon: 'hasbros', - revenue: 48, - price: 25, - quantity: 2, - currency: 'ZAR', - discount: 2.5, - order_id: '50314b8e9bcf000000000000', - products: [ - { - sku: '45790-32', - url: 'https://www.example.com/product/path', - name: 'Monopoly: 3rd Edition', - price: 19, - category: 'Games', - quantity: 1, - image_url: 'https:///www.example.com/product/path.jpg', - product_id: '507f1f77bcf86cd799439011', - }, - { - sku: '46493-32', - name: 'Uno Card Game', - price: 3, - category: 'Games', - quantity: 2, - product_id: '505bd76785ebb509fc183733', - }, - ], - shipping: 3, - subtotal: 22.5, - affiliation: 'Google Store', - checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', - }, + properties: commonPropertiesWithProduct, anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', integrations: { AF: { af_uid: 'afUid' } }, }, @@ -1074,8 +1015,8 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { 'Content-Type': 'application/json', authentication: 'abcde' }, + endpoint: commonV1EndPoint, + headers: commonHeader, params: {}, body: { JSON: { @@ -1114,14 +1055,7 @@ export const data = [ type: 'track', event: 'normal track event', sentAt: '2020-08-14T05:30:30.118Z', - context: { - externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], - source: 'test', - app: { namespace: 'com.rudderlabs.javascript' }, - os: { name: 'android' }, - traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, - library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, - }, + context: commonContextWithExternalId, messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', timestamp: '2020-08-14T05:30:30.118Z', anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', @@ -1151,8 +1085,8 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { 'Content-Type': 'application/json', authentication: 'abcde' }, + endpoint: commonV1EndPoint, + headers: commonHeader, params: {}, body: { JSON: { @@ -1219,7 +1153,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', }, Enabled: true, @@ -1238,11 +1172,8 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { - 'Content-Type': 'application/json', - authentication: 'ef1d42390426e3f7c90ac78272e74344', - }, + endpoint: commonV1EndPoint, + headers: commonHeader, params: {}, body: { JSON: { @@ -1313,7 +1244,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', sharingFilter: ['hello'], }, @@ -1332,11 +1263,8 @@ export const data = [ output: { version: '1', type: 'REST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { - 'Content-Type': 'application/json', - authentication: 'ef1d42390426e3f7c90ac78272e74344', - }, + endpoint: commonV1EndPoint, + headers: commonHeader, method: 'POST', params: {}, body: { @@ -1409,7 +1337,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', sharingFilter: 'all', }, @@ -1428,11 +1356,8 @@ export const data = [ output: { version: '1', type: 'REST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { - 'Content-Type': 'application/json', - authentication: 'ef1d42390426e3f7c90ac78272e74344', - }, + endpoint: commonV1EndPoint, + headers: commonHeader, method: 'POST', params: {}, body: { @@ -1505,7 +1430,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', }, Enabled: true, @@ -1581,7 +1506,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', sharingFilter: 'all', addPropertiesAtRoot: true, @@ -1601,11 +1526,8 @@ export const data = [ output: { version: '1', type: 'REST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { - 'Content-Type': 'application/json', - authentication: 'ef1d42390426e3f7c90ac78272e74344', - }, + endpoint: commonV1EndPoint, + headers: commonHeader, method: 'POST', params: {}, body: { @@ -1674,7 +1596,7 @@ export const data = [ }, destination: { Config: { - devKey: 'ef1d42390426e3f7c90ac78272e74344', + devKey: 'abcde', androidAppId: 'com.rudderlabs.javascript', addPropertiesAtRoot: true, }, @@ -1694,11 +1616,8 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { - 'Content-Type': 'application/json', - authentication: 'ef1d42390426e3f7c90ac78272e74344', - }, + endpoint: commonV1EndPoint, + headers: commonHeader, params: {}, body: { JSON: { @@ -1739,51 +1658,10 @@ export const data = [ type: 'track', event: 'Order Completed', sentAt: '2020-08-14T05:30:30.118Z', - context: { - externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], - source: 'test', - app: { namespace: 'com.rudderlabs.javascript' }, - os: { name: 'android' }, - traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, - library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, - }, + context: commonContextWithExternalId, messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', timestamp: '2020-08-14T05:30:30.118Z', - properties: { - tax: 2, - total: 27.5, - coupon: 'hasbros', - revenue: 48, - price: 25, - quantity: 2, - currency: 'ZAR', - discount: 2.5, - order_id: '50314b8e9bcf000000000000', - products: [ - { - sku: '45790-32', - url: 'https://www.example.com/product/path', - name: 'Monopoly: 3rd Edition', - price: 19, - category: 'Games', - quantity: 1, - image_url: 'https:///www.example.com/product/path.jpg', - product_id: '507f1f77bcf86cd799439011', - }, - { - sku: '46493-32', - name: 'Uno Card Game', - price: 3, - category: 'Games', - quantity: 2, - product_id: '505bd76785ebb509fc183733', - }, - ], - shipping: 3, - subtotal: 22.5, - affiliation: 'Google Store', - checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', - }, + properties: commonPropertiesWithProduct, anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', integrations: { AF: { af_uid: 'afUid' } }, }, @@ -1812,453 +1690,8 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { 'Content-Type': 'application/json', authentication: 'abcde' }, - params: {}, - body: { - JSON: { - bundleIdentifier: 'com.rudderlabs.javascript', - eventValue: - '{"tax":2,"total":27.5,"coupon":"hasbros","revenue":48,"price":25,"quantity":2,"currency":"ZAR","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"sku":"45790-32","url":"https://www.example.com/product/path","name":"Monopoly: 3rd Edition","price":19,"category":"Games","quantity":1,"image_url":"https:///www.example.com/product/path.jpg","product_id":"507f1f77bcf86cd799439011"},{"sku":"46493-32","name":"Uno Card Game","price":3,"category":"Games","quantity":2,"product_id":"505bd76785ebb509fc183733"}],"shipping":3,"subtotal":22.5,"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","af_revenue":48,"af_price":[19,3],"af_quantity":[1,2],"af_order_id":"50314b8e9bcf000000000000","af_content_id":["507f1f77bcf86cd799439011","505bd76785ebb509fc183733"]}', - eventName: 'Order Completed', - eventCurrency: 'ZAR', - eventTime: '2020-08-14T05:30:30.118Z', - appsflyer_id: 'afUid', - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'af', - description: 'No authentication key is present', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'track', - event: 'Order Completed', - sentAt: '2020-08-14T05:30:30.118Z', - context: { - externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], - source: 'test', - app: { namespace: 'com.rudderlabs.javascript' }, - os: { name: 'android' }, - traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, - library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, - }, - messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - timestamp: '2020-08-14T05:30:30.118Z', - properties: { - tax: 2, - total: 27.5, - coupon: 'hasbros', - revenue: 48, - price: 25, - quantity: 2, - }, - anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', - integrations: { AF: { af_uid: 'afUid' } }, - }, - destination: { - Config: { - androidAppId: 'com.rudderlabs.javascript', - groupTypeTrait: 'email', - groupValueTrait: 'age', - trackProductsOnce: false, - trackRevenuePerProduct: false, - addPropertiesAtRoot: true, - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'No authentication key is present. Aborting.', - statTags: { - destType: 'AF', - errorCategory: 'dataValidation', - errorType: 'configuration', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'af', - description: 'with authentication process v1, dev key is mandatory', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'track', - event: 'Order Completed', - sentAt: '2020-08-14T05:30:30.118Z', - context: { - externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], - source: 'test', - app: { namespace: 'com.rudderlabs.javascript' }, - os: { name: 'android' }, - traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, - library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, - }, - messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - timestamp: '2020-08-14T05:30:30.118Z', - properties: { - tax: 2, - total: 27.5, - coupon: 'hasbros', - revenue: 48, - price: 25, - quantity: 2, - }, - anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', - integrations: { AF: { af_uid: 'afUid' } }, - }, - destination: { - Config: { - authVersion: 'v1', - s2sKey: 'dummy', - androidAppId: 'com.rudderlabs.javascript', - groupTypeTrait: 'email', - groupValueTrait: 'age', - trackProductsOnce: false, - trackRevenuePerProduct: false, - addPropertiesAtRoot: true, - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'dev key is mandatory for v1 authorization. Aborting.', - statTags: { - destType: 'AF', - errorCategory: 'dataValidation', - errorType: 'configuration', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'af', - description: 'with authentication process v2, s2s key is mandatory', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'track', - event: 'Order Completed', - sentAt: '2020-08-14T05:30:30.118Z', - context: { - externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], - source: 'test', - app: { namespace: 'com.rudderlabs.javascript' }, - os: { name: 'android' }, - traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, - library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, - }, - messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - timestamp: '2020-08-14T05:30:30.118Z', - properties: { - tax: 2, - total: 27.5, - coupon: 'hasbros', - revenue: 48, - price: 25, - quantity: 2, - }, - anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', - integrations: { AF: { af_uid: 'afUid' } }, - }, - destination: { - Config: { - authVersion: 'v2', - devKey: 'dummy', - androidAppId: 'com.rudderlabs.javascript', - groupTypeTrait: 'email', - groupValueTrait: 'age', - trackProductsOnce: false, - trackRevenuePerProduct: false, - addPropertiesAtRoot: true, - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 's2s key is mandatory for v2 authorization. Aborting.', - statTags: { - destType: 'AF', - errorCategory: 'dataValidation', - errorType: 'configuration', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'af', - description: 'New Config and old way of authentication', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'track', - event: 'Order Completed', - sentAt: '2020-08-14T05:30:30.118Z', - context: { - externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], - source: 'test', - app: { namespace: 'com.rudderlabs.javascript' }, - os: { name: 'android' }, - traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, - library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, - }, - messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - timestamp: '2020-08-14T05:30:30.118Z', - properties: { - tax: 2, - total: 27.5, - coupon: 'hasbros', - revenue: 48, - price: 25, - quantity: 2, - currency: 'ZAR', - discount: 2.5, - order_id: '50314b8e9bcf000000000000', - products: [ - { - sku: '45790-32', - url: 'https://www.example.com/product/path', - name: 'Monopoly: 3rd Edition', - price: 19, - category: 'Games', - quantity: 1, - image_url: 'https:///www.example.com/product/path.jpg', - product_id: '507f1f77bcf86cd799439011', - }, - { - sku: '46493-32', - name: 'Uno Card Game', - price: 3, - category: 'Games', - quantity: 2, - product_id: '505bd76785ebb509fc183733', - }, - ], - shipping: 3, - subtotal: 22.5, - affiliation: 'Google Store', - checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', - }, - anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', - integrations: { AF: { af_uid: 'afUid' } }, - }, - destination: { - Config: { - authVersion: 'v1', - devKey: 'abcde', - androidAppId: 'com.rudderlabs.javascript', - groupTypeTrait: 'email', - groupValueTrait: 'age', - trackProductsOnce: false, - trackRevenuePerProduct: false, - addPropertiesAtRoot: true, - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { 'Content-Type': 'application/json', authentication: 'abcde' }, - params: {}, - body: { - JSON: { - bundleIdentifier: 'com.rudderlabs.javascript', - eventValue: - '{"tax":2,"total":27.5,"coupon":"hasbros","revenue":48,"price":25,"quantity":2,"currency":"ZAR","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"sku":"45790-32","url":"https://www.example.com/product/path","name":"Monopoly: 3rd Edition","price":19,"category":"Games","quantity":1,"image_url":"https:///www.example.com/product/path.jpg","product_id":"507f1f77bcf86cd799439011"},{"sku":"46493-32","name":"Uno Card Game","price":3,"category":"Games","quantity":2,"product_id":"505bd76785ebb509fc183733"}],"shipping":3,"subtotal":22.5,"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","af_revenue":48,"af_price":[19,3],"af_quantity":[1,2],"af_order_id":"50314b8e9bcf000000000000","af_content_id":["507f1f77bcf86cd799439011","505bd76785ebb509fc183733"]}', - eventName: 'Order Completed', - eventCurrency: 'ZAR', - eventTime: '2020-08-14T05:30:30.118Z', - appsflyer_id: 'afUid', - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'af', - description: 'New Config and new way of authentication', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'track', - event: 'Order Completed', - sentAt: '2020-08-14T05:30:30.118Z', - context: { - externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], - source: 'test', - app: { namespace: 'com.rudderlabs.javascript' }, - os: { name: 'android' }, - traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, - library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, - }, - messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', - timestamp: '2020-08-14T05:30:30.118Z', - properties: { - tax: 2, - total: 27.5, - coupon: 'hasbros', - revenue: 48, - price: 25, - quantity: 2, - currency: 'ZAR', - discount: 2.5, - order_id: '50314b8e9bcf000000000000', - products: [ - { - sku: '45790-32', - url: 'https://www.example.com/product/path', - name: 'Monopoly: 3rd Edition', - price: 19, - category: 'Games', - quantity: 1, - image_url: 'https:///www.example.com/product/path.jpg', - product_id: '507f1f77bcf86cd799439011', - }, - { - sku: '46493-32', - name: 'Uno Card Game', - price: 3, - category: 'Games', - quantity: 2, - product_id: '505bd76785ebb509fc183733', - }, - ], - shipping: 3, - subtotal: 22.5, - affiliation: 'Google Store', - checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', - }, - anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', - integrations: { AF: { af_uid: 'afUid' } }, - }, - destination: { - Config: { - authVersion: 'v2', - s2sKey: 'abcde', - androidAppId: 'com.rudderlabs.javascript', - groupTypeTrait: 'email', - groupValueTrait: 'age', - trackProductsOnce: false, - trackRevenuePerProduct: false, - addPropertiesAtRoot: true, - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api3.appsflyer.com/inappevent/com.rudderlabs.javascript', - headers: { 'Content-Type': 'application/json', authentication: 'abcde' }, + endpoint: commonV1EndPoint, + headers: commonHeader, params: {}, body: { JSON: { @@ -2284,3 +1717,5 @@ export const data = [ }, }, ]; + +export const data = [...existingTestCases, ...newConfigValidationTests]; diff --git a/test/integrations/destinations/af/processor/validation.ts b/test/integrations/destinations/af/processor/validation.ts new file mode 100644 index 0000000000..8042570c7d --- /dev/null +++ b/test/integrations/destinations/af/processor/validation.ts @@ -0,0 +1,2048 @@ +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; +import { + generateMetadata, + generateSimplifiedTrackPayload, + overrideDestination, + transformResultBuilder, +} from '../../../testUtils'; + +const destination: Destination = { + ID: '123', + Name: 'AF', + DestinationDefinition: { + ID: '123', + Name: 'AF', + DisplayName: 'Appsflyer', + Config: {}, + }, + Config: { + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + addPropertiesAtRoot: true, + }, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const commonProperties = { + tax: 2, + total: 27.5, + coupon: 'hasbros', + revenue: 48, + price: 25, + quantity: 2, +}; + +const commonPropertiesWithProduct = { + tax: 2, + total: 27.5, + coupon: 'hasbros', + revenue: 48, + price: 25, + quantity: 2, + currency: 'ZAR', + discount: 2.5, + order_id: '50314b8e9bcf000000000000', + products: [ + { + sku: '45790-32', + url: 'https://www.example.com/product/path', + name: 'Monopoly: 3rd Edition', + price: 19, + category: 'Games', + quantity: 1, + image_url: 'https:///www.example.com/product/path.jpg', + product_id: '507f1f77bcf86cd799439011', + }, + { + sku: '46493-32', + name: 'Uno Card Game', + price: 3, + category: 'Games', + quantity: 2, + product_id: '505bd76785ebb509fc183733', + }, + ], + shipping: 3, + subtotal: 22.5, + affiliation: 'Google Store', + checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', +}; + +const commonContextWithExternalId = { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + source: 'test', + app: { namespace: 'com.rudderlabs.javascript' }, + os: { name: 'android' }, + traits: { anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1' }, + library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, +}; + +const commonHeader = { 'Content-Type': 'application/json', authentication: 'abcde' }; + +const commonV2EndPoint = 'https://api3.appsflyer.com/inappevent/com.rudderlabs.javascript'; +const commonV1EndPoint = 'https://api2.appsflyer.com/inappevent/com.rudderlabs.javascript'; + +export const existingTestCases = [ + { + name: 'af', + description: 'Test 0', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { + email: 'testhubspot2@email.com', + name: 'Test Hubspot', + anonymousId: '12345', + }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: 'android', version: '' }, + page: { path: '', referrer: '', search: '', title: '', url: '' }, + screen: { density: 2 }, + }, + type: 'identify', + messageId: '50360b9c-ea8d-409c-b672-c9230f91cce5', + originalTimestamp: '2019-10-15T09:35:31.288Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + userProperties: { test_key: 'test value' }, + sentAt: '2019-10-14T09:03:22.563Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { devKey: 'abcde', androidAppId: 'appId' }, + Enabled: true, + addPropertiesAtRoot: false, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'message type not supported', + statTags: { + destType: 'AF', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 1', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { + email: 'testhubspot2@email.com', + name: 'Test Hubspot', + anonymousId: '12345', + }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: 'android', version: '' }, + screen: { density: 2 }, + }, + type: 'page', + messageId: 'e8585d9a-7137-4223-b295-68ab1b17dad7', + originalTimestamp: '2019-10-15T09:35:31.289Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + properties: { path: '', referrer: '', search: '', title: '', url: '' }, + name: 'ApplicationLoaded', + sentAt: '2019-10-14T11:15:53.296Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + addPropertiesAtRoot: false, + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + endpoint: commonV1EndPoint, + headers: commonHeader, + method: 'POST', + params: {}, + body: { + JSON: { + app_version_name: '1.0.0', + bundleIdentifier: 'com.rudderlabs.javascript', + customer_user_id: '12345', + eventValue: '{"path":"","referrer":"","search":"","title":"","url":""}', + eventName: 'page', + appsflyer_id: 'afUid', + os: '', + ip: '0.0.0.0', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 2', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { email: 'testhubspot2@email.com', name: 'Test Hubspot' }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: 'android', version: '' }, + screen: { density: 2 }, + }, + type: 'track', + messageId: '08829772-d991-427c-b976-b4c4f4430b4e', + originalTimestamp: '2019-10-15T09:35:31.291Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + event: 'test track event HS', + properties: { user_actual_role: 'system_admin, system_user', user_actual_id: 12345 }, + sentAt: '2019-10-14T11:15:53.296Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: commonV1EndPoint, + headers: commonHeader, + params: {}, + body: { + JSON: { + eventValue: + '{"properties":{"user_actual_role":"system_admin, system_user","user_actual_id":12345}}', + eventName: 'test track event HS', + customer_user_id: '12345', + ip: '0.0.0.0', + os: '', + appsflyer_id: 'afUid', + app_version_name: '1.0.0', + bundleIdentifier: 'com.rudderlabs.javascript', + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 3', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + anonymousId: '5094f5704b9cf2b3', + channel: 'mobile', + context: { + app: { + build: '1', + name: 'LeanPlumIntegrationAndroid', + namespace: 'com.android.SampleLeanPlum', + version: '1.0', + }, + device: { + id: '5094f5704b9cf2b3', + manufacturer: 'Google', + model: 'Android SDK built for x86', + name: 'generic_x86', + type: 'android', + }, + library: { name: 'com.rudderstack.android.sdk.core', version: '1.0.1-beta.1' }, + locale: 'en-US', + network: { carrier: 'Android', bluetooth: false, cellular: true, wifi: true }, + os: { name: 'Android', version: '8.1.0' }, + screen: { density: 420, height: 1794, width: 1080 }, + timezone: 'Asia/Kolkata', + traits: { anonymousId: '5094f5704b9cf2b3' }, + userAgent: + 'Dalvik/2.1.0 (Linux; U; Android 8.1.0; Android SDK built for x86 Build/OSM1.180201.007)', + }, + event: 'MainActivity', + integrations: { All: true }, + messageId: 'id1', + properties: { name: 'MainActivity', automatic: true }, + originalTimestamp: '2020-03-12T09:05:03.421Z', + type: 'screen', + sentAt: '2020-03-12T09:05:13.042Z', + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + addPropertiesAtRoot: false, + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'Appsflyer id is not set. Rejecting the event', + statTags: { + destType: 'AF', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 4', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { email: 'test@rudderstack.com' }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-US', + os: { name: 'android', version: '' }, + screen: { density: 2 }, + }, + type: 'track', + messageId: 'ec5481b6-a926-4d2e-b293-0b3a77c4d3be', + originalTimestamp: '2019-10-14T11:15:18.300Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + event: 'checkout started', + properties: { + currency: 'CAD', + products: [ + { + product_id: 'pr1', + quantity: 1, + price: 24.75, + name: 'my product', + sku: 'p-298', + }, + { + product_id: 'pr2', + quantity: 1, + price: 24.75, + name: 'my product 2', + sku: 'p-299', + }, + ], + step: 1, + paymentMethod: 'Visa', + testDimension: true, + testMetric: true, + }, + integrations: { All: true }, + sentAt: '2019-10-14T11:15:53.296Z', + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'Appsflyer id is not set. Rejecting the event', + statTags: { + destType: 'AF', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 5', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [ + { id: 'some_other2345_sample_external_id', type: 'appsflyerExternalId' }, + ], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { + email: 'testhubspot2@email.com', + name: 'Test Hubspot', + anonymousId: '12345', + }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: 'android', version: '' }, + screen: { density: 2 }, + }, + type: 'page', + messageId: 'e8585d9a-7137-4223-b295-68ab1b17dad7', + originalTimestamp: '2019-10-15T09:35:31.289Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + properties: { path: '', referrer: '', search: '', title: '', url: '' }, + name: 'ApplicationLoaded', + sentAt: '2019-10-14T11:15:53.296Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: commonV1EndPoint, + headers: commonHeader, + params: {}, + body: { + JSON: { + bundleIdentifier: 'com.rudderlabs.javascript', + customer_user_id: '12345', + eventValue: '{"path":"","referrer":"","search":"","title":"","url":""}', + eventName: 'page', + appsflyer_id: 'some_other2345_sample_external_id', + os: '', + ip: '0.0.0.0', + app_version_name: '1.0.0', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 6', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { + email: 'testhubspot2@email.com', + name: 'Test Hubspot', + anonymousId: '12345', + }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: 'android', version: '' }, + screen: { density: 2 }, + }, + type: 'page', + messageId: 'e8585d9a-7137-4223-b295-68ab1b17dad7', + originalTimestamp: '2019-10-15T09:35:31.289Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + properties: { path: '', referrer: '', search: '', title: '', url: '' }, + name: 'ApplicationLoaded', + sentAt: '2019-10-14T11:15:53.296Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + endpoint: commonV1EndPoint, + headers: commonHeader, + method: 'POST', + params: {}, + body: { + JSON: { + app_version_name: '1.0.0', + bundleIdentifier: 'com.rudderlabs.javascript', + customer_user_id: '12345', + eventValue: '{"path":"","referrer":"","search":"","title":"","url":""}', + eventName: 'page', + appsflyer_id: 'afUid', + os: '', + ip: '0.0.0.0', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 7', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { + email: 'testhubspot2@email.com', + name: 'Test Hubspot', + anonymousId: '12345', + }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: 'ios', version: '' }, + screen: { density: 2 }, + }, + type: 'page', + messageId: 'e8585d9a-7137-4223-b295-68ab1b17dad7', + originalTimestamp: '2019-10-15T09:35:31.289Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + properties: { path: '', referrer: '', search: '', title: '', url: '' }, + name: 'ApplicationLoaded', + sentAt: '2019-10-14T11:15:53.296Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { devKey: 'abcde', appleAppId: '123456789' }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + endpoint: 'https://api2.appsflyer.com/inappevent/id123456789', + headers: commonHeader, + method: 'POST', + params: {}, + body: { + JSON: { + app_version_name: '1.0.0', + bundleIdentifier: 'com.rudderlabs.javascript', + customer_user_id: '12345', + eventValue: '{"path":"","referrer":"","search":"","title":"","url":""}', + eventName: 'page', + appsflyer_id: 'afUid', + os: '', + ip: '0.0.0.0', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 8', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: commonContextWithExternalId, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: commonPropertiesWithProduct, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + }, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: commonV1EndPoint, + headers: commonHeader, + params: {}, + body: { + JSON: { + bundleIdentifier: 'com.rudderlabs.javascript', + eventValue: + '{"properties":{"tax":2,"total":27.5,"coupon":"hasbros","revenue":48,"price":25,"quantity":2,"currency":"ZAR","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"sku":"45790-32","url":"https://www.example.com/product/path","name":"Monopoly: 3rd Edition","price":19,"category":"Games","quantity":1,"image_url":"https:///www.example.com/product/path.jpg","product_id":"507f1f77bcf86cd799439011"},{"sku":"46493-32","name":"Uno Card Game","price":3,"category":"Games","quantity":2,"product_id":"505bd76785ebb509fc183733"}],"shipping":3,"subtotal":22.5,"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f"},"af_revenue":48,"af_price":[19,3],"af_quantity":[1,2],"af_order_id":"50314b8e9bcf000000000000","af_content_id":["507f1f77bcf86cd799439011","505bd76785ebb509fc183733"]}', + eventName: 'Order Completed', + eventCurrency: 'ZAR', + eventTime: '2020-08-14T05:30:30.118Z', + appsflyer_id: 'afUid', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 9', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: commonContextWithExternalId, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: { + tax: 2, + total: 27.5, + coupon: 'hasbros', + revenue: 48, + price: 25, + quantity: 2, + currency: 'ZAR', + discount: 2.5, + order_id: '50314b8e9bcf000000000000', + shipping: 3, + subtotal: 22.5, + affiliation: 'Google Store', + checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', + }, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + }, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: commonV1EndPoint, + headers: commonHeader, + params: {}, + body: { + JSON: { + bundleIdentifier: 'com.rudderlabs.javascript', + eventValue: + '{"properties":{"tax":2,"total":27.5,"coupon":"hasbros","revenue":48,"price":25,"quantity":2,"currency":"ZAR","discount":2.5,"order_id":"50314b8e9bcf000000000000","shipping":3,"subtotal":22.5,"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f"},"af_revenue":48,"af_price":25,"af_quantity":2,"af_order_id":"50314b8e9bcf000000000000"}', + eventName: 'Order Completed', + eventCurrency: 'ZAR', + eventTime: '2020-08-14T05:30:30.118Z', + appsflyer_id: 'afUid', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 10', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: commonContextWithExternalId, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + }, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: commonV1EndPoint, + headers: commonHeader, + params: {}, + body: { + JSON: { + bundleIdentifier: 'com.rudderlabs.javascript', + eventValue: '', + eventName: 'Order Completed', + eventTime: '2020-08-14T05:30:30.118Z', + appsflyer_id: 'afUid', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 11', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'normal track event', + sentAt: '2020-08-14T05:30:30.118Z', + context: commonContextWithExternalId, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: commonPropertiesWithProduct, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + afCurrencyAtRoot: true, + }, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: commonV1EndPoint, + headers: commonHeader, + params: {}, + body: { + JSON: { + eventValue: + '{"properties":{"tax":2,"total":27.5,"coupon":"hasbros","revenue":48,"price":25,"quantity":2,"currency":"ZAR","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"sku":"45790-32","url":"https://www.example.com/product/path","name":"Monopoly: 3rd Edition","price":19,"category":"Games","quantity":1,"image_url":"https:///www.example.com/product/path.jpg","product_id":"507f1f77bcf86cd799439011"},{"sku":"46493-32","name":"Uno Card Game","price":3,"category":"Games","quantity":2,"product_id":"505bd76785ebb509fc183733"}],"shipping":3,"subtotal":22.5,"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f"},"af_revenue":48,"af_quantity":2,"af_price":25,"af_currency":"ZAR"}', + eventName: 'normal track event', + eventTime: '2020-08-14T05:30:30.118Z', + eventCurrency: 'ZAR', + appsflyer_id: 'afUid', + bundleIdentifier: 'com.rudderlabs.javascript', + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 12', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'normal track event', + sentAt: '2020-08-14T05:30:30.118Z', + context: commonContextWithExternalId, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + }, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: commonV1EndPoint, + headers: commonHeader, + params: {}, + body: { + JSON: { + bundleIdentifier: 'com.rudderlabs.javascript', + eventValue: '', + eventName: 'normal track event', + eventTime: '2020-08-14T05:30:30.118Z', + appsflyer_id: 'afUid', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 13', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { + email: 'testhubspot2@email.com', + name: 'Test Hubspot', + anonymousId: '12345', + }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: 'android', version: '' }, + screen: { density: 2 }, + }, + type: 'page', + messageId: 'e8585d9a-7137-4223-b295-68ab1b17dad7', + originalTimestamp: '2019-10-15T09:35:31.289Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + name: 'ApplicationLoaded', + sentAt: '2019-10-14T11:15:53.296Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: commonV1EndPoint, + headers: commonHeader, + params: {}, + body: { + JSON: { + app_version_name: '1.0.0', + bundleIdentifier: 'com.rudderlabs.javascript', + customer_user_id: '12345', + eventValue: '', + eventName: 'page', + appsflyer_id: 'afUid', + os: '', + ip: '0.0.0.0', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 14', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { + email: 'testhubspot2@email.com', + name: 'Test Hubspot', + anonymousId: '12345', + }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: 'android', version: '' }, + screen: { density: 2 }, + }, + type: 'page', + messageId: 'e8585d9a-7137-4223-b295-68ab1b17dad7', + originalTimestamp: '2019-10-15T09:35:31.289Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + properties: { path: '', referrer: '', search: '', title: '', url: '' }, + name: 'ApplicationLoaded', + sentAt: '2019-10-14T11:15:53.296Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + sharingFilter: ['hello'], + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + endpoint: commonV1EndPoint, + headers: commonHeader, + method: 'POST', + params: {}, + body: { + JSON: { + app_version_name: '1.0.0', + bundleIdentifier: 'com.rudderlabs.javascript', + customer_user_id: '12345', + eventValue: '{"path":"","referrer":"","search":"","title":"","url":""}', + eventName: 'page', + appsflyer_id: 'afUid', + os: '', + ip: '0.0.0.0', + sharing_filter: ['hello'], + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 15', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { + email: 'testhubspot2@email.com', + name: 'Test Hubspot', + anonymousId: '12345', + }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: 'android', version: '' }, + screen: { density: 2 }, + }, + type: 'page', + messageId: 'e8585d9a-7137-4223-b295-68ab1b17dad7', + originalTimestamp: '2019-10-15T09:35:31.289Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + properties: { path: '', referrer: '', search: '', title: '', url: '' }, + name: 'ApplicationLoaded', + sentAt: '2019-10-14T11:15:53.296Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + sharingFilter: 'all', + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + endpoint: commonV1EndPoint, + headers: commonHeader, + method: 'POST', + params: {}, + body: { + JSON: { + app_version_name: '1.0.0', + bundleIdentifier: 'com.rudderlabs.javascript', + customer_user_id: '12345', + eventValue: '{"path":"","referrer":"","search":"","title":"","url":""}', + eventName: 'page', + appsflyer_id: 'afUid', + os: '', + ip: '0.0.0.0', + sharing_filter: 'all', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Test 16', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { + email: 'testhubspot2@email.com', + name: 'Test Hubspot', + anonymousId: '12345', + }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: '', version: '' }, + screen: { density: 2 }, + }, + type: 'page', + messageId: 'e8585d9a-7137-4223-b295-68ab1b17dad7', + originalTimestamp: '2019-10-15T09:35:31.289Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + properties: { path: '', referrer: '', search: '', title: '', url: '' }, + name: 'ApplicationLoaded', + sentAt: '2019-10-14T11:15:53.296Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'os name is required along with the respective appId eg. (os->android & Android App Id is required) or (os->ios & Apple App Id is required)', + statTags: { + destType: 'AF', + errorCategory: 'dataValidation', + errorType: 'configuration', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Place Properties at root level Page Call', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { + email: 'testhubspot2@email.com', + name: 'Test Hubspot', + anonymousId: '12345', + }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: 'android', version: '' }, + screen: { density: 2 }, + }, + type: 'page', + messageId: 'e8585d9a-7137-4223-b295-68ab1b17dad7', + originalTimestamp: '2019-10-15T09:35:31.289Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + properties: { path: '', referrer: '', search: '', title: '', url: '' }, + name: 'ApplicationLoaded', + sentAt: '2019-10-14T11:15:53.296Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + sharingFilter: 'all', + addPropertiesAtRoot: true, + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + endpoint: commonV1EndPoint, + headers: commonHeader, + method: 'POST', + params: {}, + body: { + JSON: { + app_version_name: '1.0.0', + bundleIdentifier: 'com.rudderlabs.javascript', + customer_user_id: '12345', + eventValue: '{"path":"","referrer":"","search":"","title":"","url":""}', + eventName: 'page', + appsflyer_id: 'afUid', + os: '', + ip: '0.0.0.0', + sharing_filter: 'all', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Place properties at root level track call', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + channel: 'web', + context: { + externalId: [{ type: 'appsflyerExternalId', id: 'afUid' }], + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + traits: { email: 'testhubspot2@email.com', name: 'Test Hubspot' }, + library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', + locale: 'en-GB', + ip: '0.0.0.0', + os: { name: 'android', version: '' }, + screen: { density: 2 }, + }, + type: 'track', + messageId: '08829772-d991-427c-b976-b4c4f4430b4e', + originalTimestamp: '2019-10-15T09:35:31.291Z', + anonymousId: '00000000000000000000000000', + userId: '12345', + event: 'test track event HS', + properties: { user_actual_role: 'system_admin, system_user', user_actual_id: 12345 }, + sentAt: '2019-10-14T11:15:53.296Z', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + addPropertiesAtRoot: true, + }, + Enabled: true, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: commonV1EndPoint, + headers: commonHeader, + params: {}, + body: { + JSON: { + eventValue: + '{"user_actual_role":"system_admin, system_user","user_actual_id":12345}', + eventName: 'test track event HS', + customer_user_id: '12345', + ip: '0.0.0.0', + os: '', + appsflyer_id: 'afUid', + app_version_name: '1.0.0', + bundleIdentifier: 'com.rudderlabs.javascript', + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'af', + description: 'Place properties at root track call with af data', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: commonContextWithExternalId, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: commonPropertiesWithProduct, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + destination: { + Config: { + devKey: 'abcde', + androidAppId: 'com.rudderlabs.javascript', + groupTypeTrait: 'email', + groupValueTrait: 'age', + trackProductsOnce: false, + trackRevenuePerProduct: false, + addPropertiesAtRoot: true, + }, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: commonV1EndPoint, + headers: commonHeader, + params: {}, + body: { + JSON: { + bundleIdentifier: 'com.rudderlabs.javascript', + eventValue: + '{"tax":2,"total":27.5,"coupon":"hasbros","revenue":48,"price":25,"quantity":2,"currency":"ZAR","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"sku":"45790-32","url":"https://www.example.com/product/path","name":"Monopoly: 3rd Edition","price":19,"category":"Games","quantity":1,"image_url":"https:///www.example.com/product/path.jpg","product_id":"507f1f77bcf86cd799439011"},{"sku":"46493-32","name":"Uno Card Game","price":3,"category":"Games","quantity":2,"product_id":"505bd76785ebb509fc183733"}],"shipping":3,"subtotal":22.5,"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","af_revenue":48,"af_price":[19,3],"af_quantity":[1,2],"af_order_id":"50314b8e9bcf000000000000","af_content_id":["507f1f77bcf86cd799439011","505bd76785ebb509fc183733"]}', + eventName: 'Order Completed', + eventCurrency: 'ZAR', + eventTime: '2020-08-14T05:30:30.118Z', + appsflyer_id: 'afUid', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, +]; + +export const newConfigValidationTests: ProcessorTestData[] = [ + { + id: 'af-config-validation-test-1', + name: 'af', + description: 'No authentication Key is present', + scenario: 'Framework', + successCriteria: + 'The request should fail as atleast one authentication key is must to propagate request', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: {}, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: commonProperties, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'No authentication key is present. Aborting.', + statTags: { + destinationId: 'default-destinationId', + destType: 'AF', + errorCategory: 'dataValidation', + errorType: 'configuration', + feature: 'processor', + implementation: 'native', + module: 'destination', + workspaceId: 'default-workspaceId', + }, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'af-config-validation-test-2', + name: 'af', + description: 'No dev key present even if v1 authorization is chosen', + scenario: 'Framework', + successCriteria: + 'The request should fail when authorization is of v1 type and there is no dev key', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: overrideDestination(destination, { + authVersion: 'v1', + s2sKey: 'dummy', + }), + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: {}, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: commonProperties, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'dev key is mandatory for v1 authorization. Aborting.', + statTags: { + destType: 'AF', + destinationId: 'default-destinationId', + errorCategory: 'dataValidation', + errorType: 'configuration', + feature: 'processor', + implementation: 'native', + module: 'destination', + workspaceId: 'default-workspaceId', + }, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'af-config-validation-test-3', + name: 'af', + description: 'No dev key present even if v1 authorization is chosen', + scenario: 'Framework', + successCriteria: + 'The request should fail when authorization is of v1 type and there is no dev key', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: overrideDestination(destination, { + authVersion: 'v2', + devKey: 'abcde', + }), + message: { + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: {}, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: commonProperties, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 's2s key is mandatory for v2 authorization. Aborting.', + statTags: { + destType: 'AF', + errorCategory: 'dataValidation', + errorType: 'configuration', + feature: 'processor', + implementation: 'native', + module: 'destination', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', + }, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'af-config-validation-test-4', + name: 'af', + description: 'New Config and old way of authentication', + scenario: 'Business', + successCriteria: 'Response should contain only event payload and status code should be 200', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: overrideDestination(destination, { + authVersion: 'v1', + devKey: 'abcde', + }), + message: generateSimplifiedTrackPayload({ + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: commonContextWithExternalId, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: commonPropertiesWithProduct, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + method: 'POST', + endpoint: commonV1EndPoint, + headers: commonHeader, + JSON: { + customer_user_id: 'default-user-id', + bundleIdentifier: 'com.rudderlabs.javascript', + eventValue: + '{"tax":2,"total":27.5,"coupon":"hasbros","revenue":48,"price":25,"quantity":2,"currency":"ZAR","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"sku":"45790-32","url":"https://www.example.com/product/path","name":"Monopoly: 3rd Edition","price":19,"category":"Games","quantity":1,"image_url":"https:///www.example.com/product/path.jpg","product_id":"507f1f77bcf86cd799439011"},{"sku":"46493-32","name":"Uno Card Game","price":3,"category":"Games","quantity":2,"product_id":"505bd76785ebb509fc183733"}],"shipping":3,"subtotal":22.5,"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","af_revenue":48,"af_price":[19,3],"af_quantity":[1,2],"af_order_id":"50314b8e9bcf000000000000","af_content_id":["507f1f77bcf86cd799439011","505bd76785ebb509fc183733"]}', + eventName: 'Order Completed', + eventCurrency: 'ZAR', + appsflyer_id: 'afUid', + }, + userId: '', + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'af-config-validation-test-5', + name: 'af', + description: 'New Config and new way of authentication', + scenario: 'Business', + successCriteria: 'Response should contain only event payload and status code should be 200', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: overrideDestination(destination, { + authVersion: 'v2', + s2sKey: 'dummy', + }), + message: generateSimplifiedTrackPayload({ + type: 'track', + event: 'Order Completed', + sentAt: '2020-08-14T05:30:30.118Z', + context: commonContextWithExternalId, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: commonPropertiesWithProduct, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { AF: { af_uid: 'afUid' } }, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + method: 'POST', + endpoint: commonV2EndPoint, + headers: { ...commonHeader, authentication: 'dummy' }, + JSON: { + bundleIdentifier: 'com.rudderlabs.javascript', + eventValue: + '{"tax":2,"total":27.5,"coupon":"hasbros","revenue":48,"price":25,"quantity":2,"currency":"ZAR","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"sku":"45790-32","url":"https://www.example.com/product/path","name":"Monopoly: 3rd Edition","price":19,"category":"Games","quantity":1,"image_url":"https:///www.example.com/product/path.jpg","product_id":"507f1f77bcf86cd799439011"},{"sku":"46493-32","name":"Uno Card Game","price":3,"category":"Games","quantity":2,"product_id":"505bd76785ebb509fc183733"}],"shipping":3,"subtotal":22.5,"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","af_revenue":48,"af_price":[19,3],"af_quantity":[1,2],"af_order_id":"50314b8e9bcf000000000000","af_content_id":["507f1f77bcf86cd799439011","505bd76785ebb509fc183733"]}', + eventName: 'Order Completed', + eventCurrency: 'ZAR', + customer_user_id: 'default-user-id', + appsflyer_id: 'afUid', + }, + userId: '', + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/testUtils.ts b/test/integrations/testUtils.ts index 694f224859..a6f0720e37 100644 --- a/test/integrations/testUtils.ts +++ b/test/integrations/testUtils.ts @@ -244,6 +244,8 @@ export const generateSimplifiedTrackPayload: any = (parametersOverride: any) => externalId: parametersOverride.context.externalId, traits: parametersOverride.context.traits, device: parametersOverride.context.device, + os: parametersOverride.context.os, + app: parametersOverride.context.app, }), anonymousId: parametersOverride.anonymousId || 'default-anonymousId', originalTimestamp: parametersOverride.originalTimestamp || '2021-01-03T17:02:53.193Z',