From ed3bc9261ca05a0d9cc50f50574c36936aee620c Mon Sep 17 00:00:00 2001 From: Anant Jain <62471433+anantjain45823@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:07:16 +0530 Subject: [PATCH] Update utils.js --- src/cdk/v2/destinations/gladly/utils.js | 27 +++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/cdk/v2/destinations/gladly/utils.js b/src/cdk/v2/destinations/gladly/utils.js index 0489f410ec..5abc9b6dd0 100644 --- a/src/cdk/v2/destinations/gladly/utils.js +++ b/src/cdk/v2/destinations/gladly/utils.js @@ -1,6 +1,9 @@ const get = require('get-value'); const { InstrumentationError } = require('@rudderstack/integrations-lib'); -const { base64Convertor, getDestinationExternalID } = require('../../../../v0/util'); +const { + base64Convertor, + getDestinationExternalID, +} = require('../../../../v0/util'); const { MappedToDestinationKey } = require('../../../../constants'); const reservedCustomAttributes = [ @@ -32,6 +35,7 @@ const getEndpoint = (destination) => { return `https://${domain}/api/v1/customer-profiles`; }; + const getFieldValue = (field) => { if (field) { if (Array.isArray(field)) { @@ -40,7 +44,7 @@ const getFieldValue = (field) => { return [{ original: field }]; } return undefined; -}; +} const formatFieldForRETl = (message, fieldName) => { const identifierType = get(message, identifierTypeKey); @@ -66,6 +70,7 @@ const formatField = (message, fieldName) => { return formatFieldForRETl(message, fieldName); } return formatFieldForEventStream(message, fieldName); + }; const getCustomAttributes = (message) => { @@ -73,9 +78,7 @@ const getCustomAttributes = (message) => { // for rETL if (mappedToDestination) { if (message?.traits?.customAttributes && typeof message.traits.customAttributes === 'object') { - return Object.keys(message.traits.customAttributes).length > 0 - ? message.traits.customAttributes - : undefined; + return Object.keys(message.traits.customAttributes).length > 0 ? message.traits.customAttributes : undefined; } return undefined; } @@ -137,27 +140,25 @@ const getCustomerId = (message) => { const validatePayload = (payload) => { if (!(payload?.phones || payload?.emails || payload?.id || payload?.externalCustomerId)) { - throw new InstrumentationError( - 'One of phone, email, userId or GladlyCustomerId is required for an identify call', - ); + throw new InstrumentationError('One of phone, email, userId or GladlyCustomerId is required for an identify call'); } }; const getQueryParams = (payload) => { if (payload.emails && payload.emails.length > 0) { - return `email=${encodeURIComponent(payload.emails[0].original)}`; + return `email=${encodeURIComponent(payload.emails[0].original)}` } if (payload.phones && payload.phones.length > 0) { - return `phoneNumber=${encodeURIComponent(payload.phones[0].original)}`; + return `phoneNumber=${encodeURIComponent(payload.phones[0].original)}` } if (payload.externalCustomerId) { - return `externalCustomerId=${encodeURIComponent(payload.externalCustomerId)}`; + return `externalCustomerId=${encodeURIComponent(payload.externalCustomerId)}` } return undefined; -}; +} module.exports = { getHeaders, @@ -170,5 +171,5 @@ module.exports = { formatFieldForRETl, getCustomAttributes, getExternalCustomerId, - formatFieldForEventStream, + formatFieldForEventStream };