From de171b418fe195a2a1ae2106fe529c8f497138e6 Mon Sep 17 00:00:00 2001 From: Utsab Chowdhury Date: Wed, 6 Dec 2023 13:16:32 +0530 Subject: [PATCH] feat: address review comments --- src/v0/destinations/braze/config.js | 4 +++- src/v0/destinations/braze/util.js | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/v0/destinations/braze/config.js b/src/v0/destinations/braze/config.js index 2e24f43f61..2bbade2754 100644 --- a/src/v0/destinations/braze/config.js +++ b/src/v0/destinations/braze/config.js @@ -56,6 +56,7 @@ const BRAZE_NON_BILLABLE_ATTRIBUTES = [ 'subscription_groups', ]; +const BRAZE_PURCHASE_STANDARD_PROPERTIES = ['product_id', 'sku', 'price', 'quantity', 'currency']; module.exports = { ConfigCategory, mappingConfig, @@ -64,6 +65,7 @@ module.exports = { getSubscriptionGroupEndPoint, getAliasMergeEndPoint, BRAZE_PARTNER_NAME, + BRAZE_PURCHASE_STANDARD_PROPERTIES, TRACK_BRAZE_MAX_REQ_COUNT, IDENTIFY_BRAZE_MAX_REQ_COUNT, DESTINATION, @@ -71,5 +73,5 @@ module.exports = { DEL_MAX_BATCH_SIZE, BRAZE_NON_BILLABLE_ATTRIBUTES, ALIAS_BRAZE_MAX_REQ_COUNT, - SUBSCRIPTION_BRAZE_MAX_REQ_COUNT + SUBSCRIPTION_BRAZE_MAX_REQ_COUNT, }; diff --git a/src/v0/destinations/braze/util.js b/src/v0/destinations/braze/util.js index 946c105cf3..3b0855b338 100644 --- a/src/v0/destinations/braze/util.js +++ b/src/v0/destinations/braze/util.js @@ -21,6 +21,7 @@ const { SUBSCRIPTION_BRAZE_MAX_REQ_COUNT, ALIAS_BRAZE_MAX_REQ_COUNT, TRACK_BRAZE_MAX_REQ_COUNT, + BRAZE_PURCHASE_STANDARD_PROPERTIES, } = require('./config'); const { JSON_MIME_TYPE, HTTP_STATUS_CODES } = require('../../util/constant'); const { isObject } = require('../../util'); @@ -539,7 +540,7 @@ function addMandatoryPurchaseProperties(productId, price, currencyCode, quantity }; } -function getPurchaseObjs(message, Config) { +function getPurchaseObjs(message, config) { // ref:https://www.braze.com/docs/api/objects_filters/purchase_object/ const validateForPurchaseEvent = (message) => { const { properties } = message; @@ -634,8 +635,8 @@ function getPurchaseObjs(message, Config) { parseInt(quantity, 10), timestamp, ); - const extraProperties = _.omit(product, ['product_id', 'sku', 'price', 'quantity', 'currency']); - if (Object.keys(extraProperties).length > 0 && Config.sendPurchaseEventWithExtraProperties) { + const extraProperties = _.omit(product, BRAZE_PURCHASE_STANDARD_PROPERTIES); + if (Object.keys(extraProperties).length > 0 && config.sendPurchaseEventWithExtraProperties) { purchaseObj = { ...purchaseObj, properties: extraProperties }; } purchaseObj = setExternalIdOrAliasObject(purchaseObj, message);