Skip to content

Commit 22f547a

Browse files
Mediasquare Bid Adapter: add metrics to onBidWon Event (#8209)
* remove old userSyncs method * Update mediasquareBidAdapter.js * Update mediasquareBidAdapter.js * Update mediasquareBidAdapter_spec.js * Mediasquare Bid Adapter: add floor module support * Update mediasquareBidAdapter_spec.js * Update mediasquareBidAdapter.js
1 parent 6366b39 commit 22f547a

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

modules/mediasquareBidAdapter.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export const spec = {
5555
});
5656
const payload = {
5757
codes: codes,
58-
referer: encodeURIComponent(bidderRequest.refererInfo.referer)
58+
referer: encodeURIComponent(bidderRequest.refererInfo.referer),
59+
pbjs: '$prebid.version$'
5960
};
6061
if (bidderRequest) { // modules informations (gdpr, ccpa, schain, userId)
6162
if (bidderRequest.gdprConsent) {
@@ -116,6 +117,9 @@ export const spec = {
116117
if ('match' in value) {
117118
bidResponse['mediasquare']['match'] = value['match'];
118119
}
120+
if ('hasConsent' in value) {
121+
bidResponse['mediasquare']['hasConsent'] = value['hasConsent'];
122+
}
119123
if ('native' in value) {
120124
bidResponse['native'] = value['native'];
121125
bidResponse['mediaType'] = 'native';
@@ -153,19 +157,22 @@ export const spec = {
153157
*/
154158
onBidWon: function(bid) {
155159
// fires a pixel to confirm a winning bid
156-
let params = [];
160+
let params = {'pbjs': '$prebid.version$'};
157161
let endpoint = document.location.search.match(/msq_test=true/) ? BIDDER_URL_TEST : BIDDER_URL_PROD;
158162
let paramsToSearchFor = ['cpm', 'size', 'mediaType', 'currency', 'creativeId', 'adUnitCode', 'timeToRespond', 'requestId', 'auctionId']
159163
if (bid.hasOwnProperty('mediasquare')) {
160-
if (bid['mediasquare'].hasOwnProperty('bidder')) { params.push('bidder=' + bid['mediasquare']['bidder']); }
161-
if (bid['mediasquare'].hasOwnProperty('code')) { params.push('code=' + bid['mediasquare']['code']); }
162-
if (bid['mediasquare'].hasOwnProperty('match')) { params.push('match=' + bid['mediasquare']['match']); }
164+
if (bid['mediasquare'].hasOwnProperty('bidder')) { params['bidder'] = bid['mediasquare']['bidder']; }
165+
if (bid['mediasquare'].hasOwnProperty('code')) { params['code'] = bid['mediasquare']['code']; }
166+
if (bid['mediasquare'].hasOwnProperty('match')) { params['match'] = bid['mediasquare']['match']; }
167+
if (bid['mediasquare'].hasOwnProperty('hasConsent')) { params['hasConsent'] = bid['mediasquare']['hasConsent']; }
163168
};
164169
for (let i = 0; i < paramsToSearchFor.length; i++) {
165-
if (bid.hasOwnProperty(paramsToSearchFor[i])) { params.push(paramsToSearchFor[i] + '=' + bid[paramsToSearchFor[i]]); }
170+
if (bid.hasOwnProperty(paramsToSearchFor[i])) {
171+
params[paramsToSearchFor[i]] = bid[paramsToSearchFor[i]];
172+
if (typeof params[paramsToSearchFor[i]] == 'number') { params[paramsToSearchFor[i]] = params[paramsToSearchFor[i]].toString() }
173+
}
166174
}
167-
if (params.length > 0) { params = '?' + params.join('&'); }
168-
ajax(endpoint + BIDDER_ENDPOINT_WINNING + params, null, undefined, {method: 'GET', withCredentials: true});
175+
ajax(endpoint + BIDDER_ENDPOINT_WINNING, null, JSON.stringify(params), {method: 'POST', withCredentials: true});
169176
return true;
170177
}
171178

test/spec/modules/mediasquareBidAdapter_spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ describe('MediaSquare bid adapter tests', function () {
172172
expect(bid.mediasquare.match).to.exist;
173173
expect(bid.mediasquare.match).to.equal(true);
174174
});
175+
it('Verifies hasConsent', function () {
176+
const request = spec.buildRequests(DEFAULT_PARAMS, DEFAULT_OPTIONS);
177+
BID_RESPONSE.body.responses[0].hasConsent = true;
178+
const response = spec.interpretResponse(BID_RESPONSE, request);
179+
const bid = response[0];
180+
expect(bid.mediasquare.hasConsent).to.exist;
181+
expect(bid.mediasquare.hasConsent).to.equal(true);
182+
});
175183
it('Verifies bidder code', function () {
176184
expect(spec.code).to.equal('mediasquare');
177185
});
@@ -185,6 +193,8 @@ describe('MediaSquare bid adapter tests', function () {
185193
});
186194
it('Verifies bid won', function () {
187195
const request = spec.buildRequests(DEFAULT_PARAMS, DEFAULT_OPTIONS);
196+
BID_RESPONSE.body.responses[0].match = true
197+
BID_RESPONSE.body.responses[0].hasConsent = true;
188198
const response = spec.interpretResponse(BID_RESPONSE, request);
189199
const won = spec.onBidWon(response[0]);
190200
expect(won).to.equal(true);

0 commit comments

Comments
 (0)