Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from prebid:master #16

Merged
merged 6 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 31 additions & 22 deletions modules/automatadAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { config } from '../src/config.js'
const ADAPTER_CODE = 'automatadAnalytics'
const trialCountMilsMapping = [1500, 3000, 5000, 10000];

var isLoggingEnabled; var queuePointer = 0; var retryCount = 0; var timer = null; var __atmtdAnalyticsQueue = [];
var isLoggingEnabled; var queuePointer = 0; var retryCount = 0; var timer = null; var __atmtdAnalyticsQueue = []; var qBeingUsed; var qTraversalComplete;

const prettyLog = (level, text, isGroup = false, cb = () => {}) => {
if (self.isLoggingEnabled === undefined) {
Expand Down Expand Up @@ -134,6 +134,9 @@ const processEvents = () => {
if (trialCountMilsMapping[self.retryCount]) self.prettyLog('warn', `Adapter failed to process event as aggregator has not loaded. Retrying in ${trialCountMilsMapping[self.retryCount]}ms ...`);
setTimeout(self.processEvents, trialCountMilsMapping[self.retryCount])
self.retryCount = self.retryCount + 1
} else {
self.qBeingUsed = false
self.qTraversalComplete = true
}
}

Expand All @@ -142,22 +145,18 @@ const addGPTHandlers = () => {
googletag.cmd = googletag.cmd || []
googletag.cmd.push(() => {
googletag.pubads().addEventListener('slotRenderEnded', (event) => {
if (window.atmtdAnalytics && window.atmtdAnalytics.slotRenderEndedGPTHandler) {
if (window.__atmtdAggregatorFirstAuctionInitialized === true) {
window.atmtdAnalytics.slotRenderEndedGPTHandler(event)
return;
}
if (window.atmtdAnalytics && window.atmtdAnalytics.slotRenderEndedGPTHandler && !self.qBeingUsed) {
window.atmtdAnalytics.slotRenderEndedGPTHandler(event)
return;
}
self.__atmtdAnalyticsQueue.push(['slotRenderEnded', event])
self.prettyLog(`warn`, `Aggregator not initialised at auctionInit, exiting slotRenderEnded handler and pushing to que instead`)
})

googletag.pubads().addEventListener('impressionViewable', (event) => {
if (window.atmtdAnalytics && window.atmtdAnalytics.impressionViewableHandler) {
if (window.__atmtdAggregatorFirstAuctionInitialized === true) {
window.atmtdAnalytics.impressionViewableHandler(event)
return;
}
if (window.atmtdAnalytics && window.atmtdAnalytics.impressionViewableHandler && !self.qBeingUsed) {
window.atmtdAnalytics.impressionViewableHandler(event)
return;
}
self.__atmtdAnalyticsQueue.push(['impressionViewable', event])
self.prettyLog(`warn`, `Aggregator not initialised at auctionInit, exiting impressionViewable handler and pushing to que instead`)
Expand All @@ -167,6 +166,7 @@ const addGPTHandlers = () => {

const initializeQueue = () => {
self.__atmtdAnalyticsQueue.push = (args) => {
self.qBeingUsed = true
Array.prototype.push.apply(self.__atmtdAnalyticsQueue, [args]);
if (timer) {
clearTimeout(timer);
Expand Down Expand Up @@ -196,9 +196,10 @@ let atmtdAdapter = Object.assign({}, baseAdapter, {
},

track({eventType, args}) {
const shouldNotPushToQueue = !self.qBeingUsed
switch (eventType) {
case CONSTANTS.EVENTS.AUCTION_INIT:
if (window.atmtdAnalytics && window.atmtdAnalytics.auctionInitHandler) {
if (window.atmtdAnalytics && window.atmtdAnalytics.auctionInitHandler && shouldNotPushToQueue) {
self.prettyLog('status', 'Aggregator loaded, initialising auction through handlers');
window.atmtdAnalytics.auctionInitHandler(args);
} else {
Expand All @@ -207,63 +208,63 @@ let atmtdAdapter = Object.assign({}, baseAdapter, {
}
break;
case CONSTANTS.EVENTS.BID_REQUESTED:
if (window.atmtdAnalytics && window.atmtdAnalytics.bidRequestedHandler) {
if (window.atmtdAnalytics && window.atmtdAnalytics.bidRequestedHandler && shouldNotPushToQueue) {
window.atmtdAnalytics.bidRequestedHandler(args);
} else {
self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`);
self.__atmtdAnalyticsQueue.push([eventType, args])
}
break;
case CONSTANTS.EVENTS.BID_REJECTED:
if (window.atmtdAnalytics && window.atmtdAnalytics.bidRejectedHandler) {
if (window.atmtdAnalytics && window.atmtdAnalytics.bidRejectedHandler && shouldNotPushToQueue) {
window.atmtdAnalytics.bidRejectedHandler(args);
} else {
self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`);
self.__atmtdAnalyticsQueue.push([eventType, args])
}
break;
case CONSTANTS.EVENTS.BID_RESPONSE:
if (window.atmtdAnalytics && window.atmtdAnalytics.bidResponseHandler) {
if (window.atmtdAnalytics && window.atmtdAnalytics.bidResponseHandler && shouldNotPushToQueue) {
window.atmtdAnalytics.bidResponseHandler(args);
} else {
self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`);
self.__atmtdAnalyticsQueue.push([eventType, args])
}
break;
case CONSTANTS.EVENTS.BIDDER_DONE:
if (window.atmtdAnalytics && window.atmtdAnalytics.bidderDoneHandler) {
if (window.atmtdAnalytics && window.atmtdAnalytics.bidderDoneHandler && shouldNotPushToQueue) {
window.atmtdAnalytics.bidderDoneHandler(args);
} else {
self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`);
self.__atmtdAnalyticsQueue.push([eventType, args])
}
break;
case CONSTANTS.EVENTS.BID_WON:
if (window.atmtdAnalytics && window.atmtdAnalytics.bidWonHandler) {
if (window.atmtdAnalytics && window.atmtdAnalytics.bidWonHandler && shouldNotPushToQueue) {
window.atmtdAnalytics.bidWonHandler(args);
} else {
self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`);
self.__atmtdAnalyticsQueue.push([eventType, args])
}
break;
case CONSTANTS.EVENTS.NO_BID:
if (window.atmtdAnalytics && window.atmtdAnalytics.noBidHandler) {
if (window.atmtdAnalytics && window.atmtdAnalytics.noBidHandler && shouldNotPushToQueue) {
window.atmtdAnalytics.noBidHandler(args);
} else {
self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`);
self.__atmtdAnalyticsQueue.push([eventType, args])
}
break;
case CONSTANTS.EVENTS.AUCTION_DEBUG:
if (window.atmtdAnalytics && window.atmtdAnalytics.auctionDebugHandler) {
if (window.atmtdAnalytics && window.atmtdAnalytics.auctionDebugHandler && shouldNotPushToQueue) {
window.atmtdAnalytics.auctionDebugHandler(args);
} else {
self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`);
self.__atmtdAnalyticsQueue.push([eventType, args])
}
break;
case CONSTANTS.EVENTS.BID_TIMEOUT:
if (window.atmtdAnalytics && window.atmtdAnalytics.bidderTimeoutHandler) {
if (window.atmtdAnalytics && window.atmtdAnalytics.bidderTimeoutHandler && shouldNotPushToQueue) {
window.atmtdAnalytics.bidderTimeoutHandler(args);
} else {
self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`);
Expand Down Expand Up @@ -304,7 +305,7 @@ atmtdAdapter.enableAnalytics = function (configuration) {
atmtdAdapter.originEnableAnalytics(configuration)
};

/// /////////// ADAPTER REGISTRATION //////////////
/// /////////// ADAPTER REGISTRATION /////////////

adapterManager.registerAnalyticsAdapter({
adapter: atmtdAdapter,
Expand All @@ -319,7 +320,15 @@ export var self = {
prettyLog,
queuePointer,
retryCount,
isLoggingEnabled
isLoggingEnabled,
qBeingUsed,
qTraversalComplete
}

window.__atmtdAnalyticsGlobalObject = {
q: self.__atmtdAnalyticsQueue,
qBeingUsed: self.qBeingUsed,
qTraversalComplete: self.qTraversalComplete
}

export default atmtdAdapter;
38 changes: 25 additions & 13 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { _each, isEmpty, buildUrl, deepAccess, pick, triggerPixel } from '../src/utils.js';
import { _each, isEmpty, buildUrl, deepAccess, pick, triggerPixel, logError } from '../src/utils.js';
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { getStorageManager } from '../src/storageManager.js';
Expand Down Expand Up @@ -221,7 +221,7 @@ function interpretResponse(response, bidRequest) {
width: adUnit.width,
height: adUnit.height,
ttl: 300,
creativeId: adUnit.id,
creativeId: adUnit.creativeID,
dealId: adUnit.targetingCustom,
netRevenue: true,
currency: adUnit.currency || bidRequest.currency,
Expand Down Expand Up @@ -459,10 +459,6 @@ function getImpression(bid) {
code: bid.adUnitCode
};

if (bid.floorData != null && bid.floorData.floorMin > 0) {
imp.floor = bid.floorData.floorMin;
}

if (bid.bidRequestsCount > 0) {
imp.bidRequestCount = bid.bidRequestsCount;
}
Expand All @@ -482,17 +478,33 @@ function getImpression(bid) {
}
}

if (bid.mediaTypes != null) {
if (bid.mediaTypes.banner != null) {
imp.banner = bid.mediaTypes.banner;
if (bid.mediaTypes) {
const { banner, video, native } = bid.mediaTypes;

if (banner) {
imp.banner = banner;
}

if (bid.mediaTypes.video != null) {
imp.video = bid.mediaTypes.video;
if (video) {
imp.video = video;
}

if (bid.mediaTypes.native != null) {
imp.native = bid.mediaTypes.native;
if (native) {
imp.native = native;
}

if (typeof bid.getFloor === 'function') {
let floorInfo;
try {
floorInfo = bid.getFloor({
currency: 'USD',
mediaType: '*',
size: '*'
});
} catch (e) {
logError('Kargo: getFloor threw an error: ', e);
}
imp.floor = typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseInt(floorInfo.floor)) ? floorInfo.floor : undefined;
}
}

Expand Down
3 changes: 2 additions & 1 deletion modules/onetagBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ function buildRequests(validBidRequests, bidderRequest) {
if (bidderRequest && bidderRequest.gdprConsent) {
payload.gdprConsent = {
consentString: bidderRequest.gdprConsent.consentString,
consentRequired: bidderRequest.gdprConsent.gdprApplies
consentRequired: bidderRequest.gdprConsent.gdprApplies,
addtlConsent: bidderRequest.gdprConsent.addtlConsent
};
}
if (bidderRequest && bidderRequest.gppConsent) {
Expand Down
9 changes: 7 additions & 2 deletions modules/pubmaticAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function parseBidResponse(bid) {
'cpm', () => window.parseFloat(Number(bid.cpm).toFixed(BID_PRECISION)),
'originalCpm', () => window.parseFloat(Number(bid.originalCpm).toFixed(BID_PRECISION)),
'originalCurrency',
'adserverTargeting',
'dealChannel',
'meta',
'status',
Expand Down Expand Up @@ -278,6 +279,7 @@ function gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestBid) {
if (isOWPubmaticBid(adapterName) && isS2SBidder(bid.bidder)) {
return;
}
const pg = window.parseFloat(Number(bid.bidResponse?.adserverTargeting?.hb_pb || bid.bidResponse?.adserverTargeting?.pwtpb).toFixed(BID_PRECISION));
partnerBids.push({
'pn': adapterName,
'bc': bid.bidderCode || bid.bidder,
Expand All @@ -303,7 +305,8 @@ function gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestBid) {
'ocry': bid.bidResponse ? (bid.bidResponse.originalCurrency || CURRENCY_USD) : CURRENCY_USD,
'piid': bid.bidResponse ? (bid.bidResponse.partnerImpId || EMPTY_STRING) : EMPTY_STRING,
'frv': bid.bidResponse ? bid.bidResponse.floorData?.floorRuleValue : undefined,
'md': bid.bidResponse ? getMetadata(bid.bidResponse.meta) : undefined
'md': bid.bidResponse ? getMetadata(bid.bidResponse.meta) : undefined,
'pb': pg || undefined
});
});
return partnerBids;
Expand Down Expand Up @@ -457,8 +460,9 @@ function executeBidWonLoggerCall(auctionId, adUnitId) {
let referrer = config.getConfig('pageUrl') || cache.auctions[auctionId].referer || '';
let adv = winningBid.bidResponse ? getAdDomain(winningBid.bidResponse) || undefined : undefined;
let fskp = floorData ? (floorData.floorRequestData ? (floorData.floorRequestData.skipped == false ? 0 : 1) : undefined) : undefined;

let pg = window.parseFloat(Number(winningBid?.bidResponse?.adserverTargeting?.hb_pb || winningBid?.bidResponse?.adserverTargeting?.pwtpb)) || undefined;
let pixelURL = END_POINT_WIN_BID_LOGGER;

pixelURL += 'pubid=' + publisherId;
pixelURL += '&purl=' + enc(config.getConfig('pageUrl') || cache.auctions[auctionId].referer || '');
pixelURL += '&tst=' + Math.round((new window.Date()).getTime() / 1000);
Expand All @@ -475,6 +479,7 @@ function executeBidWonLoggerCall(auctionId, adUnitId) {
pixelURL += '&kgpv=' + enc(getValueForKgpv(winningBid, adUnitId));
pixelURL += '&piid=' + enc(winningBid.bidResponse.partnerImpId || EMPTY_STRING);
pixelURL += '&di=' + enc(winningBid?.bidResponse?.dealId || OPEN_AUCTION_DEAL_ID);
pixelURL += '&pb=' + enc(pg);

pixelURL += '&plt=' + enc(getDevicePlatform());
pixelURL += '&psz=' + enc((winningBid?.bidResponse?.dimensions?.width || '0') + 'x' +
Expand Down
12 changes: 10 additions & 2 deletions modules/smartyadsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ function getAdUrlByRegion(bid) {
try {
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const region = timezone.split('/')[0];
if (region === 'Europe') adUrl = adUrls['EU'];
else adUrl = adUrls['US_EAST'];

switch (region) {
case 'Europe':
adUrl = adUrls['EU'];
break;
case 'Asia':
adUrl = adUrls['SGP'];
break;
default: adUrl = adUrls['US_EAST'];
}
} catch (err) {
adUrl = adUrls['US_EAST'];
}
Expand Down
2 changes: 1 addition & 1 deletion modules/taboolaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export const spec = {
},

onBidderError: ({ error, bidderRequest }) => {
ajax(EVENT_ENDPOINT + '/bidError', null, JSON.stringify(error, bidderRequest), {method: 'POST'});
ajax(EVENT_ENDPOINT + '/bidError', null, JSON.stringify({error, bidderRequest}), {method: 'POST'});
},
};

Expand Down
Loading