diff --git a/package-lock.json b/package-lock.json index 0422078f21..50c374bef0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,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", @@ -6602,9 +6602,10 @@ } }, "node_modules/@rudderstack/integrations-lib": { - "version": "0.2.12", - "resolved": "https://registry.npmjs.org/@rudderstack/integrations-lib/-/integrations-lib-0.2.12.tgz", - "integrity": "sha512-xy+T9SHFkSeVDd4svGOyrTtIGljZ/l4qUh5o5EQWk3dTStzaV9mKnbXLsG62kEO3aTmCVg+VYr4OPwZY2+6rxQ==", + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/@rudderstack/integrations-lib/-/integrations-lib-0.2.13.tgz", + "integrity": "sha512-MBI+OQpnYAuOzRlbGCnUX6oVfQsYA7daZ8z07WmqQYQtWFOfd2yFbaxKclu+R/a8W7+jBo4gvbW+ScEW6h+Mgg==", + "license": "MIT", "dependencies": { "axios": "^1.4.0", "axios-mock-adapter": "^1.22.0", diff --git a/package.json b/package.json index 907c340cbf..e25c865f54 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml b/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml index 64d391c888..aebb7b0667 100644 --- a/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml +++ b/src/cdk/v2/destinations/pinterest_tag/procWorkflow.yaml @@ -11,6 +11,8 @@ bindings: path: ../../../../v0/util - name: validateEventName path: ../../../../v0/util + - path: '@rudderstack/integrations-lib' + steps: - name: checkIfProcessed condition: .message.statusCode @@ -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) @@ -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); @@ -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) @@ -151,11 +153,11 @@ steps: "content_ids": products.(.product_id ?? .sku ?? .id)[], "contents": .message.properties@prop.products.({ "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: @@ -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 diff --git a/test/apitests/data_scenarios/cdk_v2/failure.json b/test/apitests/data_scenarios/cdk_v2/failure.json index 1635a3f0db..154d24481d 100644 --- a/test/apitests/data_scenarios/cdk_v2/failure.json +++ b/test/apitests/data_scenarios/cdk_v2/failure.json @@ -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" } @@ -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" } diff --git a/test/apitests/data_scenarios/cdk_v2/success.json b/test/apitests/data_scenarios/cdk_v2/success.json index ced7433a28..88f430dd7c 100644 --- a/test/apitests/data_scenarios/cdk_v2/success.json +++ b/test/apitests/data_scenarios/cdk_v2/success.json @@ -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" } @@ -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" } @@ -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" } diff --git a/test/apitests/data_scenarios/destination/proc/batch_input_multiplex.json b/test/apitests/data_scenarios/destination/proc/batch_input_multiplex.json index 3ce7c15091..3deb7d4b8b 100644 --- a/test/apitests/data_scenarios/destination/proc/batch_input_multiplex.json +++ b/test/apitests/data_scenarios/destination/proc/batch_input_multiplex.json @@ -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" } @@ -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" } @@ -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" } diff --git a/test/apitests/data_scenarios/destination/proc/multiplex_partial_failure.json b/test/apitests/data_scenarios/destination/proc/multiplex_partial_failure.json index 0e467c26d0..a2652855d5 100644 --- a/test/apitests/data_scenarios/destination/proc/multiplex_partial_failure.json +++ b/test/apitests/data_scenarios/destination/proc/multiplex_partial_failure.json @@ -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" } @@ -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" } diff --git a/test/apitests/data_scenarios/destination/proc/multiplex_success.json b/test/apitests/data_scenarios/destination/proc/multiplex_success.json index 66b6c870a9..ba4d5266f3 100644 --- a/test/apitests/data_scenarios/destination/proc/multiplex_success.json +++ b/test/apitests/data_scenarios/destination/proc/multiplex_success.json @@ -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" } @@ -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" } diff --git a/test/apitests/data_scenarios/destination/router/failure_test.json b/test/apitests/data_scenarios/destination/router/failure_test.json index 9e36da50cb..197456f66a 100644 --- a/test/apitests/data_scenarios/destination/router/failure_test.json +++ b/test/apitests/data_scenarios/destination/router/failure_test.json @@ -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" } @@ -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" } diff --git a/test/integrations/destinations/pinterest_tag/processor/data.ts b/test/integrations/destinations/pinterest_tag/processor/data.ts index b856d247d7..4982444346 100644 --- a/test/integrations/destinations/pinterest_tag/processor/data.ts +++ b/test/integrations/destinations/pinterest_tag/processor/data.ts @@ -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: {}, @@ -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: {}, @@ -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', @@ -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', @@ -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', diff --git a/test/integrations/destinations/pinterest_tag/router/data.ts b/test/integrations/destinations/pinterest_tag/router/data.ts index c9ab29a45a..4049f7663a 100644 --- a/test/integrations/destinations/pinterest_tag/router/data.ts +++ b/test/integrations/destinations/pinterest_tag/router/data.ts @@ -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' }], }, }, { diff --git a/test/integrations/destinations/pinterest_tag/step/data.ts b/test/integrations/destinations/pinterest_tag/step/data.ts index b607e3c9fa..71f12c735c 100644 --- a/test/integrations/destinations/pinterest_tag/step/data.ts +++ b/test/integrations/destinations/pinterest_tag/step/data.ts @@ -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: {}, @@ -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: {}, @@ -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', @@ -3606,7 +3606,6 @@ export const data = [ contents: [ { quantity: 1, - item_price: 'undefined', }, ], },