From 0b5720446693efe1fd0ccdfc141bd7f21b2c32ae Mon Sep 17 00:00:00 2001 From: Anant Jain <62471433+anantjain45823@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:57:09 +0530 Subject: [PATCH 01/25] fix: hubspot: search for contact using secondary prop (#3258) * fix: hubspot: search for contact using secondary prop * chore: include network.ts file * chore: address comments --- src/v0/destinations/hs/HSTransform-v2.js | 4 +- src/v0/destinations/hs/config.js | 4 + src/v0/destinations/hs/util.js | 113 ++++++++++++-- src/v0/destinations/hs/util.test.js | 14 +- test/integrations/destinations/hs/network.ts | 31 ++++ .../destinations/hs/router/data.ts | 141 ++++++++++++++++++ 6 files changed, 288 insertions(+), 19 deletions(-) diff --git a/src/v0/destinations/hs/HSTransform-v2.js b/src/v0/destinations/hs/HSTransform-v2.js index 2acdd82152..3699e1c789 100644 --- a/src/v0/destinations/hs/HSTransform-v2.js +++ b/src/v0/destinations/hs/HSTransform-v2.js @@ -12,7 +12,6 @@ const { defaultPatchRequestConfig, getFieldValueFromMessage, getSuccessRespEvents, - addExternalIdToTraits, defaultBatchRequestConfig, removeUndefinedAndNullValues, getDestinationExternalID, @@ -42,6 +41,7 @@ const { getEventAndPropertiesFromConfig, getHsSearchId, populateTraits, + addExternalIdToHSTraits, } = require('./util'); const { JSON_MIME_TYPE } = require('../../util/constant'); @@ -110,7 +110,7 @@ const processIdentify = async (message, destination, propertyMap) => { GENERIC_TRUE_VALUES.includes(mappedToDestination.toString()) && operation ) { - addExternalIdToTraits(message); + addExternalIdToHSTraits(message); if (!objectType) { throw new InstrumentationError('objectType not found'); } diff --git a/src/v0/destinations/hs/config.js b/src/v0/destinations/hs/config.js index fb9790f0e5..67ad3b5bed 100644 --- a/src/v0/destinations/hs/config.js +++ b/src/v0/destinations/hs/config.js @@ -84,6 +84,9 @@ const RETL_SOURCE = 'rETL'; const mappingConfig = getMappingConfig(ConfigCategory, __dirname); const hsCommonConfigJson = mappingConfig[ConfigCategory.COMMON.name]; +const primaryToSecondaryFields = { + email: 'hs_additional_emails', +}; module.exports = { BASE_ENDPOINT, CONTACT_PROPERTY_MAP_ENDPOINT, @@ -112,5 +115,6 @@ module.exports = { RETL_SOURCE, RETL_CREATE_ASSOCIATION_OPERATION, MAX_CONTACTS_PER_REQUEST, + primaryToSecondaryFields, DESTINATION: 'HS', }; diff --git a/src/v0/destinations/hs/util.js b/src/v0/destinations/hs/util.js index 838da08b3b..ffb2df5237 100644 --- a/src/v0/destinations/hs/util.js +++ b/src/v0/destinations/hs/util.js @@ -1,5 +1,6 @@ /* eslint-disable no-await-in-loop */ const lodash = require('lodash'); +const set = require('set-value'); const get = require('get-value'); const { NetworkInstrumentationError, @@ -28,6 +29,7 @@ const { IDENTIFY_CRM_SEARCH_ALL_OBJECTS, SEARCH_LIMIT_VALUE, hsCommonConfigJson, + primaryToSecondaryFields, DESTINATION, MAX_CONTACTS_PER_REQUEST, } = require('./config'); @@ -576,16 +578,30 @@ const performHubSpotSearch = async ( checkAfter = after; // assigning to the new value if no after we assign it to 0 and no more calls will take place const results = processedResponse.response?.results; + const extraProp = primaryToSecondaryFields[identifierType]; if (results) { searchResults.push( - ...results.map((result) => ({ - id: result.id, - property: result.properties[identifierType], - })), + ...results.map((result) => { + const contact = { + id: result.id, + property: result.properties[identifierType], + }; + // Following maps the extra property to the contact object which + // help us to know if the contact was found using secondary property + if (extraProp) { + contact[extraProp] = result.properties?.[extraProp]; + } + return contact; + }), ); } } - + /* + searchResults = { + id: 'existing_contact_id', + property: 'existing_contact_email', // when email is identifier + hs_additional_emails: ['secondary_email'] // when email is identifier + } */ return searchResults; }; @@ -612,7 +628,25 @@ const getRequestData = (identifierType, chunk) => { limit: SEARCH_LIMIT_VALUE, after: 0, }; - + /* In case of email as identifier we add a filter for hs_additional_emails field + * and append hs_additional_emails to properties list + * We are doing this because there might be emails exisitng as hs_additional_emails for some conatct but + * will not come up in search API until we search with hs_additional_emails as well. + * Not doing this resulted in erro 409 Duplicate records found + */ + const secondaryProp = primaryToSecondaryFields[identifierType]; + if (secondaryProp) { + requestData.filterGroups.push({ + filters: [ + { + propertyName: secondaryProp, + values: chunk, + operator: 'IN', + }, + ], + }); + requestData.properties.push(secondaryProp); + } return requestData; }; @@ -623,7 +657,7 @@ const getRequestData = (identifierType, chunk) => { */ const getExistingContactsData = async (inputs, destination) => { const { Config } = destination; - const updateHubspotIds = []; + const hsIdsToBeUpdated = []; const firstMessage = inputs[0].message; if (!firstMessage) { @@ -651,13 +685,19 @@ const getExistingContactsData = async (inputs, destination) => { destination, ); if (searchResults.length > 0) { - updateHubspotIds.push(...searchResults); + hsIdsToBeUpdated.push(...searchResults); } } - return updateHubspotIds; + return hsIdsToBeUpdated; }; - -const setHsSearchId = (input, id) => { +/** + * This functions sets HsSearchId in the externalId array + * @param {*} input -> Input message + * @param {*} id -> Id to be added + * @param {*} useSecondaryProp -> Let us know if that id was found using secondary property and not primnary + * @returns + */ +const setHsSearchId = (input, id, useSecondaryProp = false) => { const { message } = input; const resultExternalId = []; const externalIdArray = message.context?.externalId; @@ -668,6 +708,11 @@ const setHsSearchId = (input, id) => { if (type.includes(DESTINATION)) { extIdObjParam.hsSearchId = id; } + if (useSecondaryProp) { + // we are using it so that when final payload is made + // then primary key shouldn't be overidden + extIdObjParam.useSecondaryObject = useSecondaryProp; + } resultExternalId.push(extIdObjParam); }); } @@ -680,20 +725,24 @@ const setHsSearchId = (input, id) => { * We do search for all the objects before router transform and assign the type (create/update) * accordingly to context.hubspotOperation * + * For email as primary key we use `hs_additional_emails` as well property to search existing contacts * */ const splitEventsForCreateUpdate = async (inputs, destination) => { // get all the id and properties of already existing objects needed for update. - const updateHubspotIds = await getExistingContactsData(inputs, destination); + const hsIdsToBeUpdated = await getExistingContactsData(inputs, destination); const resultInput = inputs.map((input) => { const { message } = input; const inputParam = input; - const { destinationExternalId } = getDestinationExternalIDInfoForRetl(message, DESTINATION); + const { destinationExternalId, identifierType } = getDestinationExternalIDInfoForRetl( + message, + DESTINATION, + ); - const filteredInfo = updateHubspotIds.filter( + const filteredInfo = hsIdsToBeUpdated.filter( (update) => - update.property.toString().toLowerCase() === destinationExternalId.toString().toLowerCase(), + update.property.toString().toLowerCase() === destinationExternalId.toString().toLowerCase(), // second condition is for secondary property for identifier type ); if (filteredInfo.length > 0) { @@ -701,6 +750,26 @@ const splitEventsForCreateUpdate = async (inputs, destination) => { inputParam.message.context.hubspotOperation = 'updateObject'; return inputParam; } + const secondaryProp = primaryToSecondaryFields[identifierType]; + if (secondaryProp) { + // second condition is for secondary property for identifier type + const filteredInfoForSecondaryProp = hsIdsToBeUpdated.filter((update) => + update[secondaryProp] + ?.toString() + .toLowerCase() + .includes(destinationExternalId.toString().toLowerCase()), + ); + if (filteredInfoForSecondaryProp.length > 0) { + inputParam.message.context.externalId = setHsSearchId( + input, + filteredInfoForSecondaryProp[0].id, + true, + ); + inputParam.message.context.hubspotOperation = 'updateObject'; + return inputParam; + } + } + // if not found in the existing contacts, then it's a new contact inputParam.message.context.hubspotOperation = 'createObject'; return inputParam; }); @@ -748,8 +817,22 @@ const populateTraits = async (propertyMap, traits, destination) => { return populatedTraits; }; +const addExternalIdToHSTraits = (message) => { + const externalIdObj = message.context?.externalId?.[0]; + if (externalIdObj.useSecondaryObject) { + /* this condition help us to NOT override the primary key value with the secondary key value + example: + for `email` as primary key and `hs_additonal_emails` as secondary key we don't want to override `email` with `hs_additional_emails`. + neither we want to map anything for `hs_additional_emails` as this property can not be set + */ + return; + } + set(getFieldValueFromMessage(message, 'traits'), externalIdObj.identifierType, externalIdObj.id); +}; + module.exports = { validateDestinationConfig, + addExternalIdToHSTraits, formatKey, fetchFinalSetOfTraits, getProperties, diff --git a/src/v0/destinations/hs/util.test.js b/src/v0/destinations/hs/util.test.js index 30e89d3aee..ea2e10dc3d 100644 --- a/src/v0/destinations/hs/util.test.js +++ b/src/v0/destinations/hs/util.test.js @@ -4,6 +4,7 @@ const { validatePayloadDataTypes, getObjectAndIdentifierType, } = require('./util'); +const { primaryToSecondaryFields } = require('./config'); const propertyMap = { firstName: 'string', @@ -205,7 +206,7 @@ describe('extractUniqueValues utility test cases', () => { describe('getRequestDataAndRequestOptions utility test cases', () => { it('Should return an object with requestData and requestOptions', () => { const identifierType = 'email'; - const chunk = 'test1@gmail.com'; + const chunk = ['test1@gmail.com']; const accessToken = 'dummyAccessToken'; const expectedRequestData = { @@ -219,8 +220,17 @@ describe('getRequestDataAndRequestOptions utility test cases', () => { }, ], }, + { + filters: [ + { + propertyName: primaryToSecondaryFields[identifierType], + values: chunk, + operator: 'IN', + }, + ], + }, ], - properties: [identifierType], + properties: [identifierType, primaryToSecondaryFields[identifierType]], limit: 100, after: 0, }; diff --git a/test/integrations/destinations/hs/network.ts b/test/integrations/destinations/hs/network.ts index e29cc27562..3d3b8fd83f 100644 --- a/test/integrations/destinations/hs/network.ts +++ b/test/integrations/destinations/hs/network.ts @@ -460,6 +460,37 @@ export const networkCallsData = [ status: 200, }, }, + { + httpReq: { + url: 'https://api.hubapi.com/crm/v3/objects/contacts/search', + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: 'Bearer dummy-access-token-hs-additonal-email', + }, + }, + httpRes: { + data: { + total: 1, + results: [ + { + id: '103689', + properties: { + createdate: '2022-07-15T15:25:08.975Z', + email: 'primary@email.com', + hs_object_id: '103604', + hs_additional_emails: 'abc@extraemail.com;secondary@email.com', + lastmodifieddate: '2022-07-15T15:26:49.590Z', + }, + createdAt: '2022-07-15T15:25:08.975Z', + updatedAt: '2022-07-15T15:26:49.590Z', + archived: false, + }, + ], + }, + status: 200, + }, + }, { httpReq: { url: 'https://api.hubapi.com/crm/v3/objects/contacts/search', diff --git a/test/integrations/destinations/hs/router/data.ts b/test/integrations/destinations/hs/router/data.ts index 3a30232f9f..e1c3e04356 100644 --- a/test/integrations/destinations/hs/router/data.ts +++ b/test/integrations/destinations/hs/router/data.ts @@ -1688,4 +1688,145 @@ export const data = [ }, }, }, + { + name: 'hs', + description: 'getting duplicate records for secondary property', + feature: 'router', + module: 'destination', + version: 'v0', + scenario: 'buisness', + successCriteria: + 'should return 200 status code with contact needs to be updated and no email property', + input: { + request: { + body: { + input: [ + { + message: { + type: 'identify', + sentAt: '2024-03-19T18:46:36.348Z', + traits: { + lastname: 'Peñarete', + firstname: 'Karen', + }, + userId: 'secondary@email.com', + channel: 'sources', + context: { + externalId: [ + { + id: 'secondary@email.com', + type: 'HS-contacts', + identifierType: 'email', + }, + ], + mappedToDestination: 'true', + }, + originalTimestamp: '2024-03-19T18:46:36.348Z', + }, + metadata: { jobId: 3, userId: 'u1' }, + destination: { + Config: { + authorizationType: 'newPrivateAppApi', + accessToken: 'dummy-access-token-hs-additonal-email', + hubID: 'dummy-hubId', + apiKey: 'dummy-apikey', + apiVersion: 'newApi', + lookupField: 'email', + hubspotEvents: [], + }, + secretConfig: {}, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + name: 'Hubspot', + enabled: true, + workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', + deleted: false, + createdAt: '2020-12-30T08:39:32.005Z', + updatedAt: '2021-02-03T16:22:31.374Z', + destinationDefinition: { + id: '1aIXqM806xAVm92nx07YwKbRrO9', + name: 'HS', + displayName: 'Hubspot', + createdAt: '2020-04-09T09:24:31.794Z', + updatedAt: '2021-01-11T11:03:28.103Z', + }, + transformations: [], + isConnectionEnabled: true, + isProcessorEnabled: true, + }, + }, + ], + destType: 'hs', + }, + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: [ + { + batchedRequest: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.hubapi.com/crm/v3/objects/contacts/batch/update', + headers: { + 'Content-Type': 'application/json', + Authorization: 'Bearer dummy-access-token-hs-additonal-email', + }, + params: {}, + body: { + JSON: { + inputs: [ + { + properties: { lastname: 'Peñarete', firstname: 'Karen' }, + id: '103689', + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + }, + metadata: [{ jobId: 3, userId: 'u1' }], + batched: true, + statusCode: 200, + destination: { + Config: { + authorizationType: 'newPrivateAppApi', + accessToken: 'dummy-access-token-hs-additonal-email', + hubID: 'dummy-hubId', + apiKey: 'dummy-apikey', + apiVersion: 'newApi', + lookupField: 'email', + hubspotEvents: [], + }, + secretConfig: {}, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + name: 'Hubspot', + enabled: true, + workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', + deleted: false, + createdAt: '2020-12-30T08:39:32.005Z', + updatedAt: '2021-02-03T16:22:31.374Z', + destinationDefinition: { + id: '1aIXqM806xAVm92nx07YwKbRrO9', + name: 'HS', + displayName: 'Hubspot', + createdAt: '2020-04-09T09:24:31.794Z', + updatedAt: '2021-01-11T11:03:28.103Z', + }, + transformations: [], + isConnectionEnabled: true, + isProcessorEnabled: true, + }, + }, + ], + }, + }, + }, + }, ]; From a0d4ca82f67ed3a8f73c539c96f678e9af748ad2 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 15 Apr 2024 09:03:08 +0000 Subject: [PATCH 02/25] chore(release): 1.62.0 --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1670fa232d..27b65204f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,43 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.62.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.60.0...v1.62.0) (2024-04-15) + + +### Features + +* adding product level tracking for awin ([#3246](https://github.com/rudderlabs/rudder-transformer/issues/3246)) ([48cf9f2](https://github.com/rudderlabs/rudder-transformer/commit/48cf9f282b803382dd2961b4b834d08a06eaab63)) +* consent field support for ga4 ([#3213](https://github.com/rudderlabs/rudder-transformer/issues/3213)) ([92515a5](https://github.com/rudderlabs/rudder-transformer/commit/92515a5fd8a2798c48010078f62b360ec6a49979)) +* consent field support for gaoc for API v15 and upgrade the api version from v14 to v16 ([#3121](https://github.com/rudderlabs/rudder-transformer/issues/3121)) ([2aac2a6](https://github.com/rudderlabs/rudder-transformer/commit/2aac2a62547b7a7c617735fc3d6e88e0a1bed76e)), closes [#3190](https://github.com/rudderlabs/rudder-transformer/issues/3190) +* do away myaxios ([#3222](https://github.com/rudderlabs/rudder-transformer/issues/3222)) ([9214594](https://github.com/rudderlabs/rudder-transformer/commit/9214594bab2c86a4ae6f75e12531f778490cf127)) +* for reddit adding currency and value for addToCart, viewConent event as well ([#3239](https://github.com/rudderlabs/rudder-transformer/issues/3239)) ([ad235e7](https://github.com/rudderlabs/rudder-transformer/commit/ad235e785bf6039e11231a915be098130b25ec3b)) +* logger upgrade in services, dest, source ([#3228](https://github.com/rudderlabs/rudder-transformer/issues/3228)) ([c204113](https://github.com/rudderlabs/rudder-transformer/commit/c204113eab37a782f217488d0d626a8d6df345d3)) +* onboard new destination bloomreach ([#3185](https://github.com/rudderlabs/rudder-transformer/issues/3185)) ([d9b7e1f](https://github.com/rudderlabs/rudder-transformer/commit/d9b7e1f70565d59979aee3e62f60e39edb9a23c7)) +* onboarding linkedin conversion api ([#3194](https://github.com/rudderlabs/rudder-transformer/issues/3194)) ([eb7b197](https://github.com/rudderlabs/rudder-transformer/commit/eb7b197322c617b14c2579de8cb4d4dacf8e1df3)) +* rakuten: adding a default value for tr ([#3240](https://github.com/rudderlabs/rudder-transformer/issues/3240)) ([3748f24](https://github.com/rudderlabs/rudder-transformer/commit/3748f24e21634fc74c5e5b3761551c64c8e69942)) +* snapchat conversion: add event level_complete ([7370191](https://github.com/rudderlabs/rudder-transformer/commit/73701915b8e24b0a00afc48ddef7c687ecf02055)) +* update movable ink batch size ([#3223](https://github.com/rudderlabs/rudder-transformer/issues/3223)) ([667095f](https://github.com/rudderlabs/rudder-transformer/commit/667095fa8316cd95a066f15b848ad503c6b4af80)) + + +### Bug Fixes + +* adding check for reserved key words in extract custom fields ([#3264](https://github.com/rudderlabs/rudder-transformer/issues/3264)) ([3399c47](https://github.com/rudderlabs/rudder-transformer/commit/3399c47fdce1b3d19e29306ca3c5692a2fbc30fb)) +* deployment file paths ([#3216](https://github.com/rudderlabs/rudder-transformer/issues/3216)) ([808727d](https://github.com/rudderlabs/rudder-transformer/commit/808727de17e400ed102a843ab3b30f81f8900f24)) +* email mappings ([5d654b3](https://github.com/rudderlabs/rudder-transformer/commit/5d654b326b8a2e39413f9541da541ab86b2a56fa)) +* email mappings ([#3247](https://github.com/rudderlabs/rudder-transformer/issues/3247)) ([791cbf5](https://github.com/rudderlabs/rudder-transformer/commit/791cbf55fc6940af4e3208212b82c891c6618fc3)) +* fixed userId mapping, now mapping to uid instead of id ([#3192](https://github.com/rudderlabs/rudder-transformer/issues/3192)) ([70a468b](https://github.com/rudderlabs/rudder-transformer/commit/70a468bf16ecd5ee0b6fecee4b837895d19c525f)) +* fixed userId mapping, now mapping to uid instead of id ([#3262](https://github.com/rudderlabs/rudder-transformer/issues/3262)) ([9c6b251](https://github.com/rudderlabs/rudder-transformer/commit/9c6b251a6c784cc391f27e846a008fbe2901e2c8)) +* hs bugsnag error ([#3252](https://github.com/rudderlabs/rudder-transformer/issues/3252)) ([9daf1c9](https://github.com/rudderlabs/rudder-transformer/commit/9daf1c989258bd410d5780c1b11c4f6df9654af5)) +* hubspot: search for contact using secondary prop ([#3258](https://github.com/rudderlabs/rudder-transformer/issues/3258)) ([0b57204](https://github.com/rudderlabs/rudder-transformer/commit/0b5720446693efe1fd0ccdfc141bd7f21b2c32ae)) +* impact: support custom product mapping ([#3249](https://github.com/rudderlabs/rudder-transformer/issues/3249)) ([cb8ff2f](https://github.com/rudderlabs/rudder-transformer/commit/cb8ff2fb943c49df4ac083bd179d9674b40eb602)) +* marketo bulk ignore null while checking data type mismatch ([#3263](https://github.com/rudderlabs/rudder-transformer/issues/3263)) ([6e3274b](https://github.com/rudderlabs/rudder-transformer/commit/6e3274bfba9e7838d1f81d845a070427b67e75f5)) +* merge conflict with main ([#3233](https://github.com/rudderlabs/rudder-transformer/issues/3233)) ([042dd6d](https://github.com/rudderlabs/rudder-transformer/commit/042dd6d16236dede8126984ea590fa167d4a4a87)), closes [#3216](https://github.com/rudderlabs/rudder-transformer/issues/3216) +* ninetailed: remove page support ([#3218](https://github.com/rudderlabs/rudder-transformer/issues/3218)) ([2f30c56](https://github.com/rudderlabs/rudder-transformer/commit/2f30c56af62e983d09b5d4f2da9a0ba22f5c1612)) +* shopify invalid_event metric prometheus label ([#3200](https://github.com/rudderlabs/rudder-transformer/issues/3200)) ([345c87d](https://github.com/rudderlabs/rudder-transformer/commit/345c87d7c530c621ae3fd6c504d64e5a14e31f22)) +* shopify: send 500 for identifier call in case of failure ([#3235](https://github.com/rudderlabs/rudder-transformer/issues/3235)) ([8eb4c4e](https://github.com/rudderlabs/rudder-transformer/commit/8eb4c4e9b8daebbaeb1d12ff0c17915fe19c2b50)) +* snapchat conversion: add event level_complete ([#3231](https://github.com/rudderlabs/rudder-transformer/issues/3231)) ([39368a0](https://github.com/rudderlabs/rudder-transformer/commit/39368a09e48acc324faa855186bc623e5c347881)) +* update correct staging deployment file ([#3189](https://github.com/rudderlabs/rudder-transformer/issues/3189)) ([ac7e887](https://github.com/rudderlabs/rudder-transformer/commit/ac7e8879fcd230dae09f757a759fb42e4cdc09d0)) + ### [1.61.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.61.0...v1.61.1) (2024-04-03) ## [1.61.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.60.0...v1.61.0) (2024-04-02) diff --git a/package-lock.json b/package-lock.json index fd42692109..fdfab6703c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.61.1", + "version": "1.62.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.61.1", + "version": "1.62.0", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "0.7.24", diff --git a/package.json b/package.json index c839bc8acc..1343f27fbe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.61.1", + "version": "1.62.0", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": { From 54eabc6b1c0f49bb3388e45bc27505bbd51b66c0 Mon Sep 17 00:00:00 2001 From: Anant Jain <62471433+anantjain45823@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:23:31 +0530 Subject: [PATCH 03/25] fix: hubspot: hs_additional_email comparision logic (#3277) --- src/v0/destinations/hs/util.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/v0/destinations/hs/util.js b/src/v0/destinations/hs/util.js index ffb2df5237..b30207fe15 100644 --- a/src/v0/destinations/hs/util.js +++ b/src/v0/destinations/hs/util.js @@ -752,11 +752,18 @@ const splitEventsForCreateUpdate = async (inputs, destination) => { } const secondaryProp = primaryToSecondaryFields[identifierType]; if (secondaryProp) { - // second condition is for secondary property for identifier type + /* second condition is for secondary property for identifier type + For example: + update[secondaryProp] = "abc@e.com;cd@e.com;k@w.com" + destinationExternalId = "cd@e.com" + So we are splitting all the emails in update[secondaryProp] into an array using ';' + and then checking if array includes destinationExternalId + */ const filteredInfoForSecondaryProp = hsIdsToBeUpdated.filter((update) => update[secondaryProp] ?.toString() .toLowerCase() + .split(';') .includes(destinationExternalId.toString().toLowerCase()), ); if (filteredInfoForSecondaryProp.length > 0) { From 2e6f8e5d0f24b287daebbdb68f672b29ef46351b Mon Sep 17 00:00:00 2001 From: AASHISH MALIK Date: Tue, 16 Apr 2024 13:45:07 +0530 Subject: [PATCH 04/25] chore: cleaned changelog --- CHANGELOG.md | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27b65204f0..6ec145991f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,29 +2,21 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -## [1.62.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.60.0...v1.62.0) (2024-04-15) +## [1.62.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.61.1...v1.62.0) (2024-04-15) ### Features -* adding product level tracking for awin ([#3246](https://github.com/rudderlabs/rudder-transformer/issues/3246)) ([48cf9f2](https://github.com/rudderlabs/rudder-transformer/commit/48cf9f282b803382dd2961b4b834d08a06eaab63)) -* consent field support for ga4 ([#3213](https://github.com/rudderlabs/rudder-transformer/issues/3213)) ([92515a5](https://github.com/rudderlabs/rudder-transformer/commit/92515a5fd8a2798c48010078f62b360ec6a49979)) -* consent field support for gaoc for API v15 and upgrade the api version from v14 to v16 ([#3121](https://github.com/rudderlabs/rudder-transformer/issues/3121)) ([2aac2a6](https://github.com/rudderlabs/rudder-transformer/commit/2aac2a62547b7a7c617735fc3d6e88e0a1bed76e)), closes [#3190](https://github.com/rudderlabs/rudder-transformer/issues/3190) * do away myaxios ([#3222](https://github.com/rudderlabs/rudder-transformer/issues/3222)) ([9214594](https://github.com/rudderlabs/rudder-transformer/commit/9214594bab2c86a4ae6f75e12531f778490cf127)) * for reddit adding currency and value for addToCart, viewConent event as well ([#3239](https://github.com/rudderlabs/rudder-transformer/issues/3239)) ([ad235e7](https://github.com/rudderlabs/rudder-transformer/commit/ad235e785bf6039e11231a915be098130b25ec3b)) * logger upgrade in services, dest, source ([#3228](https://github.com/rudderlabs/rudder-transformer/issues/3228)) ([c204113](https://github.com/rudderlabs/rudder-transformer/commit/c204113eab37a782f217488d0d626a8d6df345d3)) -* onboard new destination bloomreach ([#3185](https://github.com/rudderlabs/rudder-transformer/issues/3185)) ([d9b7e1f](https://github.com/rudderlabs/rudder-transformer/commit/d9b7e1f70565d59979aee3e62f60e39edb9a23c7)) -* onboarding linkedin conversion api ([#3194](https://github.com/rudderlabs/rudder-transformer/issues/3194)) ([eb7b197](https://github.com/rudderlabs/rudder-transformer/commit/eb7b197322c617b14c2579de8cb4d4dacf8e1df3)) * rakuten: adding a default value for tr ([#3240](https://github.com/rudderlabs/rudder-transformer/issues/3240)) ([3748f24](https://github.com/rudderlabs/rudder-transformer/commit/3748f24e21634fc74c5e5b3761551c64c8e69942)) -* snapchat conversion: add event level_complete ([7370191](https://github.com/rudderlabs/rudder-transformer/commit/73701915b8e24b0a00afc48ddef7c687ecf02055)) -* update movable ink batch size ([#3223](https://github.com/rudderlabs/rudder-transformer/issues/3223)) ([667095f](https://github.com/rudderlabs/rudder-transformer/commit/667095fa8316cd95a066f15b848ad503c6b4af80)) ### Bug Fixes * adding check for reserved key words in extract custom fields ([#3264](https://github.com/rudderlabs/rudder-transformer/issues/3264)) ([3399c47](https://github.com/rudderlabs/rudder-transformer/commit/3399c47fdce1b3d19e29306ca3c5692a2fbc30fb)) * deployment file paths ([#3216](https://github.com/rudderlabs/rudder-transformer/issues/3216)) ([808727d](https://github.com/rudderlabs/rudder-transformer/commit/808727de17e400ed102a843ab3b30f81f8900f24)) -* email mappings ([5d654b3](https://github.com/rudderlabs/rudder-transformer/commit/5d654b326b8a2e39413f9541da541ab86b2a56fa)) * email mappings ([#3247](https://github.com/rudderlabs/rudder-transformer/issues/3247)) ([791cbf5](https://github.com/rudderlabs/rudder-transformer/commit/791cbf55fc6940af4e3208212b82c891c6618fc3)) * fixed userId mapping, now mapping to uid instead of id ([#3192](https://github.com/rudderlabs/rudder-transformer/issues/3192)) ([70a468b](https://github.com/rudderlabs/rudder-transformer/commit/70a468bf16ecd5ee0b6fecee4b837895d19c525f)) * fixed userId mapping, now mapping to uid instead of id ([#3262](https://github.com/rudderlabs/rudder-transformer/issues/3262)) ([9c6b251](https://github.com/rudderlabs/rudder-transformer/commit/9c6b251a6c784cc391f27e846a008fbe2901e2c8)) @@ -32,12 +24,7 @@ All notable changes to this project will be documented in this file. See [standa * hubspot: search for contact using secondary prop ([#3258](https://github.com/rudderlabs/rudder-transformer/issues/3258)) ([0b57204](https://github.com/rudderlabs/rudder-transformer/commit/0b5720446693efe1fd0ccdfc141bd7f21b2c32ae)) * impact: support custom product mapping ([#3249](https://github.com/rudderlabs/rudder-transformer/issues/3249)) ([cb8ff2f](https://github.com/rudderlabs/rudder-transformer/commit/cb8ff2fb943c49df4ac083bd179d9674b40eb602)) * marketo bulk ignore null while checking data type mismatch ([#3263](https://github.com/rudderlabs/rudder-transformer/issues/3263)) ([6e3274b](https://github.com/rudderlabs/rudder-transformer/commit/6e3274bfba9e7838d1f81d845a070427b67e75f5)) -* merge conflict with main ([#3233](https://github.com/rudderlabs/rudder-transformer/issues/3233)) ([042dd6d](https://github.com/rudderlabs/rudder-transformer/commit/042dd6d16236dede8126984ea590fa167d4a4a87)), closes [#3216](https://github.com/rudderlabs/rudder-transformer/issues/3216) -* ninetailed: remove page support ([#3218](https://github.com/rudderlabs/rudder-transformer/issues/3218)) ([2f30c56](https://github.com/rudderlabs/rudder-transformer/commit/2f30c56af62e983d09b5d4f2da9a0ba22f5c1612)) -* shopify invalid_event metric prometheus label ([#3200](https://github.com/rudderlabs/rudder-transformer/issues/3200)) ([345c87d](https://github.com/rudderlabs/rudder-transformer/commit/345c87d7c530c621ae3fd6c504d64e5a14e31f22)) * shopify: send 500 for identifier call in case of failure ([#3235](https://github.com/rudderlabs/rudder-transformer/issues/3235)) ([8eb4c4e](https://github.com/rudderlabs/rudder-transformer/commit/8eb4c4e9b8daebbaeb1d12ff0c17915fe19c2b50)) -* snapchat conversion: add event level_complete ([#3231](https://github.com/rudderlabs/rudder-transformer/issues/3231)) ([39368a0](https://github.com/rudderlabs/rudder-transformer/commit/39368a09e48acc324faa855186bc623e5c347881)) -* update correct staging deployment file ([#3189](https://github.com/rudderlabs/rudder-transformer/issues/3189)) ([ac7e887](https://github.com/rudderlabs/rudder-transformer/commit/ac7e8879fcd230dae09f757a759fb42e4cdc09d0)) ### [1.61.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.61.0...v1.61.1) (2024-04-03) From 34e861d4821fed6699b90ee6be663b02504b98fd Mon Sep 17 00:00:00 2001 From: AASHISH MALIK Date: Tue, 16 Apr 2024 14:14:48 +0530 Subject: [PATCH 05/25] chore: change log info to debug --- src/controllers/delivery.ts | 2 +- src/controllers/destination.ts | 2 +- src/v0/destinations/twitter_ads/transform.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/delivery.ts b/src/controllers/delivery.ts index 8ac7c9902a..0dc27553cb 100644 --- a/src/controllers/delivery.ts +++ b/src/controllers/delivery.ts @@ -24,7 +24,7 @@ const NON_DETERMINABLE = 'Non-determinable'; export class DeliveryController { public static async deliverToDestination(ctx: Context) { - logger.info('Native(Delivery):: Request to transformer::', ctx.request.body); + logger.debug('Native(Delivery):: Request to transformer::', ctx.request.body); let deliveryResponse: DeliveryV0Response; const requestMetadata = MiscService.getRequestMetadata(ctx); const deliveryRequest = ctx.request.body as ProxyV0Request; diff --git a/src/controllers/destination.ts b/src/controllers/destination.ts index 35606ea62e..92ef4b4c19 100644 --- a/src/controllers/destination.ts +++ b/src/controllers/destination.ts @@ -166,7 +166,7 @@ export class DestinationController { } public static batchProcess(ctx: Context) { - logger.info('Native(Process-Transform-Batch):: Requst to transformer::', ctx.request.body); + logger.debug('Native(Process-Transform-Batch):: Requst to transformer::', ctx.request.body); const startTime = new Date(); const requestMetadata = MiscService.getRequestMetadata(ctx); const routerRequest = ctx.request.body as RouterTransformationRequest; diff --git a/src/v0/destinations/twitter_ads/transform.js b/src/v0/destinations/twitter_ads/transform.js index 365663925e..328d8c4a9f 100644 --- a/src/v0/destinations/twitter_ads/transform.js +++ b/src/v0/destinations/twitter_ads/transform.js @@ -157,7 +157,7 @@ function validateRequest(message) { } function process(event, requestMetadata, logger) { - logger.info(`[TWITTER ADS]: Transforming request received with info`); + logger.debug(`[TWITTER ADS]: Transforming request received with info`); const { message, metadata, destination } = event; validateRequest(message); From f0dff674d8661eb348bb39b46376fe232ac86789 Mon Sep 17 00:00:00 2001 From: Sandeep Digumarty Date: Tue, 16 Apr 2024 14:15:48 +0530 Subject: [PATCH 06/25] chore: minor CHANGELOG.md cleanup --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ec145991f..9e221a32f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,6 @@ All notable changes to this project will be documented in this file. See [standa * adding check for reserved key words in extract custom fields ([#3264](https://github.com/rudderlabs/rudder-transformer/issues/3264)) ([3399c47](https://github.com/rudderlabs/rudder-transformer/commit/3399c47fdce1b3d19e29306ca3c5692a2fbc30fb)) * deployment file paths ([#3216](https://github.com/rudderlabs/rudder-transformer/issues/3216)) ([808727d](https://github.com/rudderlabs/rudder-transformer/commit/808727de17e400ed102a843ab3b30f81f8900f24)) * email mappings ([#3247](https://github.com/rudderlabs/rudder-transformer/issues/3247)) ([791cbf5](https://github.com/rudderlabs/rudder-transformer/commit/791cbf55fc6940af4e3208212b82c891c6618fc3)) -* fixed userId mapping, now mapping to uid instead of id ([#3192](https://github.com/rudderlabs/rudder-transformer/issues/3192)) ([70a468b](https://github.com/rudderlabs/rudder-transformer/commit/70a468bf16ecd5ee0b6fecee4b837895d19c525f)) * fixed userId mapping, now mapping to uid instead of id ([#3262](https://github.com/rudderlabs/rudder-transformer/issues/3262)) ([9c6b251](https://github.com/rudderlabs/rudder-transformer/commit/9c6b251a6c784cc391f27e846a008fbe2901e2c8)) * hs bugsnag error ([#3252](https://github.com/rudderlabs/rudder-transformer/issues/3252)) ([9daf1c9](https://github.com/rudderlabs/rudder-transformer/commit/9daf1c989258bd410d5780c1b11c4f6df9654af5)) * hubspot: search for contact using secondary prop ([#3258](https://github.com/rudderlabs/rudder-transformer/issues/3258)) ([0b57204](https://github.com/rudderlabs/rudder-transformer/commit/0b5720446693efe1fd0ccdfc141bd7f21b2c32ae)) From ec3eda85866bbba7813a8007408dac0c57c27c65 Mon Sep 17 00:00:00 2001 From: AASHISH MALIK Date: Wed, 17 Apr 2024 04:07:51 +0530 Subject: [PATCH 07/25] fix: send group_id as string in monday destination (#3278) --- src/v0/destinations/monday/util.js | 17 +++++++++-------- .../destinations/monday/processor/data.ts | 10 +++++----- .../destinations/monday/router/data.ts | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/v0/destinations/monday/util.js b/src/v0/destinations/monday/util.js index 872fad42a7..0694028eb2 100644 --- a/src/v0/destinations/monday/util.js +++ b/src/v0/destinations/monday/util.js @@ -27,7 +27,7 @@ const getGroupId = (groupTitle, board) => { } }); if (groupId) { - return groupId; + return JSON.stringify(groupId); } throw new ConfigurationError(`Group ${groupTitle} doesn't exist in the board`); }; @@ -239,19 +239,20 @@ const populatePayload = (message, Config, boardDeatailsResponse) => { columnToPropertyMapping, boardDeatailsResponse.response?.data, ); + const items = [ + `board_id: ${boardId}`, + `item_name: ${JSON.stringify(message.properties?.name)}`, + `column_values: ${JSON.stringify(columnValues)}`, + ]; if (groupTitle) { if (!message.properties?.name) { throw new InstrumentationError('Item name is required to create an item'); } const groupId = getGroupId(groupTitle, boardDeatailsResponse.response?.data); - payload.query = `mutation { create_item (board_id: ${boardId}, group_id: ${groupId} item_name: ${JSON.stringify( - message.properties?.name, - )}, column_values: ${JSON.stringify(columnValues)}) {id}}`; - } else { - payload.query = `mutation { create_item (board_id: ${boardId}, item_name: ${JSON.stringify( - message.properties?.name, - )}, column_values: ${JSON.stringify(columnValues)}) {id}}`; + items.push(`group_id: ${groupId}`); } + const itemsQuery = items.join(', '); + payload.query = `mutation { create_item (${itemsQuery}) {id}}`; return payload; }; diff --git a/test/integrations/destinations/monday/processor/data.ts b/test/integrations/destinations/monday/processor/data.ts index 4e5280efcb..082ff822fd 100644 --- a/test/integrations/destinations/monday/processor/data.ts +++ b/test/integrations/destinations/monday/processor/data.ts @@ -74,7 +74,7 @@ export const data = [ FORM: {}, JSON: { query: - 'mutation { create_item (board_id: 339283933, item_name: "Task 1", column_values: "{}") {id}}', + 'mutation { create_item (board_id: 339283933, item_name: "Task 1", column_values: "{}") {id}}', }, JSON_ARRAY: {}, XML: {}, @@ -172,7 +172,7 @@ export const data = [ FORM: {}, JSON: { query: - 'mutation { create_item (board_id: 339283933, item_name: "Task 1", column_values: "{}") {id}}', + 'mutation { create_item (board_id: 339283933, item_name: "Task 1", column_values: "{}") {id}}', }, JSON_ARRAY: {}, XML: {}, @@ -716,7 +716,7 @@ export const data = [ body: { JSON: { query: - 'mutation { create_item (board_id: 339283933, item_name: "Task 1", column_values: "{\\"status\\":{\\"label\\":\\"Done\\"},\\"email\\":{\\"email\\":\\"abc@email.com\\",\\"text\\":\\"emailId\\"}}") {id}}', + 'mutation { create_item (board_id: 339283933, item_name: "Task 1", column_values: "{\\"status\\":{\\"label\\":\\"Done\\"},\\"email\\":{\\"email\\":\\"abc@email.com\\",\\"text\\":\\"emailId\\"}}") {id}}', }, JSON_ARRAY: {}, XML: {}, @@ -827,7 +827,7 @@ export const data = [ body: { JSON: { query: - 'mutation { create_item (board_id: 339283933, group_id: group_title item_name: "Task 1", column_values: "{\\"status\\":{\\"label\\":\\"Done\\"},\\"email\\":{\\"email\\":\\"abc@email.com\\",\\"text\\":\\"emailId\\"}}") {id}}', + 'mutation { create_item (board_id: 339283933, item_name: "Task 1", column_values: "{\\"status\\":{\\"label\\":\\"Done\\"},\\"email\\":{\\"email\\":\\"abc@email.com\\",\\"text\\":\\"emailId\\"}}", group_id: "group_title") {id}}', }, JSON_ARRAY: {}, XML: {}, @@ -1188,7 +1188,7 @@ export const data = [ body: { JSON: { query: - 'mutation { create_item (board_id: 339283933, group_id: group_title item_name: "Task 1", column_values: "{\\"status\\":{\\"label\\":\\"Done\\"},\\"email\\":{\\"email\\":\\"abc@email.com\\",\\"text\\":\\"emailId\\"},\\"checkbox\\":{\\"checked\\":true},\\"numbers\\":\\"45\\",\\"text\\":\\"texting\\",\\"country\\":{\\"countryName\\":\\"Unites States\\",\\"countryCode\\":\\"US\\"},\\"location\\":{\\"address\\":\\"New York\\",\\"lat\\":\\"51.23\\",\\"lng\\":\\"35.3\\"},\\"phone\\":{\\"phone\\":\\"2626277272\\",\\"countryShortName\\":\\"US\\"},\\"rating\\":3,\\"link\\":{\\"url\\":\\"demo.com\\",\\"text\\":\\"websiteLink\\"},\\"long_text\\":{\\"text\\":\\"property description\\"},\\"world_clock\\":{\\"timezone\\":\\"America/New_York\\"}}") {id}}', + 'mutation { create_item (board_id: 339283933, item_name: "Task 1", column_values: "{\\"status\\":{\\"label\\":\\"Done\\"},\\"email\\":{\\"email\\":\\"abc@email.com\\",\\"text\\":\\"emailId\\"},\\"checkbox\\":{\\"checked\\":true},\\"numbers\\":\\"45\\",\\"text\\":\\"texting\\",\\"country\\":{\\"countryName\\":\\"Unites States\\",\\"countryCode\\":\\"US\\"},\\"location\\":{\\"address\\":\\"New York\\",\\"lat\\":\\"51.23\\",\\"lng\\":\\"35.3\\"},\\"phone\\":{\\"phone\\":\\"2626277272\\",\\"countryShortName\\":\\"US\\"},\\"rating\\":3,\\"link\\":{\\"url\\":\\"demo.com\\",\\"text\\":\\"websiteLink\\"},\\"long_text\\":{\\"text\\":\\"property description\\"},\\"world_clock\\":{\\"timezone\\":\\"America/New_York\\"}}", group_id: "group_title") {id}}', }, JSON_ARRAY: {}, XML: {}, diff --git a/test/integrations/destinations/monday/router/data.ts b/test/integrations/destinations/monday/router/data.ts index 3be8b129c5..abd649d805 100644 --- a/test/integrations/destinations/monday/router/data.ts +++ b/test/integrations/destinations/monday/router/data.ts @@ -113,7 +113,7 @@ export const data = [ FORM: {}, JSON: { query: - 'mutation { create_item (board_id: 339283933, item_name: "Task 1", column_values: "{}") {id}}', + 'mutation { create_item (board_id: 339283933, item_name: "Task 1", column_values: "{}") {id}}', }, JSON_ARRAY: {}, XML: {}, @@ -159,7 +159,7 @@ export const data = [ body: { JSON: { query: - 'mutation { create_item (board_id: 339283933, group_id: group_title item_name: "Task 1", column_values: "{\\"status\\":{\\"label\\":\\"Done\\"},\\"email\\":{\\"email\\":\\"abc@email.com\\",\\"text\\":\\"emailId\\"}}") {id}}', + 'mutation { create_item (board_id: 339283933, item_name: "Task 1", column_values: "{\\"status\\":{\\"label\\":\\"Done\\"},\\"email\\":{\\"email\\":\\"abc@email.com\\",\\"text\\":\\"emailId\\"}}", group_id: "group_title") {id}}', }, JSON_ARRAY: {}, XML: {}, From 44b29caf2537b7dc0bd178aa346ca92d143e79d0 Mon Sep 17 00:00:00 2001 From: shrouti1507 <60211312+shrouti1507@users.noreply.github.com> Date: Wed, 17 Apr 2024 11:16:30 +0530 Subject: [PATCH 08/25] fix: awin product_id mapping backward compatible (#3285) --- src/v0/destinations/awin/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/v0/destinations/awin/utils.js b/src/v0/destinations/awin/utils.js index be5f22474d..f0daea9b99 100644 --- a/src/v0/destinations/awin/utils.js +++ b/src/v0/destinations/awin/utils.js @@ -54,7 +54,11 @@ const trackProduct = (properties, advertiserId, commissionParts) => { productsArray.forEach((product) => { const productPayloadNew = { advertiserId, - orderReference: properties.order_id || properties.orderId, + orderReference: + properties.order_id || + properties.orderId || + properties.orderReference || + properties.order_reference, productId: product.product_id || product.productId, productName: product.name, productItemPrice: product.price, From 8592e664eb568e70a00261e275ab2faed8f6f618 Mon Sep 17 00:00:00 2001 From: shrouti1507 <60211312+shrouti1507@users.noreply.github.com> Date: Wed, 17 Apr 2024 13:39:24 +0530 Subject: [PATCH 09/25] feat: adding custom properties support to bluecore (#3282) * feat: adding custom properties support to bluecore * Update src/cdk/v2/destinations/bluecore/utils.js Co-authored-by: Sankeerth * fix: small fix --------- Co-authored-by: Sankeerth --- src/cdk/v2/destinations/bluecore/config.js | 22 ++++++++- .../destinations/bluecore/procWorkflow.yaml | 6 +-- src/cdk/v2/destinations/bluecore/utils.js | 45 ++++++++++++++++++- .../destinations/bluecore/ecommTestData.ts | 24 ++++++++-- .../destinations/bluecore/identifyTestData.ts | 13 ++++-- .../destinations/bluecore/trackTestData.ts | 39 +++++++++++++--- 6 files changed, 129 insertions(+), 20 deletions(-) diff --git a/src/cdk/v2/destinations/bluecore/config.js b/src/cdk/v2/destinations/bluecore/config.js index 9b9cde9c66..98e1bb4b23 100644 --- a/src/cdk/v2/destinations/bluecore/config.js +++ b/src/cdk/v2/destinations/bluecore/config.js @@ -1,6 +1,6 @@ const { getMappingConfig } = require('../../../../v0/util'); -const BASE_URL = 'https://api.bluecore.com/api/track/mobile/v1'; +const BASE_URL = 'https://api.bluecore.app/api/track/mobile/v1'; const CONFIG_CATEGORIES = { IDENTIFY: { @@ -46,6 +46,24 @@ const EVENT_NAME_MAPPING = [ const BLUECORE_EXCLUSION_FIELDS = ['query', 'order_id', 'total']; +const IDENTIFY_EXCLUSION_LIST = [ + 'name', + 'firstName', + 'first_name', + 'firstname', + 'lastName', + 'last_name', + 'lastname', + 'email', + 'age', + 'sex', + 'address', + 'action', + 'event', +]; + +const TRACK_EXCLUSION_LIST = [...IDENTIFY_EXCLUSION_LIST, 'query', 'order_id', 'total', 'products']; + const MAPPING_CONFIG = getMappingConfig(CONFIG_CATEGORIES, __dirname); module.exports = { CONFIG_CATEGORIES, @@ -53,4 +71,6 @@ module.exports = { EVENT_NAME_MAPPING, BASE_URL, BLUECORE_EXCLUSION_FIELDS, + IDENTIFY_EXCLUSION_LIST, + TRACK_EXCLUSION_LIST, }; diff --git a/src/cdk/v2/destinations/bluecore/procWorkflow.yaml b/src/cdk/v2/destinations/bluecore/procWorkflow.yaml index 480bced699..9828ac593c 100644 --- a/src/cdk/v2/destinations/bluecore/procWorkflow.yaml +++ b/src/cdk/v2/destinations/bluecore/procWorkflow.yaml @@ -26,7 +26,7 @@ steps: condition: $.outputs.messageType === {{$.EventType.IDENTIFY}} template: | const payload = $.constructProperties(.message); - payload.token = .destination.Config.bluecoreNamespace; + payload.properties.token = .destination.Config.bluecoreNamespace; $.verifyPayload(payload, .message); payload.event = payload.event ?? 'customer_patch'; payload.properties.distinct_id = $.populateAccurateDistinctId(payload, .message); @@ -50,7 +50,7 @@ steps: const temporaryProductArray = newPayload.properties.products ?? $.createProductForStandardEcommEvent(^.message, eventName); newPayload.properties.products = $.normalizeProductArray(temporaryProductArray); newPayload.event = eventName; - newPayload.token = ^.destination.Config.bluecoreNamespace; + newPayload.properties.token = ^.destination.Config.bluecoreNamespace; $.verifyPayload(newPayload, ^.message); $.removeUndefinedNullValuesAndEmptyObjectArray(newPayload) )[]; @@ -61,7 +61,7 @@ steps: const response = $.defaultRequestConfig(); response.body.JSON = .; response.method = "POST"; - response.endpoint = "https://api.bluecore.com/api/track/mobile/v1"; + response.endpoint = "https://api.bluecore.app/api/track/mobile/v1"; response.headers = { "Content-Type": "application/json" }; diff --git a/src/cdk/v2/destinations/bluecore/utils.js b/src/cdk/v2/destinations/bluecore/utils.js index 22ec254fe2..91eda60d0d 100644 --- a/src/cdk/v2/destinations/bluecore/utils.js +++ b/src/cdk/v2/destinations/bluecore/utils.js @@ -12,9 +12,10 @@ const { validateEventName, constructPayload, getDestinationExternalID, + extractCustomFields, } = require('../../../../v0/util'); const { CommonUtils } = require('../../../../util/common'); -const { EVENT_NAME_MAPPING } = require('./config'); +const { EVENT_NAME_MAPPING, IDENTIFY_EXCLUSION_LIST, TRACK_EXCLUSION_LIST } = require('./config'); const { EventType } = require('../../../../constants'); const { MAPPING_CONFIG, CONFIG_CATEGORIES } = require('./config'); @@ -167,6 +168,41 @@ const normalizeProductArray = (products) => { return finalProductArray; }; +const mapCustomProperties = (message) => { + let customerProperties; + const customProperties = { properties: {} }; + const messageType = message.type.toUpperCase(); + switch (messageType) { + case 'IDENTIFY': + customerProperties = extractCustomFields( + message, + {}, + ['traits', 'context.traits'], + IDENTIFY_EXCLUSION_LIST, + ); + customProperties.properties.customer = customerProperties; + break; + case 'TRACK': + customerProperties = extractCustomFields( + message, + {}, + ['traits', 'context.traits'], + IDENTIFY_EXCLUSION_LIST, + ); + customProperties.properties = extractCustomFields( + message, + {}, + ['properties'], + TRACK_EXCLUSION_LIST, + ); + customProperties.properties.customer = customerProperties; + break; + default: + break; + } + return customProperties; +}; + /** * Constructs properties based on the given message. * @@ -178,7 +214,12 @@ const constructProperties = (message) => { const commonPayload = constructPayload(message, MAPPING_CONFIG[commonCategory.name]); const category = CONFIG_CATEGORIES[message.type.toUpperCase()]; const typeSpecificPayload = constructPayload(message, MAPPING_CONFIG[category.name]); - const finalPayload = lodash.merge(commonPayload, typeSpecificPayload); + const typeSpecificCustomProperties = mapCustomProperties(message); + const finalPayload = lodash.merge( + commonPayload, + typeSpecificPayload, + typeSpecificCustomProperties, + ); return finalPayload; }; diff --git a/test/integrations/destinations/bluecore/ecommTestData.ts b/test/integrations/destinations/bluecore/ecommTestData.ts index de7584df78..19b63e7bda 100644 --- a/test/integrations/destinations/bluecore/ecommTestData.ts +++ b/test/integrations/destinations/bluecore/ecommTestData.ts @@ -73,7 +73,7 @@ const commonOutputHeaders = { 'Content-Type': 'application/json', }; -const eventEndPoint = 'https://api.bluecore.com/api/track/mobile/v1'; +const eventEndPoint = 'https://api.bluecore.app/api/track/mobile/v1'; export const ecomTestData = [ { @@ -296,7 +296,11 @@ export const ecomTestData = [ customer: { age: '22', email: 'test@rudderstack.com', + anonymousId: '9c6bd77ea9da3e68', + id: 'user@1', + phone: '9112340375', }, + product_id: '123', products: [ { id: '123', @@ -304,9 +308,11 @@ export const ecomTestData = [ property2: 'value2', }, ], + property1: 'value1', + property2: 'value2', + token: 'dummy_sandbox', }, event: 'viewed_product', - token: 'dummy_sandbox', }, userId: '', }), @@ -379,8 +385,11 @@ export const ecomTestData = [ JSON: { properties: { distinct_id: 'user@1', + product_id: '123', customer: { age: '22', + anonymousId: '9c6bd77ea9da3e68', + id: 'user@1', }, products: [ { @@ -389,9 +398,11 @@ export const ecomTestData = [ property2: 'value2', }, ], + property1: 'value1', + property2: 'value2', + token: 'dummy_sandbox', }, event: 'wishlist', - token: 'dummy_sandbox', }, userId: '', }), @@ -406,8 +417,11 @@ export const ecomTestData = [ JSON: { properties: { distinct_id: 'user@1', + product_id: '123', customer: { age: '22', + anonymousId: '9c6bd77ea9da3e68', + id: 'user@1', }, products: [ { @@ -416,9 +430,11 @@ export const ecomTestData = [ property2: 'value2', }, ], + token: 'dummy_sandbox', + property1: 'value1', + property2: 'value2', }, event: 'add_to_cart', - token: 'dummy_sandbox', }, userId: '', }), diff --git a/test/integrations/destinations/bluecore/identifyTestData.ts b/test/integrations/destinations/bluecore/identifyTestData.ts index 660e335bc6..fee27ccf0f 100644 --- a/test/integrations/destinations/bluecore/identifyTestData.ts +++ b/test/integrations/destinations/bluecore/identifyTestData.ts @@ -55,6 +55,10 @@ const commonOutputCustomerProperties = { first_name: 'Test', last_name: 'Rudderlabs', sex: 'non-binary', + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + db: '19950715', + gender: 'non-binary', + phone: '+1234589947', address: { city: 'Kolkata', state: 'WB', @@ -71,7 +75,7 @@ const anonymousId = '97c46c81-3140-456d-b2a9-690d70aaca35'; const userId = 'user@1'; const sentAt = '2021-01-03T17:02:53.195Z'; const originalTimestamp = '2021-01-03T17:02:53.193Z'; -const commonEndpoint = 'https://api.bluecore.com/api/track/mobile/v1'; +const commonEndpoint = 'https://api.bluecore.app/api/track/mobile/v1'; export const identifyData = [ { @@ -118,8 +122,8 @@ export const identifyData = [ properties: { distinct_id: 'abc@gmail.com', customer: { ...commonOutputCustomerProperties, email: 'abc@gmail.com' }, + token: 'dummy_sandbox', }, - token: 'dummy_sandbox', event: 'customer_patch', }, }), @@ -302,8 +306,9 @@ export const identifyData = [ properties: { distinct_id: 'user@1', customer: { ...commonOutputCustomerProperties, email: 'abc@gmail.com' }, + token: 'dummy_sandbox', }, - token: 'dummy_sandbox', + event: 'identify', }, }), @@ -361,8 +366,8 @@ export const identifyData = [ properties: { distinct_id: '54321', customer: { ...commonOutputCustomerProperties, email: 'abc@gmail.com' }, + token: 'dummy_sandbox', }, - token: 'dummy_sandbox', event: 'customer_patch', }, }), diff --git a/test/integrations/destinations/bluecore/trackTestData.ts b/test/integrations/destinations/bluecore/trackTestData.ts index 72d48bf93d..7474127558 100644 --- a/test/integrations/destinations/bluecore/trackTestData.ts +++ b/test/integrations/destinations/bluecore/trackTestData.ts @@ -86,7 +86,7 @@ const commonOutputHeaders = { 'Content-Type': 'application/json', }; -const eventEndPoint = 'https://api.bluecore.com/api/track/mobile/v1'; +const eventEndPoint = 'https://api.bluecore.app/api/track/mobile/v1'; export const trackTestData = [ { @@ -140,6 +140,9 @@ export const trackTestData = [ customer: { age: '22', email: 'test@rudderstack.com', + anonymousId: '9c6bd77ea9da3e68', + id: 'user@1', + phone: '9112340375', }, products: [ { @@ -155,9 +158,11 @@ export const trackTestData = [ quantity: 3, }, ], + property1: 'value1', + property2: 'value2', + token: 'dummy_sandbox', }, event: 'TestEven001', - token: 'dummy_sandbox', }, userId: '', }), @@ -216,13 +221,19 @@ export const trackTestData = [ JSON: { properties: { distinct_id: 'test@rudderstack.com', + product_id: '123', + property1: 'value1', + property2: 'value2', + token: 'dummy_sandbox', customer: { age: '22', email: 'test@rudderstack.com', + anonymousId: '9c6bd77ea9da3e68', + id: 'user@1', + phone: '9112340375', }, }, event: 'TestEven001', - token: 'dummy_sandbox', }, userId: '', }), @@ -283,11 +294,17 @@ export const trackTestData = [ distinct_id: 'test@rudderstack.com', customer: { age: '22', + anonymousId: '9c6bd77ea9da3e68', email: 'test@rudderstack.com', + id: 'user@1', + phone: '9112340375', }, + product_id: '123', + property1: 'value1', + property2: 'value2', + token: 'dummy_sandbox', }, event: 'optin', - token: 'dummy_sandbox', }, userId: '', }), @@ -346,13 +363,19 @@ export const trackTestData = [ JSON: { properties: { distinct_id: 'test@rudderstack.com', + product_id: '123', + property1: 'value1', + property2: 'value2', + token: 'dummy_sandbox', customer: { age: '22', + anonymousId: '9c6bd77ea9da3e68', + id: 'user@1', email: 'test@rudderstack.com', + phone: '9112340375', }, }, event: 'unsubscribe', - token: 'dummy_sandbox', }, userId: '', }), @@ -405,9 +428,12 @@ export const trackTestData = [ JSON: { properties: { distinct_id: '54321', + token: 'dummy_sandbox', customer: { age: '22', email: 'abc@gmail.com', + anonymousId: '9c6bd77ea9da3e68', + id: 'user@1', }, products: [ { @@ -423,9 +449,10 @@ export const trackTestData = [ quantity: 3, }, ], + property1: 'value1', + property2: 'value2', }, event: 'TestEven001', - token: 'dummy_sandbox', }, userId: '', }), From 86eaa07cf17de190e6b39c7087c1190faaaf927a Mon Sep 17 00:00:00 2001 From: devops-github-rudderstack <88187154+devops-github-rudderstack@users.noreply.github.com> Date: Thu, 18 Apr 2024 11:26:38 +0530 Subject: [PATCH 10/25] chore(release): pull hotfix-release/v1.62.1 into main (#3292) * fix: revert mixpanel deprecate /track (#3291) * chore(release): 1.62.1 --------- Co-authored-by: Gauravudia <60897972+Gauravudia@users.noreply.github.com> Co-authored-by: GitHub Actions --- CHANGELOG.md | 7 + package-lock.json | 4 +- package.json | 2 +- src/util/prometheus.js | 6 + src/v0/destinations/mp/config.js | 2 + src/v0/destinations/mp/transform.js | 70 ++-- src/v0/destinations/mp/util.js | 8 +- src/v0/destinations/mp/util.test.js | 14 + test/integrations/destinations/mp/common.ts | 2 +- .../destinations/mp/processor/data.ts | 363 ++++++++---------- .../destinations/mp/router/data.ts | 12 +- 11 files changed, 244 insertions(+), 246 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e221a32f8..5aeb88f374 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.62.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.62.0...v1.62.1) (2024-04-18) + + +### Bug Fixes + +* revert mixpanel deprecate /track ([#3291](https://github.com/rudderlabs/rudder-transformer/issues/3291)) ([ec068b4](https://github.com/rudderlabs/rudder-transformer/commit/ec068b49bd4a5652a762c60a8257c883e4709d1a)) + ## [1.62.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.61.1...v1.62.0) (2024-04-15) diff --git a/package-lock.json b/package-lock.json index fdfab6703c..b524ed27ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.62.0", + "version": "1.62.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.62.0", + "version": "1.62.1", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "0.7.24", diff --git a/package.json b/package.json index 1343f27fbe..57da0144ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.62.0", + "version": "1.62.1", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": { diff --git a/src/util/prometheus.js b/src/util/prometheus.js index a46eae12c9..882dff9e75 100644 --- a/src/util/prometheus.js +++ b/src/util/prometheus.js @@ -587,6 +587,12 @@ class Prometheus { type: 'gauge', labelNames: ['destination_id'], }, + { + name: 'mixpanel_batch_track_pack_size', + help: 'mixpanel_batch_track_pack_size', + type: 'gauge', + labelNames: ['destination_id'], + }, { name: 'mixpanel_batch_import_pack_size', help: 'mixpanel_batch_import_pack_size', diff --git a/src/v0/destinations/mp/config.js b/src/v0/destinations/mp/config.js index 3abdf2eebb..35b40294f5 100644 --- a/src/v0/destinations/mp/config.js +++ b/src/v0/destinations/mp/config.js @@ -49,6 +49,7 @@ const MP_IDENTIFY_EXCLUSION_LIST = [ ]; const GEO_SOURCE_ALLOWED_VALUES = [null, 'reverse_geocoding']; +const TRACK_MAX_BATCH_SIZE = 50; const IMPORT_MAX_BATCH_SIZE = 2000; const ENGAGE_MAX_BATCH_SIZE = 2000; const GROUPS_MAX_BATCH_SIZE = 200; @@ -67,6 +68,7 @@ module.exports = { MP_IDENTIFY_EXCLUSION_LIST, getCreateDeletionTaskEndpoint, DISTINCT_ID_MAX_BATCH_SIZE, + TRACK_MAX_BATCH_SIZE, IMPORT_MAX_BATCH_SIZE, ENGAGE_MAX_BATCH_SIZE, GROUPS_MAX_BATCH_SIZE, diff --git a/src/v0/destinations/mp/transform.js b/src/v0/destinations/mp/transform.js index 195c42fbee..09a7862f9a 100644 --- a/src/v0/destinations/mp/transform.js +++ b/src/v0/destinations/mp/transform.js @@ -24,6 +24,7 @@ const { mappingConfig, BASE_ENDPOINT, BASE_ENDPOINT_EU, + TRACK_MAX_BATCH_SIZE, IMPORT_MAX_BATCH_SIZE, ENGAGE_MAX_BATCH_SIZE, GROUPS_MAX_BATCH_SIZE, @@ -46,19 +47,21 @@ const mPEventPropertiesConfigJson = mappingConfig[ConfigCategory.EVENT_PROPERTIE const setImportCredentials = (destConfig) => { const endpoint = destConfig.dataResidency === 'eu' ? `${BASE_ENDPOINT_EU}/import/` : `${BASE_ENDPOINT}/import/`; + const headers = { 'Content-Type': 'application/json' }; const params = { strict: destConfig.strictMode ? 1 : 0 }; - const { serviceAccountUserName, serviceAccountSecret, projectId, token } = destConfig; - let credentials; - if (token) { - credentials = `${token}:`; + const { apiSecret, serviceAccountUserName, serviceAccountSecret, projectId } = destConfig; + if (apiSecret) { + headers.Authorization = `Basic ${base64Convertor(`${apiSecret}:`)}`; } else if (serviceAccountUserName && serviceAccountSecret && projectId) { - credentials = `${serviceAccountUserName}:${serviceAccountSecret}`; + headers.Authorization = `Basic ${base64Convertor( + `${serviceAccountUserName}:${serviceAccountSecret}`, + )}`; params.projectId = projectId; + } else { + throw new InstrumentationError( + 'Event timestamp is older than 5 days and no API secret or service account credentials (i.e. username, secret and projectId) are provided in destination configuration', + ); } - const headers = { - 'Content-Type': 'application/json', - Authorization: `Basic ${base64Convertor(credentials)}`, - }; return { endpoint, headers, params }; }; @@ -67,26 +70,37 @@ const responseBuilderSimple = (payload, message, eventType, destConfig) => { response.method = defaultPostRequestConfig.requestMethod; response.userId = message.userId || message.anonymousId; response.body.JSON_ARRAY = { batch: JSON.stringify([removeUndefinedValues(payload)]) }; - const { dataResidency } = destConfig; + const { apiSecret, serviceAccountUserName, serviceAccountSecret, projectId, dataResidency } = + destConfig; const duration = getTimeDifference(message.timestamp); switch (eventType) { case EventType.ALIAS: case EventType.TRACK: case EventType.SCREEN: - case EventType.PAGE: { - if (duration.years > 5) { + case EventType.PAGE: + if ( + !apiSecret && + !(serviceAccountUserName && serviceAccountSecret && projectId) && + duration.days <= 5 + ) { + response.endpoint = + dataResidency === 'eu' ? `${BASE_ENDPOINT_EU}/track/` : `${BASE_ENDPOINT}/track/`; + response.headers = {}; + } else if (duration.years > 5) { throw new InstrumentationError('Event timestamp should be within last 5 years'); + } else { + const credentials = setImportCredentials(destConfig); + response.endpoint = credentials.endpoint; + response.headers = credentials.headers; + response.params = { + project_id: credentials.params?.projectId, + strict: credentials.params.strict, + }; + break; } - const credentials = setImportCredentials(destConfig); - response.endpoint = credentials.endpoint; - response.headers = credentials.headers; - response.params = { - project_id: credentials.params?.projectId, - strict: credentials.params.strict, - }; break; - } - case 'merge': { + case 'merge': + // eslint-disable-next-line no-case-declarations const credentials = setImportCredentials(destConfig); response.endpoint = credentials.endpoint; response.headers = credentials.headers; @@ -95,7 +109,7 @@ const responseBuilderSimple = (payload, message, eventType, destConfig) => { strict: credentials.params.strict, }; break; - } + default: response.endpoint = dataResidency === 'eu' ? `${BASE_ENDPOINT_EU}/engage/` : `${BASE_ENDPOINT}/engage/`; @@ -470,6 +484,7 @@ const processRouterDest = async (inputs, reqMetadata) => { const batchSize = { engage: 0, groups: 0, + track: 0, import: 0, }; @@ -501,16 +516,23 @@ const processRouterDest = async (inputs, reqMetadata) => { ); transformedPayloads = lodash.flatMap(transformedPayloads); - const { engageEvents, groupsEvents, importEvents, batchErrorRespList } = + const { engageEvents, groupsEvents, trackEvents, importEvents, batchErrorRespList } = groupEventsByEndpoint(transformedPayloads); const engageRespList = batchEvents(engageEvents, ENGAGE_MAX_BATCH_SIZE, reqMetadata); const groupsRespList = batchEvents(groupsEvents, GROUPS_MAX_BATCH_SIZE, reqMetadata); + const trackRespList = batchEvents(trackEvents, TRACK_MAX_BATCH_SIZE, reqMetadata); const importRespList = batchEvents(importEvents, IMPORT_MAX_BATCH_SIZE, reqMetadata); - const batchSuccessRespList = [...engageRespList, ...groupsRespList, ...importRespList]; + const batchSuccessRespList = [ + ...engageRespList, + ...groupsRespList, + ...trackRespList, + ...importRespList, + ]; batchSize.engage += engageRespList.length; batchSize.groups += groupsRespList.length; + batchSize.track += trackRespList.length; batchSize.import += importRespList.length; return [...batchSuccessRespList, ...batchErrorRespList]; diff --git a/src/v0/destinations/mp/util.js b/src/v0/destinations/mp/util.js index b2807d6e11..d564e805ad 100644 --- a/src/v0/destinations/mp/util.js +++ b/src/v0/destinations/mp/util.js @@ -136,7 +136,7 @@ const createIdentifyResponse = (message, type, destination, responseBuilderSimpl * @returns */ const isImportAuthCredentialsAvailable = (destination) => - destination.Config.token || + destination.Config.apiSecret || (destination.Config.serviceAccountSecret && destination.Config.serviceAccountUserName && destination.Config.projectId); @@ -179,6 +179,7 @@ const groupEventsByEndpoint = (events) => { const eventMap = { engage: [], groups: [], + track: [], import: [], }; const batchErrorRespList = []; @@ -203,6 +204,7 @@ const groupEventsByEndpoint = (events) => { return { engageEvents: eventMap.engage, groupsEvents: eventMap.groups, + trackEvents: eventMap.track, importEvents: eventMap.import, batchErrorRespList, }; @@ -347,6 +349,7 @@ const generatePageOrScreenCustomEventName = (message, userDefinedEventTemplate) * @param {Object} batchSize - The object containing the batch size for different endpoints. * @param {number} batchSize.engage - The batch size for engage endpoint. * @param {number} batchSize.groups - The batch size for group endpoint. + * @param {number} batchSize.track - The batch size for track endpoint. * @param {number} batchSize.import - The batch size for import endpoint. * @param {string} destinationId - The ID of the destination. * @returns {void} @@ -358,6 +361,9 @@ const recordBatchSizeMetrics = (batchSize, destinationId) => { stats.gauge('mixpanel_batch_group_pack_size', batchSize.groups, { destination_id: destinationId, }); + stats.gauge('mixpanel_batch_track_pack_size', batchSize.track, { + destination_id: destinationId, + }); stats.gauge('mixpanel_batch_import_pack_size', batchSize.import, { destination_id: destinationId, }); diff --git a/src/v0/destinations/mp/util.test.js b/src/v0/destinations/mp/util.test.js index 3666081f59..40cdb34649 100644 --- a/src/v0/destinations/mp/util.test.js +++ b/src/v0/destinations/mp/util.test.js @@ -18,6 +18,7 @@ describe('Unit test cases for groupEventsByEndpoint', () => { expect(result).toEqual({ engageEvents: [], groupsEvents: [], + trackEvents: [], importEvents: [], batchErrorRespList: [], }); @@ -121,6 +122,19 @@ describe('Unit test cases for groupEventsByEndpoint', () => { }, }, ], + trackEvents: [ + { + message: { + endpoint: '/track', + body: { + JSON_ARRAY: { + batch: '[{prop:4}]', + }, + }, + userId: 'user1', + }, + }, + ], importEvents: [ { message: { diff --git a/test/integrations/destinations/mp/common.ts b/test/integrations/destinations/mp/common.ts index d40afa0c02..82f0e3202b 100644 --- a/test/integrations/destinations/mp/common.ts +++ b/test/integrations/destinations/mp/common.ts @@ -7,7 +7,7 @@ const defaultMockFns = () => { const sampleDestination: Destination = { Config: { apiKey: 'dummyApiKey', - token: 'test_api_token', + token: 'dummyApiKey', prefixProperties: true, useNativeSDK: false, }, diff --git a/test/integrations/destinations/mp/processor/data.ts b/test/integrations/destinations/mp/processor/data.ts index db5bc840c2..2d70d15384 100644 --- a/test/integrations/destinations/mp/processor/data.ts +++ b/test/integrations/destinations/mp/processor/data.ts @@ -12,7 +12,7 @@ export const data = [ request: { body: [ { - destination: overrideDestination(sampleDestination, { token: 'test_api_token' }), + destination: overrideDestination(sampleDestination, { token: 'dummyApiKey' }), message: { anonymousId: 'e6ab2c5e-2cda-44a9-a962-e2f67df78bca', channel: 'web', @@ -87,17 +87,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Loaded a Page","properties":{"ip":"0.0.0.0","campaign_id":"test_name","$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":1579847342402,"utm_campaign":"test_name","utm_source":"rudder","utm_medium":"test_medium","utm_term":"test_tem","utm_content":"test_content","utm_test":"test","utm_keyword":"test_keyword","name":"Contact Us","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + '[{"event":"Loaded a Page","properties":{"ip":"0.0.0.0","campaign_id":"test_name","$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":"dummyApiKey","distinct_id":"hjikl","time":1579847342402,"utm_campaign":"test_name","utm_source":"rudder","utm_medium":"test_medium","utm_term":"test_tem","utm_content":"test_content","utm_test":"test","utm_keyword":"test_keyword","name":"Contact Us","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', }, XML: {}, FORM: {}, @@ -194,17 +191,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Viewed a Contact Us 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":1579847342402,"name":"Contact Us","category":"Contact","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + '[{"event":"Viewed a Contact Us 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":"dummyApiKey","distinct_id":"hjikl","time":1579847342402,"name":"Contact Us","category":"Contact","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', }, XML: {}, FORM: {}, @@ -278,17 +272,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Loaded a Screen","properties":{"category":"communication","ip":"0.0.0.0","$user_id":"hjikl","$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":1579847342402,"name":"Contact Us"}}]', + '[{"event":"Loaded a Screen","properties":{"category":"communication","ip":"0.0.0.0","$user_id":"hjikl","$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":"dummyApiKey","distinct_id":"hjikl","time":1579847342402,"name":"Contact Us"}}]', }, XML: {}, FORM: {}, @@ -369,17 +360,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Loaded a Screen","properties":{"path":"/tests/html/index2.html","referrer":"","search":"","title":"","url":"http://localhost/tests/html/index2.html","ip":"0.0.0.0","$user_id":"hjiklmk","$screen_dpi":2,"mp_lib":"RudderLabs Android 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":"hjiklmk","time":1579847342402,"name":"Contact Us","category":"Contact"}}]', + '[{"event":"Loaded a Screen","properties":{"path":"/tests/html/index2.html","referrer":"","search":"","title":"","url":"http://localhost/tests/html/index2.html","ip":"0.0.0.0","$user_id":"hjiklmk","$screen_dpi":2,"mp_lib":"RudderLabs Android SDK","$app_build_number":"1.0.0","$app_version_string":"1.0.5","$insert_id":"dd266c67-9199-4a52-ba32-f46ddde67312","token":"dummyApiKey","distinct_id":"hjiklmk","time":1579847342402,"name":"Contact Us","category":"Contact"}}]', }, XML: {}, FORM: {}, @@ -452,17 +440,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Loaded a Screen","properties":{"ip":"0.0.0.0","$user_id":"hjikl","$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":1579847342402,"name":"Contact Us"}}]', + '[{"event":"Loaded a Screen","properties":{"ip":"0.0.0.0","$user_id":"hjikl","$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":"dummyApiKey","distinct_id":"hjikl","time":1579847342402,"name":"Contact Us"}}]', }, XML: {}, FORM: {}, @@ -565,7 +550,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$set":{"$created":"2020-01-23T08:54:02.362Z","$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$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":1579847342402}]', + '[{"$set":{"$created":"2020-01-23T08:54:02.362Z","$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -679,7 +664,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$append":{"$transactions":{"$time":"2020-01-24T06:29:02.403Z","$amount":45.89}},"$token":"test_api_token","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca"}]', + '[{"$append":{"$transactions":{"$time":"2020-01-24T06:29:02.403Z","$amount":45.89}},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca"}]', }, XML: {}, FORM: {}, @@ -701,7 +686,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$add":{"counter":1,"item_purchased":"2"},"$token":"test_api_token","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca"}]', + '[{"$add":{"counter":1,"item_purchased":"2"},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca"}]', }, XML: {}, FORM: {}, @@ -716,17 +701,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"test revenue MIXPANEL","properties":{"currency":"USD","revenue":45.89,"counter":1,"item_purchased":"2","number_of_logins":"","city":"Disney","country":"USA","email":"mickey@disney.com","firstName":"Mickey","ip":"0.0.0.0","campaign_id":"test_name","$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":"a6a0ad5a-bd26-4f19-8f75-38484e580fc7","token":"test_api_token","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342403,"utm_campaign":"test_name","utm_source":"rudder","utm_medium":"test_medium","utm_term":"test_tem","utm_content":"test_content","utm_test":"test","utm_keyword":"test_keyword","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + '[{"event":"test revenue MIXPANEL","properties":{"currency":"USD","revenue":45.89,"counter":1,"item_purchased":"2","number_of_logins":"","city":"Disney","country":"USA","email":"mickey@disney.com","firstName":"Mickey","ip":"0.0.0.0","campaign_id":"test_name","$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":"a6a0ad5a-bd26-4f19-8f75-38484e580fc7","token":"dummyApiKey","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342403,"utm_campaign":"test_name","utm_source":"rudder","utm_medium":"test_medium","utm_term":"test_tem","utm_content":"test_content","utm_test":"test","utm_keyword":"test_keyword","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', }, XML: {}, FORM: {}, @@ -814,17 +796,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"$create_alias","properties":{"distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","alias":"1234abc","token":"test_api_token"}}]', + '[{"event":"$create_alias","properties":{"distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","alias":"1234abc","token":"dummyApiKey"}}]', }, XML: {}, FORM: {}, @@ -954,7 +933,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$append":{"$transactions":{"$time":"2020-01-24T06:29:02.402Z","$amount":25}},"$token":"test_api_token","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca"}]', + '[{"$append":{"$transactions":{"$time":"2020-01-24T06:29:02.402Z","$amount":25}},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca"}]', }, XML: {}, FORM: {}, @@ -969,17 +948,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"KM Order Completed","properties":{"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","coupon":"hasbros","currency":"USD","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"category":"Games","image_url":"https:///www.example.com/product/path.jpg","name":"Monopoly: 3rd Edition","price":19,"product_id":"507f1f77bcf86cd799439011","quantity":1,"sku":"45790-32","url":"https://www.example.com/product/path"},{"category":"Games","name":"Uno Card Game","price":3,"product_id":"505bd76785ebb509fc183733","quantity":2,"sku":"46493-32"}],"revenue":25,"shipping":3,"subtotal":22.5,"tax":2,"total":27.5,"city":"Disney","country":"USA","email":"mickey@disney.com","firstName":"Mickey","ip":"0.0.0.0","$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":"aa5f5e44-8756-40ad-ad1e-b0d3b9fa710a","token":"test_api_token","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + '[{"event":"KM Order Completed","properties":{"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","coupon":"hasbros","currency":"USD","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"category":"Games","image_url":"https:///www.example.com/product/path.jpg","name":"Monopoly: 3rd Edition","price":19,"product_id":"507f1f77bcf86cd799439011","quantity":1,"sku":"45790-32","url":"https://www.example.com/product/path"},{"category":"Games","name":"Uno Card Game","price":3,"product_id":"505bd76785ebb509fc183733","quantity":2,"sku":"46493-32"}],"revenue":25,"shipping":3,"subtotal":22.5,"tax":2,"total":27.5,"city":"Disney","country":"USA","email":"mickey@disney.com","firstName":"Mickey","ip":"0.0.0.0","$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":"aa5f5e44-8756-40ad-ad1e-b0d3b9fa710a","token":"dummyApiKey","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', }, XML: {}, FORM: {}, @@ -1113,7 +1089,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$append":{"$transactions":{"$time":"2020-01-24T06:29:02.402Z","$amount":34}},"$token":"test_api_token","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca"}]', + '[{"$append":{"$transactions":{"$time":"2020-01-24T06:29:02.402Z","$amount":34}},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca"}]', }, XML: {}, FORM: {}, @@ -1128,17 +1104,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"KM Order Completed","properties":{"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","coupon":"hasbros","currency":"USD","discount":2.5,"order_id":"50314b8e9bcf000000000000","revenue":34,"key_1":{"child_key1":"child_value1","child_key2":{"child_key21":"child_value21","child_key22":"child_value22"}},"products":[{"category":"Games","image_url":"https:///www.example.com/product/path.jpg","name":"Monopoly: 3rd Edition","price":19,"product_id":"507f1f77bcf86cd799439011","quantity":1,"sku":"45790-32","url":"https://www.example.com/product/path"},{"category":"Games","name":"Uno Card Game","price":3,"product_id":"505bd76785ebb509fc183733","quantity":2,"sku":"46493-32"}],"shipping":3,"subtotal":22.5,"tax":2,"total":27.5,"city":"Disney","country":"USA","email":"mickey@disney.com","first_name":"Mickey","lastName":"Mouse","name":"Mickey Mouse","ip":"0.0.0.0","$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":"aa5f5e44-8756-40ad-ad1e-b0d3b9fa710a","token":"test_api_token","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + '[{"event":"KM Order Completed","properties":{"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","coupon":"hasbros","currency":"USD","discount":2.5,"order_id":"50314b8e9bcf000000000000","revenue":34,"key_1":{"child_key1":"child_value1","child_key2":{"child_key21":"child_value21","child_key22":"child_value22"}},"products":[{"category":"Games","image_url":"https:///www.example.com/product/path.jpg","name":"Monopoly: 3rd Edition","price":19,"product_id":"507f1f77bcf86cd799439011","quantity":1,"sku":"45790-32","url":"https://www.example.com/product/path"},{"category":"Games","name":"Uno Card Game","price":3,"product_id":"505bd76785ebb509fc183733","quantity":2,"sku":"46493-32"}],"shipping":3,"subtotal":22.5,"tax":2,"total":27.5,"city":"Disney","country":"USA","email":"mickey@disney.com","first_name":"Mickey","lastName":"Mouse","name":"Mickey Mouse","ip":"0.0.0.0","$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":"aa5f5e44-8756-40ad-ad1e-b0d3b9fa710a","token":"dummyApiKey","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', }, XML: {}, FORM: {}, @@ -1262,17 +1235,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":" new Order Completed totally","properties":{"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","coupon":"hasbros","currency":"USD","discount":2.5,"total":23,"order_id":"50314b8e9bcf000000000000","key_1":{"child_key1":"child_value1","child_key2":{"child_key21":"child_value21","child_key22":"child_value22"}},"products":[{"category":"Games","image_url":"https:///www.example.com/product/path.jpg","name":"Monopoly: 3rd Edition","price":19,"product_id":"507f1f77bcf86cd799439011","quantity":1,"sku":"45790-32","url":"https://www.example.com/product/path"},{"category":"Games","name":"Uno Card Game","price":3,"product_id":"505bd76785ebb509fc183733","quantity":2,"sku":"46493-32"}],"shipping":3,"subtotal":22.5,"tax":2,"city":"Disney","country":"USA","email":"mickey@disney.com","firstName":"Mickey","ip":"0.0.0.0","$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":"aa5f5e44-8756-40ad-ad1e-b0d3b9fa710a","token":"test_api_token","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + '[{"event":" new Order Completed totally","properties":{"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","coupon":"hasbros","currency":"USD","discount":2.5,"total":23,"order_id":"50314b8e9bcf000000000000","key_1":{"child_key1":"child_value1","child_key2":{"child_key21":"child_value21","child_key22":"child_value22"}},"products":[{"category":"Games","image_url":"https:///www.example.com/product/path.jpg","name":"Monopoly: 3rd Edition","price":19,"product_id":"507f1f77bcf86cd799439011","quantity":1,"sku":"45790-32","url":"https://www.example.com/product/path"},{"category":"Games","name":"Uno Card Game","price":3,"product_id":"505bd76785ebb509fc183733","quantity":2,"sku":"46493-32"}],"shipping":3,"subtotal":22.5,"tax":2,"city":"Disney","country":"USA","email":"mickey@disney.com","firstName":"Mickey","ip":"0.0.0.0","$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":"aa5f5e44-8756-40ad-ad1e-b0d3b9fa710a","token":"dummyApiKey","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', }, XML: {}, FORM: {}, @@ -1396,17 +1366,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":" Order Completed ","properties":{"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","coupon":"hasbros","currency":"USD","discount":2.5,"total":23,"order_id":"50314b8e9bcf000000000000","key_1":{"child_key1":"child_value1","child_key2":{"child_key21":"child_value21","child_key22":"child_value22"}},"products":[{"category":"Games","image_url":"https:///www.example.com/product/path.jpg","name":"Monopoly: 3rd Edition","price":19,"product_id":"507f1f77bcf86cd799439011","quantity":1,"sku":"45790-32","url":"https://www.example.com/product/path"},{"category":"Games","name":"Uno Card Game","price":3,"product_id":"505bd76785ebb509fc183733","quantity":2,"sku":"46493-32"}],"shipping":3,"subtotal":22.5,"tax":2,"Billing Amount":"77","city":"Disney","country":"USA","email":"mickey@disney.com","firstName":"Mickey","ip":"0.0.0.0","$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":"aa5f5e44-8756-40ad-ad1e-b0d3b9fa710a","token":"test_api_token","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + '[{"event":" Order Completed ","properties":{"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","coupon":"hasbros","currency":"USD","discount":2.5,"total":23,"order_id":"50314b8e9bcf000000000000","key_1":{"child_key1":"child_value1","child_key2":{"child_key21":"child_value21","child_key22":"child_value22"}},"products":[{"category":"Games","image_url":"https:///www.example.com/product/path.jpg","name":"Monopoly: 3rd Edition","price":19,"product_id":"507f1f77bcf86cd799439011","quantity":1,"sku":"45790-32","url":"https://www.example.com/product/path"},{"category":"Games","name":"Uno Card Game","price":3,"product_id":"505bd76785ebb509fc183733","quantity":2,"sku":"46493-32"}],"shipping":3,"subtotal":22.5,"tax":2,"Billing Amount":"77","city":"Disney","country":"USA","email":"mickey@disney.com","firstName":"Mickey","ip":"0.0.0.0","$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":"aa5f5e44-8756-40ad-ad1e-b0d3b9fa710a","token":"dummyApiKey","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', }, XML: {}, FORM: {}, @@ -1574,7 +1541,7 @@ export const data = [ 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":1579847342402}]', + '[{"$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":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -1661,7 +1628,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$token":"test_api_token","$distinct_id":"hjikl","$set":{"company":["testComp"]},"$ip":"0.0.0.0"}]', + '[{"$token":"dummyApiKey","$distinct_id":"hjikl","$set":{"company":["testComp"]},"$ip":"0.0.0.0"}]', }, XML: {}, FORM: {}, @@ -1683,7 +1650,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$token":"test_api_token","$group_key":"company","$group_id":"testComp","$set":{"company":"testComp"}}]', + '[{"$token":"dummyApiKey","$group_key":"company","$group_id":"testComp","$set":{"company":"testComp"}}]', }, XML: {}, FORM: {}, @@ -1770,7 +1737,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$token":"test_api_token","$distinct_id":"hjikl","$set":{"company":["testComp","testComp1"]},"$ip":"0.0.0.0"}]', + '[{"$token":"dummyApiKey","$distinct_id":"hjikl","$set":{"company":["testComp","testComp1"]},"$ip":"0.0.0.0"}]', }, XML: {}, FORM: {}, @@ -1792,7 +1759,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$token":"test_api_token","$group_key":"company","$group_id":"testComp","$set":{"company":["testComp","testComp1"]}}]', + '[{"$token":"dummyApiKey","$group_key":"company","$group_id":"testComp","$set":{"company":["testComp","testComp1"]}}]', }, XML: {}, FORM: {}, @@ -1814,7 +1781,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$token":"test_api_token","$group_key":"company","$group_id":"testComp1","$set":{"company":["testComp","testComp1"]}}]', + '[{"$token":"dummyApiKey","$group_key":"company","$group_id":"testComp1","$set":{"company":["testComp","testComp1"]}}]', }, XML: {}, FORM: {}, @@ -1902,7 +1869,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$token":"test_api_token","$distinct_id":"hjikl","$set":{"company":["testComp"]},"$ip":"0.0.0.0"}]', + '[{"$token":"dummyApiKey","$distinct_id":"hjikl","$set":{"company":["testComp"]},"$ip":"0.0.0.0"}]', }, XML: {}, FORM: {}, @@ -1924,7 +1891,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$token":"test_api_token","$group_key":"company","$group_id":"testComp","$set":{"company":"testComp"}}]', + '[{"$token":"dummyApiKey","$group_key":"company","$group_id":"testComp","$set":{"company":"testComp"}}]', }, XML: {}, FORM: {}, @@ -2052,7 +2019,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$append":{"$transactions":{"$time":"2020-01-24T06:29:02.402Z","$amount":25}},"$token":"test_api_token","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca"}]', + '[{"$append":{"$transactions":{"$time":"2020-01-24T06:29:02.402Z","$amount":25}},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca"}]', }, XML: {}, FORM: {}, @@ -2067,17 +2034,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api-eu.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api-eu.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"KM Order Completed","properties":{"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","coupon":"hasbros","currency":"USD","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"category":"Games","image_url":"https:///www.example.com/product/path.jpg","name":"Monopoly: 3rd Edition","price":19,"product_id":"507f1f77bcf86cd799439011","quantity":1,"sku":"45790-32","url":"https://www.example.com/product/path"},{"category":"Games","name":"Uno Card Game","price":3,"product_id":"505bd76785ebb509fc183733","quantity":2,"sku":"46493-32"}],"revenue":25,"shipping":3,"subtotal":22.5,"tax":2,"total":27.5,"city":"Disney","country":"USA","email":"mickey@disney.com","firstname":"Mickey","lastname":"Mouse","ip":"0.0.0.0","$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":"aa5f5e44-8756-40ad-ad1e-b0d3b9fa710a","token":"test_api_token","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + '[{"event":"KM Order Completed","properties":{"affiliation":"Google Store","checkout_id":"fksdjfsdjfisjf9sdfjsd9f","coupon":"hasbros","currency":"USD","discount":2.5,"order_id":"50314b8e9bcf000000000000","products":[{"category":"Games","image_url":"https:///www.example.com/product/path.jpg","name":"Monopoly: 3rd Edition","price":19,"product_id":"507f1f77bcf86cd799439011","quantity":1,"sku":"45790-32","url":"https://www.example.com/product/path"},{"category":"Games","name":"Uno Card Game","price":3,"product_id":"505bd76785ebb509fc183733","quantity":2,"sku":"46493-32"}],"revenue":25,"shipping":3,"subtotal":22.5,"tax":2,"total":27.5,"city":"Disney","country":"USA","email":"mickey@disney.com","firstname":"Mickey","lastname":"Mouse","ip":"0.0.0.0","$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":"aa5f5e44-8756-40ad-ad1e-b0d3b9fa710a","token":"dummyApiKey","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', }, XML: {}, FORM: {}, @@ -2165,7 +2129,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$set":{"$carrier":"Android","$manufacturer":"Google","$model":"Android SDK built for x86","$screen_height":1794,"$screen_width":1080,"$wifi":true,"anonymousId":"5094f5704b9cf2b3","$android_devices":["test_device_token"],"$os":"Android","$android_model":"Android SDK built for x86","$android_os_version":"8.1.0","$android_manufacturer":"Google","$android_app_version":"1.0","$android_app_version_code":"1.0","$android_brand":"Google"},"$token":"test_api_token","$distinct_id":"5094f5704b9cf2b3","$time":1584003903421}]', + '[{"$set":{"$carrier":"Android","$manufacturer":"Google","$model":"Android SDK built for x86","$screen_height":1794,"$screen_width":1080,"$wifi":true,"anonymousId":"5094f5704b9cf2b3","$android_devices":["test_device_token"],"$os":"Android","$android_model":"Android SDK built for x86","$android_os_version":"8.1.0","$android_manufacturer":"Google","$android_app_version":"1.0","$android_app_version_code":"1.0","$android_brand":"Google"},"$token":"dummyApiKey","$distinct_id":"5094f5704b9cf2b3","$time":1584003903421}]', }, XML: {}, FORM: {}, @@ -2252,7 +2216,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$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":1584003903421}]', + '[{"$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":"dummyApiKey","$distinct_id":"test_user_id","$time":1584003903421}]', }, XML: {}, FORM: {}, @@ -2269,7 +2233,7 @@ export const data = [ method: 'POST', endpoint: 'https://api-eu.mixpanel.com/import/', headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic c29tZV9hcGlfc2VjcmV0Og==', 'Content-Type': 'application/json', }, params: { strict: 0 }, @@ -2277,7 +2241,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"event":"$merge","properties":{"$distinct_ids":["test_user_id","5094f5704b9cf2b3"],"token":"test_api_token"}}]', + '[{"event":"$merge","properties":{"$distinct_ids":["test_user_id","5094f5704b9cf2b3"],"token":"dummyApiKey"}}]', }, XML: {}, FORM: {}, @@ -2364,17 +2328,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Loaded a Page","properties":{"path":"/tests/html/index2.html","referrer":"","search":"","title":"","url":"http://localhost/tests/html/index2.html","category":"communication","ip":"0.0.0.0","$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":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"name":"Contact Us","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + '[{"event":"Loaded a Page","properties":{"path":"/tests/html/index2.html","referrer":"","search":"","title":"","url":"http://localhost/tests/html/index2.html","category":"communication","ip":"0.0.0.0","$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":"dummyApiKey","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1579847342402,"name":"Contact Us","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', }, XML: {}, FORM: {}, @@ -2462,17 +2423,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"$create_alias","properties":{"distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","alias":"1234abc","token":"test_api_token"}}]', + '[{"event":"$create_alias","properties":{"distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","alias":"1234abc","token":"dummyApiKey"}}]', }, XML: {}, FORM: {}, @@ -2565,7 +2523,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$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","createdat":"2020-01-23T08:54:02.362Z","$ios_devices":["test_device_token"],"$ios_device_model":"Android SDK built for x86","$ios_app_release":"1","$ios_app_version":"1.0"},"$token":"test_api_token","$distinct_id":"test_user_id","$time":1584003903421}]', + '[{"$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","createdat":"2020-01-23T08:54:02.362Z","$ios_devices":["test_device_token"],"$ios_device_model":"Android SDK built for x86","$ios_app_release":"1","$ios_app_version":"1.0"},"$token":"dummyApiKey","$distinct_id":"test_user_id","$time":1584003903421}]', }, XML: {}, FORM: {}, @@ -2582,7 +2540,7 @@ export const data = [ method: 'POST', endpoint: 'https://api-eu.mixpanel.com/import/', headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic c29tZV9hcGlfc2VjcmV0Og==', 'Content-Type': 'application/json', }, params: { strict: 0 }, @@ -2590,7 +2548,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"event":"$merge","properties":{"$distinct_ids":["test_user_id","5094f5704b9cf2b3"],"token":"test_api_token"}}]', + '[{"event":"$merge","properties":{"$distinct_ids":["test_user_id","5094f5704b9cf2b3"],"token":"dummyApiKey"}}]', }, XML: {}, FORM: {}, @@ -2683,7 +2641,7 @@ export const data = [ 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","$name":"Mickey Mouse","$firstName":"Mickey","$lastName":"Mouse","$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":1579847342402}]', + '[{"$set":{"$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":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -2775,7 +2733,7 @@ export const data = [ 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":1579847342402}]', + '[{"$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":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -2868,7 +2826,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$set":{"$email":"mickey@disney.com","$name":"Mickey Mouse","$country_code":"USA","$city":"Disney","$region":"US","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$firstName":"Mickey","$lastName":"Mouse","$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":1579847342402}]', + '[{"$set":{"$email":"mickey@disney.com","$name":"Mickey Mouse","$country_code":"USA","$city":"Disney","$region":"US","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$firstName":"Mickey","$lastName":"Mouse","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -2966,7 +2924,7 @@ export const data = [ 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","$name":"Mickey Mouse","$firstName":"Mickey","$lastName":"Mouse","$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":1579847342402}]', + '[{"$set":{"$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":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -3062,7 +3020,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$set":{"$email":"mickey@disney.com","$name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$firstName":"Mickey","$lastName":"Mouse","$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":1579847342402}]', + '[{"$set":{"$email":"mickey@disney.com","$name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$firstName":"Mickey","$lastName":"Mouse","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -3157,7 +3115,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$set":{"$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$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":1579847342402}]', + '[{"$set":{"$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -3251,7 +3209,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$set":{"$email":"mickey@disney.com","$first_name":"Mickey","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$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":1579847342402}]', + '[{"$set":{"$email":"mickey@disney.com","$first_name":"Mickey","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -3346,7 +3304,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$set":{"$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$name":"Mickey Mouse","$country_code":"USA","$city":"Disney","$region":"US","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$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":1579847342402}]', + '[{"$set":{"$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$name":"Mickey Mouse","$country_code":"USA","$city":"Disney","$region":"US","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -3447,7 +3405,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$set":{"$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$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":1579847342402}]', + '[{"$set":{"$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -3544,29 +3502,17 @@ export const data = [ status: 200, body: [ { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, - body: { - JSON: {}, - JSON_ARRAY: { - batch: - '[{"event":"FirstTrackCall12","properties":{"foo":"bar","$deviceId":"nkasdnkasd","anonymousId":"ea776ad0-3136-44fb-9216-5b1578609a2b","userId":"as09sufa09usaf09as0f9uasf","id":"as09sufa09usaf09as0f9uasf","firstName":"Bob","lastName":"Marley","name":"Bob Marley","age":43,"email":"bob@marleymail.com","phone":"+447748544123","birthday":"1987-01-01T20:08:59+0000","createdAt":"2022-01-21T14:10:12+0000","address":"51,B.L.T road, Kolkata-700060","description":"I am great","gender":"male","title":"Founder","username":"bobm","website":"https://bobm.com","randomProperty":"randomValue","$user_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$current_url":"http://127.0.0.1:7307/Testing/App_for_testingTool/","$referrer":"http://127.0.0.1:7307/Testing/","$screen_height":900,"$screen_width":1440,"$screen_dpi":2,"mp_lib":"RudderLabs JavaScript SDK","$app_build_number":"1.0.0","$app_version_string":"1.1.18","$insert_id":"0d5c1a4a-27e4-41da-a246-4d01f44e74bd","token":"test_api_token","distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","time":1632986123523,"$browser":"Chrome","$browser_version":"93.0.4577.82"}}]', - }, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'e6ab2c5e-2cda-44a9-a962-e2f67df78bca', + error: + 'Event timestamp is older than 5 days and no API secret or service account credentials (i.e. username, secret and projectId) are provided in destination configuration', + statTags: { + destType: 'MP', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'native', + module: 'destination', }, - statusCode: 200, + statusCode: 400, }, ], }, @@ -3740,7 +3686,7 @@ export const data = [ method: 'POST', endpoint: 'https://api-eu.mixpanel.com/import/', headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic c29tZV9hcGlfc2VjcmV0Og==', 'Content-Type': 'application/json', }, params: { strict: 0 }, @@ -3748,7 +3694,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"event":"MainActivity","properties":{"name":"MainActivity","automatic":true,"anonymousId":"5094f5704b9cf2b3","userId":"test_user_id","$user_id":"test_user_id","$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":"test_user_id","time":1520845503421}}]', + '[{"event":"MainActivity","properties":{"name":"MainActivity","automatic":true,"anonymousId":"5094f5704b9cf2b3","userId":"test_user_id","$user_id":"test_user_id","$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":"dummyApiKey","distinct_id":"test_user_id","time":1520845503421}}]', }, XML: {}, FORM: {}, @@ -4019,7 +3965,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$set":{"$created":"2020-01-23T08:54:02.362Z","$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$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":1579847342402,"$ignore_time":true}]', + '[{"$set":{"$created":"2020-01-23T08:54:02.362Z","$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402,"$ignore_time":true}]', }, XML: {}, FORM: {}, @@ -4125,7 +4071,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$set":{"$created":"2020-01-23T08:54:02.362Z","$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$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":1579847342402}]', + '[{"$set":{"$created":"2020-01-23T08:54:02.362Z","$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyApiKey","$distinct_id":"e6ab2c5e-2cda-44a9-a962-e2f67df78bca","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -4330,7 +4276,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$set":{"$created":"2020-01-23T08:54:02.362Z","$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"test_api_token","$distinct_id":"user1234","$ip":"0.0.0.0","$time":1579847342402}]', + '[{"$set":{"$created":"2020-01-23T08:54:02.362Z","$email":"mickey@disney.com","$first_name":"Mickey","$last_name":"Mouse","$country_code":"USA","$city":"Disney","$initial_referrer":"https://docs.rudderstack.com","$initial_referring_domain":"docs.rudderstack.com","$name":"Mickey Mouse","$browser":"Chrome","$browser_version":"79.0.3945.117"},"$token":"dummyApiKey","$distinct_id":"user1234","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -4348,14 +4294,18 @@ export const data = [ endpoint: 'https://api.mixpanel.com/import/', headers: { 'Content-Type': 'application/json', - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: + 'Basic cnVkZGVyLmQyYTNmMS5tcC1zZXJ2aWNlLWFjY291bnQ6amF0cFF4Y2pNaDhlZXRrMXhySDNLalFJYnp5NGlYOGI=', + }, + params: { + project_id: '123456', + strict: 0, }, - params: { strict: 0 }, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"$merge","properties":{"$distinct_ids":["user1234","e6ab2c5e-2cda-44a9-a962-e2f67df78bca"],"token":"test_api_token"}}]', + '[{"event":"$merge","properties":{"$distinct_ids":["user1234","e6ab2c5e-2cda-44a9-a962-e2f67df78bca"],"token":"dummyApiKey"}}]', }, XML: {}, FORM: {}, @@ -4440,7 +4390,7 @@ export const data = [ method: 'POST', endpoint: 'https://api.mixpanel.com/import/', headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic ZHVtbXlBcGlLZXk6', 'Content-Type': 'application/json', }, params: { strict: 0 }, @@ -4448,7 +4398,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Application Installed","properties":{"build":4,"version":"1.0","anonymousId":"39da706ec83d0e90","$os":"Android","$screen_height":2984,"$screen_width":1440,"$screen_dpi":560,"$carrier":"T-Mobile","$os_version":"12","$device":"emu64a","$manufacturer":"Google","$model":"sdk_gphone64_arm64","mp_device_model":"sdk_gphone64_arm64","$wifi":true,"$bluetooth_enabled":true,"mp_lib":"com.rudderstack.android.sdk.core","$app_build_number":"4","$app_version_string":"1.0","$insert_id":"168cf720-6227-4b56-a98e-c49bdc7279e9","$session_id":"1662363980","token":"test_api_token","distinct_id":"39da706ec83d0e90","time":1662363980290}}]', + '[{"event":"Application Installed","properties":{"build":4,"version":"1.0","anonymousId":"39da706ec83d0e90","$os":"Android","$screen_height":2984,"$screen_width":1440,"$screen_dpi":560,"$carrier":"T-Mobile","$os_version":"12","$device":"emu64a","$manufacturer":"Google","$model":"sdk_gphone64_arm64","mp_device_model":"sdk_gphone64_arm64","$wifi":true,"$bluetooth_enabled":true,"mp_lib":"com.rudderstack.android.sdk.core","$app_build_number":"4","$app_version_string":"1.0","$insert_id":"168cf720-6227-4b56-a98e-c49bdc7279e9","$session_id":"1662363980","token":"dummyApiKey","distinct_id":"39da706ec83d0e90","time":1662363980290}}]', }, XML: {}, FORM: {}, @@ -4530,7 +4480,7 @@ export const data = [ method: 'POST', endpoint: 'https://api.mixpanel.com/import/', headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic ZHVtbXlBcGlLZXk6', 'Content-Type': 'application/json', }, params: { strict: 0 }, @@ -4538,7 +4488,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Application Opened","properties":{"build":4,"version":"1.0","anonymousId":"39da706ec83d0e90","$os":"Android","$screen_height":2984,"$screen_width":1440,"$screen_dpi":560,"$carrier":"T-Mobile","$os_version":"12","$device":"emu64a","$manufacturer":"Google","$model":"sdk_gphone64_arm64","mp_device_model":"sdk_gphone64_arm64","$wifi":true,"$bluetooth_enabled":true,"mp_lib":"com.rudderstack.android.sdk.core","$app_build_number":"4","$app_version_string":"1.0","$insert_id":"168cf720-6227-4b56-a98e-c49bdc7279e9","$session_id":"1662363980","token":"test_api_token","distinct_id":"39da706ec83d0e90","time":1662363980290}}]', + '[{"event":"Application Opened","properties":{"build":4,"version":"1.0","anonymousId":"39da706ec83d0e90","$os":"Android","$screen_height":2984,"$screen_width":1440,"$screen_dpi":560,"$carrier":"T-Mobile","$os_version":"12","$device":"emu64a","$manufacturer":"Google","$model":"sdk_gphone64_arm64","mp_device_model":"sdk_gphone64_arm64","$wifi":true,"$bluetooth_enabled":true,"mp_lib":"com.rudderstack.android.sdk.core","$app_build_number":"4","$app_version_string":"1.0","$insert_id":"168cf720-6227-4b56-a98e-c49bdc7279e9","$session_id":"1662363980","token":"dummyApiKey","distinct_id":"39da706ec83d0e90","time":1662363980290}}]', }, XML: {}, FORM: {}, @@ -4626,7 +4576,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$token":"test_api_token","$distinct_id":"hjikl","$set":{"groupId":["testGroupId"]},"$ip":"0.0.0.0"}]', + '[{"$token":"dummyApiKey","$distinct_id":"hjikl","$set":{"groupId":["testGroupId"]},"$ip":"0.0.0.0"}]', }, XML: {}, FORM: {}, @@ -4648,7 +4598,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$token":"test_api_token","$group_key":"groupId","$group_id":"testGroupId","$set":{"company":"testComp","groupId":"groupIdInTraits"}}]', + '[{"$token":"dummyApiKey","$group_key":"groupId","$group_id":"testGroupId","$set":{"company":"testComp","groupId":"groupIdInTraits"}}]', }, XML: {}, FORM: {}, @@ -4675,7 +4625,7 @@ export const data = [ description: 'Track: set device id and user id when simplified id merge api is selected', destination: overrideDestination(sampleDestination, { - token: 'test_api_token', + token: 'dummyApiKey', identityMergeApi: 'simplified', }), message: { @@ -4731,17 +4681,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Product Viewed","properties":{"name":"T-Shirt","$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":1579847342402,"$device_id":"anonId01"}}]', + '[{"event":"Product Viewed","properties":{"name":"T-Shirt","$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":"dummyApiKey","distinct_id":"userId01","time":1579847342402,"$device_id":"anonId01"}}]', }, XML: {}, FORM: {}, @@ -4770,7 +4717,7 @@ export const data = [ { description: 'Identify: skip merge event when simplified id merge api is selected', destination: overrideDestination(sampleDestination, { - token: 'test_api_token', + token: 'dummyApiKey', identityMergeApi: 'simplified', }), message: { @@ -4851,7 +4798,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$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":"userId01","$ip":"0.0.0.0","$time":1579847342402}]', + '[{"$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":"dummyApiKey","$distinct_id":"userId01","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -4879,7 +4826,7 @@ export const data = [ 'Identify: append $device: to deviceId while creating the user when simplified id merge api is selected', destination: overrideDestination(sampleDestination, { apiKey: 'apiKey123', - token: 'test_api_token', + token: 'dummyApiKey', identityMergeApi: 'simplified', }), message: { @@ -4959,7 +4906,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$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":1579847342402}]', + '[{"$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":"dummyApiKey","$distinct_id":"$device:anonId01","$ip":"0.0.0.0","$time":1579847342402}]', }, XML: {}, FORM: {}, @@ -4986,7 +4933,7 @@ export const data = [ description: 'Unsupported alias call when simplified id merge api is selected', destination: overrideDestination(sampleDestination, { apiKey: 'apiKey123', - token: 'test_api_token', + token: 'dummyApiKey', identityMergeApi: 'simplified', }), message: { @@ -5075,7 +5022,7 @@ export const data = [ 'Track revenue event: set device id and user id when simplified id merge api is selected', destination: overrideDestination(sampleDestination, { apiKey: 'apiKey123', - token: 'test_api_token', + token: 'dummyApiKey', identityMergeApi: 'simplified', }), message: { @@ -5146,7 +5093,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$append":{"$transactions":{"$time":"2020-01-24T06:29:02.403Z","$amount":18.9}},"$token":"test_api_token","$distinct_id":"userId01"}]', + '[{"$append":{"$transactions":{"$time":"2020-01-24T06:29:02.403Z","$amount":18.9}},"$token":"dummyApiKey","$distinct_id":"userId01"}]', }, XML: {}, FORM: {}, @@ -5161,17 +5108,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"test revenue MIXPANEL","properties":{"currency":"USD","revenue":18.9,"city":"Disney","country":"USA","email":"mickey@disney.com","firstName":"Mickey","ip":"0.0.0.0","$user_id":"userId01","$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":"a6a0ad5a-bd26-4f19-8f75-38484e580fc7","token":"test_api_token","distinct_id":"userId01","time":1579847342403,"$device_id":"anonId01","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + '[{"event":"test revenue MIXPANEL","properties":{"currency":"USD","revenue":18.9,"city":"Disney","country":"USA","email":"mickey@disney.com","firstName":"Mickey","ip":"0.0.0.0","$user_id":"userId01","$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":"a6a0ad5a-bd26-4f19-8f75-38484e580fc7","token":"dummyApiKey","distinct_id":"userId01","time":1579847342403,"$device_id":"anonId01","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', }, XML: {}, FORM: {}, @@ -5201,7 +5145,7 @@ export const data = [ description: 'Page with anonymous user when simplified api is selected', destination: overrideDestination(sampleDestination, { apiKey: 'apiKey123', - token: 'test_api_token', + token: 'dummyApiKey', identityMergeApi: 'simplified', }), message: { @@ -5268,17 +5212,14 @@ export const data = [ version: '1', type: 'REST', method: 'POST', - endpoint: 'https://api.mixpanel.com/import/', - headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', - 'Content-Type': 'application/json', - }, - params: { strict: 0 }, + endpoint: 'https://api.mixpanel.com/track/', + headers: {}, + params: {}, body: { JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Loaded a Page","properties":{"ip":"0.0.0.0","$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":"$device:anonId01","time":1579847342402,"$device_id":"anonId01","name":"Contact Us","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', + '[{"event":"Loaded a Page","properties":{"ip":"0.0.0.0","$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":"dummyApiKey","distinct_id":"$device:anonId01","time":1579847342402,"$device_id":"anonId01","name":"Contact Us","$browser":"Chrome","$browser_version":"79.0.3945.117"}}]', }, XML: {}, FORM: {}, @@ -5308,7 +5249,7 @@ export const data = [ description: 'Group call with anonymous user when simplified api is selected', destination: overrideDestination(sampleDestination, { apiKey: 'apiKey123', - token: 'test_api_token', + token: 'dummyApiKey', identityMergeApi: 'simplified', groupKeySettings: [{ groupKey: 'company' }], }), @@ -5371,7 +5312,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$token":"test_api_token","$distinct_id":"$device:anonId01","$set":{"company":["testComp"]},"$ip":"0.0.0.0"}]', + '[{"$token":"dummyApiKey","$distinct_id":"$device:anonId01","$set":{"company":["testComp"]},"$ip":"0.0.0.0"}]', }, XML: {}, FORM: {}, @@ -5393,7 +5334,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$token":"test_api_token","$group_key":"company","$group_id":"testComp","$set":{"company":"testComp"}}]', + '[{"$token":"dummyApiKey","$group_key":"company","$group_id":"testComp","$set":{"company":"testComp"}}]', }, XML: {}, FORM: {}, @@ -5419,7 +5360,7 @@ export const data = [ { destination: overrideDestination(sampleDestination, { apiKey: 'apiKey123', - token: 'test_api_token', + token: 'dummyApiKey', identityMergeApi: 'simplified', groupKeySettings: [{ groupKey: 'company' }], }), @@ -5538,7 +5479,7 @@ export const data = [ }, destination: overrideDestination(sampleDestination, { apiKey: 'dummyApiKey', - token: 'test_api_token', + token: 'dummyApiKey', apiSecret: 'dummyApiKey', useNewMapping: true, }), @@ -5564,7 +5505,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$append":{"$transactions":{"$time":"2022-09-05T07:46:20.290Z","$amount":12.13}},"$token":"test_api_token","$distinct_id":"39da706ec83d0e90"}]', + '[{"$append":{"$transactions":{"$time":"2022-09-05T07:46:20.290Z","$amount":12.13}},"$token":"dummyApiKey","$distinct_id":"39da706ec83d0e90"}]', }, XML: {}, FORM: {}, @@ -5581,7 +5522,7 @@ export const data = [ method: 'POST', endpoint: 'https://api.mixpanel.com/import/', headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic ZHVtbXlBcGlLZXk6', 'Content-Type': 'application/json', }, params: { strict: 0 }, @@ -5589,7 +5530,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Application Installed","properties":{"build":4,"version":"1.0","revenue":12.13,"anonymousId":"39da706ec83d0e90","$os":"Android","$screen_height":2984,"$screen_width":1440,"$screen_dpi":560,"$carrier":"T-Mobile","$os_version":"12","$device":"emu64a","$manufacturer":"Google","$model":"sdk_gphone64_arm64","mp_device_model":"sdk_gphone64_arm64","$wifi":true,"$bluetooth_enabled":true,"mp_lib":"com.rudderstack.android.sdk.core","$app_build_number":"4","$app_version_string":"1.0","$insert_id":"168cf720-6227-4b56-a98e-c49bdc7279e9","$session_id":"1662363980","token":"test_api_token","distinct_id":"39da706ec83d0e90","time":1662363980290}}]', + '[{"event":"Application Installed","properties":{"build":4,"version":"1.0","revenue":12.13,"anonymousId":"39da706ec83d0e90","$os":"Android","$screen_height":2984,"$screen_width":1440,"$screen_dpi":560,"$carrier":"T-Mobile","$os_version":"12","$device":"emu64a","$manufacturer":"Google","$model":"sdk_gphone64_arm64","mp_device_model":"sdk_gphone64_arm64","$wifi":true,"$bluetooth_enabled":true,"mp_lib":"com.rudderstack.android.sdk.core","$app_build_number":"4","$app_version_string":"1.0","$insert_id":"168cf720-6227-4b56-a98e-c49bdc7279e9","$session_id":"1662363980","token":"dummyApiKey","distinct_id":"39da706ec83d0e90","time":1662363980290}}]', }, XML: {}, FORM: {}, @@ -5653,7 +5594,7 @@ export const data = [ }, destination: overrideDestination(sampleDestination, { apiKey: 'dummyApiKey', - token: 'test_api_token', + token: 'dummyApiKey', apiSecret: 'dummyApiKey', useNewMapping: true, }), @@ -5679,7 +5620,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$append":{"$transactions":{"$time":"2022-09-05T07:46:20.290Z","$amount":23.45}},"$token":"test_api_token","$distinct_id":"39da706ec83d0e90"}]', + '[{"$append":{"$transactions":{"$time":"2022-09-05T07:46:20.290Z","$amount":23.45}},"$token":"dummyApiKey","$distinct_id":"39da706ec83d0e90"}]', }, XML: {}, FORM: {}, @@ -5696,7 +5637,7 @@ export const data = [ method: 'POST', endpoint: 'https://api.mixpanel.com/import/', headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic ZHVtbXlBcGlLZXk6', 'Content-Type': 'application/json', }, params: { strict: 0 }, @@ -5704,7 +5645,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"event":"Application Installed","properties":{"build":4,"version":"1.0","revenue":23.45,"anonymousId":"39da706ec83d0e90","$os":"Android","$screen_height":2984,"$screen_width":1440,"$screen_dpi":560,"$carrier":"T-Mobile","$os_version":"12","$device":"emu64a","$manufacturer":"Google","$model":"sdk_gphone64_arm64","mp_device_model":"sdk_gphone64_arm64","$wifi":true,"$bluetooth_enabled":true,"mp_lib":"com.rudderstack.android.sdk.core","$app_build_number":"4","$app_version_string":"1.0","$insert_id":"168cf720-6227-4b56-a98e-c49bdc7279e9","$session_id":"1662363980","token":"test_api_token","distinct_id":"39da706ec83d0e90","time":null}}]', + '[{"event":"Application Installed","properties":{"build":4,"version":"1.0","revenue":23.45,"anonymousId":"39da706ec83d0e90","$os":"Android","$screen_height":2984,"$screen_width":1440,"$screen_dpi":560,"$carrier":"T-Mobile","$os_version":"12","$device":"emu64a","$manufacturer":"Google","$model":"sdk_gphone64_arm64","mp_device_model":"sdk_gphone64_arm64","$wifi":true,"$bluetooth_enabled":true,"mp_lib":"com.rudderstack.android.sdk.core","$app_build_number":"4","$app_version_string":"1.0","$insert_id":"168cf720-6227-4b56-a98e-c49bdc7279e9","$session_id":"1662363980","token":"dummyApiKey","distinct_id":"39da706ec83d0e90","time":null}}]', }, XML: {}, FORM: {}, @@ -5731,7 +5672,7 @@ export const data = [ description: 'Track: with strict mode enabled', destination: overrideDestination(sampleDestination, { apiKey: 'dummyApiKey', - token: 'test_api_token', + token: 'dummyApiKey', apiSecret: 'some_api_secret', dataResidency: 'eu', strictMode: true, @@ -5795,7 +5736,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"$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":1584003903421}]', + '[{"$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":"dummyApiKey","$distinct_id":"test_user_id","$time":1584003903421}]', }, XML: {}, FORM: {}, @@ -5812,7 +5753,7 @@ export const data = [ method: 'POST', endpoint: 'https://api-eu.mixpanel.com/import/', headers: { - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic c29tZV9hcGlfc2VjcmV0Og==', 'Content-Type': 'application/json', }, params: { strict: 1 }, @@ -5820,7 +5761,7 @@ export const data = [ JSON: {}, JSON_ARRAY: { batch: - '[{"event":"$merge","properties":{"$distinct_ids":["test_user_id","5094f5704b9cf2b3"],"token":"test_api_token"}}]', + '[{"event":"$merge","properties":{"$distinct_ids":["test_user_id","5094f5704b9cf2b3"],"token":"dummyApiKey"}}]', }, XML: {}, FORM: {}, diff --git a/test/integrations/destinations/mp/router/data.ts b/test/integrations/destinations/mp/router/data.ts index 8716c9daa0..059e222e92 100644 --- a/test/integrations/destinations/mp/router/data.ts +++ b/test/integrations/destinations/mp/router/data.ts @@ -442,7 +442,7 @@ export const data = [ endpoint: 'https://api.mixpanel.com/import/', headers: { 'Content-Type': 'application/json', - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic dGVzdF9hcGlfc2VjcmV0Og==', }, params: { strict: 1 }, body: { @@ -509,7 +509,7 @@ export const data = [ endpoint: 'https://api.mixpanel.com/import/', headers: { 'Content-Type': 'application/json', - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic dGVzdF9hcGlfc2VjcmV0Og==', }, params: { strict: 1 }, body: { @@ -577,7 +577,7 @@ export const data = [ endpoint: 'https://api.mixpanel.com/import/', headers: { 'Content-Type': 'application/json', - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic dGVzdF9hcGlfc2VjcmV0Og==', }, params: { strict: 1 }, body: { @@ -1166,7 +1166,7 @@ export const data = [ endpoint: 'https://api.mixpanel.com/import/', headers: { 'Content-Type': 'application/json', - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic dGVzdF9hcGlfc2VjcmV0Og==', }, params: { strict: 1 }, body: { @@ -1232,7 +1232,7 @@ export const data = [ endpoint: 'https://api.mixpanel.com/import/', headers: { 'Content-Type': 'application/json', - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic dGVzdF9hcGlfc2VjcmV0Og==', }, params: { strict: 1 }, body: { @@ -1299,7 +1299,7 @@ export const data = [ endpoint: 'https://api.mixpanel.com/import/', headers: { 'Content-Type': 'application/json', - Authorization: 'Basic dGVzdF9hcGlfdG9rZW46', + Authorization: 'Basic dGVzdF9hcGlfc2VjcmV0Og==', }, params: { strict: 1 }, body: { From 63a5c7333ec019c95e9e801f8beac4dd56885c9e Mon Sep 17 00:00:00 2001 From: Jayachand Date: Thu, 18 Apr 2024 15:55:06 +0530 Subject: [PATCH 11/25] chore: support event validation for old and new tracking plan payload formats (#3255) * chore: support event validation for old and new tracking plan payload formats --- src/util/eventValidation.js | 2 +- src/util/trackingPlan.js | 5 + test/__tests__/eventValidation.test.js | 235 +++++++++++++++++++++++++ 3 files changed, 241 insertions(+), 1 deletion(-) diff --git a/src/util/eventValidation.js b/src/util/eventValidation.js index 68d895dcc5..9f3ecd859d 100644 --- a/src/util/eventValidation.js +++ b/src/util/eventValidation.js @@ -126,7 +126,7 @@ async function validate(event) { trackingPlanId, trackingPlanVersion, event.message.type, - event.message.event, + event.message.type === 'track' ? event.message.event : '', workspaceId, ); diff --git a/src/util/trackingPlan.js b/src/util/trackingPlan.js index a77265a5b8..ebfbc6049f 100644 --- a/src/util/trackingPlan.js +++ b/src/util/trackingPlan.js @@ -55,6 +55,11 @@ async function getEventSchema(tpId, tpVersion, eventType, eventName, workspaceId let eventSchema; const tp = await getTrackingPlan(tpId, tpVersion, workspaceId); + if (Object.hasOwn(tp, 'events')) { + const ev = tp.events.find((e) => e.name === eventName && e.eventType === eventType); + return ev?.rules; + } + if (eventType !== 'track') { if (Object.prototype.hasOwnProperty.call(tp.rules, eventType)) { eventSchema = tp.rules[eventType]; diff --git a/test/__tests__/eventValidation.test.js b/test/__tests__/eventValidation.test.js index eb58879eb7..b802b6f886 100644 --- a/test/__tests__/eventValidation.test.js +++ b/test/__tests__/eventValidation.test.js @@ -73,6 +73,97 @@ const trackingPlan = { create_time: "2021-12-14T19:19:13.666Z", update_time: "2021-12-15T13:29:59.272Z" }; + +const newTrackingPlan = { + name: "Demo Tracking Plan", + version: 1, + events: [ + { + id: "ev_22HzyIUtuhfoI80iDfAgf47GHpw", + name: "Product clicked new", + eventType: "track", + description: "Fired when an product is clicked.", + rules: { + type: "object", + $schema: "http://json-schema.org/draft-07/schema#", + required: ["properties"], + properties: { + properties: { + $schema: "http://json-schema.org/draft-07/schema#", + additionalProperties: false, + properties: { + email: { + type: ["string"] + }, + name: { + type: ["string"] + }, + prop_float: { + type: ["number"] + }, + prop_integer: { + type: ["number"] + }, + revenue: { + type: ["number"] + } + }, + type: "object", + required: [ + "email", + "name", + "prop_float", + "prop_integer", + "revenue" + ], + allOf: [ + { + properties: { + prop_integer: { + const: 2 + }, + prop_float: { + const: 2.3 + } + } + } + ] + } + } + } + }, + { + id: "ev_22HzyIUtuhfoI80iDfAgf47GHpx", + name: "", + eventType: "group", + rules: { + type: "object", + $schema: "http://json-schema.org/draft-07/schema#", + required: ["traits"], + properties: { + traits: { + additionalProperties: false, + properties: { + company: { + type: ["string"] + }, + org: { + type: ["string"] + }, + }, + type: "object", + required: [ + "company", + ] + } + } + } + } + ], + workspaceId: "dummy_workspace_id", + createdAt: "2021-12-14T19:19:13.666Z", + updatedAt: "2021-12-15T13:29:59.272Z" +}; const sourceTpConfig = { track: { allowUnplannedEvents: "true", @@ -1364,6 +1455,134 @@ const eventValidationTestCases = [ } ]; +const eventValidationWithNewPlanTestCases = [ + { + testCase: "Group is part of new Tracking Plan + additional property violation", + event: { + metadata: { + trackingPlanId: "dummy_tracking_plan_id_new", + trackingPlanVersion: "dummy_version_new", + workspaceId: "dummy_workspace_id", + mergedTpConfig, + sourceTpConfig + }, + message: { + type: "group", + userId: "user12345", + groupId: "group1", + traits: { + company: "Company", + employees: 123 + }, + context: { + traits: { + trait1: "new-val" + }, + ip: "14.5.67.21", + library: { + name: "http" + } + }, + timestamp: "2020-01-21T00:21:34.208Z" + } + }, + trackingPlan: newTrackingPlan, + output: { + dropEvent: true, + violationType: violationTypes.AdditionalProperties + } + }, + { + testCase: + "Compatibility for Spread sheet plugin + Track is not part of new Tracking Plan and allowUnplannedEvents is set to text TRUE", + event: { + metadata: { + trackingPlanId: "dummy_tracking_plan_id_new", + trackingPlanVersion: "dummy_version_new", + workspaceId: "dummy_workspace_id", + mergedTpConfig: { + allowUnplannedEvents: "TRUE", + ajvOptions: {} + }, + sourceTpConfig: { + track: { + allowUnplannedEvents: "TRUE", + ajvOptions: {} + }, + global: { + allowUnplannedEvents: "FALSE", + ajvOptions: {} + } + } + }, + message: { + type: "track", + userId: "user-demo", + event: "New Product clicked", + properties: { + name: "Rubik's Cube", + revenue: 4.99, + prop_integer: 2, + prop_float: 2.3, + email: "demo@rudderstack.com" + }, + context: { + ip: "14.5.67.21" + }, + timestamp: "2020-02-02T00:23:09.544Z" + } + }, + trackingPlan: newTrackingPlan, + output: { + dropEvent: false, + violationType: "None" + } + }, + { + testCase: + "Track is part of new Tracking Plan + no track config and unplannedProperties is set to drop", + event: { + metadata: { + trackingPlanId: "dummy_tracking_plan_id_new", + trackingPlanVersion: "dummy_version_new", + workspaceId: "dummy_workspace_id", + mergedTpConfig: { + unplannedProperties: "drop", + ajvOptions: {} + }, + sourceTpConfig: { + global: { + unplannedProperties: "drop", + ajvOptions: {} + } + } + }, + message: { + type: "track", + userId: "user-demo", + event: "Product clicked new", + properties: { + name: "Rubik's Cube", + revenue: 4.99, + prop_integer: 2, + prop_float: 2.3, + email: "demo@rudderstack.com", + mobile: "999888777666" + }, + context: { + ip: "14.5.67.21" + }, + timestamp: "2020-02-02T00:23:09.544Z" + } + }, + trackingPlan: newTrackingPlan, + output: { + dropEvent: true, + violationType: violationTypes.AdditionalProperties + } + }, +]; + describe("Supported Event types testing", () => { eventTypesTestCases.forEach(testCase => { it(`should return isSupportedOrNot ${testCase.output} for this input eventType ${testCase.eventType} everytime`, () => { @@ -1389,6 +1608,22 @@ describe("Handle validation", () => { }); }); +describe("Handle validation with new tracking plan payload", () => { + eventValidationWithNewPlanTestCases.forEach(testCase => { + it(`should return dropEvent: ${testCase.output.dropEvent}, violationType: ${testCase.output.violationType}`, async () => { + fetch.mockResolvedValue({ + json: jest.fn().mockResolvedValue(testCase.trackingPlan), + status: 200 + }); + const { dropEvent, violationType } = await handleValidation( + testCase.event + ); + expect(dropEvent).toEqual(testCase.output.dropEvent); + expect(violationType).toEqual(testCase.output.violationType); + }); + }); +}); + describe("HandleValidationErrors", () => { validationErrorsTestCases.forEach(testCase => { it(`should return dropEvent ${testCase.output} for ${testCase.test}`, () => { From e92b052e03182deb41b20b3ec3741306afa50380 Mon Sep 17 00:00:00 2001 From: AASHISH MALIK Date: Thu, 18 Apr 2024 17:18:27 +0530 Subject: [PATCH 12/25] fix: twitter_ads logger (#3295) --- src/v0/destinations/twitter_ads/transform.js | 3 +- .../destinations/twitter_ads/router/data.ts | 204 ++++++++++++++++++ 2 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 test/integrations/destinations/twitter_ads/router/data.ts diff --git a/src/v0/destinations/twitter_ads/transform.js b/src/v0/destinations/twitter_ads/transform.js index 328d8c4a9f..268dca3636 100644 --- a/src/v0/destinations/twitter_ads/transform.js +++ b/src/v0/destinations/twitter_ads/transform.js @@ -156,8 +156,7 @@ function validateRequest(message) { } } -function process(event, requestMetadata, logger) { - logger.debug(`[TWITTER ADS]: Transforming request received with info`); +function process(event) { const { message, metadata, destination } = event; validateRequest(message); diff --git a/test/integrations/destinations/twitter_ads/router/data.ts b/test/integrations/destinations/twitter_ads/router/data.ts new file mode 100644 index 0000000000..ce9aea6595 --- /dev/null +++ b/test/integrations/destinations/twitter_ads/router/data.ts @@ -0,0 +1,204 @@ +const authHeaderConstant = + 'OAuth oauth_consumer_key="qwe", oauth_nonce="V1kMh028kZLLhfeYozuL0B45Pcx6LvuW", oauth_signature="Di4cuoGv4PnCMMEeqfWTcqhvdwc%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1685603652", oauth_token="dummyAccessToken", oauth_version="1.0"'; + +export const data = [ + { + name: 'twitter_ads', + description: 'tests router flow', + feature: 'router', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + input: [ + { + message: { + type: 'track', + event: 'ABC Searched', + channel: 'web', + context: { + source: 'test', + userAgent: 'chrome', + traits: { + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + email: 'abc@gmail.com', + phone: '+1234589947', + ge: 'male', + db: '19950715', + lastname: 'Rudderlabs', + firstName: 'Test', + address: { + city: 'Kolkata', + state: 'WB', + zip: '700114', + country: 'IN', + }, + }, + device: { + advertisingId: 'abc123', + }, + library: { + name: 'rudder-sdk-ruby-sync', + version: '1.0.6', + }, + }, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: { + conversionTime: '2023-06-01T06:03:08.739Z', + tax: 2, + total: 27.5, + coupon: 'hasbros', + revenue: 48, + price: 25, + quantity: 2, + currency: 'USD', + priceCurrency: 'USD', + conversionId: '213123', + numberItems: '2323', + phone: '+919927455678', + twclid: '543', + shipping: 3, + subtotal: 22.5, + affiliation: 'Google Store', + checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', + email: 'abc@ax.com', + contents: [ + { + price: '123.3345', + quantity: '12', + id: '12', + }, + { + price: 200, + quantity: 11, + id: '4', + }, + ], + }, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { + All: true, + }, + }, + metadata: { + secret: { + consumerKey: 'qwe', + consumerSecret: 'fdghv', + accessToken: 'dummyAccessToken', + accessTokenSecret: 'testAccessTokenSecret', + }, + }, + destination: { + Config: { + pixelId: 'dummyPixelId', + rudderAccountId: '2EOknn1JNH7WK1MfNku4fGYKkRK', + twitterAdsEventNames: [ + { + rudderEventName: 'ABC Searched', + twitterEventId: 'tw-234234324234', + }, + { + rudderEventName: 'Home Page Viewed', + twitterEventId: 'tw-odt2o-odt2q', + }, + ], + }, + }, + }, + ], + destType: 'twitter_ads', + }, + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: [ + { + batched: false, + batchedRequest: { + body: { + FORM: {}, + JSON: { + conversions: [ + { + contents: [ + { content_id: '12', content_price: 123.3345, num_items: 12 }, + { content_id: '4', content_price: 200, num_items: 11 }, + ], + conversion_id: '213123', + conversion_time: '2023-06-01T06:03:08.739Z', + event_id: 'tw-234234324234', + identifiers: [ + { + hashed_email: + '4c3c8a8cba2f3bb1e9e617301f85d1f68e816a01c7b716f482f2ab9adb8181fb', + }, + { + hashed_phone_number: + 'b308962b96b40cce7981493a372db9478edae79f83c2d8ca6cd15a39566f8c56', + }, + { twclid: '543' }, + ], + number_items: 2, + price_currency: 'USD', + value: '25', + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + }, + endpoint: 'https://ads-api.twitter.com/12/measurement/conversions/dummyPixelId', + files: {}, + headers: { + Authorization: + 'OAuth oauth_consumer_key="qwe", oauth_nonce="V1kMh028kZLLhfeYozuL0B45Pcx6LvuW", oauth_signature="Di4cuoGv4PnCMMEeqfWTcqhvdwc%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1685603652", oauth_token="dummyAccessToken", oauth_version="1.0"', + 'Content-Type': 'application/json', + }, + method: 'POST', + params: {}, + type: 'REST', + version: '1', + }, + destination: { + Config: { + pixelId: 'dummyPixelId', + rudderAccountId: '2EOknn1JNH7WK1MfNku4fGYKkRK', + twitterAdsEventNames: [ + { rudderEventName: 'ABC Searched', twitterEventId: 'tw-234234324234' }, + { rudderEventName: 'Home Page Viewed', twitterEventId: 'tw-odt2o-odt2q' }, + ], + }, + }, + metadata: [ + { + secret: { + accessToken: 'dummyAccessToken', + accessTokenSecret: 'testAccessTokenSecret', + consumerKey: 'qwe', + consumerSecret: 'fdghv', + }, + }, + ], + statusCode: 200, + }, + ], + }, + }, + }, + }, +].map((tc) => ({ + ...tc, + mockFns: (_) => { + jest.mock('../../../../../src/v0/destinations/twitter_ads/util', () => ({ + getAuthHeaderForRequest: (_a, _b) => { + return { Authorization: authHeaderConstant }; + }, + })); + }, +})); From 68c64db23231252e17aa5a78b716989a7a2d7099 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 18 Apr 2024 11:51:18 +0000 Subject: [PATCH 13/25] chore(release): 1.62.2 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aeb88f374..87ca4738ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.62.2](https://github.com/rudderlabs/rudder-transformer/compare/v1.62.1...v1.62.2) (2024-04-18) + + +### Bug Fixes + +* twitter_ads logger ([#3295](https://github.com/rudderlabs/rudder-transformer/issues/3295)) ([e92b052](https://github.com/rudderlabs/rudder-transformer/commit/e92b052e03182deb41b20b3ec3741306afa50380)) + ### [1.62.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.62.0...v1.62.1) (2024-04-18) diff --git a/package-lock.json b/package-lock.json index b524ed27ff..b5b413f936 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.62.1", + "version": "1.62.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.62.1", + "version": "1.62.2", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "0.7.24", diff --git a/package.json b/package.json index 57da0144ac..a291bbab90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.62.1", + "version": "1.62.2", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": { From 4bf65be47678b7d058d6389b175b836e8692b698 Mon Sep 17 00:00:00 2001 From: Sandeep Digumarty Date: Fri, 19 Apr 2024 10:52:16 +0530 Subject: [PATCH 14/25] chore: upgrade node version to v18.20.1 from v18.19.1 (#3287) --- .nvmrc | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.nvmrc b/.nvmrc index 3c5535cf60..99c98cdd6a 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -18.19.1 +18.20.1 diff --git a/Dockerfile b/Dockerfile index 8cd4005a7b..9fe3c1cdb2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1.4 -FROM node:18.19.1-alpine3.18 AS base +FROM node:18.20.1-alpine3.18 AS base ENV HUSKY 0 RUN apk update From 5402b219ccdeaafb710c8c2828e983e9864a415f Mon Sep 17 00:00:00 2001 From: Gauravudia Date: Mon, 22 Apr 2024 12:17:47 +0530 Subject: [PATCH 15/25] fix: handle empty userId --- .../destinations/bloomreach/procWorkflow.yaml | 6 +- .../movable_ink/procWorkflow.yaml | 4 +- .../destinations/bloomreach/processor/page.ts | 59 +++++++++++++- .../bloomreach/processor/validation.ts | 78 ++++++++++++++++++- .../movable_ink/processor/identify.ts | 1 + 5 files changed, 140 insertions(+), 8 deletions(-) diff --git a/src/cdk/v2/destinations/bloomreach/procWorkflow.yaml b/src/cdk/v2/destinations/bloomreach/procWorkflow.yaml index f092d90382..5a9dcaa18d 100644 --- a/src/cdk/v2/destinations/bloomreach/procWorkflow.yaml +++ b/src/cdk/v2/destinations/bloomreach/procWorkflow.yaml @@ -39,7 +39,7 @@ steps: const userId = .message.().( {{{{$.getGenericPaths("userIdOnly")}}}}; ); - $.assert(userId ?? .message.anonymousId, "Either one of userId or anonymousId is required. Aborting"); + $.assert(userId || .message.anonymousId, "Either one of userId or anonymousId is required. Aborting"); - name: prepareIdentifyPayload condition: $.context.messageType === {{$.EventType.IDENTIFY}} @@ -64,7 +64,7 @@ steps: - name: pageEventName condition: $.context.messageType === {{$.EventType.PAGE}} template: | - const category = .message.category ?? .message.properties.category; + const category = .message.category || .message.properties.category; const name = .message.name || .message.properties.name; const eventNameArray = ["Viewed"]; category ? eventNameArray.push(category); @@ -74,7 +74,7 @@ steps: - name: screenEventName condition: $.context.messageType === {{$.EventType.SCREEN}} template: | - const category = .message.category ?? .message.properties.category; + const category = .message.category || .message.properties.category; const name = .message.name || .message.properties.name; const eventNameArray = ["Viewed"]; category ? eventNameArray.push(category); diff --git a/src/cdk/v2/destinations/movable_ink/procWorkflow.yaml b/src/cdk/v2/destinations/movable_ink/procWorkflow.yaml index 394190049b..fef11124b3 100644 --- a/src/cdk/v2/destinations/movable_ink/procWorkflow.yaml +++ b/src/cdk/v2/destinations/movable_ink/procWorkflow.yaml @@ -33,7 +33,7 @@ steps: {{{{$.getGenericPaths("email")}}}}; ); - $.assert(userId ?? email ?? .message.anonymousId, "Either one of userId or email or anonymousId is required. Aborting"); + $.assert(userId || email || .message.anonymousId, "Either one of userId or email or anonymousId is required. Aborting"); $.validateEventPayload(.message); - name: preparePayload @@ -50,7 +50,7 @@ steps: )); $.context.payload = { ...(.message), - userId: userId ?? email, + userId: userId || email, timestamp: timestampInUnix, anonymousId: .message.anonymousId } diff --git a/test/integrations/destinations/bloomreach/processor/page.ts b/test/integrations/destinations/bloomreach/processor/page.ts index 0c2d27989d..3081feeb26 100644 --- a/test/integrations/destinations/bloomreach/processor/page.ts +++ b/test/integrations/destinations/bloomreach/processor/page.ts @@ -15,7 +15,7 @@ export const page: ProcessorTestData[] = [ { id: 'bloomreach-page-test-1', name: destType, - description: 'Page call with category, name', + description: 'Page call with category from properties and root-level name', scenario: 'Framework+Business', successCriteria: 'Response should contain event_name = "Viewed {{ category }} {{ name }} Page" and properties and status code should be 200', @@ -69,4 +69,61 @@ export const page: ProcessorTestData[] = [ }, }, }, + { + id: 'bloomreach-page-test-2', + name: destType, + description: 'Page call with category, name from properties', + scenario: 'Framework+Business', + successCriteria: + 'Response should contain event_name = "Viewed {{ category }} {{ name }} Page" and properties and status code should be 200', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + type: 'page', + anonymousId: 'anonId123', + name: '', + properties: { ...properties, name: 'Integration' }, + integrations: { + All: true, + }, + originalTimestamp: '2024-03-04T15:32:56.409Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + method: 'POST', + userId: '', + endpoint, + headers, + JSON: { + data: { + customer_ids: { cookie: 'anonId123' }, + properties: { ...properties, name: 'Integration' }, + timestamp: 1709566376, + event_type: 'Viewed Docs Integration Page', + }, + name: 'customers/events', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, ]; diff --git a/test/integrations/destinations/bloomreach/processor/validation.ts b/test/integrations/destinations/bloomreach/processor/validation.ts index ff959d74c6..1a6199abb0 100644 --- a/test/integrations/destinations/bloomreach/processor/validation.ts +++ b/test/integrations/destinations/bloomreach/processor/validation.ts @@ -1,6 +1,13 @@ import { ProcessorTestData } from '../../../testTypes'; -import { generateMetadata } from '../../../testUtils'; -import { destType, destination, processorInstrumentationErrorStatTags } from '../common'; +import { generateMetadata, transformResultBuilder } from '../../../testUtils'; +import { + destType, + destination, + processorInstrumentationErrorStatTags, + traits, + headers, + endpoint, +} from '../common'; export const validation: ProcessorTestData[] = [ { @@ -128,4 +135,71 @@ export const validation: ProcessorTestData[] = [ }, }, }, + { + id: 'bloomreach-validation-test-4', + name: destType, + description: 'Empty userId and non empty anonymousId', + scenario: 'Framework', + successCriteria: 'Response should contain all the mapping and status code should be 200', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + type: 'identify', + userId: '', + anonymousId: 'anonId123', + traits, + integrations: { + All: true, + }, + originalTimestamp: '2024-03-04T15:32:56.409Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + method: 'POST', + userId: '', + endpoint, + headers, + JSON: { + data: { + customer_ids: { registered: '', cookie: 'anonId123' }, + properties: { + email: 'test@example.com', + first_name: 'John', + last_name: 'Doe', + phone: '1234567890', + city: 'New York', + country: 'USA', + address: { + city: 'New York', + country: 'USA', + pinCode: '123456', + }, + }, + update_timestamp: 1709566376, + }, + name: 'customers', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, ]; diff --git a/test/integrations/destinations/movable_ink/processor/identify.ts b/test/integrations/destinations/movable_ink/processor/identify.ts index e5bbf5a9a7..0fe806df4a 100644 --- a/test/integrations/destinations/movable_ink/processor/identify.ts +++ b/test/integrations/destinations/movable_ink/processor/identify.ts @@ -20,6 +20,7 @@ export const identify: ProcessorTestData[] = [ destination, message: { type: 'identify', + userId: '', anonymousId: 'anonId123', traits, integrations: { From bac3cc5670c149454a6063a55a4b901043b0ff02 Mon Sep 17 00:00:00 2001 From: Mihir Bhalala <77438541+mihir-4116@users.noreply.github.com> Date: Mon, 22 Apr 2024 16:40:16 +0530 Subject: [PATCH 16/25] fix(delighted): replace myAxios utility with handleHttpRequest utility (#3237) --- src/v0/destinations/delighted/util.js | 107 +++++++++--------- .../destinations/delighted/network.ts | 14 +++ .../destinations/delighted/processor/data.ts | 89 +++++++++++++++ 3 files changed, 159 insertions(+), 51 deletions(-) diff --git a/src/v0/destinations/delighted/util.js b/src/v0/destinations/delighted/util.js index c690bf5f5c..53f416b48d 100644 --- a/src/v0/destinations/delighted/util.js +++ b/src/v0/destinations/delighted/util.js @@ -1,14 +1,10 @@ -const { - NetworkInstrumentationError, - InstrumentationError, - NetworkError, -} = require('@rudderstack/integrations-lib'); -const myAxios = require('../../../util/myAxios'); +const { InstrumentationError, NetworkError } = require('@rudderstack/integrations-lib'); const { getDynamicErrorType } = require('../../../adapters/utils/networkUtils'); const { getValueFromMessage } = require('../../util'); const { ENDPOINT } = require('./config'); const tags = require('../../util/tags'); const { JSON_MIME_TYPE } = require('../../util/constant'); +const { handleHttpRequest } = require('../../../adapters/network'); const isValidEmail = (email) => { const re = @@ -41,6 +37,30 @@ const isValidUserIdOrError = (channel, userId) => { }; }; +/** + * Returns final status + * @param {*} status + * @returns + */ +const getErrorStatus = (status) => { + let errStatus; + switch (status) { + case 422: + case 401: + case 406: + case 403: + errStatus = 400; + break; + case 500: + case 503: + errStatus = 500; + break; + default: + errStatus = status; + } + return errStatus; +}; + const userValidity = async (channel, Config, userId) => { const paramsdata = {}; if (channel === 'email') { @@ -50,53 +70,38 @@ const userValidity = async (channel, Config, userId) => { } const basicAuth = Buffer.from(Config.apiKey).toString('base64'); - let response; - try { - response = await myAxios.get( - `${ENDPOINT}`, - { - headers: { - Authorization: `Basic ${basicAuth}`, - 'Content-Type': JSON_MIME_TYPE, - }, - params: paramsdata, + const { processedResponse } = await handleHttpRequest( + 'get', + `${ENDPOINT}`, + { + headers: { + Authorization: `Basic ${basicAuth}`, + 'Content-Type': JSON_MIME_TYPE, }, - { - destType: 'delighted', - feature: 'transformation', - requestMethod: 'GET', - endpointPath: '/people.json', - module: 'router', - }, - ); - if (response && response.data && response.status === 200 && Array.isArray(response.data)) { - return response.data.length > 0; - } - throw new NetworkInstrumentationError('Invalid response'); - } catch (error) { - let errMsg = ''; - let errStatus = 400; - if (error.response && error.response.data) { - errMsg = JSON.stringify(error.response.data); - switch (error.response.status) { - case 422: - case 401: - case 406: - case 403: - errStatus = 400; - break; - case 500: - case 503: - errStatus = 500; - break; - default: - errStatus = 400; - } - } - throw new NetworkError(`Error occurred while checking user : ${errMsg}`, errStatus, { - [tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(errStatus), - }); + params: paramsdata, + }, + { + destType: 'delighted', + feature: 'transformation', + requestMethod: 'GET', + endpointPath: '/people.json', + module: 'router', + }, + ); + + if (processedResponse.status === 200 && Array.isArray(processedResponse?.response)) { + return processedResponse.response.length > 0; } + + const errStatus = getErrorStatus(processedResponse.status); + throw new NetworkError( + `Error occurred while checking user: ${JSON.stringify(processedResponse?.response || 'Invalid response')}`, + errStatus, + { + [tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(errStatus), + }, + processedResponse, + ); }; const eventValidity = (Config, message) => { const event = getValueFromMessage(message, 'event'); diff --git a/test/integrations/destinations/delighted/network.ts b/test/integrations/destinations/delighted/network.ts index d9896a25e8..1ccc785ea3 100644 --- a/test/integrations/destinations/delighted/network.ts +++ b/test/integrations/destinations/delighted/network.ts @@ -27,4 +27,18 @@ export const networkCallsData = [ status: 200, }, }, + { + httpReq: { + url: 'https://api.delighted.com/v1/people.json', + method: 'GET', + headers: { Authorization: `Basic ZHVtbXlBcGlLZXlmb3JmYWlsdXJl` }, + params: { + email: 'test@rudderlabs.com', + }, + }, + httpRes: { + status: 429, + data: {}, + }, + }, ]; diff --git a/test/integrations/destinations/delighted/processor/data.ts b/test/integrations/destinations/delighted/processor/data.ts index 7a5ad7de9d..f35c2d8ecb 100644 --- a/test/integrations/destinations/delighted/processor/data.ts +++ b/test/integrations/destinations/delighted/processor/data.ts @@ -944,4 +944,93 @@ export const data = [ }, }, }, + { + name: 'delighted', + description: 'Too many request test', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'dummyApiKeyforfailure', + channel: 'email', + delay: 0, + eventNamesSettings: [ + { + event: 'Product Reviewed', + }, + ], + }, + }, + message: { + channel: 'web', + context: { + app: { + build: '1.0.0', + name: 'RudderLabs JavaScript SDK', + namespace: 'com.rudderlabs.javascript', + version: '1.0.0', + }, + 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', + ip: '0.0.0.0', + os: { + name: '', + version: '', + }, + screen: { + density: 2, + }, + }, + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + type: 'track', + userId: 'test@rudderlabs.com', + event: 'Product Reviewed', + properties: { + review_id: '12345', + product_id: '123', + rating: 3, + review_body: 'Average product, expected much more.', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + '{"message":"Error occurred while checking user: {}","destinationResponse":{"response":{},"status":429}}', + statTags: { + destType: 'DELIGHTED', + errorCategory: 'network', + errorType: 'throttled', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + statusCode: 429, + }, + ], + }, + }, + }, ]; From 650ea9ca9ca6351aadc51bfb5038b8b2507990ec Mon Sep 17 00:00:00 2001 From: Mihir Bhalala <77438541+mihir-4116@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:11:30 +0530 Subject: [PATCH 17/25] feat(iterable): component test refactor (#3250) --- .../iterable/processor/aliasTestData.ts | 97 + .../destinations/iterable/processor/data.ts | 3793 +---------------- .../iterable/processor/identifyTestData.ts | 407 ++ .../iterable/processor/pageScreenTestData.ts | 409 ++ .../iterable/processor/trackTestData.ts | 717 ++++ .../iterable/processor/validationTestData.ts | 258 ++ test/integrations/testUtils.ts | 1 + 7 files changed, 1900 insertions(+), 3782 deletions(-) create mode 100644 test/integrations/destinations/iterable/processor/aliasTestData.ts create mode 100644 test/integrations/destinations/iterable/processor/identifyTestData.ts create mode 100644 test/integrations/destinations/iterable/processor/pageScreenTestData.ts create mode 100644 test/integrations/destinations/iterable/processor/trackTestData.ts create mode 100644 test/integrations/destinations/iterable/processor/validationTestData.ts diff --git a/test/integrations/destinations/iterable/processor/aliasTestData.ts b/test/integrations/destinations/iterable/processor/aliasTestData.ts new file mode 100644 index 0000000000..cac43767bb --- /dev/null +++ b/test/integrations/destinations/iterable/processor/aliasTestData.ts @@ -0,0 +1,97 @@ +import { generateMetadata, transformResultBuilder } from './../../../testUtils'; +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; + +const destination: Destination = { + ID: '123', + Name: 'iterable', + DestinationDefinition: { + ID: '123', + Name: 'iterable', + DisplayName: 'Iterable', + Config: {}, + }, + WorkspaceID: '123', + Transformations: [], + Config: { + apiKey: 'testApiKey', + preferUserId: false, + trackAllPages: true, + trackNamedPages: false, + mapToSingleEvent: false, + trackCategorisedPages: false, + }, + Enabled: true, +}; + +const headers = { + api_key: 'testApiKey', + 'Content-Type': 'application/json', +}; + +const properties = { + path: '/abc', + referrer: '', + search: '', + title: '', + url: '', + category: 'test-category', +}; + +const sentAt = '2020-08-28T16:26:16.473Z'; +const originalTimestamp = '2020-08-28T16:26:06.468Z'; + +export const aliasTestData: ProcessorTestData[] = [ + { + id: 'iterable-alias-test-1', + name: 'iterable', + description: 'Alias call with userId and previousId', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain update email payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + anonymousId: 'anonId', + userId: 'new@email.com', + previousId: 'old@email.com', + name: 'ApplicationLoaded', + context: {}, + properties, + type: 'alias', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: 'https://api.iterable.com/api/users/updateEmail', + JSON: { + currentEmail: 'old@email.com', + newEmail: 'new@email.com', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/iterable/processor/data.ts b/test/integrations/destinations/iterable/processor/data.ts index 19b370b513..12e5738641 100644 --- a/test/integrations/destinations/iterable/processor/data.ts +++ b/test/integrations/destinations/iterable/processor/data.ts @@ -1,3784 +1,13 @@ +import { identifyTestData } from './identifyTestData'; +import { trackTestData } from './trackTestData'; +import { pageScreenTestData } from './pageScreenTestData'; +import { aliasTestData } from './aliasTestData'; +import { validationTestData } from './validationTestData'; + export const data = [ - { - name: 'iterable', - description: 'Test 0', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'page', - sentAt: '2020-08-28T16:26:16.473Z', - context: { - library: { - name: 'analytics-node', - version: '0.0.3', - }, - }, - _metadata: { - nodeVersion: '10.22.0', - }, - messageId: - 'node-6f62b91e789a636929ca38aed01c5f6e-103c720d-81bd-4742-98d6-d45a65aed23e', - properties: { - url: 'https://dominos.com', - title: 'Pizza', - referrer: 'https://google.com', - }, - anonymousId: 'abcdeeeeeeeexxxx102', - originalTimestamp: '2020-08-28T16:26:06.468Z', - }, - destination: { - Config: { - apiKey: '62d12498c37c4fd8a1a546c2d35c2f60', - mapToSingleEvent: false, - trackAllPages: false, - trackCategorisedPages: true, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'Invalid page call', - statTags: { - destType: 'ITERABLE', - errorCategory: 'dataValidation', - errorType: 'configuration', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 1', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'identify', - sentAt: '2020-08-28T16:26:06.466Z', - traits: { - city: 'Bangalore', - name: 'manashi', - email: 'manashi@website.com', - country: 'India', - }, - context: { - traits: { - city: 'Bangalore', - name: 'manashi', - email: 'manashi@website.com', - country: 'India', - preferUserId: false, - }, - library: { - name: 'analytics-node', - version: '0.0.3', - }, - }, - _metadata: { - nodeVersion: '10.22.0', - }, - messageId: - 'node-cc3ef811f686139ee527b806ee0129ef-163a3a88-266f-447e-8cce-34a8f42f8dcd', - anonymousId: 'abcdeeeeeeeexxxx102', - originalTimestamp: '2020-08-28T16:26:06.462Z', - }, - destination: { - Config: { - preferUserId: false, - apiKey: '62d12498c37c4fd8a1a546c2d35c2f60', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - JSON: { - email: 'manashi@website.com', - userId: 'abcdeeeeeeeexxxx102', - dataFields: { - city: 'Bangalore', - name: 'manashi', - email: 'manashi@website.com', - country: 'India', - }, - preferUserId: false, - mergeNestedObjects: true, - }, - }, - type: 'REST', - files: {}, - method: 'POST', - params: {}, - headers: { - api_key: '62d12498c37c4fd8a1a546c2d35c2f60', - 'Content-Type': 'application/json', - }, - version: '1', - endpoint: 'https://api.iterable.com/api/users/update', - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 2', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'track', - event: 'Email Opened', - sentAt: '2020-08-28T16:26:16.473Z', - context: { - library: { - name: 'analytics-node', - version: '0.0.3', - }, - }, - _metadata: { - nodeVersion: '10.22.0', - }, - messageId: - 'node-570110489d3e99b234b18af9a9eca9d4-6009779e-82d7-469d-aaeb-5ccf162b0453', - properties: { - subject: 'resume validate', - sendtime: '2020-01-01', - sendlocation: 'akashdeep@gmail.com', - }, - anonymousId: 'abcdeeeeeeeexxxx102', - originalTimestamp: '2020-08-28T16:26:06.468Z', - }, - destination: { - Config: { - apiKey: '62d12498c37c4fd8a1a546c2d35c2f60', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - JSON: { - userId: 'abcdeeeeeeeexxxx102', - createdAt: 1598631966468, - eventName: 'Email Opened', - dataFields: { - subject: 'resume validate', - sendtime: '2020-01-01', - sendlocation: 'akashdeep@gmail.com', - }, - }, - }, - type: 'REST', - files: {}, - method: 'POST', - params: {}, - headers: { - api_key: '62d12498c37c4fd8a1a546c2d35c2f60', - 'Content-Type': 'application/json', - }, - version: '1', - endpoint: 'https://api.iterable.com/api/events/track', - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 3', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - type: 'page', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - category: 'test-category', - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: false, - trackCategorisedPages: true, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/events/track', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'sayan@gmail.com', - dataFields: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - category: 'test-category', - }, - userId: '12345', - eventName: 'ApplicationLoaded page', - createdAt: 1571051718299, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - type: 'page', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - category: 'test-category', - campaignId: '123456', - templateId: '1213458', - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: true, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/events/track', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'sayan@gmail.com', - dataFields: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - category: 'test-category', - campaignId: '123456', - templateId: '1213458', - }, - userId: '12345', - eventName: 'Loaded a Page', - createdAt: 1571051718299, - campaignId: 123456, - templateId: 1213458, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 5', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - type: 'page', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - name: 'test-name', - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: false, - trackCategorisedPages: false, - trackNamedPages: true, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/events/track', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'sayan@gmail.com', - dataFields: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - name: 'test-name', - }, - userId: '12345', - eventName: 'ApplicationLoaded page', - createdAt: 1571051718299, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 6', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - type: 'page', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/events/track', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'sayan@gmail.com', - dataFields: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - }, - userId: '12345', - eventName: 'ApplicationLoaded page', - createdAt: 1571051718299, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 7', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - type: 'screen', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - category: 'test-category', - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: false, - trackCategorisedPages: true, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/events/track', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'sayan@gmail.com', - dataFields: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - category: 'test-category', - }, - userId: '12345', - eventName: 'ApplicationLoaded screen', - createdAt: 1571051718299, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 8', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - type: 'screen', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - category: 'test-category', - campaignId: '123456', - templateId: '1213458', - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: true, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/events/track', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'sayan@gmail.com', - dataFields: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - category: 'test-category', - campaignId: '123456', - templateId: '1213458', - }, - userId: '12345', - eventName: 'Loaded a Screen', - createdAt: 1571051718299, - campaignId: 123456, - templateId: 1213458, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 9', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - type: 'screen', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - name: 'test-name', - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: false, - trackCategorisedPages: false, - trackNamedPages: true, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/events/track', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'sayan@gmail.com', - dataFields: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - name: 'test-name', - }, - userId: '12345', - eventName: 'ApplicationLoaded screen', - createdAt: 1571051718299, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 10', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - type: 'screen', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/events/track', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'sayan@gmail.com', - dataFields: { - path: '/abc', - referrer: '', - search: '', - title: '', - url: '', - }, - userId: '12345', - eventName: 'ApplicationLoaded screen', - createdAt: 1571051718299, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 11', - 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: 'ruchira@rudderlabs.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', - ip: '0.0.0.0', - os: { - id: '72e528f869711c3d', - manufacturer: 'Google', - model: 'sdk_gphone_x86', - name: 'generic_x86_arm', - token: 'some_device_token', - type: 'android', - }, - screen: { - density: 2, - }, - }, - type: 'group', - messageId: '84e26acc-56a5-4835-8233-591137fca468', - originalTimestamp: '2019-10-14T09:03:17.562Z', - anonymousId: '00000000000000000000000000', - userId: '123456', - integrations: { - All: true, - }, - sentAt: '2019-10-14T09:03:22.563Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'Message type group not supported', - statTags: { - destType: 'ITERABLE', - errorCategory: 'dataValidation', - errorType: 'instrumentation', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 12', - 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: 'ruchira@rudderlabs.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', - ip: '0.0.0.0', - os: { - id: '72e528f869711c3d', - manufacturer: 'Google', - model: 'sdk_gphone_x86', - name: 'generic_x86_arm', - token: 'some_device_token', - type: 'android', - }, - screen: { - density: 2, - }, - }, - type: 'identify', - messageId: '84e26acc-56a5-4835-8233-591137fca468', - originalTimestamp: '2019-10-14T09:03:17.562Z', - anonymousId: '00000000000000000000000000', - userId: '123456', - integrations: { - All: true, - }, - sentAt: '2019-10-14T09:03:22.563Z', - }, - destination: { - Config: { - mergeNestedObjects: false, - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/users/update', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'ruchira@rudderlabs.com', - dataFields: { - email: 'ruchira@rudderlabs.com', - }, - userId: '123456', - preferUserId: true, - mergeNestedObjects: false, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 13', - 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', - }, - device: { - token: 'sample_push_token', - name: 'sample_device_name', - model: 'sample_device_model', - manufacturer: 'sample_device_manufacturer', - type: 'ios', - }, - traits: { - email: 'ruchira@rudderlabs.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', - ip: '0.0.0.0', - os: { - id: '72e528f869711c3d', - manufacturer: 'Google', - model: 'sdk_gphone_x86', - name: 'generic_x86_arm', - token: 'some_device_token', - type: 'android', - }, - screen: { - density: 2, - }, - }, - type: 'identify', - messageId: '84e26acc-56a5-4835-8233-591137fca468', - originalTimestamp: '2019-10-14T09:03:17.562Z', - anonymousId: '00000000000000000000000000', - userId: '123456', - integrations: { - All: true, - }, - sentAt: '2019-10-14T09:03:22.563Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/users/update', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'ruchira@rudderlabs.com', - dataFields: { - email: 'ruchira@rudderlabs.com', - }, - userId: '123456', - preferUserId: true, - mergeNestedObjects: true, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 14', - 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', - }, - device: { - token: 'sample_push_token', - name: 'sample_device_name', - model: 'sample_device_model', - manufacturer: 'sample_device_manufacturer', - type: 'android', - }, - traits: { - email: 'ruchira@rudderlabs.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', - ip: '0.0.0.0', - os: { - id: '72e528f869711c3d', - manufacturer: 'Google', - model: 'sdk_gphone_x86', - name: 'generic_x86_arm', - token: 'some_device_token', - type: 'android', - }, - screen: { - density: 2, - }, - }, - type: 'identify', - messageId: '84e26acc-56a5-4835-8233-591137fca468', - originalTimestamp: '2019-10-14T09:03:17.562Z', - anonymousId: '00000000000000000000000000', - userId: '123456', - integrations: { - All: true, - }, - sentAt: '2019-10-14T09:03:22.563Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/users/update', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'ruchira@rudderlabs.com', - dataFields: { - email: 'ruchira@rudderlabs.com', - }, - userId: '123456', - preferUserId: true, - mergeNestedObjects: true, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 15', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - event: 'product added', - type: 'track', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - campaignId: '1', - templateId: '0', - orderId: 10000, - total: 1000, - products: [ - { - product_id: '507f1f77bcf86cd799439011', - sku: '45790-32', - name: 'Monopoly: 3rd Edition', - price: '19', - position: '1', - category: 'cars', - url: 'https://www.example.com/product/path', - image_url: 'https://www.example.com/product/path.jpg', - quantity: '2', - }, - { - product_id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - price: '192', - quantity: 22, - position: '12', - category: 'Cars2', - url: 'https://www.example.com/product/path2', - image_url: 'https://www.example.com/product/path.jpg2', - }, - ], - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/commerce/updateCart', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - user: { - email: 'sayan@gmail.com', - dataFields: { - email: 'sayan@gmail.com', - }, - userId: '12345', - preferUserId: true, - mergeNestedObjects: true, - }, - items: [ - { - id: '507f1f77bcf86cd799439011', - sku: '45790-32', - name: 'Monopoly: 3rd Edition', - categories: ['cars'], - price: 19, - quantity: 2, - imageUrl: 'https://www.example.com/product/path.jpg', - url: 'https://www.example.com/product/path', - }, - { - id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - categories: ['Cars2'], - price: 192, - quantity: 22, - imageUrl: 'https://www.example.com/product/path.jpg2', - url: 'https://www.example.com/product/path2', - }, - ], - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 16', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - event: 'order completed', - type: 'track', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - orderId: 10000, - total: '1000', - campaignId: '123456', - templateId: '1213458', - products: [ - { - product_id: '507f1f77bcf86cd799439011', - sku: '45790-32', - name: 'Monopoly: 3rd Edition', - price: '19', - position: '1', - category: 'Cars', - url: 'https://www.example.com/product/path', - image_url: 'https://www.example.com/product/path.jpg', - quantity: 2, - }, - { - product_id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - price: '192', - quantity: '22', - position: '12', - category: 'Cars2', - url: 'https://www.example.com/product/path2', - image_url: 'https://www.example.com/product/path.jpg2', - }, - ], - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/commerce/trackPurchase', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - dataFields: { - orderId: 10000, - total: '1000', - campaignId: '123456', - templateId: '1213458', - products: [ - { - product_id: '507f1f77bcf86cd799439011', - sku: '45790-32', - name: 'Monopoly: 3rd Edition', - price: '19', - position: '1', - category: 'Cars', - url: 'https://www.example.com/product/path', - image_url: 'https://www.example.com/product/path.jpg', - quantity: 2, - }, - { - product_id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - price: '192', - quantity: '22', - position: '12', - category: 'Cars2', - url: 'https://www.example.com/product/path2', - image_url: 'https://www.example.com/product/path.jpg2', - }, - ], - }, - id: '10000', - createdAt: 1571051718299, - campaignId: 123456, - templateId: 1213458, - total: 1000, - user: { - email: 'sayan@gmail.com', - dataFields: { - email: 'sayan@gmail.com', - }, - userId: '12345', - preferUserId: true, - mergeNestedObjects: true, - }, - items: [ - { - id: '507f1f77bcf86cd799439011', - sku: '45790-32', - name: 'Monopoly: 3rd Edition', - categories: ['Cars'], - price: 19, - quantity: 2, - imageUrl: 'https://www.example.com/product/path.jpg', - url: 'https://www.example.com/product/path', - }, - { - id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - categories: ['Cars2'], - price: 192, - quantity: 22, - imageUrl: 'https://www.example.com/product/path.jpg2', - url: 'https://www.example.com/product/path2', - }, - ], - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 17', - 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: 'sayan@gmail.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: '', - version: '', - }, - screen: { - density: 2, - }, - }, - type: 'track', - messageId: 'ec5481b6-a926-4d2e-b293-0b3a77c4d3be', - originalTimestamp: '2019-10-14T11:15:18.300Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - event: 'test track event GA3', - properties: { - email: 'ruchira@rudderlabs.com', - campaignId: '1', - templateId: '0', - category: 'test-category', - user_actual_role: 'system_admin, system_user', - user_actual_id: 12345, - }, - integrations: { - All: true, - }, - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/events/track', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'ruchira@rudderlabs.com', - dataFields: { - campaignId: '1', - templateId: '0', - category: 'test-category', - user_actual_role: 'system_admin, system_user', - user_actual_id: 12345, - email: 'ruchira@rudderlabs.com', - }, - userId: '12345', - eventName: 'test track event GA3', - createdAt: 1571051718300, - campaignId: 1, - templateId: 0, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 18', - 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', - }, - 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', - ip: '0.0.0.0', - os: { - id: '72e528f869711c3d', - manufacturer: 'Google', - model: 'sdk_gphone_x86', - name: 'generic_x86_arm', - token: 'some_device_token', - type: 'android', - }, - screen: { - density: 2, - }, - }, - traits: { - email: 'ruchira@rudderlabs.com', - }, - type: 'identify', - messageId: '84e26acc-56a5-4835-8233-591137fca468', - originalTimestamp: '2019-10-14T09:03:17.562Z', - anonymousId: '00000000000000000000000000', - userId: '123456', - integrations: { - All: true, - }, - sentAt: '2019-10-14T09:03:22.563Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/users/update', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'ruchira@rudderlabs.com', - dataFields: { - email: 'ruchira@rudderlabs.com', - }, - userId: '123456', - preferUserId: true, - mergeNestedObjects: true, - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 19', - 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', - }, - 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', - ip: '0.0.0.0', - os: { - id: '72e528f869711c3d', - manufacturer: 'Google', - model: 'sdk_gphone_x86', - name: 'generic_x86_arm', - token: 'some_device_token', - type: 'android', - }, - screen: { - density: 2, - }, - }, - type: 'identify', - messageId: '84e26acc-56a5-4835-8233-591137fca468', - originalTimestamp: '2019-10-14T09:03:17.562Z', - integrations: { - All: true, - }, - sentAt: '2019-10-14T09:03:22.563Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'userId or email is mandatory for this request', - statTags: { - destType: 'ITERABLE', - errorCategory: 'dataValidation', - errorType: 'instrumentation', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 20', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'page', - sentAt: '2020-08-28T16:26:16.473Z', - _metadata: { - nodeVersion: '10.22.0', - }, - messageId: - 'node-6f62b91e789a636929ca38aed01c5f6e-103c720d-81bd-4742-98d6-d45a65aed23e', - properties: { - url: 'https://dominos.com', - title: 'Pizza', - referrer: 'https://google.com', - }, - anonymousId: 'abcdeeeeeeeexxxx102', - originalTimestamp: '2020-08-28T16:26:06.468Z', - }, - destination: { - Config: { - apiKey: '62d12498c37c4fd8a1a546c2d35c2f60', - mapToSingleEvent: false, - trackAllPages: false, - trackCategorisedPages: true, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'Invalid page call', - statTags: { - destType: 'ITERABLE', - errorCategory: 'dataValidation', - errorType: 'configuration', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 21', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'track', - event: 'Product Added', - sentAt: '2021-07-09T05:27:17.908Z', - userId: '8751', - channel: 'web', - context: { - os: { - name: '', - version: '', - }, - app: { - name: 'RudderLabs JavaScript SDK', - build: '1.0.0', - version: '1.0.16', - namespace: 'com.rudderlabs.javascript', - }, - page: { - url: 'https://joybird.com/cabinets/vira-console-cabinet/', - path: '/cabinets/vira-console-cabinet/', - title: 'Vira Console Cabinet | Joybird', - search: '', - referrer: '$direct', - referring_domain: '', - }, - locale: 'en-us', - screen: { - density: 2, - }, - traits: { - email: 'jessica@jlpdesign.net', - }, - library: { - name: 'RudderLabs JavaScript SDK', - version: '1.0.16', - }, - campaign: {}, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15', - }, - rudderId: '1c42e104-97ec-4f54-a328-2379623583fe', - messageId: 'e58f6624-a1c3-48f4-a6af-610389602304', - timestamp: '2021-07-09T05:27:18.131Z', - properties: { - sku: 'JB24691400-W05', - name: 'Vira Console Cabinet', - price: 797, - cart_id: 'bd9b8dbf4ef8ee01d4206b04fe2ee6ae', - variant: 'Oak', - quantity: 1, - quickship: true, - full_price: 1328, - product_id: 10606, - non_interaction: 1, - }, - receivedAt: '2021-07-09T05:27:18.131Z', - request_ip: '162.224.233.114', - anonymousId: '8a7ff986-62d8-45ca-9a16-8895b3f9d341', - integrations: { - All: true, - }, - originalTimestamp: '2021-07-09T05:27:17.908Z', - }, - destination: { - Config: { - credentials: 'abc', - eventToTopicMap: [ - { - from: 'track', - to: 'projects/big-query-integration-poc/topics/test', - }, - ], - }, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/commerce/updateCart', - headers: { - 'Content-Type': 'application/json', - }, - params: {}, - body: { - JSON: { - user: { - email: 'jessica@jlpdesign.net', - dataFields: { - email: 'jessica@jlpdesign.net', - }, - userId: '8751', - preferUserId: true, - mergeNestedObjects: true, - }, - items: [ - { - id: 10606, - sku: 'JB24691400-W05', - name: 'Vira Console Cabinet', - price: 797, - quantity: 1, - }, - ], - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 22', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - channel: 'sources', - context: { - externalId: [ - { - id: 'lynnanderson@smith.net', - identifierType: 'email', - type: 'ITERABLE-users', - }, - ], - mappedToDestination: 'true', - sources: { - batch_id: 'f5f240d0-0acb-46e0-b043-57fb0aabbadd', - job_id: '1zAj94bEy8komdqnYtSoDp0VmGs/Syncher', - job_run_id: 'c5tar6cqgmgmcjvupdhg', - task_id: 'tt_10_rows_check', - task_run_id: 'c5tar6cqgmgmcjvupdi0', - version: 'release.v1.6.8', - }, - }, - messageId: '2f052f7c-f694-4849-a7ed-a432f7ffa0a4', - originalTimestamp: '2021-10-28T14:03:50.503Z', - receivedAt: '2021-10-28T14:03:46.567Z', - recordId: '8', - request_ip: '10.1.94.92', - rudderId: 'c0f6843e-e3d6-4946-9752-fa339fbadef2', - sentAt: '2021-10-28T14:03:50.503Z', - timestamp: '2021-10-28T14:03:46.566Z', - traits: { - administrative_unit: 'Minnesota', - am_pm: 'AM', - boolean: true, - firstname: 'Jacqueline', - pPower: 'AM', - userId: 'Jacqueline', - }, - type: 'identify', - userId: 'lynnanderson@smith.net', - }, - destination: { - ID: '1zia9wKshXt80YksLmUdJnr7IHI', - Name: 'test_iterable', - DestinationDefinition: { - ID: '1iVQvTRMsPPyJzwol0ifH93QTQ6', - Name: 'ITERABLE', - DisplayName: 'Iterable', - Config: { - destConfig: { - defaultConfig: [ - 'apiKey', - 'mapToSingleEvent', - 'trackAllPages', - 'trackCategorisedPages', - 'trackNamedPages', - ], - }, - excludeKeys: [], - includeKeys: [], - saveDestinationResponse: true, - secretKeys: [], - supportedMessageTypes: ['identify', 'page', 'screen', 'track'], - supportedSourceTypes: [ - 'android', - 'ios', - 'web', - 'unity', - 'amp', - 'cloud', - 'warehouse', - 'reactnative', - 'flutter', - 'cordova', - ], - supportsVisualMapper: true, - transformAt: 'processor', - transformAtV1: 'processor', - }, - ResponseRules: null, - }, - Config: { - apiKey: '12345', - mapToSingleEvent: true, - trackAllPages: false, - trackCategorisedPages: true, - trackNamedPages: true, - }, - Enabled: true, - Transformations: [], - IsProcessorEnabled: true, - }, - libraries: [], - request: { - query: {}, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/users/update', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'lynnanderson@smith.net', - dataFields: { - administrative_unit: 'Minnesota', - am_pm: 'AM', - boolean: true, - firstname: 'Jacqueline', - pPower: 'AM', - userId: 'Jacqueline', - email: 'lynnanderson@smith.net', - }, - userId: 'lynnanderson@smith.net', - preferUserId: true, - mergeNestedObjects: true, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 23', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - channel: 'sources', - context: { - externalId: [ - { - id: 'Matthew', - identifierType: 'userId', - type: 'ITERABLE-users', - }, - ], - mappedToDestination: 'true', - sources: { - batch_id: '230d7c79-a2c2-4b2a-90bb-06ba988d3bb4', - job_id: '1zjj9aF5UkmavBi4HtM3kWOGvy0/Syncher', - job_run_id: 'c5tb4gsqgmgmcjvuplhg', - task_id: 'tt_10_rows', - task_run_id: 'c5tb4gsqgmgmcjvupli0', - version: 'release.v1.6.8', - }, - }, - messageId: 'c4c97310-463b-4300-9215-5cfddcb2a769', - originalTimestamp: '2021-10-28T14:23:43.254Z', - receivedAt: '2021-10-28T14:23:38.300Z', - recordId: '3', - request_ip: '10.1.94.92', - rudderId: '7300f5e3-bdb5-489e-ac7e-47876e487de9', - sentAt: '2021-10-28T14:23:43.254Z', - timestamp: '2021-10-28T14:23:38.299Z', - traits: { - price: 'GB', - }, - type: 'identify', - userId: 'Matthew', - }, - destination: { - ID: '1zjjHN4RQ6t4DPj3HVpp0b6XW4A', - Name: 'test_userId_uniq', - DestinationDefinition: { - ID: '1iVQvTRMsPPyJzwol0ifH93QTQ6', - Name: 'ITERABLE', - DisplayName: 'Iterable', - Config: { - destConfig: { - defaultConfig: [ - 'apiKey', - 'mapToSingleEvent', - 'trackAllPages', - 'trackCategorisedPages', - 'trackNamedPages', - ], - }, - excludeKeys: [], - includeKeys: [], - saveDestinationResponse: true, - secretKeys: [], - supportedMessageTypes: ['identify', 'page', 'screen', 'track'], - supportedSourceTypes: [ - 'android', - 'ios', - 'web', - 'unity', - 'amp', - 'cloud', - 'warehouse', - 'reactnative', - 'flutter', - 'cordova', - ], - supportsVisualMapper: true, - transformAt: 'processor', - transformAtV1: 'processor', - }, - ResponseRules: null, - }, - Config: { - apiKey: '12345', - mapToSingleEvent: true, - trackAllPages: false, - trackCategorisedPages: true, - trackNamedPages: true, - }, - Enabled: true, - Transformations: [], - IsProcessorEnabled: true, - }, - libraries: [], - request: { - query: {}, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/users/update', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - dataFields: { - price: 'GB', - userId: 'Matthew', - }, - userId: 'Matthew', - preferUserId: true, - mergeNestedObjects: true, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 24', - 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', - }, - device: { - token: 'sample_push_token', - name: 'sample_device_name', - model: 'sample_device_model', - manufacturer: 'sample_device_manufacturer', - type: 'watchos', - }, - traits: { - email: 'ruchira@rudderlabs.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', - ip: '0.0.0.0', - screen: { - density: 2, - }, - }, - type: 'identify', - messageId: '84e26acc-56a5-4835-8233-591137fca468', - originalTimestamp: '2019-10-14T09:03:17.562Z', - anonymousId: '00000000000000000000000000', - userId: '123456', - integrations: { - All: true, - }, - sentAt: '2019-10-14T09:03:22.563Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/users/update', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - email: 'ruchira@rudderlabs.com', - dataFields: { - email: 'ruchira@rudderlabs.com', - }, - userId: '123456', - preferUserId: true, - mergeNestedObjects: true, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 25', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'alias', - sentAt: '2020-08-28T16:26:16.473Z', - context: { - library: { - name: 'analytics-node', - version: '0.0.3', - }, - }, - _metadata: { - nodeVersion: '10.22.0', - }, - messageId: - 'node-6f62b91e789a636929ca38aed01c5f6e-103c720d-81bd-4742-98d6-d45a65aed23e', - properties: { - url: 'https://dominos.com', - title: 'Pizza', - referrer: 'https://google.com', - }, - userId: 'new@email.com', - previousId: 'old@email.com', - anonymousId: 'abcdeeeeeeeexxxx102', - originalTimestamp: '2020-08-28T16:26:06.468Z', - }, - destination: { - Config: { - apiKey: '62d12498c37c4fd8a1a546c2d35c2f60', - mapToSingleEvent: false, - trackAllPages: false, - trackCategorisedPages: true, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - JSON: { - currentEmail: 'old@email.com', - newEmail: 'new@email.com', - }, - }, - type: 'REST', - files: {}, - method: 'POST', - params: {}, - headers: { - api_key: '62d12498c37c4fd8a1a546c2d35c2f60', - 'Content-Type': 'application/json', - }, - version: '1', - endpoint: 'https://api.iterable.com/api/users/updateEmail', - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 26', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'alias', - sentAt: '2020-08-28T16:26:16.473Z', - context: { - library: { - name: 'analytics-node', - version: '0.0.3', - }, - }, - _metadata: { - nodeVersion: '10.22.0', - }, - messageId: - 'node-6f62b91e789a636929ca38aed01c5f6e-103c720d-81bd-4742-98d6-d45a65aed23e', - properties: { - url: 'https://dominos.com', - title: 'Pizza', - referrer: 'https://google.com', - }, - userId: 'new@email.com', - anonymousId: 'abcdeeeeeeeexxxx102', - originalTimestamp: '2020-08-28T16:26:06.468Z', - }, - destination: { - Config: { - apiKey: '62d12498c37c4fd8a1a546c2d35c2f60', - mapToSingleEvent: false, - trackAllPages: false, - trackCategorisedPages: true, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'Missing required value from "previousId"', - statTags: { - destType: 'ITERABLE', - errorCategory: 'dataValidation', - errorType: 'instrumentation', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 27', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'alias', - sentAt: '2020-08-28T16:26:16.473Z', - context: { - library: { - name: 'analytics-node', - version: '0.0.3', - }, - }, - _metadata: { - nodeVersion: '10.22.0', - }, - messageId: - 'node-6f62b91e789a636929ca38aed01c5f6e-103c720d-81bd-4742-98d6-d45a65aed23e', - properties: { - url: 'https://dominos.com', - title: 'Pizza', - referrer: 'https://google.com', - }, - previousId: 'old@email.com', - anonymousId: 'abcdeeeeeeeexxxx102', - originalTimestamp: '2020-08-28T16:26:06.468Z', - }, - destination: { - Config: { - apiKey: '62d12498c37c4fd8a1a546c2d35c2f60', - mapToSingleEvent: false, - trackAllPages: false, - trackCategorisedPages: true, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'Missing required value from "userId"', - statTags: { - destType: 'ITERABLE', - errorCategory: 'dataValidation', - errorType: 'instrumentation', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 28', - 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: 'john@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - event: 'product added', - type: 'track', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - campaignId: '1', - templateId: '0', - orderId: 10000, - total: 1000, - products: [ - { - product_id: '507f1f77bcf86cd799439011', - sku: '45790-32', - name: 'Monopoly: 3rd Edition', - price: '19', - position: '1', - category: ['bikes', 'cars', 'motors'], - url: 'https://www.example.com/product/path', - image_url: 'https://www.example.com/product/path.jpg', - quantity: '2', - }, - { - product_id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - price: '192', - quantity: 22, - position: '12', - category: ['Bikes2', 'cars2', 'motors2'], - url: 'https://www.example.com/product/path2', - image_url: 'https://www.example.com/product/path.jpg2', - }, - ], - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/commerce/updateCart', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - user: { - email: 'john@gmail.com', - dataFields: { - email: 'john@gmail.com', - }, - userId: '12345', - preferUserId: true, - mergeNestedObjects: true, - }, - items: [ - { - id: '507f1f77bcf86cd799439011', - sku: '45790-32', - name: 'Monopoly: 3rd Edition', - categories: ['bikes', 'cars', 'motors'], - price: 19, - quantity: 2, - imageUrl: 'https://www.example.com/product/path.jpg', - url: 'https://www.example.com/product/path', - }, - { - id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - categories: ['Bikes2', 'cars2', 'motors2'], - price: 192, - quantity: 22, - imageUrl: 'https://www.example.com/product/path.jpg2', - url: 'https://www.example.com/product/path2', - }, - ], - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 29', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - event: 'product added', - type: 'track', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - campaignId: '1', - templateId: '0', - orderId: 10000, - total: 1000, - products: [ - { - product_id: '507f1f77bcf86cd799439011', - sku: '45790-32', - name: 'Monopoly: 3rd Edition', - price: '19', - position: '1', - category: 'shirts,pants,trousers', - url: 'https://www.example.com/product/path', - image_url: 'https://www.example.com/product/path.jpg', - quantity: '2', - }, - { - product_id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - price: '192', - quantity: 22, - position: '12', - category: 'Cars2', - url: 'https://www.example.com/product/path2', - image_url: 'https://www.example.com/product/path.jpg2', - }, - ], - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/commerce/updateCart', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - user: { - email: 'sayan@gmail.com', - dataFields: { - email: 'sayan@gmail.com', - }, - userId: '12345', - preferUserId: true, - mergeNestedObjects: true, - }, - items: [ - { - id: '507f1f77bcf86cd799439011', - sku: '45790-32', - name: 'Monopoly: 3rd Edition', - categories: ['shirts', 'pants', 'trousers'], - price: 19, - quantity: 2, - imageUrl: 'https://www.example.com/product/path.jpg', - url: 'https://www.example.com/product/path', - }, - { - id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - categories: ['Cars2'], - price: 192, - quantity: 22, - imageUrl: 'https://www.example.com/product/path.jpg2', - url: 'https://www.example.com/product/path2', - }, - ], - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 30', - 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: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - event: 'product added', - type: 'track', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - campaignId: '1', - templateId: '0', - orderId: 10000, - total: 1000, - product_id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - price: '192', - quantity: 22, - position: '12', - category: 'Cars2', - url: 'https://www.example.com/product/path2', - image_url: 'https://www.example.com/product/path.jpg2', - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - apiKey: '12345', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/commerce/updateCart', - headers: { - 'Content-Type': 'application/json', - api_key: '12345', - }, - params: {}, - body: { - JSON: { - user: { - email: 'sayan@gmail.com', - dataFields: { - email: 'sayan@gmail.com', - }, - userId: '12345', - preferUserId: true, - mergeNestedObjects: true, - }, - items: [ - { - id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - categories: ['Cars2'], - price: 192, - quantity: 22, - imageUrl: 'https://www.example.com/product/path.jpg2', - url: 'https://www.example.com/product/path2', - }, - ], - }, - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 31', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - destination: { - Config: { - passcode: - 'fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1', - accountId: '476550467', - trackAnonymous: true, - enableObjectIdMapping: false, - }, - }, - message: { - channel: 'web', - context: { - app: { - build: '1.0.0', - name: 'RudderLabs JavaScript SDK', - namespace: 'com.rudderlabs.javascript', - version: '1.0.0', - }, - traits: { - email: 'sayan@gmail.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', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - event: 'order completed', - type: 'track', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - product_id: 1234, - name: 'Shoes', - price: 45, - quantity: 1, - orderId: 10000, - total: '1000', - campaignId: '123456', - templateId: '1213458', - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.iterable.com/api/commerce/trackPurchase', - headers: { - 'Content-Type': 'application/json', - }, - params: {}, - body: { - JSON: { - dataFields: { - product_id: 1234, - name: 'Shoes', - price: 45, - quantity: 1, - orderId: 10000, - total: '1000', - campaignId: '123456', - templateId: '1213458', - }, - id: '10000', - createdAt: 1571051718299, - campaignId: 123456, - templateId: 1213458, - total: 1000, - user: { - email: 'sayan@gmail.com', - dataFields: { - email: 'sayan@gmail.com', - }, - userId: '12345', - preferUserId: true, - mergeNestedObjects: true, - }, - items: [ - { - id: 1234, - name: 'Shoes', - price: 45, - quantity: 1, - }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 32', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'track', - sentAt: '2020-08-28T16:26:16.473Z', - context: { - library: { - name: 'analytics-node', - version: '0.0.3', - }, - }, - _metadata: { - nodeVersion: '10.22.0', - }, - messageId: - 'node-570110489d3e99b234b18af9a9eca9d4-6009779e-82d7-469d-aaeb-5ccf162b0453', - properties: { - subject: 'resume validate', - sendtime: '2020-01-01', - sendlocation: 'akashdeep@gmail.com', - }, - anonymousId: 'abcdeeeeeeeexxxx102', - originalTimestamp: '2020-08-28T16:26:06.468Z', - }, - destination: { - Config: { - apiKey: '62d12498c37c4fd8a1a546c2d35c2f60', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - JSON: { - userId: 'abcdeeeeeeeexxxx102', - createdAt: 1598631966468, - dataFields: { - subject: 'resume validate', - sendtime: '2020-01-01', - sendlocation: 'akashdeep@gmail.com', - }, - }, - }, - type: 'REST', - files: {}, - method: 'POST', - params: {}, - headers: { - api_key: '62d12498c37c4fd8a1a546c2d35c2f60', - 'Content-Type': 'application/json', - }, - version: '1', - endpoint: 'https://api.iterable.com/api/events/track', - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'iterable', - description: 'Test 33', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'track', - event: '', - sentAt: '2020-08-28T16:26:16.473Z', - context: { - library: { - name: 'analytics-node', - version: '0.0.3', - }, - }, - _metadata: { - nodeVersion: '10.22.0', - }, - messageId: - 'node-570110489d3e99b234b18af9a9eca9d4-6009779e-82d7-469d-aaeb-5ccf162b0453', - properties: { - subject: 'resume validate', - sendtime: '2020-01-01', - sendlocation: 'akashdeep@gmail.com', - }, - anonymousId: 'abcdeeeeeeeexxxx102', - originalTimestamp: '2020-08-28T16:26:06.468Z', - }, - destination: { - Config: { - apiKey: '62d12498c37c4fd8a1a546c2d35c2f60', - mapToSingleEvent: false, - trackAllPages: true, - trackCategorisedPages: false, - trackNamedPages: false, - }, - Enabled: true, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - XML: {}, - JSON_ARRAY: {}, - FORM: {}, - JSON: { - userId: 'abcdeeeeeeeexxxx102', - createdAt: 1598631966468, - dataFields: { - subject: 'resume validate', - sendtime: '2020-01-01', - sendlocation: 'akashdeep@gmail.com', - }, - }, - }, - type: 'REST', - files: {}, - method: 'POST', - params: {}, - headers: { - api_key: '62d12498c37c4fd8a1a546c2d35c2f60', - 'Content-Type': 'application/json', - }, - version: '1', - endpoint: 'https://api.iterable.com/api/events/track', - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, + ...identifyTestData, + ...trackTestData, + ...pageScreenTestData, + ...aliasTestData, + ...validationTestData, ]; diff --git a/test/integrations/destinations/iterable/processor/identifyTestData.ts b/test/integrations/destinations/iterable/processor/identifyTestData.ts new file mode 100644 index 0000000000..d05f87a11f --- /dev/null +++ b/test/integrations/destinations/iterable/processor/identifyTestData.ts @@ -0,0 +1,407 @@ +import { + generateMetadata, + transformResultBuilder, + generateIndentifyPayload, +} from './../../../testUtils'; +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; + +const destination: Destination = { + ID: '123', + Name: 'iterable', + DestinationDefinition: { + ID: '123', + Name: 'iterable', + DisplayName: 'Iterable', + Config: {}, + }, + WorkspaceID: '123', + Transformations: [], + Config: { + apiKey: 'testApiKey', + preferUserId: false, + trackAllPages: true, + trackNamedPages: false, + mapToSingleEvent: false, + trackCategorisedPages: false, + }, + Enabled: true, +}; + +const headers = { + api_key: 'testApiKey', + 'Content-Type': 'application/json', +}; + +const user1Traits = { + name: 'manashi', + country: 'India', + city: 'Bangalore', + email: 'manashi@website.com', +}; + +const user2Traits = { + am_pm: 'AM', + pPower: 'AM', + boolean: true, + userId: 'Jacqueline', + firstname: 'Jacqueline', + administrative_unit: 'Minnesota', +}; + +const userId = 'userId'; +const anonymousId = 'anonId'; +const sentAt = '2020-08-28T16:26:16.473Z'; +const originalTimestamp = '2020-08-28T16:26:06.468Z'; + +const updateUserEndpoint = 'https://api.iterable.com/api/users/update'; + +export const identifyTestData: ProcessorTestData[] = [ + { + id: 'iterable-identify-test-1', + name: 'iterable', + description: 'Indentify call to update user in iterable with user traits', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain update user payload with all user traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + anonymousId, + context: { + traits: user1Traits, + }, + traits: user1Traits, + type: 'identify', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: updateUserEndpoint, + JSON: { + email: user1Traits.email, + userId: anonymousId, + dataFields: user1Traits, + preferUserId: false, + mergeNestedObjects: true, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-identify-test-2', + name: 'iterable', + description: 'Indentify call to update user email', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain update user payload with new email sent in payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: generateIndentifyPayload({ + userId, + anonymousId, + context: { + traits: { email: 'ruchira@rudderlabs.com' }, + }, + type: 'identify', + sentAt, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: updateUserEndpoint, + JSON: { + email: 'ruchira@rudderlabs.com', + userId, + dataFields: { + email: 'ruchira@rudderlabs.com', + }, + preferUserId: false, + mergeNestedObjects: true, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-identify-test-3', + name: 'iterable', + description: 'Indentify call to update user email with preferUserId config set to true', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain update user payload with new email sent in payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...destination, Config: { ...destination.Config, preferUserId: true } }, + message: generateIndentifyPayload({ + userId, + anonymousId, + context: { + traits: { email: 'ruchira@rudderlabs.com' }, + }, + type: 'identify', + sentAt, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: updateUserEndpoint, + JSON: { + email: 'ruchira@rudderlabs.com', + userId, + dataFields: { + email: 'ruchira@rudderlabs.com', + }, + preferUserId: true, + mergeNestedObjects: true, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-identify-test-4', + name: 'iterable', + description: + 'Indentify call to update user email with traits present at root instead of context.traits', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain update user payload with new email sent in payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...destination, Config: { ...destination.Config, preferUserId: true } }, + message: generateIndentifyPayload({ + userId, + anonymousId, + context: { + traits: {}, + }, + traits: { email: 'ruchira@rudderlabs.com' }, + type: 'identify', + sentAt, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: updateUserEndpoint, + JSON: { + email: 'ruchira@rudderlabs.com', + userId, + dataFields: { + email: 'ruchira@rudderlabs.com', + }, + preferUserId: true, + mergeNestedObjects: true, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-identify-test-5', + name: 'iterable', + description: 'Iterable rEtl test to update user', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain update user payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...destination, Config: { ...destination.Config, preferUserId: true } }, + message: { + userId, + anonymousId, + context: { + externalId: [ + { + id: 'lynnanderson@smith.net', + identifierType: 'email', + type: 'ITERABLE-users', + }, + ], + mappedToDestination: 'true', + }, + traits: user2Traits, + type: 'identify', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: updateUserEndpoint, + JSON: { + email: 'lynnanderson@smith.net', + userId, + dataFields: { ...user2Traits, email: 'lynnanderson@smith.net' }, + preferUserId: true, + mergeNestedObjects: true, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-identify-test-6', + name: 'iterable', + description: 'Iterable rEtl test to update user traits', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain update user payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + userId: 'Matthew', + anonymousId, + context: { + externalId: [ + { + id: 'Matthew', + identifierType: 'userId', + type: 'ITERABLE-users', + }, + ], + mappedToDestination: 'true', + }, + traits: user2Traits, + type: 'identify', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: updateUserEndpoint, + JSON: { + userId: 'Matthew', + dataFields: { ...user2Traits, userId: 'Matthew' }, + preferUserId: false, + mergeNestedObjects: true, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/iterable/processor/pageScreenTestData.ts b/test/integrations/destinations/iterable/processor/pageScreenTestData.ts new file mode 100644 index 0000000000..074d6b56df --- /dev/null +++ b/test/integrations/destinations/iterable/processor/pageScreenTestData.ts @@ -0,0 +1,409 @@ +import { generateMetadata, transformResultBuilder } from './../../../testUtils'; +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; + +const destination: Destination = { + ID: '123', + Name: 'iterable', + DestinationDefinition: { + ID: '123', + Name: 'iterable', + DisplayName: 'Iterable', + Config: {}, + }, + WorkspaceID: '123', + Transformations: [], + Config: { + apiKey: 'testApiKey', + preferUserId: false, + trackAllPages: true, + trackNamedPages: false, + mapToSingleEvent: false, + trackCategorisedPages: false, + }, + Enabled: true, +}; + +const headers = { + api_key: 'testApiKey', + 'Content-Type': 'application/json', +}; + +const properties = { + path: '/abc', + referrer: '', + search: '', + title: '', + url: '', + category: 'test-category', +}; + +const anonymousId = 'anonId'; +const sentAt = '2020-08-28T16:26:16.473Z'; +const originalTimestamp = '2020-08-28T16:26:06.468Z'; + +const pageEndpoint = 'https://api.iterable.com/api/events/track'; + +export const pageScreenTestData: ProcessorTestData[] = [ + { + id: 'iterable-page-test-1', + name: 'iterable', + description: 'Page call with name and properties', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain page name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + anonymousId, + name: 'ApplicationLoaded', + context: { + traits: { + email: 'sayan@gmail.com', + }, + }, + properties, + type: 'page', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: pageEndpoint, + JSON: { + userId: anonymousId, + dataFields: properties, + email: 'sayan@gmail.com', + createdAt: 1598631966468, + eventName: 'ApplicationLoaded page', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-page-test-2', + name: 'iterable', + description: 'Page call with name and properties and mapToSingleEvent config set to true', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain page name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + ...destination, + Config: { ...destination.Config, mapToSingleEvent: true }, + }, + message: { + anonymousId, + name: 'ApplicationLoaded', + context: { + traits: { + email: 'sayan@gmail.com', + }, + }, + properties: { ...properties, campaignId: '123456', templateId: '1213458' }, + type: 'page', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: pageEndpoint, + JSON: { + campaignId: 123456, + templateId: 1213458, + userId: anonymousId, + email: 'sayan@gmail.com', + createdAt: 1598631966468, + eventName: 'Loaded a Page', + dataFields: { ...properties, campaignId: '123456', templateId: '1213458' }, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-page-test-3', + name: 'iterable', + description: 'Page call with name and properties and trackNamedPages config set to true', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain page name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + ...destination, + Config: { ...destination.Config, trackNamedPages: true, trackAllPages: false }, + }, + message: { + anonymousId, + name: 'ApplicationLoaded', + context: { + traits: { + email: 'sayan@gmail.com', + }, + }, + properties, + type: 'page', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: pageEndpoint, + JSON: { + userId: anonymousId, + email: 'sayan@gmail.com', + createdAt: 1598631966468, + eventName: 'ApplicationLoaded page', + dataFields: properties, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-screen-test-1', + name: 'iterable', + description: 'Screen call with name and properties', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain screen name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + ...destination, + Config: { ...destination.Config, trackCategorisedPages: true, trackAllPages: false }, + }, + message: { + anonymousId, + name: 'ApplicationLoaded', + context: { + traits: { + email: 'sayan@gmail.com', + }, + }, + properties, + type: 'screen', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: pageEndpoint, + JSON: { + userId: anonymousId, + dataFields: properties, + email: 'sayan@gmail.com', + createdAt: 1598631966468, + eventName: 'ApplicationLoaded screen', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-screen-test-2', + name: 'iterable', + description: 'Screen call with name and properties and mapToSingleEvent config set to true', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain screen name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + ...destination, + Config: { ...destination.Config, mapToSingleEvent: true }, + }, + message: { + anonymousId, + name: 'ApplicationLoaded', + context: { + traits: { + email: 'sayan@gmail.com', + }, + }, + properties: { ...properties, campaignId: '123456', templateId: '1213458' }, + type: 'screen', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: pageEndpoint, + JSON: { + campaignId: 123456, + templateId: 1213458, + userId: anonymousId, + email: 'sayan@gmail.com', + createdAt: 1598631966468, + eventName: 'Loaded a Screen', + dataFields: { ...properties, campaignId: '123456', templateId: '1213458' }, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-screen-test-3', + name: 'iterable', + description: 'Page call with name and properties and trackNamedPages config set to true', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain page name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + ...destination, + Config: { ...destination.Config, trackNamedPages: true, trackAllPages: false }, + }, + message: { + anonymousId, + name: 'ApplicationLoaded', + context: { + traits: { + email: 'sayan@gmail.com', + }, + }, + properties, + type: 'screen', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: pageEndpoint, + JSON: { + userId: anonymousId, + email: 'sayan@gmail.com', + createdAt: 1598631966468, + eventName: 'ApplicationLoaded screen', + dataFields: properties, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/iterable/processor/trackTestData.ts b/test/integrations/destinations/iterable/processor/trackTestData.ts new file mode 100644 index 0000000000..296275ad77 --- /dev/null +++ b/test/integrations/destinations/iterable/processor/trackTestData.ts @@ -0,0 +1,717 @@ +import { + generateMetadata, + generateTrackPayload, + transformResultBuilder, +} from './../../../testUtils'; +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; + +const destination: Destination = { + ID: '123', + Name: 'iterable', + DestinationDefinition: { + ID: '123', + Name: 'iterable', + DisplayName: 'Iterable', + Config: {}, + }, + WorkspaceID: '123', + Transformations: [], + Config: { + apiKey: 'testApiKey', + preferUserId: false, + trackAllPages: true, + trackNamedPages: false, + mapToSingleEvent: false, + trackCategorisedPages: false, + }, + Enabled: true, +}; + +const headers = { + api_key: 'testApiKey', + 'Content-Type': 'application/json', +}; + +const properties = { + subject: 'resume validate', + sendtime: '2020-01-01', + sendlocation: 'akashdeep@gmail.com', +}; + +const customEventProperties = { + campaignId: '1', + templateId: '0', + user_actual_id: 12345, + category: 'test-category', + email: 'ruchira@rudderlabs.com', + user_actual_role: 'system_admin, system_user', +}; + +const productInfo = { + price: 797, + variant: 'Oak', + quantity: 1, + quickship: true, + full_price: 1328, + product_id: 10606, + non_interaction: 1, + sku: 'JB24691400-W05', + name: 'Vira Console Cabinet', + cart_id: 'bd9b8dbf4ef8ee01d4206b04fe2ee6ae', +}; + +const orderCompletedProductInfo = { + price: 45, + quantity: 1, + total: '1000', + name: 'Shoes', + orderId: 10000, + product_id: 1234, + campaignId: '123456', + templateId: '1213458', +}; + +const products = [ + { + product_id: '507f1f77bcf86cd799439011', + sku: '45790-32', + name: 'Monopoly: 3rd Edition', + price: '19', + position: '1', + category: 'cars', + url: 'https://www.example.com/product/path', + image_url: 'https://www.example.com/product/path.jpg', + quantity: '2', + }, + { + product_id: '507f1f77bcf86cd7994390112', + sku: '45790-322', + name: 'Monopoly: 3rd Edition2', + price: '192', + quantity: 22, + position: '12', + category: 'Cars2', + url: 'https://www.example.com/product/path2', + image_url: 'https://www.example.com/product/path.jpg2', + }, +]; + +const items = [ + { + id: '507f1f77bcf86cd799439011', + sku: '45790-32', + name: 'Monopoly: 3rd Edition', + categories: ['cars'], + price: 19, + quantity: 2, + imageUrl: 'https://www.example.com/product/path.jpg', + url: 'https://www.example.com/product/path', + }, + { + id: '507f1f77bcf86cd7994390112', + sku: '45790-322', + name: 'Monopoly: 3rd Edition2', + categories: ['Cars2'], + price: 192, + quantity: 22, + imageUrl: 'https://www.example.com/product/path.jpg2', + url: 'https://www.example.com/product/path2', + }, +]; + +const userId = 'userId'; +const anonymousId = 'anonId'; +const sentAt = '2020-08-28T16:26:16.473Z'; +const originalTimestamp = '2020-08-28T16:26:06.468Z'; + +const endpoint = 'https://api.iterable.com/api/events/track'; +const updateCartEndpoint = 'https://api.iterable.com/api/commerce/updateCart'; +const trackPurchaseEndpoint = 'https://api.iterable.com/api/commerce/trackPurchase'; + +export const trackTestData: ProcessorTestData[] = [ + { + id: 'iterable-track-test-1', + name: 'iterable', + description: 'Track call to add event with user', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain event properties and event name', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + anonymousId, + event: 'Email Opened', + type: 'track', + context: {}, + properties, + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint, + JSON: { + userId: 'anonId', + createdAt: 1598631966468, + eventName: 'Email Opened', + dataFields: properties, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-track-test-2', + name: 'iterable', + description: 'Track call for product added event with all properties', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain event name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: generateTrackPayload({ + userId, + anonymousId, + event: 'product added', + context: { + traits: { + email: 'sayan@gmail.com', + }, + }, + properties: { + campaignId: '1', + templateId: '0', + orderId: 10000, + total: 1000, + products, + }, + sentAt, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: updateCartEndpoint, + JSON: { + user: { + email: 'sayan@gmail.com', + dataFields: { + email: 'sayan@gmail.com', + }, + userId, + preferUserId: false, + mergeNestedObjects: true, + }, + items, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-track-test-3', + name: 'iterable', + description: 'Track call for order completed event with all properties', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain event name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: generateTrackPayload({ + userId, + anonymousId, + event: 'order completed', + context: { + traits: { + email: 'sayan@gmail.com', + }, + }, + properties: { + orderId: 10000, + total: '1000', + campaignId: '123456', + templateId: '1213458', + products, + }, + sentAt, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: trackPurchaseEndpoint, + JSON: { + dataFields: { + orderId: 10000, + total: '1000', + campaignId: '123456', + templateId: '1213458', + products, + }, + id: '10000', + createdAt: 1598631966468, + campaignId: 123456, + templateId: 1213458, + total: 1000, + user: { + email: 'sayan@gmail.com', + dataFields: { + email: 'sayan@gmail.com', + }, + userId, + preferUserId: false, + mergeNestedObjects: true, + }, + items, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-track-test-4', + name: 'iterable', + description: 'Track call for custom event with all properties', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain custom event name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: generateTrackPayload({ + userId, + anonymousId, + event: 'test track event GA3', + context: { + traits: { + email: 'sayan@gmail.com', + }, + }, + properties: customEventProperties, + sentAt, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint, + JSON: { + email: 'ruchira@rudderlabs.com', + dataFields: customEventProperties, + userId, + eventName: 'test track event GA3', + createdAt: 1598631966468, + campaignId: 1, + templateId: 0, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-track-test-5', + name: 'iterable', + description: 'Track call for product added event with product info as properties', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain event name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: generateTrackPayload({ + userId, + anonymousId, + event: 'product added', + context: { + traits: { + email: 'jessica@jlpdesign.net', + }, + }, + properties: productInfo, + sentAt, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: updateCartEndpoint, + JSON: { + user: { + email: 'jessica@jlpdesign.net', + dataFields: { + email: 'jessica@jlpdesign.net', + }, + userId, + preferUserId: false, + mergeNestedObjects: true, + }, + items: [ + { + id: productInfo.product_id, + sku: productInfo.sku, + name: productInfo.name, + price: productInfo.price, + quantity: productInfo.quantity, + }, + ], + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-track-test-6', + name: 'iterable', + description: 'Track call for product added event with product info as properties', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain event name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: generateTrackPayload({ + userId, + anonymousId, + event: 'product added', + context: { + traits: { + email: 'jessica@jlpdesign.net', + }, + }, + properties: { + campaignId: '1', + templateId: '0', + orderId: 10000, + total: 1000, + ...products[1], + }, + sentAt, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: updateCartEndpoint, + JSON: { + user: { + email: 'jessica@jlpdesign.net', + dataFields: { + email: 'jessica@jlpdesign.net', + }, + userId, + preferUserId: false, + mergeNestedObjects: true, + }, + items: [ + { + price: 192, + url: products[1].url, + sku: products[1].sku, + name: products[1].name, + id: products[1].product_id, + quantity: products[1].quantity, + imageUrl: products[1].image_url, + categories: [products[1].category], + }, + ], + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-track-test-7', + name: 'iterable', + description: 'Track call for order completed event with product info as properties', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain event name and all properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: generateTrackPayload({ + userId, + anonymousId, + event: 'order completed', + context: { + traits: { + email: 'jessica@jlpdesign.net', + }, + }, + properties: orderCompletedProductInfo, + sentAt, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint: trackPurchaseEndpoint, + JSON: { + dataFields: orderCompletedProductInfo, + user: { + email: 'jessica@jlpdesign.net', + dataFields: { + email: 'jessica@jlpdesign.net', + }, + userId, + preferUserId: false, + mergeNestedObjects: true, + }, + id: '10000', + total: 1000, + campaignId: 123456, + templateId: 1213458, + createdAt: 1598631966468, + items: [ + { + id: orderCompletedProductInfo.product_id, + name: orderCompletedProductInfo.name, + price: orderCompletedProductInfo.price, + quantity: orderCompletedProductInfo.quantity, + }, + ], + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-track-test-8', + name: 'iterable', + description: 'Track call without event name and userId', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain event properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + anonymousId, + type: 'track', + context: {}, + properties, + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint, + JSON: { + userId: anonymousId, + createdAt: 1598631966468, + dataFields: properties, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-track-test-8', + name: 'iterable', + description: 'Track call without event name', + scenario: 'Business', + successCriteria: + 'Response should contain status code 200 and it should contain event properties', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + userId, + anonymousId, + type: 'track', + context: {}, + properties, + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + headers, + endpoint, + JSON: { + userId, + createdAt: 1598631966468, + dataFields: properties, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/iterable/processor/validationTestData.ts b/test/integrations/destinations/iterable/processor/validationTestData.ts new file mode 100644 index 0000000000..86728a868b --- /dev/null +++ b/test/integrations/destinations/iterable/processor/validationTestData.ts @@ -0,0 +1,258 @@ +import { generateMetadata } from './../../../testUtils'; +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; + +const destination: Destination = { + ID: '123', + Name: 'iterable', + DestinationDefinition: { + ID: '123', + Name: 'iterable', + DisplayName: 'Iterable', + Config: {}, + }, + WorkspaceID: '123', + Transformations: [], + Config: { + apiKey: 'testApiKey', + mapToSingleEvent: false, + trackAllPages: false, + trackCategorisedPages: true, + trackNamedPages: false, + }, + Enabled: true, +}; + +const properties = { + url: 'https://dominos.com', + title: 'Pizza', + referrer: 'https://google.com', +}; + +const sentAt = '2020-08-28T16:26:16.473Z'; +const originalTimestamp = '2020-08-28T16:26:06.468Z'; + +const expectedStatTags = { + destType: 'ITERABLE', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'native', + module: 'destination', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', +}; + +export const validationTestData: ProcessorTestData[] = [ + { + id: 'iterable-validation-test-1', + name: 'iterable', + description: "[Error]: Page call without it's required configuration", + scenario: 'Framework', + successCriteria: + 'Response should contain status code 400 and it should throw configuration error with respective message type', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + userId: 'sajal12', + anonymousId: 'abcdeeeeeeeexxxx102', + context: { + traits: { + email: 'abc@example.com', + }, + }, + properties, + type: 'page', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + statusCode: 400, + error: 'Invalid page call', + statTags: { ...expectedStatTags, errorType: 'configuration' }, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-validation-test-2', + name: 'iterable', + description: '[Error]: Identify call without userId and email', + scenario: 'Framework', + successCriteria: + 'Response should contain status code 400 and it should throw instrumentation error with respective message type', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + context: {}, + type: 'identify', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + statusCode: 400, + error: 'userId or email is mandatory for this request', + statTags: expectedStatTags, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-validation-test-3', + name: 'iterable', + description: '[Error]: Message type is not supported', + scenario: 'Framework', + successCriteria: + 'Response should contain status code 400 and it should throw instrumentation error with respective message type', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + context: {}, + type: 'group', + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + statusCode: 400, + error: 'Message type group not supported', + statTags: expectedStatTags, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-validation-test-4', + name: 'iterable', + description: '[Error]: Missing required value for alias call', + scenario: 'Framework', + successCriteria: + 'Response should contain status code 400 and it should throw instrumentation error with respective message type', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + context: {}, + type: 'alias', + properties, + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + statusCode: 400, + error: 'Missing required value from "previousId"', + statTags: expectedStatTags, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'iterable-validation-test-5', + name: 'iterable', + description: '[Error]: Missing userId value for alias call', + scenario: 'Framework', + successCriteria: + 'Response should contain status code 400 and it should throw instrumentation error with respective message type', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + context: {}, + type: 'alias', + previousId: 'old@email.com', + anonymousId: 'anonId', + properties, + sentAt, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + statusCode: 400, + error: 'Missing required value from "userId"', + statTags: expectedStatTags, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/testUtils.ts b/test/integrations/testUtils.ts index c16aeff98c..0a2727f4d0 100644 --- a/test/integrations/testUtils.ts +++ b/test/integrations/testUtils.ts @@ -292,6 +292,7 @@ export const generatePageOrScreenPayload: any = (parametersOverride: any, eventT 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36', }), event: parametersOverride.event, + name: parametersOverride.name, anonymousId: parametersOverride.anonymousId || 'default-anonymousId', properties: parametersOverride.properties, type: eventType || 'page', From 89a71b757998cb55a63c59151b5e3a118084970b Mon Sep 17 00:00:00 2001 From: Mihir Bhalala <77438541+mihir-4116@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:27:51 +0530 Subject: [PATCH 18/25] chore: component test refactor for intercom destination (#3236) --- .../destinations/intercom/processor/data.ts | 4156 +---------------- .../intercom/processor/groupTestData.ts | 509 ++ .../intercom/processor/identifyTestData.ts | 1025 ++++ .../intercom/processor/trackTestData.ts | 361 ++ .../intercom/processor/validationTestData.ts | 554 +++ 5 files changed, 2458 insertions(+), 4147 deletions(-) create mode 100644 test/integrations/destinations/intercom/processor/groupTestData.ts create mode 100644 test/integrations/destinations/intercom/processor/identifyTestData.ts create mode 100644 test/integrations/destinations/intercom/processor/trackTestData.ts create mode 100644 test/integrations/destinations/intercom/processor/validationTestData.ts diff --git a/test/integrations/destinations/intercom/processor/data.ts b/test/integrations/destinations/intercom/processor/data.ts index 2c562ed4e9..7bc697bc2d 100644 --- a/test/integrations/destinations/intercom/processor/data.ts +++ b/test/integrations/destinations/intercom/processor/data.ts @@ -1,4149 +1,11 @@ +import { identifyTestData } from './identifyTestData'; +import { trackTestData } from './trackTestData'; +import { groupTestData } from './groupTestData'; +import { validationTestData } from './validationTestData'; + export const data = [ - { - name: 'intercom', - description: 'No message type', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - channel: 'web', - context: { - traits: { - age: 23, - email: 'adc@test.com', - firstname: 'Test', - birthday: '2022-05-13T12:51:01.470Z', - }, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', - }, - event: 'Product Searched', - originalTimestamp: '2020-09-22T14:42:44.724Z', - timestamp: '2022-09-22T20:12:44.757+05:30', - userId: 'user@1', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 1, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 1, - }, - statusCode: 400, - error: - 'message Type is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: message Type is not present. Aborting', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Unsupported message type', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - channel: 'web', - context: { - traits: { - age: 23, - email: 'adc@test.com', - firstname: 'Test', - birthday: '2022-05-13T12:51:01.470Z', - }, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', - }, - event: 'Product Searched', - type: 'page', - originalTimestamp: '2020-09-22T14:42:44.724Z', - timestamp: '2022-09-22T20:12:44.757+05:30', - userId: 'user@1', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 2, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 2, - }, - statusCode: 400, - error: - 'message type page is not supported: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: message type page is not supported', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Missing required config', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@1', - channel: 'web', - context: { - traits: { - age: 23, - email: 'adc@test.com', - firstName: 'Test', - }, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 3, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 3, - }, - statusCode: 400, - error: - 'Access Token is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Access Token is not present. Aborting', - statTags: { - errorCategory: 'dataValidation', - errorType: 'configuration', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Create customer with email as lookup field', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@1', - channel: 'web', - context: { - traits: { - age: 23, - email: 'test@rudderlabs.com', - phone: '+91 9999999999', - firstName: 'Test', - lastName: 'Rudderlabs', - address: 'california usa', - ownerId: '13', - lastSeenAt: '2023-11-10T14:42:44.724Z', - }, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 4, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - email: 'test@rudderlabs.com', - external_id: 'user@1', - last_seen_at: 1699627364, - name: 'Test Rudderlabs', - owner_id: 13, - phone: '+91 9999999999', - custom_attributes: { - address: 'california usa', - age: 23, - }, - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.intercom.io/contacts', - headers: { - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - Accept: 'application/json', - 'Intercom-Version': '2.10', - }, - userId: '', - version: '1', - type: 'REST', - method: 'POST', - files: {}, - params: {}, - }, - metadata: { jobId: 4 }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Update customer with email as lookup field', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@2', - channel: 'web', - context: { - traits: { - age: 32, - email: 'test+2@rudderlabs.com', - phone: '+91 9299999999', - firstName: 'Test', - lastName: 'RudderStack', - ownerId: '14', - }, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 5, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - email: 'test+2@rudderlabs.com', - external_id: 'user@2', - name: 'Test RudderStack', - owner_id: 14, - phone: '+91 9299999999', - custom_attributes: { - age: 32, - }, - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.intercom.io/contacts/7070129940741e45d040', - headers: { - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - Accept: 'application/json', - 'Intercom-Version': '2.10', - }, - userId: '', - version: '1', - type: 'REST', - method: 'PUT', - files: {}, - params: {}, - }, - metadata: { jobId: 5 }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Missing required parameters for an identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: 'anon@2', - channel: 'web', - context: { - traits: { - age: 32, - phone: '+91 9299999999', - firstName: 'Test', - lastName: 'RudderStack', - ownerId: '14', - role: 'user', - source: 'rudder-sdk', - }, - }, - integrations: { - INTERCOM: { - lookup: 'phone', - }, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 6, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 6, - }, - statusCode: 400, - error: - 'Either email or userId is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForLatestVersion, ChildStep: undefined, OriginalError: Either email or userId is required for Identify call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Unauthorized error while searching contact for an identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@3', - channel: 'web', - context: { - traits: { - phone: '+91 9399999999', - email: 'test+3@rudderlabs.com', - firstName: 'Test', - lastName: 'Rudder', - ownerId: '15', - role: 'admin', - source: 'rudder-android-sdk', - }, - }, - integrations: { - INTERCOM: { - lookup: 'email', - }, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'invalidApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 7, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 7, - }, - statusCode: 401, - error: - '{"message":"{\\"message\\":\\"Unable to search contact due to : [{\\\\\\"code\\\\\\":\\\\\\"unauthorized\\\\\\",\\\\\\"message\\\\\\":\\\\\\"Access Token Invalid\\\\\\"}]: Workflow: procWorkflow, Step: searchContact, ChildStep: undefined, OriginalError: Unable to search contact due to : [{\\\\\\"code\\\\\\":\\\\\\"unauthorized\\\\\\",\\\\\\"message\\\\\\":\\\\\\"Access Token Invalid\\\\\\"}]\\",\\"destinationResponse\\":{\\"response\\":{\\"type\\":\\"error.list\\",\\"request_id\\":\\"request_1\\",\\"errors\\":[{\\"code\\":\\"unauthorized\\",\\"message\\":\\"Access Token Invalid\\"}]},\\"status\\":401}}","destinationResponse":{"response":{"type":"error.list","request_id":"request_1","errors":[{"code":"unauthorized","message":"Access Token Invalid"}]},"status":401}}', - statTags: { - errorCategory: 'network', - errorType: 'aborted', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Track call without event name', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@3', - channel: 'web', - context: { - traits: { - age: 32, - email: 'test+3@rudderlabs.com', - phone: '+91 9399999999', - firstName: 'Test', - lastName: 'RudderStack', - ownerId: '15', - }, - }, - properties: { - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - price: { - amount: 3000, - currency: 'USD', - }, - }, - type: 'track', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 8, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 8, - }, - statusCode: 400, - error: - 'Event name is required for track call: Workflow: procWorkflow, Step: trackPayload, ChildStep: undefined, OriginalError: Event name is required for track call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Successful track call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@2', - channel: 'web', - context: { - traits: { - age: 32, - email: 'test+2@rudderlabs.com', - phone: '+91 9299999999', - firstName: 'Test', - lastName: 'RudderStack', - ownerId: '14', - }, - }, - properties: { - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - price: { - amount: 3000, - currency: 'USD', - }, - }, - event: 'Product Viewed', - type: 'track', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 9, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - FORM: {}, - JSON: { - created_at: 1700628164, - email: 'test+2@rudderlabs.com', - event_name: 'Product Viewed', - metadata: { - price: { - amount: 3000, - currency: 'USD', - }, - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - }, - user_id: 'user@2', - }, - JSON_ARRAY: {}, - XML: {}, - }, - endpoint: 'https://api.intercom.io/events', - headers: { - Accept: 'application/json', - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - 'Intercom-Version': '2.10', - }, - method: 'POST', - type: 'REST', - userId: '', - version: '1', - params: {}, - files: {}, - }, - statusCode: 200, - metadata: { - jobId: 9, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Group call without groupId', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@4', - channel: 'web', - context: { - traits: { - email: 'test+4@rudderlabs.com', - phone: '+91 9499999999', - firstName: 'John', - lastName: 'Doe', - ownerId: '16', - }, - }, - traits: { - name: 'RudderStack', - size: 500, - website: 'www.rudderstack.com', - industry: 'CDP', - plan: 'enterprise', - }, - type: 'group', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 10, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 10, - }, - statusCode: 400, - error: - 'groupId is required for group call: Workflow: procWorkflow, Step: groupPayloadForLatestVersion, ChildStep: validateMessageAndPreparePayload, OriginalError: groupId is required for group call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Successful group call to create or update company', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@4', - groupId: 'rudderlabs', - channel: 'web', - context: { - traits: { - email: 'test+4@rudderlabs.com', - phone: '+91 9499999999', - firstName: 'John', - lastName: 'Doe', - ownerId: '16', - }, - }, - traits: { - name: 'RudderStack', - size: 500, - website: 'www.rudderstack.com', - industry: 'CDP', - plan: 'enterprise', - }, - type: 'group', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 11, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - company_id: 'rudderlabs', - industry: 'CDP', - name: 'RudderStack', - plan: 'enterprise', - size: 500, - website: 'www.rudderstack.com', - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.intercom.io/companies', - headers: { - Accept: 'application/json', - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - 'Intercom-Version': '2.10', - }, - method: 'POST', - type: 'REST', - userId: '', - version: '1', - params: {}, - files: {}, - }, - statusCode: 200, - metadata: { - jobId: 11, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Successful group call to add user to company', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@5', - groupId: 'rudderlabs', - channel: 'web', - context: { - traits: { - email: 'test+5@rudderlabs.com', - phone: '+91 9599999999', - firstName: 'John', - lastName: 'Snow', - ownerId: '17', - }, - }, - traits: { - name: 'RudderStack', - size: 500, - website: 'www.rudderstack.com', - industry: 'CDP', - plan: 'enterprise', - }, - type: 'group', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'eu', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 12, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - id: '657264e9018c0a647s45', - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.eu.intercom.io/contacts/70701240741e45d040/companies', - headers: { - Accept: 'application/json', - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - 'Intercom-Version': '2.10', - }, - method: 'POST', - type: 'REST', - userId: '', - version: '1', - params: {}, - files: {}, - }, - statusCode: 200, - metadata: { - jobId: 12, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Identify rEtl test', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - channel: 'web', - context: { - externalId: [ - { - id: 'user@1', - type: 'INTERCOM-customer', - identifierType: 'user_id', - }, - ], - mappedToDestination: 'true', - }, - traits: { - email: 'test@rudderlabs.com', - phone: '+91 9999999999', - name: 'Test Rudderlabs', - owner_id: 13, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 13, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - email: 'test@rudderlabs.com', - name: 'Test Rudderlabs', - phone: '+91 9999999999', - owner_id: 13, - user_id: 'user@1', - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.intercom.io/contacts', - headers: { - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - Accept: 'application/json', - 'Intercom-Version': '2.10', - }, - userId: '', - version: '1', - type: 'REST', - method: 'POST', - files: {}, - params: {}, - }, - metadata: { jobId: 13 }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Track rEtl test', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@1', - channel: 'web', - context: { - mappedToDestination: 'true', - }, - traits: { - event_name: 'Product Viewed', - user_id: 'user@1', - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - price: { - amount: 3000, - currency: 'USD', - }, - }, - event: 'Product Viewed', - type: 'track', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 14, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - event_name: 'Product Viewed', - price: { - amount: 3000, - currency: 'USD', - }, - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - user_id: 'user@1', - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.intercom.io/events', - headers: { - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - Accept: 'application/json', - 'Intercom-Version': '2.10', - }, - userId: '', - version: '1', - type: 'REST', - method: 'POST', - files: {}, - params: {}, - }, - metadata: { jobId: 14 }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - userId: 'test_user_id_1', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - address: { - city: 'Kolkata', - state: 'West Bengal', - }, - originalArray: [ - { - nested_field: 'nested value', - tags: ['tag_1', 'tag_2', 'tag_3'], - }, - { - nested_field: 'nested value', - tags: ['tag_1'], - }, - { - nested_field: 'nested value', - }, - ], - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 15, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'test_user_id_1', - email: 'test_1@test.com', - phone: '9876543210', - name: 'Test Name', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - 'address.city': 'Kolkata', - 'address.state': 'West Bengal', - 'originalArray[0].nested_field': 'nested value', - 'originalArray[0].tags[0]': 'tag_1', - 'originalArray[0].tags[1]': 'tag_2', - 'originalArray[0].tags[2]': 'tag_3', - 'originalArray[1].nested_field': 'nested value', - 'originalArray[1].tags[0]': 'tag_1', - 'originalArray[2].nested_field': 'nested value', - }, - update_last_request_at: true, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 15, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 16, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Test Name', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 16, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 17, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Name', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 17, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - firstName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 18, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Name', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 18, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old Version: Identify call without email and userId', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - firstName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 19, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - statusCode: 400, - error: - 'Either of `email` or `userId` is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForOlderVersion, ChildStep: undefined, OriginalError: Either of `email` or `userId` is required for Identify call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - metadata: { - jobId: 19, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - company: { - name: 'Test Comp', - id: 'company_id', - industry: 'test industry', - key1: 'value1', - key2: { - a: 'a', - }, - key3: [1, 2, 3], - }, - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 20, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Name', - companies: [ - { - company_id: 'company_id', - custom_attributes: { - key1: 'value1', - key2: '{"a":"a"}', - key3: '[1,2,3]', - }, - name: 'Test Comp', - industry: 'test industry', - }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 20, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - company: { - name: 'Test Comp', - industry: 'test industry', - key1: 'value1', - key2: null, - key3: ['value1', 'value2'], - key4: { - foo: 'bar', - }, - }, - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - updateLastRequestAt: false, - }, - }, - metadata: { - jobId: 21, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: false, - name: 'Name', - companies: [ - { - company_id: 'c0277b5c814453e5135f515f943d085a', - custom_attributes: { - key1: 'value1', - key3: '["value1","value2"]', - key4: '{"foo":"bar"}', - }, - name: 'Test Comp', - industry: 'test industry', - }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 21, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - company: { - industry: 'test industry', - key1: 'value1', - key2: null, - }, - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 22, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Name', - companies: [], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 22, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful track call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - userId: 'test_user_id_1', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - properties: { - property1: 1, - property2: 'test', - property3: true, - property4: '2020-10-05T09:09:03.731Z', - property5: { - property1: 1, - property2: 'test', - property3: { - subProp1: { - a: 'a', - b: 'b', - }, - subProp2: ['a', 'b'], - }, - }, - properties6: null, - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - price: { - amount: 3000, - currency: 'USD', - }, - article: { - url: 'https://example.org/ab1de.html', - value: 'the dude abides', - }, - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'track', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 23, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/events', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'test_user_id_1', - email: 'test_1@test.com', - event_name: 'Test Event 2', - created: 1601493061, - metadata: { - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - price: { - amount: 3000, - currency: 'USD', - }, - article: { - url: 'https://example.org/ab1de.html', - value: 'the dude abides', - }, - property1: 1, - property2: 'test', - property3: true, - property4: '2020-10-05T09:09:03.731Z', - 'property5.property1': 1, - 'property5.property2': 'test', - 'property5.property3.subProp1.a': 'a', - 'property5.property3.subProp1.b': 'b', - 'property5.property3.subProp2[0]': 'a', - 'property5.property3.subProp2[1]': 'b', - properties6: null, - }, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 23, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful track call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'track', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 24, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/events', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - event_name: 'Test Event 2', - created: 1601493061, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 24, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : Track call without email or userId', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'track', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 25, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - statusCode: 400, - error: - 'Either email or userId is required for Track call: Workflow: procWorkflow, Step: trackPayload, ChildStep: undefined, OriginalError: Either email or userId is required for Track call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - metadata: { - jobId: 25, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - externalId: [ - { - id: '10156', - type: 'INTERCOM-customer', - identifierType: 'user_id', - }, - ], - mappedToDestination: 'true', - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 26, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - update_last_request_at: true, - user_id: '10156', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 26, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - sendAnonymousId: true, - }, - }, - metadata: { - jobId: 27, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - phone: '9876543210', - name: 'Test Name', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - user_id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - update_last_request_at: true, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 27, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : Identify call without email or userId', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 28, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - statusCode: 400, - error: - 'Either of `email` or `userId` is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForOlderVersion, ChildStep: undefined, OriginalError: Either of `email` or `userId` is required for Identify call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - metadata: { - jobId: 28, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful group call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - groupId: 'test_company_id_wdasda', - traits: { - employees: 450, - plan: 'basic', - userId: 'sdfrsdfsdfsf', - email: 'test@test.com', - name: 'rudderUpdate', - size: '50', - industry: 'IT', - monthlySpend: '2131231', - remoteCreatedAt: '1683017572', - key1: 'val1', - }, - anonymousId: 'sdfrsdfsdfsf', - integrations: { - All: true, - }, - type: 'group', - userId: 'sdfrsdfsdfsf', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'abcd=', - appId: 'asdasdasd', - apiVersion: 'v1', - collectContext: false, - }, - }, - metadata: { - jobId: 29, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/companies', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - plan: 'basic', - size: 50, - industry: 'IT', - monthly_spend: 2131231, - remote_created_at: 1683017572, - custom_attributes: { - employees: 450, - email: 'test@test.com', - key1: 'val1', - }, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'sdfrsdfsdfsf', - }, - statusCode: 200, - metadata: { - jobId: 29, - }, - }, - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'sdfrsdfsdfsf', - companies: [ - { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'sdfrsdfsdfsf', - }, - statusCode: 200, - metadata: { - jobId: 29, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful group call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - groupId: 'test_company_id', - traits: { - plan: 'basic', - name: 'rudderUpdate', - size: 50, - industry: 'IT', - monthlySpend: '2131231', - email: 'comanyemail@abc.com', - }, - anonymousId: '12312312', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - userAgent: 'unknown', - }, - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - type: 'group', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'abcd=', - apiVersion: 'v1', - appId: 'asdasdasd', - collectContext: false, - }, - }, - metadata: { - jobId: 30, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/companies', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - company_id: 'test_company_id', - name: 'rudderUpdate', - plan: 'basic', - size: 50, - industry: 'IT', - monthly_spend: 2131231, - custom_attributes: { - email: 'comanyemail@abc.com', - }, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '12312312', - }, - statusCode: 200, - metadata: { - jobId: 30, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful group call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - groupId: 'test_company_id_wdasda', - context: { - traits: { - email: 'testUser@test.com', - }, - }, - traits: { - employees: 450, - plan: 'basic', - email: 'test@test.com', - name: 'rudderUpdate', - size: '50', - industry: 'IT', - website: 'url', - monthlySpend: '2131231', - remoteCreatedAt: '1683017572', - key1: 'val1', - }, - anonymousId: 'sdfrsdfsdfsf', - integrations: { - All: true, - }, - type: 'group', - userId: 'sdfrsdfsdfsf', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'abcd=', - apiVersion: 'v1', - appId: 'asdasdasd', - collectContext: false, - }, - }, - metadata: { - jobId: 31, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/companies', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - plan: 'basic', - size: 50, - website: 'url', - industry: 'IT', - monthly_spend: 2131231, - remote_created_at: 1683017572, - custom_attributes: { - employees: 450, - email: 'test@test.com', - key1: 'val1', - }, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'sdfrsdfsdfsf', - }, - statusCode: 200, - metadata: { - jobId: 31, - }, - }, - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'sdfrsdfsdfsf', - email: 'testUser@test.com', - companies: [ - { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'sdfrsdfsdfsf', - }, - statusCode: 200, - metadata: { - jobId: 31, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful group call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - groupId: 'test_company_id_wdasda', - context: { - traits: { - email: 'testUser@test.com', - }, - }, - traits: { - employees: 450, - plan: 'basic', - email: 'test@test.com', - name: 'rudderUpdate', - size: '50', - industry: 'IT', - website: 'url', - monthlySpend: '2131231', - remoteCreatedAt: '1683017572', - key1: 'val1', - key2: { - a: 'a', - b: 'b', - }, - key3: [1, 2, 3], - key4: null, - }, - anonymousId: 'anonId', - integrations: { - All: true, - }, - type: 'group', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'abcd=', - appId: 'asdasdasd', - apiVersion: 'v1', - collectContext: false, - sendAnonymousId: true, - }, - }, - metadata: { - jobId: 32, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/companies', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - plan: 'basic', - size: 50, - website: 'url', - industry: 'IT', - monthly_spend: 2131231, - remote_created_at: 1683017572, - custom_attributes: { - employees: 450, - email: 'test@test.com', - key1: 'val1', - 'key2.a': 'a', - 'key2.b': 'b', - 'key3[0]': 1, - 'key3[1]': 2, - 'key3[2]': 3, - key4: null, - }, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'anonId', - }, - statusCode: 200, - metadata: { - jobId: 32, - }, - }, - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'anonId', - email: 'testUser@test.com', - companies: [ - { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'anonId', - }, - statusCode: 200, - metadata: { - jobId: 32, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Test 0', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - userId: 'test_user_id_1', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - address: { - city: 'Kolkata', - state: 'West Bengal', - }, - originalArray: [ - { - nested_field: 'nested value', - tags: ['tag_1', 'tag_2', 'tag_3'], - }, - { - nested_field: 'nested value', - tags: ['tag_1'], - }, - { - nested_field: 'nested value', - }, - ], - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - Config: { - apiKey: 'intercomApiKey', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'test_user_id_1', - email: 'test_1@test.com', - phone: '9876543210', - name: 'Test Name', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - 'address.city': 'Kolkata', - 'address.state': 'West Bengal', - 'originalArray[0].nested_field': 'nested value', - 'originalArray[0].tags[0]': 'tag_1', - 'originalArray[0].tags[1]': 'tag_2', - 'originalArray[0].tags[2]': 'tag_3', - 'originalArray[1].nested_field': 'nested value', - 'originalArray[1].tags[0]': 'tag_1', - 'originalArray[2].nested_field': 'nested value', - }, - update_last_request_at: true, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Test 1', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - Config: { - apiKey: 'intercomApiKey', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Test Name', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Test 2', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - Config: { - apiKey: 'intercomApiKey', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Name', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - }, - ], - }, - }, - }, + ...identifyTestData, + ...trackTestData, + ...groupTestData, + ...validationTestData, ]; diff --git a/test/integrations/destinations/intercom/processor/groupTestData.ts b/test/integrations/destinations/intercom/processor/groupTestData.ts new file mode 100644 index 0000000000..cb81df7bd2 --- /dev/null +++ b/test/integrations/destinations/intercom/processor/groupTestData.ts @@ -0,0 +1,509 @@ +import { Destination } from '../../../../../src/types'; +import { + generateMetadata, + transformResultBuilder, + generateSimplifiedGroupPayload, +} from '../../../testUtils'; + +const v1Config = { + apiKey: 'abcd=', + appId: 'asdasdasd', + apiVersion: 'v1', + collectContext: false, +}; + +const v2Config = { + apiKey: 'testApiKey', + apiVersion: 'v2', + apiServer: 'standard', + sendAnonymousId: false, +}; + +const v1Headers = { + 'Content-Type': 'application/json', + Authorization: 'Bearer abcd=', + Accept: 'application/json', + 'Intercom-Version': '1.4', +}; + +const v2Headers = { + Accept: 'application/json', + Authorization: 'Bearer testApiKey', + 'Content-Type': 'application/json', + 'Intercom-Version': '2.10', +}; + +const destination: Destination = { + ID: '123', + Name: 'intercom', + DestinationDefinition: { + ID: '123', + Name: 'intercom', + DisplayName: 'Intercom', + Config: { + cdkV2Enabled: true, + }, + }, + Config: {}, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const v1Destination = { ...destination, Config: v1Config }; +const v2Destination = { ...destination, Config: v2Config }; + +const userTraits = { + ownerId: '17', + firstName: 'John', + lastName: 'Snow', + phone: '+91 9599999999', + email: 'test+5@rudderlabs.com', +}; + +const group1Traits = { + size: 500, + industry: 'CDP', + plan: 'enterprise', + name: 'RudderStack', + website: 'www.rudderstack.com', +}; + +const group2Traits = { + size: '50', + key1: 'val1', + plan: 'basic', + industry: 'IT', + employees: 450, + monthlySpend: '2131231', + userId: 'sdfrsdfsdfsf', + email: 'test@test.com', + name: 'rudderUpdate', + remoteCreatedAt: '1683017572', +}; + +const timestamp = '2023-11-22T10:12:44.757+05:30'; +const originalTimestamp = '2023-11-10T14:42:44.724Z'; + +const endpoint = 'https://api.intercom.io/companies'; + +export const groupTestData = [ + { + id: 'intercom-group-test-1', + name: 'intercom', + description: 'V2 version : Successful group call to create or update company', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create or update company payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: generateSimplifiedGroupPayload({ + userId: 'user@4', + groupId: 'rudderlabs', + context: { + traits: { email: 'test+4@rudderlabs.com' }, + }, + traits: group1Traits, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint, + headers: v2Headers, + JSON: { company_id: 'rudderlabs', ...group1Traits }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-group-test-2', + name: 'intercom', + description: 'V2 version : Successful group call to add user to company', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain add user to company payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...v2Destination, Config: { ...v2Destination.Config, apiServer: 'eu' } }, + message: generateSimplifiedGroupPayload({ + userId: 'user@5', + groupId: 'rudderlabs', + context: { + traits: userTraits, + }, + traits: group1Traits, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint: 'https://api.eu.intercom.io/contacts/70701240741e45d040/companies', + headers: v2Headers, + JSON: { id: '657264e9018c0a647s45' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-group-test-3', + name: 'intercom', + description: + 'V1 version : successful group call to create company and add user to company based on userId', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create company and add user to company payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: generateSimplifiedGroupPayload({ + userId: 'sdfrsdfsdfsf', + anonymousId: 'sdfrsdfsdfsf', + groupId: 'test_company_id_wdasda', + context: { + traits: {}, + }, + traits: group2Traits, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: 'sdfrsdfsdfsf', + endpoint, + headers: v1Headers, + JSON: { + company_id: 'test_company_id_wdasda', + custom_attributes: { + email: 'test@test.com', + employees: 450, + key1: 'val1', + }, + industry: 'IT', + monthly_spend: 2131231, + name: 'rudderUpdate', + plan: 'basic', + remote_created_at: 1683017572, + size: 50, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + { + output: transformResultBuilder({ + userId: 'sdfrsdfsdfsf', + endpoint: 'https://api.intercom.io/users', + headers: v1Headers, + JSON: { + companies: [ + { + name: 'rudderUpdate', + company_id: 'test_company_id_wdasda', + }, + ], + user_id: 'sdfrsdfsdfsf', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-group-test-4', + name: 'intercom', + description: + 'V1 version : successful group call to create company and add user to company based on userId', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create company and add user to company payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: generateSimplifiedGroupPayload({ + userId: 'sdfrsdfsdfsf', + anonymousId: 'sdfrsdfsdfsf', + groupId: 'test_company_id_wdasda', + context: { + traits: { + email: 'testUser@test.com', + }, + }, + traits: { ...group2Traits, website: 'url' }, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: 'sdfrsdfsdfsf', + endpoint, + headers: v1Headers, + JSON: { + company_id: 'test_company_id_wdasda', + custom_attributes: { + email: 'test@test.com', + employees: 450, + key1: 'val1', + }, + industry: 'IT', + monthly_spend: 2131231, + name: 'rudderUpdate', + plan: 'basic', + remote_created_at: 1683017572, + size: 50, + website: 'url', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + { + output: transformResultBuilder({ + userId: 'sdfrsdfsdfsf', + endpoint: 'https://api.intercom.io/users', + headers: v1Headers, + JSON: { + companies: [ + { + name: 'rudderUpdate', + company_id: 'test_company_id_wdasda', + }, + ], + email: 'testUser@test.com', + user_id: 'sdfrsdfsdfsf', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-group-test-5', + name: 'intercom', + description: + 'V1 version : successful group call without userId (anonId will be considered as userId)', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create company and add user to company payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...v1Destination, Config: v1Destination.Config, sendAnonymousId: true }, + message: { + anonymousId: 'anonId', + groupId: 'test_company_id_wdasda', + context: { + traits: { + email: 'testUser@test.com', + }, + }, + traits: { + ...group2Traits, + website: 'url', + key1: 'val1', + key2: { + a: 'a', + b: 'b', + }, + key3: [1, 2, 3], + key4: null, + }, + type: 'group', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: 'anonId', + endpoint, + headers: v1Headers, + JSON: { + company_id: 'test_company_id_wdasda', + custom_attributes: { + email: 'test@test.com', + employees: 450, + key1: 'val1', + 'key2.a': 'a', + 'key2.b': 'b', + 'key3[0]': 1, + 'key3[1]': 2, + 'key3[2]': 3, + key4: null, + }, + industry: 'IT', + monthly_spend: 2131231, + name: 'rudderUpdate', + plan: 'basic', + remote_created_at: 1683017572, + size: 50, + website: 'url', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + { + output: transformResultBuilder({ + userId: 'anonId', + endpoint: 'https://api.intercom.io/users', + headers: v1Headers, + JSON: { + companies: [ + { + name: 'rudderUpdate', + company_id: 'test_company_id_wdasda', + }, + ], + email: 'testUser@test.com', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-group-test-6', + name: 'intercom', + description: 'V1 version : successful group call with email as custom attribute', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create company payload with email as custom attribute', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '12312312', + groupId: 'test_company_id', + context: { + traits: {}, + }, + traits: { ...group1Traits, monthlySpend: '2131231', email: 'comanyemail@abc.com' }, + type: 'group', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '12312312', + endpoint, + headers: v1Headers, + JSON: { + ...group1Traits, + custom_attributes: { + email: 'comanyemail@abc.com', + }, + monthly_spend: 2131231, + company_id: 'test_company_id', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/intercom/processor/identifyTestData.ts b/test/integrations/destinations/intercom/processor/identifyTestData.ts new file mode 100644 index 0000000000..d88b7cf7f5 --- /dev/null +++ b/test/integrations/destinations/intercom/processor/identifyTestData.ts @@ -0,0 +1,1025 @@ +import { Destination } from '../../../../../src/types'; +import { + generateMetadata, + transformResultBuilder, + generateSimplifiedIdentifyPayload, +} from '../../../testUtils'; + +const v1Config = { + apiKey: 'intercomApiKey', + apiVersion: 'v1', + appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', + collectContext: false, +}; + +const v2Config = { + apiKey: 'testApiKey', + apiVersion: 'v2', + apiServer: 'standard', + sendAnonymousId: false, +}; + +const v2Headers = { + Accept: 'application/json', + Authorization: 'Bearer testApiKey', + 'Content-Type': 'application/json', + 'Intercom-Version': '2.10', +}; + +const v1Headers = { + 'Content-Type': 'application/json', + Authorization: 'Bearer intercomApiKey', + Accept: 'application/json', + 'Intercom-Version': '1.4', +}; + +const destination: Destination = { + ID: '123', + Name: 'intercom', + DestinationDefinition: { + ID: '123', + Name: 'intercom', + DisplayName: 'Intercom', + Config: { + cdkV2Enabled: true, + }, + }, + Config: {}, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const v1Destination = { ...destination, Config: v1Config }; +const v2Destination = { ...destination, Config: v2Config }; + +const user1Traits = { + age: 23, + ownerId: '13', + firstName: 'Test', + lastName: 'Rudderlabs', + phone: '+91 9999999999', + address: 'california usa', + email: 'test@rudderlabs.com', + lastSeenAt: '2023-11-10T14:42:44.724Z', +}; + +const user2Traits = { + age: 32, + ownerId: '14', + firstName: 'Test', + lastName: 'RudderStack', + phone: '+91 9299999999', + email: 'test+2@rudderlabs.com', +}; + +const user3Traits = { + owner_id: 13, + name: 'Test Rudderlabs', + phone: '+91 9999999999', + email: 'test@rudderlabs.com', +}; + +const user4Traits = { + key1: 'value1', + name: 'Test Name', + firstName: 'Test', + lastName: 'Name', + phone: '9876543210', + userId: 'test_user_id_1', + email: 'test_1@test.com', + createdAt: '2020-09-30T19:11:00.337Z', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + address: { + city: 'Kolkata', + state: 'West Bengal', + }, + originalArray: [ + { + nested_field: 'nested value', + tags: ['tag_1', 'tag_2', 'tag_3'], + }, + { + nested_field: 'nested value', + tags: ['tag_1'], + }, + { + nested_field: 'nested value', + }, + ], +}; + +const user5Traits = { + firstName: 'Test', + lastName: 'Name', + key1: 'value1', + phone: '9876543210', + email: 'test_1@test.com', + createdAt: '2020-09-30T19:11:00.337Z', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', +}; + +const user6Traits = { + lastName: 'Name', + key1: 'value1', + phone: '9876543210', + email: 'test_1@test.com', + createdAt: '2020-09-30T19:11:00.337Z', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + company: { + key1: 'value1', + name: 'Test Comp', + id: 'company_id', + industry: 'test industry', + key2: { + a: 'a', + }, + key3: [1, 2, 3], + }, +}; + +const expectedUser1Traits = { + owner_id: 13, + external_id: 'user@1', + last_seen_at: 1699627364, + name: 'Test Rudderlabs', + phone: '+91 9999999999', + email: 'test@rudderlabs.com', + custom_attributes: { + age: 23, + address: 'california usa', + }, +}; + +const expectedUser2Traits = { + owner_id: 14, + external_id: 'user@2', + name: 'Test RudderStack', + phone: '+91 9299999999', + email: 'test+2@rudderlabs.com', + custom_attributes: { + age: 32, + }, +}; + +const expectedUser3Traits = { + owner_id: 13, + user_id: 'user@1', + name: 'Test Rudderlabs', + phone: '+91 9999999999', + email: 'test@rudderlabs.com', +}; + +const expectedUser4Traits = { + name: 'Test Name', + phone: '9876543210', + email: 'test_1@test.com', + signed_up_at: 1601493060, + user_id: 'test_user_id_1', + last_seen_user_agent: 'unknown', + custom_attributes: { + key1: 'value1', + 'address.city': 'Kolkata', + 'address.state': 'West Bengal', + 'originalArray[0].nested_field': 'nested value', + 'originalArray[0].tags[0]': 'tag_1', + 'originalArray[0].tags[1]': 'tag_2', + 'originalArray[0].tags[2]': 'tag_3', + 'originalArray[1].nested_field': 'nested value', + 'originalArray[1].tags[0]': 'tag_1', + 'originalArray[2].nested_field': 'nested value', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + }, + update_last_request_at: true, +}; + +const expectedUser5Traits = { + name: 'Test Name', + phone: '9876543210', + email: 'test_1@test.com', + signed_up_at: 1601493060, + update_last_request_at: true, + last_seen_user_agent: 'unknown', + custom_attributes: { + key1: 'value1', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + }, +}; + +const expectedUser6Traits = { + name: 'Name', + phone: '9876543210', + email: 'test_1@test.com', + signed_up_at: 1601493060, + last_seen_user_agent: 'unknown', + update_last_request_at: true, + custom_attributes: { + key1: 'value1', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + }, + companies: [ + { + name: 'Test Comp', + industry: 'test industry', + company_id: 'company_id', + custom_attributes: { + key1: 'value1', + key2: '{"a":"a"}', + key3: '[1,2,3]', + }, + }, + ], +}; + +const timestamp = '2023-11-22T10:12:44.757+05:30'; +const originalTimestamp = '2023-11-10T14:42:44.724Z'; + +const v2Endpoint = 'https://api.intercom.io/contacts'; +const v1Endpoint = 'https://api.intercom.io/users'; + +export const identifyTestData = [ + { + id: 'intercom-identify-test-1', + name: 'intercom', + description: 'V2 version : Create customer with email as lookup field', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: generateSimplifiedIdentifyPayload({ + userId: 'user@1', + context: { + traits: user1Traits, + }, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint: v2Endpoint, + headers: v2Headers, + JSON: expectedUser1Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-2', + name: 'intercom', + description: 'V2 version : Update customer with email as lookup field', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain update user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: generateSimplifiedIdentifyPayload({ + userId: 'user@2', + context: { + traits: user2Traits, + }, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint: `${v2Endpoint}/7070129940741e45d040`, + headers: v2Headers, + method: 'PUT', + JSON: expectedUser2Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-3', + name: 'intercom', + description: 'V2 version : Identify rEtl test', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + context: { + externalId: [ + { + id: 'user@1', + type: 'INTERCOM-customer', + identifierType: 'user_id', + }, + ], + mappedToDestination: 'true', + }, + traits: user3Traits, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint: v2Endpoint, + headers: v2Headers, + method: 'POST', + JSON: expectedUser3Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-4', + name: 'intercom', + description: 'V1 version : successful identify call to create user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user4Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser4Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-5', + name: 'intercom', + description: 'V1 version : successful identify call to create user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user5Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser5Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-6', + name: 'intercom', + description: 'V1 version : successful identify call to update user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain update user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: { ...user5Traits, firstName: undefined }, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { ...expectedUser5Traits, name: 'Name' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-7', + name: 'intercom', + description: 'V1 version : successful identify call to update user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain update user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: { ...user5Traits, lastName: undefined }, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { ...expectedUser5Traits, name: 'Test' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-8', + name: 'intercom', + description: 'V1 version : successful identify call to create user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user6Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser6Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-9', + name: 'intercom', + description: 'V1 version : successful identify call to create user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: { + ...user6Traits, + company: { + name: 'Test Comp', + industry: 'test industry', + key1: 'value1', + key2: null, + key3: ['value1', 'value2'], + key4: { + foo: 'bar', + }, + }, + }, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { + ...expectedUser6Traits, + companies: [ + { + ...expectedUser6Traits.companies[0], + custom_attributes: { + key1: 'value1', + key3: '["value1","value2"]', + key4: '{"foo":"bar"}', + }, + company_id: 'c0277b5c814453e5135f515f943d085a', + }, + ], + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-10', + name: 'intercom', + description: 'V1 version : successful identify call to update user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain update user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: { + ...user5Traits, + firstName: undefined, + company: { + industry: 'test industry', + key1: 'value1', + key2: null, + }, + }, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { ...expectedUser5Traits, companies: [], name: 'Name' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-11', + name: 'intercom', + description: + 'No Version : Successful identify call to create user without giving apiVersion in configuration', + scenario: 'Business', + successCriteria: + 'Response should take v1 apiVersion by default and response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...v1Destination, apiVersion: undefined }, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user4Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser4Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-12', + name: 'intercom', + description: + 'No Version : Successful identify call to create user without giving apiVersion in configuration', + scenario: 'Business', + successCriteria: + 'Response should take v1 apiVersion by default and response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...v1Destination, apiVersion: undefined }, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user5Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser5Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-13', + name: 'intercom', + description: + 'No Version : Successful identify call to update user without giving apiVersion in configuration', + scenario: 'Business', + successCriteria: + 'Response should take v1 apiVersion by default and response status code should be 200 and response should contain update user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...v1Destination, apiVersion: undefined }, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: { ...user5Traits, firstName: undefined }, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { ...expectedUser5Traits, name: 'Name' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-14', + name: 'intercom', + description: + 'V1 version : Successful identify call to update user with sendAnonymousId configuration set to true', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain update user payload with all traits and userId should be equal to anonymousId', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user5Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser5Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-15', + name: 'intercom', + description: 'V1 version : Identify rEtl test', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + context: { + externalId: [ + { + id: '10156', + type: 'INTERCOM-customer', + identifierType: 'user_id', + }, + ], + mappedToDestination: 'true', + traits: user5Traits, + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { + ...user5Traits, + user_id: '10156', + name: 'Test Name', + update_last_request_at: true, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/intercom/processor/trackTestData.ts b/test/integrations/destinations/intercom/processor/trackTestData.ts new file mode 100644 index 0000000000..15bed25d68 --- /dev/null +++ b/test/integrations/destinations/intercom/processor/trackTestData.ts @@ -0,0 +1,361 @@ +import { Destination } from '../../../../../src/types'; +import { + generateMetadata, + transformResultBuilder, + generateSimplifiedTrackPayload, +} from '../../../testUtils'; + +const v1Config = { + apiKey: 'intercomApiKey', + apiVersion: 'v1', + appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', + collectContext: false, +}; + +const v2Config = { + apiKey: 'testApiKey', + apiVersion: 'v2', + apiServer: 'standard', + sendAnonymousId: false, +}; + +const v1Headers = { + 'Content-Type': 'application/json', + Authorization: 'Bearer intercomApiKey', + Accept: 'application/json', + 'Intercom-Version': '1.4', +}; + +const v2Headers = { + Accept: 'application/json', + Authorization: 'Bearer testApiKey', + 'Content-Type': 'application/json', + 'Intercom-Version': '2.10', +}; + +const destination: Destination = { + ID: '123', + Name: 'intercom', + DestinationDefinition: { + ID: '123', + Name: 'intercom', + DisplayName: 'Intercom', + Config: { + cdkV2Enabled: true, + }, + }, + Config: {}, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const v1Destination = { ...destination, Config: v1Config }; +const v2Destination = { ...destination, Config: v2Config }; + +const userTraits = { + age: 23, + ownerId: '13', + firstName: 'Test', + lastName: 'Rudderlabs', + phone: '+91 9999999999', + address: 'california usa', + email: 'test@rudderlabs.com', + lastSeenAt: '2023-11-10T14:42:44.724Z', +}; + +const properties = { + revenue: { + amount: 1232, + currency: 'inr', + test: 123, + }, + price: { + amount: 3000, + currency: 'USD', + }, +}; + +const nestedProperties = { + property1: 1, + property2: 'test', + property3: true, + property4: '2020-10-05T09:09:03.731Z', + property5: { + property1: 1, + property2: 'test', + property3: { + subProp1: { + a: 'a', + b: 'b', + }, + subProp2: ['a', 'b'], + }, + }, + properties6: null, + revenue: { + amount: 1232, + currency: 'inr', + test: 123, + }, + price: { + amount: 3000, + currency: 'USD', + }, + article: { + url: 'https://example.org/ab1de.html', + value: 'the dude abides', + }, +}; + +const expectedNestedProperties = { + revenue: { + amount: 1232, + currency: 'inr', + test: 123, + }, + price: { + amount: 3000, + currency: 'USD', + }, + article: { + url: 'https://example.org/ab1de.html', + value: 'the dude abides', + }, + property1: 1, + property2: 'test', + property3: true, + property4: '2020-10-05T09:09:03.731Z', + 'property5.property1': 1, + 'property5.property2': 'test', + 'property5.property3.subProp1.a': 'a', + 'property5.property3.subProp1.b': 'b', + 'property5.property3.subProp2[0]': 'a', + 'property5.property3.subProp2[1]': 'b', + properties6: null, +}; + +const expectedOutput = { + user_id: 'user@2', + created: 1699627364, + event_name: 'Test Event 2', + email: 'test@rudderlabs.com', +}; + +const timestamp = '2023-11-22T10:12:44.757+05:30'; +const originalTimestamp = '2023-11-10T14:42:44.724Z'; + +const endpoint = 'https://api.intercom.io/events'; + +export const trackTestData = [ + { + id: 'intercom-track-test-1', + name: 'intercom', + description: 'V2 version : Successful track call', + scenario: 'Business', + successCriteria: + "Response status code should be 200 and response should contain event name and it's properties", + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: generateSimplifiedTrackPayload({ + userId: 'user@2', + event: 'Product Viewed', + context: { + traits: userTraits, + }, + properties, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint, + headers: v2Headers, + JSON: { + user_id: 'user@2', + metadata: properties, + created_at: 1699627364, + event_name: 'Product Viewed', + email: 'test@rudderlabs.com', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-track-test-2', + name: 'intercom', + description: 'V2 version : Track rEtl test', + scenario: 'Business', + successCriteria: + "Response status code should be 200 and response should contain event name and it's properties", + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + userId: 'user@2', + event: 'Product Viewed', + context: { + mappedToDestination: 'true', + }, + traits: { + ...properties, + user_id: 'user@1', + event_name: 'Product Viewed', + }, + type: 'track', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint, + headers: v2Headers, + JSON: { + ...properties, + user_id: 'user@1', + event_name: 'Product Viewed', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-track-test-3', + name: 'intercom', + description: 'V1 version : successful track call with nested properties', + scenario: 'Business', + successCriteria: + "Response status code should be 200 and response should contain event name and it's properties", + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: generateSimplifiedTrackPayload({ + userId: 'user@2', + event: 'Test Event 2', + context: { + traits: userTraits, + }, + properties: nestedProperties, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: 'default-anonymousId', + endpoint, + headers: v1Headers, + JSON: { + ...expectedOutput, + metadata: { + ...expectedNestedProperties, + }, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-track-test-4', + name: 'intercom', + description: 'V1 version : successful track call without properties', + scenario: 'Business', + successCriteria: 'Response status code should be 200 and response should contain event name', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: generateSimplifiedTrackPayload({ + userId: 'user@2', + event: 'Test Event 2', + context: { + traits: userTraits, + }, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + endpoint, + headers: v1Headers, + JSON: expectedOutput, + userId: 'default-anonymousId', + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/intercom/processor/validationTestData.ts b/test/integrations/destinations/intercom/processor/validationTestData.ts new file mode 100644 index 0000000000..45fe3c1b9e --- /dev/null +++ b/test/integrations/destinations/intercom/processor/validationTestData.ts @@ -0,0 +1,554 @@ +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; +import { generateMetadata } from '../../../testUtils'; + +const v1Config = { + apiKey: 'intercomApiKey', + apiVersion: 'v1', + appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', + collectContext: false, +}; + +const v2Config = { + apiKey: 'testApiKey', + apiVersion: 'v2', + apiServer: 'standard', + sendAnonymousId: false, +}; + +const destination: Destination = { + ID: '123', + Name: 'intercom', + DestinationDefinition: { + ID: '123', + Name: 'intercom', + DisplayName: 'Intercom', + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + apiKey: 'testApiKey', + apiVersion: 'v2', + apiServer: 'standard', + sendAnonymousId: false, + }, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const v1Destination = { ...destination, Config: v1Config }; +const v2Destination = { ...destination, Config: v2Config }; + +const userTraits = { + age: 23, + ownerId: '14', + role: 'user', + source: 'rudder-sdk', + firstname: 'Test', + lastName: 'RudderStack', + phone: '+91 9299999999', + birthday: '2022-05-13T12:51:01.470Z', +}; + +const properties = { + revenue: { + amount: 1232, + currency: 'inr', + test: 123, + }, + price: { + amount: 3000, + currency: 'USD', + }, +}; + +const groupTraits = { + name: 'RudderStack', + size: 500, + website: 'www.rudderstack.com', + industry: 'CDP', + plan: 'enterprise', +}; + +const expectedStatTags = { + destType: 'INTERCOM', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', +}; + +export const validationTestData: ProcessorTestData[] = [ + { + id: 'intercom-validation-test-1', + name: 'intercom', + description: '[Error - V2 version]: Check for no message type', + scenario: 'Framework', + successCriteria: 'Response status code should be 400 with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + event: 'Product Searched', + context: { + traits: userTraits, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'message Type is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: message Type is not present. Aborting', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-2', + name: 'intercom', + description: '[Error - V2 version]: Check for unsupported message type', + scenario: 'Framework', + successCriteria: + 'Response should contain error message and status code should be 400, as we are sending a message type which is not supported by intercom destination and the error message should be Event type alias is not supported', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + userId: 'user@45', + type: 'page', + context: { + traits: userTraits, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'message type page is not supported: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: message type page is not supported', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-3', + name: 'intercom', + description: '[Error - V2 version]: Missing required config', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw configuration error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + ...v2Destination, + Config: { ...v2Destination.Config, apiKey: null }, + }, + message: { + userId: 'user@1', + type: 'identify', + context: { + traits: userTraits, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Access Token is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Access Token is not present. Aborting', + statTags: { ...expectedStatTags, errorType: 'configuration' }, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-4', + name: 'intercom', + description: '[Error - V2 version]: Missing required parameters for an identify call', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + anonymousId: 'anon@2', + type: 'identify', + context: { + traits: userTraits, + }, + integrations: { + INTERCOM: { + lookup: 'phone', + }, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Either email or userId is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForLatestVersion, ChildStep: undefined, OriginalError: Either email or userId is required for Identify call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-5', + name: 'intercom', + description: '[Error - V2 version]: Missing required parameters for an identify call', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + anonymousId: 'anon@2', + type: 'identify', + context: { + traits: userTraits, + }, + integrations: { + INTERCOM: { + lookup: 'phone', + }, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Either email or userId is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForLatestVersion, ChildStep: undefined, OriginalError: Either email or userId is required for Identify call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-6', + name: 'intercom', + description: + '[Error - V2 version]: Unauthorized error while searching contact for an identify call', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw network error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + ...v2Destination, + Config: { ...v2Destination.Config, apiKey: 'invalidApiKey' }, + }, + message: { + userId: 'user@3', + type: 'identify', + context: { + traits: { + phone: '+91 9399999999', + email: 'test+3@rudderlabs.com', + firstName: 'Test', + lastName: 'Rudder', + ownerId: '15', + role: 'admin', + source: 'rudder-android-sdk', + }, + }, + integrations: { + INTERCOM: { + lookup: 'email', + }, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + '{"message":"{\\"message\\":\\"Unable to search contact due to : [{\\\\\\"code\\\\\\":\\\\\\"unauthorized\\\\\\",\\\\\\"message\\\\\\":\\\\\\"Access Token Invalid\\\\\\"}]: Workflow: procWorkflow, Step: searchContact, ChildStep: undefined, OriginalError: Unable to search contact due to : [{\\\\\\"code\\\\\\":\\\\\\"unauthorized\\\\\\",\\\\\\"message\\\\\\":\\\\\\"Access Token Invalid\\\\\\"}]\\",\\"destinationResponse\\":{\\"response\\":{\\"type\\":\\"error.list\\",\\"request_id\\":\\"request_1\\",\\"errors\\":[{\\"code\\":\\"unauthorized\\",\\"message\\":\\"Access Token Invalid\\"}]},\\"status\\":401}}","destinationResponse":{"response":{"type":"error.list","request_id":"request_1","errors":[{"code":"unauthorized","message":"Access Token Invalid"}]},"status":401}}', + statTags: { ...expectedStatTags, errorCategory: 'network', errorType: 'aborted' }, + statusCode: 401, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-7', + name: 'intercom', + description: '[Error - V2 version]: Track call without event name', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + userId: 'user@3', + type: 'track', + context: { + traits: userTraits, + }, + properties, + timestamp: '2023-11-22T10:12:44.757+05:30', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Event name is required for track call: Workflow: procWorkflow, Step: trackPayload, ChildStep: undefined, OriginalError: Event name is required for track call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-8', + name: 'intercom', + description: '[Error - V2 version]: Group call without groupId', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + userId: 'user@4', + type: 'group', + context: { + traits: { + email: 'test+4@rudderlabs.com', + phone: '+91 9499999999', + firstName: 'John', + lastName: 'Doe', + ownerId: '16', + }, + }, + traits: groupTraits, + timestamp: '2023-11-22T10:12:44.757+05:30', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'groupId is required for group call: Workflow: procWorkflow, Step: groupPayloadForLatestVersion, ChildStep: validateMessageAndPreparePayload, OriginalError: groupId is required for group call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-9', + name: 'intercom', + description: '[Error - V1 version]: Identify call without email and userId', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + type: 'identify', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: userTraits, + }, + timestamp: '2023-11-22T10:12:44.757+05:30', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Either of `email` or `userId` is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForOlderVersion, ChildStep: undefined, OriginalError: Either of `email` or `userId` is required for Identify call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-10', + name: 'intercom', + description: '[Error - V1 version]: Track call without email or userId', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + type: 'track', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: userTraits, + }, + event: 'Test Event 2', + timestamp: '2023-11-22T10:12:44.757+05:30', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Either email or userId is required for Track call: Workflow: procWorkflow, Step: trackPayload, ChildStep: undefined, OriginalError: Either email or userId is required for Track call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; From 2a63f128c562bd527491cdd653ced3f689d73a06 Mon Sep 17 00:00:00 2001 From: ItsSudip Date: Wed, 17 Apr 2024 08:42:57 +0530 Subject: [PATCH 19/25] feat: remove redundant data from traits in hubspot --- src/v0/destinations/hs/HSTransform-v2.js | 2 +- test/integrations/destinations/hs/processor/data.ts | 1 - test/integrations/destinations/hs/router/data.ts | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/v0/destinations/hs/HSTransform-v2.js b/src/v0/destinations/hs/HSTransform-v2.js index 3699e1c789..d2b26f1ab8 100644 --- a/src/v0/destinations/hs/HSTransform-v2.js +++ b/src/v0/destinations/hs/HSTransform-v2.js @@ -110,11 +110,11 @@ const processIdentify = async (message, destination, propertyMap) => { GENERIC_TRUE_VALUES.includes(mappedToDestination.toString()) && operation ) { - addExternalIdToHSTraits(message); if (!objectType) { throw new InstrumentationError('objectType not found'); } if (operation === 'createObject') { + addExternalIdToHSTraits(message); endpoint = CRM_CREATE_UPDATE_ALL_OBJECTS.replace(':objectType', objectType); } else if (operation === 'updateObject' && getHsSearchId(message)) { const { hsSearchId } = getHsSearchId(message); diff --git a/test/integrations/destinations/hs/processor/data.ts b/test/integrations/destinations/hs/processor/data.ts index 0867f2cb54..f503ae92ac 100644 --- a/test/integrations/destinations/hs/processor/data.ts +++ b/test/integrations/destinations/hs/processor/data.ts @@ -1534,7 +1534,6 @@ export const data = [ firstname: 'Test Hubspot', anonymousId: '12345', country: 'India', - email: 'testhubspot2@email.com', }, }, XML: {}, diff --git a/test/integrations/destinations/hs/router/data.ts b/test/integrations/destinations/hs/router/data.ts index e1c3e04356..ab3ca8cba8 100644 --- a/test/integrations/destinations/hs/router/data.ts +++ b/test/integrations/destinations/hs/router/data.ts @@ -1033,7 +1033,6 @@ export const data = [ firstname: 'Test Hubspot', anonymousId: '12345', country: 'India', - email: 'testhubspot2@email.com', }, id: '103605', }, From 099d2295926dadadff435e3c4f011f54e514d3e7 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 25 Apr 2024 08:08:53 +0000 Subject: [PATCH 20/25] chore(release): 1.63.0 --- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87ca4738ec..fff19042bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.63.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.62.2...v1.63.0) (2024-04-25) + + +### Features + +* remove redundant data from traits in hubspot ([2a63f12](https://github.com/rudderlabs/rudder-transformer/commit/2a63f128c562bd527491cdd653ced3f689d73a06)) +* remove redundant data from traits in hubspot ([#3310](https://github.com/rudderlabs/rudder-transformer/issues/3310)) ([4b21f13](https://github.com/rudderlabs/rudder-transformer/commit/4b21f1353d3d9a431a0d5446d019f66a543b977b)) + ### [1.62.2](https://github.com/rudderlabs/rudder-transformer/compare/v1.62.1...v1.62.2) (2024-04-18) diff --git a/package-lock.json b/package-lock.json index b5b413f936..a16f7006bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.62.2", + "version": "1.63.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.62.2", + "version": "1.63.0", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "0.7.24", diff --git a/package.json b/package.json index a291bbab90..6aae041dfd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.62.2", + "version": "1.63.0", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": { From 4a546d969280bf29f14af4244ea5dd8ad7ecfff9 Mon Sep 17 00:00:00 2001 From: ItsSudip Date: Thu, 25 Apr 2024 13:41:52 +0530 Subject: [PATCH 21/25] chore: update changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fff19042bb..0d3da68413 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,6 @@ All notable changes to this project will be documented in this file. See [standa ### Features -* remove redundant data from traits in hubspot ([2a63f12](https://github.com/rudderlabs/rudder-transformer/commit/2a63f128c562bd527491cdd653ced3f689d73a06)) * remove redundant data from traits in hubspot ([#3310](https://github.com/rudderlabs/rudder-transformer/issues/3310)) ([4b21f13](https://github.com/rudderlabs/rudder-transformer/commit/4b21f1353d3d9a431a0d5446d019f66a543b977b)) ### [1.62.2](https://github.com/rudderlabs/rudder-transformer/compare/v1.62.1...v1.62.2) (2024-04-18) From f06ebde110693fe32f8e450dc395f1f4019defab Mon Sep 17 00:00:00 2001 From: shrouti1507 <60211312+shrouti1507@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:32:58 +0530 Subject: [PATCH 22/25] fix: algolia enhancement ( adding currency, price, subType and objectData support ) (#3290) * fix: algolia enhancement * fix: bug fix * Apply suggestions from code review Co-authored-by: Gauravudia <60897972+Gauravudia@users.noreply.github.com> * Revert "Apply suggestions from code review" This reverts commit fc3def40eddc86df82bde99076d6409138ddf017. * feat: review comments addressed * feat: review comments addressed --------- Co-authored-by: Gauravudia <60897972+Gauravudia@users.noreply.github.com> --- .../v2/destinations/algolia/procWorkflow.yaml | 24 +- src/v0/destinations/algolia/config.js | 2 + .../algolia/data/AlgoliaTrack.json | 10 + src/v0/destinations/algolia/transform.js | 24 +- src/v0/destinations/algolia/util.js | 19 +- .../destinations/algolia/processor/data.ts | 660 ++++++++++++++++++ 6 files changed, 734 insertions(+), 5 deletions(-) diff --git a/src/cdk/v2/destinations/algolia/procWorkflow.yaml b/src/cdk/v2/destinations/algolia/procWorkflow.yaml index f9ac8e3ae6..87da64aa45 100644 --- a/src/cdk/v2/destinations/algolia/procWorkflow.yaml +++ b/src/cdk/v2/destinations/algolia/procWorkflow.yaml @@ -5,7 +5,10 @@ bindings: - path: ../../../../v0/destinations/algolia/config - name: removeUndefinedAndNullValues path: ../../../../v0/util + - name: isDefinedAndNotNull + path: ../../../../v0/util - path: ../../bindings/jsontemplate + - path: '@rudderstack/integrations-lib' steps: - name: validateInput @@ -24,6 +27,7 @@ steps: let eventTypeMap = $.eventTypeMapping(.destination.Config); let event = .message.event.trim().toLowerCase(); let eventType = .message.properties.eventType ?? eventTypeMap[event]; + let eventSubType = .message.properties.eventSubtype && eventType === 'conversion' && (.message.properties.eventSubtype in $.ALLOWED_EVENT_SUBTYPES) ? .message.properties.eventSubtype; $.assert(eventType, "eventType is mandatory for track call"); let payload = .message.().({ index: .properties.index, @@ -32,12 +36,28 @@ steps: filters: .properties.filters, objectIDs: .properties.objectIds, positions: .properties.positions, + value: $.isDefinedAndNotNull(.properties.currency) ? .properties.value, + currency: .properties.currency, userToken: {{{{$.getGenericPaths("userId", "||")}}}}, eventName: event, - eventType: eventType + eventType: eventType, + eventSubtype: eventSubType }); $.context.payload = $.genericpayloadValidator(payload); + - name: prepareObjectDataBlock + condition: $.context.payload.eventType === "conversion" && $.isDefinedAndNotNull(^.message.properties.products) && Array.isArray(^.message.properties.products) + description: | + Populate list of objectData + template: | + const products = ^.message.properties.products + products.($.removeUndefinedAndNullValues({ + "queryID" : $.isDefinedAndNotNull(.queryID) ? String(.queryID) : null, + "price": $.isDefinedAndNotNull(.price) && $.isDefinedAndNotNull(^.message.properties.currency) ? String(.price) : null, + "quantity": $.isDefinedAndNotNull(.quantity)? Number(.quantity) : null, + "discount": $.isDefinedAndNotNull(.discount) ? String(.discount) : null + }))[] + - name: populateProductsData condition: | .message.properties.products && @@ -55,11 +75,13 @@ steps: const products = .message.properties.products; const objectIDs = ~r products.objectId; $.context.payload.objectIDs = Array.isArray(objectIDs) ? objectIDs[:20]:$.context.payload.objectIDs; + $.context.payload.objectData = $.outputs.prepareObjectDataBlock - name: validateDestPayload template: | const filters = $.context.payload.filters; const objectIDs = $.context.payload.objectIDs; + const objectData = $.context.payload.objectData; $.assert(!(filters && objectIDs), "event can't have both objectIds and filters at the same time."); $.assert(filters.length || objectIDs.length, "Either filters or objectIds is required and must be non empty."); diff --git a/src/v0/destinations/algolia/config.js b/src/v0/destinations/algolia/config.js index 11b4ec99f2..4e20294dd2 100644 --- a/src/v0/destinations/algolia/config.js +++ b/src/v0/destinations/algolia/config.js @@ -5,6 +5,7 @@ const CONFIG_CATEGORIES = { TRACK: { type: 'track', name: 'AlgoliaTrack' }, }; const EVENT_TYPES = ['click', 'view', 'conversion']; +const ALLOWED_EVENT_SUBTYPES = ['addToCart', 'purchase']; const MAX_BATCH_SIZE = 1000; const MAPPING_CONFIG = getMappingConfig(CONFIG_CATEGORIES, __dirname); module.exports = { @@ -12,4 +13,5 @@ module.exports = { MAX_BATCH_SIZE, EVENT_TYPES, trackMapping: MAPPING_CONFIG[CONFIG_CATEGORIES.TRACK.name], + ALLOWED_EVENT_SUBTYPES, }; diff --git a/src/v0/destinations/algolia/data/AlgoliaTrack.json b/src/v0/destinations/algolia/data/AlgoliaTrack.json index bdc3449147..41f43af9cb 100644 --- a/src/v0/destinations/algolia/data/AlgoliaTrack.json +++ b/src/v0/destinations/algolia/data/AlgoliaTrack.json @@ -34,5 +34,15 @@ "destKey": "positions", "sourceKeys": "properties.positions", "required": false + }, + { + "destKey": "value", + "sourceKeys": "properties.value", + "required": false + }, + { + "destKey": "currency", + "sourceKeys": "properties.currency", + "required": false } ] diff --git a/src/v0/destinations/algolia/transform.js b/src/v0/destinations/algolia/transform.js index 8e9cd57e8b..33ae6f2101 100644 --- a/src/v0/destinations/algolia/transform.js +++ b/src/v0/destinations/algolia/transform.js @@ -16,7 +16,7 @@ const { handleRtTfSingleEventError, } = require('../../util/index'); -const { ENDPOINT, MAX_BATCH_SIZE, trackMapping } = require('./config'); +const { ENDPOINT, MAX_BATCH_SIZE, trackMapping, ALLOWED_EVENT_SUBTYPES } = require('./config'); const { genericpayloadValidator, @@ -38,6 +38,12 @@ const trackResponseBuilder = (message, { Config }) => { const eventMapping = eventTypeMapping(Config); payload.eventName = event; payload.eventType = getValueFromMessage(message, 'properties.eventType') || eventMapping[event]; + if ( + payload.eventType === 'conversion' && + ALLOWED_EVENT_SUBTYPES.includes(getValueFromMessage(message, 'properties.eventSubtype')) + ) { + payload.eventSubtype = getValueFromMessage(message, 'properties.eventSubtype'); + } if (!payload.eventType) { throw new InstrumentationError('eventType is mandatory for track call'); @@ -47,9 +53,13 @@ const trackResponseBuilder = (message, { Config }) => { if (event === 'product list viewed' || event === 'order completed') { const products = getValueFromMessage(message, 'properties.products'); if (products) { - const { objectList, positionList } = createObjectArray(products, payload.eventType); + const { objectList, positionList, objectData } = createObjectArray( + products, + payload.eventType, + ); const objLen = objectList.length; const posLen = positionList.length; + const objDataLen = objectData.length; if (objLen > 0) { payload.objectIDs = objectList; payload.objectIDs.splice(20); @@ -58,10 +68,20 @@ const trackResponseBuilder = (message, { Config }) => { payload.positions = positionList; payload.positions.splice(20); } + + if (objDataLen > 0) { + payload.objectData = objectData; + } // making size of object list and position list equal if (posLen > 0 && objLen > 0 && posLen !== objLen) { throw new InstrumentationError('length of objectId and position should be equal'); } + + if (objDataLen > 0 && objLen > 0 && objDataLen !== objLen) { + throw new InstrumentationError( + 'length of objectId and properties.products array should be equal', + ); + } } } // for all events either filter or objectID should be there diff --git a/src/v0/destinations/algolia/util.js b/src/v0/destinations/algolia/util.js index eddb4dc16d..863c23aba7 100644 --- a/src/v0/destinations/algolia/util.js +++ b/src/v0/destinations/algolia/util.js @@ -1,4 +1,8 @@ -const { InstrumentationError } = require('@rudderstack/integrations-lib'); +const { + InstrumentationError, + isDefined, + removeUndefinedAndNullValues, +} = require('@rudderstack/integrations-lib'); const logger = require('../../../logger'); const { EVENT_TYPES } = require('./config'); @@ -66,6 +70,8 @@ const genericpayloadValidator = (payload) => { const createObjectArray = (objects, eventType) => { const objectList = []; const positionList = []; + // eslint-disable-next-line sonarjs/no-unused-collection + const objectData = []; if (objects.length > 0) { objects.forEach((object, index) => { if (object.objectId) { @@ -80,13 +86,22 @@ const createObjectArray = (objects, eventType) => { } } else { objectList.push(object.objectId); + if (eventType === 'conversion') { + const singleObjData = { + queryID: isDefined(object.queryID) ? `${object.queryID}` : null, + price: isDefined(object.price) ? `${object.price}` : null, + quantity: object.quantity, + discount: isDefined(object.discount) ? `${object.discount}` : null, + }; + objectData.push(removeUndefinedAndNullValues(singleObjData)); + } } } else { logger.error(`object at index ${index} dropped. objectId is required.`); } }); } - return { objectList, positionList }; + return { objectList, positionList, objectData }; }; const clickPayloadValidator = (payload) => { diff --git a/test/integrations/destinations/algolia/processor/data.ts b/test/integrations/destinations/algolia/processor/data.ts index 7c37c9642a..a8dd31b51a 100644 --- a/test/integrations/destinations/algolia/processor/data.ts +++ b/test/integrations/destinations/algolia/processor/data.ts @@ -1627,4 +1627,664 @@ export const data = [ }, }, }, + { + name: 'algolia', + description: + 'For conversion event including product array and subtype addToCart, object data is sent', + 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: 'testone@gmail.com', + firstName: 'test', + lastName: 'one', + }, + 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', + ip: '0.0.0.0', + os: { + name: '', + version: '', + }, + screen: { + density: 2, + }, + page: { + path: '/destinations/ometria', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/ometria', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + }, + type: 'track', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: '123456', + event: 'product list viewed', + userId: 'testuserId1', + properties: { + index: 'products', + eventSubtype: 'addToCart', + products: [ + { + objectId: 'ecommerce-sample-data-919', + position: 7, + quantity: '2', + price: 10, + queryID: '123', + discount: '10', + }, + { + objectId: '9780439784542', + position: 8, + quantity: '3', + price: 30, + queryID: '123', + discount: '10', + }, + ], + queryId: '43b15df305339e827f0ac0bdc5ebcaa7', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + excludeKeys: [], + includeKeys: [], + }, + }, + Config: { + apiKey: 'dummyApiKey', + applicationId: 'O2YARRI15I', + eventTypeSettings: [ + { + from: 'product list viewed', + to: 'conversion', + }, + ], + }, + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + JSON: { + events: [ + { + index: 'products', + queryID: '43b15df305339e827f0ac0bdc5ebcaa7', + objectIDs: ['ecommerce-sample-data-919', '9780439784542'], + userToken: 'testuserId1', + eventName: 'product list viewed', + eventSubtype: 'addToCart', + eventType: 'conversion', + objectData: [ + { + quantity: 2, + queryID: '123', + discount: '10', + }, + { + quantity: 3, + queryID: '123', + discount: '10', + }, + ], + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://insights.algolia.io/1/events', + headers: { + 'X-Algolia-Application-Id': 'O2YARRI15I', + 'X-Algolia-API-Key': 'dummyApiKey', + }, + params: {}, + files: {}, + userId: '', + }, + statusCode: 200, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, + { + name: 'algolia', + description: + 'For conversion event including product array and subtype purchase, object data is sent', + 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: 'testone@gmail.com', + firstName: 'test', + lastName: 'one', + }, + 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', + ip: '0.0.0.0', + os: { + name: '', + version: '', + }, + screen: { + density: 2, + }, + page: { + path: '/destinations/ometria', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/ometria', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + }, + type: 'track', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: '123456', + event: 'product list viewed', + userId: 'testuserId1', + properties: { + index: 'products', + eventSubtype: 'purchase', + products: [ + { + objectId: 'ecommerce-sample-data-919', + position: 7, + quantity: '2', + price: 10, + queryID: '123', + discount: '10', + }, + { + objectId: '9780439784542', + position: 8, + quantity: '3', + price: 30, + queryID: '123', + discount: '10', + }, + ], + queryId: '43b15df305339e827f0ac0bdc5ebcaa7', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + excludeKeys: [], + includeKeys: [], + }, + }, + Config: { + apiKey: 'dummyApiKey', + applicationId: 'O2YARRI15I', + eventTypeSettings: [ + { + from: 'product list viewed', + to: 'conversion', + }, + ], + }, + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + JSON: { + events: [ + { + index: 'products', + queryID: '43b15df305339e827f0ac0bdc5ebcaa7', + objectIDs: ['ecommerce-sample-data-919', '9780439784542'], + userToken: 'testuserId1', + eventName: 'product list viewed', + eventSubtype: 'purchase', + eventType: 'conversion', + objectData: [ + { + quantity: 2, + queryID: '123', + discount: '10', + }, + { + quantity: 3, + queryID: '123', + discount: '10', + }, + ], + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://insights.algolia.io/1/events', + headers: { + 'X-Algolia-Application-Id': 'O2YARRI15I', + 'X-Algolia-API-Key': 'dummyApiKey', + }, + params: {}, + files: {}, + userId: '', + }, + statusCode: 200, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, + { + name: 'algolia', + description: + 'For conversion event including product array and subtype wrong, object data is sent but subType is omitted', + 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: 'testone@gmail.com', + firstName: 'test', + lastName: 'one', + }, + 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', + ip: '0.0.0.0', + os: { + name: '', + version: '', + }, + screen: { + density: 2, + }, + page: { + path: '/destinations/ometria', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/ometria', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + }, + type: 'track', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: '123456', + event: 'product list viewed', + userId: 'testuserId1', + properties: { + index: 'products', + eventSubtype: 'random', + value: 10, + currency: 'USD', + products: [ + { + objectId: 'ecommerce-sample-data-919', + position: 7, + quantity: '2', + queryID: '123', + discount: '10', + price: 10, + }, + { + objectId: '9780439784542', + position: 8, + quantity: '3', + queryID: '123', + discount: '10', + price: 10, + }, + ], + queryId: '43b15df305339e827f0ac0bdc5ebcaa7', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + excludeKeys: [], + includeKeys: [], + }, + }, + Config: { + apiKey: 'dummyApiKey', + applicationId: 'O2YARRI15I', + eventTypeSettings: [ + { + from: 'product list viewed', + to: 'conversion', + }, + ], + }, + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + JSON: { + events: [ + { + index: 'products', + queryID: '43b15df305339e827f0ac0bdc5ebcaa7', + objectIDs: ['ecommerce-sample-data-919', '9780439784542'], + userToken: 'testuserId1', + eventName: 'product list viewed', + eventType: 'conversion', + value: 10, + currency: 'USD', + objectData: [ + { + price: '10', + quantity: 2, + queryID: '123', + discount: '10', + }, + { + price: '10', + quantity: 3, + queryID: '123', + discount: '10', + }, + ], + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://insights.algolia.io/1/events', + headers: { + 'X-Algolia-Application-Id': 'O2YARRI15I', + 'X-Algolia-API-Key': 'dummyApiKey', + }, + params: {}, + files: {}, + userId: '', + }, + statusCode: 200, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, + { + name: 'algolia', + description: + 'For conversion event without including product array and subtype purchase, object data is not sent but subType is sent', + 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: 'testone@gmail.com', + firstName: 'test', + lastName: 'one', + }, + 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', + ip: '0.0.0.0', + os: { + name: '', + version: '', + }, + screen: { + density: 2, + }, + page: { + path: '/destinations/ometria', + referrer: '', + search: '', + title: '', + url: 'https://docs.rudderstack.com/destinations/ometria', + category: 'destination', + initial_referrer: 'https://docs.rudderstack.com', + initial_referring_domain: 'docs.rudderstack.com', + }, + }, + type: 'track', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: '123456', + event: 'product list viewed', + userId: 'testuserId1', + properties: { + index: 'products', + eventSubtype: 'purchase', + filters: ['field1:hello', 'val1:val2'], + queryId: '43b15df305339e827f0ac0bdc5ebcaa7', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + excludeKeys: [], + includeKeys: [], + }, + }, + Config: { + apiKey: 'dummyApiKey', + applicationId: 'O2YARRI15I', + eventTypeSettings: [ + { + from: 'product list viewed', + to: 'conversion', + }, + ], + }, + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + JSON: { + events: [ + { + index: 'products', + queryID: '43b15df305339e827f0ac0bdc5ebcaa7', + filters: ['field1:hello', 'val1:val2'], + userToken: 'testuserId1', + eventName: 'product list viewed', + eventType: 'conversion', + eventSubtype: 'purchase', + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://insights.algolia.io/1/events', + headers: { + 'X-Algolia-Application-Id': 'O2YARRI15I', + 'X-Algolia-API-Key': 'dummyApiKey', + }, + params: {}, + files: {}, + userId: '', + }, + statusCode: 200, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, ]; From 54eca3220ea48fae64c655813fe4430dd704639e Mon Sep 17 00:00:00 2001 From: Sandeep Digumarty Date: Fri, 26 Apr 2024 18:14:15 +0530 Subject: [PATCH 23/25] fix: send content_ids as a string if there is only one value (#3317) --- .../facebook_conversions/utils.js | 2 +- .../facebook_conversions/processor/data.ts | 121 ++++++++++++++++++ 2 files changed, 122 insertions(+), 1 deletion(-) diff --git a/src/v0/destinations/facebook_conversions/utils.js b/src/v0/destinations/facebook_conversions/utils.js index c6e3993e33..87fb0ea606 100644 --- a/src/v0/destinations/facebook_conversions/utils.js +++ b/src/v0/destinations/facebook_conversions/utils.js @@ -134,7 +134,7 @@ const populateCustomDataBasedOnCategory = (customData, message, category, catego const { contentIds, contents } = populateContentsAndContentIDs([message.properties]); eventTypeCustomData = { ...eventTypeCustomData, - content_ids: contentIds, + content_ids: contentIds.length === 1 ? contentIds[0] : contentIds, contents, content_type: contentType, content_category: getContentCategory(contentCategory), diff --git a/test/integrations/destinations/facebook_conversions/processor/data.ts b/test/integrations/destinations/facebook_conversions/processor/data.ts index 6eb90942a7..bfa35bc22b 100644 --- a/test/integrations/destinations/facebook_conversions/processor/data.ts +++ b/test/integrations/destinations/facebook_conversions/processor/data.ts @@ -1534,4 +1534,125 @@ export const data = [ }, mockFns: defaultMockFns, }, + { + name: 'facebook_conversions', + description: 'Track event with standard event product added with content_ids', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', + channel: 'web', + context: { + device: { + id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R', + manufacturer: 'Xiaomi', + model: 'Redmi 6', + name: 'xiaomi', + }, + network: { + carrier: 'Banglalink', + }, + os: { + name: 'android', + version: '8.1.0', + }, + screen: { + height: '100', + density: 50, + }, + traits: { + email: ' aBc@gmail.com ', + address: { + zip: 1234, + }, + anonymousId: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1', + }, + }, + event: 'product added', + integrations: { + All: true, + }, + message_id: 'a80f82be-9bdc-4a9f-b2a5-15621ee41df8', + properties: { + revenue: 400, + additional_bet_index: 0, + id: '452345234', + quantity: 5, + }, + timestamp: '2023-11-12T15:46:51.693229+05:30', + type: 'track', + }, + destination: { + Config: { + limitedDataUsage: true, + blacklistPiiProperties: [ + { + blacklistPiiProperties: '', + blacklistPiiHash: false, + }, + ], + accessToken: '09876', + datasetId: 'dummyID', + eventsToEvents: [ + { + from: '', + to: '', + }, + ], + eventCustomProperties: [ + { + eventCustomProperties: '', + }, + ], + removeExternalId: true, + whitelistPiiProperties: [ + { + whitelistPiiProperties: '', + }, + ], + actionSource: 'website', + }, + Enabled: true, + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://graph.facebook.com/v18.0/dummyID/events?access_token=09876', + headers: {}, + params: {}, + body: { + JSON: {}, + XML: {}, + JSON_ARRAY: {}, + FORM: { + data: [ + '{"user_data":{"em":"48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08","zp":"03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4"},"event_name":"AddToCart","event_time":1699784211,"action_source":"website","custom_data":{"revenue":400,"additional_bet_index":0,"id":"452345234","quantity":5,"content_ids":"452345234","contents":[{"id":"452345234","quantity":5}],"content_type":"product","currency":"USD","value":400}}', + ], + }, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + mockFns: defaultMockFns, + }, ]; From 8f79f53d30326e07fc92dd624e799015ff9f87c2 Mon Sep 17 00:00:00 2001 From: Yashasvi Bajpai <33063622+yashasvibajpai@users.noreply.github.com> Date: Mon, 29 Apr 2024 10:14:10 +0530 Subject: [PATCH 24/25] feat: onboard Yandex Metrica Offline Events Destination (#3232) * feat: onboard yandex metrica offline events destination, initial changes * chore: update id logic, add tests * chore: address commentsx1 * chore: add validations and tests * chore: address commentsx2 * chore: add validations for tiemstamp and id * chore: add null check for DateTime * chore: add null error throw for DateTime --------- Co-authored-by: Sai Sankeerth --- .../yandex_metrica_offline_events/config.js | 5 + .../procWorkflow.yaml | 36 + .../yandex_metrica_offline_events/utils.js | 51 ++ .../processor/data.ts | 746 ++++++++++++++++++ 4 files changed, 838 insertions(+) create mode 100644 src/cdk/v2/destinations/yandex_metrica_offline_events/config.js create mode 100644 src/cdk/v2/destinations/yandex_metrica_offline_events/procWorkflow.yaml create mode 100644 src/cdk/v2/destinations/yandex_metrica_offline_events/utils.js create mode 100644 test/integrations/destinations/yandex_metrica_offline_events/processor/data.ts diff --git a/src/cdk/v2/destinations/yandex_metrica_offline_events/config.js b/src/cdk/v2/destinations/yandex_metrica_offline_events/config.js new file mode 100644 index 0000000000..83513c3856 --- /dev/null +++ b/src/cdk/v2/destinations/yandex_metrica_offline_events/config.js @@ -0,0 +1,5 @@ +const YANDEX_METRICA_OFFLINE_EVENTS = 'yandex_metrica_offline_events'; + +module.exports = { + YANDEX_METRICA_OFFLINE_EVENTS, +}; diff --git a/src/cdk/v2/destinations/yandex_metrica_offline_events/procWorkflow.yaml b/src/cdk/v2/destinations/yandex_metrica_offline_events/procWorkflow.yaml new file mode 100644 index 0000000000..690bc399ee --- /dev/null +++ b/src/cdk/v2/destinations/yandex_metrica_offline_events/procWorkflow.yaml @@ -0,0 +1,36 @@ +bindings: + - name: EventType + path: ../../../../constants + - path: ../../bindings/jsontemplate + exportAll: true + - path: ./config + - name: removeUndefinedAndNullValues + path: ../../../../v0/util + - name: defaultRequestConfig + path: ../../../../v0/util + - path: ./utils + +steps: + - name: validateInput + template: | + let messageType = .message.type; + $.assert(messageType, "message Type is not present. Aborting message."); + $.assert(.message.type.toLowerCase() ==='identify', "Event type " + .message.type.toLowerCase() + " is not supported. Aborting message."); + $.assert(.message.traits || .message.properties, "Message traits/properties not present. Aborting message."); + + - name: prepareData + template: | + let data = .message.traits + let identifierType = .message.context.externalId[0].identifierType; + let identifierValue = .message.context.externalId[0].id; + identifierValue = String(identifierValue); + data = $.setIdentifier(data, identifierType, identifierValue) + data = $.validateData(data) + data + + - name: buildResponseForProcessTransformation + description: build response + template: | + const response = $.defaultRequestConfig(); + response.body.JSON = $.outputs.prepareData + response diff --git a/src/cdk/v2/destinations/yandex_metrica_offline_events/utils.js b/src/cdk/v2/destinations/yandex_metrica_offline_events/utils.js new file mode 100644 index 0000000000..032b0b636d --- /dev/null +++ b/src/cdk/v2/destinations/yandex_metrica_offline_events/utils.js @@ -0,0 +1,51 @@ +/* eslint-disable no-param-reassign */ +const { InstrumentationError, isDefinedNotNullNotEmpty } = require('@rudderstack/integrations-lib'); +const moment = require('moment'); + +const setIdentifier = (data, identifierType, identifierValue) => { + const updatedData = data; + if (identifierType === 'ClientId') { + updatedData.ClientId = identifierValue; + } else if (identifierType === 'YCLID') { + updatedData.Yclid = identifierValue; + } else if (identifierType === 'UserId') { + updatedData.UserId = identifierValue; + } else { + throw new InstrumentationError( + 'Invalid identifier type passed in external Id. Valid types are ClientId, YCLID, UserId. Aborting!', + ); + } + return updatedData; +}; + +function isUnixTimestamp(datetime) { + if (moment.unix(datetime).isValid()) { + return datetime; + } + const unixTimestamp = moment(datetime).unix(); + if (moment.unix(unixTimestamp).isValid()) { + return unixTimestamp; + } + throw new InstrumentationError('Invalid timestamp. Aborting!'); +} + +const validateData = (data) => { + const { Price, DateTime } = data; + if (!isDefinedNotNullNotEmpty(data)) { + throw new InstrumentationError('No traits found in the payload. Aborting!'); + } + if (Price && typeof Price !== 'number') { + throw new InstrumentationError('Price can only be a numerical value. Aborting!'); + } + if (!isDefinedNotNullNotEmpty(DateTime)) { + throw new InstrumentationError('DateTime cannot be empty. Aborting!'); + } + data.DateTime = String(isUnixTimestamp(DateTime)); + return data; +}; + +module.exports = { + setIdentifier, + validateData, + isUnixTimestamp, +}; diff --git a/test/integrations/destinations/yandex_metrica_offline_events/processor/data.ts b/test/integrations/destinations/yandex_metrica_offline_events/processor/data.ts new file mode 100644 index 0000000000..4bb27bdf57 --- /dev/null +++ b/test/integrations/destinations/yandex_metrica_offline_events/processor/data.ts @@ -0,0 +1,746 @@ +export const data = [ + { + name: 'yandex_metrica_offline_events', + description: 'Successful identify event with YCLID identifier type', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + traits: { + Price: 100, + Target: 'GOAL1', + Currency: 'RUB', + DateTime: '1481718166', + }, + userId: '', + channel: 'sources', + context: { + sources: { + job_id: '2du7rQyxlbIJl4LKgZAaaErEjcE', + version: '1849/merge', + job_run_id: 'cnsn3tt5fleigsfclr6g', + task_run_id: 'cnsn3tt5fleigsfclr70', + }, + externalId: [ + { + id: '133591247640966458', + type: 'YANDEX_METRICA_OFFLINE_EVENTS-conversions', + identifierType: 'YCLID', + }, + ], + mappedToDestination: 'true', + }, + recordId: '1', + rudderId: '14a58046-23a5-46bd-afbf-87c8acaa9d2e', + messageId: '91ef85d9-b170-440c-bae2-6284d4070338', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + counterId: '574342423', + goalId: '23432565', + rudderAccountId: '2du7fLeK82nk9L2Xd1X507uiD1B', + authStatus: 'active', + }, + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: '', + headers: {}, + params: {}, + body: { + JSON: { + Currency: 'RUB', + DateTime: '1481718166', + Price: 100, + Target: 'GOAL1', + Yclid: '133591247640966458', + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, + { + name: 'yandex_metrica_offline_events', + description: 'Successful identify event with ClientId identifier type', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + traits: { + Price: 100, + Target: 'GOAL1', + Currency: 'RUB', + DateTime: '1481718166', + }, + userId: '', + channel: 'sources', + context: { + sources: { + job_id: '2du7rQyxlbIJl4LKgZAaaErEjcE', + version: '1849/merge', + job_run_id: 'cnsn3tt5fleigsfclr6g', + task_run_id: 'cnsn3tt5fleigsfclr70', + }, + externalId: [ + { + id: '133591247640966458', + type: 'YANDEX_METRICA_OFFLINE_EVENTS-conversions', + identifierType: 'ClientId', + }, + ], + mappedToDestination: 'true', + }, + recordId: '1', + rudderId: '14a58046-23a5-46bd-afbf-87c8acaa9d2e', + messageId: '91ef85d9-b170-440c-bae2-6284d4070338', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + counterId: '574342423', + goalId: '23432565', + rudderAccountId: '2du7fLeK82nk9L2Xd1X507uiD1B', + authStatus: 'active', + }, + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: '', + headers: {}, + params: {}, + body: { + JSON: { + Currency: 'RUB', + DateTime: '1481718166', + Price: 100, + Target: 'GOAL1', + ClientId: '133591247640966458', + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, + { + name: 'yandex_metrica_offline_events', + description: 'Successful identify event with UserId identifier type', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + traits: { + Price: 100, + Target: 'GOAL1', + Currency: 'RUB', + DateTime: '1481718166', + }, + userId: '', + channel: 'sources', + context: { + sources: { + job_id: '2du7rQyxlbIJl4LKgZAaaErEjcE', + version: '1849/merge', + job_run_id: 'cnsn3tt5fleigsfclr6g', + task_run_id: 'cnsn3tt5fleigsfclr70', + }, + externalId: [ + { + id: '133591247640966458', + type: 'YANDEX_METRICA_OFFLINE_EVENTS-conversions', + identifierType: 'UserId', + }, + ], + mappedToDestination: 'true', + }, + recordId: '1', + rudderId: '14a58046-23a5-46bd-afbf-87c8acaa9d2e', + messageId: '91ef85d9-b170-440c-bae2-6284d4070338', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + counterId: '574342423', + goalId: '23432565', + rudderAccountId: '2du7fLeK82nk9L2Xd1X507uiD1B', + authStatus: 'active', + }, + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: '', + headers: {}, + params: {}, + body: { + JSON: { + Currency: 'RUB', + DateTime: '1481718166', + Price: 100, + Target: 'GOAL1', + UserId: '133591247640966458', + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, + { + name: 'yandex_metrica_offline_events', + description: 'Failed identify event with Price passed as string', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + traits: { + Price: '100', + Target: 'GOAL1', + Currency: 'RUB', + DateTime: '1481718166', + }, + userId: '', + channel: 'sources', + context: { + sources: { + job_id: '2du7rQyxlbIJl4LKgZAaaErEjcE', + version: '1849/merge', + job_run_id: 'cnsn3tt5fleigsfclr6g', + task_run_id: 'cnsn3tt5fleigsfclr70', + }, + externalId: [ + { + id: '133591247640966458', + type: 'YANDEX_METRICA_OFFLINE_EVENTS-conversions', + identifierType: 'UserId', + }, + ], + mappedToDestination: 'true', + }, + recordId: '1', + rudderId: '14a58046-23a5-46bd-afbf-87c8acaa9d2e', + messageId: '91ef85d9-b170-440c-bae2-6284d4070338', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + counterId: '574342423', + goalId: '23432565', + rudderAccountId: '2du7fLeK82nk9L2Xd1X507uiD1B', + authStatus: 'active', + }, + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + statusCode: 400, + error: + 'Price can only be a numerical value. Aborting!: Workflow: procWorkflow, Step: prepareData, ChildStep: undefined, OriginalError: Price can only be a numerical value. Aborting!', + statTags: { + destType: 'YANDEX_METRICA_OFFLINE_EVENTS', + destinationId: 'destId', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + workspaceId: 'wspId', + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, + { + name: 'yandex_metrica_offline_events', + description: 'Failed identify event with invalid identifier type', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + traits: { + Price: 100, + Target: 'GOAL1', + Currency: 'RUB', + DateTime: '1481718166', + }, + userId: '', + channel: 'sources', + context: { + sources: { + job_id: '2du7rQyxlbIJl4LKgZAaaErEjcE', + version: '1849/merge', + job_run_id: 'cnsn3tt5fleigsfclr6g', + task_run_id: 'cnsn3tt5fleigsfclr70', + }, + externalId: [ + { + id: '133591247640966458', + type: 'YANDEX_METRICA_OFFLINE_EVENTS-conversions', + identifierType: 'InvalidIdentifierType', + }, + ], + mappedToDestination: 'true', + }, + recordId: '1', + rudderId: '14a58046-23a5-46bd-afbf-87c8acaa9d2e', + messageId: '91ef85d9-b170-440c-bae2-6284d4070338', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + counterId: '574342423', + goalId: '23432565', + rudderAccountId: '2du7fLeK82nk9L2Xd1X507uiD1B', + authStatus: 'active', + }, + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + statusCode: 400, + error: + 'Invalid identifier type passed in external Id. Valid types are ClientId, YCLID, UserId. Aborting!: Workflow: procWorkflow, Step: prepareData, ChildStep: undefined, OriginalError: Invalid identifier type passed in external Id. Valid types are ClientId, YCLID, UserId. Aborting!', + statTags: { + destType: 'YANDEX_METRICA_OFFLINE_EVENTS', + destinationId: 'destId', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + workspaceId: 'wspId', + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, + { + name: 'yandex_metrica_offline_events', + description: 'Failed identify event with invalid timestamp', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + traits: { + Price: 100, + Target: 'GOAL1', + Currency: 'RUB', + DateTime: 'invalidTimestamp', + }, + userId: '', + channel: 'sources', + context: { + sources: { + job_id: '2du7rQyxlbIJl4LKgZAaaErEjcE', + version: '1849/merge', + job_run_id: 'cnsn3tt5fleigsfclr6g', + task_run_id: 'cnsn3tt5fleigsfclr70', + }, + externalId: [ + { + id: '133591247640966458', + type: 'YANDEX_METRICA_OFFLINE_EVENTS-conversions', + identifierType: 'ClientId', + }, + ], + mappedToDestination: 'true', + }, + recordId: '1', + rudderId: '14a58046-23a5-46bd-afbf-87c8acaa9d2e', + messageId: '91ef85d9-b170-440c-bae2-6284d4070338', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + counterId: '574342423', + goalId: '23432565', + rudderAccountId: '2du7fLeK82nk9L2Xd1X507uiD1B', + authStatus: 'active', + }, + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + statusCode: 400, + error: + 'Invalid timestamp. Aborting!: Workflow: procWorkflow, Step: prepareData, ChildStep: undefined, OriginalError: Invalid timestamp. Aborting!', + statTags: { + destType: 'YANDEX_METRICA_OFFLINE_EVENTS', + destinationId: 'destId', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + workspaceId: 'wspId', + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, + { + name: 'yandex_metrica_offline_events', + description: 'Successful identify event with non unix timestamp', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + traits: { + Price: 100, + Target: 'GOAL1', + Currency: 'RUB', + DateTime: '2023-08-14T05:30:30.118Z', + }, + userId: '', + channel: 'sources', + context: { + sources: { + job_id: '2du7rQyxlbIJl4LKgZAaaErEjcE', + version: '1849/merge', + job_run_id: 'cnsn3tt5fleigsfclr6g', + task_run_id: 'cnsn3tt5fleigsfclr70', + }, + externalId: [ + { + id: '133591247640966458', + type: 'YANDEX_METRICA_OFFLINE_EVENTS-conversions', + identifierType: 'YCLID', + }, + ], + mappedToDestination: 'true', + }, + recordId: '1', + rudderId: '14a58046-23a5-46bd-afbf-87c8acaa9d2e', + messageId: '91ef85d9-b170-440c-bae2-6284d4070338', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + counterId: '574342423', + goalId: '23432565', + rudderAccountId: '2du7fLeK82nk9L2Xd1X507uiD1B', + authStatus: 'active', + }, + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: '', + headers: {}, + params: {}, + body: { + JSON: { + Currency: 'RUB', + DateTime: '1691991030', + Price: 100, + Target: 'GOAL1', + Yclid: '133591247640966458', + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, + { + name: 'yandex_metrica_offline_events', + description: 'Failed identify event with null or empty timestamp', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + traits: { + Price: 100, + Target: 'GOAL1', + Currency: 'RUB', + DateTime: '', + }, + userId: '', + channel: 'sources', + context: { + sources: { + job_id: '2du7rQyxlbIJl4LKgZAaaErEjcE', + version: '1849/merge', + job_run_id: 'cnsn3tt5fleigsfclr6g', + task_run_id: 'cnsn3tt5fleigsfclr70', + }, + externalId: [ + { + id: '133591247640966458', + type: 'YANDEX_METRICA_OFFLINE_EVENTS-conversions', + identifierType: 'ClientId', + }, + ], + mappedToDestination: 'true', + }, + recordId: '1', + rudderId: '14a58046-23a5-46bd-afbf-87c8acaa9d2e', + messageId: '91ef85d9-b170-440c-bae2-6284d4070338', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + counterId: '574342423', + goalId: '23432565', + rudderAccountId: '2du7fLeK82nk9L2Xd1X507uiD1B', + authStatus: 'active', + }, + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + statusCode: 400, + error: + 'DateTime cannot be empty. Aborting!: Workflow: procWorkflow, Step: prepareData, ChildStep: undefined, OriginalError: DateTime cannot be empty. Aborting!', + statTags: { + destType: 'YANDEX_METRICA_OFFLINE_EVENTS', + destinationId: 'destId', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + workspaceId: 'wspId', + }, + metadata: { + destinationId: 'destId', + workspaceId: 'wspId', + }, + }, + ], + }, + }, + }, +]; From 7b1d11b306f3fa3a5698061c31acfbf53bc78dd1 Mon Sep 17 00:00:00 2001 From: Mihir Bhalala <77438541+mihir-4116@users.noreply.github.com> Date: Mon, 29 Apr 2024 11:01:53 +0530 Subject: [PATCH 25/25] feat(refiner): component test refactor (#3221) --- .../destinations/refiner/processor/data.ts | 677 +----------------- .../refiner/processor/groupTestData.ts | 91 +++ .../refiner/processor/identifyTestData.ts | 114 +++ .../refiner/processor/pageTestData.ts | 99 +++ .../refiner/processor/trackTestData.ts | 109 +++ .../refiner/processor/validationTestData.ts | 227 ++++++ 6 files changed, 651 insertions(+), 666 deletions(-) create mode 100644 test/integrations/destinations/refiner/processor/groupTestData.ts create mode 100644 test/integrations/destinations/refiner/processor/identifyTestData.ts create mode 100644 test/integrations/destinations/refiner/processor/pageTestData.ts create mode 100644 test/integrations/destinations/refiner/processor/trackTestData.ts create mode 100644 test/integrations/destinations/refiner/processor/validationTestData.ts diff --git a/test/integrations/destinations/refiner/processor/data.ts b/test/integrations/destinations/refiner/processor/data.ts index c851e9d7ce..b09ea234db 100644 --- a/test/integrations/destinations/refiner/processor/data.ts +++ b/test/integrations/destinations/refiner/processor/data.ts @@ -1,668 +1,13 @@ +import { identifyTestData } from './identifyTestData'; +import { trackTestData } from './trackTestData'; +import { pageTestData } from './pageTestData'; +import { groupTestData } from './groupTestData'; +import { validationTestData } from './validationTestData'; + export const data = [ - { - name: 'refiner', - description: 'No Message type', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - sentAt: '2022-10-11T13:10:54.877+05:30', - userId: 'user@45', - context: { - traits: { - age: '30', - city: 'Banglore', - email: 'test@user.com', - phone: '9876543210', - address: { city: 'ahmedabad', state: 'india' }, - lastName: 'user', - username: 'testUser', - firstName: 'test', - userCountry: 'india', - }, - }, - rudderId: 'caae04c5-959f-467b-a293-86f6c62d59e6', - messageId: 'b6ce7f31-5d76-4240-94d2-3eea020ef791', - timestamp: '2022-10-11T13:10:52.137+05:30', - receivedAt: '2022-10-11T13:10:52.138+05:30', - request_ip: '[::1]', - originalTimestamp: '2022-10-11T13:10:54.877+05:30', - }, - destination: { - Config: { - apiKey: 'dummyApiKey', - blacklistedEvents: [{ eventName: '' }], - eventDelivery: true, - eventDeliveryTS: 1665474171943, - eventFilteringOption: 'disable', - whitelistedEvents: [{ eventName: '' }], - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'Event type is required', - statTags: { - destType: 'REFINER', - errorCategory: 'dataValidation', - errorType: 'instrumentation', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'refiner', - description: 'Unsupported Event type ', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'alias', - sentAt: '2022-10-11T13:10:54.877+05:30', - userId: 'user@45', - context: { - traits: { - age: '30', - city: 'Banglore', - email: 'test@user.com', - phone: '9876543210', - address: { city: 'ahmedabad', state: 'india' }, - lastName: 'user', - username: 'testUser', - firstName: 'test', - userCountry: 'india', - }, - }, - rudderId: 'caae04c5-959f-467b-a293-86f6c62d59e6', - messageId: 'b6ce7f31-5d76-4240-94d2-3eea020ef791', - timestamp: '2022-10-11T13:10:52.137+05:30', - receivedAt: '2022-10-11T13:10:52.138+05:30', - request_ip: '[::1]', - originalTimestamp: '2022-10-11T13:10:54.877+05:30', - }, - destination: { - Config: { - apiKey: 'dummyApiKey', - blacklistedEvents: [{ eventName: '' }], - eventDelivery: true, - eventDeliveryTS: 1665474171943, - eventFilteringOption: 'disable', - whitelistedEvents: [{ eventName: '' }], - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'Event type "alias" is not supported', - statTags: { - destType: 'REFINER', - errorCategory: 'dataValidation', - errorType: 'instrumentation', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'refiner', - description: 'userId and email is not present', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'identify', - sentAt: '2022-10-11T13:10:54.877+05:30', - context: { - traits: { - age: '30', - city: 'Banglore', - phone: '9876543210', - address: { city: 'ahmedabad', state: 'india' }, - lastName: 'user', - username: 'testUser', - firstName: 'test', - userCountry: 'india', - }, - }, - rudderId: 'caae04c5-959f-467b-a293-86f6c62d59e6', - messageId: 'b6ce7f31-5d76-4240-94d2-3eea020ef791', - timestamp: '2022-10-11T13:10:52.137+05:30', - receivedAt: '2022-10-11T13:10:52.138+05:30', - request_ip: '[::1]', - originalTimestamp: '2022-10-11T13:10:54.877+05:30', - }, - destination: { - Config: { - apiKey: 'dummyApiKey', - blacklistedEvents: [{ eventName: '' }], - eventDelivery: true, - eventDeliveryTS: 1665474171943, - eventFilteringOption: 'disable', - whitelistedEvents: [{ eventName: '' }], - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'At least one of `userId` or `email` is required', - statTags: { - destType: 'REFINER', - errorCategory: 'dataValidation', - errorType: 'instrumentation', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'refiner', - description: 'event name is not present', - 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.1.2', - }, - traits: { - age: '30', - email: 'test@user.com', - phone: '9876543210', - city: 'Banglore', - userCountry: 'india', - lastName: 'user', - username: 'testUser', - firstName: 'test', - }, - library: { name: 'RudderLabs JavaScript SDK', version: '1.1.2' }, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36', - locale: 'en-GB', - os: { name: '', version: '' }, - screen: { density: 2 }, - page: { - path: '/tests/html/ecomm_test.html', - referrer: 'http://0.0.0.0:1112/tests/html/', - search: '', - title: 'Fb Offline Conversion Ecommerce Test', - url: 'http://0.0.0.0:1112/tests/html/ecomm_test.html', - }, - }, - type: 'track', - messageId: '9116b734-7e6b-4497-ab51-c16744d4487e', - userId: 'user@45', - properties: { - order_id: '5241735', - coupon: 'APPARELSALE', - currency: 'IND', - products: [ - { id: 'product-bacon-jam', category: 'Merch', brand: '' }, - { id: 'product-t-shirt', category: 'Merch', brand: 'Levis' }, - { id: 'offer-t-shirt', category: 'Merch', brand: 'Levis' }, - ], - }, - }, - destination: { - Config: { - apiKey: 'dummyApiKey', - blacklistedEvents: [{ eventName: '' }], - eventDelivery: true, - eventDeliveryTS: 1665474171943, - eventFilteringOption: 'disable', - whitelistedEvents: [{ eventName: '' }], - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - error: 'Event name is required', - statTags: { - destType: 'REFINER', - errorCategory: 'dataValidation', - errorType: 'instrumentation', - feature: 'processor', - implementation: 'native', - module: 'destination', - }, - statusCode: 400, - }, - ], - }, - }, - }, - { - name: 'refiner', - description: 'successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'identify', - sentAt: '2022-10-11T13:10:54.877+05:30', - userId: 'user@45', - context: { - traits: { - age: '30', - city: 'Banglore', - email: 'test@user.com', - phone: '9876543210', - address: { city: 'ahmedabad', state: 'india' }, - lastName: 'user', - username: 'testUser', - firstName: 'test', - userCountry: 'india', - }, - }, - rudderId: 'caae04c5-959f-467b-a293-86f6c62d59e6', - messageId: 'b6ce7f31-5d76-4240-94d2-3eea020ef791', - timestamp: '2022-10-11T13:10:52.137+05:30', - receivedAt: '2022-10-11T13:10:52.138+05:30', - request_ip: '[::1]', - originalTimestamp: '2022-10-11T13:10:54.877+05:30', - }, - destination: { - Config: { - apiKey: 'dummyApiKey', - blacklistedEvents: [{ eventName: '' }], - eventDelivery: true, - eventDeliveryTS: 1665475307930, - eventFilteringOption: 'disable', - userAttributesMapping: [{ from: 'address', to: 'userAddress' }], - whitelistedEvents: [{ eventName: '' }], - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.refiner.io/v1/identify-user', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - Authorization: 'Bearer dummyApiKey', - }, - params: {}, - body: { - JSON: {}, - JSON_ARRAY: {}, - XML: {}, - FORM: { - age: '30', - city: 'Banglore', - email: 'test@user.com', - phone: '9876543210', - userId: 'user@45', - lastName: 'user', - username: 'testUser', - firstName: 'test', - userAddress: { city: 'ahmedabad', state: 'india' }, - userCountry: 'india', - }, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'refiner', - description: 'successful track call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'track', - event: 'Product Searched', - sentAt: '2022-10-11T13:38:31.827+05:30', - userId: 'user@45', - channel: 'web', - context: { - os: { name: '', version: '' }, - app: { - name: 'RudderLabs JavaScript SDK', - build: '1.0.0', - version: '1.1.2', - namespace: 'com.rudderlabs.javascript', - }, - page: { - url: 'http://0.0.0.0:1112/tests/html/ecomm_test.html', - path: '/tests/html/ecomm_test.html', - title: 'Fb Offline Conversion Ecommerce Test', - search: '', - referrer: 'http://0.0.0.0:1112/tests/html/', - }, - locale: 'en-GB', - screen: { density: 2 }, - traits: { - age: '30', - city: 'Banglore', - email: 'test@user.com', - phone: '9876543210', - lastName: 'user', - username: 'testUser', - firstName: 'test', - userCountry: 'india', - }, - library: { name: 'RudderLabs JavaScript SDK', version: '1.1.2' }, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36', - }, - rudderId: 'caae04c5-959f-467b-a293-86f6c62d59e6', - messageId: '9116b734-7e6b-4497-ab51-c16744d4487e', - timestamp: '2022-10-11T13:38:29.177+05:30', - properties: { - coupon: 'APPARELSALE', - currency: 'IND', - order_id: '5241735', - products: [ - { id: 'product-bacon-jam', category: 'Merch', brand: '' }, - { id: 'product-t-shirt', category: 'Merch', brand: 'Levis' }, - { id: 'offer-t-shirt', category: 'Merch', brand: 'Levis' }, - ], - }, - receivedAt: '2022-10-11T13:38:29.178+05:30', - request_ip: '[::1]', - originalTimestamp: '2022-10-11T13:38:31.827+05:30', - }, - destination: { - Config: { - apiKey: 'dummyApiKey', - blacklistedEvents: [{ eventName: '' }], - eventDelivery: true, - eventDeliveryTS: 1665475307930, - eventFilteringOption: 'disable', - userAttributesMapping: [{ from: 'address', to: 'userAddress' }], - whitelistedEvents: [{ eventName: '' }], - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - XML: {}, - FORM: { id: 'user@45', email: 'test@user.com', event: 'Product Searched' }, - JSON: {}, - JSON_ARRAY: {}, - }, - type: 'REST', - files: {}, - method: 'POST', - params: {}, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - Authorization: 'Bearer dummyApiKey', - }, - version: '1', - endpoint: 'https://api.refiner.io/v1/track', - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'refiner', - description: 'successful group call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - type: 'group', - sentAt: '2015-02-23T22:28:55.111Z', - traits: { name: 'rudder ventures', email: 'business@rudderstack.com' }, - userId: 'test@12', - channel: 'browser', - context: { - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36', - }, - groupId: 'group@123', - rudderId: 'd944be7a-c870-41ba-9fa5-f3c9dbf5f7e0', - messageId: '022bb90c-bbac-11e4-8dfc-aa07a5b093db', - request_ip: '[::1]', - integrations: { All: true }, - originalTimestamp: '2022-10-11T13:51:00.906+05:30', - }, - destination: { - Config: { - accountAttributesMapping: [{ from: 'email', to: 'businessEmail' }], - apiKey: 'dummyApiKey', - blacklistedEvents: [{ eventName: '' }], - eventDelivery: true, - eventDeliveryTS: 1665476456112, - eventFilteringOption: 'disable', - userAttributesMapping: [{ from: 'address', to: 'userAddress' }], - whitelistedEvents: [{ eventName: '' }], - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.refiner.io/v1/identify-user', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - Authorization: 'Bearer dummyApiKey', - }, - params: {}, - body: { - JSON: {}, - JSON_ARRAY: {}, - XML: {}, - FORM: { - id: 'test@12', - 'account[businessEmail]': 'business@rudderstack.com', - 'account[id]': 'group@123', - 'account[name]': 'rudder ventures', - }, - }, - files: {}, - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'refiner', - description: 'Refiner page call', - 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', - }, - 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', - ip: '0.0.0.0', - os: { name: '', version: '' }, - screen: { density: 2 }, - }, - type: 'page', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - timestamp: '2019-09-01T15:46:51.693229+05:30', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - path: '/abc', - referrer: 'xyz', - search: 'def', - title: 'ghi', - url: 'jkl', - }, - integrations: { All: true }, - name: 'pageviewed', - sentAt: '2019-10-14T11:15:53.296Z', - }, - destination: { - Config: { - accountAttributesMapping: [{ from: 'email', to: 'businessEmail' }], - apiKey: 'dummyApiKey', - blacklistedEvents: [{ eventName: '' }], - eventDelivery: true, - eventDeliveryTS: 1665476456112, - eventFilteringOption: 'disable', - userAttributesMapping: [{ from: 'address', to: 'userAddress' }], - whitelistedEvents: [{ eventName: '' }], - }, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - XML: {}, - FORM: { id: '12345', event: 'Viewed pageviewed Page' }, - JSON: {}, - JSON_ARRAY: {}, - }, - type: 'REST', - files: {}, - method: 'POST', - params: {}, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - Authorization: 'Bearer dummyApiKey', - }, - version: '1', - endpoint: 'https://api.refiner.io/v1/track', - userId: '', - }, - statusCode: 200, - }, - ], - }, - }, - }, + ...identifyTestData, + ...trackTestData, + ...pageTestData, + ...groupTestData, + ...validationTestData, ]; diff --git a/test/integrations/destinations/refiner/processor/groupTestData.ts b/test/integrations/destinations/refiner/processor/groupTestData.ts new file mode 100644 index 0000000000..e3a05357f5 --- /dev/null +++ b/test/integrations/destinations/refiner/processor/groupTestData.ts @@ -0,0 +1,91 @@ +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; +import { + generateMetadata, + transformResultBuilder, + generateSimplifiedGroupPayload, +} from '../../../testUtils'; + +const destination: Destination = { + ID: '123', + Name: 'refiner', + DestinationDefinition: { + ID: '123', + Name: 'refiner', + DisplayName: 'Refiner', + Config: {}, + }, + Config: { + apiKey: 'dummyApiKey', + blacklistedEvents: [{ eventName: '' }], + eventDelivery: true, + eventDeliveryTS: 1665474171943, + eventFilteringOption: 'disable', + whitelistedEvents: [{ eventName: '' }], + }, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const headers = { + Authorization: 'Bearer dummyApiKey', + 'Content-Type': 'application/x-www-form-urlencoded', +}; + +const endpoint = 'https://api.refiner.io/v1/identify-user'; + +export const groupTestData: ProcessorTestData[] = [ + { + id: 'refiner-group-test-1', + name: 'refiner', + description: 'Successful group call to create account and add user to account', + scenario: 'Framework', + successCriteria: 'Response status code should be 200 and it should contain all account traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: generateSimplifiedGroupPayload({ + userId: 'test@12', + groupId: 'group@123', + traits: { name: 'rudder ventures', email: 'business@rudderstack.com' }, + context: { + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36', + }, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + method: 'POST', + userId: '', + endpoint, + headers, + FORM: { + id: 'test@12', + 'account[email]': 'business@rudderstack.com', + 'account[id]': 'group@123', + 'account[name]': 'rudder ventures', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/refiner/processor/identifyTestData.ts b/test/integrations/destinations/refiner/processor/identifyTestData.ts new file mode 100644 index 0000000000..cc3704bb45 --- /dev/null +++ b/test/integrations/destinations/refiner/processor/identifyTestData.ts @@ -0,0 +1,114 @@ +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; +import { + generateMetadata, + generateSimplifiedIdentifyPayload, + transformResultBuilder, +} from '../../../testUtils'; + +const destination: Destination = { + ID: '123', + Name: 'refiner', + DestinationDefinition: { + ID: '123', + Name: 'refiner', + DisplayName: 'Refiner', + Config: {}, + }, + Config: { + apiKey: 'dummyApiKey', + blacklistedEvents: [{ eventName: '' }], + eventDelivery: true, + eventDeliveryTS: 1665474171943, + eventFilteringOption: 'disable', + whitelistedEvents: [{ eventName: '' }], + }, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const userTraits = { + age: '30', + city: 'Banglore', + email: 'test@user.com', + phone: '9876543210', + address: { city: 'ahmedabad', state: 'india' }, + lastName: 'user', + username: 'testUser', + firstName: 'test', + userCountry: 'india', +}; + +const expectedOutputUserTraits = { + address: { + city: 'ahmedabad', + state: 'india', + }, + age: '30', + city: 'Banglore', + email: 'test@user.com', + firstName: 'test', + lastName: 'user', + phone: '9876543210', + userCountry: 'india', + userId: 'user@45', + username: 'testUser', +}; + +const headers = { + Authorization: 'Bearer dummyApiKey', + 'Content-Type': 'application/x-www-form-urlencoded', +}; + +const endpoint = 'https://api.refiner.io/v1/identify-user'; + +export const identifyTestData: ProcessorTestData[] = [ + { + id: 'refiner-identify-test-1', + name: 'refiner', + description: 'Successful identify call to create user', + scenario: 'Framework', + successCriteria: + 'Response status code should be 200 and it should contain all user standard and custom traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: generateSimplifiedIdentifyPayload({ + userId: 'user@45', + context: { + traits: userTraits, + }, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + method: 'POST', + userId: '', + endpoint, + headers, + FORM: { + ...expectedOutputUserTraits, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/refiner/processor/pageTestData.ts b/test/integrations/destinations/refiner/processor/pageTestData.ts new file mode 100644 index 0000000000..b6c782202e --- /dev/null +++ b/test/integrations/destinations/refiner/processor/pageTestData.ts @@ -0,0 +1,99 @@ +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; +import { + generateMetadata, + transformResultBuilder, + generateSimplifiedPageOrScreenPayload, +} from '../../../testUtils'; + +const destination: Destination = { + ID: '123', + Name: 'refiner', + DestinationDefinition: { + ID: '123', + Name: 'refiner', + DisplayName: 'Refiner', + Config: {}, + }, + Config: { + apiKey: 'dummyApiKey', + blacklistedEvents: [{ eventName: '' }], + eventDelivery: true, + eventDeliveryTS: 1665474171943, + eventFilteringOption: 'disable', + userAttributesMapping: [{ from: 'address', to: 'userAddress' }], + whitelistedEvents: [{ eventName: '' }], + }, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const properties = { + order_id: '5241735', + coupon: 'APPARELSALE', + currency: 'IND', + products: [ + { id: 'product-bacon-jam', category: 'Merch', brand: '' }, + { id: 'product-t-shirt', category: 'Merch', brand: 'Levis' }, + { id: 'offer-t-shirt', category: 'Merch', brand: 'Levis' }, + ], +}; + +const headers = { + Authorization: 'Bearer dummyApiKey', + 'Content-Type': 'application/x-www-form-urlencoded', +}; + +const endpoint = 'https://api.refiner.io/v1/track'; + +export const pageTestData: ProcessorTestData[] = [ + { + id: 'refiner-track-test-1', + name: 'refiner', + description: 'Successful page call', + scenario: 'Framework', + successCriteria: + 'Response status code should be 200 and response should contain respective page name', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: generateSimplifiedPageOrScreenPayload({ + type: 'page', + userId: '12345', + context: { + traits: {}, + }, + name: 'pageviewed', + properties, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + method: 'POST', + userId: '', + endpoint, + headers, + FORM: { id: '12345', event: 'Viewed pageviewed Page' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/refiner/processor/trackTestData.ts b/test/integrations/destinations/refiner/processor/trackTestData.ts new file mode 100644 index 0000000000..e10ac6f0f5 --- /dev/null +++ b/test/integrations/destinations/refiner/processor/trackTestData.ts @@ -0,0 +1,109 @@ +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; +import { + generateMetadata, + transformResultBuilder, + generateSimplifiedTrackPayload, +} from '../../../testUtils'; + +const destination: Destination = { + ID: '123', + Name: 'refiner', + DestinationDefinition: { + ID: '123', + Name: 'refiner', + DisplayName: 'Refiner', + Config: {}, + }, + Config: { + apiKey: 'dummyApiKey', + blacklistedEvents: [{ eventName: '' }], + eventDelivery: true, + eventDeliveryTS: 1665474171943, + eventFilteringOption: 'disable', + userAttributesMapping: [{ from: 'address', to: 'userAddress' }], + whitelistedEvents: [{ eventName: '' }], + }, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const userTraits = { + age: '30', + city: 'Banglore', + email: 'test@user.com', + phone: '9876543210', + address: { city: 'ahmedabad', state: 'india' }, + lastName: 'user', + username: 'testUser', + firstName: 'test', + userCountry: 'india', +}; + +const properties = { + order_id: '5241735', + coupon: 'APPARELSALE', + currency: 'IND', + products: [ + { id: 'product-bacon-jam', category: 'Merch', brand: '' }, + { id: 'product-t-shirt', category: 'Merch', brand: 'Levis' }, + { id: 'offer-t-shirt', category: 'Merch', brand: 'Levis' }, + ], +}; + +const headers = { + Authorization: 'Bearer dummyApiKey', + 'Content-Type': 'application/x-www-form-urlencoded', +}; + +const endpoint = 'https://api.refiner.io/v1/track'; + +export const trackTestData: ProcessorTestData[] = [ + { + id: 'refiner-track-test-1', + name: 'refiner', + description: 'Track event call for Product Searched event', + scenario: 'Framework', + successCriteria: 'Response status code should be 200 and event name should be Product Searched', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: generateSimplifiedTrackPayload({ + userId: 'user@45', + event: 'Product Searched', + context: { + traits: userTraits, + }, + properties, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + method: 'POST', + userId: '', + endpoint, + headers, + FORM: { id: 'user@45', email: 'test@user.com', event: 'Product Searched' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/refiner/processor/validationTestData.ts b/test/integrations/destinations/refiner/processor/validationTestData.ts new file mode 100644 index 0000000000..20a9694fdf --- /dev/null +++ b/test/integrations/destinations/refiner/processor/validationTestData.ts @@ -0,0 +1,227 @@ +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; +import { generateMetadata } from '../../../testUtils'; + +const destination: Destination = { + ID: '123', + Name: 'refiner', + DestinationDefinition: { + ID: '123', + Name: 'refiner', + DisplayName: 'Refiner', + Config: {}, + }, + Config: { + apiKey: 'dummyApiKey', + blacklistedEvents: [{ eventName: '' }], + eventDelivery: true, + eventDeliveryTS: 1665474171943, + eventFilteringOption: 'disable', + whitelistedEvents: [{ eventName: '' }], + }, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const userTraits = { + age: '30', + city: 'Banglore', + email: 'test@user.com', + phone: '9876543210', + address: { city: 'ahmedabad', state: 'india' }, + lastName: 'user', + username: 'testUser', + firstName: 'test', + userCountry: 'india', +}; + +const properties = { + order_id: '5241735', + coupon: 'APPARELSALE', + currency: 'IND', + products: [ + { id: 'product-bacon-jam', category: 'Merch', brand: '' }, + { id: 'product-t-shirt', category: 'Merch', brand: 'Levis' }, + { id: 'offer-t-shirt', category: 'Merch', brand: 'Levis' }, + ], +}; + +const expectedStatTags = { + destType: 'REFINER', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'native', + module: 'destination', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', +}; + +export const validationTestData: ProcessorTestData[] = [ + { + id: 'refiner-validation-test-1', + name: 'refiner', + description: '[Error]: Check for no message type', + scenario: 'Framework', + successCriteria: 'Response status code should be 400 with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + userId: 'user@45', + context: { + traits: userTraits, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'Event type is required', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'refiner-validation-test-2', + name: 'refiner', + description: 'Error]: Check for unsupported message type', + scenario: 'Framework', + successCriteria: + 'Response should contain error message and status code should be 400, as we are sending a message type which is not supported by Klaviyo destination and the error message should be Event type alias is not supported', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + userId: 'user@45', + type: 'alias', + context: { + traits: userTraits, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'Event type "alias" is not supported', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'refiner-validation-test-3', + name: 'refiner', + description: 'Error]: userId and email is not present in payload', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400, it should throw instrumetation error with respective message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + type: 'identify', + context: { + traits: {}, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'At least one of `userId` or `email` is required', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'refiner-validation-test-4', + name: 'refiner', + description: 'Error]: event name is not present in payload', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400, it should throw instrumetation error with respective message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + type: 'track', + context: { + traits: userTraits, + }, + properties, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'Event name is required', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +];