Skip to content

Commit

Permalink
revert: fix: amplitude page and screen call containg double spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
anantjain45823 committed Nov 9, 2023
1 parent 30e9981 commit f651045
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
19 changes: 6 additions & 13 deletions src/v0/destinations/am/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/__tests__/data/am_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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": "",
Expand Down

0 comments on commit f651045

Please sign in to comment.