From 09e3d0fe47a8766880719aa73f23c3bc240b0d1b Mon Sep 17 00:00:00 2001 From: Gauravudia Date: Wed, 12 Jun 2024 18:30:50 +0530 Subject: [PATCH 1/4] feat: onboard new custom destination: wunderkind --- .../destinations/wunderkind/procWorkflow.yaml | 36 +++++++++++++++++++ .../destinations/wunderkind/rtWorkflow.yaml | 31 ++++++++++++++++ src/features.json | 5 +-- 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 src/cdk/v2/destinations/wunderkind/procWorkflow.yaml create mode 100644 src/cdk/v2/destinations/wunderkind/rtWorkflow.yaml diff --git a/src/cdk/v2/destinations/wunderkind/procWorkflow.yaml b/src/cdk/v2/destinations/wunderkind/procWorkflow.yaml new file mode 100644 index 0000000000..7cb2b3e8ef --- /dev/null +++ b/src/cdk/v2/destinations/wunderkind/procWorkflow.yaml @@ -0,0 +1,36 @@ +bindings: + - name: EventType + path: ../../../../constants + - path: ../../bindings/jsontemplate + exportAll: true + - path: ../../../../v0/destinations/webhook/utils + - name: getHashFromArray + path: ../../../../v0/util + - name: getIntegrationsObj + path: ../../../../v0/util + - name: removeUndefinedAndNullValues + path: ../../../../v0/util + +steps: + - name: checkIfProcessed + condition: .message.statusCode + template: | + $.batchMode ? .message.body.JSON : .message + onComplete: return + + - name: messageType + template: | + $.context.messageType = .message.type.toLowerCase(); + + - name: validateInput + template: | + let messageType = $.context.messageType; + $.assert(messageType, "message Type is not present. Aborting"); + $.assert(messageType in {{$.EventType.([.TRACK])}}, "message type " + messageType + " is not supported"); + $.assertConfig(.destination.Config.accountID, "Account ID is not present. Aborting"); + $.assertConfig(.destination.Config.instanceID, "Instance ID is not present. Aborting"); + - name: buildResponseForProcessTransformation + template: | + { + payload: JSON.stringify(.message.properties), + } diff --git a/src/cdk/v2/destinations/wunderkind/rtWorkflow.yaml b/src/cdk/v2/destinations/wunderkind/rtWorkflow.yaml new file mode 100644 index 0000000000..335293b6db --- /dev/null +++ b/src/cdk/v2/destinations/wunderkind/rtWorkflow.yaml @@ -0,0 +1,31 @@ +bindings: + - name: handleRtTfSingleEventError + path: ../../../../v0/util/index + +steps: + - name: validateInput + template: | + $.assert(Array.isArray(^) && ^.length > 0, "Invalid event array") + + - name: transform + externalWorkflow: + path: ./procWorkflow.yaml + loopOverInput: true + + - name: successfulEvents + template: | + $.outputs.transform#idx.output.({ + "batchedRequest": ., + "batched": false, + "destination": ^[idx].destination, + "metadata": ^[idx].metadata[], + "statusCode": 200 + })[] + - name: failedEvents + template: | + $.outputs.transform#idx.error.( + $.handleRtTfSingleEventError(^[idx], .originalError ?? ., {}) + )[] + - name: finalPayload + template: | + [...$.outputs.failedEvents, ...$.outputs.successfulEvents] diff --git a/src/features.json b/src/features.json index 58af795a77..52ea52d15a 100644 --- a/src/features.json +++ b/src/features.json @@ -72,7 +72,8 @@ "BLOOMREACH": true, "MOVABLE_INK": true, "EMARSYS": true, - "KODDI": true + "KODDI": true, + "WUNDERKIND": true }, "regulations": [ "BRAZE", @@ -91,4 +92,4 @@ ], "supportSourceTransformV1": true, "supportTransformerProxyV1": true -} +} \ No newline at end of file From b06fa7de55c14be0fdba4746389738b726d6a0d1 Mon Sep 17 00:00:00 2001 From: Gauravudia Date: Thu, 27 Jun 2024 12:51:44 +0530 Subject: [PATCH 2/4] feat: add destination canonical name and update payload --- .../destinations/wunderkind/procWorkflow.yaml | 40 +++++++++++++++++-- src/constants/destinationCanonicalNames.js | 1 + 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/cdk/v2/destinations/wunderkind/procWorkflow.yaml b/src/cdk/v2/destinations/wunderkind/procWorkflow.yaml index 7cb2b3e8ef..e976f7da60 100644 --- a/src/cdk/v2/destinations/wunderkind/procWorkflow.yaml +++ b/src/cdk/v2/destinations/wunderkind/procWorkflow.yaml @@ -10,6 +10,8 @@ bindings: path: ../../../../v0/util - name: removeUndefinedAndNullValues path: ../../../../v0/util + - name: CommonUtils + path: ../../../../util/common steps: - name: checkIfProcessed @@ -20,7 +22,7 @@ steps: - name: messageType template: | - $.context.messageType = .message.type.toLowerCase(); + $.context.messageType = .message.type.toLowerCase(); - name: validateInput template: | @@ -29,8 +31,38 @@ steps: $.assert(messageType in {{$.EventType.([.TRACK])}}, "message type " + messageType + " is not supported"); $.assertConfig(.destination.Config.accountID, "Account ID is not present. Aborting"); $.assertConfig(.destination.Config.instanceID, "Instance ID is not present. Aborting"); + $.assertConfig(.destination.Config.apiKey, "API Key is not present. Aborting"); + + - name: buildAccountPayload + template: | + { + account_id: .destination.Config.accountID, + account_settings: { + instance_id: .destination.Config.instanceID, + key: .destination.Config.apiKey + } + } + + - name: buildPayload + template: | + const integrationObj = $.getIntegrationsObj(.message, "wunderkind") + const event = { + ...integrationObj.extraEventProperties, + attributes: .message.properties + } + + const payload = { + account: $.outputs.buildAccountPayload, + ...integrationObj.lambdaRootLevelProperties, + user_attributes: .message.().( + {{{{$.getGenericPaths("traits")}}}} + ), + events: $.CommonUtils.toArray(event) + } + - name: buildResponseForProcessTransformation template: | - { - payload: JSON.stringify(.message.properties), - } + + { + payload: JSON.stringify($.outputs.buildPayload), + } diff --git a/src/constants/destinationCanonicalNames.js b/src/constants/destinationCanonicalNames.js index 19136eab59..c16013d7cc 100644 --- a/src/constants/destinationCanonicalNames.js +++ b/src/constants/destinationCanonicalNames.js @@ -167,6 +167,7 @@ const DestCanonicalNames = { koala: ['Koala', 'koala', 'KOALA'], bloomreach: ['Bloomreach', 'bloomreach', 'BLOOMREACH'], emarsys: ['EMARSYS', 'Emarsys', 'emarsys'], + wunderkind: ['wunderkind', 'Wunderkind', 'WUNDERKIND'], }; module.exports = { DestHandlerMap, DestCanonicalNames }; From 4e23809d8dad8e1dac8ab1859a86c68aedaec513 Mon Sep 17 00:00:00 2001 From: Gauravudia Date: Wed, 3 Jul 2024 14:51:05 +0530 Subject: [PATCH 3/4] test: add processor and router testcases --- .../destinations/wunderkind/common.ts | 123 ++++++++++++ .../destinations/wunderkind/processor/data.ts | 3 + .../wunderkind/processor/track.ts | 183 ++++++++++++++++++ .../wunderkind/processor/validation.ts | 50 +++++ .../destinations/wunderkind/router/data.ts | 127 ++++++++++++ 5 files changed, 486 insertions(+) create mode 100644 test/integrations/destinations/wunderkind/common.ts create mode 100644 test/integrations/destinations/wunderkind/processor/data.ts create mode 100644 test/integrations/destinations/wunderkind/processor/track.ts create mode 100644 test/integrations/destinations/wunderkind/processor/validation.ts create mode 100644 test/integrations/destinations/wunderkind/router/data.ts diff --git a/test/integrations/destinations/wunderkind/common.ts b/test/integrations/destinations/wunderkind/common.ts new file mode 100644 index 0000000000..48472b0059 --- /dev/null +++ b/test/integrations/destinations/wunderkind/common.ts @@ -0,0 +1,123 @@ +import { Destination } from '../../../../src/types'; + +export const destType = 'wunderkind'; +const destTypeInUpperCase = 'WUNDERKIND'; +const displayName = 'WUNDERKIND'; +export const destination: Destination = { + Config: { + accountID: 'test-account-id', + instanceID: 'test-instance-id', + apiKey: 'test-api-key', + }, + DestinationDefinition: { + DisplayName: displayName, + ID: '123', + Name: destTypeInUpperCase, + Config: { cdkV2Enabled: true }, + }, + Enabled: true, + ID: '123', + Name: destTypeInUpperCase, + Transformations: [], + WorkspaceID: 'test-workspace-id', +}; + +export const properties = { + profileLoginType: 'logged-in', + launchType: 'organic', + platform: 'iphone-app', + fuelType: 'Gasoline', + makeName: 'Volvo', + vehicleAdCategory: 'multi_cat', + searchInstanceId: 'test-search-instance-id', + customerId: 'test-customer-id', + drivetrain: 'All-wheel Drive', + year: '2024', + canonical_mmt: 'volvo:xc90:b5_core_bright_theme', + mileage: '5', + make: 'volvo', + pushNotification: 'disabled', + advertiserId: '00000000-0000-0000-0000-000000000000', + exteriorColor: 'Crystal White', + adobeId: 'test-adobe-id', + pageChannel: 'shopping', + bodyStyle: 'suv', + tripId: 'test-trip-id', + stockType: 'new', + makeModelTrim: 'volvo:xc90:b5_core_bright_theme', + pageName: 'shopping/vehicle-details', + model: 'xc90', + deviceType: 'mobile', + listingId: 'test-listing-id', + dealerZip: '30341', + cpoIndicator: 'false', + trim: 'b5_core_bright_theme', + canonical_mmty: 'volvo:xc90:b5_core_bright_theme:2024', + sellerType: 'franchise', + price: '56002', + vin: 'test-vin', + resultSelected: '89', + zip: '85381', + stockSubStock: 'new', + profileUserId: 'test-profile-user-id', + pageKey: 'vehicle-details', + badges: 'homeDelivery,virtualAppointment', + modelName: 'XC90', +}; + +export const runtimeEnvironment = { + sdk_version: '8.8.0', + type: 'ios', + identities: [ + { + type: 'apple_push_notification_token', + encoding: 'raw', + value: '9e3dba8db39f9d130f3d1584c8aab674e9f4b06d0b1b52867e128d3e7b1130f1', + }, + { + type: 'ios_vendor_id', + encoding: 'raw', + value: '78c53c15-32a1-4b65-adac-bec2d7bb8fab', + }, + ], + build_id: '20E12', + brand: 'iPhone14,7', + product: 'iPhone14,7', + name: 'iPhone', + manufacturer: 'Apple', + os_version: '16.3.1', + model: 'iPhone14,7', + screen_height: 2532, + screen_width: 1170, + locale_language: 'en-US', + locale_country: 'US', + network_country: 'us', + network_carrier: 'Verizon', + network_code: '480', + network_mobile_country_code: '311', + timezone_offset: -7, + timezone_name: 'America/Phoenix', + cpu_architecture: 'arm64', + radio_access_technology: 'LTE', + application_name: 'Abc.com - New Account', + application_version: '8.8.0', + application_package: 'com.abc', + apple_search_ads_attribution: {}, + client_ip_address: '192.0.2.0', +}; + +export const processorInstrumentationErrorStatTags = { + destType: destTypeInUpperCase, + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', +}; + +export const routerInstrumentationErrorStatTags = { + ...processorInstrumentationErrorStatTags, + feature: 'router', +}; diff --git a/test/integrations/destinations/wunderkind/processor/data.ts b/test/integrations/destinations/wunderkind/processor/data.ts new file mode 100644 index 0000000000..b57a5e8a12 --- /dev/null +++ b/test/integrations/destinations/wunderkind/processor/data.ts @@ -0,0 +1,3 @@ +import { validation } from './validation'; +import { track } from './track'; +export const data = [...track, ...validation]; diff --git a/test/integrations/destinations/wunderkind/processor/track.ts b/test/integrations/destinations/wunderkind/processor/track.ts new file mode 100644 index 0000000000..af8eb538d3 --- /dev/null +++ b/test/integrations/destinations/wunderkind/processor/track.ts @@ -0,0 +1,183 @@ +import { generateMetadata } from '../../../testUtils'; +import { destType, destination, properties, runtimeEnvironment } from '../common'; + +export const track = [ + { + id: 'Wunderkind-track-test-1', + name: destType, + description: 'Track call: custom event srp-screen-view', + scenario: 'Framework+Business', + successCriteria: + 'Response should contain the input payload with request level properties mapped from integration object `lambdaRootLevelProperties` field and event level properties mapping from integration object `extraEventProperties` field and status code should be 200', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + event: 'srp-screen-view', + type: 'track', + userId: 'test_123', + context: { + traits: { + firstName: 'john', + lastName: 'doe', + }, + }, + integrations: { + Wunderkind: { + extraEventProperties: { + screen_name: 'shopping/vehicle-details', + type: 'custom_event', + id: '1393f120-53b8-4126-8deb-874c26b5b06d', + timestamp_ms: 1703685306737, + source_id: 'test-source-id', + session_id: 1688982077105114764, + name: 'srp-screen-view', + custom_event_type: 'other', + }, + lambdaRootLevelProperties: { + type: 'event_processing_request', + id: 'a2a5575b-d3b0-4a14-96a5-79f8e38b0778', + timestamp_ms: 1718893923387, + source_id: 'test-source-id', + source_channel: 'native', + device_application_stamp: 'test-device-application-stamp', + user_identities: [ + { + type: 'customer', + encoding: 'raw', + value: 'eb3f565d-49bd-418c-ae31-801f25da0ce2', + }, + { + type: 'email', + encoding: 'raw', + value: 'johndoe@gmail.com', + }, + { + type: 'other', + encoding: 'raw', + value: '7c2c3abd-62bf-473e-998d-034df0f25ea3', + }, + ], + user_attribute_lists: {}, + runtime_environment: runtimeEnvironment, + }, + }, + }, + properties, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + payload: + '{"account":{"account_id":"test-account-id","account_settings":{"instance_id":"test-instance-id","key":"test-api-key"}},"type":"event_processing_request","id":"a2a5575b-d3b0-4a14-96a5-79f8e38b0778","timestamp_ms":1718893923387,"source_id":"test-source-id","source_channel":"native","device_application_stamp":"test-device-application-stamp","user_identities":[{"type":"customer","encoding":"raw","value":"eb3f565d-49bd-418c-ae31-801f25da0ce2"},{"type":"email","encoding":"raw","value":"johndoe@gmail.com"},{"type":"other","encoding":"raw","value":"7c2c3abd-62bf-473e-998d-034df0f25ea3"}],"user_attribute_lists":{},"runtime_environment":{"sdk_version":"8.8.0","type":"ios","identities":[{"type":"apple_push_notification_token","encoding":"raw","value":"9e3dba8db39f9d130f3d1584c8aab674e9f4b06d0b1b52867e128d3e7b1130f1"},{"type":"ios_vendor_id","encoding":"raw","value":"78c53c15-32a1-4b65-adac-bec2d7bb8fab"}],"build_id":"20E12","brand":"iPhone14,7","product":"iPhone14,7","name":"iPhone","manufacturer":"Apple","os_version":"16.3.1","model":"iPhone14,7","screen_height":2532,"screen_width":1170,"locale_language":"en-US","locale_country":"US","network_country":"us","network_carrier":"Verizon","network_code":"480","network_mobile_country_code":"311","timezone_offset":-7,"timezone_name":"America/Phoenix","cpu_architecture":"arm64","radio_access_technology":"LTE","application_name":"Abc.com - New Account","application_version":"8.8.0","application_package":"com.abc","apple_search_ads_attribution":{},"client_ip_address":"192.0.2.0"},"user_attributes":{"firstName":"john","lastName":"doe"},"events":[{"screen_name":"shopping/vehicle-details","type":"custom_event","id":"1393f120-53b8-4126-8deb-874c26b5b06d","timestamp_ms":1703685306737,"source_id":"test-source-id","session_id":1688982077105115000,"name":"srp-screen-view","custom_event_type":"other","attributes":{"profileLoginType":"logged-in","launchType":"organic","platform":"iphone-app","fuelType":"Gasoline","makeName":"Volvo","vehicleAdCategory":"multi_cat","searchInstanceId":"test-search-instance-id","customerId":"test-customer-id","drivetrain":"All-wheel Drive","year":"2024","canonical_mmt":"volvo:xc90:b5_core_bright_theme","mileage":"5","make":"volvo","pushNotification":"disabled","advertiserId":"00000000-0000-0000-0000-000000000000","exteriorColor":"Crystal White","adobeId":"test-adobe-id","pageChannel":"shopping","bodyStyle":"suv","tripId":"test-trip-id","stockType":"new","makeModelTrim":"volvo:xc90:b5_core_bright_theme","pageName":"shopping/vehicle-details","model":"xc90","deviceType":"mobile","listingId":"test-listing-id","dealerZip":"30341","cpoIndicator":"false","trim":"b5_core_bright_theme","canonical_mmty":"volvo:xc90:b5_core_bright_theme:2024","sellerType":"franchise","price":"56002","vin":"test-vin","resultSelected":"89","zip":"85381","stockSubStock":"new","profileUserId":"test-profile-user-id","pageKey":"vehicle-details","badges":"homeDelivery,virtualAppointment","modelName":"XC90"}}]}', + userId: '', + }, + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, + { + id: 'Wunderkind-track-test-2', + name: destType, + description: 'Track call: screen_view event', + scenario: 'Framework+Business', + successCriteria: + 'Response should contain the input payload with request level properties mapped from integration object `lambdaRootLevelProperties` field and event level properties mapping from integration object `extraEventProperties` field and status code should be 200', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + event: 'screen_view', + type: 'track', + userId: 'test_123', + context: { + traits: { + firstName: 'john', + lastName: 'doe', + }, + }, + integrations: { + Wunderkind: { + extraEventProperties: { + type: 'screen_view', + id: '1393f120-53b8-4126-8deb-874c26b5b06d', + timestamp_ms: 1703685306737, + source_id: 'test-source-id', + session_id: 1688982077105114764, + screen_name: 'shopping/vehicle-details', + }, + lambdaRootLevelProperties: { + type: 'event_processing_request', + id: 'a2a5575b-d3b0-4a14-96a5-79f8e38b0778', + timestamp_ms: 1718893923387, + source_id: 'test-source-id', + source_channel: 'native', + device_application_stamp: 'test-device-application-stamp', + user_identities: [ + { + type: 'customer', + encoding: 'raw', + value: 'eb3f565d-49bd-418c-ae31-801f25da0ce2', + }, + { + type: 'email', + encoding: 'raw', + value: 'johndoe@gmail.com', + }, + { + type: 'other', + encoding: 'raw', + value: '7c2c3abd-62bf-473e-998d-034df0f25ea3', + }, + ], + user_attribute_lists: {}, + runtime_environment: runtimeEnvironment, + }, + }, + }, + properties, + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + payload: + '{"account":{"account_id":"test-account-id","account_settings":{"instance_id":"test-instance-id","key":"test-api-key"}},"type":"event_processing_request","id":"a2a5575b-d3b0-4a14-96a5-79f8e38b0778","timestamp_ms":1718893923387,"source_id":"test-source-id","source_channel":"native","device_application_stamp":"test-device-application-stamp","user_identities":[{"type":"customer","encoding":"raw","value":"eb3f565d-49bd-418c-ae31-801f25da0ce2"},{"type":"email","encoding":"raw","value":"johndoe@gmail.com"},{"type":"other","encoding":"raw","value":"7c2c3abd-62bf-473e-998d-034df0f25ea3"}],"user_attribute_lists":{},"runtime_environment":{"sdk_version":"8.8.0","type":"ios","identities":[{"type":"apple_push_notification_token","encoding":"raw","value":"9e3dba8db39f9d130f3d1584c8aab674e9f4b06d0b1b52867e128d3e7b1130f1"},{"type":"ios_vendor_id","encoding":"raw","value":"78c53c15-32a1-4b65-adac-bec2d7bb8fab"}],"build_id":"20E12","brand":"iPhone14,7","product":"iPhone14,7","name":"iPhone","manufacturer":"Apple","os_version":"16.3.1","model":"iPhone14,7","screen_height":2532,"screen_width":1170,"locale_language":"en-US","locale_country":"US","network_country":"us","network_carrier":"Verizon","network_code":"480","network_mobile_country_code":"311","timezone_offset":-7,"timezone_name":"America/Phoenix","cpu_architecture":"arm64","radio_access_technology":"LTE","application_name":"Abc.com - New Account","application_version":"8.8.0","application_package":"com.abc","apple_search_ads_attribution":{},"client_ip_address":"192.0.2.0"},"user_attributes":{"firstName":"john","lastName":"doe"},"events":[{"type":"screen_view","id":"1393f120-53b8-4126-8deb-874c26b5b06d","timestamp_ms":1703685306737,"source_id":"test-source-id","session_id":1688982077105115000,"screen_name":"shopping/vehicle-details","attributes":{"profileLoginType":"logged-in","launchType":"organic","platform":"iphone-app","fuelType":"Gasoline","makeName":"Volvo","vehicleAdCategory":"multi_cat","searchInstanceId":"test-search-instance-id","customerId":"test-customer-id","drivetrain":"All-wheel Drive","year":"2024","canonical_mmt":"volvo:xc90:b5_core_bright_theme","mileage":"5","make":"volvo","pushNotification":"disabled","advertiserId":"00000000-0000-0000-0000-000000000000","exteriorColor":"Crystal White","adobeId":"test-adobe-id","pageChannel":"shopping","bodyStyle":"suv","tripId":"test-trip-id","stockType":"new","makeModelTrim":"volvo:xc90:b5_core_bright_theme","pageName":"shopping/vehicle-details","model":"xc90","deviceType":"mobile","listingId":"test-listing-id","dealerZip":"30341","cpoIndicator":"false","trim":"b5_core_bright_theme","canonical_mmty":"volvo:xc90:b5_core_bright_theme:2024","sellerType":"franchise","price":"56002","vin":"test-vin","resultSelected":"89","zip":"85381","stockSubStock":"new","profileUserId":"test-profile-user-id","pageKey":"vehicle-details","badges":"homeDelivery,virtualAppointment","modelName":"XC90"}}]}', + userId: '', + }, + statusCode: 200, + metadata: generateMetadata(1), + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/wunderkind/processor/validation.ts b/test/integrations/destinations/wunderkind/processor/validation.ts new file mode 100644 index 0000000000..aeabdd497b --- /dev/null +++ b/test/integrations/destinations/wunderkind/processor/validation.ts @@ -0,0 +1,50 @@ +import { ProcessorTestData } from '../../../testTypes'; +import { generateMetadata } from '../../../testUtils'; +import { destType, destination, processorInstrumentationErrorStatTags } from '../common'; + +export const validation: ProcessorTestData[] = [ + { + id: 'Wunderkind-validation-test-1', + name: destType, + description: 'Unsupported message type -> group', + scenario: 'Framework', + successCriteria: 'Instrumentation Error for Unsupported message type', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination, + message: { + type: 'group', + userId: 'userId123', + channel: 'mobile', + anonymousId: 'anon_123', + integrations: { + All: true, + }, + originalTimestamp: '2024-03-04T15:32:56.409Z', + }, + metadata: generateMetadata(1), + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'message type group is not supported: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: message type group is not supported', + metadata: generateMetadata(1), + statTags: processorInstrumentationErrorStatTags, + statusCode: 400, + }, + ], + }, + }, + }, +]; diff --git a/test/integrations/destinations/wunderkind/router/data.ts b/test/integrations/destinations/wunderkind/router/data.ts new file mode 100644 index 0000000000..8081bdf456 --- /dev/null +++ b/test/integrations/destinations/wunderkind/router/data.ts @@ -0,0 +1,127 @@ +import { generateMetadata } from '../../../testUtils'; +import { + destType, + destination, + properties, + runtimeEnvironment, + routerInstrumentationErrorStatTags, +} from '../common'; + +export const data = [ + { + id: 'MovableInk-router-test-1', + name: destType, + description: 'Basic Router Test to test multiple payloads', + scenario: 'Framework', + successCriteria: + 'Some events should be transformed successfully and some should fail for missing fields and status code should be 200', + feature: 'router', + module: 'destination', + version: 'v0', + input: { + request: { + body: { + input: [ + { + destination, + message: { + type: 'identify', + anonymousId: 'anonId123', + integrations: { + All: true, + }, + originalTimestamp: '2024-03-04T15:32:56.409Z', + }, + metadata: generateMetadata(1), + }, + { + destination, + message: { + event: 'srp-screen-view', + type: 'track', + userId: 'test_123', + context: { + traits: { + firstName: 'john', + lastName: 'doe', + }, + }, + integrations: { + Wunderkind: { + extraEventProperties: { + screen_name: 'shopping/vehicle-details', + type: 'custom_event', + id: '1393f120-53b8-4126-8deb-874c26b5b06d', + timestamp_ms: 1703685306737, + source_id: 'test-source-id', + session_id: 1688982077105114764, + name: 'srp-screen-view', + custom_event_type: 'other', + }, + lambdaRootLevelProperties: { + type: 'event_processing_request', + id: 'a2a5575b-d3b0-4a14-96a5-79f8e38b0778', + timestamp_ms: 1718893923387, + source_id: 'test-source-id', + source_channel: 'native', + device_application_stamp: 'test-device-application-stamp', + user_identities: [ + { + type: 'customer', + encoding: 'raw', + value: 'eb3f565d-49bd-418c-ae31-801f25da0ce2', + }, + { + type: 'email', + encoding: 'raw', + value: 'johndoe@gmail.com', + }, + { + type: 'other', + encoding: 'raw', + value: '7c2c3abd-62bf-473e-998d-034df0f25ea3', + }, + ], + user_attribute_lists: {}, + runtime_environment: runtimeEnvironment, + }, + }, + }, + properties, + }, + metadata: generateMetadata(2), + }, + ], + destType, + }, + }, + }, + output: { + response: { + status: 200, + body: { + output: [ + { + metadata: [generateMetadata(1)], + batched: false, + statusCode: 400, + error: 'message type identify is not supported', + statTags: routerInstrumentationErrorStatTags, + destination, + }, + { + batchedRequest: { + payload: + '{"account":{"account_id":"test-account-id","account_settings":{"instance_id":"test-instance-id","key":"test-api-key"}},"type":"event_processing_request","id":"a2a5575b-d3b0-4a14-96a5-79f8e38b0778","timestamp_ms":1718893923387,"source_id":"test-source-id","source_channel":"native","device_application_stamp":"test-device-application-stamp","user_identities":[{"type":"customer","encoding":"raw","value":"eb3f565d-49bd-418c-ae31-801f25da0ce2"},{"type":"email","encoding":"raw","value":"johndoe@gmail.com"},{"type":"other","encoding":"raw","value":"7c2c3abd-62bf-473e-998d-034df0f25ea3"}],"user_attribute_lists":{},"runtime_environment":{"sdk_version":"8.8.0","type":"ios","identities":[{"type":"apple_push_notification_token","encoding":"raw","value":"9e3dba8db39f9d130f3d1584c8aab674e9f4b06d0b1b52867e128d3e7b1130f1"},{"type":"ios_vendor_id","encoding":"raw","value":"78c53c15-32a1-4b65-adac-bec2d7bb8fab"}],"build_id":"20E12","brand":"iPhone14,7","product":"iPhone14,7","name":"iPhone","manufacturer":"Apple","os_version":"16.3.1","model":"iPhone14,7","screen_height":2532,"screen_width":1170,"locale_language":"en-US","locale_country":"US","network_country":"us","network_carrier":"Verizon","network_code":"480","network_mobile_country_code":"311","timezone_offset":-7,"timezone_name":"America/Phoenix","cpu_architecture":"arm64","radio_access_technology":"LTE","application_name":"Abc.com - New Account","application_version":"8.8.0","application_package":"com.abc","apple_search_ads_attribution":{},"client_ip_address":"192.0.2.0"},"user_attributes":{"firstName":"john","lastName":"doe"},"events":[{"screen_name":"shopping/vehicle-details","type":"custom_event","id":"1393f120-53b8-4126-8deb-874c26b5b06d","timestamp_ms":1703685306737,"source_id":"test-source-id","session_id":1688982077105115000,"name":"srp-screen-view","custom_event_type":"other","attributes":{"profileLoginType":"logged-in","launchType":"organic","platform":"iphone-app","fuelType":"Gasoline","makeName":"Volvo","vehicleAdCategory":"multi_cat","searchInstanceId":"test-search-instance-id","customerId":"test-customer-id","drivetrain":"All-wheel Drive","year":"2024","canonical_mmt":"volvo:xc90:b5_core_bright_theme","mileage":"5","make":"volvo","pushNotification":"disabled","advertiserId":"00000000-0000-0000-0000-000000000000","exteriorColor":"Crystal White","adobeId":"test-adobe-id","pageChannel":"shopping","bodyStyle":"suv","tripId":"test-trip-id","stockType":"new","makeModelTrim":"volvo:xc90:b5_core_bright_theme","pageName":"shopping/vehicle-details","model":"xc90","deviceType":"mobile","listingId":"test-listing-id","dealerZip":"30341","cpoIndicator":"false","trim":"b5_core_bright_theme","canonical_mmty":"volvo:xc90:b5_core_bright_theme:2024","sellerType":"franchise","price":"56002","vin":"test-vin","resultSelected":"89","zip":"85381","stockSubStock":"new","profileUserId":"test-profile-user-id","pageKey":"vehicle-details","badges":"homeDelivery,virtualAppointment","modelName":"XC90"}}]}', + }, + metadata: [generateMetadata(2)], + destination, + batched: false, + statusCode: 200, + }, + ], + }, + }, + }, + }, +]; From 87eeb9ab714c753da104057183f8b25e048ad1a5 Mon Sep 17 00:00:00 2001 From: Gauravudia Date: Thu, 4 Jul 2024 17:54:53 +0530 Subject: [PATCH 4/4] refactor: testcases --- .../wunderkind/processor/track.ts | 90 ++++++++++++++++++- 1 file changed, 86 insertions(+), 4 deletions(-) diff --git a/test/integrations/destinations/wunderkind/processor/track.ts b/test/integrations/destinations/wunderkind/processor/track.ts index af8eb538d3..286f35a255 100644 --- a/test/integrations/destinations/wunderkind/processor/track.ts +++ b/test/integrations/destinations/wunderkind/processor/track.ts @@ -81,8 +81,43 @@ export const track = [ body: [ { output: { - payload: - '{"account":{"account_id":"test-account-id","account_settings":{"instance_id":"test-instance-id","key":"test-api-key"}},"type":"event_processing_request","id":"a2a5575b-d3b0-4a14-96a5-79f8e38b0778","timestamp_ms":1718893923387,"source_id":"test-source-id","source_channel":"native","device_application_stamp":"test-device-application-stamp","user_identities":[{"type":"customer","encoding":"raw","value":"eb3f565d-49bd-418c-ae31-801f25da0ce2"},{"type":"email","encoding":"raw","value":"johndoe@gmail.com"},{"type":"other","encoding":"raw","value":"7c2c3abd-62bf-473e-998d-034df0f25ea3"}],"user_attribute_lists":{},"runtime_environment":{"sdk_version":"8.8.0","type":"ios","identities":[{"type":"apple_push_notification_token","encoding":"raw","value":"9e3dba8db39f9d130f3d1584c8aab674e9f4b06d0b1b52867e128d3e7b1130f1"},{"type":"ios_vendor_id","encoding":"raw","value":"78c53c15-32a1-4b65-adac-bec2d7bb8fab"}],"build_id":"20E12","brand":"iPhone14,7","product":"iPhone14,7","name":"iPhone","manufacturer":"Apple","os_version":"16.3.1","model":"iPhone14,7","screen_height":2532,"screen_width":1170,"locale_language":"en-US","locale_country":"US","network_country":"us","network_carrier":"Verizon","network_code":"480","network_mobile_country_code":"311","timezone_offset":-7,"timezone_name":"America/Phoenix","cpu_architecture":"arm64","radio_access_technology":"LTE","application_name":"Abc.com - New Account","application_version":"8.8.0","application_package":"com.abc","apple_search_ads_attribution":{},"client_ip_address":"192.0.2.0"},"user_attributes":{"firstName":"john","lastName":"doe"},"events":[{"screen_name":"shopping/vehicle-details","type":"custom_event","id":"1393f120-53b8-4126-8deb-874c26b5b06d","timestamp_ms":1703685306737,"source_id":"test-source-id","session_id":1688982077105115000,"name":"srp-screen-view","custom_event_type":"other","attributes":{"profileLoginType":"logged-in","launchType":"organic","platform":"iphone-app","fuelType":"Gasoline","makeName":"Volvo","vehicleAdCategory":"multi_cat","searchInstanceId":"test-search-instance-id","customerId":"test-customer-id","drivetrain":"All-wheel Drive","year":"2024","canonical_mmt":"volvo:xc90:b5_core_bright_theme","mileage":"5","make":"volvo","pushNotification":"disabled","advertiserId":"00000000-0000-0000-0000-000000000000","exteriorColor":"Crystal White","adobeId":"test-adobe-id","pageChannel":"shopping","bodyStyle":"suv","tripId":"test-trip-id","stockType":"new","makeModelTrim":"volvo:xc90:b5_core_bright_theme","pageName":"shopping/vehicle-details","model":"xc90","deviceType":"mobile","listingId":"test-listing-id","dealerZip":"30341","cpoIndicator":"false","trim":"b5_core_bright_theme","canonical_mmty":"volvo:xc90:b5_core_bright_theme:2024","sellerType":"franchise","price":"56002","vin":"test-vin","resultSelected":"89","zip":"85381","stockSubStock":"new","profileUserId":"test-profile-user-id","pageKey":"vehicle-details","badges":"homeDelivery,virtualAppointment","modelName":"XC90"}}]}', + payload: JSON.stringify({ + account: { + account_id: 'test-account-id', + account_settings: { instance_id: 'test-instance-id', key: 'test-api-key' }, + }, + type: 'event_processing_request', + id: 'a2a5575b-d3b0-4a14-96a5-79f8e38b0778', + timestamp_ms: 1718893923387, + source_id: 'test-source-id', + source_channel: 'native', + device_application_stamp: 'test-device-application-stamp', + user_identities: [ + { + type: 'customer', + encoding: 'raw', + value: 'eb3f565d-49bd-418c-ae31-801f25da0ce2', + }, + { type: 'email', encoding: 'raw', value: 'johndoe@gmail.com' }, + { type: 'other', encoding: 'raw', value: '7c2c3abd-62bf-473e-998d-034df0f25ea3' }, + ], + user_attribute_lists: {}, + runtime_environment: runtimeEnvironment, + user_attributes: { firstName: 'john', lastName: 'doe' }, + events: [ + { + screen_name: 'shopping/vehicle-details', + type: 'custom_event', + id: '1393f120-53b8-4126-8deb-874c26b5b06d', + timestamp_ms: 1703685306737, + source_id: 'test-source-id', + session_id: 1688982077105115000, + name: 'srp-screen-view', + custom_event_type: 'other', + attributes: properties, + }, + ], + }), userId: '', }, statusCode: 200, @@ -169,8 +204,55 @@ export const track = [ body: [ { output: { - payload: - '{"account":{"account_id":"test-account-id","account_settings":{"instance_id":"test-instance-id","key":"test-api-key"}},"type":"event_processing_request","id":"a2a5575b-d3b0-4a14-96a5-79f8e38b0778","timestamp_ms":1718893923387,"source_id":"test-source-id","source_channel":"native","device_application_stamp":"test-device-application-stamp","user_identities":[{"type":"customer","encoding":"raw","value":"eb3f565d-49bd-418c-ae31-801f25da0ce2"},{"type":"email","encoding":"raw","value":"johndoe@gmail.com"},{"type":"other","encoding":"raw","value":"7c2c3abd-62bf-473e-998d-034df0f25ea3"}],"user_attribute_lists":{},"runtime_environment":{"sdk_version":"8.8.0","type":"ios","identities":[{"type":"apple_push_notification_token","encoding":"raw","value":"9e3dba8db39f9d130f3d1584c8aab674e9f4b06d0b1b52867e128d3e7b1130f1"},{"type":"ios_vendor_id","encoding":"raw","value":"78c53c15-32a1-4b65-adac-bec2d7bb8fab"}],"build_id":"20E12","brand":"iPhone14,7","product":"iPhone14,7","name":"iPhone","manufacturer":"Apple","os_version":"16.3.1","model":"iPhone14,7","screen_height":2532,"screen_width":1170,"locale_language":"en-US","locale_country":"US","network_country":"us","network_carrier":"Verizon","network_code":"480","network_mobile_country_code":"311","timezone_offset":-7,"timezone_name":"America/Phoenix","cpu_architecture":"arm64","radio_access_technology":"LTE","application_name":"Abc.com - New Account","application_version":"8.8.0","application_package":"com.abc","apple_search_ads_attribution":{},"client_ip_address":"192.0.2.0"},"user_attributes":{"firstName":"john","lastName":"doe"},"events":[{"type":"screen_view","id":"1393f120-53b8-4126-8deb-874c26b5b06d","timestamp_ms":1703685306737,"source_id":"test-source-id","session_id":1688982077105115000,"screen_name":"shopping/vehicle-details","attributes":{"profileLoginType":"logged-in","launchType":"organic","platform":"iphone-app","fuelType":"Gasoline","makeName":"Volvo","vehicleAdCategory":"multi_cat","searchInstanceId":"test-search-instance-id","customerId":"test-customer-id","drivetrain":"All-wheel Drive","year":"2024","canonical_mmt":"volvo:xc90:b5_core_bright_theme","mileage":"5","make":"volvo","pushNotification":"disabled","advertiserId":"00000000-0000-0000-0000-000000000000","exteriorColor":"Crystal White","adobeId":"test-adobe-id","pageChannel":"shopping","bodyStyle":"suv","tripId":"test-trip-id","stockType":"new","makeModelTrim":"volvo:xc90:b5_core_bright_theme","pageName":"shopping/vehicle-details","model":"xc90","deviceType":"mobile","listingId":"test-listing-id","dealerZip":"30341","cpoIndicator":"false","trim":"b5_core_bright_theme","canonical_mmty":"volvo:xc90:b5_core_bright_theme:2024","sellerType":"franchise","price":"56002","vin":"test-vin","resultSelected":"89","zip":"85381","stockSubStock":"new","profileUserId":"test-profile-user-id","pageKey":"vehicle-details","badges":"homeDelivery,virtualAppointment","modelName":"XC90"}}]}', + payload: JSON.stringify({ + account: { + account_id: 'test-account-id', + account_settings: { + instance_id: 'test-instance-id', + key: 'test-api-key', + }, + }, + type: 'event_processing_request', + id: 'a2a5575b-d3b0-4a14-96a5-79f8e38b0778', + timestamp_ms: 1718893923387, + source_id: 'test-source-id', + source_channel: 'native', + device_application_stamp: 'test-device-application-stamp', + user_identities: [ + { + type: 'customer', + encoding: 'raw', + value: 'eb3f565d-49bd-418c-ae31-801f25da0ce2', + }, + { + type: 'email', + encoding: 'raw', + value: 'johndoe@gmail.com', + }, + { + type: 'other', + encoding: 'raw', + value: '7c2c3abd-62bf-473e-998d-034df0f25ea3', + }, + ], + user_attribute_lists: {}, + runtime_environment: runtimeEnvironment, + user_attributes: { + firstName: 'john', + lastName: 'doe', + }, + events: [ + { + type: 'screen_view', + id: '1393f120-53b8-4126-8deb-874c26b5b06d', + timestamp_ms: 1703685306737, + source_id: 'test-source-id', + session_id: 1688982077105115000, + screen_name: 'shopping/vehicle-details', + attributes: properties, + }, + ], + }), userId: '', }, statusCode: 200,