From 89a71b757998cb55a63c59151b5e3a118084970b Mon Sep 17 00:00:00 2001 From: Mihir Bhalala <77438541+mihir-4116@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:27:51 +0530 Subject: [PATCH] chore: component test refactor for intercom destination (#3236) --- .../destinations/intercom/processor/data.ts | 4156 +---------------- .../intercom/processor/groupTestData.ts | 509 ++ .../intercom/processor/identifyTestData.ts | 1025 ++++ .../intercom/processor/trackTestData.ts | 361 ++ .../intercom/processor/validationTestData.ts | 554 +++ 5 files changed, 2458 insertions(+), 4147 deletions(-) create mode 100644 test/integrations/destinations/intercom/processor/groupTestData.ts create mode 100644 test/integrations/destinations/intercom/processor/identifyTestData.ts create mode 100644 test/integrations/destinations/intercom/processor/trackTestData.ts create mode 100644 test/integrations/destinations/intercom/processor/validationTestData.ts diff --git a/test/integrations/destinations/intercom/processor/data.ts b/test/integrations/destinations/intercom/processor/data.ts index 2c562ed4e9..7bc697bc2d 100644 --- a/test/integrations/destinations/intercom/processor/data.ts +++ b/test/integrations/destinations/intercom/processor/data.ts @@ -1,4149 +1,11 @@ +import { identifyTestData } from './identifyTestData'; +import { trackTestData } from './trackTestData'; +import { groupTestData } from './groupTestData'; +import { validationTestData } from './validationTestData'; + export const data = [ - { - name: 'intercom', - description: 'No message type', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - channel: 'web', - context: { - traits: { - age: 23, - email: 'adc@test.com', - firstname: 'Test', - birthday: '2022-05-13T12:51:01.470Z', - }, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', - }, - event: 'Product Searched', - originalTimestamp: '2020-09-22T14:42:44.724Z', - timestamp: '2022-09-22T20:12:44.757+05:30', - userId: 'user@1', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 1, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 1, - }, - statusCode: 400, - error: - 'message Type is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: message Type is not present. Aborting', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Unsupported message type', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - channel: 'web', - context: { - traits: { - age: 23, - email: 'adc@test.com', - firstname: 'Test', - birthday: '2022-05-13T12:51:01.470Z', - }, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', - }, - event: 'Product Searched', - type: 'page', - originalTimestamp: '2020-09-22T14:42:44.724Z', - timestamp: '2022-09-22T20:12:44.757+05:30', - userId: 'user@1', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 2, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 2, - }, - statusCode: 400, - error: - 'message type page is not supported: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: message type page is not supported', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Missing required config', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@1', - channel: 'web', - context: { - traits: { - age: 23, - email: 'adc@test.com', - firstName: 'Test', - }, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 3, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 3, - }, - statusCode: 400, - error: - 'Access Token is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Access Token is not present. Aborting', - statTags: { - errorCategory: 'dataValidation', - errorType: 'configuration', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Create customer with email as lookup field', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@1', - channel: 'web', - context: { - traits: { - age: 23, - email: 'test@rudderlabs.com', - phone: '+91 9999999999', - firstName: 'Test', - lastName: 'Rudderlabs', - address: 'california usa', - ownerId: '13', - lastSeenAt: '2023-11-10T14:42:44.724Z', - }, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 4, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - email: 'test@rudderlabs.com', - external_id: 'user@1', - last_seen_at: 1699627364, - name: 'Test Rudderlabs', - owner_id: 13, - phone: '+91 9999999999', - custom_attributes: { - address: 'california usa', - age: 23, - }, - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.intercom.io/contacts', - headers: { - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - Accept: 'application/json', - 'Intercom-Version': '2.10', - }, - userId: '', - version: '1', - type: 'REST', - method: 'POST', - files: {}, - params: {}, - }, - metadata: { jobId: 4 }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Update customer with email as lookup field', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@2', - channel: 'web', - context: { - traits: { - age: 32, - email: 'test+2@rudderlabs.com', - phone: '+91 9299999999', - firstName: 'Test', - lastName: 'RudderStack', - ownerId: '14', - }, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 5, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - email: 'test+2@rudderlabs.com', - external_id: 'user@2', - name: 'Test RudderStack', - owner_id: 14, - phone: '+91 9299999999', - custom_attributes: { - age: 32, - }, - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.intercom.io/contacts/7070129940741e45d040', - headers: { - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - Accept: 'application/json', - 'Intercom-Version': '2.10', - }, - userId: '', - version: '1', - type: 'REST', - method: 'PUT', - files: {}, - params: {}, - }, - metadata: { jobId: 5 }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Missing required parameters for an identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: 'anon@2', - channel: 'web', - context: { - traits: { - age: 32, - phone: '+91 9299999999', - firstName: 'Test', - lastName: 'RudderStack', - ownerId: '14', - role: 'user', - source: 'rudder-sdk', - }, - }, - integrations: { - INTERCOM: { - lookup: 'phone', - }, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 6, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 6, - }, - statusCode: 400, - error: - 'Either email or userId is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForLatestVersion, ChildStep: undefined, OriginalError: Either email or userId is required for Identify call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Unauthorized error while searching contact for an identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@3', - channel: 'web', - context: { - traits: { - phone: '+91 9399999999', - email: 'test+3@rudderlabs.com', - firstName: 'Test', - lastName: 'Rudder', - ownerId: '15', - role: 'admin', - source: 'rudder-android-sdk', - }, - }, - integrations: { - INTERCOM: { - lookup: 'email', - }, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'invalidApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 7, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 7, - }, - statusCode: 401, - error: - '{"message":"{\\"message\\":\\"Unable to search contact due to : [{\\\\\\"code\\\\\\":\\\\\\"unauthorized\\\\\\",\\\\\\"message\\\\\\":\\\\\\"Access Token Invalid\\\\\\"}]: Workflow: procWorkflow, Step: searchContact, ChildStep: undefined, OriginalError: Unable to search contact due to : [{\\\\\\"code\\\\\\":\\\\\\"unauthorized\\\\\\",\\\\\\"message\\\\\\":\\\\\\"Access Token Invalid\\\\\\"}]\\",\\"destinationResponse\\":{\\"response\\":{\\"type\\":\\"error.list\\",\\"request_id\\":\\"request_1\\",\\"errors\\":[{\\"code\\":\\"unauthorized\\",\\"message\\":\\"Access Token Invalid\\"}]},\\"status\\":401}}","destinationResponse":{"response":{"type":"error.list","request_id":"request_1","errors":[{"code":"unauthorized","message":"Access Token Invalid"}]},"status":401}}', - statTags: { - errorCategory: 'network', - errorType: 'aborted', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Track call without event name', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@3', - channel: 'web', - context: { - traits: { - age: 32, - email: 'test+3@rudderlabs.com', - phone: '+91 9399999999', - firstName: 'Test', - lastName: 'RudderStack', - ownerId: '15', - }, - }, - properties: { - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - price: { - amount: 3000, - currency: 'USD', - }, - }, - type: 'track', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 8, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 8, - }, - statusCode: 400, - error: - 'Event name is required for track call: Workflow: procWorkflow, Step: trackPayload, ChildStep: undefined, OriginalError: Event name is required for track call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Successful track call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@2', - channel: 'web', - context: { - traits: { - age: 32, - email: 'test+2@rudderlabs.com', - phone: '+91 9299999999', - firstName: 'Test', - lastName: 'RudderStack', - ownerId: '14', - }, - }, - properties: { - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - price: { - amount: 3000, - currency: 'USD', - }, - }, - event: 'Product Viewed', - type: 'track', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 9, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - FORM: {}, - JSON: { - created_at: 1700628164, - email: 'test+2@rudderlabs.com', - event_name: 'Product Viewed', - metadata: { - price: { - amount: 3000, - currency: 'USD', - }, - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - }, - user_id: 'user@2', - }, - JSON_ARRAY: {}, - XML: {}, - }, - endpoint: 'https://api.intercom.io/events', - headers: { - Accept: 'application/json', - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - 'Intercom-Version': '2.10', - }, - method: 'POST', - type: 'REST', - userId: '', - version: '1', - params: {}, - files: {}, - }, - statusCode: 200, - metadata: { - jobId: 9, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Group call without groupId', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@4', - channel: 'web', - context: { - traits: { - email: 'test+4@rudderlabs.com', - phone: '+91 9499999999', - firstName: 'John', - lastName: 'Doe', - ownerId: '16', - }, - }, - traits: { - name: 'RudderStack', - size: 500, - website: 'www.rudderstack.com', - industry: 'CDP', - plan: 'enterprise', - }, - type: 'group', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 10, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - metadata: { - jobId: 10, - }, - statusCode: 400, - error: - 'groupId is required for group call: Workflow: procWorkflow, Step: groupPayloadForLatestVersion, ChildStep: validateMessageAndPreparePayload, OriginalError: groupId is required for group call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Successful group call to create or update company', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@4', - groupId: 'rudderlabs', - channel: 'web', - context: { - traits: { - email: 'test+4@rudderlabs.com', - phone: '+91 9499999999', - firstName: 'John', - lastName: 'Doe', - ownerId: '16', - }, - }, - traits: { - name: 'RudderStack', - size: 500, - website: 'www.rudderstack.com', - industry: 'CDP', - plan: 'enterprise', - }, - type: 'group', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 11, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - company_id: 'rudderlabs', - industry: 'CDP', - name: 'RudderStack', - plan: 'enterprise', - size: 500, - website: 'www.rudderstack.com', - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.intercom.io/companies', - headers: { - Accept: 'application/json', - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - 'Intercom-Version': '2.10', - }, - method: 'POST', - type: 'REST', - userId: '', - version: '1', - params: {}, - files: {}, - }, - statusCode: 200, - metadata: { - jobId: 11, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Successful group call to add user to company', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@5', - groupId: 'rudderlabs', - channel: 'web', - context: { - traits: { - email: 'test+5@rudderlabs.com', - phone: '+91 9599999999', - firstName: 'John', - lastName: 'Snow', - ownerId: '17', - }, - }, - traits: { - name: 'RudderStack', - size: 500, - website: 'www.rudderstack.com', - industry: 'CDP', - plan: 'enterprise', - }, - type: 'group', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'eu', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 12, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - id: '657264e9018c0a647s45', - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.eu.intercom.io/contacts/70701240741e45d040/companies', - headers: { - Accept: 'application/json', - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - 'Intercom-Version': '2.10', - }, - method: 'POST', - type: 'REST', - userId: '', - version: '1', - params: {}, - files: {}, - }, - statusCode: 200, - metadata: { - jobId: 12, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Identify rEtl test', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - channel: 'web', - context: { - externalId: [ - { - id: 'user@1', - type: 'INTERCOM-customer', - identifierType: 'user_id', - }, - ], - mappedToDestination: 'true', - }, - traits: { - email: 'test@rudderlabs.com', - phone: '+91 9999999999', - name: 'Test Rudderlabs', - owner_id: 13, - }, - type: 'identify', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 13, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - email: 'test@rudderlabs.com', - name: 'Test Rudderlabs', - phone: '+91 9999999999', - owner_id: 13, - user_id: 'user@1', - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.intercom.io/contacts', - headers: { - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - Accept: 'application/json', - 'Intercom-Version': '2.10', - }, - userId: '', - version: '1', - type: 'REST', - method: 'POST', - files: {}, - params: {}, - }, - metadata: { jobId: 13 }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Track rEtl test', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - userId: 'user@1', - channel: 'web', - context: { - mappedToDestination: 'true', - }, - traits: { - event_name: 'Product Viewed', - user_id: 'user@1', - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - price: { - amount: 3000, - currency: 'USD', - }, - }, - event: 'Product Viewed', - type: 'track', - originalTimestamp: '2023-11-10T14:42:44.724Z', - timestamp: '2023-11-22T10:12:44.757+05:30', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'testApiKey', - apiVersion: 'v2', - apiServer: 'standard', - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 14, - }, - }, - ], - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - body: { - JSON: { - event_name: 'Product Viewed', - price: { - amount: 3000, - currency: 'USD', - }, - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - user_id: 'user@1', - }, - XML: {}, - FORM: {}, - JSON_ARRAY: {}, - }, - endpoint: 'https://api.intercom.io/events', - headers: { - Authorization: 'Bearer testApiKey', - 'Content-Type': 'application/json', - Accept: 'application/json', - 'Intercom-Version': '2.10', - }, - userId: '', - version: '1', - type: 'REST', - method: 'POST', - files: {}, - params: {}, - }, - metadata: { jobId: 14 }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - userId: 'test_user_id_1', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - address: { - city: 'Kolkata', - state: 'West Bengal', - }, - originalArray: [ - { - nested_field: 'nested value', - tags: ['tag_1', 'tag_2', 'tag_3'], - }, - { - nested_field: 'nested value', - tags: ['tag_1'], - }, - { - nested_field: 'nested value', - }, - ], - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 15, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'test_user_id_1', - email: 'test_1@test.com', - phone: '9876543210', - name: 'Test Name', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - 'address.city': 'Kolkata', - 'address.state': 'West Bengal', - 'originalArray[0].nested_field': 'nested value', - 'originalArray[0].tags[0]': 'tag_1', - 'originalArray[0].tags[1]': 'tag_2', - 'originalArray[0].tags[2]': 'tag_3', - 'originalArray[1].nested_field': 'nested value', - 'originalArray[1].tags[0]': 'tag_1', - 'originalArray[2].nested_field': 'nested value', - }, - update_last_request_at: true, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 15, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 16, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Test Name', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 16, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 17, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Name', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 17, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - firstName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 18, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Name', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 18, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old Version: Identify call without email and userId', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - firstName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 19, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - statusCode: 400, - error: - 'Either of `email` or `userId` is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForOlderVersion, ChildStep: undefined, OriginalError: Either of `email` or `userId` is required for Identify call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - metadata: { - jobId: 19, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - company: { - name: 'Test Comp', - id: 'company_id', - industry: 'test industry', - key1: 'value1', - key2: { - a: 'a', - }, - key3: [1, 2, 3], - }, - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 20, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Name', - companies: [ - { - company_id: 'company_id', - custom_attributes: { - key1: 'value1', - key2: '{"a":"a"}', - key3: '[1,2,3]', - }, - name: 'Test Comp', - industry: 'test industry', - }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 20, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - company: { - name: 'Test Comp', - industry: 'test industry', - key1: 'value1', - key2: null, - key3: ['value1', 'value2'], - key4: { - foo: 'bar', - }, - }, - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - updateLastRequestAt: false, - }, - }, - metadata: { - jobId: 21, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: false, - name: 'Name', - companies: [ - { - company_id: 'c0277b5c814453e5135f515f943d085a', - custom_attributes: { - key1: 'value1', - key3: '["value1","value2"]', - key4: '{"foo":"bar"}', - }, - name: 'Test Comp', - industry: 'test industry', - }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 21, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - company: { - industry: 'test industry', - key1: 'value1', - key2: null, - }, - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 22, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Name', - companies: [], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 22, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful track call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - userId: 'test_user_id_1', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - properties: { - property1: 1, - property2: 'test', - property3: true, - property4: '2020-10-05T09:09:03.731Z', - property5: { - property1: 1, - property2: 'test', - property3: { - subProp1: { - a: 'a', - b: 'b', - }, - subProp2: ['a', 'b'], - }, - }, - properties6: null, - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - price: { - amount: 3000, - currency: 'USD', - }, - article: { - url: 'https://example.org/ab1de.html', - value: 'the dude abides', - }, - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'track', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 23, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/events', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'test_user_id_1', - email: 'test_1@test.com', - event_name: 'Test Event 2', - created: 1601493061, - metadata: { - revenue: { - amount: 1232, - currency: 'inr', - test: 123, - }, - price: { - amount: 3000, - currency: 'USD', - }, - article: { - url: 'https://example.org/ab1de.html', - value: 'the dude abides', - }, - property1: 1, - property2: 'test', - property3: true, - property4: '2020-10-05T09:09:03.731Z', - 'property5.property1': 1, - 'property5.property2': 'test', - 'property5.property3.subProp1.a': 'a', - 'property5.property3.subProp1.b': 'b', - 'property5.property3.subProp2[0]': 'a', - 'property5.property3.subProp2[1]': 'b', - properties6: null, - }, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 23, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version - successful track call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'track', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 24, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/events', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - event_name: 'Test Event 2', - created: 1601493061, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 24, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : Track call without email or userId', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'track', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 25, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - statusCode: 400, - error: - 'Either email or userId is required for Track call: Workflow: procWorkflow, Step: trackPayload, ChildStep: undefined, OriginalError: Either email or userId is required for Track call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - metadata: { - jobId: 25, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - externalId: [ - { - id: '10156', - type: 'INTERCOM-customer', - identifierType: 'user_id', - }, - ], - mappedToDestination: 'true', - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - metadata: { - jobId: 26, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - update_last_request_at: true, - user_id: '10156', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 26, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful identify call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - sendAnonymousId: true, - }, - }, - metadata: { - jobId: 27, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - phone: '9876543210', - name: 'Test Name', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - user_id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - update_last_request_at: true, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - metadata: { - jobId: 27, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : Identify call without email or userId', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'intercomApiKey', - apiVersion: 'v1', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - sendAnonymousId: false, - }, - }, - metadata: { - jobId: 28, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - statusCode: 400, - error: - 'Either of `email` or `userId` is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForOlderVersion, ChildStep: undefined, OriginalError: Either of `email` or `userId` is required for Identify call', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - destType: 'INTERCOM', - module: 'destination', - implementation: 'cdkV2', - feature: 'processor', - }, - metadata: { - jobId: 28, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful group call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - groupId: 'test_company_id_wdasda', - traits: { - employees: 450, - plan: 'basic', - userId: 'sdfrsdfsdfsf', - email: 'test@test.com', - name: 'rudderUpdate', - size: '50', - industry: 'IT', - monthlySpend: '2131231', - remoteCreatedAt: '1683017572', - key1: 'val1', - }, - anonymousId: 'sdfrsdfsdfsf', - integrations: { - All: true, - }, - type: 'group', - userId: 'sdfrsdfsdfsf', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'abcd=', - appId: 'asdasdasd', - apiVersion: 'v1', - collectContext: false, - }, - }, - metadata: { - jobId: 29, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/companies', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - plan: 'basic', - size: 50, - industry: 'IT', - monthly_spend: 2131231, - remote_created_at: 1683017572, - custom_attributes: { - employees: 450, - email: 'test@test.com', - key1: 'val1', - }, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'sdfrsdfsdfsf', - }, - statusCode: 200, - metadata: { - jobId: 29, - }, - }, - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'sdfrsdfsdfsf', - companies: [ - { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'sdfrsdfsdfsf', - }, - statusCode: 200, - metadata: { - jobId: 29, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful group call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - groupId: 'test_company_id', - traits: { - plan: 'basic', - name: 'rudderUpdate', - size: 50, - industry: 'IT', - monthlySpend: '2131231', - email: 'comanyemail@abc.com', - }, - anonymousId: '12312312', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - userAgent: 'unknown', - }, - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - type: 'group', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'abcd=', - apiVersion: 'v1', - appId: 'asdasdasd', - collectContext: false, - }, - }, - metadata: { - jobId: 30, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/companies', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - company_id: 'test_company_id', - name: 'rudderUpdate', - plan: 'basic', - size: 50, - industry: 'IT', - monthly_spend: 2131231, - custom_attributes: { - email: 'comanyemail@abc.com', - }, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '12312312', - }, - statusCode: 200, - metadata: { - jobId: 30, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful group call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - groupId: 'test_company_id_wdasda', - context: { - traits: { - email: 'testUser@test.com', - }, - }, - traits: { - employees: 450, - plan: 'basic', - email: 'test@test.com', - name: 'rudderUpdate', - size: '50', - industry: 'IT', - website: 'url', - monthlySpend: '2131231', - remoteCreatedAt: '1683017572', - key1: 'val1', - }, - anonymousId: 'sdfrsdfsdfsf', - integrations: { - All: true, - }, - type: 'group', - userId: 'sdfrsdfsdfsf', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'abcd=', - apiVersion: 'v1', - appId: 'asdasdasd', - collectContext: false, - }, - }, - metadata: { - jobId: 31, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/companies', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - plan: 'basic', - size: 50, - website: 'url', - industry: 'IT', - monthly_spend: 2131231, - remote_created_at: 1683017572, - custom_attributes: { - employees: 450, - email: 'test@test.com', - key1: 'val1', - }, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'sdfrsdfsdfsf', - }, - statusCode: 200, - metadata: { - jobId: 31, - }, - }, - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'sdfrsdfsdfsf', - email: 'testUser@test.com', - companies: [ - { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'sdfrsdfsdfsf', - }, - statusCode: 200, - metadata: { - jobId: 31, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Old version : successful group call', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - groupId: 'test_company_id_wdasda', - context: { - traits: { - email: 'testUser@test.com', - }, - }, - traits: { - employees: 450, - plan: 'basic', - email: 'test@test.com', - name: 'rudderUpdate', - size: '50', - industry: 'IT', - website: 'url', - monthlySpend: '2131231', - remoteCreatedAt: '1683017572', - key1: 'val1', - key2: { - a: 'a', - b: 'b', - }, - key3: [1, 2, 3], - key4: null, - }, - anonymousId: 'anonId', - integrations: { - All: true, - }, - type: 'group', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - apiKey: 'abcd=', - appId: 'asdasdasd', - apiVersion: 'v1', - collectContext: false, - sendAnonymousId: true, - }, - }, - metadata: { - jobId: 32, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/companies', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - plan: 'basic', - size: 50, - website: 'url', - industry: 'IT', - monthly_spend: 2131231, - remote_created_at: 1683017572, - custom_attributes: { - employees: 450, - email: 'test@test.com', - key1: 'val1', - 'key2.a': 'a', - 'key2.b': 'b', - 'key3[0]': 1, - 'key3[1]': 2, - 'key3[2]': 3, - key4: null, - }, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'anonId', - }, - statusCode: 200, - metadata: { - jobId: 32, - }, - }, - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer abcd=', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'anonId', - email: 'testUser@test.com', - companies: [ - { - company_id: 'test_company_id_wdasda', - name: 'rudderUpdate', - }, - ], - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: 'anonId', - }, - statusCode: 200, - metadata: { - jobId: 32, - }, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Test 0', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - name: 'Test Name', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - userId: 'test_user_id_1', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - address: { - city: 'Kolkata', - state: 'West Bengal', - }, - originalArray: [ - { - nested_field: 'nested value', - tags: ['tag_1', 'tag_2', 'tag_3'], - }, - { - nested_field: 'nested value', - tags: ['tag_1'], - }, - { - nested_field: 'nested value', - }, - ], - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - Config: { - apiKey: 'intercomApiKey', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - user_id: 'test_user_id_1', - email: 'test_1@test.com', - phone: '9876543210', - name: 'Test Name', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - 'address.city': 'Kolkata', - 'address.state': 'West Bengal', - 'originalArray[0].nested_field': 'nested value', - 'originalArray[0].tags[0]': 'tag_1', - 'originalArray[0].tags[1]': 'tag_2', - 'originalArray[0].tags[2]': 'tag_3', - 'originalArray[1].nested_field': 'nested value', - 'originalArray[1].tags[0]': 'tag_1', - 'originalArray[2].nested_field': 'nested value', - }, - update_last_request_at: true, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Test 1', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - firstName: 'Test', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - Config: { - apiKey: 'intercomApiKey', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Test Name', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - }, - ], - }, - }, - }, - { - name: 'intercom', - description: 'Test 2', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - channel: 'mobile', - context: { - app: { - build: '1.0', - name: 'Test_Example', - namespace: 'com.example.testapp', - version: '1.0', - }, - device: { - id: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - manufacturer: 'Apple', - model: 'iPhone', - name: 'iPod touch (7th generation)', - type: 'iOS', - }, - library: { - name: 'test-ios-library', - version: '1.0.7', - }, - locale: 'en-US', - network: { - bluetooth: false, - carrier: 'unavailable', - cellular: false, - wifi: true, - }, - os: { - name: 'iOS', - version: '14.0', - }, - screen: { - density: 2, - height: 320, - width: 568, - }, - timezone: 'Asia/Kolkata', - traits: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - lastName: 'Name', - createdAt: '2020-09-30T19:11:00.337Z', - email: 'test_1@test.com', - phone: '9876543210', - key1: 'value1', - }, - userAgent: 'unknown', - }, - event: 'Test Event 2', - integrations: { - All: true, - }, - messageId: '1601493060-39010c49-e6e4-4626-a75c-0dbf1925c9e8', - originalTimestamp: '2020-09-30T19:11:00.337Z', - receivedAt: '2020-10-01T00:41:11.369+05:30', - request_ip: '2405:201:8005:9856:7911:25e7:5603:5e18', - sentAt: '2020-09-30T19:11:10.382Z', - timestamp: '2020-10-01T00:41:01.324+05:30', - type: 'identify', - }, - destination: { - Config: { - apiKey: 'intercomApiKey', - appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', - collectContext: false, - }, - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: 'https://api.intercom.io/users', - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer intercomApiKey', - Accept: 'application/json', - 'Intercom-Version': '1.4', - }, - params: {}, - body: { - JSON: { - email: 'test_1@test.com', - phone: '9876543210', - signed_up_at: 1601493060, - last_seen_user_agent: 'unknown', - custom_attributes: { - anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - key1: 'value1', - }, - update_last_request_at: true, - name: 'Name', - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', - }, - statusCode: 200, - }, - ], - }, - }, - }, + ...identifyTestData, + ...trackTestData, + ...groupTestData, + ...validationTestData, ]; diff --git a/test/integrations/destinations/intercom/processor/groupTestData.ts b/test/integrations/destinations/intercom/processor/groupTestData.ts new file mode 100644 index 0000000000..cb81df7bd2 --- /dev/null +++ b/test/integrations/destinations/intercom/processor/groupTestData.ts @@ -0,0 +1,509 @@ +import { Destination } from '../../../../../src/types'; +import { + generateMetadata, + transformResultBuilder, + generateSimplifiedGroupPayload, +} from '../../../testUtils'; + +const v1Config = { + apiKey: 'abcd=', + appId: 'asdasdasd', + apiVersion: 'v1', + collectContext: false, +}; + +const v2Config = { + apiKey: 'testApiKey', + apiVersion: 'v2', + apiServer: 'standard', + sendAnonymousId: false, +}; + +const v1Headers = { + 'Content-Type': 'application/json', + Authorization: 'Bearer abcd=', + Accept: 'application/json', + 'Intercom-Version': '1.4', +}; + +const v2Headers = { + Accept: 'application/json', + Authorization: 'Bearer testApiKey', + 'Content-Type': 'application/json', + 'Intercom-Version': '2.10', +}; + +const destination: Destination = { + ID: '123', + Name: 'intercom', + DestinationDefinition: { + ID: '123', + Name: 'intercom', + DisplayName: 'Intercom', + Config: { + cdkV2Enabled: true, + }, + }, + Config: {}, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const v1Destination = { ...destination, Config: v1Config }; +const v2Destination = { ...destination, Config: v2Config }; + +const userTraits = { + ownerId: '17', + firstName: 'John', + lastName: 'Snow', + phone: '+91 9599999999', + email: 'test+5@rudderlabs.com', +}; + +const group1Traits = { + size: 500, + industry: 'CDP', + plan: 'enterprise', + name: 'RudderStack', + website: 'www.rudderstack.com', +}; + +const group2Traits = { + size: '50', + key1: 'val1', + plan: 'basic', + industry: 'IT', + employees: 450, + monthlySpend: '2131231', + userId: 'sdfrsdfsdfsf', + email: 'test@test.com', + name: 'rudderUpdate', + remoteCreatedAt: '1683017572', +}; + +const timestamp = '2023-11-22T10:12:44.757+05:30'; +const originalTimestamp = '2023-11-10T14:42:44.724Z'; + +const endpoint = 'https://api.intercom.io/companies'; + +export const groupTestData = [ + { + id: 'intercom-group-test-1', + name: 'intercom', + description: 'V2 version : Successful group call to create or update company', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create or update company payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: generateSimplifiedGroupPayload({ + userId: 'user@4', + groupId: 'rudderlabs', + context: { + traits: { email: 'test+4@rudderlabs.com' }, + }, + traits: group1Traits, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint, + headers: v2Headers, + JSON: { company_id: 'rudderlabs', ...group1Traits }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-group-test-2', + name: 'intercom', + description: 'V2 version : Successful group call to add user to company', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain add user to company payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...v2Destination, Config: { ...v2Destination.Config, apiServer: 'eu' } }, + message: generateSimplifiedGroupPayload({ + userId: 'user@5', + groupId: 'rudderlabs', + context: { + traits: userTraits, + }, + traits: group1Traits, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint: 'https://api.eu.intercom.io/contacts/70701240741e45d040/companies', + headers: v2Headers, + JSON: { id: '657264e9018c0a647s45' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-group-test-3', + name: 'intercom', + description: + 'V1 version : successful group call to create company and add user to company based on userId', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create company and add user to company payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: generateSimplifiedGroupPayload({ + userId: 'sdfrsdfsdfsf', + anonymousId: 'sdfrsdfsdfsf', + groupId: 'test_company_id_wdasda', + context: { + traits: {}, + }, + traits: group2Traits, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: 'sdfrsdfsdfsf', + endpoint, + headers: v1Headers, + JSON: { + company_id: 'test_company_id_wdasda', + custom_attributes: { + email: 'test@test.com', + employees: 450, + key1: 'val1', + }, + industry: 'IT', + monthly_spend: 2131231, + name: 'rudderUpdate', + plan: 'basic', + remote_created_at: 1683017572, + size: 50, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + { + output: transformResultBuilder({ + userId: 'sdfrsdfsdfsf', + endpoint: 'https://api.intercom.io/users', + headers: v1Headers, + JSON: { + companies: [ + { + name: 'rudderUpdate', + company_id: 'test_company_id_wdasda', + }, + ], + user_id: 'sdfrsdfsdfsf', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-group-test-4', + name: 'intercom', + description: + 'V1 version : successful group call to create company and add user to company based on userId', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create company and add user to company payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: generateSimplifiedGroupPayload({ + userId: 'sdfrsdfsdfsf', + anonymousId: 'sdfrsdfsdfsf', + groupId: 'test_company_id_wdasda', + context: { + traits: { + email: 'testUser@test.com', + }, + }, + traits: { ...group2Traits, website: 'url' }, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: 'sdfrsdfsdfsf', + endpoint, + headers: v1Headers, + JSON: { + company_id: 'test_company_id_wdasda', + custom_attributes: { + email: 'test@test.com', + employees: 450, + key1: 'val1', + }, + industry: 'IT', + monthly_spend: 2131231, + name: 'rudderUpdate', + plan: 'basic', + remote_created_at: 1683017572, + size: 50, + website: 'url', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + { + output: transformResultBuilder({ + userId: 'sdfrsdfsdfsf', + endpoint: 'https://api.intercom.io/users', + headers: v1Headers, + JSON: { + companies: [ + { + name: 'rudderUpdate', + company_id: 'test_company_id_wdasda', + }, + ], + email: 'testUser@test.com', + user_id: 'sdfrsdfsdfsf', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-group-test-5', + name: 'intercom', + description: + 'V1 version : successful group call without userId (anonId will be considered as userId)', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create company and add user to company payload', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...v1Destination, Config: v1Destination.Config, sendAnonymousId: true }, + message: { + anonymousId: 'anonId', + groupId: 'test_company_id_wdasda', + context: { + traits: { + email: 'testUser@test.com', + }, + }, + traits: { + ...group2Traits, + website: 'url', + key1: 'val1', + key2: { + a: 'a', + b: 'b', + }, + key3: [1, 2, 3], + key4: null, + }, + type: 'group', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: 'anonId', + endpoint, + headers: v1Headers, + JSON: { + company_id: 'test_company_id_wdasda', + custom_attributes: { + email: 'test@test.com', + employees: 450, + key1: 'val1', + 'key2.a': 'a', + 'key2.b': 'b', + 'key3[0]': 1, + 'key3[1]': 2, + 'key3[2]': 3, + key4: null, + }, + industry: 'IT', + monthly_spend: 2131231, + name: 'rudderUpdate', + plan: 'basic', + remote_created_at: 1683017572, + size: 50, + website: 'url', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + { + output: transformResultBuilder({ + userId: 'anonId', + endpoint: 'https://api.intercom.io/users', + headers: v1Headers, + JSON: { + companies: [ + { + name: 'rudderUpdate', + company_id: 'test_company_id_wdasda', + }, + ], + email: 'testUser@test.com', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-group-test-6', + name: 'intercom', + description: 'V1 version : successful group call with email as custom attribute', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create company payload with email as custom attribute', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '12312312', + groupId: 'test_company_id', + context: { + traits: {}, + }, + traits: { ...group1Traits, monthlySpend: '2131231', email: 'comanyemail@abc.com' }, + type: 'group', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '12312312', + endpoint, + headers: v1Headers, + JSON: { + ...group1Traits, + custom_attributes: { + email: 'comanyemail@abc.com', + }, + monthly_spend: 2131231, + company_id: 'test_company_id', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/intercom/processor/identifyTestData.ts b/test/integrations/destinations/intercom/processor/identifyTestData.ts new file mode 100644 index 0000000000..d88b7cf7f5 --- /dev/null +++ b/test/integrations/destinations/intercom/processor/identifyTestData.ts @@ -0,0 +1,1025 @@ +import { Destination } from '../../../../../src/types'; +import { + generateMetadata, + transformResultBuilder, + generateSimplifiedIdentifyPayload, +} from '../../../testUtils'; + +const v1Config = { + apiKey: 'intercomApiKey', + apiVersion: 'v1', + appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', + collectContext: false, +}; + +const v2Config = { + apiKey: 'testApiKey', + apiVersion: 'v2', + apiServer: 'standard', + sendAnonymousId: false, +}; + +const v2Headers = { + Accept: 'application/json', + Authorization: 'Bearer testApiKey', + 'Content-Type': 'application/json', + 'Intercom-Version': '2.10', +}; + +const v1Headers = { + 'Content-Type': 'application/json', + Authorization: 'Bearer intercomApiKey', + Accept: 'application/json', + 'Intercom-Version': '1.4', +}; + +const destination: Destination = { + ID: '123', + Name: 'intercom', + DestinationDefinition: { + ID: '123', + Name: 'intercom', + DisplayName: 'Intercom', + Config: { + cdkV2Enabled: true, + }, + }, + Config: {}, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const v1Destination = { ...destination, Config: v1Config }; +const v2Destination = { ...destination, Config: v2Config }; + +const user1Traits = { + age: 23, + ownerId: '13', + firstName: 'Test', + lastName: 'Rudderlabs', + phone: '+91 9999999999', + address: 'california usa', + email: 'test@rudderlabs.com', + lastSeenAt: '2023-11-10T14:42:44.724Z', +}; + +const user2Traits = { + age: 32, + ownerId: '14', + firstName: 'Test', + lastName: 'RudderStack', + phone: '+91 9299999999', + email: 'test+2@rudderlabs.com', +}; + +const user3Traits = { + owner_id: 13, + name: 'Test Rudderlabs', + phone: '+91 9999999999', + email: 'test@rudderlabs.com', +}; + +const user4Traits = { + key1: 'value1', + name: 'Test Name', + firstName: 'Test', + lastName: 'Name', + phone: '9876543210', + userId: 'test_user_id_1', + email: 'test_1@test.com', + createdAt: '2020-09-30T19:11:00.337Z', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + address: { + city: 'Kolkata', + state: 'West Bengal', + }, + originalArray: [ + { + nested_field: 'nested value', + tags: ['tag_1', 'tag_2', 'tag_3'], + }, + { + nested_field: 'nested value', + tags: ['tag_1'], + }, + { + nested_field: 'nested value', + }, + ], +}; + +const user5Traits = { + firstName: 'Test', + lastName: 'Name', + key1: 'value1', + phone: '9876543210', + email: 'test_1@test.com', + createdAt: '2020-09-30T19:11:00.337Z', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', +}; + +const user6Traits = { + lastName: 'Name', + key1: 'value1', + phone: '9876543210', + email: 'test_1@test.com', + createdAt: '2020-09-30T19:11:00.337Z', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + company: { + key1: 'value1', + name: 'Test Comp', + id: 'company_id', + industry: 'test industry', + key2: { + a: 'a', + }, + key3: [1, 2, 3], + }, +}; + +const expectedUser1Traits = { + owner_id: 13, + external_id: 'user@1', + last_seen_at: 1699627364, + name: 'Test Rudderlabs', + phone: '+91 9999999999', + email: 'test@rudderlabs.com', + custom_attributes: { + age: 23, + address: 'california usa', + }, +}; + +const expectedUser2Traits = { + owner_id: 14, + external_id: 'user@2', + name: 'Test RudderStack', + phone: '+91 9299999999', + email: 'test+2@rudderlabs.com', + custom_attributes: { + age: 32, + }, +}; + +const expectedUser3Traits = { + owner_id: 13, + user_id: 'user@1', + name: 'Test Rudderlabs', + phone: '+91 9999999999', + email: 'test@rudderlabs.com', +}; + +const expectedUser4Traits = { + name: 'Test Name', + phone: '9876543210', + email: 'test_1@test.com', + signed_up_at: 1601493060, + user_id: 'test_user_id_1', + last_seen_user_agent: 'unknown', + custom_attributes: { + key1: 'value1', + 'address.city': 'Kolkata', + 'address.state': 'West Bengal', + 'originalArray[0].nested_field': 'nested value', + 'originalArray[0].tags[0]': 'tag_1', + 'originalArray[0].tags[1]': 'tag_2', + 'originalArray[0].tags[2]': 'tag_3', + 'originalArray[1].nested_field': 'nested value', + 'originalArray[1].tags[0]': 'tag_1', + 'originalArray[2].nested_field': 'nested value', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + }, + update_last_request_at: true, +}; + +const expectedUser5Traits = { + name: 'Test Name', + phone: '9876543210', + email: 'test_1@test.com', + signed_up_at: 1601493060, + update_last_request_at: true, + last_seen_user_agent: 'unknown', + custom_attributes: { + key1: 'value1', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + }, +}; + +const expectedUser6Traits = { + name: 'Name', + phone: '9876543210', + email: 'test_1@test.com', + signed_up_at: 1601493060, + last_seen_user_agent: 'unknown', + update_last_request_at: true, + custom_attributes: { + key1: 'value1', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + }, + companies: [ + { + name: 'Test Comp', + industry: 'test industry', + company_id: 'company_id', + custom_attributes: { + key1: 'value1', + key2: '{"a":"a"}', + key3: '[1,2,3]', + }, + }, + ], +}; + +const timestamp = '2023-11-22T10:12:44.757+05:30'; +const originalTimestamp = '2023-11-10T14:42:44.724Z'; + +const v2Endpoint = 'https://api.intercom.io/contacts'; +const v1Endpoint = 'https://api.intercom.io/users'; + +export const identifyTestData = [ + { + id: 'intercom-identify-test-1', + name: 'intercom', + description: 'V2 version : Create customer with email as lookup field', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: generateSimplifiedIdentifyPayload({ + userId: 'user@1', + context: { + traits: user1Traits, + }, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint: v2Endpoint, + headers: v2Headers, + JSON: expectedUser1Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-2', + name: 'intercom', + description: 'V2 version : Update customer with email as lookup field', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain update user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: generateSimplifiedIdentifyPayload({ + userId: 'user@2', + context: { + traits: user2Traits, + }, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint: `${v2Endpoint}/7070129940741e45d040`, + headers: v2Headers, + method: 'PUT', + JSON: expectedUser2Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-3', + name: 'intercom', + description: 'V2 version : Identify rEtl test', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + context: { + externalId: [ + { + id: 'user@1', + type: 'INTERCOM-customer', + identifierType: 'user_id', + }, + ], + mappedToDestination: 'true', + }, + traits: user3Traits, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint: v2Endpoint, + headers: v2Headers, + method: 'POST', + JSON: expectedUser3Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-4', + name: 'intercom', + description: 'V1 version : successful identify call to create user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user4Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser4Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-5', + name: 'intercom', + description: 'V1 version : successful identify call to create user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user5Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser5Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-6', + name: 'intercom', + description: 'V1 version : successful identify call to update user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain update user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: { ...user5Traits, firstName: undefined }, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { ...expectedUser5Traits, name: 'Name' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-7', + name: 'intercom', + description: 'V1 version : successful identify call to update user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain update user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: { ...user5Traits, lastName: undefined }, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { ...expectedUser5Traits, name: 'Test' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-8', + name: 'intercom', + description: 'V1 version : successful identify call to create user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user6Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser6Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-9', + name: 'intercom', + description: 'V1 version : successful identify call to create user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: { + ...user6Traits, + company: { + name: 'Test Comp', + industry: 'test industry', + key1: 'value1', + key2: null, + key3: ['value1', 'value2'], + key4: { + foo: 'bar', + }, + }, + }, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { + ...expectedUser6Traits, + companies: [ + { + ...expectedUser6Traits.companies[0], + custom_attributes: { + key1: 'value1', + key3: '["value1","value2"]', + key4: '{"foo":"bar"}', + }, + company_id: 'c0277b5c814453e5135f515f943d085a', + }, + ], + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-10', + name: 'intercom', + description: 'V1 version : successful identify call to update user', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain update user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: { + ...user5Traits, + firstName: undefined, + company: { + industry: 'test industry', + key1: 'value1', + key2: null, + }, + }, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { ...expectedUser5Traits, companies: [], name: 'Name' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-11', + name: 'intercom', + description: + 'No Version : Successful identify call to create user without giving apiVersion in configuration', + scenario: 'Business', + successCriteria: + 'Response should take v1 apiVersion by default and response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...v1Destination, apiVersion: undefined }, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user4Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser4Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-12', + name: 'intercom', + description: + 'No Version : Successful identify call to create user without giving apiVersion in configuration', + scenario: 'Business', + successCriteria: + 'Response should take v1 apiVersion by default and response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...v1Destination, apiVersion: undefined }, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user5Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser5Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-13', + name: 'intercom', + description: + 'No Version : Successful identify call to update user without giving apiVersion in configuration', + scenario: 'Business', + successCriteria: + 'Response should take v1 apiVersion by default and response status code should be 200 and response should contain update user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { ...v1Destination, apiVersion: undefined }, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: { ...user5Traits, firstName: undefined }, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { ...expectedUser5Traits, name: 'Name' }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-14', + name: 'intercom', + description: + 'V1 version : Successful identify call to update user with sendAnonymousId configuration set to true', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain update user payload with all traits and userId should be equal to anonymousId', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: user5Traits, + userAgent: 'unknown', + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: expectedUser5Traits, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-identify-test-15', + name: 'intercom', + description: 'V1 version : Identify rEtl test', + scenario: 'Business', + successCriteria: + 'Response status code should be 200 and response should contain create user payload with all traits', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + context: { + externalId: [ + { + id: '10156', + type: 'INTERCOM-customer', + identifierType: 'user_id', + }, + ], + mappedToDestination: 'true', + traits: user5Traits, + }, + type: 'identify', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint: v1Endpoint, + headers: v1Headers, + method: 'POST', + JSON: { + ...user5Traits, + user_id: '10156', + name: 'Test Name', + update_last_request_at: true, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/intercom/processor/trackTestData.ts b/test/integrations/destinations/intercom/processor/trackTestData.ts new file mode 100644 index 0000000000..15bed25d68 --- /dev/null +++ b/test/integrations/destinations/intercom/processor/trackTestData.ts @@ -0,0 +1,361 @@ +import { Destination } from '../../../../../src/types'; +import { + generateMetadata, + transformResultBuilder, + generateSimplifiedTrackPayload, +} from '../../../testUtils'; + +const v1Config = { + apiKey: 'intercomApiKey', + apiVersion: 'v1', + appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', + collectContext: false, +}; + +const v2Config = { + apiKey: 'testApiKey', + apiVersion: 'v2', + apiServer: 'standard', + sendAnonymousId: false, +}; + +const v1Headers = { + 'Content-Type': 'application/json', + Authorization: 'Bearer intercomApiKey', + Accept: 'application/json', + 'Intercom-Version': '1.4', +}; + +const v2Headers = { + Accept: 'application/json', + Authorization: 'Bearer testApiKey', + 'Content-Type': 'application/json', + 'Intercom-Version': '2.10', +}; + +const destination: Destination = { + ID: '123', + Name: 'intercom', + DestinationDefinition: { + ID: '123', + Name: 'intercom', + DisplayName: 'Intercom', + Config: { + cdkV2Enabled: true, + }, + }, + Config: {}, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const v1Destination = { ...destination, Config: v1Config }; +const v2Destination = { ...destination, Config: v2Config }; + +const userTraits = { + age: 23, + ownerId: '13', + firstName: 'Test', + lastName: 'Rudderlabs', + phone: '+91 9999999999', + address: 'california usa', + email: 'test@rudderlabs.com', + lastSeenAt: '2023-11-10T14:42:44.724Z', +}; + +const properties = { + revenue: { + amount: 1232, + currency: 'inr', + test: 123, + }, + price: { + amount: 3000, + currency: 'USD', + }, +}; + +const nestedProperties = { + property1: 1, + property2: 'test', + property3: true, + property4: '2020-10-05T09:09:03.731Z', + property5: { + property1: 1, + property2: 'test', + property3: { + subProp1: { + a: 'a', + b: 'b', + }, + subProp2: ['a', 'b'], + }, + }, + properties6: null, + revenue: { + amount: 1232, + currency: 'inr', + test: 123, + }, + price: { + amount: 3000, + currency: 'USD', + }, + article: { + url: 'https://example.org/ab1de.html', + value: 'the dude abides', + }, +}; + +const expectedNestedProperties = { + revenue: { + amount: 1232, + currency: 'inr', + test: 123, + }, + price: { + amount: 3000, + currency: 'USD', + }, + article: { + url: 'https://example.org/ab1de.html', + value: 'the dude abides', + }, + property1: 1, + property2: 'test', + property3: true, + property4: '2020-10-05T09:09:03.731Z', + 'property5.property1': 1, + 'property5.property2': 'test', + 'property5.property3.subProp1.a': 'a', + 'property5.property3.subProp1.b': 'b', + 'property5.property3.subProp2[0]': 'a', + 'property5.property3.subProp2[1]': 'b', + properties6: null, +}; + +const expectedOutput = { + user_id: 'user@2', + created: 1699627364, + event_name: 'Test Event 2', + email: 'test@rudderlabs.com', +}; + +const timestamp = '2023-11-22T10:12:44.757+05:30'; +const originalTimestamp = '2023-11-10T14:42:44.724Z'; + +const endpoint = 'https://api.intercom.io/events'; + +export const trackTestData = [ + { + id: 'intercom-track-test-1', + name: 'intercom', + description: 'V2 version : Successful track call', + scenario: 'Business', + successCriteria: + "Response status code should be 200 and response should contain event name and it's properties", + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: generateSimplifiedTrackPayload({ + userId: 'user@2', + event: 'Product Viewed', + context: { + traits: userTraits, + }, + properties, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint, + headers: v2Headers, + JSON: { + user_id: 'user@2', + metadata: properties, + created_at: 1699627364, + event_name: 'Product Viewed', + email: 'test@rudderlabs.com', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-track-test-2', + name: 'intercom', + description: 'V2 version : Track rEtl test', + scenario: 'Business', + successCriteria: + "Response status code should be 200 and response should contain event name and it's properties", + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + userId: 'user@2', + event: 'Product Viewed', + context: { + mappedToDestination: 'true', + }, + traits: { + ...properties, + user_id: 'user@1', + event_name: 'Product Viewed', + }, + type: 'track', + timestamp, + originalTimestamp, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: '', + endpoint, + headers: v2Headers, + JSON: { + ...properties, + user_id: 'user@1', + event_name: 'Product Viewed', + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-track-test-3', + name: 'intercom', + description: 'V1 version : successful track call with nested properties', + scenario: 'Business', + successCriteria: + "Response status code should be 200 and response should contain event name and it's properties", + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: generateSimplifiedTrackPayload({ + userId: 'user@2', + event: 'Test Event 2', + context: { + traits: userTraits, + }, + properties: nestedProperties, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + userId: 'default-anonymousId', + endpoint, + headers: v1Headers, + JSON: { + ...expectedOutput, + metadata: { + ...expectedNestedProperties, + }, + }, + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-track-test-4', + name: 'intercom', + description: 'V1 version : successful track call without properties', + scenario: 'Business', + successCriteria: 'Response status code should be 200 and response should contain event name', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: generateSimplifiedTrackPayload({ + userId: 'user@2', + event: 'Test Event 2', + context: { + traits: userTraits, + }, + timestamp, + originalTimestamp, + }), + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: transformResultBuilder({ + endpoint, + headers: v1Headers, + JSON: expectedOutput, + userId: 'default-anonymousId', + }), + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/intercom/processor/validationTestData.ts b/test/integrations/destinations/intercom/processor/validationTestData.ts new file mode 100644 index 0000000000..45fe3c1b9e --- /dev/null +++ b/test/integrations/destinations/intercom/processor/validationTestData.ts @@ -0,0 +1,554 @@ +import { Destination } from '../../../../../src/types'; +import { ProcessorTestData } from '../../../testTypes'; +import { generateMetadata } from '../../../testUtils'; + +const v1Config = { + apiKey: 'intercomApiKey', + apiVersion: 'v1', + appId: '9e9cdea1-78fa-4829-a9b2-5d7f7e96d1a0', + collectContext: false, +}; + +const v2Config = { + apiKey: 'testApiKey', + apiVersion: 'v2', + apiServer: 'standard', + sendAnonymousId: false, +}; + +const destination: Destination = { + ID: '123', + Name: 'intercom', + DestinationDefinition: { + ID: '123', + Name: 'intercom', + DisplayName: 'Intercom', + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + apiKey: 'testApiKey', + apiVersion: 'v2', + apiServer: 'standard', + sendAnonymousId: false, + }, + Enabled: true, + WorkspaceID: '123', + Transformations: [], +}; + +const v1Destination = { ...destination, Config: v1Config }; +const v2Destination = { ...destination, Config: v2Config }; + +const userTraits = { + age: 23, + ownerId: '14', + role: 'user', + source: 'rudder-sdk', + firstname: 'Test', + lastName: 'RudderStack', + phone: '+91 9299999999', + birthday: '2022-05-13T12:51:01.470Z', +}; + +const properties = { + revenue: { + amount: 1232, + currency: 'inr', + test: 123, + }, + price: { + amount: 3000, + currency: 'USD', + }, +}; + +const groupTraits = { + name: 'RudderStack', + size: 500, + website: 'www.rudderstack.com', + industry: 'CDP', + plan: 'enterprise', +}; + +const expectedStatTags = { + destType: 'INTERCOM', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', +}; + +export const validationTestData: ProcessorTestData[] = [ + { + id: 'intercom-validation-test-1', + name: 'intercom', + description: '[Error - V2 version]: Check for no message type', + scenario: 'Framework', + successCriteria: 'Response status code should be 400 with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + event: 'Product Searched', + context: { + traits: userTraits, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'message Type is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: message Type is not present. Aborting', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-2', + name: 'intercom', + description: '[Error - V2 version]: Check for unsupported message type', + scenario: 'Framework', + successCriteria: + 'Response should contain error message and status code should be 400, as we are sending a message type which is not supported by intercom destination and the error message should be Event type alias is not supported', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + userId: 'user@45', + type: 'page', + context: { + traits: userTraits, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'message type page is not supported: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: message type page is not supported', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-3', + name: 'intercom', + description: '[Error - V2 version]: Missing required config', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw configuration error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + ...v2Destination, + Config: { ...v2Destination.Config, apiKey: null }, + }, + message: { + userId: 'user@1', + type: 'identify', + context: { + traits: userTraits, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Access Token is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Access Token is not present. Aborting', + statTags: { ...expectedStatTags, errorType: 'configuration' }, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-4', + name: 'intercom', + description: '[Error - V2 version]: Missing required parameters for an identify call', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + anonymousId: 'anon@2', + type: 'identify', + context: { + traits: userTraits, + }, + integrations: { + INTERCOM: { + lookup: 'phone', + }, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Either email or userId is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForLatestVersion, ChildStep: undefined, OriginalError: Either email or userId is required for Identify call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-5', + name: 'intercom', + description: '[Error - V2 version]: Missing required parameters for an identify call', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + anonymousId: 'anon@2', + type: 'identify', + context: { + traits: userTraits, + }, + integrations: { + INTERCOM: { + lookup: 'phone', + }, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Either email or userId is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForLatestVersion, ChildStep: undefined, OriginalError: Either email or userId is required for Identify call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-6', + name: 'intercom', + description: + '[Error - V2 version]: Unauthorized error while searching contact for an identify call', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw network error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + ...v2Destination, + Config: { ...v2Destination.Config, apiKey: 'invalidApiKey' }, + }, + message: { + userId: 'user@3', + type: 'identify', + context: { + traits: { + phone: '+91 9399999999', + email: 'test+3@rudderlabs.com', + firstName: 'Test', + lastName: 'Rudder', + ownerId: '15', + role: 'admin', + source: 'rudder-android-sdk', + }, + }, + integrations: { + INTERCOM: { + lookup: 'email', + }, + }, + timestamp: '2020-01-21T00:21:34.208Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + '{"message":"{\\"message\\":\\"Unable to search contact due to : [{\\\\\\"code\\\\\\":\\\\\\"unauthorized\\\\\\",\\\\\\"message\\\\\\":\\\\\\"Access Token Invalid\\\\\\"}]: Workflow: procWorkflow, Step: searchContact, ChildStep: undefined, OriginalError: Unable to search contact due to : [{\\\\\\"code\\\\\\":\\\\\\"unauthorized\\\\\\",\\\\\\"message\\\\\\":\\\\\\"Access Token Invalid\\\\\\"}]\\",\\"destinationResponse\\":{\\"response\\":{\\"type\\":\\"error.list\\",\\"request_id\\":\\"request_1\\",\\"errors\\":[{\\"code\\":\\"unauthorized\\",\\"message\\":\\"Access Token Invalid\\"}]},\\"status\\":401}}","destinationResponse":{"response":{"type":"error.list","request_id":"request_1","errors":[{"code":"unauthorized","message":"Access Token Invalid"}]},"status":401}}', + statTags: { ...expectedStatTags, errorCategory: 'network', errorType: 'aborted' }, + statusCode: 401, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-7', + name: 'intercom', + description: '[Error - V2 version]: Track call without event name', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + userId: 'user@3', + type: 'track', + context: { + traits: userTraits, + }, + properties, + timestamp: '2023-11-22T10:12:44.757+05:30', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Event name is required for track call: Workflow: procWorkflow, Step: trackPayload, ChildStep: undefined, OriginalError: Event name is required for track call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-8', + name: 'intercom', + description: '[Error - V2 version]: Group call without groupId', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v2Destination, + message: { + userId: 'user@4', + type: 'group', + context: { + traits: { + email: 'test+4@rudderlabs.com', + phone: '+91 9499999999', + firstName: 'John', + lastName: 'Doe', + ownerId: '16', + }, + }, + traits: groupTraits, + timestamp: '2023-11-22T10:12:44.757+05:30', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'groupId is required for group call: Workflow: procWorkflow, Step: groupPayloadForLatestVersion, ChildStep: validateMessageAndPreparePayload, OriginalError: groupId is required for group call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-9', + name: 'intercom', + description: '[Error - V1 version]: Identify call without email and userId', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + type: 'identify', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: userTraits, + }, + timestamp: '2023-11-22T10:12:44.757+05:30', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Either of `email` or `userId` is required for Identify call: Workflow: procWorkflow, Step: identifyPayloadForOlderVersion, ChildStep: undefined, OriginalError: Either of `email` or `userId` is required for Identify call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'intercom-validation-test-10', + name: 'intercom', + description: '[Error - V1 version]: Track call without email or userId', + scenario: 'Framework', + successCriteria: + 'Response status code should be 400 and it should throw instrumentation error with respective error message', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: v1Destination, + message: { + type: 'track', + anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33', + context: { + traits: userTraits, + }, + event: 'Test Event 2', + timestamp: '2023-11-22T10:12:44.757+05:30', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Either email or userId is required for Track call: Workflow: procWorkflow, Step: trackPayload, ChildStep: undefined, OriginalError: Either email or userId is required for Track call', + statTags: expectedStatTags, + statusCode: 400, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +];