Skip to content

Commit

Permalink
Merge branch 'develop' into feat.cm360-proxyV1
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik authored Nov 30, 2023
2 parents db59918 + 571dbf5 commit d126f95
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/v0/destinations/adobe_analytics/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const responseBuilderSimple = async (message, destinationConfig, basicPayload) =
}
payload.linkURL =
adobeIntegrationsObject?.linkURL || context?.page?.url || 'No linkURL provided';
payload.linkURL = encodeURI(payload.linkURL);
}
// handle hier
if (overrideHiers) {
Expand All @@ -97,7 +98,7 @@ const responseBuilderSimple = async (message, destinationConfig, basicPayload) =
const propertiesPageUrl = properties?.pageUrl;
const pageUrl = contextPageUrl || propertiesPageUrl;
if (isDefinedAndNotNullAndNotEmpty(pageUrl)) {
payload.pageUrl = pageUrl;
payload.pageUrl = encodeURI(pageUrl);
}
if (trackPageName) {
// better handling possible here, both error and implementation wise
Expand Down
26 changes: 23 additions & 3 deletions src/v0/destinations/adobe_analytics/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ function handleContextData(payload, destinationConfig, message) {
return payload;
}

/**
* This function is used for replacing '&', '<' and '>' with their respective HTML entities
* @param {*} inputString
* @returns string with HTML entities replaced
*
*/

function escapeToHTML(inputString) {
return inputString.replace(
/[&<>]/g,
(match) =>
({
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
}[match]),
);
}

/**
* This function is used for populating the eVars and hVars in the payload
* @param {*} destVarMapping
Expand All @@ -90,16 +109,16 @@ function rudderPropToDestMap(destVarMapping, message, payload, destVarStrPrefix)
let val = get(message, `properties.${key}`);
if (isDefinedAndNotNull(val)) {
const destVarKey = destVarStrPrefix + destVarMapping[key];
mappedVar[destVarKey] = val;
mappedVar[destVarKey] = escapeToHTML(val);
} else {
SOURCE_KEYS.some((sourceKey) => {
val = getMappingFieldValueFormMessage(message, sourceKey, key);
if (isDefinedAndNotNull(val)) {
mappedVar[`${destVarStrPrefix}${[destVarMapping[key]]}`] = val;
mappedVar[`${destVarStrPrefix}${[destVarMapping[key]]}`] = escapeToHTML(val);
} else {
val = getValueByPath(message, key);
if (isDefinedAndNotNull(val)) {
mappedVar[`${destVarStrPrefix}${[destVarMapping[key]]}`] = val;
mappedVar[`${destVarStrPrefix}${[destVarMapping[key]]}`] = escapeToHTML(val);
}
}
});
Expand Down Expand Up @@ -200,4 +219,5 @@ module.exports = {
handleList,
handleCustomProperties,
stringifyValueAndJoinWithDelimiter,
escapeToHTML,
};
47 changes: 24 additions & 23 deletions test/integrations/destinations/adobe_analytics/processor/data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const data = [
{
name: 'adobe_analytics',
description: 'Test 0',
description: 'Test 0: [ECom]: Product Viewed',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -31,7 +31,7 @@ export const data = [
referring_domain: 'google.com',
search: 'estore bestseller',
title: 'The best sellers offered by EStore',
url: 'https://www.estore.com/best-seller/1',
url: 'https://www.estore.com/best-seller/News & Sports?ik=123&ij=456',
name: 'Best Seller',
},
screen: {
Expand Down Expand Up @@ -61,7 +61,7 @@ export const data = [
coupon: 'DISC21',
currency: 'USD',
position: 1,
url: 'https://www.website.com/product/path',
url: 'https://www.website.com/product/path?ik=123&ij=456',
image_url: 'https://www.website.com/product/path.png',
currencyMerch: 25,
addressMerch: 'Delhi',
Expand Down Expand Up @@ -170,7 +170,7 @@ export const data = [
JSON_ARRAY: {},
XML: {
payload:
'<?xml version="1.0" encoding="utf-8"?><request><browserHeight>1794</browserHeight><browserWidth>1080</browserWidth><campaign>sales campaign</campaign><channel>web</channel><currencyCode>USD</currencyCode><ipaddress>127.0.0.1</ipaddress><language>en-US</language><userAgent>Dalvik/2.1.0 (Linux; U; Android 9; Android SDK built for x86 Build/PSR1.180720.075)</userAgent><referrer>https://www.google.com/search?q=estore+bestseller</referrer><contextData><tt01>t01</tt01><tt02>t02</tt02><roott01>roottval001</roott01></contextData><eVar5>Kolkata</eVar5><eVar4>9935400932</eVar4><eVar6>RudderLabs JavaScript SDK</eVar6><list1>r15,faze90R</list1><list2>ciaz,hummer,thar</list2><pageUrl>https://www.estore.com/best-seller/1</pageUrl><pageName>Best Seller</pageName><prop1>custompropval1</prop1><prop2>custompropval2</prop2><timestamp>2020-01-09T10:01:53.558Z</timestamp><marketingcloudorgid>mktcloudid001</marketingcloudorgid><events>prodView</events><products>Games;Game;11;148.39</products><reportSuiteID>footlockerrudderstackpoc</reportSuiteID></request>',
'<?xml version="1.0" encoding="utf-8"?><request><browserHeight>1794</browserHeight><browserWidth>1080</browserWidth><campaign>sales campaign</campaign><channel>web</channel><currencyCode>USD</currencyCode><ipaddress>127.0.0.1</ipaddress><language>en-US</language><userAgent>Dalvik/2.1.0 (Linux; U; Android 9; Android SDK built for x86 Build/PSR1.180720.075)</userAgent><referrer>https://www.google.com/search?q=estore+bestseller</referrer><contextData><tt01>t01</tt01><tt02>t02</tt02><roott01>roottval001</roott01></contextData><eVar5>Kolkata</eVar5><eVar4>9935400932</eVar4><eVar6>RudderLabs JavaScript SDK</eVar6><list1>r15,faze90R</list1><list2>ciaz,hummer,thar</list2><pageUrl>https://www.estore.com/best-seller/News%20&%20Sports?ik=123&ij=456</pageUrl><pageName>Best Seller</pageName><prop1>custompropval1</prop1><prop2>custompropval2</prop2><timestamp>2020-01-09T10:01:53.558Z</timestamp><marketingcloudorgid>mktcloudid001</marketingcloudorgid><events>prodView</events><products>Games;Game;11;148.39</products><reportSuiteID>footlockerrudderstackpoc</reportSuiteID></request>',
},
FORM: {},
},
Expand All @@ -185,7 +185,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 1',
description: 'Test 1: [ECom]: Product Added',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -356,7 +356,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 2',
description: 'Test 2: [ECom]: Product Removed',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -527,7 +527,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 3',
description: 'Test 3: [ECom]: Cart Viewed',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -708,7 +708,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 4',
description: 'Test 4: [ECom]: Checkout started',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -896,7 +896,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 5',
description: 'Test 5: [ECom]: Order Completed',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -1085,7 +1085,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 6',
description: 'Test 6: Cart Opened',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -1265,7 +1265,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 7',
description: 'Test 7: [Custom] Watched Video',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand All @@ -1285,7 +1285,7 @@ export const data = [
term: 'event data',
content: 'Make sense of the modern data stack',
},
library: { name: 'RudderLabs JavaScript SDK', version: '2.9.1' },
library: { name: 'RudderLabs JavaScript SDK <Custom>', version: '2.9.1' },
locale: 'en-US',
page: {
path: '/best-seller/1',
Expand All @@ -1311,7 +1311,7 @@ export const data = [
traits: { roott01: 'roottval001' },
event: 'Watched Video',
integrations: { All: true },
properties: { plan: 'growth', video: 'TEDxGROWTH' },
properties: { plan: 'growth', video: 'TEDxGROWTH&MARKETING' },
originalTimestamp: '2020-01-09T10:01:53.558Z',
type: 'track',
sentAt: '2020-01-09T10:02:03.257Z',
Expand Down Expand Up @@ -1412,7 +1412,7 @@ export const data = [
JSON_ARRAY: {},
XML: {
payload:
'<?xml version="1.0" encoding="utf-8"?><request><browserHeight>1794</browserHeight><browserWidth>1080</browserWidth><campaign>sales campaign</campaign><channel>web</channel><ipaddress>127.0.0.1</ipaddress><language>en-US</language><userAgent>Dalvik/2.1.0 (Linux; U; Android 9; Android SDK built for x86 Build/PSR1.180720.075)</userAgent><referrer>https://www.google.com/search?q=estore+bestseller</referrer><contextData><roott01>roottval001</roott01></contextData><eVar6>RudderLabs JavaScript SDK</eVar6><eVar2>TEDxGROWTH</eVar2><linkType>o</linkType><linkName>Watched Video</linkName><linkURL>https://www.estore.com/best-seller/1</linkURL><prop2>growth</prop2><timestamp>2020-01-09T10:01:53.558Z</timestamp><marketingcloudorgid>mktcloudid001</marketingcloudorgid><events>event1</events><products/><reportSuiteID>footlockerrudderstackpoc</reportSuiteID></request>',
'<?xml version="1.0" encoding="utf-8"?><request><browserHeight>1794</browserHeight><browserWidth>1080</browserWidth><campaign>sales campaign</campaign><channel>web</channel><ipaddress>127.0.0.1</ipaddress><language>en-US</language><userAgent>Dalvik/2.1.0 (Linux; U; Android 9; Android SDK built for x86 Build/PSR1.180720.075)</userAgent><referrer>https://www.google.com/search?q=estore+bestseller</referrer><contextData><roott01>roottval001</roott01></contextData><eVar6>RudderLabs JavaScript SDK &lt;Custom&gt;</eVar6><eVar2>TEDxGROWTH&amp;MARKETING</eVar2><linkType>o</linkType><linkName>Watched Video</linkName><linkURL>https://www.estore.com/best-seller/1</linkURL><prop2>growth</prop2><timestamp>2020-01-09T10:01:53.558Z</timestamp><marketingcloudorgid>mktcloudid001</marketingcloudorgid><events>event1</events><products/><reportSuiteID>footlockerrudderstackpoc</reportSuiteID></request>',
},
FORM: {},
},
Expand All @@ -1427,7 +1427,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 8',
description: 'Test 8: Common Page Call',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -1597,7 +1597,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 9',
description: 'Test 9: Currency test event',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -1789,7 +1789,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 10',
description: 'Test 10: Override feature test',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -1988,7 +1988,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 11',
description: 'Test 11: Override hiers test',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -2188,7 +2188,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 12',
description: 'Test 12: product level eVaR',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -2390,7 +2390,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 13',
description: 'Test 13: [ERROR]: Invalid message type: Identify',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -2523,7 +2523,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 14',
description: 'Test 14: [ERROR]: Message Type is not present.',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -2697,7 +2697,8 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 15',
description:
'Test 15: [ERROR]: The event is not a supported ECOM event or a mapped custom event.',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -2872,7 +2873,7 @@ export const data = [
},
{
name: 'adobe_analytics',
description: 'Test 16',
description: 'Test 16: Test overrideEventName property',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down

0 comments on commit d126f95

Please sign in to comment.