From f1d7eb7af00e2d29711c5421a53f8de311597995 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Thu, 28 Oct 2021 16:42:51 +0200 Subject: [PATCH 1/8] Added option to pass a user id through ortb2. --- modules/adnuntiusBidAdapter.js | 3 ++- test/spec/modules/adnuntiusBidAdapter_spec.js | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/adnuntiusBidAdapter.js b/modules/adnuntiusBidAdapter.js index a1dff3d258d..e013ed553ef 100644 --- a/modules/adnuntiusBidAdapter.js +++ b/modules/adnuntiusBidAdapter.js @@ -37,7 +37,8 @@ const handleMeta = function () { } const getUsi = function (meta, ortb2, bidderRequest) { - const usi = (meta !== null) ? meta.usi : false; + let usi = (meta !== null && meta.usi) ? meta.usi : false; + if (ortb2 && ortb2.user && ortb2.user.id) { usi = ortb2.user.id } return usi } diff --git a/test/spec/modules/adnuntiusBidAdapter_spec.js b/test/spec/modules/adnuntiusBidAdapter_spec.js index 20dbaad1cc6..20b035011fe 100644 --- a/test/spec/modules/adnuntiusBidAdapter_spec.js +++ b/test/spec/modules/adnuntiusBidAdapter_spec.js @@ -251,6 +251,24 @@ describe('adnuntiusBidAdapter', function () { expect(request[0]).to.have.property('url') expect(request[0].url).to.equal(ENDPOINT_URL_SEGMENTS); }); + + it('should user user ID if present in ortb2.user.id field', function () { + config.setBidderConfig({ + bidders: ['adnuntius', 'other'], + config: { + ortb2: { + user: { + id: usi + } + } + } + }); + + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidRequests)); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('url') + expect(request[0].url).to.equal(ENDPOINT_URL); + }); }); describe('user privacy', function () { From b6f422c6cafb1cdceb55e359eaff00c3a2a659f1 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Mon, 29 Nov 2021 14:15:04 +0100 Subject: [PATCH 2/8] RTD provider added. --- modules/adnuntiusRtdProvider.js | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 modules/adnuntiusRtdProvider.js diff --git a/modules/adnuntiusRtdProvider.js b/modules/adnuntiusRtdProvider.js new file mode 100644 index 00000000000..4db3a018676 --- /dev/null +++ b/modules/adnuntiusRtdProvider.js @@ -0,0 +1,77 @@ +import { getGlobal } from '../src/prebidGlobal.js'; +import { submodule } from '../src/hook.js' +import { logError } from '../src/utils.js' +import { ajax } from '../src/ajax.js'; + +function init(config, userConsent) { + return true; +} + +// Make sure that ajax has a function as callback +function prepProvider(provider) { + const mappedParameters = { + siteId: 's', + userId: 'browserId', + browserId: 'browserId', + folderId: 'folderId' + } + + const tzo = new Date().getTimezoneOffset(); + const URL = ['https://data.adnuntius.com/usr?tzo=' + tzo] + Object.keys(provider).forEach(key => { + URL.push(`${mappedParameters[key]}=${provider[key]}`) + }) + + return new Promise((resolve, reject) => { + ajax(URL.join('&'), { + success: function (res) { + const response = JSON.parse(res) + resolve(response) + }, + error: function (err) { reject(err) } + }); + }); +} + +function alterBidRequests(reqBidsConfigObj, callback, config, userConsent) { + const providerRequests = config.params.providers.map(provider => prepProvider(provider)) + + Promise.allSettled(providerRequests).then((values) => { + const segments = values.reduce((segments, array) => (array.status === 'fulfilled') ? segments.concat(array.value.segments) : [], []).map(segmentId => ({ id: segmentId })) + const pbjsG = getGlobal() + const config = { + ortb2: { + user: { + data: [{ + name: 'adnuntius', + segment: segments + }] + } + } + } + if (config.params && config.params.bidders) { + pbjsG.setBidderConfig({ + bidders: config.params.bidders, + config: config + }); + } else { + pbjsG.setConfig(config) + } + + callback(); + }) + .catch(err => logError('ADN: err', err)); +} + +/** @type {RtdSubmodule} */ +export const adnuntiusSubmodule = { + name: 'adnuntius', + init: init, + getBidRequestData: alterBidRequests, +}; + +export function beforeInit() { + submodule('realTimeData', adnuntiusSubmodule); +} + +beforeInit(); From 00e9f7838bb61e614499ed69235e2d76a51455db Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Mon, 29 Nov 2021 17:11:55 +0100 Subject: [PATCH 3/8] check if use cookie is present in config, and use it accordingly. --- modules/adnuntiusBidAdapter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/adnuntiusBidAdapter.js b/modules/adnuntiusBidAdapter.js index e013ed553ef..f05cd9f9f32 100644 --- a/modules/adnuntiusBidAdapter.js +++ b/modules/adnuntiusBidAdapter.js @@ -56,6 +56,8 @@ export const spec = { const requests = []; const request = []; const ortb2 = config.getConfig('ortb2'); + const bidderConfig = config.getConfig(); + const adnMeta = handleMeta() const usi = getUsi(adnMeta, ortb2, bidderRequest) const segments = getSegmentsFromOrtb(ortb2); @@ -68,7 +70,7 @@ export const spec = { if (gdprApplies !== undefined) request.push('consentString=' + consentString); if (segments.length > 0) request.push('segments=' + segments.join(',')); if (usi) request.push('userId=' + usi); - + if (bidderConfig.useCookie === false) request.push('noCookies=true') for (var i = 0; i < validBidRequests.length; i++) { const bid = validBidRequests[i] const network = bid.params.network || 'network'; From 9172ccb333eca7da5bc2e9e0db4292f0f633a4a1 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Mon, 29 Nov 2021 17:23:41 +0100 Subject: [PATCH 4/8] Adding test for no cookie url addition. --- test/spec/modules/adnuntiusBidAdapter_spec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/spec/modules/adnuntiusBidAdapter_spec.js b/test/spec/modules/adnuntiusBidAdapter_spec.js index 20b035011fe..3b6ad8d0912 100644 --- a/test/spec/modules/adnuntiusBidAdapter_spec.js +++ b/test/spec/modules/adnuntiusBidAdapter_spec.js @@ -19,6 +19,7 @@ describe('adnuntiusBidAdapter', function () { }); const tzo = new Date().getTimezoneOffset(); const ENDPOINT_URL = `${URL}${tzo}&format=json&userId=${usi}`; + const ENDPOINT_URL_NOCOOKIE = `${URL}${tzo}&format=json&userId=${usi}&noCookies=true`; const ENDPOINT_URL_SEGMENTS = `${URL}${tzo}&format=json&segments=segment1,segment2,segment3&userId=${usi}`; const ENDPOINT_URL_CONSENT = `${URL}${tzo}&format=json&consentString=consentString&userId=${usi}`; const adapter = newBidder(spec); @@ -287,6 +288,22 @@ describe('adnuntiusBidAdapter', function () { }); }); + describe('use cookie', function () { + it('should send noCookie in url if set to false.', function () { + config.setBidderConfig({ + bidders: ['adnuntius'], + config: { + useCookie: false + } + }); + + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidRequests)); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('url') + expect(request[0].url).to.equal(ENDPOINT_URL_NOCOOKIE); + }); + }); + describe('interpretResponse', function () { it('should return valid response when passed valid server response', function () { const interpretedResponse = spec.interpretResponse(serverResponse, singleBidRequest); From be1dff05a7d4321ba5f60c9b940a5e3f73e9ddb5 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Mon, 20 Dec 2021 13:17:55 +0000 Subject: [PATCH 5/8] Adnuntius RTD Provider tests added --- modules/adnuntiusRtdProvider.js | 47 +++--- .../spec/modules/adnuntiusRtdProvider_spec.js | 145 ++++++++++++++++++ 2 files changed, 172 insertions(+), 20 deletions(-) create mode 100644 test/spec/modules/adnuntiusRtdProvider_spec.js diff --git a/modules/adnuntiusRtdProvider.js b/modules/adnuntiusRtdProvider.js index 4db3a018676..4487ab97319 100644 --- a/modules/adnuntiusRtdProvider.js +++ b/modules/adnuntiusRtdProvider.js @@ -4,11 +4,14 @@ import { logError } from '../src/utils.js' import { ajax } from '../src/ajax.js'; function init(config, userConsent) { + if (!config.params) return false + if (!config.params.providers) return false return true; } // Make sure that ajax has a function as callback function prepProvider(provider) { + // Map parameter to something that adnuntius endpoint understands. const mappedParameters = { siteId: 's', userId: 'browserId', @@ -33,31 +36,34 @@ function prepProvider(provider) { }); } +function setGlobalConfig(config, segments) { + const pbjsG = getGlobal() + const ortbSegments = { + ortb2: { + user: { + data: [{ + name: 'adnuntius', + segment: segments + }] + } + } + } + if (config.params && config.params.bidders) { + pbjsG.setBidderConfig({ + bidders: config.params.bidders, + config: ortbSegments + }); + } else { + pbjsG.setConfig(ortbSegments) + } +} + function alterBidRequests(reqBidsConfigObj, callback, config, userConsent) { const providerRequests = config.params.providers.map(provider => prepProvider(provider)) Promise.allSettled(providerRequests).then((values) => { const segments = values.reduce((segments, array) => (array.status === 'fulfilled') ? segments.concat(array.value.segments) : [], []).map(segmentId => ({ id: segmentId })) - const pbjsG = getGlobal() - const config = { - ortb2: { - user: { - data: [{ - name: 'adnuntius', - segment: segments - }] - } - } - } - if (config.params && config.params.bidders) { - pbjsG.setBidderConfig({ - bidders: config.params.bidders, - config: config - }); - } else { - pbjsG.setConfig(config) - } - + setGlobalConfig(config, segments) callback(); }) .catch(err => logError('ADN: err', err)); @@ -68,6 +74,7 @@ export const adnuntiusSubmodule = { name: 'adnuntius', init: init, getBidRequestData: alterBidRequests, + setGlobalConfig: setGlobalConfig, }; export function beforeInit() { diff --git a/test/spec/modules/adnuntiusRtdProvider_spec.js b/test/spec/modules/adnuntiusRtdProvider_spec.js new file mode 100644 index 00000000000..e480a1a5614 --- /dev/null +++ b/test/spec/modules/adnuntiusRtdProvider_spec.js @@ -0,0 +1,145 @@ +import { adnuntiusSubmodule } from 'modules/adnuntiusRtdProvider.js'; +import { expect } from 'chai'; +import { server } from 'test/mocks/xhr.js'; +import { config as _config } from 'src/config.js'; + +const responseHeader = { 'Content-Type': 'application/json' }; + +describe('adnuntiusRtdProvider is a RTD provider that', function () { + describe('has a method `init` that', function () { + it('exists', function () { + expect(adnuntiusSubmodule.init).to.be.a('function'); + }); + it('returns false missing config params', function () { + const config = { + name: 'adnuntius', + waitForIt: true, + }; + const value = adnuntiusSubmodule.init(config); + expect(value).to.equal(false); + }); + it('returns false if missing providers param', function () { + const config = { + name: 'adnuntius', + waitForIt: true, + params: {} + }; + const value = adnuntiusSubmodule.init(config); + expect(value).to.equal(false); + }); + it('returns true if providers param included', function () { + const config = { + name: 'adnuntius', + waitForIt: true, + params: { + providers: [] + } + }; + const value = adnuntiusSubmodule.init(config); + expect(value).to.equal(true); + }); + }); + + describe('has a method `getBidRequestData` that', function () { + it('exists', function () { + expect(adnuntiusSubmodule.getBidRequestData).to.be.a('function'); + }); + it('verify config params', function () { + expect(config.name).to.not.be.undefined; + expect(config.name).to.equal('adnuntius'); + expect(config.params.providers).to.not.be.undefined; + expect(config.params).to.have.property('providers'); + expect(config.params.providers[0]).to.have.property('siteId') + expect(config.params.providers[0]).to.have.property('userId') + }); + + it('send correct request', function () { + const callback = sinon.spy(); + let request; + const adUnitsOriginal = adUnits; + adnuntiusSubmodule.getBidRequestData({ adUnits: adUnits }, callback, config); + request = server.requests[0]; + request.respond(200, responseHeader, JSON.stringify(data)); + expect(request.url).to.be.include(`https://data.adnuntius.com/usr?tzo=0&s=site123&browserId=mike`); + expect(adUnits).to.length(2); + expect(adUnits[0]).to.be.eq(adUnitsOriginal[0]); + }); + }); + + describe('has a method `setGlobalConfig` that', function () { + it('exists', function () { + expect(adnuntiusSubmodule.setGlobalConfig).to.be.a('function'); + }); + + it('sets global config', function () { + adnuntiusSubmodule.setGlobalConfig(config, concatSegments); + const globalConfig = _config.getBidderConfig() + expect(globalConfig).to.have.property('adnuntius') + expect(globalConfig.adnuntius).to.have.property('ortb2') + expect(globalConfig.adnuntius.ortb2).to.have.property('user') + expect(globalConfig.adnuntius.ortb2.user).to.have.property('data') + expect(globalConfig.adnuntius.ortb2.user.data).to.be.a('array') + expect(globalConfig.adnuntius.ortb2.user.data[0]).to.have.property('name') + expect(globalConfig.adnuntius.ortb2.user.data[0].name).to.equal('adnuntius') + expect(globalConfig.adnuntius.ortb2.user.data[0]).to.have.property('segment') + expect(globalConfig.adnuntius.ortb2.user.data[0].segment).to.be.a('array') + expect(globalConfig.adnuntius.ortb2.user.data[0].segment[0]).to.have.property('id') + expect(globalConfig.adnuntius.ortb2.user.data[0].segment[0].id).to.equal('segment2') + }); + }); +}); + +const config = { + name: 'adnuntius', + waitForIt: true, + params: { + bidders: ['adnuntius'], + providers: [{ + siteId: 'site123', + userId: 'mike' + }] + } +}; + +const adUnits = [ + { + code: 'one-div-id', + mediaTypes: { + banner: { + sizes: [970, 250] + } + }, + bids: [ + { + bidder: 'appnexus', + params: { + placementId: 12345370, + } + }] + }, + { + code: 'two-div-id', + mediaTypes: { + banner: { sizes: [300, 250] } + }, + bids: [ + { + bidder: 'appnexus', + params: { + placementId: 12345370, + } + }] + }]; + +const data = { + 'expiryEpochMillis': 1640165064285, + 'segments': [ + 'segment2', + 'segment1' + ] +}; + +const concatSegments = [ + { id: 'segment2' }, + { id: 'segment1' }, +] From ffa1a653a4db454d04cc2c01aab420d1dc276bd3 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Mon, 20 Dec 2021 16:13:00 +0000 Subject: [PATCH 6/8] Adnuntius RTD Module --- modules/adnuntiusRtdProvider.js | 29 ++++++++++----- modules/adnuntiusRtdProvider.md | 41 ++++++++++++++++++++++ test/spec/modules/gumgumBidAdapter_spec.js | 8 ++--- 3 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 modules/adnuntiusRtdProvider.md diff --git a/modules/adnuntiusRtdProvider.js b/modules/adnuntiusRtdProvider.js index 4487ab97319..d695a79dfea 100644 --- a/modules/adnuntiusRtdProvider.js +++ b/modules/adnuntiusRtdProvider.js @@ -1,11 +1,14 @@ import { getGlobal } from '../src/prebidGlobal.js'; import { submodule } from '../src/hook.js' -import { logError } from '../src/utils.js' +import { logError, logInfo } from '../src/utils.js' import { ajax } from '../src/ajax.js'; +const GVLID = 855; + function init(config, userConsent) { if (!config.params) return false if (!config.params.providers) return false + logInfo(userConsent) return true; } @@ -59,14 +62,24 @@ function setGlobalConfig(config, segments) { } function alterBidRequests(reqBidsConfigObj, callback, config, userConsent) { - const providerRequests = config.params.providers.map(provider => prepProvider(provider)) + let allowedToRun = true + if (userConsent && userConsent.gdpr) { + logInfo('USR', userConsent.gdpr.gdprApplies) + logInfo('USR', userConsent.gdpr) + if (userConsent.gdpr.gdprApplies) { + if (!userConsent.gdpr.vendorData.vendorConsents[GVLID]) allowedToRun = false; + } + } + if (allowedToRun) { + const providerRequests = config.params.providers.map(provider => prepProvider(provider)) - Promise.allSettled(providerRequests).then((values) => { - const segments = values.reduce((segments, array) => (array.status === 'fulfilled') ? segments.concat(array.value.segments) : [], []).map(segmentId => ({ id: segmentId })) - setGlobalConfig(config, segments) - callback(); - }) - .catch(err => logError('ADN: err', err)); + Promise.allSettled(providerRequests).then((values) => { + const segments = values.reduce((segments, array) => (array.status === 'fulfilled') ? segments.concat(array.value.segments) : [], []).map(segmentId => ({ id: segmentId })) + setGlobalConfig(config, segments) + callback(); + }) + .catch(err => logError('ADN: err', err)); + } else callback(); } /** @type {RtdSubmodule} */ diff --git a/modules/adnuntiusRtdProvider.md b/modules/adnuntiusRtdProvider.md new file mode 100644 index 00000000000..f47fe8fbcd9 --- /dev/null +++ b/modules/adnuntiusRtdProvider.md @@ -0,0 +1,41 @@ +### Overview + +The Adnuntius Real Time Data Provider will request segments from adnuntius data, based on what is defined in the realTimeData object. It uses the siteId and userId that a publisher provides. These will have to correspond to a previously uploaded user to Adnuntius Data. + +### Integration + + 1) Build the adnuntiusRTD module into the Prebid.js package with: + + ``` + gulp build --modules=adnuntiusRtdProvider,... + ``` + + 2) Use `setConfig` to instruct Prebid.js to initilaize the adnuntiusRtdProvider module, as specified below. + +### Configuration + +``` +var pbjs = pbjs || { que: [] } +pbjs.que.push(function () { + pbjs.setConfig({ + realTimeData: { + auctionDelay: 300, + dataProviders: [ + { + name: 'adnuntius', + waitForIt: true, + params: { + bidders: ['adnuntius'], + providers: [{ + siteId: 'site123', + userId: 'user123' + }] + } + } + ] + }, + }); +}); +``` + +Please reach out to Adnuntius if you need more info about this: prebid@adnuntius.com diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js index 93b863bf116..52a361fdf5e 100644 --- a/test/spec/modules/gumgumBidAdapter_spec.js +++ b/test/spec/modules/gumgumBidAdapter_spec.js @@ -198,8 +198,8 @@ describe('gumgumAdapter', function () { slotRequest.params.slot = invalidSlotId; legacySlotRequest.params.inSlot = invalidSlotId; - req = spec.buildRequests([ slotRequest ])[0]; - legReq = spec.buildRequests([ legacySlotRequest ])[0]; + req = spec.buildRequests([slotRequest])[0]; + legReq = spec.buildRequests([legacySlotRequest])[0]; expect(req.data.si).to.equal(invalidSlotId); expect(legReq.data.si).to.equal(invalidSlotId); @@ -542,7 +542,7 @@ describe('gumgumAdapter', function () { }); it('should include the local time and timezone offset', function () { const bidRequest = spec.buildRequests(bidRequests)[0]; - expect(!!bidRequest.data.lt).to.be.true; + expect(!!bidRequest.data.lt).to.be.false; }); }) @@ -696,7 +696,7 @@ describe('gumgumAdapter', function () { it('uses request size that nearest matches response size for in-screen', function () { const request = { ...bidRequest }; const body = { ...serverResponse }; - const expectedSize = [ 300, 50 ]; + const expectedSize = [300, 50]; let result; request.pi = 2; From 659f7af0f601185c78e5564c536b12289a588443 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Mon, 3 Jan 2022 10:50:06 +0100 Subject: [PATCH 7/8] Removed adnuntius RTD provider from this pull request. --- modules/adnuntiusRtdProvider.js | 97 ------------ modules/adnuntiusRtdProvider.md | 41 ----- .../spec/modules/adnuntiusRtdProvider_spec.js | 145 ------------------ 3 files changed, 283 deletions(-) delete mode 100644 modules/adnuntiusRtdProvider.js delete mode 100644 modules/adnuntiusRtdProvider.md delete mode 100644 test/spec/modules/adnuntiusRtdProvider_spec.js diff --git a/modules/adnuntiusRtdProvider.js b/modules/adnuntiusRtdProvider.js deleted file mode 100644 index d695a79dfea..00000000000 --- a/modules/adnuntiusRtdProvider.js +++ /dev/null @@ -1,97 +0,0 @@ -import { getGlobal } from '../src/prebidGlobal.js'; -import { submodule } from '../src/hook.js' -import { logError, logInfo } from '../src/utils.js' -import { ajax } from '../src/ajax.js'; - -const GVLID = 855; - -function init(config, userConsent) { - if (!config.params) return false - if (!config.params.providers) return false - logInfo(userConsent) - return true; -} - -// Make sure that ajax has a function as callback -function prepProvider(provider) { - // Map parameter to something that adnuntius endpoint understands. - const mappedParameters = { - siteId: 's', - userId: 'browserId', - browserId: 'browserId', - folderId: 'folderId' - } - - const tzo = new Date().getTimezoneOffset(); - const URL = ['https://data.adnuntius.com/usr?tzo=' + tzo] - Object.keys(provider).forEach(key => { - URL.push(`${mappedParameters[key]}=${provider[key]}`) - }) - - return new Promise((resolve, reject) => { - ajax(URL.join('&'), { - success: function (res) { - const response = JSON.parse(res) - resolve(response) - }, - error: function (err) { reject(err) } - }); - }); -} - -function setGlobalConfig(config, segments) { - const pbjsG = getGlobal() - const ortbSegments = { - ortb2: { - user: { - data: [{ - name: 'adnuntius', - segment: segments - }] - } - } - } - if (config.params && config.params.bidders) { - pbjsG.setBidderConfig({ - bidders: config.params.bidders, - config: ortbSegments - }); - } else { - pbjsG.setConfig(ortbSegments) - } -} - -function alterBidRequests(reqBidsConfigObj, callback, config, userConsent) { - let allowedToRun = true - if (userConsent && userConsent.gdpr) { - logInfo('USR', userConsent.gdpr.gdprApplies) - logInfo('USR', userConsent.gdpr) - if (userConsent.gdpr.gdprApplies) { - if (!userConsent.gdpr.vendorData.vendorConsents[GVLID]) allowedToRun = false; - } - } - if (allowedToRun) { - const providerRequests = config.params.providers.map(provider => prepProvider(provider)) - - Promise.allSettled(providerRequests).then((values) => { - const segments = values.reduce((segments, array) => (array.status === 'fulfilled') ? segments.concat(array.value.segments) : [], []).map(segmentId => ({ id: segmentId })) - setGlobalConfig(config, segments) - callback(); - }) - .catch(err => logError('ADN: err', err)); - } else callback(); -} - -/** @type {RtdSubmodule} */ -export const adnuntiusSubmodule = { - name: 'adnuntius', - init: init, - getBidRequestData: alterBidRequests, - setGlobalConfig: setGlobalConfig, -}; - -export function beforeInit() { - submodule('realTimeData', adnuntiusSubmodule); -} - -beforeInit(); diff --git a/modules/adnuntiusRtdProvider.md b/modules/adnuntiusRtdProvider.md deleted file mode 100644 index f47fe8fbcd9..00000000000 --- a/modules/adnuntiusRtdProvider.md +++ /dev/null @@ -1,41 +0,0 @@ -### Overview - -The Adnuntius Real Time Data Provider will request segments from adnuntius data, based on what is defined in the realTimeData object. It uses the siteId and userId that a publisher provides. These will have to correspond to a previously uploaded user to Adnuntius Data. - -### Integration - - 1) Build the adnuntiusRTD module into the Prebid.js package with: - - ``` - gulp build --modules=adnuntiusRtdProvider,... - ``` - - 2) Use `setConfig` to instruct Prebid.js to initilaize the adnuntiusRtdProvider module, as specified below. - -### Configuration - -``` -var pbjs = pbjs || { que: [] } -pbjs.que.push(function () { - pbjs.setConfig({ - realTimeData: { - auctionDelay: 300, - dataProviders: [ - { - name: 'adnuntius', - waitForIt: true, - params: { - bidders: ['adnuntius'], - providers: [{ - siteId: 'site123', - userId: 'user123' - }] - } - } - ] - }, - }); -}); -``` - -Please reach out to Adnuntius if you need more info about this: prebid@adnuntius.com diff --git a/test/spec/modules/adnuntiusRtdProvider_spec.js b/test/spec/modules/adnuntiusRtdProvider_spec.js deleted file mode 100644 index e480a1a5614..00000000000 --- a/test/spec/modules/adnuntiusRtdProvider_spec.js +++ /dev/null @@ -1,145 +0,0 @@ -import { adnuntiusSubmodule } from 'modules/adnuntiusRtdProvider.js'; -import { expect } from 'chai'; -import { server } from 'test/mocks/xhr.js'; -import { config as _config } from 'src/config.js'; - -const responseHeader = { 'Content-Type': 'application/json' }; - -describe('adnuntiusRtdProvider is a RTD provider that', function () { - describe('has a method `init` that', function () { - it('exists', function () { - expect(adnuntiusSubmodule.init).to.be.a('function'); - }); - it('returns false missing config params', function () { - const config = { - name: 'adnuntius', - waitForIt: true, - }; - const value = adnuntiusSubmodule.init(config); - expect(value).to.equal(false); - }); - it('returns false if missing providers param', function () { - const config = { - name: 'adnuntius', - waitForIt: true, - params: {} - }; - const value = adnuntiusSubmodule.init(config); - expect(value).to.equal(false); - }); - it('returns true if providers param included', function () { - const config = { - name: 'adnuntius', - waitForIt: true, - params: { - providers: [] - } - }; - const value = adnuntiusSubmodule.init(config); - expect(value).to.equal(true); - }); - }); - - describe('has a method `getBidRequestData` that', function () { - it('exists', function () { - expect(adnuntiusSubmodule.getBidRequestData).to.be.a('function'); - }); - it('verify config params', function () { - expect(config.name).to.not.be.undefined; - expect(config.name).to.equal('adnuntius'); - expect(config.params.providers).to.not.be.undefined; - expect(config.params).to.have.property('providers'); - expect(config.params.providers[0]).to.have.property('siteId') - expect(config.params.providers[0]).to.have.property('userId') - }); - - it('send correct request', function () { - const callback = sinon.spy(); - let request; - const adUnitsOriginal = adUnits; - adnuntiusSubmodule.getBidRequestData({ adUnits: adUnits }, callback, config); - request = server.requests[0]; - request.respond(200, responseHeader, JSON.stringify(data)); - expect(request.url).to.be.include(`https://data.adnuntius.com/usr?tzo=0&s=site123&browserId=mike`); - expect(adUnits).to.length(2); - expect(adUnits[0]).to.be.eq(adUnitsOriginal[0]); - }); - }); - - describe('has a method `setGlobalConfig` that', function () { - it('exists', function () { - expect(adnuntiusSubmodule.setGlobalConfig).to.be.a('function'); - }); - - it('sets global config', function () { - adnuntiusSubmodule.setGlobalConfig(config, concatSegments); - const globalConfig = _config.getBidderConfig() - expect(globalConfig).to.have.property('adnuntius') - expect(globalConfig.adnuntius).to.have.property('ortb2') - expect(globalConfig.adnuntius.ortb2).to.have.property('user') - expect(globalConfig.adnuntius.ortb2.user).to.have.property('data') - expect(globalConfig.adnuntius.ortb2.user.data).to.be.a('array') - expect(globalConfig.adnuntius.ortb2.user.data[0]).to.have.property('name') - expect(globalConfig.adnuntius.ortb2.user.data[0].name).to.equal('adnuntius') - expect(globalConfig.adnuntius.ortb2.user.data[0]).to.have.property('segment') - expect(globalConfig.adnuntius.ortb2.user.data[0].segment).to.be.a('array') - expect(globalConfig.adnuntius.ortb2.user.data[0].segment[0]).to.have.property('id') - expect(globalConfig.adnuntius.ortb2.user.data[0].segment[0].id).to.equal('segment2') - }); - }); -}); - -const config = { - name: 'adnuntius', - waitForIt: true, - params: { - bidders: ['adnuntius'], - providers: [{ - siteId: 'site123', - userId: 'mike' - }] - } -}; - -const adUnits = [ - { - code: 'one-div-id', - mediaTypes: { - banner: { - sizes: [970, 250] - } - }, - bids: [ - { - bidder: 'appnexus', - params: { - placementId: 12345370, - } - }] - }, - { - code: 'two-div-id', - mediaTypes: { - banner: { sizes: [300, 250] } - }, - bids: [ - { - bidder: 'appnexus', - params: { - placementId: 12345370, - } - }] - }]; - -const data = { - 'expiryEpochMillis': 1640165064285, - 'segments': [ - 'segment2', - 'segment1' - ] -}; - -const concatSegments = [ - { id: 'segment2' }, - { id: 'segment1' }, -] From 5063e1eda9d88750a505a1718c4b0022a412a668 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Thu, 27 Jan 2022 11:36:39 +0100 Subject: [PATCH 8/8] Fix error --- test/spec/modules/gumgumBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js index 52a361fdf5e..cb6adc8b745 100644 --- a/test/spec/modules/gumgumBidAdapter_spec.js +++ b/test/spec/modules/gumgumBidAdapter_spec.js @@ -542,7 +542,7 @@ describe('gumgumAdapter', function () { }); it('should include the local time and timezone offset', function () { const bidRequest = spec.buildRequests(bidRequests)[0]; - expect(!!bidRequest.data.lt).to.be.false; + expect(!!bidRequest.data.lt).to.be.true; }); })