diff --git a/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml b/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml index 7bcb804126..8a956e905c 100644 --- a/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml +++ b/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml @@ -9,6 +9,8 @@ bindings: path: ../../../../v0/util - name: removeUndefinedAndNullAndEmptyValues path: ../../../../v0/util + - name: validateEventName + path: ../../../../v0/util steps: - name: checkIfProcessed condition: .message.statusCode @@ -175,6 +177,7 @@ steps: name: eventNamesForOthers template: | let event = .message.event ?? .message.name; + $.validateEventName(event); let eventInLowerCase = event.toLowerCase(); let eventNames = .destination.Config.eventsMapping.(){.from === event}.to[] ?? []; eventNames = $.convertToSnakeCase(eventNames); @@ -243,4 +246,4 @@ steps: }, "params": $.outputs.checkSendTestEventConfig, "files": {} - })[] + })[] \ No newline at end of file diff --git a/src/v0/destinations/pinterest_tag/utils.js b/src/v0/destinations/pinterest_tag/utils.js index c1493e9dbd..340fba498e 100644 --- a/src/v0/destinations/pinterest_tag/utils.js +++ b/src/v0/destinations/pinterest_tag/utils.js @@ -8,6 +8,7 @@ const { isDefined, getHashFromArrayWithDuplicate, removeUndefinedAndNullValues, + validateEventName, } = require('../../util'); const { COMMON_CONFIGS, CUSTOM_CONFIGS, API_VERSION } = require('./config'); @@ -170,6 +171,7 @@ const deduceTrackScreenEventName = (message, Config) => { if (!trackEventOrScreenName) { throw new InstrumentationError('event_name could not be mapped. Aborting'); } + validateEventName(trackEventOrScreenName); /* Step 1: If the event is not amongst the above list of ecommerce events, will look for diff --git a/test/integrations/destinations/pinterest_tag/processor/data.ts b/test/integrations/destinations/pinterest_tag/processor/data.ts index 17ab83b2e9..65b33e7740 100644 --- a/test/integrations/destinations/pinterest_tag/processor/data.ts +++ b/test/integrations/destinations/pinterest_tag/processor/data.ts @@ -3569,4 +3569,129 @@ export const data = [ }, }, }, + { + name: 'pinterest_tag', + description: 'Test 3', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + description: 'Any other format of event except string should be aborted', + message: { + type: 'track', + event: [1, 2, 3], + sentAt: '2020-08-14T05:30:30.118Z', + channel: 'web', + context: { + source: 'test', + userAgent: 'chrome', + traits: { + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + email: 'abc@gmail.com', + phone: '+1234589947', + ge: 'male', + db: '19950715', + lastname: 'Rudderlabs', + firstName: 'Test', + address: { city: 'Kolkata', state: 'WB', zip: '700114', country: 'IN' }, + }, + device: { advertisingId: 'abc123' }, + library: { name: 'rudder-sdk-ruby-sync', version: '1.0.6' }, + }, + messageId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9', + timestamp: '2020-08-14T05:30:30.118Z', + properties: { + tax: 2, + total: 27.5, + coupon: 'hasbros', + revenue: 48, + price: 25, + quantity: 2, + currency: 'USD', + discount: 2.5, + order_id: '50314b8e9bcf000000000000', + requestIP: '123.0.0.0', + optOutType: 'LDP', + products: [ + { + sku: '45790-32', + url: 'https://www.example.com/product/path', + name: 'Monopoly: 3rd Edition', + price: 19, + category: 'Games', + quantity: 1, + image_url: 'https:///www.example.com/product/path.jpg', + product_id: '507f1f77bcf86cd799439011', + }, + { + sku: '46493-32', + name: 'Uno Card Game', + price: 3, + category: 'Games', + quantity: 2, + product_id: '505bd76785ebb509fc183733', + }, + ], + shipping: 3, + subtotal: 22.5, + affiliation: 'Google Store', + checkout_id: 'fksdjfsdjfisjf9sdfjsd9f', + }, + anonymousId: '50be5c78-6c3f-4b60-be84-97805a316fb1', + integrations: { All: true }, + }, + destination: { + DestinationDefinition: { Config: { cdkV2Enabled: true } }, + ID: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', + Name: 'PINTEREST_TAG', + Config: { + sendAsTestEvent: false, + tagId: '123456789', + apiVersion: 'newApi', + adAccountId: 'accountId123', + conversionToken: 'conversionToken123', + appId: '429047995', + enhancedMatch: true, + enableDeduplication: true, + deduplicationKey: 'messageId', + sendingUnHashedData: true, + sendExternalId: true, + customProperties: [{ properties: 'presentclass' }, { properties: 'presentgrade' }], + eventsMapping: [{ from: 'ABC Searched', to: 'WatchVideo' }], + }, + Enabled: true, + Transformations: [], + }, + metadata: { destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq' }, + }, + ], + method: 'POST', + }, + pathSuffix: '', + }, + output: { + response: { + status: 200, + body: [ + { + error: + 'Event is a required field and should be a string: Workflow: procWorkflow, Step: eventNames, ChildStep: undefined, OriginalError: Event is a required field and should be a string', + metadata: { destintionId: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq' }, + statTags: { + destType: 'PINTEREST_TAG', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'processor', + implementation: 'cdkV2', + module: 'destination', + }, + statusCode: 400, + }, + ], + }, + }, + }, ];