Skip to content

Commit

Permalink
Mediasquare Bid Adapter: fix getUserSyncs issue with empty bids + add…
Browse files Browse the repository at this point in the history
… metrics to onBidWon Event (#6480)

* Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event

* Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event

* removing status as it does not seem populated when called

* add tests
  • Loading branch information
matthieularere-msq authored and idettman committed May 21, 2021
1 parent a28ac01 commit 50bebfd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/mediasquareBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export const spec = {
getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {
let params = '';
let endpoint = document.location.search.match(/msq_test=true/) ? BIDDER_URL_TEST : BIDDER_URL_PROD;
if (serverResponses[0].body.hasOwnProperty('cookies') && typeof serverResponses[0].body.cookies === 'object') {
if (typeof serverResponses === 'object' && serverResponses != null && serverResponses.length > 0 && serverResponses[0].hasOwnProperty('body') &&
serverResponses[0].body.hasOwnProperty('cookies') && typeof serverResponses[0].body.cookies === 'object') {
return serverResponses[0].body.cookies;
} else {
if (gdprConsent && typeof gdprConsent.consentString === 'string') { params += typeof gdprConsent.gdprApplies === 'boolean' ? `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}` : `&gdpr_consent=${gdprConsent.consentString}`; }
Expand All @@ -148,7 +149,7 @@ export const spec = {
// fires a pixel to confirm a winning bid
let params = [];
let endpoint = document.location.search.match(/msq_test=true/) ? BIDDER_URL_TEST : BIDDER_URL_PROD;
let paramsToSearchFor = ['cpm', 'size', 'mediaType', 'currency', 'creativeId', 'adUnitCode', 'timeToRespond']
let paramsToSearchFor = ['cpm', 'size', 'mediaType', 'currency', 'creativeId', 'adUnitCode', 'timeToRespond', 'requestId', 'auctionId']
if (bid.hasOwnProperty('mediasquare')) {
if (bid['mediasquare'].hasOwnProperty('bidder')) { params.push('bidder=' + bid['mediasquare']['bidder']); }
if (bid['mediasquare'].hasOwnProperty('code')) { params.push('code=' + bid['mediasquare']['code']); }
Expand Down
10 changes: 10 additions & 0 deletions test/spec/modules/mediasquareBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ describe('MediaSquare bid adapter tests', function () {
expect(syncs[0]).to.have.property('type').and.to.equal('image');
expect(syncs[0]).to.have.property('url').and.to.equal('http://www.cookie.sync.org/');
});
it('Verifies user sync with no bid response', function() {
var syncs = spec.getUserSyncs({}, null, DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent);
expect(syncs).to.have.property('type').and.to.equal('iframe');
});
it('Verifies user sync with no bid body response', function() {
var syncs = spec.getUserSyncs({}, [], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent);
expect(syncs).to.have.property('type').and.to.equal('iframe');
var syncs = spec.getUserSyncs({}, [{}], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent);
expect(syncs).to.have.property('type').and.to.equal('iframe');
});
it('Verifies native in bid response', function () {
const request = spec.buildRequests(NATIVE_PARAMS, DEFAULT_OPTIONS);
BID_RESPONSE.body.responses[0].native = {'title': 'native title'};
Expand Down

0 comments on commit 50bebfd

Please sign in to comment.