From 264f326fe5e4c91162710ff99b1c153c1dbb40e4 Mon Sep 17 00:00:00 2001 From: mihir-4116 Date: Fri, 10 Nov 2023 10:58:41 +0530 Subject: [PATCH] chore: code review changes --- src/cdk/v2/destinations/gladly/procWorkflow.yaml | 6 +++--- src/cdk/v2/destinations/gladly/utils.js | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cdk/v2/destinations/gladly/procWorkflow.yaml b/src/cdk/v2/destinations/gladly/procWorkflow.yaml index 795aac9dac..b11f75b06d 100644 --- a/src/cdk/v2/destinations/gladly/procWorkflow.yaml +++ b/src/cdk/v2/destinations/gladly/procWorkflow.yaml @@ -39,9 +39,9 @@ steps: - name: preparePayload template: | $.context.payload = { - name: .message.context.traits.name || .message.traits.name, - image: .message.context.traits.avatar || .message.traits.avatar, - address: .message.context.traits.address || .message.traits.address + name: .message.traits.name || .message.context.traits.name, + image: .message.traits.avatar || .message.context.traits.avatar, + address: .message.traits.address || .message.context.traits.address } $.context.payload.address && typeof $.context.payload.address === "object" ? $.context.payload.address = JSON.stringify($.context.payload.address) $.context.payload.emails = $.formatField(.message, "email") diff --git a/src/cdk/v2/destinations/gladly/utils.js b/src/cdk/v2/destinations/gladly/utils.js index 18ee9c976e..e9827b294f 100644 --- a/src/cdk/v2/destinations/gladly/utils.js +++ b/src/cdk/v2/destinations/gladly/utils.js @@ -37,6 +37,10 @@ const formatField = (message, fieldName) => { }; const getCustomAttributes = (message) => { + if (message.traits?.customAttributes && typeof message.traits?.customAttributes === 'object'){ + return message.traits?.customAttributes; + } + const customAttributes = message.context.traits; reservedCustomAttributes.forEach((customAttribute) => { if (customAttributes[customAttribute]) {