diff --git a/src/cdk/v2/destinations/ortto/procWorkflow.yaml b/src/cdk/v2/destinations/ortto/procWorkflow.yaml index 5d0baa7172..98f6e33461 100644 --- a/src/cdk/v2/destinations/ortto/procWorkflow.yaml +++ b/src/cdk/v2/destinations/ortto/procWorkflow.yaml @@ -84,7 +84,7 @@ steps: customEvent = event === .rsEventName ? .orttoEventName : null; ) $.assert(customEvent, "Event names is not mapped"); - customEvent = "act:cm:"+customEvent.trim().toLowerCase().replace(new RegExp('\\s+', 'g'),'-'); + "act:cm:"+customEvent.trim().toLowerCase().replace(new RegExp('\\s+', 'g'),'-'); - name: getAttributes template: | @@ -101,8 +101,8 @@ steps: "activity_id": $.outputs.prepareTrackPayload.getTrimmedEvent, "attributes": $.outputs.prepareTrackPayload.getAttributes, "location": {"source_ip": .message.context.ip} - } - const trackPayoad = { + }; + { "activities":[activityObj], "merge_by": ["str::ei", "str::email"] } @@ -122,4 +122,4 @@ steps: "X-Api-Key": .destination.Config.privateApiKey, "Content-Type": "application/json" }; - finalResponse = response; + response; diff --git a/src/cdk/v2/destinations/ortto/rtWorkflow.yaml b/src/cdk/v2/destinations/ortto/rtWorkflow.yaml index ca351f09b1..78e25cc8ea 100644 --- a/src/cdk/v2/destinations/ortto/rtWorkflow.yaml +++ b/src/cdk/v2/destinations/ortto/rtWorkflow.yaml @@ -16,8 +16,8 @@ steps: loopOverInput: true - name: successfulEvents template: | - $.outputs.transform#idx{ "output" in .}.({ - "message": .output[], + $.outputs.transform#idx.output.({ + "message": .[], "destination": ^ [idx].destination, "metadata": ^ [idx].metadata })[] @@ -34,12 +34,14 @@ steps: - name: batchSuccessfulEvents description: Batches the successfulEvents using V3 API + condition: $.outputs.successfulEvents.length template: | let batches = $.batchEvents($.outputs.successfulEvents); + console.log("abc",JSON.stringify(batches,null,2)) batches@batch.({ "batchedRequest": { "body": { - "JSON": ~r batch.message, + "JSON": batch.message, "JSON_ARRAY": {}, "XML": {}, "FORM": {} @@ -55,11 +57,14 @@ steps: "params": {}, "files": {} }, - "metadata": ~r batch.metadata, + "metadata": batch.metadata, "batched": true, "statusCode": 200, - "destination": ~r batch.destination + "destination": batch.destination })[]; + else: + name: returnEmptyOuput + template: '[]' - name: finalPayload template: | diff --git a/src/cdk/v2/destinations/ortto/utils.js b/src/cdk/v2/destinations/ortto/utils.js index 2c8a28deaa..f26e1fd32c 100644 --- a/src/cdk/v2/destinations/ortto/utils.js +++ b/src/cdk/v2/destinations/ortto/utils.js @@ -27,7 +27,7 @@ const groupEventsByEndpoint = (events) => { const { destination, metadata } = result; const message = CommonUtils.toArray(result.message); message.forEach((msg) => { - const endpoint = Object.keys(eventMap).find((key) => msg.endpoint.includes(key)); + const endpoint = Object.keys(eventMap).find((key) => msg.endpoint?.includes(key)); if (endpoint) { eventMap[endpoint].push({ message: msg.body.JSON, destination, metadata }); } diff --git a/src/features.json b/src/features.json index 9784f03e44..7de214ab39 100644 --- a/src/features.json +++ b/src/features.json @@ -57,6 +57,7 @@ "BRAZE": true, "OPTIMIZELY_FULLSTACK": true, "TWITTER_ADS": true, - "CLEVERTAP": true + "CLEVERTAP": true, + "ORTTO": true } } diff --git a/test/integrations/destinations/ortto/processor/data.ts b/test/integrations/destinations/ortto/processor/data.ts index d8f0bd0d11..e37e976a12 100644 --- a/test/integrations/destinations/ortto/processor/data.ts +++ b/test/integrations/destinations/ortto/processor/data.ts @@ -206,6 +206,651 @@ export const data = [ }, }, }, + { + name: 'ortto', + description: 'Unsupported messageType group', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + ID: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', + Name: 'ORTTO', + Config: { + privateApiKey: 'dummyApiKey', + instanceRegion: 'other', + orttoEventsMapping: [ + { + rsEventName: 'RudderEvent', + orttoEventName: 'Ortto Event', + eventProperties: [ + { + rudderProperty: 'RudderProp', + orttoProperty: 'OrttoProp', + type: 'text', + }, + { + rudderProperty: 'RudderProp', + orttoProperty: 'OrttoProp', + type: 'longText', + }, + ], + }, + ], + orttoPersonAttributes: [ + { + rudderTraits: 'ruddertrait0', + orttoAttribute: 'ortto attirbute0', + type: 'email', + }, + { + rudderTraits: 'ruddertrait1', + orttoAttribute: 'ortto attirbute1', + type: 'email', + }, + ], + }, + Enabled: true, + Transformations: [], + }, + metadata: { destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', jobId: 1 }, + message: { + anonymousId: '8d872292709c6fbe', + channel: 'mobile', + context: { + app: { + build: '1', + name: 'AMTestProject', + namespace: 'com.rudderstack.android.rudderstack.sampleAndroidApp', + version: '1.0', + }, + device: { + id: '8d872292709c6fbe', + manufacturer: 'Google', + model: 'AOSPonIAEmulator', + name: 'generic_x86_arm', + type: 'android', + }, + library: { + name: 'com.rudderstack.android.sdk.core', + version: '1.0.2', + }, + locale: 'en-US', + network: { + carrier: 'Android', + bluetooth: false, + cellular: true, + wifi: true, + }, + os: { + name: 'Android', + version: '9', + }, + screen: { + density: 420, + height: 1794, + width: 1080, + }, + timezone: 'Asia/Kolkata', + traits: { + ruddertrait0: 'abc', + ruddertrait1: 'def', + tags: ['tag1', 'tag2'], + unset_tags: ['tag3', 'tag4'], + emailConsent: true, + smsConsent: true, + address: { + city: 'Kolkata', + country: 'India', + postalcode: '700096', + state: 'West bengal', + street: 'Park Street', + }, + age: '30', + anonymousId: '8d872292709c6fbe', + birthday: '2020-05-26', + createDate: '18th March 2020', + description: 'Premium User for 3 years', + email: 'identify@test.com', + firstname: 'John', + userId: 'sample_user_id', + lastname: 'Sparrow', + name: 'John Sparrow', + id: 'sample_user_id', + phone: '9112340345', + username: 'john_sparrow', + }, + userAgent: + 'Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)', + }, + integrations: { + All: true, + }, + messageId: '1590431830915-73bed370-5889-436d-9a9e-0c0e0c809d06', + originalTimestamp: '2020-05-25T18:37:10.917Z', + type: 'group', + userId: 'sample_user_id', + }, + }, + ], + method: 'POST', + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + body: [ + { + statTags: { + destType: 'ORTTO', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + error: + 'message type group is not supported: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: message type group is not supported', + metadata: { + destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', + jobId: 1, + }, + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'ortto', + description: 'email or userId is not present', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + ID: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', + Name: 'ORTTO', + Config: { + privateApiKey: 'dummyApiKey', + instanceRegion: 'other', + orttoEventsMapping: [ + { + rsEventName: 'RudderEvent', + orttoEventName: 'Ortto Event', + eventProperties: [ + { + rudderProperty: 'RudderProp', + orttoProperty: 'OrttoProp', + type: 'text', + }, + { + rudderProperty: 'RudderProp', + orttoProperty: 'OrttoProp', + type: 'longText', + }, + ], + }, + ], + orttoPersonAttributes: [ + { + rudderTraits: 'ruddertrait0', + orttoAttribute: 'ortto attirbute0', + type: 'email', + }, + { + rudderTraits: 'ruddertrait1', + orttoAttribute: 'ortto attirbute1', + type: 'email', + }, + ], + }, + Enabled: true, + Transformations: [], + }, + metadata: { destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', jobId: 1 }, + message: { + channel: 'mobile', + context: { + app: { + build: '1', + name: 'AMTestProject', + namespace: 'com.rudderstack.android.rudderstack.sampleAndroidApp', + version: '1.0', + }, + device: { + id: '8d872292709c6fbe', + manufacturer: 'Google', + model: 'AOSPonIAEmulator', + name: 'generic_x86_arm', + type: 'android', + }, + library: { + name: 'com.rudderstack.android.sdk.core', + version: '1.0.2', + }, + locale: 'en-US', + network: { + carrier: 'Android', + bluetooth: false, + cellular: true, + wifi: true, + }, + os: { + name: 'Android', + version: '9', + }, + screen: { + density: 420, + height: 1794, + width: 1080, + }, + timezone: 'Asia/Kolkata', + traits: { + ruddertrait0: 'abc', + ruddertrait1: 'def', + tags: ['tag1', 'tag2'], + unset_tags: ['tag3', 'tag4'], + emailConsent: true, + smsConsent: true, + address: { + city: 'Kolkata', + country: 'India', + postalcode: '700096', + state: 'West bengal', + street: 'Park Street', + }, + age: '30', + anonymousId: '8d872292709c6fbe', + birthday: '2020-05-26', + createDate: '18th March 2020', + description: 'Premium User for 3 years', + firstname: 'John', + lastname: 'Sparrow', + name: 'John Sparrow', + phone: '9112340345', + username: 'john_sparrow', + }, + userAgent: + 'Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)', + }, + integrations: { + All: true, + }, + messageId: '1590431830915-73bed370-5889-436d-9a9e-0c0e0c809d06', + originalTimestamp: '2020-05-25T18:37:10.917Z', + type: 'identify', + }, + }, + ], + method: 'POST', + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + body: [ + { + statTags: { + destType: 'ORTTO', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + error: + 'Either of email or userId is required. Aborting message.: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Either of email or userId is required. Aborting message.', + metadata: { + destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', + jobId: 1, + }, + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'ortto', + description: 'instance region is not present', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + ID: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', + Name: 'ORTTO', + Config: { + privateApiKey: 'dummyApiKey', + orttoEventsMapping: [ + { + rsEventName: 'RudderEvent', + orttoEventName: 'Ortto Event', + eventProperties: [ + { + rudderProperty: 'RudderProp', + orttoProperty: 'OrttoProp', + type: 'text', + }, + { + rudderProperty: 'RudderProp', + orttoProperty: 'OrttoProp', + type: 'longText', + }, + ], + }, + ], + orttoPersonAttributes: [ + { + rudderTraits: 'ruddertrait0', + orttoAttribute: 'ortto attirbute0', + type: 'email', + }, + { + rudderTraits: 'ruddertrait1', + orttoAttribute: 'ortto attirbute1', + type: 'email', + }, + ], + }, + Enabled: true, + Transformations: [], + }, + metadata: { destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', jobId: 1 }, + message: { + anonymousId: '8d872292709c6fbe', + channel: 'mobile', + context: { + app: { + build: '1', + name: 'AMTestProject', + namespace: 'com.rudderstack.android.rudderstack.sampleAndroidApp', + version: '1.0', + }, + device: { + id: '8d872292709c6fbe', + manufacturer: 'Google', + model: 'AOSPonIAEmulator', + name: 'generic_x86_arm', + type: 'android', + }, + library: { + name: 'com.rudderstack.android.sdk.core', + version: '1.0.2', + }, + locale: 'en-US', + network: { + carrier: 'Android', + bluetooth: false, + cellular: true, + wifi: true, + }, + os: { + name: 'Android', + version: '9', + }, + screen: { + density: 420, + height: 1794, + width: 1080, + }, + timezone: 'Asia/Kolkata', + traits: { + ruddertrait0: 'abc', + ruddertrait1: 'def', + tags: ['tag1', 'tag2'], + unset_tags: ['tag3', 'tag4'], + emailConsent: true, + smsConsent: true, + address: { + city: 'Kolkata', + country: 'India', + postalcode: '700096', + state: 'West bengal', + street: 'Park Street', + }, + age: '30', + anonymousId: '8d872292709c6fbe', + birthday: '2020-05-26', + createDate: '18th March 2020', + description: 'Premium User for 3 years', + email: 'identify@test.com', + firstname: 'John', + userId: 'sample_user_id', + lastname: 'Sparrow', + name: 'John Sparrow', + id: 'sample_user_id', + phone: '9112340345', + username: 'john_sparrow', + }, + userAgent: + 'Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)', + }, + integrations: { + All: true, + }, + messageId: '1590431830915-73bed370-5889-436d-9a9e-0c0e0c809d06', + originalTimestamp: '2020-05-25T18:37:10.917Z', + type: 'identify', + userId: 'sample_user_id', + }, + }, + ], + method: 'POST', + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + body: [ + { + statTags: { + destType: 'ORTTO', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + error: + 'Instance Region is not present: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Instance Region is not present', + metadata: { + destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', + jobId: 1, + }, + statusCode: 400, + }, + ], + }, + }, + }, + { + name: 'ortto', + description: 'privateApi Key is not present', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + ID: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', + Name: 'ORTTO', + Config: { + instanceRegion: 'other', + orttoEventsMapping: [ + { + rsEventName: 'RudderEvent', + orttoEventName: 'Ortto Event', + eventProperties: [ + { + rudderProperty: 'RudderProp', + orttoProperty: 'OrttoProp', + type: 'text', + }, + { + rudderProperty: 'RudderProp', + orttoProperty: 'OrttoProp', + type: 'longText', + }, + ], + }, + ], + orttoPersonAttributes: [ + { + rudderTraits: 'ruddertrait0', + orttoAttribute: 'ortto attirbute0', + type: 'email', + }, + { + rudderTraits: 'ruddertrait1', + orttoAttribute: 'ortto attirbute1', + type: 'email', + }, + ], + }, + Enabled: true, + Transformations: [], + }, + metadata: { destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', jobId: 1 }, + message: { + anonymousId: '8d872292709c6fbe', + channel: 'mobile', + context: { + app: { + build: '1', + name: 'AMTestProject', + namespace: 'com.rudderstack.android.rudderstack.sampleAndroidApp', + version: '1.0', + }, + device: { + id: '8d872292709c6fbe', + manufacturer: 'Google', + model: 'AOSPonIAEmulator', + name: 'generic_x86_arm', + type: 'android', + }, + library: { + name: 'com.rudderstack.android.sdk.core', + version: '1.0.2', + }, + locale: 'en-US', + network: { + carrier: 'Android', + bluetooth: false, + cellular: true, + wifi: true, + }, + os: { + name: 'Android', + version: '9', + }, + screen: { + density: 420, + height: 1794, + width: 1080, + }, + timezone: 'Asia/Kolkata', + traits: { + ruddertrait0: 'abc', + ruddertrait1: 'def', + tags: ['tag1', 'tag2'], + unset_tags: ['tag3', 'tag4'], + emailConsent: true, + smsConsent: true, + address: { + city: 'Kolkata', + country: 'India', + postalcode: '700096', + state: 'West bengal', + street: 'Park Street', + }, + age: '30', + anonymousId: '8d872292709c6fbe', + birthday: '2020-05-26', + createDate: '18th March 2020', + description: 'Premium User for 3 years', + email: 'identify@test.com', + firstname: 'John', + userId: 'sample_user_id', + lastname: 'Sparrow', + name: 'John Sparrow', + id: 'sample_user_id', + phone: '9112340345', + username: 'john_sparrow', + }, + userAgent: + 'Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)', + }, + integrations: { + All: true, + }, + messageId: '1590431830915-73bed370-5889-436d-9a9e-0c0e0c809d06', + originalTimestamp: '2020-05-25T18:37:10.917Z', + type: 'identify', + userId: 'sample_user_id', + }, + }, + ], + method: 'POST', + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + body: [ + { + statTags: { + destType: 'ORTTO', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + error: + 'Private Api Key is not present: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Private Api Key is not present', + metadata: { + destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', + jobId: 1, + }, + statusCode: 400, + }, + ], + }, + }, + }, { name: 'ortto', description: 'Track call for updating activities', @@ -424,4 +1069,173 @@ export const data = [ }, }, }, + { + name: 'ortto', + description: 'Track call for updating activities', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + DestinationDefinition: { + Config: { + cdkV2Enabled: true, + }, + }, + ID: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', + Name: 'ORTTO', + Config: { + privateApiKey: 'dummyApiKey', + instanceRegion: 'other', + orttoEventsMapping: [ + { + rsEventName: 'RudderEvent', + orttoEventName: 'Ortto Event', + eventProperties: [ + { + rudderProperty: 'RudderProp', + orttoProperty: 'OrttoProp', + type: 'text', + }, + { + rudderProperty: 'RudderProp', + orttoProperty: 'OrttoProp', + type: 'longText', + }, + ], + }, + ], + orttoPersonAttributes: [ + { + rudderTraits: 'ruddertrait0', + orttoAttribute: 'ortto attirbute0', + type: 'email', + }, + { + rudderTraits: 'ruddertrait1', + orttoAttribute: 'ortto attirbute1', + type: 'email', + }, + ], + }, + Enabled: true, + Transformations: [], + }, + metadata: { destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', jobId: 2 }, + message: { + anonymousId: '8d872292709c6fbe', + channel: 'mobile', + context: { + app: { + build: '1', + name: 'AMTestProject', + namespace: 'com.rudderstack.android.rudderstack.sampleAndroidApp', + version: '1.0', + }, + device: { + id: '8d872292709c6fbe', + manufacturer: 'Google', + model: 'AOSPonIAEmulator', + name: 'generic_x86_arm', + type: 'android', + }, + library: { + name: 'com.rudderstack.android.sdk.core', + version: '1.0.2', + }, + locale: 'en-US', + network: { + carrier: 'Android', + bluetooth: false, + cellular: true, + wifi: true, + }, + os: { + name: 'Android', + version: '9', + }, + screen: { + density: 420, + height: 1794, + width: 1080, + }, + timezone: 'Asia/Kolkata', + traits: { + ruddertrait0: 'abc', + ruddertrait1: 'def', + address: { + city: 'Kolkata', + country: 'India', + postalcode: '700096', + state: 'West bengal', + street: 'Park Street', + }, + age: '30', + anonymousId: '8d872292709c6fbe', + birthday: '2020-05-26', + createDate: '18th March 2020', + description: 'Premium User for 3 years', + email: 'identify@test.com', + firstname: 'John', + gdpr: false, + userId: 'sample_user_id', + lastname: 'Sparrow', + name: 'John Sparrow', + id: 'sample_user_id', + phone: '9112340345', + username: 'john_sparrow', + }, + userAgent: + 'Dalvik/2.1.0 (Linux; U; Android 9; AOSP on IA Emulator Build/PSR1.180720.117)', + }, + integrations: { + All: true, + }, + messageId: '1590431830915-73bed370-5889-436d-9a9e-0c0e0c809d06', + properties: { + revenue: '30', + RudderProp: 'USD', + quantity: '5', + test_key_2: { + test_child_key_1: 'test_child_value_1', + }, + price: '58.0', + }, + originalTimestamp: '2020-05-25T18:37:10.917Z', + type: 'track', + userId: 'sample_user_id', + }, + }, + ], + method: 'POST', + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + body: [ + { + statTags: { + destType: 'ORTTO', + errorCategory: 'platform', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + error: + 'event is not present. Aborting.: Workflow: procWorkflow, Step: validateInputForTrack, ChildStep: undefined, OriginalError: event is not present. Aborting.', + metadata: { + destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', + jobId: 2, + }, + statusCode: 400, + }, + ], + }, + }, + }, ];