From f651045de5fe31e1d5f2edce298522c835337fe0 Mon Sep 17 00:00:00 2001 From: Anant Jain Date: Thu, 9 Nov 2023 22:23:45 +0530 Subject: [PATCH 1/2] revert: fix: amplitude page and screen call containg double spaces --- src/v0/destinations/am/transform.js | 19 ++++++------------- test/__tests__/data/am_output.json | 4 ++-- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/v0/destinations/am/transform.js b/src/v0/destinations/am/transform.js index 04a1c5a107..9cc8813aef 100644 --- a/src/v0/destinations/am/transform.js +++ b/src/v0/destinations/am/transform.js @@ -194,9 +194,9 @@ const handleTraits = (messageTrait, destination) => { const getScreenevTypeAndUpdatedProperties = (message, CATEGORY_KEY) => { const name = message.name || message.event || get(message, CATEGORY_KEY); - const updatedName = name ? `${name} ` : ''; + return { - eventType: `Viewed ${updatedName}Screen`, + eventType: `Viewed ${name} Screen`, updatedProperties: { ...message.properties, name, @@ -577,8 +577,6 @@ 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 @@ -611,15 +609,10 @@ const processSingleMessage = (message, destination) => { userProvidedPageEventString.trim() === '' ? name : userProvidedPageEventString - .trim() - .replaceAll(/{{([^{}]+)}}/g, get(message, getMessagePath)); + .trim() + .replaceAll(/{{([^{}]+)}}/g, get(message, getMessagePath)); } else { - const updatedName = getUpdatedPageNameWithoutUserDefinedPageEventName( - name, - message, - CATEGORY_KEY, - ); - evType = `Viewed ${updatedName || ''}Page`; + evType = `Viewed ${name || get(message, CATEGORY_KEY)} Page`; } message.properties = { ...properties, @@ -843,7 +836,7 @@ const getBatchEvents = (message, destination, metadata, batchEventResponse) => { if ( batchEventArray.length < AMBatchEventLimit && JSON.stringify(batchPayloadJSON).length + JSON.stringify(incomingMessageEvent).length < - AMBatchSizeLimit + AMBatchSizeLimit ) { batchEventArray.push(incomingMessageEvent); // set value batchEventJobs.push(metadata); diff --git a/test/__tests__/data/am_output.json b/test/__tests__/data/am_output.json index 34471f4922..ea4b8b908d 100644 --- a/test/__tests__/data/am_output.json +++ b/test/__tests__/data/am_output.json @@ -3944,7 +3944,7 @@ "id": "User Android", "userId": "User Android" }, - "event_type": "Viewed Screen", + "event_type": "Viewed Screen", "user_id": "User Android", "device_brand": "Google", "time": 1662393883250, @@ -4276,7 +4276,7 @@ "app_name": "RudderLabs JavaScript SDK", "app_version": "1.0.0", "language": "en-US", - "event_type": "Viewed Page", + "event_type": "Viewed Page", "event_properties": { "path": "/destinations/amplitude", "referrer": "", From 07e5e40af2d27bd252d114a39493905efad4807b Mon Sep 17 00:00:00 2001 From: Anant Jain Date: Thu, 9 Nov 2023 22:35:23 +0530 Subject: [PATCH 2/2] chore: fix for undefined names --- src/v0/destinations/am/transform.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/v0/destinations/am/transform.js b/src/v0/destinations/am/transform.js index 9cc8813aef..48d9d0cd9b 100644 --- a/src/v0/destinations/am/transform.js +++ b/src/v0/destinations/am/transform.js @@ -196,7 +196,7 @@ const getScreenevTypeAndUpdatedProperties = (message, CATEGORY_KEY) => { const name = message.name || message.event || get(message, CATEGORY_KEY); return { - eventType: `Viewed ${name} Screen`, + eventType: `Viewed ${message.name || message.event || get(message, CATEGORY_KEY) || ''} Screen`, updatedProperties: { ...message.properties, name, @@ -609,10 +609,10 @@ const processSingleMessage = (message, destination) => { userProvidedPageEventString.trim() === '' ? name : userProvidedPageEventString - .trim() - .replaceAll(/{{([^{}]+)}}/g, get(message, getMessagePath)); + .trim() + .replaceAll(/{{([^{}]+)}}/g, get(message, getMessagePath)); } else { - evType = `Viewed ${name || get(message, CATEGORY_KEY)} Page`; + evType = `Viewed ${name || get(message, CATEGORY_KEY) || ''} Page`; } message.properties = { ...properties, @@ -836,7 +836,7 @@ const getBatchEvents = (message, destination, metadata, batchEventResponse) => { if ( batchEventArray.length < AMBatchEventLimit && JSON.stringify(batchPayloadJSON).length + JSON.stringify(incomingMessageEvent).length < - AMBatchSizeLimit + AMBatchSizeLimit ) { batchEventArray.push(incomingMessageEvent); // set value batchEventJobs.push(metadata);