From e37d6938aa6d74685a99fd417e2b96b79619f001 Mon Sep 17 00:00:00 2001 From: Anant Jain <62471433+anantjain45823@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:43:21 +0530 Subject: [PATCH] fix: main into develop conflicts (#2686) * fix(dm): updated the stats definition for the tracking plan service * fix(iterable): event id mapping (#2659) * chore(release): 1.43.1 * chore: update release owners (#2661) chore: update release stakeholder * chore(release): pull release/v1.44.0 into main (#2672) * fix(mixpanel): batch event ordering (#2608) * fix: bqstream event ordering fix (#2624) * fix: bqstream event ordering fix * fix: review comments addressed * fix: importing the common util function * fix: putting both error and successful events logic back * fix: test cases addition and code clean up * fix: code clean up * fix: resolving sonar error * fix: removing network handler for bqstream * fix: refactor process router dest * fix: use promise for prompts in personalize create tracking script (#2635) * fix(snyk): snyk updated versions merged to oen pr * chore: add ttl values for cache (#2593) * fix(hubspot): add validation for hubspotEvents (#2643) * fix: add optional chaining for error message in network handler of Intercom (#2648) fix bugsnag issue * fix(snyk): removed the new added dependencies * fix(snyk): removed aws-sdk dependency * feat: add circular reference check in flattern json (#2650) * chore: update fb_error message for invalid type of property value (#2656) fix: fb_error message for invalid type of property value * feat(iterable): user deletion support (#2621) * feat(iterable): user deletion support * feat(iterable): user deletion improvements * chore: added comments * feat(gaec): partial failures handling (#2631) * chore: partial failure handling * chore: code review changes * chore: move unit tests to correct place for mssql and postgres (#2657) * chore: move unit tests to correct place for mssql and postgres * chore: replace var to const * chore: replace var to const * feat: add axios mocking to component test-suite (#2638) * feat: tslint rules enable (#2604) * feat: remove eslint issues * fix: fixed es-lint tests * fix: merge conflicts * fix: add auth status inactive category handling to GA in userDeletion flow (#2669) * fix: refactor adjust using optional chaining (#2671) fix: refactor adj using opitonal chaining * chore(release): pull main into develop post release v1.43.1 (#2662) * fix(dm): updated the stats definition for the tracking plan service * fix(iterable): event id mapping (#2659) * chore(release): 1.43.1 * chore: update release owners (#2661) chore: update release stakeholder --------- Co-authored-by: Abhimanyu Babbar Co-authored-by: Mihir Bhalala <77438541+mihir-4116@users.noreply.github.com> Co-authored-by: GitHub Actions Co-authored-by: Anant Jain <62471433+anantjain45823@users.noreply.github.com> Co-authored-by: Sudip Paul <67197965+ItsSudip@users.noreply.github.com> * chore(release): 1.44.0 * feat(ga4): added support of filter user traits (#2679) * fix: add optional chaining for traits (#2677) * fix: add optional chaing for traits * update changelog * feat: geolocation support for python transformations (#2678) * feat: geolocation support for python transformations * chore: updating changelog --------- Co-authored-by: Anant Jain <62471433+anantjain45823@users.noreply.github.com> * update changelog * Update CHANGELOG.md --------- Co-authored-by: Gauravudia <60897972+Gauravudia@users.noreply.github.com> Co-authored-by: shrouti1507 <60211312+shrouti1507@users.noreply.github.com> Co-authored-by: Dilip Kola <33080863+koladilip@users.noreply.github.com> Co-authored-by: Sudip Paul <67197965+ItsSudip@users.noreply.github.com> Co-authored-by: Sanjay <71065320+Sanjay-Veernala@users.noreply.github.com> Co-authored-by: Siva Shanmukh Vetcha Co-authored-by: Ujjwal Abhishek <63387036+ujjwal-ab@users.noreply.github.com> Co-authored-by: Mihir Bhalala <77438541+mihir-4116@users.noreply.github.com> Co-authored-by: Sankeerth Co-authored-by: AASHISH MALIK Co-authored-by: Anant Jain <62471433+anantjain45823@users.noreply.github.com> Co-authored-by: Abhimanyu Babbar Co-authored-by: GitHub Actions Co-authored-by: Jayachand Co-authored-by: Anant Jain --------- Co-authored-by: Abhimanyu Babbar Co-authored-by: Mihir Bhalala <77438541+mihir-4116@users.noreply.github.com> Co-authored-by: GitHub Actions Co-authored-by: Sudip Paul <67197965+ItsSudip@users.noreply.github.com> Co-authored-by: devops-github-rudderstack <88187154+devops-github-rudderstack@users.noreply.github.com> Co-authored-by: Gauravudia <60897972+Gauravudia@users.noreply.github.com> Co-authored-by: shrouti1507 <60211312+shrouti1507@users.noreply.github.com> Co-authored-by: Dilip Kola <33080863+koladilip@users.noreply.github.com> Co-authored-by: Sanjay <71065320+Sanjay-Veernala@users.noreply.github.com> Co-authored-by: Siva Shanmukh Vetcha Co-authored-by: Ujjwal Abhishek <63387036+ujjwal-ab@users.noreply.github.com> Co-authored-by: Sankeerth Co-authored-by: AASHISH MALIK Co-authored-by: Jayachand --- CHANGELOG.md | 27 +++ package-lock.json | 4 +- package.json | 2 +- src/util/openfaas/index.js | 4 + src/v0/destinations/clevertap/transform.js | 2 +- src/v0/destinations/ga4/transform.js | 6 +- src/v0/destinations/ga4/utils.js | 36 ++- src/v0/destinations/ga4/utils.test.js | 252 ++++++++++++++++++++- test/__tests__/data/clevertap_input.json | 91 ++++++-- test/__tests__/data/clevertap_output.json | 81 +++++-- test/integrations/testUtils.ts | 1 - 11 files changed, 447 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 509ddabe0a..621c6709bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,33 @@ 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.44.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.43.1...v1.44.0) (2023-09-29) + + +### Features + +* add geolocation support for python transformations ([#2678](https://github.com/rudderlabs/rudder-transformer/issues/2678)) ([b688c4a](https://github.com/rudderlabs/rudder-transformer/commit/b688c4a6889250bacfd2a81c9de8a1436281daa9)) +* add axios mocking to component test-suite ([#2638](https://github.com/rudderlabs/rudder-transformer/issues/2638)) ([100c808](https://github.com/rudderlabs/rudder-transformer/commit/100c80881eb99716198231deb9ec0e69dc3fa2a0)) +* add circular reference check in flattern json ([#2650](https://github.com/rudderlabs/rudder-transformer/issues/2650)) ([a21ea3a](https://github.com/rudderlabs/rudder-transformer/commit/a21ea3aaecfc3d10de3f4eaa34425dda388032ff)) +* **gaec:** partial failures handling ([#2631](https://github.com/rudderlabs/rudder-transformer/issues/2631)) ([0008277](https://github.com/rudderlabs/rudder-transformer/commit/0008277fe43d20ced4066f8f1f1b0f1d12345f01)) +* **iterable:** user deletion support ([#2621](https://github.com/rudderlabs/rudder-transformer/issues/2621)) ([c0ab19a](https://github.com/rudderlabs/rudder-transformer/commit/c0ab19a293a72ea0a7575b863356aea9a0e6762f)) +* tslint rules enable ([#2604](https://github.com/rudderlabs/rudder-transformer/issues/2604)) ([4d6c4b8](https://github.com/rudderlabs/rudder-transformer/commit/4d6c4b834de005484dc1099a52c69ab6212273e8)) + + +### Bug Fixes +* add optional chaining for traits ([#2677](https://github.com/rudderlabs/rudder-transformer/issues/2677)) ([b80bfbc](https://github.com/rudderlabs/rudder-transformer/commit/b80bfbc8a6afdef57ad5f2560bb803c8e00bcbfc)) +* add auth status inactive category handling to GA in userDeletion flow ([#2669](https://github.com/rudderlabs/rudder-transformer/issues/2669)) ([b784800](https://github.com/rudderlabs/rudder-transformer/commit/b7848004e2679ec7278c8381560cb1a77da6c642)) +* add optional chaining for error message in network handler of Intercom ([#2648](https://github.com/rudderlabs/rudder-transformer/issues/2648)) ([10a13bc](https://github.com/rudderlabs/rudder-transformer/commit/10a13bcf7f987de45540b52d414883664e43f9cd)) +* bqstream event ordering fix ([#2624](https://github.com/rudderlabs/rudder-transformer/issues/2624)) ([e97e7ca](https://github.com/rudderlabs/rudder-transformer/commit/e97e7caed20ffb007f1c543e15c15c6e89e2dfb7)) +* **hubspot:** add validation for hubspotEvents ([#2643](https://github.com/rudderlabs/rudder-transformer/issues/2643)) ([b49d0ee](https://github.com/rudderlabs/rudder-transformer/commit/b49d0ee576f55e5f95e3d02b7111e995fc9b8ada)) +* **mixpanel:** batch event ordering ([#2608](https://github.com/rudderlabs/rudder-transformer/issues/2608)) ([36c7f06](https://github.com/rudderlabs/rudder-transformer/commit/36c7f06ccfa534b751ca9b3f5c41e9bb6d2e9f00)) +* refactor adjust using optional chaining ([#2671](https://github.com/rudderlabs/rudder-transformer/issues/2671)) ([f63b493](https://github.com/rudderlabs/rudder-transformer/commit/f63b4932d5ba467a82a36d3e8b80578f81f729cf)) +* **snyk:** fix dependencies version from snyk ([#2640](https://github.com/rudderlabs/rudder-transformer/issues/2640)) ([8422744](https://github.com/rudderlabs/rudder-transformer/commit/8422744b3af48f71358f7acbe2df7b3688ce04a8)) +* **snyk:** removed aws-sdk dependency ([08a3535](https://github.com/rudderlabs/rudder-transformer/commit/08a3535257e5d84566c95cebc701613478f0e039)) +* **snyk:** removed the new added dependencies ([364779c](https://github.com/rudderlabs/rudder-transformer/commit/364779ce959d7548e5cf1cc8c718b71331dcb378)) +* **snyk:** snyk updated versions merged to oen pr ([16a9b8e](https://github.com/rudderlabs/rudder-transformer/commit/16a9b8e6cc26a8df1331cb1af8774df7cc05c959)) +* use promise for prompts in personalize create tracking script ([#2635](https://github.com/rudderlabs/rudder-transformer/issues/2635)) ([5fbddd1](https://github.com/rudderlabs/rudder-transformer/commit/5fbddd1490b16dbda6bca19df4cac5bef6ff78c5)) + ### [1.43.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.43.0...v1.43.1) (2023-09-26) diff --git a/package-lock.json b/package-lock.json index 944b00860c..895ec6c211 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.43.1", + "version": "1.44.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.43.1", + "version": "1.44.0", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "^0.7.24", diff --git a/package.json b/package.json index ddb20fe411..8f23db4f7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.43.1", + "version": "1.44.0", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": { diff --git a/src/util/openfaas/index.js b/src/util/openfaas/index.js index 1b3e531ceb..60ad316e1b 100644 --- a/src/util/openfaas/index.js +++ b/src/util/openfaas/index.js @@ -20,6 +20,7 @@ const FAAS_MAX_INFLIGHT = process.env.FAAS_MAX_INFLIGHT || '4'; const FAAS_EXEC_TIMEOUT = process.env.FAAS_EXEC_TIMEOUT || '4s'; const FAAS_ENABLE_WATCHDOG_ENV_VARS = process.env.FAAS_ENABLE_WATCHDOG_ENV_VARS || 'true'; const CONFIG_BACKEND_URL = process.env.CONFIG_BACKEND_URL || 'https://api.rudderlabs.com'; +const GEOLOCATION_URL = process.env.GEOLOCATION_URL || ''; const FAAS_AST_VID = 'ast'; const FAAS_AST_FN_NAME = 'fn-ast'; @@ -128,6 +129,9 @@ const deployFaasFunction = async (functionName, code, versionId, libraryVersionI envVars.max_inflight = FAAS_MAX_INFLIGHT; envVars.exec_timeout = FAAS_EXEC_TIMEOUT; } + if (GEOLOCATION_URL) { + envVars.geolocation_url = GEOLOCATION_URL; + } // TODO: investigate and add more required labels and annotations const payload = { service: functionName, diff --git a/src/v0/destinations/clevertap/transform.js b/src/v0/destinations/clevertap/transform.js index 7ce864aae2..e3d9ca1083 100644 --- a/src/v0/destinations/clevertap/transform.js +++ b/src/v0/destinations/clevertap/transform.js @@ -232,7 +232,7 @@ const getClevertapProfile = (message, category) => { if (message.traits?.overrideFields) { const { overrideFields } = message.traits; Object.assign(profile, overrideFields); - } else if (message.context.traits?.overrideFields) { + } else if (message.context?.traits?.overrideFields) { const { overrideFields } = message.context.traits; Object.assign(profile, overrideFields); } diff --git a/src/v0/destinations/ga4/transform.js b/src/v0/destinations/ga4/transform.js index dc89927085..d1d0790fa9 100644 --- a/src/v0/destinations/ga4/transform.js +++ b/src/v0/destinations/ga4/transform.js @@ -106,7 +106,7 @@ const responseBuilder = (message, { Config }) => { } break; default: - throw ConfigurationError('Invalid type of client'); + throw new ConfigurationError('Invalid type of client'); } let payload = {}; @@ -119,7 +119,7 @@ const responseBuilder = (message, { Config }) => { payload.name = evConfigEvent; payload.params = constructPayload(message, mappingConfig[name]); - const { items, mapRootLevelPropertiesToGA4ItemsArray } = getItemsArray(message, item, itemList) + const { items, mapRootLevelPropertiesToGA4ItemsArray } = getItemsArray(message, item, itemList); if (items.length > 0) { payload.params.items = items; @@ -233,7 +233,7 @@ const responseBuilder = (message, { Config }) => { } // Prepare GA4 user properties - const userProperties = prepareUserProperties(message); + const userProperties = prepareUserProperties(message, Config.piiPropertiesToIgnore); if (!isEmptyObject(userProperties)) { rawPayload.user_properties = userProperties; } diff --git a/src/v0/destinations/ga4/utils.js b/src/v0/destinations/ga4/utils.js index 4bb35e3fdd..d356300ff7 100644 --- a/src/v0/destinations/ga4/utils.js +++ b/src/v0/destinations/ga4/utils.js @@ -166,13 +166,15 @@ const GA4_ITEM_EXCLUSION = [ ]; /** - * Remove arrays and objects from transformed payload - * @param {*} params - * @returns + * Remove arrays and objects from transformed payload + * @param {*} params + * @returns */ const removeInvalidParams = (params) => Object.fromEntries( - Object.entries(params).filter(([key, value]) => key === 'items' || (typeof value !== 'object' && !isEmpty(value))), + Object.entries(params).filter( + ([key, value]) => key === 'items' || (typeof value !== 'object' && !isEmpty(value)), + ), ); /** @@ -244,10 +246,10 @@ const getItem = (message, isItemsRequired) => { /** * Returns items array for ga4 event payload - * @param {*} message - * @param {*} item - * @param {*} itemList - * @returns + * @param {*} message + * @param {*} item + * @param {*} itemList + * @returns */ const getItemsArray = (message, item, itemList) => { let items = []; @@ -269,7 +271,7 @@ const getItemsArray = (message, item, itemList) => { } return { items, mapRootLevelPropertiesToGA4ItemsArray }; -} +}; /** * get exclusion list for a particular event * ga4ExclusionList contains the sourceKeys that are already mapped @@ -398,13 +400,25 @@ const isValidUserProperty = (key, value) => { /** * Function to validate and prepare user_properties * @param {*} message + * @param {*} piiPropertiesToIgnore + * @returns */ -const prepareUserProperties = (message) => { +const prepareUserProperties = (message, piiPropertiesToIgnore = []) => { + // Exclude PII user traits + const piiProperties = []; + if (piiPropertiesToIgnore.length > 0) { + piiPropertiesToIgnore.forEach((property) => { + if (typeof property.piiProperty === 'string' && property.piiProperty.trim() !== '') { + piiProperties.push(property.piiProperty.trim()); + } + }); + } + const userProperties = extractCustomFields( message, {}, ['properties.user_properties', 'context.traits'], - GA4_RESERVED_USER_PROPERTY_EXCLUSION, + [...GA4_RESERVED_USER_PROPERTY_EXCLUSION, ...piiProperties], ); const validatedUserProperties = Object.entries(userProperties) diff --git a/src/v0/destinations/ga4/utils.test.js b/src/v0/destinations/ga4/utils.test.js index a39fef6f5e..7826c23d35 100644 --- a/src/v0/destinations/ga4/utils.test.js +++ b/src/v0/destinations/ga4/utils.test.js @@ -2,7 +2,7 @@ const { validateEventName, prepareUserProperties, removeInvalidParams } = requir const userPropertyData = [ { - description: "Should validate and prepare user_properties", + description: 'Should validate and prepare user_properties', input: { userId: 'user@1', group_id: 'group@1', @@ -163,6 +163,256 @@ describe('Google Analytics 4 utils test', () => { }); describe('prepareUserProperties function tests', () => { + // Empty message and context returns empty object + it('should return empty object when message and context are empty', () => { + // Arrange + const message = {}; + const context = {}; + + // Act + const result = prepareUserProperties(message, []); + + // Assert + expect(result).toEqual({}); + }); + + // Filters out reserved and PII properties + it('should filter out reserved and PII properties', () => { + // Arrange + const message = { + context: { + traits: { + property3: 'value3', + property4: 'value4', + pii_property3: 'pii_value3', + pii_property4: 'pii_value4', + }, + }, + properties: { + user_properties: { + property1: 'value1', + property2: 'value2', + pii_property1: 'pii_value1', + pii_property2: 'pii_value2', + }, + }, + }; + + const piiPropertiesToIgnore = [ + { piiProperty: 'pii_property1' }, + { piiProperty: 'pii_property2' }, + { piiProperty: 'pii_property3' }, + { piiProperty: 'pii_property4' }, + ]; + + // Act + const result = prepareUserProperties(message, piiPropertiesToIgnore); + + // Assert + expect(result).toEqual({ + property1: { value: 'value1' }, + property2: { value: 'value2' }, + property3: { value: 'value3' }, + property4: { value: 'value4' }, + }); + }); + + // Validates user properties and returns them in expected format + it('should validate user properties and return them in expected format', () => { + // Arrange + const message = { + context: { + traits: { + valid_property3: 'value3', + _invalid_property3: '12_invalid_value3', + valid_property4: 'value4', + invalid_property4: [], + }, + }, + properties: { + user_properties: { + valid_property1: 'value1', + '12invalid_property1': 'ga_invalid_value1', + valid_property2: 'value2', + ga_invalid_property2: 'google_invalid_value2', + }, + }, + }; + // Act + const result = prepareUserProperties(message, []); + + // Assert + expect(result).toEqual({ + valid_property1: { value: 'value1' }, + valid_property2: { value: 'value2' }, + valid_property3: { value: 'value3' }, + valid_property4: { value: 'value4' }, + }); + }); + + // Invalid user properties are filtered out + + // User properties with invalid value types are filtered out + it('should filter out user properties with invalid value types', () => { + // Arrange + const message = { + context: { + traits: { + valid_property3: 'value3', + invalid_property3: { 456: 'value3' }, + valid_property4: 'value4', + invalid_property4: '01234567890123456789012345678901234567890123456789', + }, + }, + properties: { + user_properties: { + valid_property1: 'value1', + invalid_property1: [123, 456], + valid_property2: 'value2', + }, + }, + }; + + // Act + const result = prepareUserProperties(message, []); + + // Assert + expect(result).toEqual({ + valid_property1: { value: 'value1' }, + valid_property2: { value: 'value2' }, + valid_property3: { value: 'value3' }, + valid_property4: { value: 'value4' }, + }); + }); + + // PII properties are filtered out + it('should filter out PII properties from user_properties', () => { + // Arrange + const message = { + properties: { + user_properties: { + property1: 'value1', + property2: 'value2', + pii_property1: 'pii_value1', + pii_property2: 'pii_value2', + }, + }, + }; + const piiPropertiesToIgnore = [ + { piiProperty: 'pii_property1' }, + { piiProperty: 'pii_property2' }, + ]; + + // Act + const result = prepareUserProperties(message, piiPropertiesToIgnore); + + // Assert + expect(result).toEqual({ + property1: { value: 'value1' }, + property2: { value: 'value2' }, + }); + }); + + // PII properties are undefined + it('should return undefined when user_properties is undefined', () => { + // Arrange + const message = { + properties: { + user_properties: { + property1: 'value1', + property2: 'value2', + pii_property1: 'pii_value1', + pii_property2: 'pii_value2', + }, + }, + }; + const piiPropertiesToIgnore = undefined; + + // Act + const result = prepareUserProperties(message, piiPropertiesToIgnore); + + // Assert + expect(result).toEqual({ + pii_property1: { value: 'pii_value1' }, + pii_property2: { value: 'pii_value2' }, + property1: { value: 'value1' }, + property2: { value: 'value2' }, + }); + }); + + // User properties with valid keys and values are returned in expected format + it('should return user properties with valid keys and values in expected format', () => { + // Arrange + const message = { + properties: { + user_properties: { + property1: 'value1', + property2: 'value2', + }, + }, + }; + + // Act + const result = prepareUserProperties(message, []); + + // Assert + expect(result).toEqual({ + property1: { value: 'value1' }, + property2: { value: 'value2' }, + }); + }); + + // User properties with valid keys but invalid values are filtered out + it('should filter out user properties with invalid values', () => { + // Arrange + const message = { + properties: { + user_properties: { + validKey1: 'validValue1', + validKey2: 'validValue2', + invalidKey1: '', + invalidKey2: + 'invalidValueThatIsTooLongInvalidValueThatIsTooLongInvalidValueThatIsTooLongInvalidValueThatIsTooLong', + validKey4: true, + }, + }, + }; + const piiPropertiesToIgnore = []; + + // Act + const result = prepareUserProperties(message, piiPropertiesToIgnore); + + // Assert + expect(result).toEqual({ + validKey1: { value: 'validValue1' }, + validKey2: { value: 'validValue2' }, + validKey4: { value: true }, + }); + }); + // User properties with keys starting with reserved prefixes are filtered out + it('should filter out user properties with keys starting with reserved prefixes', () => { + // Arrange + const message = { + properties: { + user_properties: { + google_property: 'value1', + ga_property: 'value2', + firebase_property: 'value3', + valid_property: 'value4', + }, + }, + }; + const piiPropertiesToIgnore = []; + + // Act + const result = prepareUserProperties(message, piiPropertiesToIgnore); + + // Assert + expect(result).toEqual({ + valid_property: { value: 'value4' }, + }); + }); + userPropertyData.forEach((dataPoint) => { it(`${dataPoint.description}`, () => { try { diff --git a/test/__tests__/data/clevertap_input.json b/test/__tests__/data/clevertap_input.json index e8aaa4b528..e0bb1241e2 100644 --- a/test/__tests__/data/clevertap_input.json +++ b/test/__tests__/data/clevertap_input.json @@ -2,7 +2,56 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", + "accountId": "476550467", + "trackAnonymous": true, + "enableObjectIdMapping": false + } + }, + "message": { + "channel": "web", + "messageId": "84e26acc-56a5-4835-8233-591137fca468", + "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", + "originalTimestamp": "2019-10-14T09:03:17.562Z", + "anonymousId": "anon_id", + "type": "identify", + "traits": { + "anonymousId": "anon_id", + "email": "jamesDoe@gmail.com", + "name": "James Doe", + "phone": "92374162212", + "gender": "M", + "employed": true, + "birthday": "1614775793", + "education": "Science", + "graduate": true, + "married": true, + "customerType": "Prime", + "msg_push": true, + "msgSms": true, + "msgemail": true, + "msgwhatsapp": false, + "custom_tags": ["Test_User", "Interested_User", "DIY_Hobby"], + "custom_mappings": { + "Office": "Trastkiv", + "Country": "Russia" + }, + "address": { + "city": "kolkata", + "country": "India", + "postalCode": 789223, + "state": "WB", + "street": "" + } + }, + "integrations": { "All": true }, + "sentAt": "2019-10-14T09:03:22.563Z" + } + }, + { + "destination": { + "Config": { + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -65,7 +114,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -91,7 +140,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -116,7 +165,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -139,7 +188,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -161,7 +210,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -184,7 +233,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -279,7 +328,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": false, "enableObjectIdMapping": false @@ -302,7 +351,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -365,7 +414,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -428,7 +477,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": true @@ -499,7 +548,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": true @@ -566,7 +615,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": true @@ -587,7 +636,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": true @@ -608,7 +657,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -682,7 +731,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": true @@ -750,7 +799,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": true @@ -772,7 +821,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -850,7 +899,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -930,7 +979,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": false @@ -1015,7 +1064,7 @@ { "destination": { "Config": { - "passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "passcode": "sample_passcode", "accountId": "476550467", "trackAnonymous": true, "enableObjectIdMapping": true diff --git a/test/__tests__/data/clevertap_output.json b/test/__tests__/data/clevertap_output.json index fc6a4ee2c3..947cc2da21 100644 --- a/test/__tests__/data/clevertap_output.json +++ b/test/__tests__/data/clevertap_output.json @@ -6,7 +6,52 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", + "Content-Type": "application/json" + }, + "params": {}, + "body": { + "JSON": { + "d": [ + { + "type": "profile", + "profileData": { + "Email": "jamesDoe@gmail.com", + "Name": "James Doe", + "Phone": "92374162212", + "Gender": "M", + "Employed": true, + "DOB": "1614775793", + "Education": "Science", + "Married": true, + "Customer Type": "Prime", + "graduate": true, + "msg_push": true, + "msgSms": true, + "msgemail": true, + "msgwhatsapp": false, + "custom_tags": "[\"Test_User\",\"Interested_User\",\"DIY_Hobby\"]", + "custom_mappings": "{\"Office\":\"Trastkiv\",\"Country\":\"Russia\"}", + "address": "{\"city\":\"kolkata\",\"country\":\"India\",\"postalCode\":789223,\"state\":\"WB\",\"street\":\"\"}" + }, + "identity": "anon_id" + } + ] + }, + "JSON_ARRAY": {}, + "XML": {}, + "FORM": {} + }, + "files": {} + }, + { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://api.clevertap.com/1/upload", + "headers": { + "X-CleverTap-Account-Id": "476550467", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, @@ -69,7 +114,7 @@ "params": {}, "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "version": "1", @@ -99,7 +144,7 @@ "params": {}, "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "version": "1", @@ -130,7 +175,7 @@ "params": {}, "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "version": "1", @@ -149,7 +194,7 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, @@ -212,7 +257,7 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, @@ -257,7 +302,7 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, @@ -302,7 +347,7 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, @@ -334,7 +379,7 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, @@ -365,7 +410,7 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, @@ -414,7 +459,7 @@ "params": {}, "headers": { "Content-Type": "application/json", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "X-CleverTap-Account-Id": "476550467" }, "version": "1", @@ -445,7 +490,7 @@ "params": {}, "headers": { "Content-Type": "application/json", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "X-CleverTap-Account-Id": "476550467" }, "version": "1", @@ -458,7 +503,7 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, @@ -505,7 +550,7 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, @@ -537,7 +582,7 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, @@ -585,7 +630,7 @@ "params": {}, "headers": { "Content-Type": "application/json", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "X-CleverTap-Account-Id": "476550467" }, "version": "1", @@ -598,7 +643,7 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, @@ -645,7 +690,7 @@ "endpoint": "https://api.clevertap.com/1/upload", "headers": { "X-CleverTap-Account-Id": "476550467", - "X-CleverTap-Passcode": "fbee74a147828e2932c701d19dc1f2dcfa4ac0048be3aa3a88d427090a59dc1c0fa002f1", + "X-CleverTap-Passcode": "sample_passcode", "Content-Type": "application/json" }, "params": {}, diff --git a/test/integrations/testUtils.ts b/test/integrations/testUtils.ts index 92cffadcf2..13fc7c7f75 100644 --- a/test/integrations/testUtils.ts +++ b/test/integrations/testUtils.ts @@ -65,7 +65,6 @@ export const addMock = (mock: MockAdapter, axiosMock: MockHttpCallsData) => { break; } }; - export const overrideDestination = (destination, overrideConfigValues) => { return Object.assign({}, destination, { Config: { ...destination.Config, ...overrideConfigValues },