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

Mgid Bid Adapter: fix usage of ortb2 data #9117

Merged
merged 3 commits into from
Oct 19, 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
9 changes: 8 additions & 1 deletion modules/mgidBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ _each(NATIVE_ASSETS, anAsset => { _NATIVE_ASSET_KEY_TO_ASSET_MAP[anAsset.KEY] =
export const spec = {
VERSION: '1.5',
code: BIDDER_CODE,
gvlid: GVLID,
supportedMediaTypes: [BANNER, NATIVE],
reId: /^[1-9][0-9]*$/,
NATIVE_ASSET_ID_TO_KEY_MAP: _NATIVE_ASSET_ID_TO_KEY_MAP,
Expand Down Expand Up @@ -177,6 +178,8 @@ export const spec = {
return;
}

const ortb2Data = bidderRequest?.ortb2 || {};

let request = {
id: deepAccess(bidderRequest, 'bidderRequestId'),
site: {domain, page},
Expand All @@ -190,7 +193,11 @@ export const spec = {
w: screen.width,
language: getLanguage()
},
ext: {mgid_ver: spec.VERSION, prebid_ver: '$prebid.version$'},
ext: {
mgid_ver: spec.VERSION,
prebid_ver: '$prebid.version$',
...ortb2Data
},
imp
};
if (bidderRequest && bidderRequest.gdprConsent) {
Expand Down
50 changes: 50 additions & 0 deletions test/spec/modules/mgidBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ describe('Mgid bid adapter', function () {
const mgid_ver = spec.VERSION;
const utcOffset = (new Date()).getTimezoneOffset().toString();

it('should expose gvlid', function() {
expect(spec.gvlid).to.equal(358)
});

describe('isBidRequestValid', function () {
let bid = {
'adUnitCode': 'div',
Expand Down Expand Up @@ -541,6 +545,52 @@ describe('Mgid bid adapter', function () {
'data': '{"site":{"domain":"' + domain + '","page":"' + page + '"},"cur":["USD"],"geo":{"utcoffset":' + utcOffset + '},"device":{"ua":"' + ua + '","js":1,"dnt":' + dnt + ',"h":' + screenHeight + ',"w":' + screenWidth + ',"language":"' + lang + '"},"ext":{"mgid_ver":"' + mgid_ver + '","prebid_ver":"' + version + '"},"imp":[{"tagid":"2/div","secure":' + secure + ',"banner":{"w":300,"h":600,"format":[{"w":300,"h":600},{"w":300,"h":250}],"pos":1}}]}',
});
});
it('should proper handle ortb2 data', function () {
let bid = Object.assign({}, abid);
bid.mediaTypes = {
banner: {
sizes: [[300, 250]]
}
};
let bidRequests = [bid];

let bidderRequest = {
ortb2: {
site: {
content: {
data: [{
name: 'mgid.com',
ext: {
segtax: 1,
},
segment: [
{id: '123'},
{id: '456'},
],
}]
}
},
user: {
data: [{
name: 'mgid.com',
ext: {
segtax: 2,
},
segment: [
{'id': '789'},
{'id': '987'},
],
}]
}
}
};

const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.url).deep.equal('https://prebid.mgid.com/prebid/1');
expect(request.method).deep.equal('POST');
const data = JSON.parse(request.data);
expect(data.ext).deep.include(bidderRequest.ortb2);
});
});

describe('interpretResponse', function () {
Expand Down