Skip to content

Commit f199fca

Browse files
authored
nextMillenniumBidAdapter: ImpId generation has been changed (prebid#14266)
* fixed typos end changed test endpoint * changed report endpoint * fixed tests * fixed tests * nextMillenniumBidAdapter - changed generate impId * nextMillenniumBidAdapter - fixed bug * nextMillenniumBidAdapter - revert cahnges file package-lock.json
1 parent 28d5ee4 commit f199fca

2 files changed

Lines changed: 57 additions & 30 deletions

File tree

modules/nextMillenniumBidAdapter.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
2323
import {getRefererInfo} from '../src/refererDetection.js';
2424
import { getViewportSize } from '../libraries/viewport/viewport.js';
2525

26-
const NM_VERSION = '4.5.0';
26+
const NM_VERSION = '4.5.1';
2727
const PBJS_VERSION = 'v$prebid.version$';
2828
const GVLID = 1060;
2929
const BIDDER_CODE = 'nextMillennium';
@@ -148,6 +148,7 @@ export const spec = {
148148
},
149149

150150
buildRequests: function(validBidRequests, bidderRequest) {
151+
const bidIds = new Map()
151152
const requests = [];
152153
window.nmmRefreshCounts = window.nmmRefreshCounts || {};
153154
const site = getSiteObj();
@@ -180,10 +181,14 @@ export const spec = {
180181
const id = getPlacementId(bid);
181182
const {cur, mediaTypes} = getCurrency(bid);
182183
if (i === 0) postBody.cur = cur;
183-
const imp = getImp(bid, id, mediaTypes);
184+
185+
const impId = String(i + 1)
186+
bidIds.set(impId, bid.bidId)
187+
188+
const imp = getImp(impId, bid, id, mediaTypes);
184189
setOrtb2Parameters(ALLOWED_ORTB2_IMP_PARAMETERS, imp, bid?.ortb2Imp);
185190
postBody.imp.push(imp);
186-
postBody.ext.next_mil_imps.push(getExtNextMilImp(bid));
191+
postBody.ext.next_mil_imps.push(getExtNextMilImp(impId, bid));
187192
});
188193

189194
this.getUrlPixelMetric(EVENTS.BID_REQUESTED, validBidRequests);
@@ -196,19 +201,21 @@ export const spec = {
196201
contentType: 'text/plain',
197202
withCredentials: true,
198203
},
204+
205+
bidIds,
199206
});
200207

201208
return requests;
202209
},
203210

204-
interpretResponse: function(serverResponse) {
211+
interpretResponse: function(serverResponse, bidRequest) {
205212
const response = serverResponse.body;
206213
const bidResponses = [];
207214

208215
const bids = [];
209216
_each(response.seatbid, (resp) => {
210217
_each(resp.bid, (bid) => {
211-
const requestId = bid.impid;
218+
const requestId = bidRequest.bidIds.get(bid.impid);
212219

213220
const {ad, adUrl, vastUrl, vastXml} = getAd(bid);
214221

@@ -327,11 +334,11 @@ export const spec = {
327334
},
328335
};
329336

330-
export function getExtNextMilImp(bid) {
337+
export function getExtNextMilImp(impId, bid) {
331338
if (typeof window?.nmmRefreshCounts[bid.adUnitCode] === 'number') ++window.nmmRefreshCounts[bid.adUnitCode];
332339
const {adSlots, allowedAds} = bid.params
333340
const nextMilImp = {
334-
impId: bid.bidId,
341+
impId,
335342
nextMillennium: {
336343
nm_version: NM_VERSION,
337344
pbjs_version: PBJS_VERSION,
@@ -346,10 +353,10 @@ export function getExtNextMilImp(bid) {
346353
return nextMilImp;
347354
}
348355

349-
export function getImp(bid, id, mediaTypes) {
356+
export function getImp(impId, bid, id, mediaTypes) {
350357
const {banner, video} = mediaTypes;
351358
const imp = {
352-
id: bid.bidId,
359+
id: impId,
353360
ext: {
354361
prebid: {
355362
storedrequest: {

test/spec/modules/nextMillenniumBidAdapter_spec.js

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ describe('nextMillenniumBidAdapterTests', () => {
1818
{
1919
title: 'imp - banner',
2020
data: {
21+
impId: '5',
2122
id: '123',
22-
postBody: {ext: {nextMillennium: {refresh_counts: {}, elemOffsets: {}}}},
2323
bid: {
2424
mediaTypes: {banner: {sizes: [[300, 250], [320, 250]]}},
2525
adUnitCode: 'test-banner-1',
@@ -37,7 +37,7 @@ describe('nextMillenniumBidAdapterTests', () => {
3737
},
3838

3939
expected: {
40-
id: 'e36ea395f67f',
40+
id: '5',
4141
bidfloorcur: 'EUR',
4242
bidfloor: 1.11,
4343
ext: {prebid: {storedrequest: {id: '123'}}},
@@ -53,8 +53,8 @@ describe('nextMillenniumBidAdapterTests', () => {
5353
{
5454
title: 'imp - video',
5555
data: {
56+
impId: '3',
5657
id: '234',
57-
postBody: {ext: {nextMillennium: {refresh_counts: {}, elemOffsets: {}}}},
5858
bid: {
5959
mediaTypes: {video: {playerSize: [400, 300], api: [2], placement: 1, plcmt: 1}},
6060
adUnitCode: 'test-video-1',
@@ -71,7 +71,7 @@ describe('nextMillenniumBidAdapterTests', () => {
7171
},
7272

7373
expected: {
74-
id: 'e36ea395f67f',
74+
id: '3',
7575
bidfloorcur: 'USD',
7676
ext: {prebid: {storedrequest: {id: '234'}}},
7777
video: {
@@ -89,8 +89,8 @@ describe('nextMillenniumBidAdapterTests', () => {
8989
{
9090
title: 'imp - mediaTypes.video is empty',
9191
data: {
92+
impId: '4',
9293
id: '234',
93-
postBody: {ext: {nextMillennium: {refresh_counts: {}, elemOffsets: {}}}},
9494
bid: {
9595
mediaTypes: {video: {w: 640, h: 480}},
9696
bidId: 'e36ea395f67f',
@@ -105,7 +105,7 @@ describe('nextMillenniumBidAdapterTests', () => {
105105
},
106106

107107
expected: {
108-
id: 'e36ea395f67f',
108+
id: '4',
109109
bidfloorcur: 'USD',
110110
ext: {prebid: {storedrequest: {id: '234'}}},
111111
video: {w: 640, h: 480, mimes: ['video/mp4', 'video/x-ms-wmv', 'application/javascript']},
@@ -115,8 +115,8 @@ describe('nextMillenniumBidAdapterTests', () => {
115115
{
116116
title: 'imp with gpid',
117117
data: {
118+
impId: '2',
118119
id: '123',
119-
postBody: {ext: {nextMillennium: {refresh_counts: {}, elemOffsets: {}}}},
120120
bid: {
121121
mediaTypes: {banner: {sizes: [[300, 250], [320, 250]]}},
122122
adUnitCode: 'test-gpid-1',
@@ -132,7 +132,7 @@ describe('nextMillenniumBidAdapterTests', () => {
132132
},
133133

134134
expected: {
135-
id: 'e36ea395f67a',
135+
id: '2',
136136
ext: {
137137
prebid: {storedrequest: {id: '123'}},
138138
gpid: 'imp-gpid-123'
@@ -144,8 +144,8 @@ describe('nextMillenniumBidAdapterTests', () => {
144144
{
145145
title: 'imp with pbadslot',
146146
data: {
147+
impId: '1',
147148
id: '123',
148-
postBody: {ext: {nextMillennium: {refresh_counts: {}, elemOffsets: {}}}},
149149
bid: {
150150
mediaTypes: {banner: {sizes: [[300, 250], [320, 250]]}},
151151
adUnitCode: 'test-gpid-1',
@@ -167,7 +167,7 @@ describe('nextMillenniumBidAdapterTests', () => {
167167
},
168168

169169
expected: {
170-
id: 'e36ea395f67a',
170+
id: '1',
171171
ext: {
172172
prebid: {storedrequest: {id: '123'}},
173173
},
@@ -178,8 +178,8 @@ describe('nextMillenniumBidAdapterTests', () => {
178178

179179
for (const {title, data, expected} of dataTests) {
180180
it(title, () => {
181-
const {bid, id, mediaTypes, postBody} = data;
182-
const imp = getImp(bid, id, mediaTypes, postBody);
181+
const {impId, bid, id, mediaTypes} = data;
182+
const imp = getImp(impId, bid, id, mediaTypes);
183183
expect(imp).to.deep.equal(expected);
184184
});
185185
}
@@ -900,17 +900,17 @@ describe('nextMillenniumBidAdapterTests', () => {
900900
describe('Check ext.next_mil_imps', function() {
901901
const expectedNextMilImps = [
902902
{
903-
impId: 'bid1234',
903+
impId: '1',
904904
nextMillennium: {refresh_count: 1},
905905
},
906906

907907
{
908-
impId: 'bid1235',
908+
impId: '2',
909909
nextMillennium: {refresh_count: 1},
910910
},
911911

912912
{
913-
impId: 'bid1236',
913+
impId: '3',
914914
nextMillennium: {refresh_count: 1},
915915
},
916916
];
@@ -1183,6 +1183,12 @@ describe('nextMillenniumBidAdapterTests', () => {
11831183
expect(requestData.id).to.equal(expected.id);
11841184
expect(requestData.tmax).to.equal(expected.tmax);
11851185
expect(requestData?.imp?.length).to.equal(expected.impSize);
1186+
1187+
for (let i = 0; i < bidRequests.length; i++) {
1188+
const impId = String(i + 1);
1189+
expect(impId).to.equal(requestData.imp[i].id);
1190+
expect(bidRequests[i].bidId).to.equal(request[0].bidIds.get(impId));
1191+
};
11861192
});
11871193
};
11881194
});
@@ -1199,7 +1205,7 @@ describe('nextMillenniumBidAdapterTests', () => {
11991205
bid: [
12001206
{
12011207
id: '7457329903666272789-0',
1202-
impid: '700ce0a43f72',
1208+
impid: '1',
12031209
price: 0.5,
12041210
adm: 'Hello! It\'s a test ad!',
12051211
adid: '96846035-0',
@@ -1210,7 +1216,7 @@ describe('nextMillenniumBidAdapterTests', () => {
12101216

12111217
{
12121218
id: '7457329903666272789-1',
1213-
impid: '700ce0a43f73',
1219+
impid: '2',
12141220
price: 0.7,
12151221
adm: 'https://some_vast_host.com/vast.xml',
12161222
adid: '96846035-1',
@@ -1222,7 +1228,7 @@ describe('nextMillenniumBidAdapterTests', () => {
12221228

12231229
{
12241230
id: '7457329903666272789-2',
1225-
impid: '700ce0a43f74',
1231+
impid: '3',
12261232
price: 1.0,
12271233
adm: '<vast><ad></ad></vast>',
12281234
adid: '96846035-3',
@@ -1238,6 +1244,14 @@ describe('nextMillenniumBidAdapterTests', () => {
12381244
},
12391245
},
12401246

1247+
bidRequest: {
1248+
bidIds: new Map([
1249+
['1', '700ce0a43f72'],
1250+
['2', '700ce0a43f73'],
1251+
['3', '700ce0a43f74'],
1252+
]),
1253+
},
1254+
12411255
expected: [
12421256
{
12431257
title: 'banner',
@@ -1308,15 +1322,19 @@ describe('nextMillenniumBidAdapterTests', () => {
13081322
const tests = [
13091323
{
13101324
title: 'parameters adSlots and allowedAds are empty',
1325+
impId: '1',
13111326
bid: {
13121327
params: {},
13131328
},
13141329

1315-
expected: {},
1330+
expected: {
1331+
impId: '1',
1332+
},
13161333
},
13171334

13181335
{
13191336
title: 'parameters adSlots and allowedAds',
1337+
impId: '2',
13201338
bid: {
13211339
params: {
13221340
adSlots: ['test1'],
@@ -1325,15 +1343,17 @@ describe('nextMillenniumBidAdapterTests', () => {
13251343
},
13261344

13271345
expected: {
1346+
impId: '2',
13281347
adSlots: ['test1'],
13291348
allowedAds: ['test2'],
13301349
},
13311350
},
13321351
];
13331352

1334-
for (const {title, bid, expected} of tests) {
1353+
for (const {title, impId, bid, expected} of tests) {
13351354
it(title, () => {
1336-
const extNextMilImp = getExtNextMilImp(bid);
1355+
const extNextMilImp = getExtNextMilImp(impId, bid);
1356+
expect(extNextMilImp.impId).to.deep.equal(expected.impId);
13371357
expect(extNextMilImp.nextMillennium.adSlots).to.deep.equal(expected.adSlots);
13381358
expect(extNextMilImp.nextMillennium.allowedAds).to.deep.equal(expected.allowedAds);
13391359
});

0 commit comments

Comments
 (0)