Skip to content

Commit dfc738c

Browse files
author
Dereje Dilnesaw
committed
feat: add adobe specific reporting for martech optimization
1 parent 8485d99 commit dfc738c

File tree

1 file changed

+73
-3
lines changed

1 file changed

+73
-3
lines changed

src/support/slack/commands/martech-impact.js

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,68 @@ export function calculateColumnWidths(table, headers) {
6262
}, []);
6363
}
6464

65+
/**
66+
* Identifies Adobe Experience Cloud tools from third party summary
67+
* @param {Array<Object>} summary - The third party summary array
68+
* @returns {Object} Object containing identified Adobe tools
69+
*/
70+
export function identifyAdobeTools(summary = []) {
71+
const adobeTools = {
72+
hasLaunch: false,
73+
hasTarget: false,
74+
hasAnalytics: false,
75+
details: []
76+
};
77+
78+
summary.forEach((thirdParty) => {
79+
const { entity, blockingTime, mainThreadTime, transferSize } = thirdParty;
80+
const entityLower = entity.toLowerCase();
81+
82+
// Check for Adobe Launch/Tags
83+
if (entityLower.includes('launch.adobe.com') || entityLower.includes('assets.adobedtm.com')) {
84+
adobeTools.hasLaunch = true;
85+
adobeTools.details.push({ type: 'Adobe Launch/Tags', ...thirdParty });
86+
}
87+
88+
// Check for Adobe Target
89+
if (entityLower.includes('tt.omtrdc.net') || entityLower.includes('adobe target')) {
90+
adobeTools.hasTarget = true;
91+
adobeTools.details.push({ type: 'Adobe Target', ...thirdParty });
92+
}
93+
94+
// Check for Adobe Analytics
95+
if (entityLower.includes('.sc.omtrdc.net') || entityLower.includes('adobe analytics') || entityLower.includes('2o7.net') || entityLower.includes('omniture')) {
96+
adobeTools.hasAnalytics = true;
97+
adobeTools.details.push({ type: 'Adobe Analytics', ...thirdParty });
98+
}
99+
});
100+
101+
return adobeTools;
102+
}
103+
104+
/**
105+
* Formats Adobe Experience Cloud tools information
106+
* @param {Object} adobeTools - The Adobe tools object from identifyAdobeTools
107+
* @returns {string} Formatted string with Adobe tools information
108+
*/
109+
export function formatAdobeToolsInfo(adobeTools) {
110+
if (!adobeTools.details.length) {
111+
return '';
112+
}
113+
114+
const lines = ['\n*Adobe Experience Cloud Tools:*'];
115+
116+
adobeTools.details.forEach(({ type, entity, blockingTime, mainThreadTime, transferSize }) => {
117+
lines.push(`• *${type}*
118+
- Entity: ${entity}
119+
- Main Thread Time: ${Math.round(mainThreadTime)} ms
120+
- Blocking Time: ${Math.round(blockingTime)} ms
121+
- Transfer Size: ${formatSize(transferSize)}`);
122+
});
123+
124+
return `\n${lines.join('\n')}\n`;
125+
}
126+
65127
/**
66128
* Formats an array of third party sumary into a stringified table format.
67129
* If summary array is empty, it returns a fallback message. If the formatted
@@ -76,6 +138,9 @@ export function formatThirdPartySummary(summary = []) {
76138
return ' _No third party impact detected_';
77139
}
78140

141+
// First identify Adobe tools
142+
const adobeTools = identifyAdobeTools(summary);
143+
79144
const headers = ['Third Party', 'Main Thread', 'Blocking', 'Transfer'];
80145
const rows = summary.map((thirdParty) => {
81146
const {
@@ -94,9 +159,14 @@ export function formatThirdPartySummary(summary = []) {
94159
const columnWidths = calculateColumnWidths(table);
95160

96161
const formattedTable = `${BACKTICKS}\n${table.map((row) => formatRows(row, columnWidths)).join('\n')}\n${BACKTICKS}`;
97-
98-
// Ensure the formattedTable string does not exceed the Slack message character limit.
99-
return formattedTable.length > CHARACTER_LIMIT ? `${formattedTable.slice(0, CHARACTER_LIMIT - 3)}...` : formattedTable;
162+
163+
// Add Adobe tools specific information
164+
const adobeToolsInfo = formatAdobeToolsInfo(adobeTools);
165+
166+
const finalOutput = `${formattedTable}${adobeToolsInfo}`;
167+
168+
// Ensure the finalOutput string does not exceed the Slack message character limit.
169+
return finalOutput.length > CHARACTER_LIMIT ? `${finalOutput.slice(0, CHARACTER_LIMIT - 3)}...` : finalOutput;
100170
}
101171

102172
/**

0 commit comments

Comments
 (0)