From ec5c8a31a5a4d9b3c57bd8211520228f8039ac86 Mon Sep 17 00:00:00 2001 From: Gauravudia Date: Thu, 19 Oct 2023 10:52:26 +0530 Subject: [PATCH] test: add gzip support header in testcase --- src/v0/destinations/mp/config.js | 2 - src/v0/destinations/mp/util.js | 10 +- src/v0/destinations/mp/util.test.js | 9 +- src/v0/util/constant.js | 2 + src/v0/util/index.js | 23 +- .../destinations/mp/router/data.ts | 878 ++++++++++++++++++ 6 files changed, 905 insertions(+), 19 deletions(-) diff --git a/src/v0/destinations/mp/config.js b/src/v0/destinations/mp/config.js index 21026fa947..41a801e9da 100644 --- a/src/v0/destinations/mp/config.js +++ b/src/v0/destinations/mp/config.js @@ -3,7 +3,6 @@ const { getMappingConfig } = require('../../util'); const BASE_ENDPOINT = 'https://api.mixpanel.com'; const BASE_ENDPOINT_EU = 'https://api-eu.mixpanel.com'; const CREATE_DELETION_TASK_ENDPOINT = 'https://mixpanel.com/api/app/data-deletions/v3.0/'; -const FEATURE_GZIP_SUPPORT = 'gzip-support'; const getCreateDeletionTaskEndpoint = (projectToken) => `${CREATE_DELETION_TASK_ENDPOINT}?token=${projectToken}`; @@ -62,7 +61,6 @@ module.exports = { DEL_MAX_BATCH_SIZE, ConfigCategory, BASE_ENDPOINT_EU, - FEATURE_GZIP_SUPPORT, GEO_SOURCE_ALLOWED_VALUES, MP_IDENTIFY_EXCLUSION_LIST, getCreateDeletionTaskEndpoint, diff --git a/src/v0/destinations/mp/util.js b/src/v0/destinations/mp/util.js index 306f29efaf..abc4134302 100644 --- a/src/v0/destinations/mp/util.js +++ b/src/v0/destinations/mp/util.js @@ -11,13 +11,13 @@ const { batchMultiplexedEvents, getSuccessRespEvents, defaultBatchRequestConfig, + IsGzipSupported, } = require('../../util'); const { ConfigCategory, MP_IDENTIFY_EXCLUSION_LIST, GEO_SOURCE_ALLOWED_VALUES, mappingConfig, - FEATURE_GZIP_SUPPORT, } = require('./config'); const { InstrumentationError } = require('../../util/errorTypes'); const { CommonUtils } = require('../../../util/common'); @@ -213,14 +213,6 @@ const groupEventsByEndpoint = (events) => { }; }; -const IsGzipSupported = (reqMetadata = {}) => { - if (reqMetadata && typeof reqMetadata === 'object' && !Array.isArray(reqMetadata)) { - const { features } = reqMetadata; - return !!(features && features[FEATURE_GZIP_SUPPORT]); - } - return false; -}; - const generateBatchedPayloadForArray = (events, reqMetadata) => { const { batchedRequest } = defaultBatchRequestConfig(); const firstEvent = events[0]; diff --git a/src/v0/destinations/mp/util.test.js b/src/v0/destinations/mp/util.test.js index c707d09dfe..b5a1e90a9a 100644 --- a/src/v0/destinations/mp/util.test.js +++ b/src/v0/destinations/mp/util.test.js @@ -4,6 +4,7 @@ const { batchEvents, generateBatchedPayloadForArray, } = require('./util'); +const { FEATURE_GZIP_SUPPORT } = require('../../util/constant'); const destinationMock = { Config: { @@ -524,7 +525,9 @@ describe('Mixpanel utils test', () => { version: '1', }; - const result = generateBatchedPayloadForArray(events); + const result = generateBatchedPayloadForArray(events, { + features: { [FEATURE_GZIP_SUPPORT]: true }, + }); expect(result).toEqual(expectedBatchedRequest); }); @@ -560,7 +563,9 @@ describe('Mixpanel utils test', () => { version: '1', }; - const result = generateBatchedPayloadForArray(events); + const result = generateBatchedPayloadForArray(events, { + features: { [FEATURE_GZIP_SUPPORT]: true }, + }); expect(result).toEqual(expectedBatchedRequest); }); diff --git a/src/v0/util/constant.js b/src/v0/util/constant.js index 50f1b76a74..9996f1ea7c 100644 --- a/src/v0/util/constant.js +++ b/src/v0/util/constant.js @@ -11,6 +11,7 @@ const API_CALL = 'api_call_count'; const JSON_MIME_TYPE = 'application/json'; const FEATURE_FILTER_CODE = 'filter-code'; +const FEATURE_GZIP_SUPPORT = 'gzip-support'; const HTTP_STATUS_CODES = { // 1xx Informational @@ -89,4 +90,5 @@ module.exports = { HTTP_STATUS_CODES, USER_LEAD_CACHE_TTL, FEATURE_FILTER_CODE, + FEATURE_GZIP_SUPPORT, }; diff --git a/src/v0/util/index.js b/src/v0/util/index.js index f534f1acca..8c6f26bf1e 100644 --- a/src/v0/util/index.js +++ b/src/v0/util/index.js @@ -32,7 +32,8 @@ const { REFRESH_TOKEN, AUTH_STATUS_INACTIVE, } = require('../../adapters/networkhandler/authConstants'); -const { FEATURE_FILTER_CODE } = require('./constant'); +const { FEATURE_FILTER_CODE, FEATURE_GZIP_SUPPORT } = require('./constant'); + // ======================================================================== // INLINERS // ======================================================================== @@ -372,7 +373,7 @@ const hashToSha256 = (value) => sha256(value); // Check what type of gender and convert to f or m const getFbGenderVal = (gender) => { - if (typeof (gender) !== 'string') { + if (typeof gender !== 'string') { return null; } if ( @@ -2050,11 +2051,20 @@ const getAuthErrCategoryFromStCode = (status) => { return ''; }; -const validateEventType = event => { - if(!event || typeof event !== "string"){ - throw new InstrumentationError("Event is a required field and should be a string"); +const validateEventType = (event) => { + if (!event || typeof event !== 'string') { + throw new InstrumentationError('Event is a required field and should be a string'); } -} +}; + +const IsGzipSupported = (reqMetadata = {}) => { + if (reqMetadata && typeof reqMetadata === 'object' && !Array.isArray(reqMetadata)) { + const { features } = reqMetadata; + return !!(features && features[FEATURE_GZIP_SUPPORT]); + } + return false; +}; + // ======================================================================== // EXPORTS // ======================================================================== @@ -2161,4 +2171,5 @@ module.exports = { getAuthErrCategoryFromErrDetailsAndStCode, getAuthErrCategoryFromStCode, isNewStatusCodesAccepted, + IsGzipSupported, }; diff --git a/test/integrations/destinations/mp/router/data.ts b/test/integrations/destinations/mp/router/data.ts index 7e0de0693d..7058929909 100644 --- a/test/integrations/destinations/mp/router/data.ts +++ b/test/integrations/destinations/mp/router/data.ts @@ -542,6 +542,9 @@ export const data = [ destType: 'mp', }, method: 'POST', + headers: { + 'X-Feature-Gzip-Support': '?1', + }, }, }, output: { @@ -880,4 +883,879 @@ export const data = [ }, }, }, + { + name: 'mp', + description: 'Test 1', + feature: 'router', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + input: [ + { + description: 'Page call', + destination: overrideDestination(sampleDestination, { + apiSecret: 'test_api_secret', + token: 'test_api_token', + useOldMapping: true, + strictMode: true, + }), + metadata: { + jobId: 1, + additionalProp: 1, + }, + message: { + anonymousId: 'e6ab2c5e-2cda-44a9-a962-e2f67df78bca', + channel: 'web', + name: 'Contact Us', + context: { + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.5', + }, + ip: '0.0.0.0', + library: { + name: 'RudderLabs JavaScript SDK', + version: '1.0.5', + }, + locale: 'en-GB', + os: { + name: '', + version: '', + }, + screen: { + density: 2, + }, + traits: {}, + page: { + path: '/destinations/mixpanel', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/mixpanel', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36', + }, + integrations: { + All: true, + }, + messageId: 'dd266c67-9199-4a52-ba32-f46ddde67312', + originalTimestamp: '2020-01-24T06:29:02.358Z', + page: { + path: '/destinations/mixpanel', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/mixpanel', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + receivedAt: '2020-01-24T11:59:02.403+05:30', + request_ip: '[::1]:53708', + sentAt: '2020-01-24T06:29:02.359Z', + timestamp: '2023-07-06T11:59:02.402+05:30', + type: 'page', + userId: 'hjikl', + }, + }, + { + description: + 'Track: set device id and user id when simplified id merge api is selected', + destination: overrideDestination(sampleDestination, { + apiSecret: 'test_api_secret', + token: 'test_api_token', + identityMergeApi: 'simplified', + strictMode: true, + }), + metadata: { + jobId: 2, + additionalProp: 2, + }, + message: { + anonymousId: 'anonId01', + 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: 'ios', + token: 'test_device_token', + }, + 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: 'iOS', + version: '8.1.0', + }, + screen: { + density: 420, + height: 1794, + width: 1080, + }, + timezone: 'Asia/Kolkata', + userAgent: + 'Dalvik/2.1.0 (Linux; U; Android 8.1.0; Android SDK built for x86 Build/OSM1.180201.007)', + }, + event: 'Product Viewed', + integrations: { + All: true, + }, + userId: 'userId01', + messageId: 'id2', + properties: { + name: 'T-Shirt', + revenue: 18.9, + }, + type: 'track', + originalTimestamp: '2020-01-24T06:29:02.362Z', + receivedAt: '2020-01-24T11:59:02.403+05:30', + sentAt: '2020-01-24T06:29:02.363Z', + timestamp: '2023-07-06T11:59:02.402+05:30', + }, + }, + { + description: 'Identify call to create anonymous user profile', + destination: overrideDestination(sampleDestination, { + apiSecret: 'test_api_secret', + token: 'test_api_token', + useOldMapping: true, + strictMode: true, + }), + metadata: { + jobId: 3, + additionalProp: 3, + }, + message: { + anonymousId: 'e6ab2c5e-2cda-44a9-a962-e2f67df78bca', + channel: 'web', + context: { + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.5', + }, + ip: '0.0.0.0', + library: { + name: 'RudderLabs JavaScript SDK', + version: '1.0.5', + }, + locale: 'en-GB', + os: { + name: '', + version: '', + }, + screen: { + density: 2, + }, + traits: { + city: 'Disney', + country: 'USA', + email: 'mickey@disney.com', + firstName: 'Mickey', + }, + page: { + path: '/destinations/mixpanel', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/mixpanel', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36', + }, + integrations: { + All: true, + }, + page: { + path: '/destinations/mixpanel', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/mixpanel', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + messageId: '2536eda4-d638-4c93-8014-8ffe3f083214', + originalTimestamp: '2020-01-24T06:29:02.362Z', + receivedAt: '2020-01-24T11:59:02.403+05:30', + request_ip: '[::1]:53709', + sentAt: '2020-01-24T06:29:02.363Z', + timestamp: '2023-07-06T11:59:02.402+05:30', + type: 'identify', + userId: '', + }, + }, + { + description: + 'Identify: append $device: to deviceId while creating the user when simplified id merge api is selected', + destination: overrideDestination(sampleDestination, { + apiSecret: 'test_api_secret', + token: 'test_api_token', + identityMergeApi: 'simplified', + strictMode: true, + }), + metadata: { + jobId: 4, + additionalProp: 4, + }, + message: { + anonymousId: 'anonId01', + channel: 'web', + context: { + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.5', + }, + ip: '0.0.0.0', + library: { + name: 'RudderLabs JavaScript SDK', + version: '1.0.5', + }, + locale: 'en-GB', + os: { + name: '', + version: '', + }, + screen: { + density: 2, + }, + traits: { + city: 'Disney', + country: 'USA', + email: 'mickey@disney.com', + firstName: 'Mickey', + lastName: 'Mouse', + createdAt: '2020-01-23T08:54:02.362Z', + }, + page: { + path: '/destinations/mixpanel', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/mixpanel', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36', + }, + integrations: { + All: true, + }, + page: { + path: '/destinations/mixpanel', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/mixpanel', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + messageId: '2536eda4-d638-4c93-8014-8ffe3f083214', + originalTimestamp: '2020-01-24T06:29:02.362Z', + receivedAt: '2020-01-24T11:59:02.403+05:30', + request_ip: '[::1]:53709', + sentAt: '2020-01-24T06:29:02.363Z', + timestamp: '2023-07-06T11:59:02.402+05:30', + type: 'identify', + }, + }, + { + description: 'Merge call with strict mode enabled', + destination: overrideDestination(sampleDestination, { + apiSecret: 'test_api_secret', + token: 'test_api_token', + strictMode: true, + }), + metadata: { + jobId: 5, + additionalProp: 5, + }, + 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: 'ios', + token: 'test_device_token', + }, + 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: 'iOS', + version: '8.1.0', + }, + screen: { + density: 420, + height: 1794, + width: 1080, + }, + timezone: 'Asia/Kolkata', + traits: { + anonymousId: '5094f5704b9cf2b3', + userId: 'test_user_id', + }, + 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, + }, + userId: 'test_user_id', + messageId: 'id2', + properties: { + name: 'MainActivity', + automatic: true, + }, + originalTimestamp: '2020-03-12T09:05:03.421Z', + type: 'identify', + sentAt: '2020-03-12T09:05:13.042Z', + }, + }, + { + description: 'Group call', + destination: overrideDestination(sampleDestination, { + apiSecret: 'test_api_secret', + token: 'test_api_token', + groupKeySettings: [ + { + groupKey: 'company', + }, + ], + strictMode: true, + }), + metadata: { + jobId: 6, + additionalProp: 6, + }, + message: { + anonymousId: 'anonId06', + channel: 'web', + context: { + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.5', + }, + ip: '0.0.0.0', + library: { + name: 'RudderLabs JavaScript SDK', + version: '1.0.5', + }, + locale: 'en-GB', + os: { + name: '', + version: '', + }, + screen: { + density: 2, + }, + page: { + path: '/destinations/mixpanel', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/mixpanel', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36', + }, + integrations: { + All: true, + }, + page: { + path: '/destinations/mixpanel', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/mixpanel', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + traits: { + company: 'testComp', + }, + messageId: '2536eda4-d638-4c93-8014-8ffe3f083214', + originalTimestamp: '2020-01-24T06:29:02.362Z', + receivedAt: '2020-01-24T11:59:02.403+05:30', + request_ip: '[::1]:53709', + sentAt: '2020-01-24T06:29:02.363Z', + timestamp: '2023-07-06T11:59:02.402+05:30', + type: 'group', + userId: 'userId06', + }, + }, + { + description: 'Group key not present in traits', + destination: overrideDestination(sampleDestination, { + apiSecret: 'test_api_secret', + token: 'test_api_token', + groupKeySettings: [ + { + groupKey: 'company', + }, + ], + strictMode: true, + }), + metadata: { + jobId: 7, + additionalProp: 7, + }, + message: { + anonymousId: 'anonId06', + channel: 'web', + context: { + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.5', + }, + ip: '0.0.0.0', + library: { + name: 'RudderLabs JavaScript SDK', + version: '1.0.5', + }, + locale: 'en-GB', + os: { + name: '', + version: '', + }, + screen: { + density: 2, + }, + page: { + path: '/destinations/mixpanel', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/mixpanel', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36', + }, + integrations: { + All: true, + }, + page: { + path: '/destinations/mixpanel', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/mixpanel', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + messageId: '2536eda4-d638-4c93-8014-8ffe3f083214', + originalTimestamp: '2020-01-24T06:29:02.362Z', + receivedAt: '2020-01-24T11:59:02.403+05:30', + request_ip: '[::1]:53709', + sentAt: '2020-01-24T06:29:02.363Z', + timestamp: '2023-07-06T11:59:02.402+05:30', + type: 'group', + userId: 'userId06', + }, + }, + ], + destType: 'mp', + }, + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: [ + { + batchedRequest: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.mixpanel.com/import/', + headers: { + 'Content-Type': 'application/json', + Authorization: 'Basic dGVzdF9hcGlfc2VjcmV0Og==', + }, + params: { + strict: 1, + }, + body: { + JSON: {}, + JSON_ARRAY: { + batch: + '[{"event":"Loaded a Page","properties":{"ip":"0.0.0.0","$user_id":"hjikl","$current_url":"https://docs.rudderstack.com/destinations/mixpanel","$screen_dpi":2,"mp_lib":"RudderLabs JavaScript SDK","$app_build_number":"1.0.0","$app_version_string":"1.0.5","$insert_id":"dd266c67-9199-4a52-ba32-f46ddde67312","token":"test_api_token","distinct_id":"hjikl","time":1688624942,"name":"Contact Us","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + }, + XML: {}, + FORM: {}, + }, + files: {}, + }, + metadata: [ + { + jobId: 1, + additionalProp: 1, + }, + ], + batched: true, + statusCode: 200, + destination: { + Config: { + apiKey: 'dummyApiKey', + apiSecret: 'test_api_secret', + token: 'test_api_token', + prefixProperties: true, + useNativeSDK: false, + useOldMapping: true, + strictMode: true, + }, + DestinationDefinition: { + DisplayName: 'Mixpanel', + ID: '1WhbSZ6uA3H5ChVifHpfL2H6sie', + Name: 'MP', + }, + Enabled: true, + ID: '1WhcOCGgj9asZu850HvugU2C3Aq', + Name: 'MP', + Transformations: [], + }, + }, + { + batchedRequest: [ + { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.mixpanel.com/engage/', + headers: {}, + params: {}, + body: { + JSON: {}, + JSON_ARRAY: { + batch: + '[{"$append":{"$transactions":{"$time":"2023-07-06T06:29:02.402Z","$amount":18.9}},"$token":"test_api_token","$distinct_id":"userId01"}]', + }, + XML: {}, + FORM: {}, + }, + files: {}, + }, + { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.mixpanel.com/import/', + headers: { + 'Content-Type': 'application/json', + Authorization: 'Basic dGVzdF9hcGlfc2VjcmV0Og==', + }, + params: { + strict: 1, + }, + body: { + JSON: {}, + JSON_ARRAY: { + batch: + '[{"event":"Product Viewed","properties":{"name":"T-Shirt","revenue":18.9,"$user_id":"userId01","$os":"iOS","$screen_height":1794,"$screen_width":1080,"$screen_dpi":420,"$carrier":"Android","$os_version":"8.1.0","$device":"generic_x86","$manufacturer":"Google","$model":"Android SDK built for x86","mp_device_model":"Android SDK built for x86","$wifi":true,"$bluetooth_enabled":false,"mp_lib":"com.rudderstack.android.sdk.core","$app_build_number":"1","$app_version_string":"1.0","$insert_id":"id2","token":"test_api_token","distinct_id":"userId01","time":1688624942,"$device_id":"anonId01"}}]', + }, + XML: {}, + FORM: {}, + }, + files: {}, + }, + ], + metadata: [ + { + jobId: 2, + additionalProp: 2, + }, + ], + batched: true, + statusCode: 200, + destination: { + Config: { + apiKey: 'dummyApiKey', + apiSecret: 'test_api_secret', + token: 'test_api_token', + prefixProperties: true, + identityMergeApi: 'simplified', + strictMode: true, + useNativeSDK: false, + }, + DestinationDefinition: { + DisplayName: 'Mixpanel', + ID: '1WhbSZ6uA3H5ChVifHpfL2H6sie', + Name: 'MP', + }, + Enabled: true, + ID: '1WhcOCGgj9asZu850HvugU2C3Aq', + Name: 'MP', + Transformations: [], + }, + }, + { + batchedRequest: [ + { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.mixpanel.com/engage/', + headers: {}, + params: {}, + body: { + JSON: {}, + JSON_ARRAY: { + batch: + '[{"$set":{"$email":"mickey@disney.com","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$firstName":"Mickey","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"test_api_token","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1688624942},{"$set":{"$created":"2020-01-23T08:54:02.362Z","$email":"mickey@disney.com","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$firstName":"Mickey","$lastName":"Mouse","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"test_api_token","$distinct_id":"$device:anonId01","$ip":"0.0.0.0","$time":1688624942},{"$set":{"$carrier":"Android","$manufacturer":"Google","$model":"Android SDK built for x86","$screen_height":1794,"$screen_width":1080,"$wifi":true,"anonymousId":"5094f5704b9cf2b3","userId":"test_user_id","$ios_devices":["test_device_token"],"$os":"iOS","$ios_device_model":"Android SDK built for x86","$ios_version":"8.1.0","$ios_app_release":"1","$ios_app_version":"1.0"},"$token":"test_api_token","$distinct_id":"test_user_id","$time":null}]', + }, + XML: {}, + FORM: {}, + }, + files: {}, + }, + { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.mixpanel.com/import/', + headers: { + 'Content-Type': 'application/json', + Authorization: 'Basic dGVzdF9hcGlfc2VjcmV0Og==', + }, + params: { + strict: 1, + }, + body: { + JSON: {}, + JSON_ARRAY: { + batch: + '[{"event":"$merge","properties":{"$distinct_ids":["test_user_id","5094f5704b9cf2b3"],"token":"test_api_token"}}]', + }, + XML: {}, + FORM: {}, + }, + files: {}, + }, + ], + metadata: [ + { + jobId: 3, + additionalProp: 3, + }, + { + jobId: 4, + additionalProp: 4, + }, + { + jobId: 5, + additionalProp: 5, + }, + ], + batched: true, + statusCode: 200, + destination: { + Config: { + apiKey: 'dummyApiKey', + apiSecret: 'test_api_secret', + token: 'test_api_token', + prefixProperties: true, + useNativeSDK: false, + useOldMapping: true, + strictMode: true, + }, + DestinationDefinition: { + DisplayName: 'Mixpanel', + ID: '1WhbSZ6uA3H5ChVifHpfL2H6sie', + Name: 'MP', + }, + Enabled: true, + ID: '1WhcOCGgj9asZu850HvugU2C3Aq', + Name: 'MP', + Transformations: [], + }, + }, + { + batchedRequest: [ + { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.mixpanel.com/engage/', + headers: {}, + params: {}, + body: { + JSON: {}, + JSON_ARRAY: { + batch: + '[{"$token":"test_api_token","$distinct_id":"userId06","$set":{"company":["testComp"]},"$ip":"0.0.0.0"}]', + }, + XML: {}, + FORM: {}, + }, + files: {}, + }, + { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.mixpanel.com/groups/', + headers: {}, + params: {}, + body: { + JSON: {}, + JSON_ARRAY: { + batch: + '[{"$token":"test_api_token","$group_key":"company","$group_id":"testComp","$set":{"company":"testComp"}}]', + }, + XML: {}, + FORM: {}, + }, + files: {}, + }, + ], + metadata: [ + { + jobId: 6, + additionalProp: 6, + }, + ], + batched: true, + statusCode: 200, + destination: { + Config: { + apiKey: 'dummyApiKey', + apiSecret: 'test_api_secret', + token: 'test_api_token', + prefixProperties: true, + groupKeySettings: [ + { + groupKey: 'company', + }, + ], + strictMode: true, + useNativeSDK: false, + }, + DestinationDefinition: { + DisplayName: 'Mixpanel', + ID: '1WhbSZ6uA3H5ChVifHpfL2H6sie', + Name: 'MP', + }, + Enabled: true, + ID: '1WhcOCGgj9asZu850HvugU2C3Aq', + Name: 'MP', + Transformations: [], + }, + }, + { + metadata: [ + { + jobId: 7, + additionalProp: 7, + }, + ], + batched: false, + statusCode: 400, + error: + 'Group Key is not present. Please ensure that the group key is included in the payload as configured in the `Group Key Settings` in destination', + statTags: { + destType: 'MP', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'router', + implementation: 'native', + module: 'destination', + }, + destination: { + Config: { + apiKey: 'dummyApiKey', + apiSecret: 'test_api_secret', + token: 'test_api_token', + prefixProperties: true, + useNativeSDK: false, + groupKeySettings: [ + { + groupKey: 'company', + }, + ], + strictMode: true, + }, + DestinationDefinition: { + DisplayName: 'Mixpanel', + ID: '1WhbSZ6uA3H5ChVifHpfL2H6sie', + Name: 'MP', + }, + Enabled: true, + ID: '1WhcOCGgj9asZu850HvugU2C3Aq', + Name: 'MP', + Transformations: [], + }, + }, + ], + }, + }, + }, + }, ];