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

NextMillennium Bid Adapter: Add referrer and imp to bid request #8718

Merged
merged 8 commits into from
Aug 9, 2022
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
23 changes: 21 additions & 2 deletions modules/nextMillenniumBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isStr, _each, parseUrl, getWindowTop, getBidIdParameter } from '../src/utils.js';
import { getRefererInfo } from '../src/refererDetection.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';

Expand All @@ -24,12 +25,18 @@ export const spec = {

_each(validBidRequests, function(bid) {
window.nmmRefreshCounts[bid.adUnitCode] = window.nmmRefreshCounts[bid.adUnitCode] || 0;
const id = getPlacementId(bid)

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': {
'prebid': {
'storedrequest': {
'id': getPlacementId(bid)
'id': id
}
},

Expand All @@ -39,7 +46,19 @@ export const spec = {
'scrollTop': window.pageYOffset || document.documentElement.scrollTop
}
},
...bid.ortb2
...bid.ortb2,
'imp': [{
'banner': {
'format': (bid.sizes || []).map(s => { return {w: s[0], h: s[1]} })
},
'ext': {
'prebid': {
'storedrequest': {
'id': id
}
}
}
}]
}

const gdprConsent = bidderRequest && bidderRequest.gdprConsent;
Expand Down
17 changes: 17 additions & 0 deletions test/spec/modules/nextMillenniumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ describe('nextMillenniumBidAdapterTests', function() {
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')
})

it('Check if imp prebid stored id is correct', function() {
const request = spec.buildRequests(bidRequestData)
const requestData = JSON.parse(request[0].data);
const storedReqId = requestData.ext.prebid.storedrequest.id;
expect(requestData.imp[0].ext.prebid.storedrequest.id).to.equal(storedReqId)
})

it('Test getUserSyncs function', function () {
const syncOptions = {
'iframeEnabled': true
Expand Down