Skip to content

Commit

Permalink
Mediasquare Bid Adapter: handle context for video bids (#10055)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieularere-msq authored Jun 7, 2023
1 parent d435b4e commit c6c9321
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 10 additions & 5 deletions modules/mediasquareBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export const spec = {
'advertiserDomains': value['adomain']
}
};
if ('context' in value) {
bidResponse['mediasquare']['context'] = value['context'];
}
if ('match' in value) {
bidResponse['mediasquare']['match'] = value['match'];
}
Expand Down Expand Up @@ -173,13 +176,15 @@ export const spec = {
// fires a pixel to confirm a winning bid
let params = { pbjs: '$prebid.version$', referer: encodeURIComponent(getRefererInfo().page || getRefererInfo().topmostLocation) };
let endpoint = document.location.search.match(/msq_test=true/) ? BIDDER_URL_TEST : BIDDER_URL_PROD;
let paramsToSearchFor = ['cpm', 'size', 'mediaType', 'currency', 'creativeId', 'adUnitCode', 'timeToRespond', 'requestId', 'auctionId', 'originalCpm', 'originalCurrency'];
let paramsToSearchFor = ['bidder', 'code', 'match', 'hasConsent', 'context'];
if (bid.hasOwnProperty('mediasquare')) {
if (bid['mediasquare'].hasOwnProperty('bidder')) { params['bidder'] = bid['mediasquare']['bidder']; }
if (bid['mediasquare'].hasOwnProperty('code')) { params['code'] = bid['mediasquare']['code']; }
if (bid['mediasquare'].hasOwnProperty('match')) { params['match'] = bid['mediasquare']['match']; }
if (bid['mediasquare'].hasOwnProperty('hasConsent')) { params['hasConsent'] = bid['mediasquare']['hasConsent']; }
for (let i = 0; i < paramsToSearchFor.length; i++) {
if (bid['mediasquare'].hasOwnProperty(paramsToSearchFor[i])) {
params[paramsToSearchFor[i]] = bid['mediasquare'][paramsToSearchFor[i]];
}
}
};
paramsToSearchFor = ['cpm', 'size', 'mediaType', 'currency', 'creativeId', 'adUnitCode', 'timeToRespond', 'requestId', 'auctionId', 'originalCpm', 'originalCurrency'];
for (let i = 0; i < paramsToSearchFor.length; i++) {
if (bid.hasOwnProperty(paramsToSearchFor[i])) {
params[paramsToSearchFor[i]] = bid[paramsToSearchFor[i]];
Expand Down
4 changes: 4 additions & 0 deletions test/spec/modules/mediasquareBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ describe('MediaSquare bid adapter tests', function () {
'code': 'test/publishername_atf_desktop_rg_pave',
'bid_id': 'aaaa1234',
'adomain': ['test.com'],
'context': 'instream',
}],
}};

Expand Down Expand Up @@ -161,7 +162,10 @@ describe('MediaSquare bid adapter tests', function () {
expect(bid.ttl).to.equal(300);
expect(bid.requestId).to.equal('aaaa1234');
expect(bid.mediasquare).to.exist;
expect(bid.mediasquare.bidder).to.exist;
expect(bid.mediasquare.bidder).to.equal('msqClassic');
expect(bid.mediasquare.context).to.exist;
expect(bid.mediasquare.context).to.equal('instream');
expect(bid.mediasquare.code).to.equal([DEFAULT_PARAMS[0].params.owner, DEFAULT_PARAMS[0].params.code].join('/'));
expect(bid.meta).to.exist;
expect(bid.meta.advertiserDomains).to.exist;
Expand Down

0 comments on commit c6c9321

Please sign in to comment.