From 9eda50e850c5a1ccb46f1b54c3d176edb915eb27 Mon Sep 17 00:00:00 2001 From: shrouti1507 <60211312+shrouti1507@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:51:50 +0530 Subject: [PATCH] feat: mixpanel set once feature onboard (#2820) * feat: initial commit * feat: making sure existing functionality is intact * fix: edits for exclusion keys * fix: edits for supporting property paths * fix: delete wrong test case * fix: test cases * fix: removed unnecessary code * fix: adding unit test cases for trimTraits * fix: changing the order of priority in property mapping * fix: edited distinct id logic * fix: small edit * fix: review comments addressed * fix: adding dedicated mappingJson for setOnce * fix: adding all the fields to the dedicated json * fix: addressing review comments * feat: review comments addressed --- src/v0/destinations/mp/config.js | 3 + .../destinations/mp/data/MPSetOnceConfig.json | 122 ++++++++ src/v0/destinations/mp/transform.js | 47 ++- src/v0/destinations/mp/util.js | 70 +++++ src/v0/destinations/mp/util.test.js | 94 ++++++ src/v0/util/index.js | 26 ++ test/integrations/destinations/mp/common.ts | 40 ++- .../destinations/mp/processor/data.ts | 271 +++++++++++++++++- 8 files changed, 665 insertions(+), 8 deletions(-) create mode 100644 src/v0/destinations/mp/data/MPSetOnceConfig.json diff --git a/src/v0/destinations/mp/config.js b/src/v0/destinations/mp/config.js index 41a801e9da..35b40294f5 100644 --- a/src/v0/destinations/mp/config.js +++ b/src/v0/destinations/mp/config.js @@ -11,6 +11,9 @@ const ConfigCategory = { IDENTIFY: { name: 'MPIdentifyConfig', }, + SET_ONCE: { + name: 'MPSetOnceConfig', + }, PROFILE_ANDROID: { name: 'MPProfilePropertiesAndroid', }, diff --git a/src/v0/destinations/mp/data/MPSetOnceConfig.json b/src/v0/destinations/mp/data/MPSetOnceConfig.json new file mode 100644 index 0000000000..e5aaf851a3 --- /dev/null +++ b/src/v0/destinations/mp/data/MPSetOnceConfig.json @@ -0,0 +1,122 @@ +[ + { + "destKey": "$created", + "sourceKeys": "createdAt", + "required": false + }, + { + "destKey": "$email", + "sourceKeys": "email", + "required": false + }, + { + "destKey": "$first_name", + "sourceKeys": ["firstName", "firstname", "first_name"], + "required": false + }, + { + "destKey": "$last_name", + "sourceKeys": ["lastName", "lastname", "last_name"], + "required": false + }, + { + "destKey": "$name", + "sourceKeys": "name", + "required": false + }, + { + "destKey": "$username", + "sourceKeys": ["username", "userName"], + "required": false + }, + { + "destKey": "$phone", + "sourceKeys": "phone", + "required": false + }, + { + "destKey": "$avatar", + "sourceKeys": "avatar", + "required": false + }, + { + "destKey": "$country_code", + "sourceKeys": ["country", "address.country"], + "required": false + }, + { + "destKey": "$city", + "sourceKeys": ["city", "address.city"], + "required": false + }, + { + "destKey": "$region", + "sourceKeys": ["state", "address.state", "location.region"], + "required": false + }, + { + "destKey": "$unsubscribed", + "sourceKeys": "unsubscribed", + "required": false + }, + { + "destKey": "$geo_source", + "sourceKeys": "location.geoSource", + "required": false + }, + { + "destKey": "$timezone", + "sourceKeys": "location.timezone", + "required": false + }, + { + "destKey": "$latitude", + "sourceKeys": "location.latitude", + "required": false + }, + { + "destKey": "$longitude", + "sourceKeys": "location.longitude", + "required": false + }, + { + "destKey": "$carrier", + "sourceKeys": "network.carrier", + "required": false + }, + { + "destKey": "$manufacturer", + "sourceKeys": "device.manufacturer", + "required": false + }, + { + "destKey": "$model", + "sourceKeys": "device.model", + "required": false + }, + { + "destKey": "$screen_height", + "sourceKeys": "screen.height", + "required": false + }, + { + "destKey": "$screen_width", + "sourceKeys": "screen.width", + "required": false + }, + { + "destKey": "$wifi", + "sourceKeys": "network.wifi", + "required": false + }, + { + "destKey": "$initial_referrer", + "sourceKeys": "page.initial_referrer", + "required": false + }, + { + "destKey": "$initial_referring_domain", + "sourceKeys": ["page.initial_referring_domain", "page.initialReferringDomain"], + "required": false + } +] diff --git a/src/v0/destinations/mp/transform.js b/src/v0/destinations/mp/transform.js index bb8d3e5756..3d0aaa7c4c 100644 --- a/src/v0/destinations/mp/transform.js +++ b/src/v0/destinations/mp/transform.js @@ -17,6 +17,7 @@ const { checkInvalidRtTfEvents, handleRtTfSingleEventError, groupEventsByType, + parseConfigArray, } = require('../../util'); const { ConfigCategory, @@ -35,6 +36,7 @@ const { combineBatchRequestsWithSameJobIds, groupEventsByEndpoint, batchEvents, + trimTraits, } = require('./util'); const { CommonUtils } = require('../../../util/common'); @@ -226,17 +228,51 @@ const processTrack = (message, destination) => { return returnValue; }; +const createSetOnceResponse = (message, type, destination, setOnce) => { + const payload = { + $set_once: setOnce, + $token: destination.Config.token, + $distinct_id: message.userId || message.anonymousId, + }; + + if (destination?.Config.identityMergeApi === 'simplified') { + payload.$distinct_id = message.userId || `$device:${message.anonymousId}`; + } + + return responseBuilderSimple(payload, message, type, destination.Config); +}; + const processIdentifyEvents = async (message, type, destination) => { + const messageClone = { ...message }; + let seggregatedTraits = {}; const returnValue = []; + let setOnceProperties = []; + + // making payload for set_once properties + if (destination.Config.setOnceProperties && destination.Config.setOnceProperties.length > 0) { + setOnceProperties = parseConfigArray(destination.Config.setOnceProperties, 'property'); + seggregatedTraits = trimTraits( + messageClone.traits, + messageClone.context.traits, + setOnceProperties, + ); + messageClone.traits = seggregatedTraits.traits; + messageClone.context.traits = seggregatedTraits.contextTraits; + if (Object.keys(seggregatedTraits.setOnce).length > 0) { + returnValue.push( + createSetOnceResponse(messageClone, type, destination, seggregatedTraits.setOnce), + ); + } + } // Creating the user profile // https://developer.mixpanel.com/reference/profile-set - returnValue.push(createIdentifyResponse(message, type, destination, responseBuilderSimple)); + returnValue.push(createIdentifyResponse(messageClone, type, destination, responseBuilderSimple)); if ( destination.Config?.identityMergeApi !== 'simplified' && - message.userId && - message.anonymousId && + messageClone.userId && + messageClone.anonymousId && isImportAuthCredentialsAvailable(destination) ) { // If userId and anonymousId both are present and required credentials for /import @@ -245,13 +281,13 @@ const processIdentifyEvents = async (message, type, destination) => { const trackPayload = { event: '$merge', properties: { - $distinct_ids: [message.userId, message.anonymousId], + $distinct_ids: [messageClone.userId, messageClone.anonymousId], token: destination.Config.token, }, }; const identifyTrackResponse = responseBuilderSimple( trackPayload, - message, + messageClone, 'merge', destination.Config, ); @@ -440,7 +476,6 @@ const processRouterDest = async (inputs, reqMetadata) => { destination: event.destination, }; } - let processedEvents = await process(event); processedEvents = CommonUtils.toArray(processedEvents); return processedEvents.map((res) => ({ diff --git a/src/v0/destinations/mp/util.js b/src/v0/destinations/mp/util.js index bb4c23f1b4..bb8f36fdbe 100644 --- a/src/v0/destinations/mp/util.js +++ b/src/v0/destinations/mp/util.js @@ -1,3 +1,4 @@ +const lodash = require('lodash'); const set = require('set-value'); const get = require('get-value'); const { InstrumentationError } = require('@rudderstack/integrations-lib'); @@ -14,6 +15,7 @@ const { defaultBatchRequestConfig, IsGzipSupported, isObject, + isDefinedAndNotNullAndNotEmpty, } = require('../../util'); const { ConfigCategory, @@ -26,6 +28,7 @@ const { CommonUtils } = require('../../../util/common'); const mPIdentifyConfigJson = mappingConfig[ConfigCategory.IDENTIFY.name]; const mPProfileAndroidConfigJson = mappingConfig[ConfigCategory.PROFILE_ANDROID.name]; const mPProfileIosConfigJson = mappingConfig[ConfigCategory.PROFILE_IOS.name]; +const mPSetOnceConfigJson = mappingConfig[ConfigCategory.SET_ONCE.name]; /** * this function has been used to create @@ -322,6 +325,72 @@ const combineBatchRequestsWithSameJobIds = (inputBatches) => { return combineBatches(combineBatches(inputBatches)); }; +/** + * Trims the traits and contextTraits objects based on the setOnceProperties array and returns an object containing the modified traits, contextTraits, and setOnce properties. + * + * @param {object} traits - An object representing the traits. + * @param {object} contextTraits - An object representing the context traits. + * @param {string[]} setOnceProperties - An array of property paths to be considered for the setOnce transformation. + * @returns {object} - An object containing the modified traits, contextTraits, and setOnce properties. + * + * @example + * const traits = { name: 'John', age: 30 }; + * const contextTraits = { country: 'USA', language: 'English', address: { city: 'New York', state: 'NY' }}}; + * const setOnceProperties = ['name', 'country', 'address.city']; + * + * const result = trimTraits(traits, contextTraits, setOnceProperties); + * // Output: { traits: { age: 30 }, contextTraits: { language: 'English' }, setOnce: { $name: 'John', $country_code: 'USA', city: 'New York'} } + */ +function trimTraits(traits, contextTraits, setOnceProperties) { + let sentOnceTransformedPayload; + // Create a copy of the original traits object + const traitsCopy = { ...traits }; + const contextTraitsCopy = { ...contextTraits }; + + // Initialize setOnce object + const setOnceEligible = {}; + + // Step 1: find the k-v pairs of setOnceProperties in traits and contextTraits + + setOnceProperties.forEach((propertyPath) => { + const propName = lodash.last(propertyPath.split('.')); + + const traitsValue = get(traitsCopy, propertyPath); + const contextTraitsValue = get(contextTraitsCopy, propertyPath); + + if (isDefinedAndNotNullAndNotEmpty(traitsValue)) { + setOnceEligible[propName] = traitsValue; + lodash.unset(traitsCopy, propertyPath); + } + if (isDefinedAndNotNullAndNotEmpty(contextTraitsValue)) { + if (!setOnceEligible.hasOwnProperty(propName)) { + setOnceEligible[propName] = contextTraitsValue; + } + lodash.unset(contextTraitsCopy, propertyPath); + } + }); + + if (setOnceEligible && Object.keys(setOnceEligible).length > 0) { + // Step 2: transform properties eligible as per rudderstack declared identify event mapping + // setOnce should have all traits from message.traits and message.context.traits by now + sentOnceTransformedPayload = constructPayload(setOnceEligible, mPSetOnceConfigJson); + + // Step 3: combine the transformed and custom setOnce traits + sentOnceTransformedPayload = extractCustomFields( + setOnceEligible, + sentOnceTransformedPayload, + 'root', + MP_IDENTIFY_EXCLUSION_LIST, + ); + } + + return { + traits: traitsCopy, + contextTraits: contextTraitsCopy, + setOnce: sentOnceTransformedPayload || {}, + }; +} + module.exports = { createIdentifyResponse, isImportAuthCredentialsAvailable, @@ -330,4 +399,5 @@ module.exports = { generateBatchedPayloadForArray, batchEvents, combineBatchRequestsWithSameJobIds, + trimTraits, }; diff --git a/src/v0/destinations/mp/util.test.js b/src/v0/destinations/mp/util.test.js index 6d5b24766d..fbaa6f9b9f 100644 --- a/src/v0/destinations/mp/util.test.js +++ b/src/v0/destinations/mp/util.test.js @@ -4,6 +4,7 @@ const { batchEvents, generateBatchedPayloadForArray, buildUtmParams, + trimTraits, } = require('./util'); const { FEATURE_GZIP_SUPPORT } = require('../../util/constant'); @@ -602,4 +603,97 @@ describe('Mixpanel utils test', () => { }); }); }); + describe('Unit test cases for trimTraits', () => { + // Given a valid traits object and contextTraits object, and a valid setOnceProperties array, the function should return an object containing traits, contextTraits, and setOnce properties. + it('should return an object containing traits, contextTraits, and setOnce properties when given valid inputs', () => { + const traits = { name: 'John', age: 30 }; + const contextTraits = { email: 'john@example.com' }; + const setOnceProperties = ['name', 'email']; + + const result = trimTraits(traits, contextTraits, setOnceProperties); + console.log(result); + + expect(result).toEqual({ + traits: { + age: 30, + }, + contextTraits: {}, + setOnce: { $name: 'John', $email: 'john@example.com' }, + }); + }); + + // Given an empty traits object and contextTraits object, and a valid setOnceProperties array, the function should return an object containing empty traits and contextTraits, and an empty setOnce property. + it('should return an object containing empty traits and contextTraits, and an empty setOnce property when given empty traits and contextTraits objects', () => { + const traits = {}; + const contextTraits = {}; + const setOnceProperties = ['name', 'email']; + + const result = trimTraits(traits, contextTraits, setOnceProperties); + + expect(result).toEqual({ + traits: {}, + contextTraits: {}, + setOnce: {}, + }); + }); + + // Given an empty setOnceProperties array, the function should return an object containing the original traits and contextTraits objects, and an empty setOnce property. + it('should return an object containing the original traits and contextTraits objects, and an empty setOnce property when given an empty setOnceProperties array', () => { + const traits = { name: 'John', age: 30 }; + const contextTraits = { email: 'john@example.com' }; + const setOnceProperties = []; + + const result = trimTraits(traits, contextTraits, setOnceProperties); + + expect(result).toEqual({ + traits: { name: 'John', age: 30 }, + contextTraits: { email: 'john@example.com' }, + setOnce: {}, + }); + }); + + // Given a setOnceProperties array containing properties that do not exist in either traits or contextTraits objects, the function should not add the property to the setOnce property. + it('should not add properties to the setOnce property when given setOnceProperties array with non-existent properties', () => { + const traits = { name: 'John', age: 30 }; + const contextTraits = { email: 'john@example.com' }; + const setOnceProperties = ['name', 'email', 'address']; + + const result = trimTraits(traits, contextTraits, setOnceProperties); + + expect(result).toEqual({ + traits: { age: 30 }, + contextTraits: {}, + setOnce: { $name: 'John', $email: 'john@example.com' }, + }); + }); + + // Given a setOnceProperties array containing properties with nested paths that do not exist in either traits or contextTraits objects, the function should not add the property to the setOnce property. + it('should not add properties to the setOnce property when given setOnceProperties array with non-existent nested properties', () => { + const traits = { name: 'John', age: 30, address: 'kolkata' }; + const contextTraits = { email: 'john@example.com' }; + const setOnceProperties = ['name', 'email', 'address.city']; + + const result = trimTraits(traits, contextTraits, setOnceProperties); + + expect(result).toEqual({ + traits: { age: 30, address: 'kolkata' }, + contextTraits: {}, + setOnce: { $name: 'John', $email: 'john@example.com' }, + }); + }); + + it('should add properties to the setOnce property when given setOnceProperties array with existent nested properties', () => { + const traits = { name: 'John', age: 30, address: { city: 'kolkata' }, isAdult: false }; + const contextTraits = { email: 'john@example.com' }; + const setOnceProperties = ['name', 'email', 'address.city']; + + const result = trimTraits(traits, contextTraits, setOnceProperties); + + expect(result).toEqual({ + traits: { age: 30, address: {}, isAdult: false }, + contextTraits: {}, + setOnce: { $name: 'John', $email: 'john@example.com', $city: 'kolkata' }, + }); + }); + }); }); diff --git a/src/v0/util/index.js b/src/v0/util/index.js index 0296895662..fee1d7a96d 100644 --- a/src/v0/util/index.js +++ b/src/v0/util/index.js @@ -2083,6 +2083,31 @@ const IsGzipSupported = (reqMetadata = {}) => { return false; }; +/** + * Returns an array containing the values of the specified key from each object in the input array. + * If the input array is falsy (null, undefined, empty array), an empty array is returned. + * + * @param {Array} arr - The input array from which values will be extracted. + * @param {string} key - The key of the property whose values will be extracted from each object in the input array. + * @returns {Array} - A new array containing the values of the specified key from each object in the input array. + * + * @example + * const configArray = [ + * { name: 'John', age: 25 }, + * { name: 'Jane', age: 30 }, + * { name: 'Bob', age: 35 } + * ]; + * + * const result = parseConfigArray(configArray, 'name'); + * Output: ['John', 'Jane', 'Bob'] + */ +const parseConfigArray = (arr, key) => { + if (!arr) { + return []; + } + return arr.map((item) => item[key]); +}; + // ======================================================================== // EXPORTS // ======================================================================== @@ -2192,4 +2217,5 @@ module.exports = { isValidInteger, isNewStatusCodesAccepted, IsGzipSupported, + parseConfigArray, }; diff --git a/test/integrations/destinations/mp/common.ts b/test/integrations/destinations/mp/common.ts index ad12566cc6..76ed25a760 100644 --- a/test/integrations/destinations/mp/common.ts +++ b/test/integrations/destinations/mp/common.ts @@ -20,4 +20,42 @@ const sampleDestination = { Transformations: [], }; -export { sampleDestination, defaultMockFns }; +const destinationWithSetOnceProperty = { + Config: { + apiSecret: 'dummySecret', + dataResidency: 'us', + identityMergeApi: 'simplified', + setOnceProperties: [ + { + property: 'nationality', + }, + { + property: 'firstName', + }, + { + property: 'address.city', + }, + ], + superProperties: [ + { + property: 'random', + }, + ], + token: 'dummyToken', + useNativeSDK: false, + useNewMapping: false, + userDeletionApi: 'engage', + whitelistedEvents: [], + }, + DestinationDefinition: { + DisplayName: 'Kiss Metrics', + ID: '1WhbSZ6uA3H5ChVifHpfL2H6sie', + Name: 'MIXPANEL', + }, + Enabled: true, + ID: '1WhcOCGgj9asZu850HvugU2C3Aq', + Name: 'Kiss Metrics', + Transformations: [], +}; + +export { sampleDestination, defaultMockFns, destinationWithSetOnceProperty }; diff --git a/test/integrations/destinations/mp/processor/data.ts b/test/integrations/destinations/mp/processor/data.ts index 2745c09ecc..a6ba51ee78 100644 --- a/test/integrations/destinations/mp/processor/data.ts +++ b/test/integrations/destinations/mp/processor/data.ts @@ -1,5 +1,5 @@ import { overrideDestination } from '../../../testUtils'; -import { sampleDestination, defaultMockFns } from '../common'; +import { sampleDestination, defaultMockFns, destinationWithSetOnceProperty } from '../common'; export const data = [ { @@ -5852,4 +5852,273 @@ export const data = [ }, }, }, + { + name: 'mp', + description: 'Test Set Once Property', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + description: 'Alias: with property beyond and within exclusion list', + destination: destinationWithSetOnceProperty, + 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: { + address: { + city: 'Disney', + }, + country: 'USA', + email: 'TestSanity@disney.com', + firstName: 'Mickey test', + lastName: 'VarChange', + createdAt: '2020-01-23T08:54:02.362Z', + nationality: 'USA', + random: 'superProp', + }, + 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', + }, + request_ip: '[::1]:53709', + type: 'identify', + userId: 'Santiy', + }, + }, + ], + method: 'POST', + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.mixpanel.com/engage/', + headers: {}, + params: {}, + body: { + JSON: {}, + JSON_ARRAY: { + batch: + '[{"$set_once":{"$first_name":"Mickey test","$city":"Disney","nationality":"USA"},"$token":"dummyToken","$distinct_id":"Santiy"}]', + }, + XML: {}, + FORM: {}, + }, + files: {}, + userId: 'Santiy', + }, + statusCode: 200, + }, + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.mixpanel.com/engage/', + headers: {}, + params: {}, + body: { + JSON: {}, + JSON_ARRAY: { + batch: + '[{"$set":{"$created":"2020-01-23T08:54:02.362Z","$email":"TestSanity@disney.com","$country_code":"USA","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","random":"superProp","$lastName":"VarChange","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyToken","$distinct_id":"Santiy","$ip":"0.0.0.0","$time":null}]', + }, + XML: {}, + FORM: {}, + }, + files: {}, + userId: 'Santiy', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'mp', + description: 'Test Set Once Property with anonymousId', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + description: 'Alias: with property beyond and within exclusion list', + destination: destinationWithSetOnceProperty, + message: { + anonymousId: 'dummyAnnonymousId', + 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: { + address: { + city: 'Disney', + }, + country: 'USA', + email: 'TestSanity@disney.com', + firstName: 'Mickey test', + lastName: 'VarChange', + createdAt: '2020-01-23T08:54:02.362Z', + nationality: 'USA', + random: 'superProp', + }, + 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', + }, + request_ip: '[::1]:53709', + type: 'identify', + }, + }, + ], + method: 'POST', + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.mixpanel.com/engage/', + headers: {}, + params: {}, + body: { + JSON: {}, + JSON_ARRAY: { + batch: + '[{"$set_once":{"$first_name":"Mickey test","$city":"Disney","nationality":"USA"},"$token":"dummyToken","$distinct_id":"$device:dummyAnnonymousId"}]', + }, + XML: {}, + FORM: {}, + }, + files: {}, + userId: 'dummyAnnonymousId', + }, + statusCode: 200, + }, + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.mixpanel.com/engage/', + headers: {}, + params: {}, + body: { + JSON: {}, + JSON_ARRAY: { + batch: + '[{"$set":{"$created":"2020-01-23T08:54:02.362Z","$email":"TestSanity@disney.com","$country_code":"USA","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","random":"superProp","$lastName":"VarChange","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyToken","$distinct_id":"$device:dummyAnnonymousId","$ip":"0.0.0.0","$time":null}]', + }, + XML: {}, + FORM: {}, + }, + files: {}, + userId: 'dummyAnnonymousId', + }, + statusCode: 200, + }, + ], + }, + }, + }, ];