From fb58e7adfaa42a38f5032798ba620d4ed24d4e91 Mon Sep 17 00:00:00 2001 From: Gaurav Kochar Date: Thu, 28 Sep 2023 18:23:51 +0530 Subject: [PATCH 1/3] worked on fixing 3157 | Pinterest Conversions API sending integers as strings. --- .../__tests__/__snapshots__/index.test.ts.snap | 4 ++-- .../reportConversionEvent/__tests__/index.test.ts | 4 ++++ .../pinterest-conversions/reportConversionEvent/index.ts | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/__tests__/__snapshots__/index.test.ts.snap b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/__tests__/__snapshots__/index.test.ts.snap index 78707fd8a5..fa3dca3bef 100644 --- a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/__tests__/__snapshots__/index.test.ts.snap @@ -12,11 +12,11 @@ Object { "content_ids": undefined, "contents": undefined, "currency": undefined, - "num_items": undefined, + "num_items": 2, "opt_out_type": undefined, "order_id": undefined, "search_string": undefined, - "value": "undefined", + "value": "2000", }, "device_brand": undefined, "device_carrier": undefined, diff --git a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/__tests__/index.test.ts b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/__tests__/index.test.ts index 0796e29183..7487051e98 100644 --- a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/__tests__/index.test.ts +++ b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/__tests__/index.test.ts @@ -111,6 +111,10 @@ describe('PinterestConversionApi', () => { client_user_agent: '5.5.5.5', client_ip_address: 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1' + }, + custom_data: { + num_items: '2', + value: 2000 } } }) diff --git a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts index a2bc97f1e4..b5bf58d0be 100644 --- a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts +++ b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts @@ -203,7 +203,7 @@ function createPinterestPayload(payload: Payload) { value: String(payload?.custom_data?.value), content_ids: payload.custom_data?.content_ids, contents: payload.custom_data?.contents, - num_items: payload.custom_data?.num_items, + num_items: payload.custom_data?.num_items ? parseInt(payload.custom_data?.num_items) : undefined, order_id: payload.custom_data?.order_id, search_string: payload.custom_data?.search_string, opt_out_type: payload.custom_data?.opt_out_type From 2ef096bec5fbd92d5e5cb6f9765ff267eb0ca068 Mon Sep 17 00:00:00 2001 From: Gaurav Kochar Date: Fri, 29 Sep 2023 13:55:43 +0530 Subject: [PATCH 2/3] Handle NAN while parsing --- .../pinterest-conversions/reportConversionEvent/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts index b5bf58d0be..b53549cf80 100644 --- a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts +++ b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts @@ -203,7 +203,10 @@ function createPinterestPayload(payload: Payload) { value: String(payload?.custom_data?.value), content_ids: payload.custom_data?.content_ids, contents: payload.custom_data?.contents, - num_items: payload.custom_data?.num_items ? parseInt(payload.custom_data?.num_items) : undefined, + num_items: + payload.custom_data?.num_items && !isNaN(parseInt(payload.custom_data?.num_items)) + ? parseInt(payload.custom_data?.num_items) + : undefined, order_id: payload.custom_data?.order_id, search_string: payload.custom_data?.search_string, opt_out_type: payload.custom_data?.opt_out_type From 005a7c5daef7474a405c8cb256f78915680ad458 Mon Sep 17 00:00:00 2001 From: Gaurav Kochar Date: Tue, 3 Oct 2023 12:43:57 +0530 Subject: [PATCH 3/3] updated datatype of num_items from string to integer --- .../pinterest-conversions/pinterest-capi-custom-data.ts | 2 +- .../reportConversionEvent/generated-types.ts | 2 +- .../pinterest-conversions/reportConversionEvent/index.ts | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/destination-actions/src/destinations/pinterest-conversions/pinterest-capi-custom-data.ts b/packages/destination-actions/src/destinations/pinterest-conversions/pinterest-capi-custom-data.ts index 260980e804..59ded2fde9 100644 --- a/packages/destination-actions/src/destinations/pinterest-conversions/pinterest-capi-custom-data.ts +++ b/packages/destination-actions/src/destinations/pinterest-conversions/pinterest-capi-custom-data.ts @@ -48,7 +48,7 @@ export const custom_data_field: InputField = { num_items: { label: 'Number of Items', description: 'Total number of products in the event. ', - type: 'string' + type: 'integer' }, order_id: { label: 'Order ID', diff --git a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/generated-types.ts b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/generated-types.ts index bfc6dc06a6..605e89d920 100644 --- a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/generated-types.ts +++ b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/generated-types.ts @@ -122,7 +122,7 @@ export interface Payload { /** * Total number of products in the event. */ - num_items?: string + num_items?: number /** * Order ID */ diff --git a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts index b53549cf80..a2bc97f1e4 100644 --- a/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts +++ b/packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts @@ -203,10 +203,7 @@ function createPinterestPayload(payload: Payload) { value: String(payload?.custom_data?.value), content_ids: payload.custom_data?.content_ids, contents: payload.custom_data?.contents, - num_items: - payload.custom_data?.num_items && !isNaN(parseInt(payload.custom_data?.num_items)) - ? parseInt(payload.custom_data?.num_items) - : undefined, + num_items: payload.custom_data?.num_items, order_id: payload.custom_data?.order_id, search_string: payload.custom_data?.search_string, opt_out_type: payload.custom_data?.opt_out_type