Skip to content

Commit

Permalink
NextMillenium Bid Adapter: Remove ortb2 referrerInfo (prebid#8868)
Browse files Browse the repository at this point in the history
* remove ortb2, get device/site manually

* updated tests

* remove fallbacks

* no need to craete variable if there is no fallback (return in place)

* removed one test case

Co-authored-by: Yakov Klein <[email protected]>
  • Loading branch information
JacobKlein26 and Yakov Klein committed Feb 8, 2023
1 parent 9cf49dd commit 0e5c43d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
31 changes: 25 additions & 6 deletions modules/nextMillenniumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ export const spec = {
_each(validBidRequests, function(bid) {
window.nmmRefreshCounts[bid.adUnitCode] = window.nmmRefreshCounts[bid.adUnitCode] || 0;
const id = getPlacementId(bid)
let sizes = bid.sizes
if (sizes && !Array.isArray(sizes[0])) sizes = [sizes]

const site = getSiteObj()
const device = getDeviceObj()

if (bid.sizes && !Array.isArray(bid.sizes[0])) bid.sizes = [bid.sizes]
if (!bid.ortb2) bid.ortb2 = {}
if (!bid.ortb2.device) bid.ortb2.device = {}
bid.ortb2.device.referrer = (getRefererInfo && getRefererInfo().ref) || ''
const postBody = {
'id': bid.auctionId,
'ext': {
Expand All @@ -46,10 +47,11 @@ export const spec = {
'scrollTop': window.pageYOffset || document.documentElement.scrollTop
}
},
...bid.ortb2,
device,
site,
'imp': [{
'banner': {
'format': (bid.sizes || []).map(s => { return {w: s[0], h: s[1]} })
'format': (sizes || []).map(s => { return {w: s[0], h: s[1]} })
},
'ext': {
'prebid': {
Expand Down Expand Up @@ -198,4 +200,21 @@ function getTopWindow(curWindow, nesting = 0) {
}
}

function getSiteObj() {
const refInfo = (getRefererInfo && getRefererInfo()) || {}

return {
page: refInfo.page,
ref: refInfo.ref,
domain: refInfo.domain
}
}

function getDeviceObj() {
return {
w: window.innerWidth || window.document.documentElement.clientWidth || window.document.body.clientWidth || 0,
h: window.innerHeight || window.document.documentElement.clientHeight || window.document.body.clientHeight || 0,
}
}

registerBidder(spec);
9 changes: 2 additions & 7 deletions test/spec/modules/nextMillenniumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,16 @@ describe('nextMillenniumBidAdapterTests', function() {
expect(JSON.parse(request[0].data).ext.nextMillennium.refresh_count).to.equal(3);
});

it('Check if ORTB was added', function() {
it('Check if domain was added', function() {
const request = spec.buildRequests(bidRequestData)
expect(JSON.parse(request[0].data).site.domain).to.equal('example.com')
expect(JSON.parse(request[0].data).site.domain).to.exist
})

it('Check if elOffsets was added', function() {
const request = spec.buildRequests(bidRequestData)
expect(JSON.parse(request[0].data).ext.nextMillennium.elOffsets).to.be.an('object')
})

it('Check if refferer was added', function() {
const request = spec.buildRequests(bidRequestData)
expect(JSON.parse(request[0].data).device.referrer).to.exist
})

it('Check if imp object was added', function() {
const request = spec.buildRequests(bidRequestData)
expect(JSON.parse(request[0].data).imp).to.be.an('array')
Expand Down

0 comments on commit 0e5c43d

Please sign in to comment.