From 9320251e9303737ade0a2f8effdfd9039a8498b5 Mon Sep 17 00:00:00 2001 From: Anant Jain Date: Thu, 2 Nov 2023 11:02:01 +0530 Subject: [PATCH] sonarcloud fix+1 --- src/v0/destinations/am/transform.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/v0/destinations/am/transform.js b/src/v0/destinations/am/transform.js index 9babaff22b..b74625e273 100644 --- a/src/v0/destinations/am/transform.js +++ b/src/v0/destinations/am/transform.js @@ -577,6 +577,9 @@ const getGroupInfo = (destination, groupInfo, groupTraits) => { } return groupInfo; }; +const getUpdatedPageNameWithoutUserDefinedPageEventName = (name, message, CATEGORY_KEY) => + name || get(message, CATEGORY_KEY) ? `${name || get(message, CATEGORY_KEY)} ` : undefined; + // Generic process function which invokes specific handler functions depending on message type // and event type where applicable const processSingleMessage = (message, destination) => { @@ -612,11 +615,13 @@ const processSingleMessage = (message, destination) => { .trim() .replaceAll(/{{([^{}]+)}}/g, get(message, getMessagePath)); } else { - const updatedName = - name || get(message, CATEGORY_KEY) ? `${name || get(message, CATEGORY_KEY)} ` : undefined; + const updatedName = getUpdatedPageNameWithoutUserDefinedPageEventName( + name, + message, + CATEGORY_KEY, + ); evType = `Viewed ${updatedName || ''}Page`; } - message.properties = { ...message.properties, name: name || get(message, CATEGORY_KEY),