Skip to content

Commit

Permalink
NextMillenniumBidAdapter: Added OpenRTB 2.6 parameters support: `bcat…
Browse files Browse the repository at this point in the history
…`, `badv`, `wlang`, `wlangb` and `tmax` (#12368)

* added support for gpp consent string

* changed test for nextMillenniumBidAdapter

* added some tests

* added site.pagecat, site.content.cat and site.content.language to request

* lint fix

* formated code

* formated code

* formated code

* pachage-lock with prebid

* pachage-lock with prebid

* formatted code

* added device.sua, user.eids

* formatted

* fixed tests

* fixed bug functio getSua

* NextMillennium: Sending a request with several imp objects.

* PB-2650 - tmax

* PB-2626 - "bcat", "badv", "wlang", "wlangb"

* PB-2626 - coppa

* PB-2626 - save

* PB-2650 - fixed bugs

* PB-2650 - save

* PB-2650 - save - 2
  • Loading branch information
mhlm authored Oct 28, 2024
1 parent 19c6382 commit 9058a09
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 21 deletions.
26 changes: 20 additions & 6 deletions modules/nextMillenniumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {getRefererInfo} from '../src/refererDetection.js';

const NM_VERSION = '4.0.1';
const NM_VERSION = '4.1.0';
const PBJS_VERSION = 'v$prebid.version$';
const GVLID = 1060;
const BIDDER_CODE = 'nextMillennium';
Expand All @@ -30,6 +30,7 @@ const SYNC_ENDPOINT = 'https://cookies.nextmillmedia.com/sync?gdpr={{.GDPR}}&gdp
const REPORT_ENDPOINT = 'https://report2.hb.brainlyads.com/statistics/metric';
const TIME_TO_LIVE = 360;
const DEFAULT_CURRENCY = 'USD';
const DEFAULT_TMAX = 1500;

const VIDEO_PARAMS_DEFAULT = {
api: undefined,
Expand Down Expand Up @@ -65,6 +66,10 @@ const ALLOWED_ORTB2_PARAMETERS = [
'site.keywords',
'site.content.keywords',
'user.keywords',
'bcat',
'badv',
'wlang',
'wlangb',
];

export const spec = {
Expand All @@ -74,7 +79,8 @@ export const spec = {

isBidRequestValid: function(bid) {
return !!(
(bid.params.placement_id && isStr(bid.params.placement_id)) || (bid.params.group_id && isStr(bid.params.group_id))
(bid.params.placement_id && isStr(bid.params.placement_id)) ||
(bid.params.group_id && isStr(bid.params.group_id))
);
},

Expand All @@ -84,9 +90,11 @@ export const spec = {
window.nmmRefreshCounts = window.nmmRefreshCounts || {};
const site = getSiteObj();
const device = getDeviceObj();
const tmax = deepAccess(bidderRequest, 'timeout') || DEFAULT_TMAX;

const postBody = {
id: bidderRequest?.bidderRequestId,
tmax,
ext: {
next_mil_imps: [],
},
Expand Down Expand Up @@ -334,10 +342,10 @@ export function setConsentStrings(postBody = {}, bidderRequest) {
if (!gppConsent && bidderRequest?.ortb2?.regs?.gpp) gppConsent = bidderRequest?.ortb2?.regs;

if (gdprConsent || uspConsent || gppConsent) {
postBody.regs = { ext: {} };
postBody.regs = {};

if (uspConsent) {
postBody.regs.ext.us_privacy = uspConsent;
postBody.regs.us_privacy = uspConsent;
};

if (gppConsent) {
Expand All @@ -347,15 +355,19 @@ export function setConsentStrings(postBody = {}, bidderRequest) {

if (gdprConsent) {
if (typeof gdprConsent.gdprApplies !== 'undefined') {
postBody.regs.ext.gdpr = gdprConsent.gdprApplies ? 1 : 0;
postBody.regs.gdpr = gdprConsent.gdprApplies ? 1 : 0;
};

if (typeof gdprConsent.consentString !== 'undefined') {
postBody.user = {
ext: { consent: gdprConsent.consentString },
consent: gdprConsent.consentString,
};
};
};

if (typeof bidderRequest?.ortb2?.regs?.coppa === 'number') {
postBody.regs.coppa = bidderRequest?.ortb2?.regs?.coppa;
};
};
};

Expand All @@ -364,6 +376,8 @@ export function setOrtb2Parameters(postBody, ortb2 = {}) {
const value = deepAccess(ortb2, parameter);
if (value) deepSetValue(postBody, parameter, value);
}

if (postBody.wlang) delete postBody.wlangb
}

export function setEids(postBody = {}, bids = []) {
Expand Down
48 changes: 33 additions & 15 deletions test/spec/modules/nextMillenniumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,18 @@ describe('nextMillenniumBidAdapterTests', () => {
uspConsent: '1---',
gppConsent: {gppString: 'DBACNYA~CPXxRfAPXxR', applicableSections: [7]},
gdprConsent: {consentString: 'kjfdniwjnifwenrif3', gdprApplies: true},
ortb2: {regs: {gpp: 'DSFHFHWEUYVDC', gpp_sid: [8, 9, 10]}},
ortb2: {regs: {gpp: 'DSFHFHWEUYVDC', gpp_sid: [8, 9, 10], coppa: 1}},
},
},

expected: {
user: {ext: {consent: 'kjfdniwjnifwenrif3'}},
user: {consent: 'kjfdniwjnifwenrif3'},
regs: {
gpp: 'DBACNYA~CPXxRfAPXxR',
gpp_sid: [7],
ext: {gdpr: 1, us_privacy: '1---'},
gdpr: 1,
us_privacy: '1---',
coppa: 1
},
},
},
Expand All @@ -138,16 +140,17 @@ describe('nextMillenniumBidAdapterTests', () => {
postBody: {},
bidderRequest: {
gdprConsent: {consentString: 'ewtewbefbawyadexv', gdprApplies: false},
ortb2: {regs: {gpp: 'DSFHFHWEUYVDC', gpp_sid: [8, 9, 10]}},
ortb2: {regs: {gpp: 'DSFHFHWEUYVDC', gpp_sid: [8, 9, 10], coppa: 0}},
},
},

expected: {
user: {ext: {consent: 'ewtewbefbawyadexv'}},
user: {consent: 'ewtewbefbawyadexv'},
regs: {
gpp: 'DSFHFHWEUYVDC',
gpp_sid: [8, 9, 10],
ext: {gdpr: 0},
gdpr: 0,
coppa: 0,
},
},
},
Expand All @@ -160,7 +163,7 @@ describe('nextMillenniumBidAdapterTests', () => {
},

expected: {
regs: {ext: {gdpr: 0}},
regs: {gdpr: 0},
},
},

Expand Down Expand Up @@ -414,23 +417,35 @@ describe('nextMillenniumBidAdapterTests', () => {
title: 'site.pagecat, site.content.cat and site.content.language',
data: {
postBody: {},
ortb2: {site: {
ortb2: {
bcat: ['IAB1-3', 'IAB1-4'],
badv: ['domain1.com', 'domain2.com'],
wlang: ['en', 'fr', 'de'],
wlangb: ['en', 'fr', 'de'],
site: {
pagecat: ['IAB2-11', 'IAB2-12', 'IAB2-14'],
content: {cat: ['IAB2-11', 'IAB2-12', 'IAB2-14'], language: 'EN'},
}
},
},

expected: {
bcat: ['IAB1-3', 'IAB1-4'],
badv: ['domain1.com', 'domain2.com'],
wlang: ['en', 'fr', 'de'],
site: {
pagecat: ['IAB2-11', 'IAB2-12', 'IAB2-14'],
content: {cat: ['IAB2-11', 'IAB2-12', 'IAB2-14'], language: 'EN'},
}},
}
},

expected: {site: {
pagecat: ['IAB2-11', 'IAB2-12', 'IAB2-14'],
content: {cat: ['IAB2-11', 'IAB2-12', 'IAB2-14'], language: 'EN'},
}},
},

{
title: 'site.keywords, site.content.keywords and user.keywords',
data: {
postBody: {},
ortb2: {
wlangb: ['en', 'fr', 'de'],
user: {keywords: 'key7,key8,key9'},
site: {
keywords: 'key1,key2,key3',
Expand All @@ -440,6 +455,7 @@ describe('nextMillenniumBidAdapterTests', () => {
},

expected: {
wlangb: ['en', 'fr', 'de'],
user: {keywords: 'key7,key8,key9'},
site: {
keywords: 'key1,key2,key3',
Expand Down Expand Up @@ -873,7 +889,7 @@ describe('nextMillenniumBidAdapterTests', () => {
const tests = [
{
title: 'test - 1',
bidderRequest: {bidderRequestId: 'mock-uuid'},
bidderRequest: {bidderRequestId: 'mock-uuid', timeout: 1200},
bidRequests: [
{
adUnitCode: 'test-div',
Expand Down Expand Up @@ -936,6 +952,7 @@ describe('nextMillenniumBidAdapterTests', () => {
impSize: 2,
requestSize: 1,
domain: 'example.com',
tmax: 1200,
},
},
];
Expand All @@ -948,6 +965,7 @@ describe('nextMillenniumBidAdapterTests', () => {

const requestData = JSON.parse(request[0].data);
expect(requestData.id).to.equal(expected.id);
expect(requestData.tmax).to.equal(expected.tmax);
expect(requestData?.imp?.length).to.equal(expected.impSize);
});
};
Expand Down

0 comments on commit 9058a09

Please sign in to comment.