Skip to content

Commit

Permalink
nextMillennium Bid Adapter: Fixed a bug when there were several bids …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
mhlm authored Nov 26, 2024
1 parent 894f60b commit 8f0bb73
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 34 deletions.
15 changes: 5 additions & 10 deletions modules/nextMillenniumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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,
Expand All @@ -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: {
Expand Down
39 changes: 15 additions & 24 deletions test/spec/modules/nextMillenniumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('nextMillenniumBidAdapterTests', () => {
bid: {
mediaTypes: {banner: {sizes: [[300, 250], [320, 250]]}},
adUnitCode: 'test-banner-1',
bidId: 'e36ea395f67f',
},

mediaTypes: {
Expand All @@ -32,7 +33,7 @@ describe('nextMillenniumBidAdapterTests', () => {
},

expected: {
id: 'test-banner-1',
id: 'e36ea395f67f',
bidfloorcur: 'EUR',
bidfloor: 1.11,
ext: {prebid: {storedrequest: {id: '123'}}},
Expand All @@ -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: {
Expand All @@ -59,7 +61,7 @@ describe('nextMillenniumBidAdapterTests', () => {
},

expected: {
id: 'test-video-1',
id: 'e36ea395f67f',
bidfloorcur: 'USD',
ext: {prebid: {storedrequest: {id: '234'}}},
video: {
Expand All @@ -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: {
Expand All @@ -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']},
Expand Down Expand Up @@ -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},
},
];
Expand Down Expand Up @@ -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',
Expand All @@ -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);
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -1113,7 +1113,7 @@ describe('nextMillenniumBidAdapterTests', () => {

{
id: '7457329903666272789-2',
impid: 'ad-unit-3',
impid: '700ce0a43f74',
price: 1.0,
adm: '<vast><ad></ad></vast>',
adid: '96846035-3',
Expand All @@ -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,
Expand All @@ -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',
Expand All @@ -1167,7 +1158,7 @@ describe('nextMillenniumBidAdapterTests', () => {

{
title: 'video - vastXml',
requestId: 'bid-id-3',
requestId: '700ce0a43f74',
creativeId: '96846035-3',
ad: undefined,
vastUrl: undefined,
Expand Down

0 comments on commit 8f0bb73

Please sign in to comment.