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

AdagioAnalyticsAdapter: track revelant ad-units only #12383

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion modules/adagioAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const cache = {
return { auctionId: null, adUnitCode: null }
}
};

const enc = window.encodeURIComponent;

/**
Expand Down Expand Up @@ -195,7 +196,14 @@ function handlerAuctionInit(event) {
const w = getBestWindowForAdagio();

const prebidAuctionId = event.auctionId;
const adUnitCodes = removeDuplicates(event.adUnitCodes, adUnitCode => adUnitCode);

// adUnitCodes come from `event.bidderRequests` to be sure to keep the ad-units that are valid and will be effectively used during the auction.
// This array can be different than `event.adUnitCodes` because of the usage of conditionnal ad-units (see: https://docs.prebid.org/dev-docs/conditional-ad-units.html)
const adUnitCodes = new Set(
event.bidderRequests
.map(br => br.bids.map(bid => bid.adUnitCode))
.flat()
);

// Check if Adagio is on the bid requests.
const adagioBidRequest = event.bidderRequests.find(bidRequest => isAdagio(bidRequest.bidderCode));
Expand All @@ -207,6 +215,7 @@ function handlerAuctionInit(event) {

adUnitCodes.forEach(adUnitCode => {
// event.adUnits are splitted by mediatypes
// having twin ad-unit codes is ok: https://docs.prebid.org/dev-docs/adunit-reference.html#twin-adunit-codes
const adUnits = event.adUnits.filter(adUnit => adUnit.code === adUnitCode);

// Get all bidders configured for the ad unit.
Expand Down Expand Up @@ -236,6 +245,7 @@ function handlerAuctionInit(event) {
const request = event.bidderRequests.find(br => br.bidderCode === bidder)
return request ? request.bids[0].src : null
}

const biddersSrc = sortedBidderNames.map(bidSrcMapper).join(',');
const biddersCode = sortedBidderNames.map(bidder => adapterManager.resolveAlias(bidder)).join(',');

Expand Down
287 changes: 169 additions & 118 deletions test/spec/modules/adagioAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,141 +287,192 @@ const AUCTION_INIT_ANOTHER = {
},
} ],
'adUnitCodes': ['/19968336/header-bid-tag-1', '/19968336/footer-bid-tag-1'],
'bidderRequests': [ {
'bidderCode': 'another',
'auctionId': AUCTION_ID,
'bidderRequestId': '1be65d7958826a',
'bids': [ {
'bidder': 'another',
'params': {
'publisherId': '1001',
},
'mediaTypes': {
'banner': {
'sizes': [[640, 480]]
}
},
'adUnitCode': '/19968336/header-bid-tag-1',
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
'bidderRequests': [
{
'bidderCode': 'another',
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
}, {
'bidder': 'another',
'params': {
'publisherId': '1001'
'bidderRequestId': '1be65d7958826a',
'bids': [
{
'bidder': 'another',
'params': {
'publisherId': '1001',
},
'mediaTypes': {
'banner': {
'sizes': [[640, 480]]
}
},
'adUnitCode': '/19968336/header-bid-tag-1',
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
},
{
'bidder': 'another',
'params': {
'publisherId': '1001'
},
'mediaTypes': {
'banner': {
'sizes': [[640, 480]]
}
},
'adUnitCode': '/19968336/footer-bid-tag-1',
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
},
],
'timeout': 3000,
'refererInfo': {
'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
},
'mediaTypes': {
'banner': {
'sizes': [[640, 480]]
'ortb2': {
'site': {
'ext': {
'data': {
'adg_rtd': {
...ADG_RTD
},
...ORTB_DATA
}
}
}
},
'adUnitCode': '/19968336/footer-bid-tag-1',
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
}
},
{
'bidderCode': 'nobid',
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
}, {
'bidder': 'nobid',
'params': {
'publisherId': '1001'
'bidderRequestId': '1be65d7958826a',
'bids': [{
'bidder': 'nobid',
'params': {
'publisherId': '1001'
},
'mediaTypes': {
'banner': {
'sizes': [[640, 480]]
}
},
'adUnitCode': '/19968336/header-bid-tag-1',
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
}
],
'timeout': 3000,
'refererInfo': {
'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
},
'mediaTypes': {
'banner': {
'sizes': [[640, 480]]
'ortb2': {
'site': {
'ext': {
'data': {
'adg_rtd': {
...ADG_RTD
},
...ORTB_DATA
}
}
}
},
'adUnitCode': '/19968336/footer-bid-tag-1',
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
}
},
{
bidderCode: 'anotherWithAlias',
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
}, {
'bidder': 'anotherWithAlias',
'params': {
'publisherId': '1001',
'bidderRequestId': '1be65d7958826a',
'bids': [
{
'bidder': 'anotherWithAlias',
'params': {
'publisherId': '1001',
},
'mediaTypes': {
'banner': {
'sizes': [[640, 480]]
}
},
'adUnitCode': '/19968336/header-bid-tag-1',
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
},
],
'timeout': 3000,
'refererInfo': {
'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
},
'mediaTypes': {
'banner': {
'sizes': [[640, 480]]
'ortb2': {
'site': {
'ext': {
'data': {
'adg_rtd': {
...ADG_RTD
},
...ORTB_DATA
}
}
}
},
'adUnitCode': '/19968336/header-bid-tag-1',
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
},
],
'timeout': 3000,
'refererInfo': {
'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
}
},
'ortb2': {
'site': {
'ext': {
'data': {
'adg_rtd': {
...ADG_RTD
},
...ORTB_DATA
{
'bidderCode': 'adagio',
'auctionId': AUCTION_ID,
'bidderRequestId': '1be65d7958826a',
'bids': [ {
'bidder': 'adagio',
'params': {
...PARAMS_ADG
},
'mediaTypes': {
'banner': {
'sizes': [[640, 480]]
}
}
},
'adUnitCode': '/19968336/header-bid-tag-1',
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
}
}
}, {
'bidderCode': 'adagio',
'auctionId': AUCTION_ID,
'bidderRequestId': '1be65d7958826a',
'bids': [ {
'bidder': 'adagio',
'params': {
...PARAMS_ADG
],
'timeout': 3000,
'refererInfo': {
'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
},
'mediaTypes': {
'banner': {
'sizes': [[640, 480]]
}
},
'adUnitCode': '/19968336/header-bid-tag-1',
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
}
],
'timeout': 3000,
'refererInfo': {
'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html']
},
'ortb2': {
'site': {
'ext': {
'data': {
'adg_rtd': {
...ADG_RTD
},
...ORTB_DATA
'ortb2': {
'site': {
'ext': {
'data': {
'adg_rtd': {
...ADG_RTD
},
...ORTB_DATA
}
}
}
}
}
}
],
'bidsReceived': [],
'winningBids': [],
Expand Down