From 9058a09066196cea0b4640d8717a2988acd2c81e Mon Sep 17 00:00:00 2001 From: Mikhail Malkov Date: Mon, 28 Oct 2024 23:55:01 +0300 Subject: [PATCH] NextMillenniumBidAdapter: Added OpenRTB 2.6 parameters support: `bcat`, `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 --- modules/nextMillenniumBidAdapter.js | 26 +++++++--- .../modules/nextMillenniumBidAdapter_spec.js | 48 +++++++++++++------ 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/modules/nextMillenniumBidAdapter.js b/modules/nextMillenniumBidAdapter.js index 1d37c237b70..540659a7034 100644 --- a/modules/nextMillenniumBidAdapter.js +++ b/modules/nextMillenniumBidAdapter.js @@ -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'; @@ -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, @@ -65,6 +66,10 @@ const ALLOWED_ORTB2_PARAMETERS = [ 'site.keywords', 'site.content.keywords', 'user.keywords', + 'bcat', + 'badv', + 'wlang', + 'wlangb', ]; export const spec = { @@ -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)) ); }, @@ -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: [], }, @@ -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) { @@ -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; + }; }; }; @@ -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 = []) { diff --git a/test/spec/modules/nextMillenniumBidAdapter_spec.js b/test/spec/modules/nextMillenniumBidAdapter_spec.js index 6b2e7ef9ba0..0ba2635c87a 100644 --- a/test/spec/modules/nextMillenniumBidAdapter_spec.js +++ b/test/spec/modules/nextMillenniumBidAdapter_spec.js @@ -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 }, }, }, @@ -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, }, }, }, @@ -160,7 +163,7 @@ describe('nextMillenniumBidAdapterTests', () => { }, expected: { - regs: {ext: {gdpr: 0}}, + regs: {gdpr: 0}, }, }, @@ -414,16 +417,27 @@ 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'}, - }}, }, { @@ -431,6 +445,7 @@ describe('nextMillenniumBidAdapterTests', () => { data: { postBody: {}, ortb2: { + wlangb: ['en', 'fr', 'de'], user: {keywords: 'key7,key8,key9'}, site: { keywords: 'key1,key2,key3', @@ -440,6 +455,7 @@ describe('nextMillenniumBidAdapterTests', () => { }, expected: { + wlangb: ['en', 'fr', 'de'], user: {keywords: 'key7,key8,key9'}, site: { keywords: 'key1,key2,key3', @@ -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', @@ -936,6 +952,7 @@ describe('nextMillenniumBidAdapterTests', () => { impSize: 2, requestSize: 1, domain: 'example.com', + tmax: 1200, }, }, ]; @@ -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); }); };