From ad3295ee48a71dcacae77183a969e9573c6e64d3 Mon Sep 17 00:00:00 2001 From: mifanich Date: Tue, 23 Nov 2021 15:14:29 +0300 Subject: [PATCH 1/3] Add getUserSyncs function --- modules/nextMillenniumBidAdapter.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/nextMillenniumBidAdapter.js b/modules/nextMillenniumBidAdapter.js index afc409c19f6..ff9ccdc6791 100644 --- a/modules/nextMillenniumBidAdapter.js +++ b/modules/nextMillenniumBidAdapter.js @@ -4,6 +4,7 @@ import { BANNER } from '../src/mediaTypes.js'; const BIDDER_CODE = 'nextMillennium'; const ENDPOINT = 'https://pbs.nextmillmedia.com/openrtb2/auction'; +const SYNC_ENDPOINT = 'https://statics.nextmillmedia.com/load-cookie.html?v=4'; const TIME_TO_LIVE = 360; export const spec = { @@ -89,7 +90,31 @@ export const spec = { }); return bidResponses; - } + }, + + getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) { + if (!syncOptions.iframeEnabled) { + return + } + + let syncurl = gdprConsent && gdprConsent.gdprApplies ? `${SYNC_ENDPOINT}&gdpr=1&gdpr_consent=${gdprConsent.consentString}` : SYNC_ENDPOINT + + let bidders = [] + if (responses) { + _each(responses, (response) => { + _each(Object.keys(response.body.ext.responsetimemillis), b => bidders.push(b)) + }) + } + + if (bidders.length) { + syncurl += `&bidders=${bidders.join(',')}` + } + + return [{ + type: 'iframe', + url: syncurl + }]; + }, }; registerBidder(spec); From 443a92b2b6093523a1926d3be39a015c97bb60cb Mon Sep 17 00:00:00 2001 From: mifanich Date: Wed, 24 Nov 2021 12:56:46 +0300 Subject: [PATCH 2/3] add unit tests --- test/spec/modules/nextMillenniumBidAdapter_spec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/spec/modules/nextMillenniumBidAdapter_spec.js b/test/spec/modules/nextMillenniumBidAdapter_spec.js index 1a24c6d0575..886b9c70018 100644 --- a/test/spec/modules/nextMillenniumBidAdapter_spec.js +++ b/test/spec/modules/nextMillenniumBidAdapter_spec.js @@ -30,6 +30,18 @@ describe('nextMillenniumBidAdapterTests', function() { expect(JSON.parse(request[0].data).id).to.equal('b06c5141-fe8f-4cdf-9d7d-54415490a917'); }); + it('Test getUserSyncs function', function () { + const syncOptions = { + 'iframeEnabled': 'false' + } + const userSync = spec.getUserSyncs(syncOptions); + expect(userSync).to.be.an('array').with.lengthOf(1); + expect(userSync[0].type).to.exist; + expect(userSync[0].url).to.exist; + expect(userSync[0].type).to.be.equal('iframe'); + expect(userSync[0].url).to.be.equal('https://statics.nextmillmedia.com/load-cookie.html?v=4'); + }); + it('validate_response_params', function() { const serverResponse = { body: { From aba6d2c85addd8985a0face65886d331aebec2e0 Mon Sep 17 00:00:00 2001 From: mifanich Date: Wed, 24 Nov 2021 13:06:58 +0300 Subject: [PATCH 3/3] add unit tests --- test/spec/modules/nextMillenniumBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/nextMillenniumBidAdapter_spec.js b/test/spec/modules/nextMillenniumBidAdapter_spec.js index 886b9c70018..9b6364810e3 100644 --- a/test/spec/modules/nextMillenniumBidAdapter_spec.js +++ b/test/spec/modules/nextMillenniumBidAdapter_spec.js @@ -32,7 +32,7 @@ describe('nextMillenniumBidAdapterTests', function() { it('Test getUserSyncs function', function () { const syncOptions = { - 'iframeEnabled': 'false' + 'iframeEnabled': true } const userSync = spec.getUserSyncs(syncOptions); expect(userSync).to.be.an('array').with.lengthOf(1);