From 8f0bb737a83876d559b9be3bdc0a8feabb30ce16 Mon Sep 17 00:00:00 2001 From: Mikhail Malkov Date: Wed, 27 Nov 2024 01:09:08 +0300 Subject: [PATCH] nextMillennium Bid Adapter: Fixed a bug when there were several bids with the same adUnit.code (#12505) * nextMillenniumBidAdaper: Fixed a bug when there were several bids with the same adUnit.code * nextMillenniumBidAdaper: Fixed a bug when there were several bids with the same adUnit.code --- modules/nextMillenniumBidAdapter.js | 15 +++---- .../modules/nextMillenniumBidAdapter_spec.js | 39 +++++++------------ 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/modules/nextMillenniumBidAdapter.js b/modules/nextMillenniumBidAdapter.js index 8c794fdaf03..8cf20848675 100644 --- a/modules/nextMillenniumBidAdapter.js +++ b/modules/nextMillenniumBidAdapter.js @@ -21,7 +21,7 @@ import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {getRefererInfo} from '../src/refererDetection.js'; -const NM_VERSION = '4.2.0'; +const NM_VERSION = '4.2.1'; const PBJS_VERSION = 'v$prebid.version$'; const GVLID = 1060; const BIDDER_CODE = 'nextMillennium'; @@ -87,7 +87,6 @@ export const spec = { buildRequests: function(validBidRequests, bidderRequest) { const requests = []; - const bidIds = {}; window.nmmRefreshCounts = window.nmmRefreshCounts || {}; const site = getSiteObj(); const device = getDeviceObj(); @@ -121,8 +120,6 @@ export const spec = { if (i === 0) postBody.cur = cur; postBody.imp.push(getImp(bid, id, mediaTypes)); postBody.ext.next_mil_imps.push(getExtNextMilImp(bid)); - - bidIds[bid.adUnitCode] = bid.bidId; }); this.getUrlPixelMetric(EVENTS.BID_REQUESTED, validBidRequests); @@ -135,21 +132,19 @@ export const spec = { contentType: 'text/plain', withCredentials: true, }, - - bidIds, }); return requests; }, - interpretResponse: function(serverResponse, bidRequest) { + interpretResponse: function(serverResponse) { const response = serverResponse.body; const bidResponses = []; const bids = []; _each(response.seatbid, (resp) => { _each(resp.bid, (bid) => { - const requestId = bidRequest.bidIds[bid.impid]; + const requestId = bid.impid; const {ad, adUrl, vastUrl, vastXml} = getAd(bid); @@ -271,7 +266,7 @@ export const spec = { function getExtNextMilImp(bid) { if (typeof window?.nmmRefreshCounts[bid.adUnitCode] === 'number') ++window.nmmRefreshCounts[bid.adUnitCode]; const nextMilImp = { - impId: bid.adUnitCode, + impId: bid.bidId, nextMillennium: { nm_version: NM_VERSION, pbjs_version: PBJS_VERSION, @@ -286,7 +281,7 @@ function getExtNextMilImp(bid) { export function getImp(bid, id, mediaTypes) { const {banner, video} = mediaTypes; const imp = { - id: bid.adUnitCode, + id: bid.bidId, ext: { prebid: { storedrequest: { diff --git a/test/spec/modules/nextMillenniumBidAdapter_spec.js b/test/spec/modules/nextMillenniumBidAdapter_spec.js index 5cf51af9948..a5c5f5f714d 100644 --- a/test/spec/modules/nextMillenniumBidAdapter_spec.js +++ b/test/spec/modules/nextMillenniumBidAdapter_spec.js @@ -20,6 +20,7 @@ describe('nextMillenniumBidAdapterTests', () => { bid: { mediaTypes: {banner: {sizes: [[300, 250], [320, 250]]}}, adUnitCode: 'test-banner-1', + bidId: 'e36ea395f67f', }, mediaTypes: { @@ -32,7 +33,7 @@ describe('nextMillenniumBidAdapterTests', () => { }, expected: { - id: 'test-banner-1', + id: 'e36ea395f67f', bidfloorcur: 'EUR', bidfloor: 1.11, ext: {prebid: {storedrequest: {id: '123'}}}, @@ -48,6 +49,7 @@ describe('nextMillenniumBidAdapterTests', () => { bid: { mediaTypes: {video: {playerSize: [400, 300], api: [2], placement: 1, plcmt: 1}}, adUnitCode: 'test-video-1', + bidId: 'e36ea395f67f', }, mediaTypes: { @@ -59,7 +61,7 @@ describe('nextMillenniumBidAdapterTests', () => { }, expected: { - id: 'test-video-1', + id: 'e36ea395f67f', bidfloorcur: 'USD', ext: {prebid: {storedrequest: {id: '234'}}}, video: { @@ -80,7 +82,7 @@ describe('nextMillenniumBidAdapterTests', () => { postBody: {ext: {nextMillennium: {refresh_counts: {}, elemOffsets: {}}}}, bid: { mediaTypes: {video: {w: 640, h: 480}}, - adUnitCode: 'test-video-2', + bidId: 'e36ea395f67f', }, mediaTypes: { @@ -92,7 +94,7 @@ describe('nextMillenniumBidAdapterTests', () => { }, expected: { - id: 'test-video-2', + id: 'e36ea395f67f', bidfloorcur: 'USD', ext: {prebid: {storedrequest: {id: '234'}}}, video: {w: 640, h: 480, mimes: ['video/mp4', 'video/x-ms-wmv', 'application/javascript']}, @@ -789,17 +791,17 @@ describe('nextMillenniumBidAdapterTests', () => { describe('Check ext.next_mil_imps', function() { const expectedNextMilImps = [ { - impId: 'nmi-test-0', + impId: 'bid1234', nextMillennium: {refresh_count: 1}, }, { - impId: 'nmi-test-1', + impId: 'bid1235', nextMillennium: {refresh_count: 1}, }, { - impId: 'nmi-test-2', + impId: 'bid1236', nextMillennium: {refresh_count: 1}, }, ]; @@ -1055,7 +1057,6 @@ describe('nextMillenniumBidAdapterTests', () => { expected: { id: 'mock-uuid', - bidIds: {'test-div': 'bid1234', 'test-div-2': 'bid1235'}, impSize: 2, requestSize: 1, domain: 'example.com', @@ -1068,7 +1069,6 @@ describe('nextMillenniumBidAdapterTests', () => { it(title, () => { const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.length).to.equal(expected.requestSize); - expect(request[0].bidIds).to.deep.equal(expected.bidIds); const requestData = JSON.parse(request[0].data); expect(requestData.id).to.equal(expected.id); @@ -1090,7 +1090,7 @@ describe('nextMillenniumBidAdapterTests', () => { bid: [ { id: '7457329903666272789-0', - impid: 'ad-unit-0', + impid: '700ce0a43f72', price: 0.5, adm: 'Hello! It\'s a test ad!', adid: '96846035-0', @@ -1101,7 +1101,7 @@ describe('nextMillenniumBidAdapterTests', () => { { id: '7457329903666272789-1', - impid: 'ad-unit-1', + impid: '700ce0a43f73', price: 0.7, adm: 'https://some_vast_host.com/vast.xml', adid: '96846035-1', @@ -1113,7 +1113,7 @@ describe('nextMillenniumBidAdapterTests', () => { { id: '7457329903666272789-2', - impid: 'ad-unit-3', + impid: '700ce0a43f74', price: 1.0, adm: '', adid: '96846035-3', @@ -1129,19 +1129,10 @@ describe('nextMillenniumBidAdapterTests', () => { }, }, - bidRequest: { - bidIds: { - 'ad-unit-0': 'bid-id-0', - 'ad-unit-1': 'bid-id-1', - 'ad-unit-2': 'bid-id-2', - 'ad-unit-3': 'bid-id-3', - }, - }, - expected: [ { title: 'banner', - requestId: 'bid-id-0', + requestId: '700ce0a43f72', creativeId: '96846035-0', ad: 'Hello! It\'s a test ad!', vastUrl: undefined, @@ -1154,7 +1145,7 @@ describe('nextMillenniumBidAdapterTests', () => { { title: 'video - vastUrl', - requestId: 'bid-id-1', + requestId: '700ce0a43f73', creativeId: '96846035-1', ad: undefined, vastUrl: 'https://some_vast_host.com/vast.xml', @@ -1167,7 +1158,7 @@ describe('nextMillenniumBidAdapterTests', () => { { title: 'video - vastXml', - requestId: 'bid-id-3', + requestId: '700ce0a43f74', creativeId: '96846035-3', ad: undefined, vastUrl: undefined,