Skip to content

Commit

Permalink
[Release] Stage to Main (#2153)
Browse files Browse the repository at this point in the history
* MWPW-146352 fix georouting dropdown on ios (#2143)

* MWPW-146491 Fast follow to add timeout value (#2155)

add timeout value

---------

Co-authored-by: Victor Hargrave <115231412+vhargrave@users.noreply.github.com>
Co-authored-by: Vivian A Goodrich <101133187+vgoodric@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 17, 2024
1 parent b74610d commit cb1c9a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion libs/features/georoutingv2/georoutingv2.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
}

.dialog-modal.locale-modal-v2 {
overflow: hidden;
overflow: visible;
font-family: 'Adobe Clean', adobe-clean, 'Trebuchet MS', sans-serif;
}

.dialog-modal.locale-modal-v2 .georouting-bg {
position: absolute;
overflow: hidden;
top: 0;
bottom: 0;
left: 0;
Expand Down
19 changes: 12 additions & 7 deletions libs/martech/martech.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,20 @@ const handleAlloyResponse = (response) => {
.filter(Boolean);
};

function roundToQuarter(num) {
return Math.ceil(num / 250) / 4;
}

function calculateResponseTime(responseStart) {
const responseTime = performance.now() - responseStart;
return Math.ceil(responseTime / 250) / 4;
return roundToQuarter(responseTime);
}

function sendTargetResponseAnalytics(failure, responseStart, message) {
function sendTargetResponseAnalytics(failure, responseStart, timeout, message) {
// temporary solution until we can decide on a better timeout value
const responseTime = calculateResponseTime(responseStart);
let val = `target response time ${responseTime}:timed out ${failure}`;
const timeoutTime = roundToQuarter(timeout);
let val = `target response time ${responseTime}:timed out ${failure}:timeout ${timeoutTime}`;
if (message) val += `:${message}`;
window.alloy('sendEvent', {
documentUnloading: true,
Expand Down Expand Up @@ -117,26 +122,26 @@ const getTargetPersonalization = async () => {

try {
response = await waitForEventOrTimeout(ALLOY_SEND_EVENT, timeout);
sendTargetResponseAnalytics(false, responseStart);
sendTargetResponseAnalytics(false, responseStart, timeout);
} catch (e) {
// eslint-disable-next-line no-console
console.log(e);
if (e.message.startsWith('Timeout waiting for alloy_sendEvent after')) {
const timer = setTimeout(() => {
// eslint-disable-next-line no-use-before-define
window.removeEventListener(ALLOY_SEND_EVENT, sendAnalytics);
sendTargetResponseAnalytics(true, responseStart);
sendTargetResponseAnalytics(true, responseStart, timeout);
}, 5100 - timeout);

// eslint-disable-next-line no-inner-declarations
function sendAnalytics() {
clearTimeout(timer);
sendTargetResponseAnalytics(true, responseStart);
sendTargetResponseAnalytics(true, responseStart, timeout);
}

window.addEventListener(ALLOY_SEND_EVENT, sendAnalytics, { once: true });
} else {
sendTargetResponseAnalytics(false, responseStart, e.message);
sendTargetResponseAnalytics(false, responseStart, timeout, e.message);
}
}

Expand Down

0 comments on commit cb1c9a9

Please sign in to comment.