From 95c16b25d88c320dfa50e9216f8b177649e5239f Mon Sep 17 00:00:00 2001 From: sandeepdigumarty Date: Thu, 21 Dec 2023 21:13:20 +0530 Subject: [PATCH] fix: send empty string instead of null when the schema data is undefined --- .../destinations/fb_custom_audience/util.js | 10 +++++----- .../fb_custom_audience/processor/data.ts | 6 +++--- .../fb_custom_audience/router/data.ts | 20 +++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/v0/destinations/fb_custom_audience/util.js b/src/v0/destinations/fb_custom_audience/util.js index 47ccb9bf7d..6c53ed2814 100644 --- a/src/v0/destinations/fb_custom_audience/util.js +++ b/src/v0/destinations/fb_custom_audience/util.js @@ -131,21 +131,21 @@ const getUpdatedDataElement = (dataElement, isHashRequired, eachProperty, update /** * hash the original value for the properties apart from 'MADID' && 'EXTERN_ID as hashing is not required for them * ref: https://developers.facebook.com/docs/marketing-api/audiences/guides/custom-audiences#hash - * sending null values for the properties for which user hasn't provided any value + * sending empty string for the properties for which user hasn't provided any value */ if (isHashRequired && eachProperty !== 'MADID' && eachProperty !== 'EXTERN_ID') { if (tmpUpdatedProperty) { tmpUpdatedProperty = `${tmpUpdatedProperty}`; dataElement.push(sha256(tmpUpdatedProperty)); } else { - dataElement.push(null); + dataElement.push(''); } } - // if property name is MADID or EXTERN_ID if the value is undefined send null + // if property name is MADID or EXTERN_ID if the value is undefined send empty string else if (!tmpUpdatedProperty && (eachProperty === 'MADID' || eachProperty === 'EXTERN_ID')) { - dataElement.push(null); + dataElement.push(''); } else { - dataElement.push(tmpUpdatedProperty); + dataElement.push(tmpUpdatedProperty || ''); } return dataElement; }; diff --git a/test/integrations/destinations/fb_custom_audience/processor/data.ts b/test/integrations/destinations/fb_custom_audience/processor/data.ts index 4f892f6fef..267b966865 100644 --- a/test/integrations/destinations/fb_custom_audience/processor/data.ts +++ b/test/integrations/destinations/fb_custom_audience/processor/data.ts @@ -1987,7 +1987,7 @@ export const data = [ 'a953f09a1b6b6725b81956e9ad0b1eb49e3ad40004c04307ef8af6246a054116', '3fdba35f04dc8c462986c992bcf875546257113072a909c162f7e470e581e278', '7931aa2a1bed855457d1ddf6bc06ab4406a9fba0579045a4d6ff78f9c07c440f', - null, + '', '252f10c83610ebca1a059c0bae8255eba2f95be4d1d7bcfa89d7248a82d9f111', 'db0683221aebc02cc034b65ebcf7d1bddd1eb199e33fd23a31931947d13a11bc', 'abc', @@ -2123,7 +2123,7 @@ export const data = [ 'ST', 'COUNTRY', ], - data: [[null, null, null, null, null, null, null, null, null, null, null]], + data: [['', '', '', '', '', '', '', '', '', '', '']], }, }, body: { @@ -2256,7 +2256,7 @@ export const data = [ 'a953f09a1b6b6725b81956e9ad0b1eb49e3ad40004c04307ef8af6246a054116', '3fdba35f04dc8c462986c992bcf875546257113072a909c162f7e470e581e278', '7931aa2a1bed855457d1ddf6bc06ab4406a9fba0579045a4d6ff78f9c07c440f', - null, + '', '252f10c83610ebca1a059c0bae8255eba2f95be4d1d7bcfa89d7248a82d9f111', 'db0683221aebc02cc034b65ebcf7d1bddd1eb199e33fd23a31931947d13a11bc', 'abc', diff --git a/test/integrations/destinations/fb_custom_audience/router/data.ts b/test/integrations/destinations/fb_custom_audience/router/data.ts index efefb80a89..fd099fe33c 100644 --- a/test/integrations/destinations/fb_custom_audience/router/data.ts +++ b/test/integrations/destinations/fb_custom_audience/router/data.ts @@ -26757,16 +26757,16 @@ export const data = [ payload: { schema: ['EMAIL', 'FN'], data: [ - ['7625cab24612c37df6d2f724721bb38a25095d0295e29b807238ee188b8aca43', null], - ['b2b4abadd72190af54305c0d3abf1977fec4935016bb13ff28040d5712318dfd', null], - ['c4b007d1c3c9a5d31bd4082237a913e8e0db1767225c2a5ef33be2716df005fa', null], - ['94639be1bd9f17c05820164e9d71ef78558f117a9e8bfab43cf8015e08aa0b27', null], - ['39b456cfb4bb07f9e6bb18698aa173171ca49c731fccc4790e9ecea808d24ae6', null], - ['769f73387add781a481ca08300008a08fb2f1816aaed196137efc2e05976d711', null], - ['48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', null], - ['da2d431121cd10578fd81f8f80344b06db59ea2d05a7b5d27536c8789ddae8f0', null], - ['b100c2ec0718fe6b4805b623aeec6710719d042ceea55f5c8135b010ec1c7b36', null], - ['0c1d1b0ba547a742013366d6fbc8f71dd77f566d94e41ed9f828a74b96928161', null], + ['7625cab24612c37df6d2f724721bb38a25095d0295e29b807238ee188b8aca43', ''], + ['b2b4abadd72190af54305c0d3abf1977fec4935016bb13ff28040d5712318dfd', ''], + ['c4b007d1c3c9a5d31bd4082237a913e8e0db1767225c2a5ef33be2716df005fa', ''], + ['94639be1bd9f17c05820164e9d71ef78558f117a9e8bfab43cf8015e08aa0b27', ''], + ['39b456cfb4bb07f9e6bb18698aa173171ca49c731fccc4790e9ecea808d24ae6', ''], + ['769f73387add781a481ca08300008a08fb2f1816aaed196137efc2e05976d711', ''], + ['48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', ''], + ['da2d431121cd10578fd81f8f80344b06db59ea2d05a7b5d27536c8789ddae8f0', ''], + ['b100c2ec0718fe6b4805b623aeec6710719d042ceea55f5c8135b010ec1c7b36', ''], + ['0c1d1b0ba547a742013366d6fbc8f71dd77f566d94e41ed9f828a74b96928161', ''], ], }, },