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

Mediasquare Bid Adapter: handle context for video bids #10055

Merged
merged 1 commit into from
Jun 7, 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
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