Skip to content

Commit

Permalink
feat: update pinterest_tag single product events with new mapping (#3858
Browse files Browse the repository at this point in the history
)

* feat: update pinterest_tag single product events with new mapping

* chore: use toString function from integrations-lib

* chore: update integrations-lib library
  • Loading branch information
ItsSudip authored Nov 18, 2024
1 parent d57f48e commit 8520278
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 33 deletions.
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@koa/router": "^12.0.0",
"@ndhoule/extend": "^2.0.0",
"@pyroscope/nodejs": "^0.2.9",
"@rudderstack/integrations-lib": "^0.2.12",
"@rudderstack/integrations-lib": "^0.2.13",
"@rudderstack/json-template-engine": "^0.18.0",
"@rudderstack/workflow-engine": "^0.8.13",
"@shopify/jest-koa-mocks": "^5.1.1",
Expand Down
40 changes: 23 additions & 17 deletions src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ bindings:
path: ../../../../v0/util
- name: validateEventName
path: ../../../../v0/util
- path: '@rudderstack/integrations-lib'

steps:
- name: checkIfProcessed
condition: .message.statusCode
Expand Down Expand Up @@ -67,9 +69,9 @@ steps:
"event_id": $.getOneByPaths(., ^.destination.Config.deduplicationKey) ?? .messageId,
"app_id": ^.destination.Config.appId,
"advertiser_id": ^.destination.Config.advertiserId,
"partner_name": .properties.partnerName,
"device_carrier": .context.network.carrier,
"wifi": .context.network.wifi
"partner_name": .properties.partnerName ? $.convertToString(.properties.partnerName) : undefined,
"device_carrier": .properties.partnerName ? $.convertToString(.context.network.carrier) : undefined,
"wifi": .context.network.wifi ? Boolean(.context.network.wifi) : undefined
});
$.outputs.apiVersion === {{$.API_VERSION.v5}} ? commonFields = commonFields{~["advertiser_id"]};
$.removeUndefinedValues(commonFields)
Expand Down Expand Up @@ -107,7 +109,7 @@ steps:
"client_user_agent": .context.userAgent,
"external_id": {{{{$.getGenericPaths("userId")}}}},
"click_id": .properties.clickId,
"partner_id": .traits.partnerId ?? .context.traits.partnerId
"partner_id": .traits.partnerId ?? .context.traits.partnerId ? $.convertToString(.traits.partnerId ?? .context.traits.partnerId) : undefined
});
!.destination.Config.sendExternalId ? userFields = userFields{~["external_id"]} : null;
userFields = $.removeUndefinedAndNullAndEmptyValues(userFields);
Expand All @@ -127,17 +129,17 @@ steps:
template: |
const customFields = .message.().({
"currency": .properties.currency,
"value": .properties.value !== undefined ? String(.properties.value) :
.properties.total !== undefined ? String(.properties.total) :
.properties.revenue !== undefined ? String(.properties.revenue) : undefined,
"value": .properties.value !== undefined ? $.convertToString(.properties.value) :
.properties.total !== undefined ? $.convertToString(.properties.total) :
.properties.revenue !== undefined ? $.convertToString(.properties.revenue) : undefined,
"num_items": .properties.numOfItems && Number(.properties.numOfItems),
"order_id": .properties.order_id,
"search_string": .properties.query,
"opt_out_type": .properties.optOutType,
"content_name": .properties.contentName,
"content_category": .properties.contentCategory,
"content_brand": .properties.contentBrand,
"np": .properties.np
"content_name": .properties.contentName ? $.convertToString(.properties.contentName) : undefined,
"content_category": .properties.contentCategory ? $.convertToString(.properties.contentCategory) : undefined,
"content_brand": .properties.contentBrand ? $.convertToString(.properties.contentBrand) : undefined,
"np": .properties.np ? $.convertToString(.properties.np) : undefined
});
$.removeUndefinedValues(customFields)
Expand All @@ -151,11 +153,11 @@ steps:
"content_ids": products.(.product_id ?? .sku ?? .id)[],
"contents": [email protected].({
"quantity": Number(.quantity ?? prop.quantity ?? 1),
"item_price": String(.price ?? prop.price),
"item_name": String(.name),
"id": .product_id ?? .sku,
"item_category": .category,
"item_brand": .brand
"item_price": $.convertToString(.price ?? prop.price),
"item_name": $.convertToString(.name),
"id": .product_id ?? .sku ? $.convertToString(.product_id ?? .sku) : undefined,
"item_category": .category ? $.convertToString(.category) : undefined,
"item_brand": .brand ? $.convertToString(.brand) : undefined
})[]
}
else:
Expand All @@ -167,7 +169,11 @@ steps:
"content_ids": (props.product_id ?? props.sku ?? props.id)[],
"contents": {
"quantity": Number(props.quantity) || 1,
"item_price": String(props.price)
"item_price": props.price ? $.convertToString(props.price),
"item_name": props.name ? $.convertToString(props.name),
"id": props.product_id ?? props.sku ? $.convertToString(props.product_id ?? props.sku) : undefined,
"item_category": props.category ? $.convertToString(props.category) : undefined,
"item_brand": props.brand ? $.convertToString(props.brand) : undefined
}[]
};
- name: combineAllEcomFields
Expand Down
8 changes: 8 additions & 0 deletions test/apitests/data_scenarios/cdk_v2/failure.json
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down Expand Up @@ -679,6 +683,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down
12 changes: 12 additions & 0 deletions test/apitests/data_scenarios/cdk_v2/success.json
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down Expand Up @@ -634,6 +638,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down Expand Up @@ -712,6 +720,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down Expand Up @@ -466,6 +470,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down Expand Up @@ -544,6 +552,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down Expand Up @@ -466,6 +470,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down Expand Up @@ -285,6 +289,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down Expand Up @@ -781,6 +785,10 @@
"content_ids": ["123"],
"contents": [
{
"id": "123",
"item_brand": "Gamepro",
"item_category": "Games",
"item_name": "Game",
"quantity": 11,
"item_price": "13.49"
}
Expand Down
11 changes: 5 additions & 6 deletions test/integrations/destinations/pinterest_tag/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ export const data = [
order_id: '50314b8e9bcf000000000000',
num_items: 2,
content_ids: ['123'],
contents: [{ quantity: 2, item_price: '25' }],
contents: [{ id: '123', quantity: 2, item_price: '25' }],
},
},
JSON_ARRAY: {},
Expand Down Expand Up @@ -2405,7 +2405,7 @@ export const data = [
order_id: '50314b8e9bcf000000000000',
num_items: 0,
content_ids: ['1234'],
contents: [{ quantity: 1, item_price: 'undefined' }],
contents: [{ id: '1234', quantity: 1 }],
},
},
JSON_ARRAY: {},
Expand Down Expand Up @@ -2666,7 +2666,7 @@ export const data = [
advertiser_id: '123456',
app_id: '429047995',
custom_data: {
contents: [{ item_price: 'undefined', quantity: 1 }],
contents: [{ quantity: 1 }],
currency: 'USD',
num_items: 0,
order_id: '50314b8e9bcf000000000000',
Expand Down Expand Up @@ -3486,7 +3486,7 @@ export const data = [
timestamp: '2020-08-14T05:30:30.118Z',
properties: {
tax: 2,
total: 27.5,
total: [27.5, 123],
coupon: 'hasbros',
revenue: 48,
currency: 'USD',
Expand Down Expand Up @@ -3562,11 +3562,10 @@ export const data = [
contents: [
{
quantity: 1,
item_price: 'undefined',
},
],
currency: 'USD',
value: '27.5',
value: '[27.5,123]',
order_id: '50314b8e9bcf000000000000',
},
event_name: 'custom event',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ export const data = [
order_id: '50314b8e9bcf000000000000',
num_items: 2,
content_ids: ['123'],
contents: [{ quantity: 2, item_price: '25' }],
contents: [{ id: '123', quantity: 2, item_price: '25' }],
},
},
{
Expand Down
7 changes: 3 additions & 4 deletions test/integrations/destinations/pinterest_tag/step/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ export const data = [
order_id: '50314b8e9bcf000000000000',
num_items: 2,
content_ids: ['123'],
contents: [{ quantity: 2, item_price: '25' }],
contents: [{ id: '123', quantity: 2, item_price: '25' }],
},
},
JSON_ARRAY: {},
Expand Down Expand Up @@ -2420,7 +2420,7 @@ export const data = [
order_id: '50314b8e9bcf000000000000',
num_items: 0,
content_ids: ['1234'],
contents: [{ quantity: 1, item_price: 'undefined' }],
contents: [{ id: '1234', quantity: 1 }],
},
},
JSON_ARRAY: {},
Expand Down Expand Up @@ -2685,7 +2685,7 @@ export const data = [
advertiser_id: '123456',
app_id: '429047995',
custom_data: {
contents: [{ item_price: 'undefined', quantity: 1 }],
contents: [{ quantity: 1 }],
currency: 'USD',
num_items: 0,
order_id: '50314b8e9bcf000000000000',
Expand Down Expand Up @@ -3606,7 +3606,6 @@ export const data = [
contents: [
{
quantity: 1,
item_price: 'undefined',
},
],
},
Expand Down

0 comments on commit 8520278

Please sign in to comment.