From e44eaa506952927b868b85bf69d62651b547207f Mon Sep 17 00:00:00 2001 From: Marcin Komorski Date: Thu, 12 Sep 2024 15:57:27 +0200 Subject: [PATCH 1/3] #11838 send beacon fix --- modules/33acrossAnalyticsAdapter.js | 3 ++- modules/cwireBidAdapter.js | 5 +++-- modules/sirdataRtdProvider.js | 9 ++------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/modules/33acrossAnalyticsAdapter.js b/modules/33acrossAnalyticsAdapter.js index 1de986cd28e..9ffc8c2124f 100644 --- a/modules/33acrossAnalyticsAdapter.js +++ b/modules/33acrossAnalyticsAdapter.js @@ -5,6 +5,7 @@ import adapterManager, { coppaDataHandler, gdprDataHandler, gppDataHandler, uspD * @typedef {typeof import('../src/constants.js').EVENTS} EVENTS */ import { EVENTS } from '../src/constants.js'; +import { sendBeacon } from '../src/ajax.js'; /** @typedef {'pending'|'available'|'targetingSet'|'rendered'|'timeout'|'rejected'|'noBid'|'error'} BidStatus */ /** @@ -631,7 +632,7 @@ function setCachedBidStatus(auctionId, bidId, status) { function sendReport(report, endpoint) { // TODO FIX THIS RULES VIOLATION // eslint-disable-next-line - if (navigator.sendBeacon(endpoint, JSON.stringify(report))) { + if (sendBeacon(endpoint, JSON.stringify(report))) { log.info(`Analytics report sent to ${endpoint}`, report); return; diff --git a/modules/cwireBidAdapter.js b/modules/cwireBidAdapter.js index 6fbe401bfde..3515f0198b9 100644 --- a/modules/cwireBidAdapter.js +++ b/modules/cwireBidAdapter.js @@ -3,6 +3,7 @@ import {getStorageManager} from '../src/storageManager.js'; import {BANNER} from '../src/mediaTypes.js'; import {generateUUID, getParameterByName, isNumber, logError, logInfo} from '../src/utils.js'; import {hasPurpose1Consent} from '../src/utils/gdpr.js'; +import { sendBeacon } from '../src/ajax.js'; /** * @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest @@ -230,7 +231,7 @@ export const spec = { } // TODO FIX THIS RULES VIOLATION // eslint-disable-next-line prebid/no-member - navigator.sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) + sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) }, onBidderError: function (error, bidderRequest) { @@ -244,7 +245,7 @@ export const spec = { } // TODO FIX THIS RULES VIOLATION // eslint-disable-next-line prebid/no-member - navigator.sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) + sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) }, getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { diff --git a/modules/sirdataRtdProvider.js b/modules/sirdataRtdProvider.js index 507d8d982f2..129d708cf8f 100644 --- a/modules/sirdataRtdProvider.js +++ b/modules/sirdataRtdProvider.js @@ -8,7 +8,7 @@ * @requires module:modules/realTimeData */ import adapterManager from '../src/adapterManager.js'; -import { ajax } from '../src/ajax.js'; +import { ajax, sendBeacon } from '../src/ajax.js'; import { deepAccess, checkCookieSupport, deepSetValue, hasDeviceAccess, inIframe, isEmpty, logError, logInfo, mergeDeep @@ -217,12 +217,7 @@ export function postContentForSemanticAnalysis(postContentToken, actualUrl) { if (payload && payload.length > 300 && payload.length < 300000) { const url = `https://contextual.sirdata.io/api/v1/push/contextual?post_content_token=${postContentToken}&url=${encodeURIComponent(actualUrl)}`; - // Use the Beacon API if supported to send the payload - if ('sendBeacon' in navigator) { - // TODO FIX RULES VIOLATION - // eslint-disable-next-line prebid/no-member - navigator.sendBeacon(url, payload); - } else { + if (!sendBeacon(url, payload)) { // Fallback to using AJAX if Beacon API is not supported ajax(url, {}, payload, { contentType: 'text/plain', From e4091a640f7a1d2529fad91b4bab0d9996fc5c21 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Tue, 24 Sep 2024 15:48:09 -0400 Subject: [PATCH 2/3] Update cwireBidAdapter.js --- modules/cwireBidAdapter.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/cwireBidAdapter.js b/modules/cwireBidAdapter.js index 3515f0198b9..16370c6e911 100644 --- a/modules/cwireBidAdapter.js +++ b/modules/cwireBidAdapter.js @@ -229,8 +229,6 @@ export const spec = { bid: bid } } - // TODO FIX THIS RULES VIOLATION - // eslint-disable-next-line prebid/no-member sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) }, @@ -243,8 +241,6 @@ export const spec = { bidderRequest: bidderRequest } } - // TODO FIX THIS RULES VIOLATION - // eslint-disable-next-line prebid/no-member sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) }, From 29c8a42ac926dc2c2f6413fbd1ff53d1adcf41f9 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Tue, 24 Sep 2024 15:48:43 -0400 Subject: [PATCH 3/3] Update 33acrossAnalyticsAdapter.js --- modules/33acrossAnalyticsAdapter.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/33acrossAnalyticsAdapter.js b/modules/33acrossAnalyticsAdapter.js index 9ffc8c2124f..ec2e669be1a 100644 --- a/modules/33acrossAnalyticsAdapter.js +++ b/modules/33acrossAnalyticsAdapter.js @@ -630,8 +630,6 @@ function setCachedBidStatus(auctionId, bidId, status) { * @param {string} endpoint URL */ function sendReport(report, endpoint) { - // TODO FIX THIS RULES VIOLATION - // eslint-disable-next-line if (sendBeacon(endpoint, JSON.stringify(report))) { log.info(`Analytics report sent to ${endpoint}`, report);