Skip to content

Commit

Permalink
unload
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrmartinez committed Jan 19, 2023
1 parent b824499 commit 05fbb3f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions modules/magniteAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,25 @@ magniteAdapter.onDataDeletionRequest = function () {
}
};

// send a beacon to see how many times this happens
window.addEventListener("beforeunload", function () {
const pendingAuctions = Object.keys(cache.auctions).length;
const pendingEvents = Object.keys(cache.pendingEvents).length && Object.keys(cache.pendingEvents).reduce((accum, eventName) => {
accum[eventName] = cache.pendingEvents[eventName].length;
return accum;
}, {});

if (pendingAuctions || pendingEvents) {
const payload = {
auctions: pendingAuctions,
...pendingEvents,
...getTopLevelDetails(),
trigger: 'unload'
}
navigator.sendBeacon(endpoint, JSON.stringify(payload));
}
});

magniteAdapter.MODULE_INITIALIZED_TIME = Date.now();
magniteAdapter.referrerHostname = '';

Expand Down
19 changes: 19 additions & 0 deletions modules/rubiconAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,25 @@ magniteAdapter.onDataDeletionRequest = function () {
}
};

// send a beacon to see how many times this happens
window.addEventListener("beforeunload", function () {
const pendingAuctions = Object.keys(cache.auctions).length;
const pendingEvents = Object.keys(cache.pendingEvents).length && Object.keys(cache.pendingEvents).reduce((accum, eventName) => {
accum[eventName] = cache.pendingEvents[eventName].length;
return accum;
}, {});

if (pendingAuctions || pendingEvents) {
const payload = {
auctions: pendingAuctions,
...pendingEvents,
...getTopLevelDetails(),
trigger: 'unload'
}
navigator.sendBeacon(endpoint, JSON.stringify(payload));
}
});

magniteAdapter.MODULE_INITIALIZED_TIME = Date.now();
magniteAdapter.referrerHostname = '';

Expand Down

0 comments on commit 05fbb3f

Please sign in to comment.