From c2c50011f5853755e89cbf6298ca170cdd76a598 Mon Sep 17 00:00:00 2001 From: Anant Jain Date: Wed, 1 Nov 2023 22:17:12 +0530 Subject: [PATCH] chore: comments addressed+2 --- src/v0/destinations/am/transform.js | 4 +++- test/__tests__/data/am_input.json | 4 +--- test/__tests__/data/am_output.json | 9 +++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/v0/destinations/am/transform.js b/src/v0/destinations/am/transform.js index c14e17d3ab..9babaff22b 100644 --- a/src/v0/destinations/am/transform.js +++ b/src/v0/destinations/am/transform.js @@ -612,7 +612,9 @@ const processSingleMessage = (message, destination) => { .trim() .replaceAll(/{{([^{}]+)}}/g, get(message, getMessagePath)); } else { - evType = `Viewed ${name || get(message, CATEGORY_KEY) || ''} Page`; + const updatedName = + name || get(message, CATEGORY_KEY) ? `${name || get(message, CATEGORY_KEY)} ` : undefined; + evType = `Viewed ${updatedName || ''}Page`; } message.properties = { diff --git a/test/__tests__/data/am_input.json b/test/__tests__/data/am_input.json index 01cd5d0a92..3e5cde2cca 100644 --- a/test/__tests__/data/am_input.json +++ b/test/__tests__/data/am_input.json @@ -4824,7 +4824,6 @@ "search": "", "title": "", "url": "https://docs.rudderstack.com/destinations/amplitude", - "category": "destination", "initial_referrer": "https://docs.rudderstack.com", "initial_referring_domain": "docs.rudderstack.com" }, @@ -4834,13 +4833,12 @@ "event_id": 2 } }, - "name": "ApplicationLoaded", "sentAt": "2019-10-14T11:15:53.296Z" }, "destination": { "Config": { "apiKey": "abcde", - "useUserDefinedPageEventName": true, + "useUserDefinedPageEventName": false, "userProvidedPageEventString": "Viewed {{context.page.title}} event." } } diff --git a/test/__tests__/data/am_output.json b/test/__tests__/data/am_output.json index de2709f150..34471f4922 100644 --- a/test/__tests__/data/am_output.json +++ b/test/__tests__/data/am_output.json @@ -3937,8 +3937,7 @@ "app_version": "1.2", "platform": "Android", "language": "en-US", - "event_properties": { - }, + "event_properties": {}, "insert_id": "1662393883248-509420bf-b812-4f8d-bdb2-8c811bfde87f", "user_properties": { "anonymousId": "5d205961641ee6c5", @@ -4277,17 +4276,15 @@ "app_name": "RudderLabs JavaScript SDK", "app_version": "1.0.0", "language": "en-US", - "event_type": "Viewed Home Page event.", + "event_type": "Viewed Page", "event_properties": { "path": "/destinations/amplitude", "referrer": "", "search": "", "title": "", "url": "https://docs.rudderstack.com/destinations/amplitude", - "category": "destination", "initial_referrer": "https://docs.rudderstack.com", - "initial_referring_domain": "docs.rudderstack.com", - "name": "ApplicationLoaded" + "initial_referring_domain": "docs.rudderstack.com" }, "session_id": -1, "insert_id": "5e10d13a-bf9a-44bf-b884-43a9e591ea71",