From cbcf2056a0d8a4264a9ebd497b0f6f1e0a76966e Mon Sep 17 00:00:00 2001 From: Alexander Velichkin Date: Fri, 7 Oct 2022 19:08:41 +0300 Subject: [PATCH 1/2] Fix Mgid Bid provider: 1. Use ortb2 data 2. Added gvlid to spec --- modules/mgidBidAdapter.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/mgidBidAdapter.js b/modules/mgidBidAdapter.js index 2653f157196..036effecd88 100644 --- a/modules/mgidBidAdapter.js +++ b/modules/mgidBidAdapter.js @@ -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, @@ -177,6 +178,8 @@ export const spec = { return; } + const ortb2Data = bidderRequest?.ortb2 || {}; + let request = { id: deepAccess(bidderRequest, 'bidderRequestId'), site: {domain, page}, @@ -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) { From 74c62986d3004763f7a712a8647b979f56b6454d Mon Sep 17 00:00:00 2001 From: Alexander Velichkin Date: Wed, 19 Oct 2022 12:39:10 +0300 Subject: [PATCH 2/2] Fix Mgid Bid provider. Unit-tests --- test/spec/modules/mgidBidAdapter_spec.js | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/spec/modules/mgidBidAdapter_spec.js b/test/spec/modules/mgidBidAdapter_spec.js index 34ad29b3e92..c79cad6245d 100644 --- a/test/spec/modules/mgidBidAdapter_spec.js +++ b/test/spec/modules/mgidBidAdapter_spec.js @@ -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', @@ -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 () {