From 1a3a8993eb4422a5e79c18131043fb28926e482c Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Mon, 25 Sep 2023 12:18:34 +0530 Subject: [PATCH] feat: move optimizely fullstack processor tests - 1 --- test/__tests__/data/optimizely_fullstack.json | 448 ---------- .../optimizely_fullstack/network.ts | 71 +- .../optimizely_fullstack/processor/data.ts | 821 ++++++++++++++++++ 3 files changed, 889 insertions(+), 451 deletions(-) create mode 100644 test/integrations/destinations/optimizely_fullstack/processor/data.ts diff --git a/test/__tests__/data/optimizely_fullstack.json b/test/__tests__/data/optimizely_fullstack.json index 1331d38033..30f494efd0 100644 --- a/test/__tests__/data/optimizely_fullstack.json +++ b/test/__tests__/data/optimizely_fullstack.json @@ -1,452 +1,4 @@ [ - { - "description": "Missing Data File URL", - "input": { - "message": { - "type": "identify", - "channel": "web", - "properties": {}, - "context": {}, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35", - "integrations": { - "All": true - } - }, - "destination": { - "Config": { - "accountId": "test_account_id", - "campaignId": "test_campaign_id", - "experimentId": "test_experiment_id" - } - } - }, - "output": { - "error": "Data File Url is not present. Aborting" - } - }, - { - "description": "Identify call: Missing Variation ID in integration object", - "input": { - "message": { - "type": "identify", - "channel": "web", - "properties": {}, - "context": {}, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35", - "integrations": { - "All": true - } - }, - "destination": { - "Config": { - "dataFileUrl": "https://cdn.optimizely.com/datafiles/abc.json", - "accountId": "test_account_id", - "campaignId": "test_campagin_id", - "experimentId": "test_experiment_id" - } - } - }, - "output": { - "error": "Variation ID is not present in the integrations object" - } - }, - { - "description": "Missing Account ID", - "input": { - "message": { - "type": "identify", - "channel": "web", - "properties": {}, - "context": {}, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35", - "integrations": { - "All": true - } - }, - "destination": { - "Config": { - "dataFileUrl": "https://cdn.optimizely.com/datafiles/abc.json", - "campaignId": "test_campagin_id", - "experimentId": "test_experiment_id" - } - } - }, - "output": { - "error": "Account ID is not present. Aborting" - } - }, - { - "description": "Missing Campaign ID", - "input": { - "message": { - "type": "identify", - "channel": "web", - "properties": {}, - "context": {}, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35", - "integrations": { - "All": true - } - }, - "destination": { - "Config": { - "dataFileUrl": "https://cdn.optimizely.com/datafiles/abc.json", - "accountId": "test_account_id", - "experimentId": "test_experiment_id" - } - } - }, - "output": { - "error": "Campaign ID is not present. Aborting" - } - }, - { - "description": "Missing Experiment ID", - "input": { - "message": { - "type": "identify", - "channel": "web", - "properties": {}, - "context": {}, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35", - "integrations": { - "All": true - } - }, - "destination": { - "Config": { - "dataFileUrl": "https://cdn.optimizely.com/datafiles/abc.json", - "accountId": "test_account_id", - "campaignId": "test_campagin_id" - } - } - }, - "output": { - "error": "Experiment ID is not present. Aborting" - } - }, - { - "description": "Page: Track Categorized Page and Track Named Pages toggle are disabled", - "input": { - "message": { - "type": "page", - "channel": "web", - "name": "Home", - "properties": {}, - "context": {}, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35", - "integrations": { - "All": true, - "optimizely_fullstack": { - "variationId": "123" - } - } - }, - "destination": { - "Config": { - "dataFileUrl": "https://cdn.optimizely.com/datafiles/abc.json", - "accountId": "test_account_id", - "campaignId": "test_campagin_id", - "experimentId": "test_experiment_id", - "trackCategorizedPages": false, - "trackNamedPages": false - } - } - }, - "output": { - "error": "Both 'Track Categorized Pages' and 'Track Named Pages' toggles are disabled in webapp. Please enable at one of them to send page/screen events to Optimizely." - } - }, - { - "description": "Invalid Configuration (Track known users toggle is on and userId is missing in request)", - "input": { - "message": { - "type": "track", - "channel": "web", - "event": "Product Added", - "properties": { - "price": 999, - "quantity": 1 - }, - "context": { - "traits": { - "firstName": "John", - "age": 27 - } - }, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35", - "optimizely_fullstack": { - "variationId": "123" - } - }, - "destination": { - "Config": { - "dataFileUrl": "https://cdn.optimizely.com/datafiles/abc.json", - "accountId": "test_account_id", - "campaignId": "test_campagin_id", - "experimentId": "test_experiment_id", - "trackCategorizedPages": false, - "trackNamedPages": false, - "trackKnownUsers": true - } - } - }, - "output": { - "error": "UserId is required for event tracking when the 'Track Known Users' setting is enabled. Please include a 'userId' in your event payload" - } - }, - { - "description": "Invalid Configuration (Track known users toggle is off and anonymousId is missing in request)", - "input": { - "message": { - "type": "track", - "channel": "web", - "event": "Product Added", - "properties": { - "price": 999, - "quantity": 1 - }, - "context": { - "traits": { - "firstName": "John", - "age": 27 - } - }, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "integrations": { - "All": true, - "optimizely_fullstack": { - "variationId": "123" - } - } - }, - "destination": { - "Config": { - "dataFileUrl": "https://cdn.optimizely.com/datafiles/abc.json", - "accountId": "test_account_id", - "campaignId": "test_campagin_id", - "experimentId": "test_experiment_id" - } - } - }, - "output": { - "error": "AnonymousId is required when 'Track Known Users' setting is disabled" - } - }, - { - "description": "Track call without event", - "input": { - "message": { - "type": "track", - "channel": "web", - "properties": {}, - "context": {}, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35" - }, - "destination": { - "Config": { - "dataFileUrl": "https://cdn.optimizely.com/datafiles/abc.json", - "accountId": "test_account_id", - "campaignId": "test_campagin_id", - "experimentId": "test_experiment_id" - } - } - }, - "output": { - "error": "Event is not present. Aborting." - } - }, - { - "description": "Invalid data file url", - "input": { - "message": { - "type": "track", - "event": "Product Added", - "channel": "web", - "properties": {}, - "context": {}, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35" - }, - "destination": { - "Config": { - "dataFileUrl": "https://cdn.optimizely.com/datafiles/wrong_cdn.json", - "accountId": "test_account_id", - "campaignId": "test_campagin_id", - "experimentId": "test_experiment_id" - } - } - }, - "output": { - "error": "Data File Lookup Failed due to {\"code\":\"document_not_found\",\"message\":\"document_not_found\"}" - } - }, - { - "description": "Invalid data file url", - "input": { - "message": { - "type": "track", - "event": "Product Added", - "channel": "web", - "properties": {}, - "context": {}, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35", - "integrations": { - "All": true, - "optimizely_fullstack": { - "variationId": "123" - } - } - }, - "destination": { - "Config": { - "dataFileUrl": "https://cdn.optimizely.com/datafiles/abc.json", - "accountId": "test_account_id", - "campaignId": "test_campagin_id", - "experimentId": "test_experiment_id", - "eventMapping": [ - { - "from": "Product Added", - "to": "product_added" - } - ] - } - } - }, - "output": { - "error": "Event 'product_added' is not present in data file. Make sure event exists in Optimizely." - } - }, - { - "description": "Identify call (Decision Event) with userId", - "input": { - "message": { - "type": "identify", - "channel": "web", - "properties": {}, - "context": { - "traits": { - "organization": "RudderStack", - "fullName": "John Doe", - "country": "US" - }, - "sessionId": 1685626914716 - }, - "rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f", - "messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff", - "anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35", - "timestamp": "2023-02-10T12:16:07.251Z", - "userId": "userId123", - "integrations": { - "All": true, - "optimizely_fullstack": { - "variationId": "test_variation_id_1" - } - } - }, - "destination": { - "Config": { - "dataFileUrl": "https://cdn.optimizely.com/datafiles/abc.json", - "accountId": "test_account_id", - "campaignId": "test_campaign_id", - "experimentId": "test_experiment_id", - "trackKnownUsers": true, - "attributeMapping": [ - { - "from": "organization", - "to": "company" - }, - { - "from": "fullName", - "to": "name" - } - ] - } - } - }, - "output": { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://logx.optimizely.com/v1/events", - "headers": { - "Content-Type": "application/json" - }, - "params": {}, - "body": { - "JSON": { - "account_id": "test_account_id", - "anonymize_ip": false, - "enrich_decisions": true, - "client_name": "RudderStack", - "client_version": "1.0.0", - "visitors": [ - { - "visitor_id": "userId123", - "attributes": [ - { - "entity_id": "test_attribute_id_5", - "key": "company", - "type": "custom", - "value": "RudderStack" - }, - { - "entity_id": "test_attribute_id_2", - "key": "name", - "type": "custom", - "value": "John Doe" - } - ], - "snapshots": [ - { - "decisions": [ - { - "campaign_id": "test_campaign_id", - "experiment_id": "test_experiment_id", - "variation_id": "test_variation_id_1" - } - ], - "events": [ - { - "entity_id": "test_campaign_id", - "type": "campaign_activated", - "timestamp": 1676031367251, - "uuid": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff" - } - ] - } - ], - "session_id": "1685626914716" - } - ] - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - }, { "description": "Identify call (Decision Event) with anonymousId", "input": { diff --git a/test/integrations/destinations/optimizely_fullstack/network.ts b/test/integrations/destinations/optimizely_fullstack/network.ts index 509663fb05..5489b8b4cd 100644 --- a/test/integrations/destinations/optimizely_fullstack/network.ts +++ b/test/integrations/destinations/optimizely_fullstack/network.ts @@ -56,9 +56,6 @@ const deleteNwData = [ }, }, url: 'https://cdn.optimizely.com/datafiles/abc.json', - // headers: { - // Accept: 'application/json, text/plain, */*', - // }, maxContentLength: 100000000, }, httpRes: { @@ -245,5 +242,73 @@ const deleteNwData = [ }, }, }, + { + httpReq: { + method: 'get', + timeout: 60000, + withCredentials: false, + responseType: 'json', + responseEncoding: 'utf8', + maxBodyLength: 100000000, + maxRedirects: 5, + httpAgent: { + _events: {}, + _eventsCount: 2, + defaultPort: 80, + protocol: 'http:', + options: { + keepAlive: true, + noDelay: true, + path: null, + }, + requests: {}, + sockets: {}, + freeSockets: {}, + keepAliveMsecs: 1000, + keepAlive: true, + maxSockets: null, + maxFreeSockets: 256, + scheduling: 'lifo', + maxTotalSockets: null, + totalSocketCount: 0, + }, + httpsAgent: { + _events: {}, + _eventsCount: 2, + defaultPort: 443, + protocol: 'https:', + options: { + keepAlive: true, + noDelay: true, + path: null, + }, + requests: {}, + sockets: {}, + freeSockets: {}, + keepAliveMsecs: 1000, + keepAlive: true, + maxSockets: null, + maxFreeSockets: 256, + scheduling: 'lifo', + maxTotalSockets: null, + totalSocketCount: 0, + maxCachedSessions: 100, + _sessionCache: { + map: {}, + list: [], + }, + }, + url: 'https://cdn.optimizely.com/datafiles/wrong_cdn.json', + maxContentLength: 100000000, + }, + httpRes: { + status: 404, + statusText: 'Not Found', + data: { + code: 'document_not_found', + message: 'document_not_found', + }, + }, + }, ]; export const networkCallsData = [...deleteNwData]; diff --git a/test/integrations/destinations/optimizely_fullstack/processor/data.ts b/test/integrations/destinations/optimizely_fullstack/processor/data.ts new file mode 100644 index 0000000000..33f018249f --- /dev/null +++ b/test/integrations/destinations/optimizely_fullstack/processor/data.ts @@ -0,0 +1,821 @@ +export const data = [ + { + name: 'optimizely_fullstack', + description: 'Missing Data File URL', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + channel: 'web', + properties: {}, + context: {}, + rudderId: '8f8fa6b5-8e24-489c-8e22-61f23f2e364f', + messageId: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + anonymousId: '97c46c81-3140-456d-b2a9-690d70aaca35', + integrations: { + All: true, + }, + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + accountId: 'test_account_id', + campaignId: 'test_campaign_id', + experimentId: 'test_experiment_id', + }, + }, + metadata: { + jobId: 1, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Data File Url is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Data File Url is not present. Aborting', + statTags: { + destType: 'OPTIMIZELY_FULLSTACK', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + statusCode: 400, + metadata: { + jobId: 1, + }, + }, + ], + }, + }, + }, + { + name: 'optimizely_fullstack', + description: 'Identify call: Missing Variation ID in integration object', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + channel: 'web', + properties: {}, + context: {}, + rudderId: '8f8fa6b5-8e24-489c-8e22-61f23f2e364f', + messageId: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + anonymousId: '97c46c81-3140-456d-b2a9-690d70aaca35', + integrations: { + All: true, + }, + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + dataFileUrl: 'https://cdn.optimizely.com/datafiles/abc.json', + accountId: 'test_account_id', + campaignId: 'test_campagin_id', + experimentId: 'test_experiment_id', + }, + }, + metadata: { + jobId: 2, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Variation ID is not present in the integrations object: Workflow: procWorkflow, Step: validateInputForIdentify, ChildStep: undefined, OriginalError: Variation ID is not present in the integrations object', + statTags: { + destType: 'OPTIMIZELY_FULLSTACK', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + statusCode: 400, + metadata: { + jobId: 2, + }, + }, + ], + }, + }, + }, + { + name: 'optimizely_fullstack', + description: 'Missing Account ID', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + channel: 'web', + properties: {}, + context: {}, + rudderId: '8f8fa6b5-8e24-489c-8e22-61f23f2e364f', + messageId: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + anonymousId: '97c46c81-3140-456d-b2a9-690d70aaca35', + integrations: { + All: true, + }, + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + dataFileUrl: 'https://cdn.optimizely.com/datafiles/abc.json', + campaignId: 'test_campagin_id', + experimentId: 'test_experiment_id', + }, + }, + metadata: { + jobId: 3, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Account ID is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Account ID is not present. Aborting', + statTags: { + destType: 'OPTIMIZELY_FULLSTACK', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + statusCode: 400, + metadata: { + jobId: 3, + }, + }, + ], + }, + }, + }, + { + name: 'optimizely_fullstack', + description: 'Missing Campaign ID', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + channel: 'web', + properties: {}, + context: {}, + rudderId: '8f8fa6b5-8e24-489c-8e22-61f23f2e364f', + messageId: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + anonymousId: '97c46c81-3140-456d-b2a9-690d70aaca35', + integrations: { + All: true, + }, + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + dataFileUrl: 'https://cdn.optimizely.com/datafiles/abc.json', + accountId: 'test_account_id', + experimentId: 'test_experiment_id', + }, + }, + metadata: { + jobId: 4, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Campaign ID is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Campaign ID is not present. Aborting', + statTags: { + destType: 'OPTIMIZELY_FULLSTACK', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + statusCode: 400, + metadata: { + jobId: 4, + }, + }, + ], + }, + }, + }, + { + name: 'optimizely_fullstack', + description: 'Missing Experiment ID', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + channel: 'web', + properties: {}, + context: {}, + rudderId: '8f8fa6b5-8e24-489c-8e22-61f23f2e364f', + messageId: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + anonymousId: '97c46c81-3140-456d-b2a9-690d70aaca35', + integrations: { + All: true, + }, + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + dataFileUrl: 'https://cdn.optimizely.com/datafiles/abc.json', + accountId: 'test_account_id', + campaignId: 'test_campagin_id', + }, + }, + metadata: { + jobId: 5, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Experiment ID is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Experiment ID is not present. Aborting', + statTags: { + destType: 'OPTIMIZELY_FULLSTACK', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + statusCode: 400, + metadata: { + jobId: 5, + }, + }, + ], + }, + }, + }, + { + name: 'optimizely_fullstack', + description: 'Page: Track Categorized Page and Track Named Pages toggle are disabled', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'page', + channel: 'web', + name: 'Home', + properties: {}, + context: {}, + rudderId: '8f8fa6b5-8e24-489c-8e22-61f23f2e364f', + messageId: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + anonymousId: '97c46c81-3140-456d-b2a9-690d70aaca35', + integrations: { + All: true, + optimizely_fullstack: { + variationId: '123', + }, + }, + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + dataFileUrl: 'https://cdn.optimizely.com/datafiles/abc.json', + accountId: 'test_account_id', + campaignId: 'test_campagin_id', + experimentId: 'test_experiment_id', + trackCategorizedPages: false, + trackNamedPages: false, + }, + }, + metadata: { + jobId: 6, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + "Both 'Track Categorized Pages' and 'Track Named Pages' toggles are disabled in webapp. Please enable at one of them to send page/screen events to Optimizely.: Workflow: procWorkflow, Step: validateInputForPageAndScreen, ChildStep: undefined, OriginalError: Both 'Track Categorized Pages' and 'Track Named Pages' toggles are disabled in webapp. Please enable at one of them to send page/screen events to Optimizely.", + statTags: { + destType: 'OPTIMIZELY_FULLSTACK', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + statusCode: 400, + metadata: { + jobId: 6, + }, + }, + ], + }, + }, + }, + { + name: 'optimizely_fullstack', + description: + 'Invalid Configuration (Track known users toggle is on and userId is missing in request)', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + channel: 'web', + event: 'Product Added', + properties: { + price: 999, + quantity: 1, + }, + context: { + traits: { + firstName: 'John', + age: 27, + }, + }, + rudderId: '8f8fa6b5-8e24-489c-8e22-61f23f2e364f', + messageId: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + anonymousId: '97c46c81-3140-456d-b2a9-690d70aaca35', + optimizely_fullstack: { + variationId: '123', + }, + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + dataFileUrl: 'https://cdn.optimizely.com/datafiles/abc.json', + accountId: 'test_account_id', + campaignId: 'test_campagin_id', + experimentId: 'test_experiment_id', + trackCategorizedPages: false, + trackNamedPages: false, + trackKnownUsers: true, + }, + }, + metadata: { + jobId: 7, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + "UserId is required for event tracking when the 'Track Known Users' setting is enabled. Please include a 'userId' in your event payload: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: UserId is required for event tracking when the 'Track Known Users' setting is enabled. Please include a 'userId' in your event payload", + statTags: { + destType: 'OPTIMIZELY_FULLSTACK', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + statusCode: 400, + metadata: { + jobId: 7, + }, + }, + ], + }, + }, + }, + { + name: 'optimizely_fullstack', + description: 'Track call without event', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + channel: 'web', + properties: {}, + context: {}, + rudderId: '8f8fa6b5-8e24-489c-8e22-61f23f2e364f', + messageId: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + anonymousId: '97c46c81-3140-456d-b2a9-690d70aaca35', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + dataFileUrl: 'https://cdn.optimizely.com/datafiles/abc.json', + accountId: 'test_account_id', + campaignId: 'test_campagin_id', + experimentId: 'test_experiment_id', + }, + }, + metadata: { + jobId: 9, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Event is not present. Aborting.: Workflow: procWorkflow, Step: validateInputForTrack, ChildStep: undefined, OriginalError: Event is not present. Aborting.', + statTags: { + destType: 'OPTIMIZELY_FULLSTACK', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + statusCode: 400, + metadata: { + jobId: 9, + }, + }, + ], + }, + }, + }, + { + name: 'optimizely_fullstack', + description: 'Invalid data file url', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'Product Added', + channel: 'web', + properties: {}, + context: {}, + rudderId: '8f8fa6b5-8e24-489c-8e22-61f23f2e364f', + messageId: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + anonymousId: '97c46c81-3140-456d-b2a9-690d70aaca35', + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + dataFileUrl: 'https://cdn.optimizely.com/datafiles/wrong_cdn.json', + accountId: 'test_account_id', + campaignId: 'test_campagin_id', + experimentId: 'test_experiment_id', + }, + }, + metadata: { + jobId: 10, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Data File Lookup Failed due to {"code":"document_not_found","message":"document_not_found"}: Workflow: procWorkflow, Step: dataFile, ChildStep: undefined, OriginalError: Data File Lookup Failed due to {"code":"document_not_found","message":"document_not_found"}', + statTags: { + destType: 'OPTIMIZELY_FULLSTACK', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + statusCode: 400, + metadata: { + jobId: 10, + }, + }, + ], + }, + }, + }, + { + name: 'optimizely_fullstack', + description: 'Event not present in data-file', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'track', + event: 'Product Added', + channel: 'web', + properties: {}, + context: {}, + rudderId: '8f8fa6b5-8e24-489c-8e22-61f23f2e364f', + messageId: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + anonymousId: '97c46c81-3140-456d-b2a9-690d70aaca35', + integrations: { + All: true, + optimizely_fullstack: { + variationId: '123', + }, + }, + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + dataFileUrl: 'https://cdn.optimizely.com/datafiles/abc.json', + accountId: 'test_account_id', + campaignId: 'test_campagin_id', + experimentId: 'test_experiment_id', + eventMapping: [ + { + from: 'Product Added', + to: 'product_added', + }, + ], + }, + }, + metadata: { + jobId: 11, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + "Event 'product_added' is not present in data file. Make sure event exists in Optimizely.: Workflow: procWorkflow, Step: prepareTrackPayload, ChildStep: optimizelyEvent, OriginalError: Event 'product_added' is not present in data file. Make sure event exists in Optimizely.", + statTags: { + destType: 'OPTIMIZELY_FULLSTACK', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + statusCode: 400, + metadata: { + jobId: 11, + }, + }, + ], + }, + }, + }, + { + name: 'optimizely_fullstack', + description: 'Identify call (Decision Event) with userId', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + message: { + type: 'identify', + channel: 'web', + properties: {}, + context: { + traits: { + organization: 'RudderStack', + fullName: 'John Doe', + country: 'US', + }, + sessionId: 1685626914716, + }, + rudderId: '8f8fa6b5-8e24-489c-8e22-61f23f2e364f', + messageId: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + anonymousId: '97c46c81-3140-456d-b2a9-690d70aaca35', + timestamp: '2023-02-10T12:16:07.251Z', + userId: 'userId123', + integrations: { + All: true, + optimizely_fullstack: { + variationId: 'test_variation_id_1', + }, + }, + }, + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + Config: { + dataFileUrl: 'https://cdn.optimizely.com/datafiles/abc.json', + accountId: 'test_account_id', + campaignId: 'test_campaign_id', + experimentId: 'test_experiment_id', + trackKnownUsers: true, + attributeMapping: [ + { + from: 'organization', + to: 'company', + }, + { + from: 'fullName', + to: 'name', + }, + ], + }, + }, + metadata: { + jobId: 12, + }, + }, + ], + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: [ + { + metadata: { jobId: 12 }, + output: { + body: { + FORM: {}, + JSON: { + account_id: 'test_account_id', + anonymize_ip: false, + client_name: 'RudderStack', + client_version: '1.0.0', + enrich_decisions: true, + visitors: [ + { + attributes: [ + { + entity_id: 'test_attribute_id_5', + key: 'company', + type: 'custom', + value: 'RudderStack', + }, + { + entity_id: 'test_attribute_id_2', + key: 'name', + type: 'custom', + value: 'John Doe', + }, + ], + session_id: '1685626914716', + snapshots: [ + { + decisions: [ + { + campaign_id: 'test_campaign_id', + experiment_id: 'test_experiment_id', + variation_id: 'test_variation_id_1', + }, + ], + events: [ + { + entity_id: 'test_campaign_id', + timestamp: 1676031367251, + type: 'campaign_activated', + uuid: '2116ef8c-efc3-4ca4-851b-02ee60dad6ff', + }, + ], + }, + ], + visitor_id: 'userId123', + }, + ], + }, + JSON_ARRAY: {}, + XML: {}, + }, + endpoint: 'https://logx.optimizely.com/v1/events', + files: {}, + headers: { 'Content-Type': 'application/json' }, + method: 'POST', + params: {}, + type: 'REST', + userId: '', + version: '1', + }, + statusCode: 200, + }, + ], + }, + }, + }, +];