From 8bf56cc7914bda530b0bf3fb16bfece6be542ddd Mon Sep 17 00:00:00 2001 From: shrouti1507 <60211312+shrouti1507@users.noreply.github.com> Date: Thu, 4 Jan 2024 11:42:18 +0530 Subject: [PATCH 1/2] fix: for gainsight px only new users to have default signUp date (#2953) * fix: only new users to have default signUp date * fix: only new users to have default createDate * fix: small edit in comment * fix: small edit in comment * fix: small edit in comment * fix: review comments addressed --- .../data/GainsightPX_Identify.json | 14 +- src/v0/destinations/gainsight_px/transform.js | 20 +- .../gainsight_px/processor/data.ts | 4020 +++++++++-------- .../destinations/gainsight_px/router/data.ts | 1093 +++-- 4 files changed, 2729 insertions(+), 2418 deletions(-) diff --git a/src/v0/destinations/gainsight_px/data/GainsightPX_Identify.json b/src/v0/destinations/gainsight_px/data/GainsightPX_Identify.json index 5d07b290dc..c37c992d84 100644 --- a/src/v0/destinations/gainsight_px/data/GainsightPX_Identify.json +++ b/src/v0/destinations/gainsight_px/data/GainsightPX_Identify.json @@ -55,12 +55,7 @@ }, { "destKey": "signUpDate", - "sourceKeys": [ - "traits.signUpDate", - "context.traits.signUpDate", - "timestamp", - "originalTimestamp" - ], + "sourceKeys": ["traits.signUpDate", "context.traits.signUpDate"], "required": false, "metadata": { "type": "timestamp" @@ -109,12 +104,7 @@ }, { "destKey": "createDate", - "sourceKeys": [ - "traits.createDate", - "context.traits.createDate", - "timestamp", - "originalTimestamp" - ], + "sourceKeys": ["traits.createDate", "context.traits.createDate"], "required": false, "metadata": { "type": "timestamp" diff --git a/src/v0/destinations/gainsight_px/transform.js b/src/v0/destinations/gainsight_px/transform.js index 4d91980f11..a63be08c80 100644 --- a/src/v0/destinations/gainsight_px/transform.js +++ b/src/v0/destinations/gainsight_px/transform.js @@ -1,5 +1,9 @@ /* eslint-disable no-nested-ternary */ -const { InstrumentationError, ConfigurationError } = require('@rudderstack/integrations-lib'); +const { + InstrumentationError, + ConfigurationError, + formatTimeStamp, +} = require('@rudderstack/integrations-lib'); const { EventType } = require('../../../constants'); const { isEmptyObject, @@ -47,7 +51,7 @@ const identifyResponseBuilder = async (message, { Config }) => { 'Content-Type': JSON_MIME_TYPE, }; - const { success: isPresent } = await objectExists(userId, Config, 'user'); + const { success: isUserPresent } = await objectExists(userId, Config, 'user'); let payload = constructPayload(message, identifyMapping); const name = getValueFromMessage(message, ['traits.name', 'context.traits.name']); @@ -56,6 +60,16 @@ const identifyResponseBuilder = async (message, { Config }) => { payload.firstName = fName; payload.lastName = lName; } + // Only for the case of new user creation, if signUpDate is not provided in traits, timestamp / originalTimestamp is mapped + if (!isUserPresent && !payload.signUpDate) { + payload.signUpDate = formatTimeStamp(message.timestamp || message.originalTimestamp); + } + + // Only for the case of new user creation, if createDate is not provided in traits, timestamp / originalTimestamp is mapped + if (!isUserPresent && !payload.createDate) { + payload.createDate = formatTimeStamp(message.timestamp || message.originalTimestamp); + } + let customAttributes = {}; customAttributes = extractCustomFields( message, @@ -75,7 +89,7 @@ const identifyResponseBuilder = async (message, { Config }) => { type: 'USER', }; - if (isPresent) { + if (isUserPresent) { // update user response.method = defaultPutRequestConfig.requestMethod; response.endpoint = `${ENDPOINTS.USERS_ENDPOINT}/${userId}`; diff --git a/test/integrations/destinations/gainsight_px/processor/data.ts b/test/integrations/destinations/gainsight_px/processor/data.ts index 192c6969c4..3dfe86aa98 100644 --- a/test/integrations/destinations/gainsight_px/processor/data.ts +++ b/test/integrations/destinations/gainsight_px/processor/data.ts @@ -1,1857 +1,2165 @@ export const data = [ - { - "name": "gainsight_px", - "description": "Test 0", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "globalContextMap": [ - { - "from": "projectId", - "to": "p-123" - }, - { - "from": "tag", - "to": "sample-category-tag" - } - ] - } - }, - "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 - } - }, - "userId": "sample-user-id", - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "sample-anon-id", - "type": "track", - "event": "Product Added", - "properties": { - "product_id": "123", - "sku": "F16", - "category": "Games", - "name": "Game", - "brand": "Gamepro", - "variant": "111", - "price": 13.49, - "quantity": 11, - "coupon": "DISC21", - "position": 1, - "url": "https://www.website.com/product/path", - "image_url": "https://www.website.com/product/path.png" - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "output": { - "body": { - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {}, - "JSON": { - "attributes": { - "product_id": "123", - "sku": "F16", - "category": "Games", - "name": "Game", - "brand": "Gamepro", - "variant": "111", - "price": 13.49, - "quantity": 11, - "coupon": "DISC21", - "position": 1, - "url": "https://www.website.com/product/path", - "image_url": "https://www.website.com/product/path.png" - }, - "propertyKey": "AP-XABC-123", - "userType": "USER", - "identifyId": "sample-user-id", - "date": 1571043797562, - "eventName": "Product Added", - "globalContext": { - "projectId": "p-123", - "tag": "sample-category-tag" - } - } - }, - "type": "REST", - "files": {}, - "method": "POST", - "params": {}, - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "version": "1", - "endpoint": "https://api.aptrinsic.com/v1/events/custom", - "userId": "" - }, - "statusCode": 200 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 1", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "globalContextMap": [ - { - "from": "projectId", - "to": "p-123" - }, - { - "from": "tag", - "to": "sample-category-tag" - } - ] - } - }, - "message": { - "channel": "web", - "context": { - "os": { - "name": "", - "version": "" - }, - "app": { - "name": "RudderLabs JavaScript SDK", - "version": "1.27.0", - "namespace": "com.rudderlabs.javascript" - }, - "page": { - "url": "http://127.0.0.1:8887/", - "path": "/", - "title": "RudderStack in 5", - "search": "", - "tab_url": "http://127.0.0.1:8887/", - "referrer": "$direct", - "initial_referrer": "$direct", - "referring_domain": "", - "initial_referring_domain": "" - }, - "locale": "en-US", - "screen": { - "width": 1512, - "height": 982, - "density": 2, - "innerWidth": 774, - "innerHeight": 774 - }, - "library": { - "name": "RudderLabs JavaScript SDK", - "version": "1.27.0" - }, - "campaign": {}, - "sessionId": 1679967592314, - "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36", - "properties": { - "email": "84@84.com", - "price": "56.0", - "quantity": "5" - } - }, - "userId": "sample-user-id", - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "sample-anon-id", - "type": "track", - "event": "Marketing - Plan Change Events", - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "output": { - "body": { - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {}, - "JSON": { - "attributes": {}, - "url": "http://127.0.0.1:8887/", - "propertyKey": "AP-XABC-123", - "userType": "USER", - "identifyId": "sample-user-id", - "referrer": "$direct", - "date": 1571043797562, - "sessionId": 1679967592314, - "eventName": "Marketing - Plan Change Events", - "globalContext": { - "projectId": "p-123", - "tag": "sample-category-tag" - } - } - }, - "type": "REST", - "files": {}, - "method": "POST", - "params": {}, - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "version": "1", - "endpoint": "https://api.aptrinsic.com/v1/events/custom", - "userId": "" - }, - "statusCode": 200 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 2", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "globalContextMap": [ - { - "from": "projectId", - "to": "p-123" - }, - { - "from": "tag", - "to": "sample-category-tag" - } - ] - } - }, - "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 - } - }, - "userId": "sample-user-id", - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "sample-anon-id", - "type": "track", - "event": "Track Me", - "properties": { - "description": "Sample Track call", - "globalContext": { - "testOverride": "some-value" - } - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "output": { - "body": { - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {}, - "JSON": { - "attributes": { - "description": "Sample Track call" - }, - "propertyKey": "AP-XABC-123", - "userType": "USER", - "identifyId": "sample-user-id", - "date": 1571043797562, - "eventName": "Track Me", - "globalContext": { - "testOverride": "some-value" - } - } - }, - "type": "REST", - "files": {}, - "method": "POST", - "params": {}, - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "version": "1", - "endpoint": "https://api.aptrinsic.com/v1/events/custom", - "userId": "" - }, - "statusCode": 200 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 3", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [ - { - "from": "hobbyCustomField", - "to": "hobby" - } - ], - "globalContextMap": [] - } - }, - "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", - "userId": "sample-user-id", - "anonymousId": "sample-anon-id", - "type": "identify", - "traits": { - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User", - "signUpDate": 1624431528295, - "title": "engineer", - "countryName": "USA", - "countryCode": "US", - "city": "New York", - "hobbyCustomField": "Sample Hobby" - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "output": { - "body": { - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {}, - "JSON": { - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User", - "signUpDate": 1624431528295, - "createDate": 1571043797562, - "title": "engineer", - "propertyKeys": [ - "AP-XABC-123" - ], - "location": { - "countryName": "USA", - "countryCode": "US", - "city": "New York" - }, - "customAttributes": { - "hobby": "Sample Hobby" - } - } - }, - "type": "REST", - "files": {}, - "method": "PUT", - "params": {}, - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "version": "1", - "endpoint": "https://api.aptrinsic.com/v1/users/sample-user-id", - "userId": "" - }, - "statusCode": 200 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 4", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [], - "globalContextMap": [] - } - }, - "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 - }, - "traits": { - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User", - "medium": null - } - }, - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "sample-anon-id", - "userId": "sample-user-id", - "groupId": "ecorp-id", - "type": "group", - "traits": { - "name": "ECorp", - "industry": "software", - "numberOfEmployees": 400, - "website": "www.ecorp.com", - "plan": "premium" - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "output": { - "body": { - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {}, - "JSON": { - "accountId": "ecorp-id" - } - }, - "type": "REST", - "files": {}, - "method": "PUT", - "params": {}, - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "version": "1", - "endpoint": "https://api.aptrinsic.com/v1/users/sample-user-id", - "userId": "" - }, - "statusCode": 200 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 5", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [ - { - "from": "hobbyCustomField", - "to": "hobby" - } - ], - "globalContextMap": [] - } - }, - "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": "identify", - "traits": { - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User", - "signUpDate": 1624431528295, - "title": "engineer", - "countryName": "USA", - "countryCode": "US", - "city": "New York", - "hobbyCustomField": "Sample Hobby" - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "error": "userId or anonymousId is required for identify", - "statTags": { - "destType": "GAINSIGHT_PX", - "errorCategory": "dataValidation", - "errorType": "instrumentation", - "feature": "processor", - "implementation": "native", - "module": "destination" - }, - "statusCode": 400 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 6", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "globalContextMap": [ - { - "from": "projectId", - "to": "p-123" - }, - { - "from": "tag", - "to": "sample-category-tag" - } - ] - } - }, - "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", - "event": "Product Added", - "properties": { - "product_id": "123", - "sku": "F16", - "category": "Games", - "name": "Game", - "brand": "Gamepro", - "variant": "111", - "price": 13.49, - "quantity": 11, - "coupon": "DISC21", - "position": 1, - "url": "https://www.website.com/product/path", - "image_url": "https://www.website.com/product/path.png" - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "error": "Missing required value from \"userId\"", - "statTags": { - "destType": "GAINSIGHT_PX", - "errorCategory": "dataValidation", - "errorType": "instrumentation", - "feature": "processor", - "implementation": "native", - "module": "destination" - }, - "statusCode": 400 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 7", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [], - "globalContextMap": [] - } - }, - "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 - }, - "traits": { - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User" - } - }, - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "sample-anon-id", - "userId": "sample-user-id", - "type": "group", - "traits": { - "name": "ECorp", - "industry": "software", - "numberOfEmployees": 400, - "website": "www.ecorp.com", - "plan": "premium" - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "error": "groupId is required for group", - "statTags": { - "destType": "GAINSIGHT_PX", - "errorCategory": "dataValidation", - "errorType": "instrumentation", - "feature": "processor", - "implementation": "native", - "module": "destination" - }, - "statusCode": 400 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 8", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "globalContextMap": [ - { - "from": "projectId", - "to": "p-123" - }, - { - "from": "tag", - "to": "sample-category-tag" - } - ] - } - }, - "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 - } - }, - "userId": "sample-user-id", - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "sample-anon-id", - "type": "track", - "event": "Stringify Test", - "properties": { - "description": "Stringify test for object values", - "nested": { - "a": [ - 1, - 2, - 3 - ], - "b": { - "c": 1 - } - }, - "arr": [ - 1, - 2, - 3 - ] - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "output": { - "body": { - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {}, - "JSON": { - "attributes": { - "description": "Stringify test for object values", - "nested": "{\"a\":[1,2,3],\"b\":{\"c\":1}}", - "arr": "[1,2,3]" - }, - "propertyKey": "AP-XABC-123", - "userType": "USER", - "identifyId": "sample-user-id", - "date": 1571043797562, - "eventName": "Stringify Test", - "globalContext": { - "projectId": "p-123", - "tag": "sample-category-tag" - } - } - }, - "type": "REST", - "files": {}, - "method": "POST", - "params": {}, - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "version": "1", - "endpoint": "https://api.aptrinsic.com/v1/events/custom", - "userId": "" - }, - "statusCode": 200 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 9", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "globalContextMap": [ - { - "from": "projectId", - "to": "p-123" - }, - { - "from": "tag", - "to": "sample-category-tag" - } - ] - } - }, - "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 - } - }, - "userId": "sample-user-id", - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "sample-anon-id", - "type": "track", - "event": "Stringify Test", - "properties": { - "description": "Stringify test for object values", - "nested": { - "a": [ - 1, - 2, - 3 - ], - "b": { - "c": 1 - } - }, - "arr": [ - 1, - 2, - 3 - ], - "globalContext": { - "someKey": "someVal" - } - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "output": { - "body": { - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {}, - "JSON": { - "attributes": { - "description": "Stringify test for object values", - "nested": "{\"a\":[1,2,3],\"b\":{\"c\":1}}", - "arr": "[1,2,3]" - }, - "propertyKey": "AP-XABC-123", - "userType": "USER", - "identifyId": "sample-user-id", - "date": 1571043797562, - "eventName": "Stringify Test", - "globalContext": { - "someKey": "someVal" - } - } - }, - "type": "REST", - "files": {}, - "method": "POST", - "params": {}, - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "version": "1", - "endpoint": "https://api.aptrinsic.com/v1/events/custom", - "userId": "" - }, - "statusCode": 200 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 10", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [], - "globalContextMap": [] - } - }, - "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 - }, - "traits": { - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User" - } - }, - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "sample-anon-id", - "userId": "absent-id", - "groupId": "ecorp-id", - "type": "group", - "traits": { - "name": "ECorp", - "industry": "software", - "numberOfEmployees": 400, - "website": "www.ecorp.com", - "plan": "premium" - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "error": "aborting group call: {\"status\":\"NOT_FOUND\",\"message\":\"User was not found for parameters {id=absent-id}\",\"debugMessage\":null,\"subErrors\":null}", - "statTags": { - "destType": "GAINSIGHT_PX", - "errorCategory": "dataValidation", - "errorType": "instrumentation", - "feature": "processor", - "implementation": "native", - "module": "destination" - }, - "statusCode": 400 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 11", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [ - { - "from": "hobbyCustomField", - "to": "hobby" - } - ], - "globalContextMap": [] - } - }, - "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", - "userId": "absent-id", - "anonymousId": "sample-anon-id", - "type": "identify", - "traits": { - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User", - "signUpDate": 1624431528295, - "title": "engineer", - "countryName": "USA", - "countryCode": "US", - "city": "New York", - "hobbyCustomField": "Sample Hobby" - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "output": { - "body": { - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {}, - "JSON": { - "identifyId": "absent-id", - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User", - "signUpDate": 1624431528295, - "createDate": 1571043797562, - "title": "engineer", - "propertyKeys": [ - "AP-XABC-123" - ], - "location": { - "countryName": "USA", - "countryCode": "US", - "city": "New York" - }, - "customAttributes": { - "hobby": "Sample Hobby" - } - } - }, - "type": "REST", - "files": {}, - "method": "POST", - "params": {}, - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "version": "1", - "endpoint": "https://api.aptrinsic.com/v1/users", - "userId": "" - }, - "statusCode": 200 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 12", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "globalContextMap": [] - } - }, - "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", - "userId": "absent-id", - "anonymousId": "sample-anon-id", - "type": "identify", - "traits": { - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User", - "signUpDate": 1624431528295, - "title": "engineer", - "countryName": "USA", - "countryCode": "US", - "city": "New York", - "hobbyCustomField": "Sample Hobby", - "accountId": 1234 - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "output": { - "body": { - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {}, - "JSON": { - "identifyId": "absent-id", - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User", - "signUpDate": 1624431528295, - "createDate": 1571043797562, - "title": "engineer", - "propertyKeys": [ - "AP-XABC-123" - ], - "accountId": "1234", - "location": { - "countryName": "USA", - "countryCode": "US", - "city": "New York" - }, - "customAttributes": {} - } - }, - "type": "REST", - "files": {}, - "method": "POST", - "params": {}, - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "version": "1", - "endpoint": "https://api.aptrinsic.com/v1/users", - "userId": "" - }, - "statusCode": 200 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 13", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [], - "globalContextMap": [] - } - }, - "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 - }, - "traits": { - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User" - } - }, - "messageId": "84e26acc-56a5-4835-8233-591137fca468", - "session_id": "3049dc4c-5a95-4ccd-a3e7-d74a7e411f22", - "originalTimestamp": "2019-10-14T09:03:17.562Z", - "anonymousId": "sample-anon-id", - "userId": "absent-id", - "groupId": "ecorp-id", - "type": "group", - "traits": { - "name": "ECorp", - "industry": "software", - "numberOfEmployees": 400, - "website": "www.ecorp.com", - "plan": "premium", - "term": null - }, - "integrations": { - "All": true, - "GAINSIGHT_PX": { - "limitAPIForGroup": true - } - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "output": { - "version": "1", - "type": "REST", - "method": "PUT", - "endpoint": "https://api.aptrinsic.com/v1/users/absent-id", - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "params": {}, - "body": { - "JSON": { - "accountId": "ecorp-id" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {}, - "userId": "" - }, - "statusCode": 200 - } - ] - } - } - }, - { - "name": "gainsight_px", - "description": "Test 14", - "feature": "processor", - "module": "destination", - "version": "v0", - "input": { - "request": { - "body": [ - { - "destination": { - "Config": { - "apiKey": "sample-api-key", - "productTagKey": "AP-XABC-123", - "accountAttributeMap": [ - { - "from": "", - "to": "" - } - ], - "userAttributeMap": [ - { - "from": "hobbyCustomField", - "to": "hobby" - } - ], - "globalContextMap": [] - } - }, - "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", - "userId": "sample-user-id", - "anonymousId": "sample-anon-id", - "type": "identify", - "traits": { - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User", - "signUpDate": 1624431528295, - "title": "engineer", - "countryName": "USA", - "countryCode": "US", - "city": "New York", - "hobbyCustomField": "Sample Hobby", - "term": null, - "campaign": "" - }, - "integrations": { - "All": true - }, - "sentAt": "2019-10-14T09:03:22.563Z" - } - } - ] - } - }, - "output": { - "response": { - "status": 200, - "body": [ - { - "output": { - "body": { - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {}, - "JSON": { - "type": "USER", - "gender": "MALE", - "email": "user@email.com", - "firstName": "Sample", - "lastName": "User", - "signUpDate": 1624431528295, - "createDate": 1571043797562, - "title": "engineer", - "propertyKeys": [ - "AP-XABC-123" - ], - "location": { - "countryName": "USA", - "countryCode": "US", - "city": "New York" - }, - "customAttributes": { - "hobby": "Sample Hobby" - } - } - }, - "type": "REST", - "files": {}, - "method": "PUT", - "params": {}, - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "version": "1", - "endpoint": "https://api.aptrinsic.com/v1/users/sample-user-id", - "userId": "" - }, - "statusCode": 200 - } - ] - } - } - } -] \ No newline at end of file + { + name: 'gainsight_px', + description: 'Test 0', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: '', + to: '', + }, + ], + globalContextMap: [ + { + from: 'projectId', + to: 'p-123', + }, + { + from: 'tag', + to: 'sample-category-tag', + }, + ], + }, + }, + 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, + }, + }, + userId: 'sample-user-id', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: 'sample-anon-id', + type: 'track', + event: 'Product Added', + properties: { + product_id: '123', + sku: 'F16', + category: 'Games', + name: 'Game', + brand: 'Gamepro', + variant: '111', + price: 13.49, + quantity: 11, + coupon: 'DISC21', + position: 1, + url: 'https://www.website.com/product/path', + image_url: 'https://www.website.com/product/path.png', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + JSON: { + attributes: { + product_id: '123', + sku: 'F16', + category: 'Games', + name: 'Game', + brand: 'Gamepro', + variant: '111', + price: 13.49, + quantity: 11, + coupon: 'DISC21', + position: 1, + url: 'https://www.website.com/product/path', + image_url: 'https://www.website.com/product/path.png', + }, + propertyKey: 'AP-XABC-123', + userType: 'USER', + identifyId: 'sample-user-id', + date: 1571043797562, + eventName: 'Product Added', + globalContext: { + projectId: 'p-123', + tag: 'sample-category-tag', + }, + }, + }, + type: 'REST', + files: {}, + method: 'POST', + params: {}, + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + version: '1', + endpoint: 'https://api.aptrinsic.com/v1/events/custom', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 1', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: '', + to: '', + }, + ], + globalContextMap: [ + { + from: 'projectId', + to: 'p-123', + }, + { + from: 'tag', + to: 'sample-category-tag', + }, + ], + }, + }, + message: { + channel: 'web', + context: { + os: { + name: '', + version: '', + }, + app: { + name: 'RudderLabs JavaScript SDK', + version: '1.27.0', + namespace: 'com.rudderlabs.javascript', + }, + page: { + url: 'http://127.0.0.1:8887/', + path: '/', + title: 'RudderStack in 5', + search: '', + tab_url: 'http://127.0.0.1:8887/', + referrer: '$direct', + initial_referrer: '$direct', + referring_domain: '', + initial_referring_domain: '', + }, + locale: 'en-US', + screen: { + width: 1512, + height: 982, + density: 2, + innerWidth: 774, + innerHeight: 774, + }, + library: { + name: 'RudderLabs JavaScript SDK', + version: '1.27.0', + }, + campaign: {}, + sessionId: 1679967592314, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36', + properties: { + email: '84@84.com', + price: '56.0', + quantity: '5', + }, + }, + userId: 'sample-user-id', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: 'sample-anon-id', + type: 'track', + event: 'Marketing - Plan Change Events', + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + JSON: { + attributes: {}, + url: 'http://127.0.0.1:8887/', + propertyKey: 'AP-XABC-123', + userType: 'USER', + identifyId: 'sample-user-id', + referrer: '$direct', + date: 1571043797562, + sessionId: 1679967592314, + eventName: 'Marketing - Plan Change Events', + globalContext: { + projectId: 'p-123', + tag: 'sample-category-tag', + }, + }, + }, + type: 'REST', + files: {}, + method: 'POST', + params: {}, + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + version: '1', + endpoint: 'https://api.aptrinsic.com/v1/events/custom', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 2', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: '', + to: '', + }, + ], + globalContextMap: [ + { + from: 'projectId', + to: 'p-123', + }, + { + from: 'tag', + to: 'sample-category-tag', + }, + ], + }, + }, + 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, + }, + }, + userId: 'sample-user-id', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: 'sample-anon-id', + type: 'track', + event: 'Track Me', + properties: { + description: 'Sample Track call', + globalContext: { + testOverride: 'some-value', + }, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + JSON: { + attributes: { + description: 'Sample Track call', + }, + propertyKey: 'AP-XABC-123', + userType: 'USER', + identifyId: 'sample-user-id', + date: 1571043797562, + eventName: 'Track Me', + globalContext: { + testOverride: 'some-value', + }, + }, + }, + type: 'REST', + files: {}, + method: 'POST', + params: {}, + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + version: '1', + endpoint: 'https://api.aptrinsic.com/v1/events/custom', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 3', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: 'hobbyCustomField', + to: 'hobby', + }, + ], + globalContextMap: [], + }, + }, + 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', + userId: 'sample-user-id', + anonymousId: 'sample-anon-id', + type: 'identify', + traits: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + signUpDate: 1624431528295, + title: 'engineer', + countryName: 'USA', + countryCode: 'US', + city: 'New York', + hobbyCustomField: 'Sample Hobby', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + JSON: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + signUpDate: 1624431528295, + title: 'engineer', + propertyKeys: ['AP-XABC-123'], + location: { + countryName: 'USA', + countryCode: 'US', + city: 'New York', + }, + customAttributes: { + hobby: 'Sample Hobby', + }, + }, + }, + type: 'REST', + files: {}, + method: 'PUT', + params: {}, + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + version: '1', + endpoint: 'https://api.aptrinsic.com/v1/users/sample-user-id', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 4', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [], + globalContextMap: [], + }, + }, + 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, + }, + traits: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + medium: null, + }, + }, + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: 'sample-anon-id', + userId: 'sample-user-id', + groupId: 'ecorp-id', + type: 'group', + traits: { + name: 'ECorp', + industry: 'software', + numberOfEmployees: 400, + website: 'www.ecorp.com', + plan: 'premium', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + JSON: { + accountId: 'ecorp-id', + }, + }, + type: 'REST', + files: {}, + method: 'PUT', + params: {}, + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + version: '1', + endpoint: 'https://api.aptrinsic.com/v1/users/sample-user-id', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 5', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: 'hobbyCustomField', + to: 'hobby', + }, + ], + globalContextMap: [], + }, + }, + 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: 'identify', + traits: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + signUpDate: 1624431528295, + title: 'engineer', + countryName: 'USA', + countryCode: 'US', + city: 'New York', + hobbyCustomField: 'Sample Hobby', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'userId or anonymousId is required for identify', + statTags: { + destType: 'GAINSIGHT_PX', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 6', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: '', + to: '', + }, + ], + globalContextMap: [ + { + from: 'projectId', + to: 'p-123', + }, + { + from: 'tag', + to: 'sample-category-tag', + }, + ], + }, + }, + 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', + event: 'Product Added', + properties: { + product_id: '123', + sku: 'F16', + category: 'Games', + name: 'Game', + brand: 'Gamepro', + variant: '111', + price: 13.49, + quantity: 11, + coupon: 'DISC21', + position: 1, + url: 'https://www.website.com/product/path', + image_url: 'https://www.website.com/product/path.png', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'Missing required value from "userId"', + statTags: { + destType: 'GAINSIGHT_PX', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 7', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [], + globalContextMap: [], + }, + }, + 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, + }, + traits: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + }, + }, + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: 'sample-anon-id', + userId: 'sample-user-id', + type: 'group', + traits: { + name: 'ECorp', + industry: 'software', + numberOfEmployees: 400, + website: 'www.ecorp.com', + plan: 'premium', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: 'groupId is required for group', + statTags: { + destType: 'GAINSIGHT_PX', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 8', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: '', + to: '', + }, + ], + globalContextMap: [ + { + from: 'projectId', + to: 'p-123', + }, + { + from: 'tag', + to: 'sample-category-tag', + }, + ], + }, + }, + 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, + }, + }, + userId: 'sample-user-id', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: 'sample-anon-id', + type: 'track', + event: 'Stringify Test', + properties: { + description: 'Stringify test for object values', + nested: { + a: [1, 2, 3], + b: { + c: 1, + }, + }, + arr: [1, 2, 3], + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + JSON: { + attributes: { + description: 'Stringify test for object values', + nested: '{"a":[1,2,3],"b":{"c":1}}', + arr: '[1,2,3]', + }, + propertyKey: 'AP-XABC-123', + userType: 'USER', + identifyId: 'sample-user-id', + date: 1571043797562, + eventName: 'Stringify Test', + globalContext: { + projectId: 'p-123', + tag: 'sample-category-tag', + }, + }, + }, + type: 'REST', + files: {}, + method: 'POST', + params: {}, + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + version: '1', + endpoint: 'https://api.aptrinsic.com/v1/events/custom', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 9', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: '', + to: '', + }, + ], + globalContextMap: [ + { + from: 'projectId', + to: 'p-123', + }, + { + from: 'tag', + to: 'sample-category-tag', + }, + ], + }, + }, + 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, + }, + }, + userId: 'sample-user-id', + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: 'sample-anon-id', + type: 'track', + event: 'Stringify Test', + properties: { + description: 'Stringify test for object values', + nested: { + a: [1, 2, 3], + b: { + c: 1, + }, + }, + arr: [1, 2, 3], + globalContext: { + someKey: 'someVal', + }, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + JSON: { + attributes: { + description: 'Stringify test for object values', + nested: '{"a":[1,2,3],"b":{"c":1}}', + arr: '[1,2,3]', + }, + propertyKey: 'AP-XABC-123', + userType: 'USER', + identifyId: 'sample-user-id', + date: 1571043797562, + eventName: 'Stringify Test', + globalContext: { + someKey: 'someVal', + }, + }, + }, + type: 'REST', + files: {}, + method: 'POST', + params: {}, + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + version: '1', + endpoint: 'https://api.aptrinsic.com/v1/events/custom', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 10', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [], + globalContextMap: [], + }, + }, + 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, + }, + traits: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + }, + }, + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: 'sample-anon-id', + userId: 'absent-id', + groupId: 'ecorp-id', + type: 'group', + traits: { + name: 'ECorp', + industry: 'software', + numberOfEmployees: 400, + website: 'www.ecorp.com', + plan: 'premium', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'aborting group call: {"status":"NOT_FOUND","message":"User was not found for parameters {id=absent-id}","debugMessage":null,"subErrors":null}', + statTags: { + destType: 'GAINSIGHT_PX', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'native', + module: 'destination', + }, + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 11', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: 'hobbyCustomField', + to: 'hobby', + }, + ], + globalContextMap: [], + }, + }, + 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', + userId: 'absent-id', + anonymousId: 'sample-anon-id', + type: 'identify', + traits: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + signUpDate: 1624431528295, + title: 'engineer', + countryName: 'USA', + countryCode: 'US', + city: 'New York', + hobbyCustomField: 'Sample Hobby', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + JSON: { + identifyId: 'absent-id', + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + signUpDate: 1624431528295, + createDate: 1571043797562, + title: 'engineer', + propertyKeys: ['AP-XABC-123'], + location: { + countryName: 'USA', + countryCode: 'US', + city: 'New York', + }, + customAttributes: { + hobby: 'Sample Hobby', + }, + }, + }, + type: 'REST', + files: {}, + method: 'POST', + params: {}, + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + version: '1', + endpoint: 'https://api.aptrinsic.com/v1/users', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 12', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: '', + to: '', + }, + ], + globalContextMap: [], + }, + }, + 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', + userId: 'absent-id', + anonymousId: 'sample-anon-id', + type: 'identify', + traits: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + signUpDate: 1624431528295, + title: 'engineer', + countryName: 'USA', + countryCode: 'US', + city: 'New York', + hobbyCustomField: 'Sample Hobby', + accountId: 1234, + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + JSON: { + identifyId: 'absent-id', + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + signUpDate: 1624431528295, + createDate: 1571043797562, + title: 'engineer', + propertyKeys: ['AP-XABC-123'], + accountId: '1234', + location: { + countryName: 'USA', + countryCode: 'US', + city: 'New York', + }, + customAttributes: {}, + }, + }, + type: 'REST', + files: {}, + method: 'POST', + params: {}, + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + version: '1', + endpoint: 'https://api.aptrinsic.com/v1/users', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 13', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [], + globalContextMap: [], + }, + }, + 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, + }, + traits: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + }, + }, + messageId: '84e26acc-56a5-4835-8233-591137fca468', + session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22', + originalTimestamp: '2019-10-14T09:03:17.562Z', + anonymousId: 'sample-anon-id', + userId: 'absent-id', + groupId: 'ecorp-id', + type: 'group', + traits: { + name: 'ECorp', + industry: 'software', + numberOfEmployees: 400, + website: 'www.ecorp.com', + plan: 'premium', + term: null, + }, + integrations: { + All: true, + GAINSIGHT_PX: { + limitAPIForGroup: true, + }, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'PUT', + endpoint: 'https://api.aptrinsic.com/v1/users/absent-id', + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + params: {}, + body: { + JSON: { + accountId: 'ecorp-id', + }, + JSON_ARRAY: {}, + XML: {}, + FORM: {}, + }, + files: {}, + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 14 : existing user with no createdAt field in traits but signUpDate exists', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: 'hobbyCustomField', + to: 'hobby', + }, + ], + globalContextMap: [], + }, + }, + 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', + userId: 'sample-user-id', + anonymousId: 'sample-anon-id', + type: 'identify', + traits: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + signUpDate: 1624431528295, + title: 'engineer', + countryName: 'USA', + countryCode: 'US', + city: 'New York', + hobbyCustomField: 'Sample Hobby', + term: null, + campaign: '', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + JSON: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + signUpDate: 1624431528295, + title: 'engineer', + propertyKeys: ['AP-XABC-123'], + location: { + countryName: 'USA', + countryCode: 'US', + city: 'New York', + }, + customAttributes: { + hobby: 'Sample Hobby', + }, + }, + }, + type: 'REST', + files: {}, + method: 'PUT', + params: {}, + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + version: '1', + endpoint: 'https://api.aptrinsic.com/v1/users/sample-user-id', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 15 : new user with no signUpDate and createDate in traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + Config: { + apiKey: 'sample-api-key', + productTagKey: 'AP-XABC-123', + accountAttributeMap: [ + { + from: '', + to: '', + }, + ], + userAttributeMap: [ + { + from: 'hobbyCustomField', + to: 'hobby', + }, + ], + globalContextMap: [], + }, + }, + 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', + userId: 'absent-id', + anonymousId: 'sample-anon-id', + type: 'identify', + traits: { + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + title: 'engineer', + countryName: 'USA', + countryCode: 'US', + city: 'New York', + hobbyCustomField: 'Sample Hobby', + }, + integrations: { + All: true, + }, + sentAt: '2019-10-14T09:03:22.563Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + JSON: { + identifyId: 'absent-id', + type: 'USER', + gender: 'MALE', + email: 'user@email.com', + firstName: 'Sample', + lastName: 'User', + signUpDate: 1571043797562, + createDate: 1571043797562, + title: 'engineer', + propertyKeys: ['AP-XABC-123'], + location: { + countryName: 'USA', + countryCode: 'US', + city: 'New York', + }, + customAttributes: { + hobby: 'Sample Hobby', + }, + }, + }, + type: 'REST', + files: {}, + method: 'POST', + params: {}, + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + version: '1', + endpoint: 'https://api.aptrinsic.com/v1/users', + userId: '', + }, + statusCode: 200, + }, + ], + }, + }, + }, + { + name: 'gainsight_px', + description: 'Test 16 : existing user with no signUpDate and createDate in traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + ID: '1uLy1tqsoo9RhL1zLiqLQTKBIKL', + Name: 'gainsight-px-dest', + DestinationDefinition: { + ID: '1uLuOdwPCqtei55ZKXewwPhjQPf', + Name: 'GAINSIGHT_PX', + DisplayName: 'Gainsight PX', + Config: { + destConfig: { + defaultConfig: [ + 'apiKey', + 'productTagKey', + 'userAttributeMap', + 'accountAttributeMap', + 'globalContextMap', + ], + }, + excludeKeys: [], + includeKeys: [], + saveDestinationResponse: true, + secretKeys: ['apiKey', 'productTagKey'], + supportedSourceTypes: [ + 'android', + 'ios', + 'web', + 'unity', + 'amp', + 'cloud', + 'reactnative', + 'flutter', + ], + transformAt: 'router', + transformAtV1: 'router', + }, + ResponseRules: {}, + }, + Config: { + accountAttributeMap: [ + { + from: 'cultureCustomField', + to: 'culture', + }, + ], + apiKey: 'sample-api-key', + eventDelivery: false, + eventDeliveryTS: 1624472902670, + globalContextMap: [ + { + from: 'kubrickTest', + to: 'value', + }, + ], + productTagKey: 'AP-SAMPLE-2', + userAttributeMap: [ + { + from: 'hobbyCustomField', + to: 'hobby', + }, + ], + }, + Enabled: true, + Transformations: [], + IsProcessorEnabled: true, + }, + message: { + type: 'identify', + sentAt: '2021-06-25T08:59:52.891Z', + userId: 'stanley-kubrick', + channel: 'web', + context: { + os: { + name: '', + version: '', + }, + app: { + name: 'RudderLabs JavaScript SDK', + build: '1.0.0', + version: '1.1.18', + namespace: 'com.rudderlabs.javascript', + }, + page: { + title: 'Test', + search: '', + path: 'index.html', + url: 'http://127.0.0.1:3003/index.html', + tab_url: 'http://127.0.0.1:3003/index.html', + referrer: '$direct', + initial_referrer: '$direct', + referring_domain: '', + initial_referring_domain: '', + }, + locale: 'en-GB', + screen: { + width: 1920, + height: 1080, + density: 1, + innerWidth: 1920, + innerHeight: 436, + }, + traits: { + name: 'Stanley Kubrick', + email: 'stanley@kubrick.com', + score: 100, + title: 'Director/Film Maker', + gender: 'Male', + countryCode: 'US', + countryName: 'USA', + hobbyCustomField: 'Making films. Being a genius', + }, + library: { + name: 'RudderLabs JavaScript SDK', + version: '1.1.18', + }, + campaign: {}, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36', + }, + rudderId: '9a7820d0-0ff2-4451-b655-682cec15cbd2', + messageId: 'ff90d62e-a6e3-4e23-af20-03b4a249ef48', + timestamp: '2021-06-25T14:29:52.911+05:30', + receivedAt: '2021-06-25T14:29:52.911+05:30', + request_ip: '[::1]', + anonymousId: '1585ea2f-dddc-4d23-935f-c1196405d61e', + integrations: { + All: true, + }, + originalTimestamp: '2021-06-25T08:59:52.891Z', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + version: '1', + type: 'REST', + method: 'PUT', + endpoint: 'https://api.aptrinsic.com/v1/users/stanley-kubrick', + userId: '', + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + params: {}, + body: { + JSON: { + email: 'stanley@kubrick.com', + gender: 'MALE', + title: 'Director/Film Maker', + score: 100, + location: { + countryName: 'USA', + countryCode: 'US', + }, + firstName: 'Stanley', + lastName: 'Kubrick', + customAttributes: { + hobby: 'Making films. Being a genius', + }, + propertyKeys: ['AP-SAMPLE-2'], + type: 'USER', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + }, + statusCode: 200, + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/gainsight_px/router/data.ts b/test/integrations/destinations/gainsight_px/router/data.ts index 4017a3ddb7..3b735c5b69 100644 --- a/test/integrations/destinations/gainsight_px/router/data.ts +++ b/test/integrations/destinations/gainsight_px/router/data.ts @@ -1,558 +1,557 @@ export const data = [ - { - name: 'gainsight_px', - description: 'Test 0', - feature: 'router', - module: 'destination', - version: 'v0', - input: { - request: { - body: { - input: [ - { - "message": { - "type": "identify", - "sentAt": "2021-06-25T08:59:52.891Z", - "userId": "stanley-kubrick", - "channel": "web", - "context": { - "os": { - "name": "", - "version": "" - }, - "app": { - "name": "RudderLabs JavaScript SDK", - "build": "1.0.0", - "version": "1.1.18", - "namespace": "com.rudderlabs.javascript" - }, - "page": { - "title": "Test", - "search": "", - "path": "index.html", - "url": "http://127.0.0.1:3003/index.html", - "tab_url": "http://127.0.0.1:3003/index.html", - "referrer": "$direct", - "initial_referrer": "$direct", - "referring_domain": "", - "initial_referring_domain": "" - }, - "locale": "en-GB", - "screen": { - "width": 1920, - "height": 1080, - "density": 1, - "innerWidth": 1920, - "innerHeight": 436 - }, - "traits": { - "name": "Stanley Kubrick", - "email": "stanley@kubrick.com", - "score": 100, - "title": "Director/Film Maker", - "gender": "Male", - "countryCode": "US", - "countryName": "USA", - "hobbyCustomField": "Making films. Being a genius" - }, - "library": { - "name": "RudderLabs JavaScript SDK", - "version": "1.1.18" - }, - "campaign": {}, - "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36" - }, - "rudderId": "9a7820d0-0ff2-4451-b655-682cec15cbd2", - "messageId": "ff90d62e-a6e3-4e23-af20-03b4a249ef48", - "timestamp": "2021-06-25T14:29:52.911+05:30", - "receivedAt": "2021-06-25T14:29:52.911+05:30", - "request_ip": "[::1]", - "anonymousId": "1585ea2f-dddc-4d23-935f-c1196405d61e", - "integrations": { - "All": true - }, - "originalTimestamp": "2021-06-25T08:59:52.891Z" - }, - "metadata": { - "userId": "9a7820d0-0ff2-4451-b655-682cec15cbd2", - "jobId": 1, - "sourceId": "1s9eG8UCer6YSKsD8ZlQCyLa3pj", - "destinationId": "1uLy1tqsoo9RhL1zLiqLQTKBIKL", - "attemptNum": 0, - "receivedAt": "2021-06-25T14:29:52.911+05:30", - "createdAt": "2021-06-25T08:59:56.329Z", - "firstAttemptedAt": "", - "transformAt": "router" - }, - "destination": { - "ID": "1uLy1tqsoo9RhL1zLiqLQTKBIKL", - "Name": "gainsight-px-dest", - "DestinationDefinition": { - "ID": "1uLuOdwPCqtei55ZKXewwPhjQPf", - "Name": "GAINSIGHT_PX", - "DisplayName": "Gainsight PX", - "Config": { - "destConfig": { - "defaultConfig": [ - "apiKey", - "productTagKey", - "userAttributeMap", - "accountAttributeMap", - "globalContextMap" - ] - }, - "excludeKeys": [], - "includeKeys": [], - "saveDestinationResponse": true, - "secretKeys": ["apiKey", "productTagKey"], - "supportedSourceTypes": [ - "android", - "ios", - "web", - "unity", - "amp", - "cloud", - "reactnative", - "flutter" - ], - "transformAt": "router", - "transformAtV1": "router" - }, - "ResponseRules": {} - }, - "Config": { - "accountAttributeMap": [ - { - "from": "cultureCustomField", - "to": "culture" - } - ], - "apiKey": "sample-api-key", - "eventDelivery": false, - "eventDeliveryTS": 1624472902670, - "globalContextMap": [ - { - "from": "kubrickTest", - "to": "value" - } - ], - "productTagKey": "AP-SAMPLE-2", - "userAttributeMap": [ - { - "from": "hobbyCustomField", - "to": "hobby" - } - ] - }, - "Enabled": true, - "Transformations": [], - "IsProcessorEnabled": true - } - }, - { - "message": { - "type": "track", - "event": "nested test2", - "sentAt": "2021-06-26T10:41:22.316Z", - "userId": "adifhas9734", - "channel": "web", - "context": { - "os": { - "name": "", - "version": "" - }, - "app": { - "name": "RudderLabs JavaScript SDK", - "build": "1.0.0", - "version": "1.1.18", - "namespace": "com.rudderlabs.javascript" - }, - "page": { - "url": "file:///Users/anurajguha/workspace/simple-html-test/index.html", - "path": "/Users/anurajguha/workspace/simple-html-test/index.html", - "title": "Test", - "search": "", - "tab_url": "file:///Users/anurajguha/workspace/simple-html-test/index.html", - "referrer": "$direct", - "initial_referrer": "$direct", - "referring_domain": "", - "initial_referring_domain": "" - }, - "locale": "en-GB", - "screen": { - "width": 1920, - "height": 1080, - "density": 1, - "innerWidth": 1920, - "innerHeight": 585 - }, - "traits": { - "name": "Update test unique", - "phone": "9900990899", - "lastname": "user6", - "firstname": "test", - "previousCompany": "testprevCompany2" - }, - "library": { - "name": "RudderLabs JavaScript SDK", - "version": "1.1.18" - }, - "campaign": {}, - "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36" - }, - "rudderId": "a27a8a8a-9e81-4898-beeb-e6041fc1552d", - "messageId": "595dae36-5e4f-4feb-a2e4-8a7849615d38", - "timestamp": "2021-06-26T16:11:22.335+05:30", - "properties": { - "array": [1, 2, 3], - "nested": { - "json": "test" - }, - "status": "testing", - "description": "Example track call", - "fullyNested": [ - { - "a": 1, - "b": 2 - }, - { - "a": 1, - "b": [1, 2, 3] - } - ] - }, - "receivedAt": "2021-06-26T16:11:22.335+05:30", - "request_ip": "[::1]", - "anonymousId": "1585ea2f-dddc-4d23-935f-c1196405d61e", - "integrations": { - "All": true - }, - "originalTimestamp": "2021-06-26T10:41:22.316Z" - }, - "metadata": { - "userId": "a27a8a8a-9e81-4898-beeb-e6041fc1552d", - "jobId": 2, - "sourceId": "1s9eG8UCer6YSKsD8ZlQCyLa3pj", - "destinationId": "1uLy1tqsoo9RhL1zLiqLQTKBIKL", - "attemptNum": 0, - "receivedAt": "2021-06-26T16:11:22.335+05:30", - "createdAt": "2021-06-26T10:41:24.126Z", - "firstAttemptedAt": "", - "transformAt": "router" - }, - "destination": { - "ID": "1uLy1tqsoo9RhL1zLiqLQTKBIKL", - "Name": "gainsight-px-dest", - "DestinationDefinition": { - "ID": "1uLuOdwPCqtei55ZKXewwPhjQPf", - "Name": "GAINSIGHT_PX", - "DisplayName": "Gainsight PX", - "Config": { - "destConfig": { - "defaultConfig": [ - "apiKey", - "productTagKey", - "userAttributeMap", - "accountAttributeMap", - "globalContextMap" - ] - }, - "excludeKeys": [], - "includeKeys": [], - "saveDestinationResponse": true, - "secretKeys": ["apiKey", "productTagKey"], - "supportedSourceTypes": [ - "android", - "ios", - "web", - "unity", - "amp", - "cloud", - "reactnative", - "flutter" - ], - "transformAt": "router", - "transformAtV1": "router" - }, - "ResponseRules": {} - }, - "Config": { - "accountAttributeMap": [ - { - "from": "cultureCustomField", - "to": "culture" - } - ], - "apiKey": "sample-api-key", - "eventDelivery": false, - "eventDeliveryTS": 1624472902670, - "globalContextMap": [ - { - "from": "kubrickTest", - "to": "value" - } - ], - "productTagKey": "AP-SAMPLE-2", - "userAttributeMap": [ - { - "from": "hobbyCustomField", - "to": "hobby" - } - ] - }, - "Enabled": true, - "Transformations": [], - "IsProcessorEnabled": true - } - } - ] - , - destType: 'gainsight_px', + { + name: 'gainsight_px', + description: 'Test 0', + feature: 'router', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + input: [ + { + message: { + type: 'identify', + sentAt: '2021-06-25T08:59:52.891Z', + userId: 'stanley-kubrick', + channel: 'web', + context: { + os: { + name: '', + version: '', + }, + app: { + name: 'RudderLabs JavaScript SDK', + build: '1.0.0', + version: '1.1.18', + namespace: 'com.rudderlabs.javascript', + }, + page: { + title: 'Test', + search: '', + path: 'index.html', + url: 'http://127.0.0.1:3003/index.html', + tab_url: 'http://127.0.0.1:3003/index.html', + referrer: '$direct', + initial_referrer: '$direct', + referring_domain: '', + initial_referring_domain: '', + }, + locale: 'en-GB', + screen: { + width: 1920, + height: 1080, + density: 1, + innerWidth: 1920, + innerHeight: 436, + }, + traits: { + name: 'Stanley Kubrick', + email: 'stanley@kubrick.com', + score: 100, + title: 'Director/Film Maker', + gender: 'Male', + countryCode: 'US', + countryName: 'USA', + hobbyCustomField: 'Making films. Being a genius', + }, + library: { + name: 'RudderLabs JavaScript SDK', + version: '1.1.18', + }, + campaign: {}, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36', + }, + rudderId: '9a7820d0-0ff2-4451-b655-682cec15cbd2', + messageId: 'ff90d62e-a6e3-4e23-af20-03b4a249ef48', + timestamp: '2021-06-25T14:29:52.911+05:30', + receivedAt: '2021-06-25T14:29:52.911+05:30', + request_ip: '[::1]', + anonymousId: '1585ea2f-dddc-4d23-935f-c1196405d61e', + integrations: { + All: true, + }, + originalTimestamp: '2021-06-25T08:59:52.891Z', + }, + metadata: { + userId: '9a7820d0-0ff2-4451-b655-682cec15cbd2', + jobId: 1, + sourceId: '1s9eG8UCer6YSKsD8ZlQCyLa3pj', + destinationId: '1uLy1tqsoo9RhL1zLiqLQTKBIKL', + attemptNum: 0, + receivedAt: '2021-06-25T14:29:52.911+05:30', + createdAt: '2021-06-25T08:59:56.329Z', + firstAttemptedAt: '', + transformAt: 'router', + }, + destination: { + ID: '1uLy1tqsoo9RhL1zLiqLQTKBIKL', + Name: 'gainsight-px-dest', + DestinationDefinition: { + ID: '1uLuOdwPCqtei55ZKXewwPhjQPf', + Name: 'GAINSIGHT_PX', + DisplayName: 'Gainsight PX', + Config: { + destConfig: { + defaultConfig: [ + 'apiKey', + 'productTagKey', + 'userAttributeMap', + 'accountAttributeMap', + 'globalContextMap', + ], + }, + excludeKeys: [], + includeKeys: [], + saveDestinationResponse: true, + secretKeys: ['apiKey', 'productTagKey'], + supportedSourceTypes: [ + 'android', + 'ios', + 'web', + 'unity', + 'amp', + 'cloud', + 'reactnative', + 'flutter', + ], + transformAt: 'router', + transformAtV1: 'router', + }, + ResponseRules: {}, }, + Config: { + accountAttributeMap: [ + { + from: 'cultureCustomField', + to: 'culture', + }, + ], + apiKey: 'sample-api-key', + eventDelivery: false, + eventDeliveryTS: 1624472902670, + globalContextMap: [ + { + from: 'kubrickTest', + to: 'value', + }, + ], + productTagKey: 'AP-SAMPLE-2', + userAttributeMap: [ + { + from: 'hobbyCustomField', + to: 'hobby', + }, + ], + }, + Enabled: true, + Transformations: [], + IsProcessorEnabled: true, + }, }, + { + message: { + type: 'track', + event: 'nested test2', + sentAt: '2021-06-26T10:41:22.316Z', + userId: 'adifhas9734', + channel: 'web', + context: { + os: { + name: '', + version: '', + }, + app: { + name: 'RudderLabs JavaScript SDK', + build: '1.0.0', + version: '1.1.18', + namespace: 'com.rudderlabs.javascript', + }, + page: { + url: 'file:///Users/anurajguha/workspace/simple-html-test/index.html', + path: '/Users/anurajguha/workspace/simple-html-test/index.html', + title: 'Test', + search: '', + tab_url: 'file:///Users/anurajguha/workspace/simple-html-test/index.html', + referrer: '$direct', + initial_referrer: '$direct', + referring_domain: '', + initial_referring_domain: '', + }, + locale: 'en-GB', + screen: { + width: 1920, + height: 1080, + density: 1, + innerWidth: 1920, + innerHeight: 585, + }, + traits: { + name: 'Update test unique', + phone: '9900990899', + lastname: 'user6', + firstname: 'test', + previousCompany: 'testprevCompany2', + }, + library: { + name: 'RudderLabs JavaScript SDK', + version: '1.1.18', + }, + campaign: {}, + userAgent: + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36', + }, + rudderId: 'a27a8a8a-9e81-4898-beeb-e6041fc1552d', + messageId: '595dae36-5e4f-4feb-a2e4-8a7849615d38', + timestamp: '2021-06-26T16:11:22.335+05:30', + properties: { + array: [1, 2, 3], + nested: { + json: 'test', + }, + status: 'testing', + description: 'Example track call', + fullyNested: [ + { + a: 1, + b: 2, + }, + { + a: 1, + b: [1, 2, 3], + }, + ], + }, + receivedAt: '2021-06-26T16:11:22.335+05:30', + request_ip: '[::1]', + anonymousId: '1585ea2f-dddc-4d23-935f-c1196405d61e', + integrations: { + All: true, + }, + originalTimestamp: '2021-06-26T10:41:22.316Z', + }, + metadata: { + userId: 'a27a8a8a-9e81-4898-beeb-e6041fc1552d', + jobId: 2, + sourceId: '1s9eG8UCer6YSKsD8ZlQCyLa3pj', + destinationId: '1uLy1tqsoo9RhL1zLiqLQTKBIKL', + attemptNum: 0, + receivedAt: '2021-06-26T16:11:22.335+05:30', + createdAt: '2021-06-26T10:41:24.126Z', + firstAttemptedAt: '', + transformAt: 'router', + }, + destination: { + ID: '1uLy1tqsoo9RhL1zLiqLQTKBIKL', + Name: 'gainsight-px-dest', + DestinationDefinition: { + ID: '1uLuOdwPCqtei55ZKXewwPhjQPf', + Name: 'GAINSIGHT_PX', + DisplayName: 'Gainsight PX', + Config: { + destConfig: { + defaultConfig: [ + 'apiKey', + 'productTagKey', + 'userAttributeMap', + 'accountAttributeMap', + 'globalContextMap', + ], + }, + excludeKeys: [], + includeKeys: [], + saveDestinationResponse: true, + secretKeys: ['apiKey', 'productTagKey'], + supportedSourceTypes: [ + 'android', + 'ios', + 'web', + 'unity', + 'amp', + 'cloud', + 'reactnative', + 'flutter', + ], + transformAt: 'router', + transformAtV1: 'router', + }, + ResponseRules: {}, + }, + Config: { + accountAttributeMap: [ + { + from: 'cultureCustomField', + to: 'culture', + }, + ], + apiKey: 'sample-api-key', + eventDelivery: false, + eventDeliveryTS: 1624472902670, + globalContextMap: [ + { + from: 'kubrickTest', + to: 'value', + }, + ], + productTagKey: 'AP-SAMPLE-2', + userAttributeMap: [ + { + from: 'hobbyCustomField', + to: 'hobby', + }, + ], + }, + Enabled: true, + Transformations: [], + IsProcessorEnabled: true, + }, + }, + ], + destType: 'gainsight_px', }, - output: { - response: { - status: 200, + }, + }, + output: { + response: { + status: 200, + body: { + output: [ + { + batchedRequest: { + version: '1', + type: 'REST', + method: 'PUT', + endpoint: 'https://api.aptrinsic.com/v1/users/stanley-kubrick', + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + params: {}, + body: { + JSON: { + email: 'stanley@kubrick.com', + gender: 'MALE', + title: 'Director/Film Maker', + score: 100, + location: { + countryName: 'USA', + countryCode: 'US', + }, + firstName: 'Stanley', + lastName: 'Kubrick', + customAttributes: { + hobby: 'Making films. Being a genius', + }, + propertyKeys: ['AP-SAMPLE-2'], + type: 'USER', + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + }, + metadata: [ + { + userId: '9a7820d0-0ff2-4451-b655-682cec15cbd2', + jobId: 1, + sourceId: '1s9eG8UCer6YSKsD8ZlQCyLa3pj', + destinationId: '1uLy1tqsoo9RhL1zLiqLQTKBIKL', + attemptNum: 0, + receivedAt: '2021-06-25T14:29:52.911+05:30', + createdAt: '2021-06-25T08:59:56.329Z', + firstAttemptedAt: '', + transformAt: 'router', + }, + ], + batched: false, + statusCode: 200, + destination: { + ID: '1uLy1tqsoo9RhL1zLiqLQTKBIKL', + Name: 'gainsight-px-dest', + DestinationDefinition: { + ID: '1uLuOdwPCqtei55ZKXewwPhjQPf', + Name: 'GAINSIGHT_PX', + DisplayName: 'Gainsight PX', + Config: { + destConfig: { + defaultConfig: [ + 'apiKey', + 'productTagKey', + 'userAttributeMap', + 'accountAttributeMap', + 'globalContextMap', + ], + }, + excludeKeys: [], + includeKeys: [], + saveDestinationResponse: true, + secretKeys: ['apiKey', 'productTagKey'], + supportedSourceTypes: [ + 'android', + 'ios', + 'web', + 'unity', + 'amp', + 'cloud', + 'reactnative', + 'flutter', + ], + transformAt: 'router', + transformAtV1: 'router', + }, + ResponseRules: {}, + }, + Config: { + accountAttributeMap: [ + { + from: 'cultureCustomField', + to: 'culture', + }, + ], + apiKey: 'sample-api-key', + eventDelivery: false, + eventDeliveryTS: 1624472902670, + globalContextMap: [ + { + from: 'kubrickTest', + to: 'value', + }, + ], + productTagKey: 'AP-SAMPLE-2', + userAttributeMap: [ + { + from: 'hobbyCustomField', + to: 'hobby', + }, + ], + }, + Enabled: true, + Transformations: [], + IsProcessorEnabled: true, + }, + }, + { + batchedRequest: { + version: '1', + type: 'REST', + method: 'POST', + endpoint: 'https://api.aptrinsic.com/v1/events/custom', + headers: { + 'X-APTRINSIC-API-KEY': 'sample-api-key', + 'Content-Type': 'application/json', + }, + params: {}, body: { - output: [ - { - "batchedRequest": { - "version": "1", - "type": "REST", - "method": "PUT", - "endpoint": "https://api.aptrinsic.com/v1/users/stanley-kubrick", - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "params": {}, - "body": { - "JSON": { - "email": "stanley@kubrick.com", - "gender": "MALE", - "signUpDate": 1624611592911, - "title": "Director/Film Maker", - "score": 100, - "createDate": 1624611592911, - "location": { - "countryName": "USA", - "countryCode": "US" - }, - "firstName": "Stanley", - "lastName": "Kubrick", - "customAttributes": { - "hobby": "Making films. Being a genius" - }, - "propertyKeys": ["AP-SAMPLE-2"], - "type": "USER" - }, - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {} - }, - "files": {} - }, - "metadata": [ - { - "userId": "9a7820d0-0ff2-4451-b655-682cec15cbd2", - "jobId": 1, - "sourceId": "1s9eG8UCer6YSKsD8ZlQCyLa3pj", - "destinationId": "1uLy1tqsoo9RhL1zLiqLQTKBIKL", - "attemptNum": 0, - "receivedAt": "2021-06-25T14:29:52.911+05:30", - "createdAt": "2021-06-25T08:59:56.329Z", - "firstAttemptedAt": "", - "transformAt": "router" - } - ], - "batched": false, - "statusCode": 200, - "destination": { - "ID": "1uLy1tqsoo9RhL1zLiqLQTKBIKL", - "Name": "gainsight-px-dest", - "DestinationDefinition": { - "ID": "1uLuOdwPCqtei55ZKXewwPhjQPf", - "Name": "GAINSIGHT_PX", - "DisplayName": "Gainsight PX", - "Config": { - "destConfig": { - "defaultConfig": [ - "apiKey", - "productTagKey", - "userAttributeMap", - "accountAttributeMap", - "globalContextMap" - ] - }, - "excludeKeys": [], - "includeKeys": [], - "saveDestinationResponse": true, - "secretKeys": ["apiKey", "productTagKey"], - "supportedSourceTypes": [ - "android", - "ios", - "web", - "unity", - "amp", - "cloud", - "reactnative", - "flutter" - ], - "transformAt": "router", - "transformAtV1": "router" - }, - "ResponseRules": {} - }, - "Config": { - "accountAttributeMap": [ - { - "from": "cultureCustomField", - "to": "culture" - } - ], - "apiKey": "sample-api-key", - "eventDelivery": false, - "eventDeliveryTS": 1624472902670, - "globalContextMap": [ - { - "from": "kubrickTest", - "to": "value" - } - ], - "productTagKey": "AP-SAMPLE-2", - "userAttributeMap": [ - { - "from": "hobbyCustomField", - "to": "hobby" - } - ] - }, - "Enabled": true, - "Transformations": [], - "IsProcessorEnabled": true - } - }, - { - "batchedRequest": { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.aptrinsic.com/v1/events/custom", - "headers": { - "X-APTRINSIC-API-KEY": "sample-api-key", - "Content-Type": "application/json" - }, - "params": {}, - "body": { - "JSON": { - "identifyId": "adifhas9734", - "eventName": "nested test2", - "date": 1624704082335, - "attributes": { - "array": "[1,2,3]", - "nested": "{\"json\":\"test\"}", - "status": "testing", - "description": "Example track call", - "fullyNested": "[{\"a\":1,\"b\":2},{\"a\":1,\"b\":[1,2,3]}]" - }, - "url": "file:///Users/anurajguha/workspace/simple-html-test/index.html", - "referrer": "$direct", - "propertyKey": "AP-SAMPLE-2", - "userType": "USER", - "globalContext": { - "kubrickTest": "value" - } - }, - "XML": {}, - "JSON_ARRAY": {}, - "FORM": {} - }, - "files": {} - }, - "metadata": [ - { - "userId": "a27a8a8a-9e81-4898-beeb-e6041fc1552d", - "jobId": 2, - "sourceId": "1s9eG8UCer6YSKsD8ZlQCyLa3pj", - "destinationId": "1uLy1tqsoo9RhL1zLiqLQTKBIKL", - "attemptNum": 0, - "receivedAt": "2021-06-26T16:11:22.335+05:30", - "createdAt": "2021-06-26T10:41:24.126Z", - "firstAttemptedAt": "", - "transformAt": "router" - } - ], - "batched": false, - "statusCode": 200, - "destination": { - "ID": "1uLy1tqsoo9RhL1zLiqLQTKBIKL", - "Name": "gainsight-px-dest", - "DestinationDefinition": { - "ID": "1uLuOdwPCqtei55ZKXewwPhjQPf", - "Name": "GAINSIGHT_PX", - "DisplayName": "Gainsight PX", - "Config": { - "destConfig": { - "defaultConfig": [ - "apiKey", - "productTagKey", - "userAttributeMap", - "accountAttributeMap", - "globalContextMap" - ] - }, - "excludeKeys": [], - "includeKeys": [], - "saveDestinationResponse": true, - "secretKeys": ["apiKey", "productTagKey"], - "supportedSourceTypes": [ - "android", - "ios", - "web", - "unity", - "amp", - "cloud", - "reactnative", - "flutter" - ], - "transformAt": "router", - "transformAtV1": "router" - }, - "ResponseRules": {} - }, - "Config": { - "accountAttributeMap": [ - { - "from": "cultureCustomField", - "to": "culture" - } - ], - "apiKey": "sample-api-key", - "eventDelivery": false, - "eventDeliveryTS": 1624472902670, - "globalContextMap": [ - { - "from": "kubrickTest", - "to": "value" - } - ], - "productTagKey": "AP-SAMPLE-2", - "userAttributeMap": [ - { - "from": "hobbyCustomField", - "to": "hobby" - } - ] - }, - "Enabled": true, - "Transformations": [], - "IsProcessorEnabled": true - } - } + JSON: { + identifyId: 'adifhas9734', + eventName: 'nested test2', + date: 1624704082335, + attributes: { + array: '[1,2,3]', + nested: '{"json":"test"}', + status: 'testing', + description: 'Example track call', + fullyNested: '[{"a":1,"b":2},{"a":1,"b":[1,2,3]}]', + }, + url: 'file:///Users/anurajguha/workspace/simple-html-test/index.html', + referrer: '$direct', + propertyKey: 'AP-SAMPLE-2', + userType: 'USER', + globalContext: { + kubrickTest: 'value', + }, + }, + XML: {}, + JSON_ARRAY: {}, + FORM: {}, + }, + files: {}, + }, + metadata: [ + { + userId: 'a27a8a8a-9e81-4898-beeb-e6041fc1552d', + jobId: 2, + sourceId: '1s9eG8UCer6YSKsD8ZlQCyLa3pj', + destinationId: '1uLy1tqsoo9RhL1zLiqLQTKBIKL', + attemptNum: 0, + receivedAt: '2021-06-26T16:11:22.335+05:30', + createdAt: '2021-06-26T10:41:24.126Z', + firstAttemptedAt: '', + transformAt: 'router', + }, + ], + batched: false, + statusCode: 200, + destination: { + ID: '1uLy1tqsoo9RhL1zLiqLQTKBIKL', + Name: 'gainsight-px-dest', + DestinationDefinition: { + ID: '1uLuOdwPCqtei55ZKXewwPhjQPf', + Name: 'GAINSIGHT_PX', + DisplayName: 'Gainsight PX', + Config: { + destConfig: { + defaultConfig: [ + 'apiKey', + 'productTagKey', + 'userAttributeMap', + 'accountAttributeMap', + 'globalContextMap', + ], + }, + excludeKeys: [], + includeKeys: [], + saveDestinationResponse: true, + secretKeys: ['apiKey', 'productTagKey'], + supportedSourceTypes: [ + 'android', + 'ios', + 'web', + 'unity', + 'amp', + 'cloud', + 'reactnative', + 'flutter', ], + transformAt: 'router', + transformAtV1: 'router', + }, + ResponseRules: {}, + }, + Config: { + accountAttributeMap: [ + { + from: 'cultureCustomField', + to: 'culture', + }, + ], + apiKey: 'sample-api-key', + eventDelivery: false, + eventDeliveryTS: 1624472902670, + globalContextMap: [ + { + from: 'kubrickTest', + to: 'value', + }, + ], + productTagKey: 'AP-SAMPLE-2', + userAttributeMap: [ + { + from: 'hobbyCustomField', + to: 'hobby', + }, + ], }, + Enabled: true, + Transformations: [], + IsProcessorEnabled: true, + }, }, + ], }, + }, }, + }, ]; From e0c225dfab711c1d87d1c5dd1be98fb476548588 Mon Sep 17 00:00:00 2001 From: Mihir Bhalala <77438541+mihir-4116@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:18:51 +0530 Subject: [PATCH 2/2] feat(sprig): added user deletion support (#2886) * feat(sprig): added user deletion support * chore: destination doc link added for reference * chore: code review changes * chore: code review changes --- src/v0/destinations/sprig/deleteUsers.js | 79 +++++++ .../destinations/sprig/deleteUsers/data.ts | 217 ++++++++++++++++++ .../destinations/sprig/network.ts | 79 +++++++ 3 files changed, 375 insertions(+) create mode 100644 src/v0/destinations/sprig/deleteUsers.js create mode 100644 test/integrations/destinations/sprig/deleteUsers/data.ts create mode 100644 test/integrations/destinations/sprig/network.ts diff --git a/src/v0/destinations/sprig/deleteUsers.js b/src/v0/destinations/sprig/deleteUsers.js new file mode 100644 index 0000000000..a886bbbafc --- /dev/null +++ b/src/v0/destinations/sprig/deleteUsers.js @@ -0,0 +1,79 @@ +const { NetworkError, ConfigurationError } = require('@rudderstack/integrations-lib'); +const { httpPOST } = require('../../../adapters/network'); +const { + processAxiosResponse, + getDynamicErrorType, +} = require('../../../adapters/utils/networkUtils'); +const { isHttpStatusSuccess } = require('../../util'); +const { executeCommonValidations } = require('../../util/regulation-api'); +const tags = require('../../util/tags'); +const { getUserIdBatches } = require('../../util/deleteUserUtils'); +const { JSON_MIME_TYPE } = require('../../util/constant'); + +/** + * This function will help to delete the users one by one from the userAttributes array. + * @param {*} userAttributes Array of objects with userId, email and phone + * @param {*} config Destination.Config provided in dashboard + * @returns + */ +const userDeletionHandler = async (userAttributes, config) => { + const { apiKey } = config; + + if (!apiKey) { + throw new ConfigurationError('Api Key is required for user deletion'); + } + + const endpoint = 'https://api.sprig.com/v2/purge/visitors'; + const headers = { + Accept: JSON_MIME_TYPE, + 'Content-Type': JSON_MIME_TYPE, + Authorization: `API-Key ${apiKey}`, + }; + /** + * userIdBatches = [[u1,u2,u3,...batchSize],[u1,u2,u3,...batchSize]...] + * Ref doc : https://docs.sprig.com/reference/post-v2-purge-visitors-1 + */ + const userIdBatches = getUserIdBatches(userAttributes, 100); + // Note: we will only get 400 status code when no user deletion is present for given userIds so we will not throw error in that case + // eslint-disable-next-line no-restricted-syntax + for (const curBatch of userIdBatches) { + // eslint-disable-next-line no-await-in-loop + const deletionResponse = await httpPOST( + endpoint, + { + userIds: curBatch, + }, + { + headers, + }, + { + destType: 'sprig', + feature: 'deleteUsers', + endpointPath: 'api.sprig.com/v2/purge/visitors', + }, + ); + const handledDelResponse = processAxiosResponse(deletionResponse); + if (!isHttpStatusSuccess(handledDelResponse.status) && handledDelResponse.status !== 400) { + throw new NetworkError( + 'User deletion request failed', + handledDelResponse.status, + { + [tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(handledDelResponse.status), + }, + handledDelResponse, + ); + } + } + + return { + statusCode: 200, + status: 'successful', + }; +}; +const processDeleteUsers = async (event) => { + const { userAttributes, config } = event; + executeCommonValidations(userAttributes); + const resp = await userDeletionHandler(userAttributes, config); + return resp; +}; +module.exports = { processDeleteUsers }; diff --git a/test/integrations/destinations/sprig/deleteUsers/data.ts b/test/integrations/destinations/sprig/deleteUsers/data.ts new file mode 100644 index 0000000000..7ab5620e66 --- /dev/null +++ b/test/integrations/destinations/sprig/deleteUsers/data.ts @@ -0,0 +1,217 @@ +export const data = [ + { + name: 'sprig', + description: 'Missing api key', + feature: 'userDeletion', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destType: 'SPRIG', + userAttributes: [ + { + userId: '1', + }, + { + userId: '2', + }, + ], + config: { + apiKey: undefined, + }, + }, + ], + }, + }, + output: { + response: { + status: 400, + body: [ + { + statusCode: 400, + error: 'Api Key is required for user deletion', + }, + ], + }, + }, + }, + { + name: 'sprig', + description: 'Invalid api key', + feature: 'userDeletion', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destType: 'SPRIG', + userAttributes: [ + { + userId: '1', + }, + { + userId: '2', + }, + ], + config: { + apiKey: 'invalidApiKey', + }, + }, + ], + }, + }, + output: { + response: { + status: 403, + body: [ + { + statusCode: 403, + error: 'User deletion request failed', + }, + ], + }, + }, + }, + { + name: 'sprig', + description: 'Too many requests', + feature: 'userDeletion', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destType: 'SPRIG', + userAttributes: [ + { + userId: '1', + }, + { + userId: '2', + }, + { + userId: '3', + }, + { + userId: '4', + }, + { + userId: '5', + }, + { + userId: '6', + }, + { + userId: '7', + }, + { + userId: '8', + }, + { + userId: '9', + }, + { + userId: '10', + }, + ], + config: { + apiKey: 'testApiKey', + }, + }, + ], + }, + }, + output: { + response: { + status: 429, + body: [ + { + statusCode: 429, + error: 'User deletion request failed', + }, + ], + }, + }, + }, + { + name: 'sprig', + description: 'Given userId is not present for user deletion', + feature: 'userDeletion', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destType: 'SPRIG', + userAttributes: [ + { + userId: '9', + }, + ], + config: { + apiKey: 'testApiKey', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + statusCode: 200, + status: 'successful', + }, + , + ], + }, + }, + }, + { + name: 'sprig', + description: 'Successful user deletion', + feature: 'userDeletion', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destType: 'SPRIG', + userAttributes: [ + { + userId: '1', + }, + { + userId: '2', + }, + { + userId: '3', + }, + ], + config: { + apiKey: 'testApiKey', + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + statusCode: 200, + status: 'successful', + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/sprig/network.ts b/test/integrations/destinations/sprig/network.ts new file mode 100644 index 0000000000..e5f2ff23b1 --- /dev/null +++ b/test/integrations/destinations/sprig/network.ts @@ -0,0 +1,79 @@ +const deleteNwData = [ + { + httpReq: { + method: 'post', + url: 'https://api.sprig.com/v2/purge/visitors', + data: { + userIds: ['1', '2'], + }, + headers: { + Accept: 'application/json', + Authorization: 'API-Key invalidApiKey', + 'Content-Type': 'application/json', + }, + }, + httpRes: { + data: 'Forbidden', + status: 403, + }, + }, + { + httpReq: { + method: 'post', + url: 'https://api.sprig.com/v2/purge/visitors', + data: { + userIds: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'], + }, + headers: { + Accept: 'application/json', + Authorization: 'API-Key testApiKey', + 'Content-Type': 'application/json', + }, + }, + httpRes: { + data: 'Your application has made too many requests in too short a time.', + status: 429, + }, + }, + { + httpReq: { + method: 'post', + url: 'https://api.sprig.com/v2/purge/visitors', + data: { + userIds: ['9'], + }, + headers: { + Accept: 'application/json', + Authorization: 'API-Key testApiKey', + 'Content-Type': 'application/json', + }, + }, + httpRes: { + data: { + error: 'User deletion request failed', + }, + status: 400, + }, + }, + { + httpReq: { + method: 'post', + url: 'https://api.sprig.com/v2/purge/visitors', + data: { + userIds: ['1', '2', '3'], + }, + headers: { + Accept: 'application/json', + Authorization: 'API-Key testApiKey', + 'Content-Type': 'application/json', + }, + }, + httpRes: { + data: { + requestId: 'request_1', + }, + status: 200, + }, + }, +]; +export const networkCallsData = [...deleteNwData];