Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pinterest event value is restricted to string #2933

Merged
merged 4 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ bindings:
path: ../../../../v0/util
- name: removeUndefinedAndNullAndEmptyValues
path: ../../../../v0/util
- name: validateEventName
path: ../../../../v0/util
steps:
- name: checkIfProcessed
condition: .message.statusCode
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -243,4 +246,4 @@ steps:
},
"params": $.outputs.checkSendTestEventConfig,
"files": {}
})[]
})[]
2 changes: 2 additions & 0 deletions src/v0/destinations/pinterest_tag/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
isDefined,
getHashFromArrayWithDuplicate,
removeUndefinedAndNullValues,
validateEventName,
} = require('../../util');
const { COMMON_CONFIGS, CUSTOM_CONFIGS, API_VERSION } = require('./config');

Expand Down Expand Up @@ -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
Expand Down
125 changes: 125 additions & 0 deletions test/integrations/destinations/pinterest_tag/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]',
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,
},
],
},
},
},
];
Loading