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

Discovery Bid Adapter: add adUnitCode, gpid, and adslot #10615

Merged
merged 6 commits into from
Oct 27, 2023
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
59 changes: 59 additions & 0 deletions modules/discoveryBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,60 @@ const popInAdSize = [
{ w: 336, h: 280 },
];

/**
* get screen size
*
* @returns {Array} eg: "['widthxheight']"
*/
function getScreenSize() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have a parseSizesInput() utils function that would be more stable in the event multiple sizes are passed
https://github.com/prebid/Prebid.js/blob/master/src/utils.js#L136

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you for your suggestion, I used parseSizesInput utils function to handle ScreenSize. Could you please review it again? Thank you very much. 🙏 @ChrisHuie

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, The PR has passed all the tests, Could you please approve it? I'm very sorry for being so urgent, but it's really important to us. Thank you @ChrisHuie

return utils.parseSizesInput([window.screen.width, window.screen.height]);
}

/**
* @param {BidRequest} bidRequest
* @param bidderRequest
* @returns {string}
*/
function getReferrer(bidRequest = {}, bidderRequest = {}) {
let pageUrl;
if (bidRequest.params && bidRequest.params.referrer) {
pageUrl = bidRequest.params.referrer;
} else {
pageUrl = utils.deepAccess(bidderRequest, 'refererInfo.page');
}
return pageUrl;
}

/**
* format imp ad test ext params
*
* @param validBidRequest sigleBidRequest
* @param bidderRequest
*/
function addImpExtParams(bidRequest = {}, bidderRequest = {}) {
const { deepAccess } = utils;
const { params = {}, adUnitCode } = bidRequest;
const ext = {
adUnitCode: adUnitCode || '',
token: params.token || '',
siteId: params.siteId || '',
zoneId: params.zoneId || '',
publisher: params.publisher || '',
p_pos: params.position || '',
screenSize: getScreenSize(),
referrer: getReferrer(bidRequest, bidderRequest),
b_pos: deepAccess(bidRequest, 'mediaTypes.banner.pos', '', ''),
ortbUser: deepAccess(bidRequest, 'ortb2.user', {}, {}),
ortbSite: deepAccess(bidRequest, 'ortb2.site', {}, {}),
tid: deepAccess(bidRequest, 'ortb2Imp.ext.tid', '', ''),
browsiViewability: deepAccess(bidRequest, 'ortb2Imp.ext.data.browsi.browsiViewability', '', ''),
adserverName: deepAccess(bidRequest, 'ortb2Imp.ext.data.adserver.name', '', ''),
adslot: deepAccess(bidRequest, 'ortb2Imp.ext.data.adserver.adslot', '', ''),
gpid: deepAccess(bidRequest, 'ortb2Imp.ext.gpid', '', ''),
};
return ext;
}

/**
* get aditem setting
* @param {Array} validBidRequests an an array of bids
Expand Down Expand Up @@ -261,6 +315,11 @@ function getItems(validBidRequests, bidderRequest) {
tagid: req.params && req.params.tagid
};
}

try {
ret.ext = addImpExtParams(req, bidderRequest);
} catch (e) {}

itemMaps[id] = {
req,
ret,
Expand Down
40 changes: 40 additions & 0 deletions test/spec/modules/discoveryBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,51 @@ describe('discovery:BidAdapterTests', function () {
bidder: 'discovery',
params: {
token: 'd0f4902b616cc5c38cbe0a08676d0ed9',
siteId: 'siteId_01',
zoneId: 'zoneId_01',
publisher: '52',
position: 'left',
referrer: 'https://discovery.popin.cc',
},
refererInfo: {
page: 'https://discovery.popin.cc',
},
mediaTypes: {
banner: {
sizes: [[300, 250]],
pos: 'left',
},
},
ortb2: {
user: {
ext: {
data: {
CxSegments: []
}
}
},
site: {
domain: 'discovery.popin.cc',
publisher: {
domain: 'discovery.popin.cc'
},
page: 'https://discovery.popin.cc'
},
},
ortb2Imp: {
ext: {
gpid: 'adslot_gpid',
tid: 'tid_01',
data: {
browsi: {
browsiViewability: 'NA',
},
adserver: {
name: 'adserver_name',
adslot: 'adslot_name',
}
}
}
},
adUnitCode: 'regular_iframe',
transactionId: 'd163f9e2-7ecd-4c2c-a3bd-28ceb52a60ee',
Expand Down