From 987c08289b2328864dc7ea1b893b9716afbe8569 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Wed, 7 Apr 2021 14:57:15 +0200 Subject: [PATCH 001/303] Added automatic tzo and targetId to adserver request. (#6534) --- modules/adnuntiusBidAdapter.js | 11 ++++++----- test/spec/modules/adnuntiusBidAdapter_spec.js | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/adnuntiusBidAdapter.js b/modules/adnuntiusBidAdapter.js index 16594b3453c..f250f6e334d 100644 --- a/modules/adnuntiusBidAdapter.js +++ b/modules/adnuntiusBidAdapter.js @@ -1,7 +1,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'adnuntius'; -const ENDPOINT_URL = 'https://delivery.adnuntius.com/i?tzo=-60&format=json'; +const ENDPOINT_URL = 'https://delivery.adnuntius.com/i?tzo='; export const spec = { code: BIDDER_CODE, @@ -14,6 +14,7 @@ export const spec = { const networks = {}; const bidRequests = {}; const requests = []; + const tzo = new Date().getTimezoneOffset(); for (var i = 0; i < validBidRequests.length; i++) { const bid = validBidRequests[i] @@ -23,7 +24,7 @@ export const spec = { networks[network] = networks[network] || {}; networks[network].adUnits = networks[network].adUnits || []; - networks[network].adUnits.push({ ...bid.params.targeting, auId: bid.params.auId }); + networks[network].adUnits.push({ ...bid.params.targeting, auId: bid.params.auId, targetId: bid.bidId }); } const networkKeys = Object.keys(networks) @@ -31,7 +32,7 @@ export const spec = { const network = networkKeys[j]; requests.push({ method: 'POST', - url: ENDPOINT_URL, + url: ENDPOINT_URL + tzo + '&format=json', data: JSON.stringify(networks[network]), bid: bidRequests[network] }); @@ -50,11 +51,11 @@ export const spec = { const bid = adUnit.ads[0]; bidResponses.push({ requestId: bidRequest.bid[k].bidId, - cpm: (bid.cpm) ? bid.cpm.amount : 0, + cpm: (bid.bid) ? bid.bid.amount : 0, width: Number(bid.creativeWidth), height: Number(bid.creativeHeight), creativeId: bid.creativeId, - currency: (bid.cpm) ? bid.cpm.currency : 'EUR', + currency: (bid.bid) ? bid.bid.currency : 'EUR', netRevenue: false, ttl: 360, ad: adUnit.html diff --git a/test/spec/modules/adnuntiusBidAdapter_spec.js b/test/spec/modules/adnuntiusBidAdapter_spec.js index 54ff038c083..f4b0306451c 100644 --- a/test/spec/modules/adnuntiusBidAdapter_spec.js +++ b/test/spec/modules/adnuntiusBidAdapter_spec.js @@ -4,7 +4,8 @@ import { spec } from 'modules/adnuntiusBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; describe('adnuntiusBidAdapter', function () { - const ENDPOINT_URL = 'https://delivery.adnuntius.com/i?tzo=-60&format=json'; + const tzo = new Date().getTimezoneOffset(); + const ENDPOINT_URL = `https://delivery.adnuntius.com/i?tzo=${tzo}&format=json`; const adapter = newBidder(spec); const bidRequests = [ { @@ -47,8 +48,8 @@ describe('adnuntiusBidAdapter', function () { 'destination': 'http://google.com' }, 'cpm': { 'amount': 5.0, 'currency': 'NOK' }, - 'bid': { 'amount': 0.005, 'currency': 'NOK' }, - 'cost': { 'amount': 0.005, 'currency': 'NOK' }, + 'bid': { 'amount': 5.0, 'currency': 'NOK' }, + 'cost': { 'amount': 5.0, 'currency': 'NOK' }, 'impressionTrackingUrls': [], 'impressionTrackingUrlsEsc': [], 'adId': 'adn-id-1347343135', @@ -96,7 +97,7 @@ describe('adnuntiusBidAdapter', function () { expect(request[0]).to.have.property('url'); expect(request[0].url).to.equal(ENDPOINT_URL); expect(request[0]).to.have.property('data'); - expect(request[0].data).to.equal('{\"adUnits\":[{\"auId\":\"8b6bc\"}]}'); + expect(request[0].data).to.equal('{\"adUnits\":[{\"auId\":\"8b6bc\",\"targetId\":\"123\"}]}'); }); }); From 0ab09644cc13fd9f7c7f2394d6b1a2f48c286cbd Mon Sep 17 00:00:00 2001 From: prebidtappx <77485538+prebidtappx@users.noreply.github.com> Date: Wed, 7 Apr 2021 15:12:21 +0200 Subject: [PATCH 002/303] Tappx Bid Adapter: minor updates and universal id added (#6504) * UPDATE: add initial UID * UPDATE: UID change user ext * UPDATE: UID clean logs * UPDATE: add host info * UPDATE: tappx bid adapter universal id * UPDATE: fix bidder param * UPDATE: tappxBidAdapter tests * tappxBidAdapter - fix spacing * tappxBidAdapter: add test user eids array * tappxBidAdapter: update eids array * FIX: package-lock.json Co-authored-by: marc_tappx --- modules/tappxBidAdapter.js | 48 +++++++- package-lock.json | 2 +- test/spec/modules/tappxBidAdapter_spec.js | 141 ++++++++++++++++++---- 3 files changed, 163 insertions(+), 28 deletions(-) diff --git a/modules/tappxBidAdapter.js b/modules/tappxBidAdapter.js index 7782f151802..3677c3ce4c9 100644 --- a/modules/tappxBidAdapter.js +++ b/modules/tappxBidAdapter.js @@ -8,6 +8,8 @@ import { config } from '../src/config.js'; const BIDDER_CODE = 'tappx'; const TTL = 360; const CUR = 'USD'; +const TAPPX_BIDDER_VERSION = '0.1.10329'; +const TYPE_CNN = 'prebidjs'; var HOST; var hostDomain; @@ -134,7 +136,9 @@ function interpretBannerBid(serverBid, request) { */ function buildOneRequest(validBidRequests, bidderRequest) { HOST = utils.deepAccess(validBidRequests, 'params.host'); - hostDomain = HOST.split('/', 1)[0]; + let hostInfo = getHostInfo(HOST) + // hostDomain = HOST.split('/', 1)[0]; + hostDomain = hostInfo.domain; const ENDPOINT = utils.deepAccess(validBidRequests, 'params.endpoint'); const TAPPXKEY = utils.deepAccess(validBidRequests, 'params.tappxkey'); @@ -206,6 +210,14 @@ function buildOneRequest(validBidRequests, bidderRequest) { imp.secure = 1; imp.bidfloor = utils.deepAccess(validBidRequests, 'params.bidfloor'); + + let bidder = {}; + bidder.tappxkey = TAPPXKEY; + bidder.endpoint = ENDPOINT; + bidder.host = hostInfo.url; + + imp.ext = {}; + imp.ext.bidder = bidder; // < Imp object // > Device object @@ -230,8 +242,6 @@ function buildOneRequest(validBidRequests, bidderRequest) { // > Params let params = {}; params.host = 'tappx.com'; - params.tappxkey = TAPPXKEY; - params.endpoint = ENDPOINT; params.bidfloor = BIDFLOOR; // < Params @@ -253,6 +263,14 @@ function buildOneRequest(validBidRequests, bidderRequest) { if (config.getConfig('coppa') === true) { regs.coppa = config.getConfig('coppa') === true ? 1 : 0; } + + // Universal ID + const eidsArr = utils.deepAccess(validBidRequests, 'userIdAsEids'); + payload.user = { + ext: { + eids: eidsArr + } + }; // < GDPR // > Payload @@ -270,7 +288,7 @@ function buildOneRequest(validBidRequests, bidderRequest) { return { method: 'POST', - url: `https://${HOST}/${ENDPOINT}?type_cnn=prebidjs`, + url: `https://${HOST}/${ENDPOINT}?type_cnn=${TYPE_CNN}&v=${TAPPX_BIDDER_VERSION}`, data: JSON.stringify(payload), bids: validBidRequests }; @@ -286,4 +304,26 @@ function getOs() { if (ua == null) { return 'unknown'; } else if (ua.match(/(iPhone|iPod|iPad)/)) { return 'ios'; } else if (ua.match(/Android/)) { return 'android'; } else if (ua.match(/Window/)) { return 'windows'; } else { return 'unknown'; } } +function getHostInfo(hostParam) { + let domainInfo = {}; + + domainInfo.domain = hostParam.split('/', 1)[0]; + domainInfo.url = hostParam; + + let regexNewEndpoints = new RegExp(`^(zz.*|testing)\.ssp\.tappx\.com$`, 'i'); + let regexClassicEndpoints = new RegExp(`^[a-z]{3}\.[a-z]{3}\.tappx\.com$`, 'i'); + + if (regexNewEndpoints.test(domainInfo.domain)) { + let endpoint = domainInfo.domain.split('.', 1)[0] + if (endpoint.toUpperCase().indexOf('TESTING') === -1) { + domainInfo.endpoint = endpoint + domainInfo.new_endpoint = true; + } + } else if (regexClassicEndpoints.test(domainInfo.domain)) { + domainInfo.new_endpoint = false; + } + + return domainInfo; +} + registerBidder(spec); diff --git a/package-lock.json b/package-lock.json index 330298cbaac..5131b5f4d23 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24613,4 +24613,4 @@ } } } -} +} \ No newline at end of file diff --git a/test/spec/modules/tappxBidAdapter_spec.js b/test/spec/modules/tappxBidAdapter_spec.js index c4410d8ce5e..1d3f9676d09 100644 --- a/test/spec/modules/tappxBidAdapter_spec.js +++ b/test/spec/modules/tappxBidAdapter_spec.js @@ -1,36 +1,126 @@ import { assert } from 'chai'; -import {spec} from 'modules/tappxBidAdapter'; +import { spec } from 'modules/tappxBidAdapter'; -describe('Tappx adapter tests', function () { - describe('isBidRequestValid', function () { - let bid = { bidder: 'tappx', params: { host: 'testing.ssp.tappx.com', tappxkey: 'pub-1234-test-1234', endpoint: 'ZZ1234PBJS', bidfloor: 0.005 } }; +const c_BIDREQUEST = { + data: { + }, + bids: [ + { + bidder: 'tappx', + params: { + host: 'testing.ssp.tappx.com\/rtb\/v2\/', + tappxkey: 'pub-1234-android-1234', + endpoint: 'ZZ1234PBJS', + bidfloor: 0.05 + }, + crumbs: { + pubcid: 'df2144f7-673f-4440-83f5-cd4a73642d99' + }, + fpd: { + context: { + adServer: { + name: 'gam', + adSlot: '/19968336/header-bid-tag-0' + }, + pbAdSlot: '/19968336/header-bid-tag-0', + }, + }, + mediaTypes: { + banner: { + sizes: [ + [ + 320, + 480 + ] + ] + } + }, + adUnitCode: 'div-1', + transactionId: '47dd44e8-e7db-417c-a8f1-621a2e1a117d', + sizes: [ + [ + 320, + 480 + ] + ], + bidId: '2170932097e505', + bidderRequestId: '140ba7a1ab7aeb', + auctionId: '1c54b4f1-645f-44e6-b8ae-5d43c923ef1c', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0, + } + ] +}; +const c_SERVERRESPONSE = { + body: { + id: '1c54b4f1-645f-44e6-b8ae-5d43c923ef1c', + bidid: 'bid3811165568213389257', + seatbid: [ + { + seat: '1', + group: 0, + bid: [ + { + id: '3811165568213389257', + impid: 1, + price: 0.05, + adm: "\t", + w: 320, + h: 480, + lurl: 'http://testing.ssp.tappx.com/rtb/RTBv2Loss?id=3811165568213389257&ep=ZZ1234PBJS&au=test&bu=localhost&sz=320x480&pu=0.005&pt=0.01&cid=&crid=&adv=&aid=${AUCTION_ID}&bidid=${AUCTION_BID_ID}&impid=${AUCTION_IMP_ID}&sid=${AUCTION_SEAT_ID}&adid=${AUCTION_AD_ID}&ap=${AUCTION_PRICE}&cur=${AUCTION_CURRENCY}&mbr=${AUCTION_MBR}&l=${AUCTION_LOSS}', + cid: '01744fbb521e9fb10ffea926190effea', + crid: 'a13cf884e66e7c660afec059c89d98b6', + adomain: [ + ], + }, + ], + }, + ], + cur: 'USD', + }, + headers: {} +}; +const c_CONSENTSTRING = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; +const c_VALIDBIDREQUESTS = [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com\/rtb\/v2\/', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'test': 1}, 'userId': {'haloId': '0000x179MZAzMqUWsFonu7Drm3eDDBMYtj5SPoWQnl89Upk3WTlCvEnKI9SshX0p6eFJ7otPYix179MZAzMqUWsFonu7Drm3eDDBMYtj5SPoWQnl89Upk3WTlCvEnKI9SshX0p6e', 'id5id': {'uid': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_rEXbz6UYtYEJelYrDaZOLkh8WcF9J0ZHmEHFKZEBlLXsgP6xqXU3BCj4Ay0Z6fw_jSOaHxMHwd-voRHqFA4Q9NwAxFcVLyPWnNGZ9VbcSAPos1wupq7Xu3MIm-Bw_0vxjhZdWNy4chM9x3i', 'ext': {'linkType': 0}}, 'intentIqId': 'GIF89a\u0000\u0000\u0000\u0000�\u0000\u0000���\u0000\u0000\u0000?�\u0000\u0000\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000A\u0000\u0000;', 'lotamePanoramaId': 'xTtLUY7GwqX2MMqSHo9RQ2YUOIBFhlASOR43I9KjvgtcrxIys3RxME96M02LTjWR', 'parrableId': {'eid': '02.YoqC9lWZh8.C8QTSiJTNgI6Pp0KCM5zZgEgwVMSsVP5W51X8cmiUHQESq9WRKB4nreqZJwsWIcNKlORhG4u25Wm6lmDOBmQ0B8hv0KP6uVQ97aouuH52zaz2ctVQTORUKkErPRPcaCJ7dKFcrNoF2i6WOR0S5Nk'}, 'pubcid': 'b1254-152f-12F5-5698-dI1eljK6C7WA', 'pubProvidedId': [{'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}]}, 'userIdAsEids': [{'source': 'audigent.com', 'uids': [{'id': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'atype': 1}]}, {'source': 'id5-sync.com', 'uids': [{'id': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'atype': 1, 'ext': {'linkType': 0}}]}], 'ortb2Imp': {'ext': {'data': {'adserver': {'name': 'gam', 'adslot': '/19968336/header-bid-tag-0'}, 'pbadslot': '/19968336/header-bid-tag-0'}}}, 'mediaTypes': {'banner': {'sizes': [[320, 480], [320, 50]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '71c0d86b-4b47-4aff-a6da-1af0b1712439', 'sizes': [[320, 480], [320, 50]], 'bidId': '264d7969b125a5', 'bidderRequestId': '1c674c14a3889c', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}]; +const c_VALIDBIDAPPREQUESTS = [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com\/rtb\/v2\/', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'test': 1, 'app': {'name': 'Tappx Test', 'bundle': 'com.test.tappx', 'domain': 'tappx.com', 'publisher': { 'name': 'Tappx', 'domain': 'tappx.com' }}}, 'userId': {'haloId': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'id5id': {'uid': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'ext': {'linkType': 0}}, 'intentIqId': 'GIF89a\u0001\u0000\u0001\u0000�\u0000\u0000���\u0000\u0000\u0000!�\u0004\u0001\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000\u0002\u0002D\u0001\u0000;', 'lotamePanoramaId': '8003916b61a95b185690ec103bdf4945a70213e01818a5e5d8690b542730755a', 'parrableId': {'eid': '01.1617088921.7faa68d9570a50ea8e4f359e9b99ca4b7509e948a6175b3e5b0b8cbaf5b62424104ccfb0191ca79366de8368ed267b89a68e236df5f41f96f238e4301659e9023fec05e46399fb1ad0a0'}, 'pubcid': 'b7143795-852f-42f0-8864-5ecbea1ade4e', 'pubProvidedId': [{'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}]}, 'userIdAsEids': [{'source': 'audigent.com', 'uids': [{'id': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'atype': 1}]}, {'source': 'id5-sync.com', 'uids': [{'id': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'atype': 1, 'ext': {'linkType': 0}}]}, {'source': 'intentiq.com', 'uids': [{'id': 'GIF89a\u0001\u0000\u0001\u0000�\u0000\u0000���\u0000\u0000\u0000!�\u0004\u0001\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000\u0002\u0002D\u0001\u0000;', 'atype': 1}]}, {'source': 'crwdcntrl.net', 'uids': [{'id': '8003916b61a95b185690ec103bdf4945a70213e01818a5e5d8690b542730755a', 'atype': 1}]}, {'source': 'parrable.com', 'uids': [{'id': '01.1617088921.7faa68d9570a50ea8e4f359e9b99ca4b7509e948a6175b3e5b0b8cbaf5b62424104ccfb0191ca79366de8368ed267b89a68e236df5f41f96f238e4301659e9023fec05e46399fb1ad0a0', 'atype': 1}]}, {'source': 'pubcid.org', 'uids': [{'id': 'b7143795-852f-42f0-8864-5ecbea1ade4e', 'atype': 1}]}, {'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}], 'ortb2Imp': {'ext': {'data': {'adserver': {'name': 'gam', 'adslot': '/19968336/header-bid-tag-0'}, 'pbadslot': '/19968336/header-bid-tag-0'}}}, 'mediaTypes': {'banner': {'sizes': [[320, 480], [320, 50]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '71c0d86b-4b47-4aff-a6da-1af0b1712439', 'sizes': [[320, 480], [320, 50]], 'bidId': '264d7969b125a5', 'bidderRequestId': '1c674c14a3889c', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}]; +const c_BIDDERREQUEST = {'bidderCode': 'tappx', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'bidderRequestId': '1c674c14a3889c', 'bids': [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com\/rtb\/v2\/', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'test': 1}, 'userId': {'haloId': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'id5id': {'uid': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'ext': {'linkType': 0}}, 'intentIqId': 'GIF89a\u0000\u0000\u0000\u0000�\u0000\u0000���\u0000\u0000\u0000?�\u0000\u0000\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000A\u0000\u0000;', 'lotamePanoramaId': '8003916b61a95b185690ec103bdf4945a70213e01818a5e5d8690b542730755a', 'parrableId': {'eid': '01.1617088921.7faa68d9570a50ea8e4f359e9b99ca4b7509e948a6175b3e5b0b8cbaf5b62424104ccfb0191ca79366de8368ed267b89a68e236df5f41f96f238e4301659e9023fec05e46399fb1ad0a0'}, 'pubcid': 'b7143795-852f-42f0-8864-5ecbea1ade4e', 'pubProvidedId': [{'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}]}, 'userIdAsEids': [{'source': 'audigent.com', 'uids': [{'id': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'atype': 1}]}, {'source': 'id5-sync.com', 'uids': [{'id': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'atype': 1, 'ext': {'linkType': 0}}]}], 'ortb2Imp': {'ext': {'data': {'adserver': {'name': 'gam', 'adslot': '/19968336/header-bid-tag-0'}, 'pbadslot': '/19968336/header-bid-tag-0'}}}, 'mediaTypes': {'banner': {'sizes': [[320, 480], [320, 50]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '71c0d86b-4b47-4aff-a6da-1af0b1712439', 'sizes': [[320, 480], [320, 50]], 'bidId': '264d7969b125a5', 'bidderRequestId': '1c674c14a3889c', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}], 'auctionStart': 1617088922120, 'timeout': 700, 'refererInfo': {'referer': 'http://localhost:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true', 'reachedTop': true, 'isAmp': false, 'numIframes': 0, 'stack': ['http://localhost:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true'], 'canonicalUrl': null}, 'gdprConsent': {'consentString': c_CONSENTSTRING, 'vendorData': {'metadata': 'BO-JeiTPABAOkAAABAENABA', 'gdprApplies': true, 'hasGlobalScope': false, 'cookieVersion': 1, 'created': '2020-12-09T09:22:09.900Z', 'lastUpdated': '2021-01-14T15:44:03.600Z', 'cmpId': 0, 'cmpVersion': 1, 'consentScreen': 0, 'consentLanguage': 'EN', 'vendorListVersion': 1, 'maxVendorId': 0, 'purposeConsents': {}, 'vendorConsents': {}}, 'gdprApplies': true, 'apiVersion': 1}, 'uspConsent': '1YCC', 'start': 1611308859099}; +describe('Tappx bid adapter', function () { + /** + * IS REQUEST VALID + */ + describe('isBidRequestValid', function () { it('should return true when required params found', function () { - assert(spec.isBidRequestValid(bid)); + assert.isTrue(spec.isBidRequestValid(c_BIDREQUEST.bids[0]), JSON.stringify(c_BIDREQUEST)); }); it('should return false when required params are missing', function () { - const bid = { - host: 'testing.ssp.tappx.com' - }; - assert.isFalse(spec.isBidRequestValid(bid)); + let badBidRequest = c_BIDREQUEST; + delete badBidRequest.bids[0].params.tappxkey; + delete badBidRequest.bids[0].params.endpoint; + assert.isFalse(spec.isBidRequestValid(badBidRequest.bids[0])); }); }); + /** + * BUILD REQUEST TEST + */ describe('buildRequest', function () { - let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; // Web Test - let validBidRequests = [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'api': [3, 5]}, 'crumbs': {'pubcid': 'df2144f7-673f-4440-83f5-cd4a73642d99'}, 'fpd': {'context': {'adServer': {'name': 'gam', 'adSlot': '/19968336/header-bid-tag-0'}, 'pbAdSlot': '/19968336/header-bid-tag-0'}}, 'mediaTypes': {'banner': {'sizes': [[320, 480]]}}, 'adUnitCode': 'div-1', 'transactionId': '713f2c01-61e3-45b5-9e4e-2b163033f3d6', 'sizes': [[320, 480]], 'bidId': '27818d05971607', 'bidderRequestId': '1320551a307df5', 'auctionId': '3f1281d3-9860-4657-808d-3c1d42231ef3', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}] + let validBidRequests = c_VALIDBIDREQUESTS; // App Test - let validAppBidRequests = [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'api': [3, 5], 'app': {'name': 'Tappx Test', 'bundle': 'com.test.tappx', 'domain': 'tappx.com', 'publisher': { 'name': 'Tappx', 'domain': 'tappx.com' }}}, 'crumbs': {'pubcid': 'df2144f7-673f-4440-83f5-cd4a73642d99'}, 'fpd': {'context': {'adServer': {'name': 'gam', 'adSlot': '/19968336/header-bid-tag-0'}, 'pbAdSlot': '/19968336/header-bid-tag-0'}}, 'mediaTypes': {'banner': {'sizes': [[320, 50]]}}, 'adUnitCode': 'div-1', 'transactionId': '713f2c01-61e3-45b5-9e4e-2b163033f3d6', 'sizes': [[320, 50]], 'bidId': '27818d05971607', 'bidderRequestId': '1320551a307df5', 'auctionId': '3f1281d3-9860-4657-808d-3c1d42231ef3', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}] - let bidderRequest = {'bidderCode': 'tappx', 'auctionId': '6cca2192-2262-468b-8a3c-d00c58a5d911', 'bidderRequestId': '1ae5c6a02684df', 'bids': [{'bidder': 'tappx', 'params': {'host': 'tests.tappx.com', 'tappxkey': 'pub-1234-test-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005}, 'fpd': {'context': {'adServer': {'name': 'gam', 'adSlot': '/19968336/header-bid-tag-0'}, 'pbAdSlot': '/19968336/header-bid-tag-0'}}, 'mediaTypes': {'banner': {'sizes': [[320, 480]]}}, 'adUnitCode': 'banner-ad-div', 'transactionId': 'c44cdbde-ab6d-47a0-8dde-6b4ff7909a35', 'sizes': [[320, 50]], 'bidId': '2e3a5feb30cfe4', 'bidderRequestId': '1ae5c6a02684df', 'auctionId': '6cca2192-2262-468b-8a3c-d00c58a5d911', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}], 'auctionStart': 1611308859094, 'timeout': 700, 'refererInfo': {'referer': 'http://tappx.local:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true', 'reachedTop': true, 'isAmp': false, 'numIframes': 0, 'stack': ['http://tappx.local:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true'], 'canonicalUrl': null}, 'gdprConsent': {'consentString': consentString, 'vendorData': {'metadata': 'BO-JeiTPABAOkAAABAENABA', 'gdprApplies': true, 'hasGlobalScope': false, 'cookieVersion': 1, 'created': '2020-12-09T09:22:09.900Z', 'lastUpdated': '2021-01-14T15:44:03.600Z', 'cmpId': 0, 'cmpVersion': 1, 'consentScreen': 0, 'consentLanguage': 'EN', 'vendorListVersion': 1, 'maxVendorId': 0, 'purposeConsents': {}, 'vendorConsents': {}}, 'gdprApplies': true, 'apiVersion': 1}, 'uspConsent': '1YCC', 'start': 1611308859099}; + let validAppBidRequests = c_VALIDBIDAPPREQUESTS; + + let bidderRequest = c_BIDDERREQUEST; it('should add gdpr/usp consent information to the request', function () { const request = spec.buildRequests(validBidRequests, bidderRequest); const payload = JSON.parse(request[0].data); expect(payload.regs.gdpr).to.exist.and.to.be.true; - expect(payload.regs.consent).to.exist.and.to.equal(consentString); + expect(payload.regs.consent).to.exist.and.to.equal(c_CONSENTSTRING); expect(payload.regs.ext.us_privacy).to.exist; }); @@ -48,6 +138,14 @@ describe('Tappx adapter tests', function () { expect(data.imp[0].banner.h).to.be.oneOf([320, 50, 250, 480]); }); + it('should set user eids array', function () { + const request = spec.buildRequests(validBidRequests, bidderRequest); + + const data = JSON.parse(request[0].data); + expect(data.user.ext.eids, data).to.not.be.null; + expect(data.user.ext.eids[0]).to.have.keys(['source', 'uids']); + }); + it('should properly build a banner request with app params', function () { const request = spec.buildRequests(validAppBidRequests, bidderRequest); expect(request[0].url).to.match(/^(http|https):\/\/(.*)\.tappx\.com\/.+/); @@ -63,23 +161,20 @@ describe('Tappx adapter tests', function () { }); }); + /** + * INTERPRET RESPONSE TESTS + */ describe('interpretResponse', function () { - const bidRequest = { - data: {}, - bids: [ {'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.05, 'api': [3, 5]}, 'crumbs': {'pubcid': 'df2144f7-673f-4440-83f5-cd4a73642d99'}, 'fpd': {'context': {'adServer': {'name': 'gam', 'adSlot': '/19968336/header-bid-tag-0'}, 'pbAdSlot': '/19968336/header-bid-tag-0'}}, 'mediaTypes': {'banner': {'sizes': [[320, 480]]}}, 'adUnitCode': 'div-1', 'transactionId': '47dd44e8-e7db-417c-a8f1-621a2e1a117d', 'sizes': [[320, 480]], 'bidId': '2170932097e505', 'bidderRequestId': '140ba7a1ab7aeb', 'auctionId': '1c54b4f1-645f-44e6-b8ae-5d43c923ef1c', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0} ] - }; - - const serverResponse = {'body': {'id': '1c54b4f1-645f-44e6-b8ae-5d43c923ef1c', 'bidid': 'bid3811165568213389257', 'seatbid': [{'seat': '1', 'group': 0, 'bid': [{'id': '3811165568213389257', 'impid': 1, 'price': 0.05, 'adm': "\t", 'w': 320, 'h': 480, 'lurl': 'http://testing.ssp.tappx.com/rtb/RTBv2Loss?id=3811165568213389257&ep=ZZ1234PBJS&au=test&bu=localhost&sz=320x480&pu=0.005&pt=0.01&cid=&crid=&adv=&aid=${AUCTION_ID}&bidid=${AUCTION_BID_ID}&impid=${AUCTION_IMP_ID}&sid=${AUCTION_SEAT_ID}&adid=${AUCTION_AD_ID}&ap=${AUCTION_PRICE}&cur=${AUCTION_CURRENCY}&mbr=${AUCTION_MBR}&l=${AUCTION_LOSS}', 'cid': '01744fbb521e9fb10ffea926190effea', 'crid': 'a13cf884e66e7c660afec059c89d98b6', 'adomain': []}]}], 'cur': 'USD'}, 'headers': {}}; it('receive reponse with single placement', function () { - const bids = spec.interpretResponse(serverResponse, bidRequest); + const bids = spec.interpretResponse(c_SERVERRESPONSE, c_BIDREQUEST); const bid = bids[0]; expect(bid.cpm).to.exist; expect(bid.ad).to.match(/^', + 'adUrl': 'adUrl', 'requestId': '2e41f65424c87c', 'creative_id': 342516, 'cmpId': 342516, @@ -171,6 +173,7 @@ const displayEqResponse = [{ netRevenue: true, currency: 'USD', ad: '', + adUrl: 'adUrl', height: 250, width: 300, ttl: 300, From 9eff9d55daa0e89dd365c597ecb6f0197958560e Mon Sep 17 00:00:00 2001 From: BrightMountainMedia <69471268+BrightMountainMediaInc@users.noreply.github.com> Date: Tue, 13 Apr 2021 18:38:18 +0530 Subject: [PATCH 030/303] Bright Mountain Media Bid Adapter: Change Endpoint URL (#6576) --- modules/brightMountainMediaBidAdapter.js | 2 +- test/spec/modules/brightMountainMediaBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/brightMountainMediaBidAdapter.js b/modules/brightMountainMediaBidAdapter.js index 6434d8b2b81..b57e696148f 100644 --- a/modules/brightMountainMediaBidAdapter.js +++ b/modules/brightMountainMediaBidAdapter.js @@ -3,7 +3,7 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import * as utils from '../src/utils.js'; const BIDDER_CODE = 'bmtm'; -const AD_URL = 'https://console.brightmountainmedia.com/hb/bid'; +const AD_URL = 'https://one.elitebidder.com/api/hb'; export const spec = { code: BIDDER_CODE, diff --git a/test/spec/modules/brightMountainMediaBidAdapter_spec.js b/test/spec/modules/brightMountainMediaBidAdapter_spec.js index 7511b5bf239..bc7f69f0baf 100644 --- a/test/spec/modules/brightMountainMediaBidAdapter_spec.js +++ b/test/spec/modules/brightMountainMediaBidAdapter_spec.js @@ -55,7 +55,7 @@ describe('brightMountainMediaBidAdapter_spec', function () { expect(serverRequest.method).to.equal('POST'); }); it('Returns valid URL', function () { - expect(serverRequest.url).to.equal('https://console.brightmountainmedia.com/hb/bid'); + expect(serverRequest.url).to.equal('https://one.elitebidder.com/api/hb'); }); it('Returns valid data if array of bids is valid', function () { From e0007c24baabd294151f510d2e69bbf3eed7257b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rok=20Su=C5=A1nik?= Date: Tue, 13 Apr 2021 17:03:59 +0200 Subject: [PATCH 031/303] Outbrain Bid Adapter: only trigger nurl ajax call if nurl is present (#6579) --- modules/outbrainBidAdapter.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/outbrainBidAdapter.js b/modules/outbrainBidAdapter.js index 402d4515abc..304cdf2088c 100644 --- a/modules/outbrainBidAdapter.js +++ b/modules/outbrainBidAdapter.js @@ -164,7 +164,11 @@ export const spec = { return syncs; }, onBidWon: (bid) => { - ajax(utils.replaceAuctionPrice(bid.nurl, bid.originalCpm)) + // for native requests we put the nurl as an imp tracker, otherwise if the auction takes place on prebid server + // the server JS adapter puts the nurl in the adm as a tracking pixel and removes the attribute + if (bid.nurl) { + ajax(utils.replaceAuctionPrice(bid.nurl, bid.originalCpm)) + } } }; From c83bc53a8239bc828e81622d4567174a82a29b48 Mon Sep 17 00:00:00 2001 From: bjorn-lw <32431346+bjorn-lw@users.noreply.github.com> Date: Tue, 13 Apr 2021 18:00:32 +0200 Subject: [PATCH 032/303] LiveWrapper Bid Adapter: add US privacy and Coppa support (#6569) * Livewrapped bid and analytics adapter * Fixed some tests for browser compatibility * Fixed some tests for browser compatibility * Changed analytics adapter code name * Fix double quote in debug message * modified how gdpr is being passed * Added support for Publisher Common ID Module * Corrections for ttr in analytics * ANalytics updates * Auction start time stamp changed * Detect recovered ad blocked requests Make it possible to pass dynamic parameters to adapter * Collect info on ad units receiving any valid bid * Support for ID5 Pass metadata from adapter * Typo in test + eids on wrong level * Fix for Prebid 3.0 * Fix get referer * http -> https in tests * Native support * Read sizes from mediatype.banner * Revert accidental commit * Support native data collection + minor refactorings * Set analytics endpoint * Support for app parameters * Fix issue where adunits with bids were not counted on reload * Send debug info from adapter to external debugger * SChain support * Send GDPR data in analytics request * video support Video support * Report back floor via analytic * Send auction id and adunit/bidder connection id * Criteo id support * Updated example * livewrapped Analytics Adapter info file * Livewrapped gvlid * Us Privacy and Coppa support --- modules/livewrappedBidAdapter.js | 7 ++ .../modules/livewrappedBidAdapter_spec.js | 73 +++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/modules/livewrappedBidAdapter.js b/modules/livewrappedBidAdapter.js index 2840da8dda6..93552638007 100644 --- a/modules/livewrappedBidAdapter.js +++ b/modules/livewrappedBidAdapter.js @@ -81,6 +81,8 @@ export const spec = { version: VERSION, gdprApplies: bidderRequest.gdprConsent ? bidderRequest.gdprConsent.gdprApplies : undefined, gdprConsent: bidderRequest.gdprConsent ? bidderRequest.gdprConsent.consentString : undefined, + coppa: getCoppa(), + usPrivacy: bidderRequest.uspConsent, cookieSupport: !utils.isSafariBrowser() && storage.cookiesAreEnabled(), rcv: getAdblockerRecovered(), adRequests: [...adRequests], @@ -309,4 +311,9 @@ function getDeviceHeight() { return window.innerHeight; } +function getCoppa() { + if (typeof config.getConfig('coppa') === 'boolean') { + return config.getConfig('coppa'); + } +} registerBidder(spec); diff --git a/test/spec/modules/livewrappedBidAdapter_spec.js b/test/spec/modules/livewrappedBidAdapter_spec.js index fa00a359191..9435d9131fa 100644 --- a/test/spec/modules/livewrappedBidAdapter_spec.js +++ b/test/spec/modules/livewrappedBidAdapter_spec.js @@ -625,6 +625,79 @@ describe('Livewrapped adapter tests', function () { expect(data).to.deep.equal(expectedQuery); }); + it('should pass us privacy parameter', function() { + sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); + sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => true); + let testRequest = clone(bidderRequest); + testRequest.uspConsent = '1---'; + let result = spec.buildRequests(testRequest.bids, testRequest); + let data = JSON.parse(result.data); + + expect(result.url).to.equal('https://lwadm.com/ad'); + + let expectedQuery = { + auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', + publisherId: '26947112-2289-405D-88C1-A7340C57E63E', + userId: 'user id', + url: 'https://www.domain.com', + seats: {'dsp': ['seat 1']}, + version: '1.4', + width: 100, + height: 100, + cookieSupport: true, + usPrivacy: '1---', + adRequests: [{ + adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', + callerAdUnitId: 'panorama_d_1', + bidId: '2ffb201a808da7', + transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + formats: [{width: 980, height: 240}, {width: 980, height: 120}] + }] + }; + + expect(data).to.deep.equal(expectedQuery); + }); + + it('should pass coppa parameter', function() { + sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); + sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => true); + + let origGetConfig = config.getConfig; + sandbox.stub(config, 'getConfig').callsFake(function (key) { + if (key === 'coppa') { + return true; + } + return origGetConfig.apply(config, arguments); + }); + + let result = spec.buildRequests(bidderRequest.bids, bidderRequest); + let data = JSON.parse(result.data); + + expect(result.url).to.equal('https://lwadm.com/ad'); + + let expectedQuery = { + auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C', + publisherId: '26947112-2289-405D-88C1-A7340C57E63E', + userId: 'user id', + url: 'https://www.domain.com', + seats: {'dsp': ['seat 1']}, + version: '1.4', + width: 100, + height: 100, + cookieSupport: true, + coppa: true, + adRequests: [{ + adUnitId: '9E153CED-61BC-479E-98DF-24DC0D01BA37', + callerAdUnitId: 'panorama_d_1', + bidId: '2ffb201a808da7', + transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D', + formats: [{width: 980, height: 240}, {width: 980, height: 120}] + }] + }; + + expect(data).to.deep.equal(expectedQuery); + }); + it('should pass no cookie support', function() { sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => false); sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false); From 41e050a28003a4c0a23967694c3a327c3dba62be Mon Sep 17 00:00:00 2001 From: Robert Ray Martinez III Date: Tue, 13 Apr 2021 15:28:17 -0700 Subject: [PATCH 033/303] Rubicon Analytics: Handle PBS Sending Bid ID 0 (#6584) --- modules/rubiconAnalyticsAdapter.js | 5 +-- .../modules/rubiconAnalyticsAdapter_spec.js | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/modules/rubiconAnalyticsAdapter.js b/modules/rubiconAnalyticsAdapter.js index 90575cf8cf1..74f098c0292 100644 --- a/modules/rubiconAnalyticsAdapter.js +++ b/modules/rubiconAnalyticsAdapter.js @@ -363,8 +363,9 @@ export function parseBidResponse(bid, previousBidResponse, auctionFloorData) { const height = bid.height || bid.playerHeight; return (width && height) ? {width, height} : undefined; }, - 'pbsBidId', - 'seatBidId', + // Handling use case where pbs sends back 0 or '0' bidIds + 'pbsBidId', pbsBidId => pbsBidId == 0 ? utils.generateUUID() : pbsBidId, + 'seatBidId', seatBidId => seatBidId == 0 ? utils.generateUUID() : seatBidId, 'floorValue', () => utils.deepAccess(bid, 'floorData.floorValue'), 'floorRuleValue', () => utils.deepAccess(bid, 'floorData.floorRuleValue'), 'floorRule', () => utils.debugTurnedOn() ? utils.deepAccess(bid, 'floorData.floorRule') : undefined, diff --git a/test/spec/modules/rubiconAnalyticsAdapter_spec.js b/test/spec/modules/rubiconAnalyticsAdapter_spec.js index 0239eff5883..84315dd1eba 100644 --- a/test/spec/modules/rubiconAnalyticsAdapter_spec.js +++ b/test/spec/modules/rubiconAnalyticsAdapter_spec.js @@ -1773,6 +1773,40 @@ describe('rubicon analytics adapter', function () { expect(message.bidsWon[0].bidId).to.equal('zzzz-yyyy-xxxx-wwww'); }); + it('should correctly generate new bidId if it is 0', function () { + // Only want one bid request in our mock auction + let bidRequested = utils.deepClone(MOCK.BID_REQUESTED); + bidRequested.bids.shift(); + let auctionInit = utils.deepClone(MOCK.AUCTION_INIT); + auctionInit.adUnits.shift(); + + // clone the mock bidResponse and duplicate + let seatBidResponse = utils.deepClone(BID4); + seatBidResponse.pbsBidId = '0'; + + const setTargeting = { + [seatBidResponse.adUnitCode]: seatBidResponse.adserverTargeting + }; + + const bidWon = Object.assign({}, seatBidResponse, { + 'status': 'rendered' + }); + + // spoof the auction with just our duplicates + events.emit(AUCTION_INIT, auctionInit); + events.emit(BID_REQUESTED, bidRequested); + events.emit(BID_RESPONSE, seatBidResponse); + events.emit(AUCTION_END, MOCK.AUCTION_END); + events.emit(SET_TARGETING, setTargeting); + events.emit(BID_WON, bidWon); + + let message = JSON.parse(server.requests[0].requestBody); + + validate(message); + expect(message.auctions[0].adUnits[0].bids[0].bidId).to.equal(STUBBED_UUID); + expect(message.bidsWon[0].bidId).to.equal(STUBBED_UUID); + }); + it('should pick the highest cpm bid if more than one bid per bidRequestId', function () { // Only want one bid request in our mock auction let bidRequested = utils.deepClone(MOCK.BID_REQUESTED); From e25678894b54f01615beb72033be5a20902096a9 Mon Sep 17 00:00:00 2001 From: PWyrembak Date: Wed, 14 Apr 2021 12:27:40 +0300 Subject: [PATCH 034/303] TrustX Bid Adapter: support new format request (#6556) * Add trustx adapter and tests for it * update integration example * Update trustx adapter * Post-review fixes of Trustx adapter * Code improvement for trustx adapter: changed default price type from gross to net * Update TrustX adapter to support the 1.0 version * Make requested changes for TrustX adapter * Updated markdown file for TrustX adapter * Fix TrustX adapter and spec file * Update TrustX adapter: r parameter was added to ad request as cache buster * Add support of gdpr to Trustx Bid Adapter * Add wtimeout to ad request params for TrustX Bid Adapter * TrustX Bid Adapter: remove last ampersand in the ad request * Update TrustX Bid Adapter to support identical uids in parameters * Update TrustX Bid Adapter to ignore bids that sizes do not match the size of the request * Update TrustX Bid Adapter to support instream and outstream video * Added wrapperType and wrapperVersion parameters in ad request for TrustX Bid Adapter * Update TrustX Bid Adapter to use refererInfo instead depricated function utils.getTopWindowUrl * HOTFIX for referrer encodind in TrustX Bid Adapter * Fix test for TrustX Bid Adapter * TrustX Bid Adapter: added keywords passing support * TrustX Bid Adapter: added us_privacy parameter in bid request * TrustX Bid Adapter: fix us_privacy parameter in bid request * Fix alias error for TrustX Bid Adapter * TrustX Bid Adapter: added new request format * TrustX Bid adapter: fix new format endpoint * TrustX Bid Adapter: update md file to support useNewFormat parameter --- modules/trustxBidAdapter.js | 556 ++++++++++++++++----- modules/trustxBidAdapter.md | 14 +- test/spec/modules/trustxBidAdapter_spec.js | 465 ++++++++++++++++- 3 files changed, 880 insertions(+), 155 deletions(-) diff --git a/modules/trustxBidAdapter.js b/modules/trustxBidAdapter.js index a86ac1f2874..3116400edf7 100644 --- a/modules/trustxBidAdapter.js +++ b/modules/trustxBidAdapter.js @@ -2,9 +2,11 @@ import * as utils from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { Renderer } from '../src/Renderer.js'; import { VIDEO, BANNER } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'trustx'; const ENDPOINT_URL = 'https://sofia.trustx.org/hb'; +const NEW_ENDPOINT_URL = 'https://grid.bidswitch.net/hbjson?sp=trustx'; const TIME_TO_LIVE = 360; const ADAPTER_SYNC_URL = 'https://sofia.trustx.org/push_sync'; const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; @@ -40,98 +42,30 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(validBidRequests, bidderRequest) { - const auids = []; - const bidsMap = {}; - const slotsMapByUid = {}; - const sizeMap = {}; const bids = validBidRequests || []; - let priceType = 'net'; - let pageKeywords; - let reqId; - + const newFormatBids = []; + const oldFormatBids = []; + const requests = []; bids.forEach(bid => { - if (bid.params.priceType === 'gross') { - priceType = 'gross'; - } - reqId = bid.bidderRequestId; - const {params: {uid}, adUnitCode} = bid; - auids.push(uid); - const sizesId = utils.parseSizesInput(bid.sizes); - - if (!pageKeywords && !utils.isEmpty(bid.params.keywords)) { - const keywords = utils.transformBidderParamKeywords(bid.params.keywords); - - if (keywords.length > 0) { - keywords.forEach(deleteValues); - } - pageKeywords = keywords; - } - - if (!slotsMapByUid[uid]) { - slotsMapByUid[uid] = {}; - } - const slotsMap = slotsMapByUid[uid]; - if (!slotsMap[adUnitCode]) { - slotsMap[adUnitCode] = {adUnitCode, bids: [bid], parents: []}; + if (bid.params.useNewFormat) { + newFormatBids.push(bid); } else { - slotsMap[adUnitCode].bids.push(bid); + oldFormatBids.push(bid); } - const slot = slotsMap[adUnitCode]; - - sizesId.forEach((sizeId) => { - sizeMap[sizeId] = true; - if (!bidsMap[uid]) { - bidsMap[uid] = {}; - } - - if (!bidsMap[uid][sizeId]) { - bidsMap[uid][sizeId] = [slot]; - } else { - bidsMap[uid][sizeId].push(slot); - } - slot.parents.push({parent: bidsMap[uid], key: sizeId, uid}); - }); }); - - const payload = { - pt: priceType, - auids: auids.join(','), - sizes: utils.getKeys(sizeMap).join(','), - r: reqId, - wrapperType: 'Prebid_js', - wrapperVersion: '$prebid.version$' - }; - - if (pageKeywords) { - payload.keywords = JSON.stringify(pageKeywords); - } - - if (bidderRequest) { - if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - payload.u = bidderRequest.refererInfo.referer; + if (newFormatBids.length) { + const newFormatRequests = newFormatRequest(newFormatBids, bidderRequest); + if (newFormatRequests) { + requests.push(newFormatRequests); } - if (bidderRequest.timeout) { - payload.wtimeout = bidderRequest.timeout; - } - if (bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.consentString) { - payload.gdpr_consent = bidderRequest.gdprConsent.consentString; - } - payload.gdpr_applies = - (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') - ? Number(bidderRequest.gdprConsent.gdprApplies) : 1; - } - if (bidderRequest.uspConsent) { - payload.us_privacy = bidderRequest.uspConsent; + } + if (oldFormatBids.length) { + const oldFormatRequests = oldFormatRequest(oldFormatBids, bidderRequest); + if (oldFormatRequests) { + requests.push(oldFormatRequests); } } - - return { - method: 'GET', - url: ENDPOINT_URL, - data: utils.parseQueryStringParameters(payload).replace(/\&$/, ''), - bidsMap: bidsMap, - }; + return requests; }, /** * Unpack the response from the server into a list of bids. @@ -143,8 +77,6 @@ export const spec = { interpretResponse: function(serverResponse, bidRequest, RendererConst = Renderer) { serverResponse = serverResponse && serverResponse.body; const bidResponses = []; - const bidsMap = bidRequest.bidsMap; - const priceType = bidRequest.data.pt; let errorMessage; @@ -155,7 +87,7 @@ export const spec = { if (!errorMessage && serverResponse.seatbid) { serverResponse.seatbid.forEach(respItem => { - _addBidResponse(_getBidFromResponse(respItem), bidsMap, priceType, bidResponses, RendererConst); + _addBidResponse(_getBidFromResponse(respItem), bidRequest, bidResponses, RendererConst); }); } if (errorMessage) utils.logError(errorMessage); @@ -192,66 +124,75 @@ function _getBidFromResponse(respItem) { return respItem && respItem.bid && respItem.bid[0]; } -function _addBidResponse(serverBid, bidsMap, priceType, bidResponses, RendererConst) { +function _addBidResponse(serverBid, bidRequest, bidResponses, RendererConst) { if (!serverBid) return; let errorMessage; if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid); if (!serverBid.adm) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid); else { - const awaitingBids = bidsMap[serverBid.auid]; - if (awaitingBids) { - const sizeId = `${serverBid.w}x${serverBid.h}`; - if (awaitingBids[sizeId]) { - const slot = awaitingBids[sizeId][0]; - - const bid = slot.bids.shift(); - const bidResponse = { - requestId: bid.bidId, // bid.bidderRequestId, - cpm: serverBid.price, - width: serverBid.w, - height: serverBid.h, - creativeId: serverBid.auid, // bid.bidId, - currency: 'USD', - netRevenue: priceType !== 'gross', - ttl: TIME_TO_LIVE, - dealId: serverBid.dealid - }; - if (serverBid.content_type === 'video') { - bidResponse.vastXml = serverBid.adm; - bidResponse.mediaType = VIDEO; - bidResponse.adResponse = { - content: bidResponse.vastXml - }; - if (!bid.renderer && (!bid.mediaTypes || !bid.mediaTypes.video || bid.mediaTypes.video.context === 'outstream')) { - bidResponse.renderer = createRenderer(bidResponse, { - id: bid.bidId, - url: RENDERER_URL - }, RendererConst); - } - } else { - bidResponse.ad = serverBid.adm; - bidResponse.mediaType = BANNER; + const { bidsMap, priceType, newFormat } = bidRequest; + let bid; + let slot; + if (newFormat) { + bid = bidsMap[serverBid.impid]; + } else { + const awaitingBids = bidsMap[serverBid.auid]; + if (awaitingBids) { + const sizeId = `${serverBid.w}x${serverBid.h}`; + if (awaitingBids[sizeId]) { + slot = awaitingBids[sizeId][0]; + bid = slot.bids.shift(); } + } else { + errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; + } + } - bidResponses.push(bidResponse); - - if (!slot.bids.length) { - slot.parents.forEach(({parent, key, uid}) => { - const index = parent[key].indexOf(slot); - if (index > -1) { - parent[key].splice(index, 1); - } - if (!parent[key].length) { - delete parent[key]; - if (!utils.getKeys(parent).length) { - delete bidsMap[uid]; - } - } - }); + if (!errorMessage && bid) { + const bidResponse = { + requestId: bid.bidId, // bid.bidderRequestId, + cpm: serverBid.price, + width: serverBid.w, + height: serverBid.h, + creativeId: serverBid.auid, // bid.bidId, + currency: 'USD', + netRevenue: newFormat ? false : priceType !== 'gross', + ttl: TIME_TO_LIVE, + dealId: serverBid.dealid + }; + if (serverBid.content_type === 'video') { + bidResponse.vastXml = serverBid.adm; + bidResponse.mediaType = VIDEO; + bidResponse.adResponse = { + content: bidResponse.vastXml + }; + if (!bid.renderer && (!bid.mediaTypes || !bid.mediaTypes.video || bid.mediaTypes.video.context === 'outstream')) { + bidResponse.renderer = createRenderer(bidResponse, { + id: bid.bidId, + url: RENDERER_URL + }, RendererConst); } + } else { + bidResponse.ad = serverBid.adm; + bidResponse.mediaType = BANNER; } - } else { - errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; + + bidResponses.push(bidResponse); + } + + if (slot && !slot.bids.length) { + slot.parents.forEach(({parent, key, uid}) => { + const index = parent[key].indexOf(slot); + if (index > -1) { + parent[key].splice(index, 1); + } + if (!parent[key].length) { + delete parent[key]; + if (!utils.getKeys(parent).length) { + delete bidsMap[uid]; + } + } + }); } } if (errorMessage) { @@ -284,4 +225,343 @@ function createRenderer (bid, rendererParams, RendererConst) { return rendererInst; } +function createVideoRequest(bid, mediaType) { + const {playerSize, mimes, durationRangeSec, protocols} = mediaType; + const size = (playerSize || bid.sizes || [])[0]; + if (!size) return; + + let result = utils.parseGPTSingleSizeArrayToRtbSize(size); + + if (mimes) { + result.mimes = mimes; + } + + if (durationRangeSec && durationRangeSec.length === 2) { + result.minduration = durationRangeSec[0]; + result.maxduration = durationRangeSec[1]; + } + + if (protocols && protocols.length) { + result.protocols = protocols; + } + + return result; +} + +function createBannerRequest(bid, mediaType) { + const sizes = mediaType.sizes || bid.sizes; + if (!sizes || !sizes.length) return; + + let format = sizes.map((size) => utils.parseGPTSingleSizeArrayToRtbSize(size)); + let result = utils.parseGPTSingleSizeArrayToRtbSize(sizes[0]); + + if (format.length) { + result.format = format + } + return result; +} + +/** + * Gets bidfloor + * @param {Object} mediaTypes + * @param {Object} bid + * @returns {Number} floor + */ +function _getFloor (mediaTypes, bid) { + const curMediaType = mediaTypes.video ? 'video' : 'banner'; + let floor = bid.params.bidFloor || 0; + + if (typeof bid.getFloor === 'function') { + const floorInfo = bid.getFloor({ + currency: 'USD', + mediaType: curMediaType, + size: bid.sizes.map(([w, h]) => ({w, h})) + }); + + if (typeof floorInfo === 'object' && + floorInfo.currency === 'USD' && + !isNaN(parseFloat(floorInfo.floor))) { + floor = Math.max(floor, parseFloat(floorInfo.floor)); + } + } + + return floor; +} + +function newFormatRequest(validBidRequests, bidderRequest) { + if (!validBidRequests.length) { + return null; + } + let pageKeywords = null; + let jwpseg = null; + let content = null; + let schain = null; + let userId = null; + let userIdAsEids = null; + let user = null; + let userExt = null; + let {bidderRequestId, auctionId, gdprConsent, uspConsent, timeout, refererInfo} = bidderRequest || {}; + + const referer = refererInfo ? encodeURIComponent(refererInfo.referer) : ''; + const imp = []; + const bidsMap = {}; + + validBidRequests.forEach((bid) => { + if (!bidderRequestId) { + bidderRequestId = bid.bidderRequestId; + } + if (!auctionId) { + auctionId = bid.auctionId; + } + if (!schain) { + schain = bid.schain; + } + if (!userId) { + userId = bid.userId; + } + if (!userIdAsEids) { + userIdAsEids = bid.userIdAsEids; + } + const {params: {uid, keywords}, mediaTypes, bidId, adUnitCode, rtd} = bid; + bidsMap[bidId] = bid; + if (!pageKeywords && !utils.isEmpty(keywords)) { + pageKeywords = utils.transformBidderParamKeywords(keywords); + } + const bidFloor = _getFloor(mediaTypes || {}, bid); + const jwTargeting = rtd && rtd.jwplayer && rtd.jwplayer.targeting; + if (jwTargeting) { + if (!jwpseg && jwTargeting.segments) { + jwpseg = jwTargeting.segments; + } + if (!content && jwTargeting.content) { + content = jwTargeting.content; + } + } + let impObj = { + id: bidId, + tagid: uid.toString(), + ext: { + divid: adUnitCode + } + }; + + if (bidFloor) { + impObj.bidfloor = bidFloor; + } + + if (!mediaTypes || mediaTypes[BANNER]) { + const banner = createBannerRequest(bid, mediaTypes ? mediaTypes[BANNER] : {}); + if (banner) { + impObj.banner = banner; + } + } + if (mediaTypes && mediaTypes[VIDEO]) { + const video = createVideoRequest(bid, mediaTypes[VIDEO]); + if (video) { + impObj.video = video; + } + } + + if (impObj.banner || impObj.video) { + imp.push(impObj); + } + }); + + const source = { + tid: auctionId, + ext: { + wrapper: 'Prebid_js', + wrapper_version: '$prebid.version$' + } + }; + + if (schain) { + source.ext.schain = schain; + } + + const bidderTimeout = config.getConfig('bidderTimeout') || timeout; + const tmax = timeout ? Math.min(bidderTimeout, timeout) : bidderTimeout; + + let request = { + id: bidderRequestId, + site: { + page: referer + }, + tmax, + source, + imp + }; + + if (content) { + request.site.content = content; + } + + if (jwpseg && jwpseg.length) { + user = { + data: [{ + name: 'iow_labs_pub_data', + segment: jwpseg.map((seg) => { + return {name: 'jwpseg', value: seg}; + }) + }] + }; + } + + if (gdprConsent && gdprConsent.consentString) { + userExt = {consent: gdprConsent.consentString}; + } + + if (userIdAsEids && userIdAsEids.length) { + userExt = userExt || {}; + userExt.eids = [...userIdAsEids]; + } + + if (userExt && Object.keys(userExt).length) { + user = user || {}; + user.ext = userExt; + } + + if (user) { + request.user = user; + } + + const configKeywords = utils.transformBidderParamKeywords({ + 'user': utils.deepAccess(config.getConfig('ortb2.user'), 'keywords') || null, + 'context': utils.deepAccess(config.getConfig('ortb2.site'), 'keywords') || null + }); + + if (configKeywords.length) { + pageKeywords = (pageKeywords || []).concat(configKeywords); + } + + if (pageKeywords && pageKeywords.length > 0) { + pageKeywords.forEach(deleteValues); + } + + if (pageKeywords) { + request.ext = { + keywords: pageKeywords + }; + } + + if (gdprConsent && gdprConsent.gdprApplies) { + request.regs = { + ext: { + gdpr: gdprConsent.gdprApplies ? 1 : 0 + } + } + } + + if (uspConsent) { + if (!request.regs) { + request.regs = {ext: {}}; + } + request.regs.ext.us_privacy = uspConsent; + } + + return { + method: 'POST', + url: NEW_ENDPOINT_URL, + data: JSON.stringify(request), + newFormat: true, + bidsMap + }; +} + +function oldFormatRequest(validBidRequests, bidderRequest) { + const auids = []; + const bidsMap = {}; + const slotsMapByUid = {}; + const sizeMap = {}; + const bids = validBidRequests || []; + let priceType = 'net'; + let pageKeywords; + let reqId; + + bids.forEach(bid => { + if (bid.params.priceType === 'gross') { + priceType = 'gross'; + } + reqId = bid.bidderRequestId; + const {params: {uid}, adUnitCode} = bid; + auids.push(uid); + const sizesId = utils.parseSizesInput(bid.sizes); + + if (!pageKeywords && !utils.isEmpty(bid.params.keywords)) { + const keywords = utils.transformBidderParamKeywords(bid.params.keywords); + + if (keywords.length > 0) { + keywords.forEach(deleteValues); + } + pageKeywords = keywords; + } + + if (!slotsMapByUid[uid]) { + slotsMapByUid[uid] = {}; + } + const slotsMap = slotsMapByUid[uid]; + if (!slotsMap[adUnitCode]) { + slotsMap[adUnitCode] = {adUnitCode, bids: [bid], parents: []}; + } else { + slotsMap[adUnitCode].bids.push(bid); + } + const slot = slotsMap[adUnitCode]; + + sizesId.forEach((sizeId) => { + sizeMap[sizeId] = true; + if (!bidsMap[uid]) { + bidsMap[uid] = {}; + } + + if (!bidsMap[uid][sizeId]) { + bidsMap[uid][sizeId] = [slot]; + } else { + bidsMap[uid][sizeId].push(slot); + } + slot.parents.push({parent: bidsMap[uid], key: sizeId, uid}); + }); + }); + + const payload = { + pt: priceType, + auids: auids.join(','), + sizes: utils.getKeys(sizeMap).join(','), + r: reqId, + wrapperType: 'Prebid_js', + wrapperVersion: '$prebid.version$' + }; + + if (pageKeywords) { + payload.keywords = JSON.stringify(pageKeywords); + } + + if (bidderRequest) { + if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { + payload.u = bidderRequest.refererInfo.referer; + } + if (bidderRequest.timeout) { + payload.wtimeout = bidderRequest.timeout; + } + if (bidderRequest.gdprConsent) { + if (bidderRequest.gdprConsent.consentString) { + payload.gdpr_consent = bidderRequest.gdprConsent.consentString; + } + payload.gdpr_applies = + (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') + ? Number(bidderRequest.gdprConsent.gdprApplies) : 1; + } + if (bidderRequest.uspConsent) { + payload.us_privacy = bidderRequest.uspConsent; + } + } + + return { + method: 'GET', + url: ENDPOINT_URL, + data: utils.parseQueryStringParameters(payload).replace(/\&$/, ''), + bidsMap, + priceType + }; +} + registerBidder(spec); diff --git a/modules/trustxBidAdapter.md b/modules/trustxBidAdapter.md index a72f1ba85aa..e891df8f161 100644 --- a/modules/trustxBidAdapter.md +++ b/modules/trustxBidAdapter.md @@ -52,6 +52,18 @@ TrustX Bid Adapter supports Banner and Video (instream and outstream). } } ] + },{ + code: 'test-div', + sizes: [[300, 250]], + bids: [ + { + bidder: "trustx", + params: { + uid: '58851', + useNewFormat: true + } + } + ] } ]; -``` \ No newline at end of file +``` diff --git a/test/spec/modules/trustxBidAdapter_spec.js b/test/spec/modules/trustxBidAdapter_spec.js index e9daaa83b5d..c0155f87ab6 100644 --- a/test/spec/modules/trustxBidAdapter_spec.js +++ b/test/spec/modules/trustxBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { spec } from 'modules/trustxBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; +import { config } from 'src/config.js'; describe('TrustXAdapter', function () { const adapter = newBidder(spec); @@ -92,7 +93,7 @@ describe('TrustXAdapter', function () { ]; it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]], bidderRequest); + const request = spec.buildRequests([bidRequests[0]], bidderRequest)[0]; expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); expect(payload).to.have.property('u', referrer); @@ -105,7 +106,7 @@ describe('TrustXAdapter', function () { }); it('sizes must not be duplicated', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); expect(payload).to.have.property('u', referrer); @@ -117,7 +118,7 @@ describe('TrustXAdapter', function () { it('pt parameter must be "gross" if params.priceType === "gross"', function () { bidRequests[1].params.priceType = 'gross'; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); expect(payload).to.have.property('u', referrer); @@ -130,7 +131,7 @@ describe('TrustXAdapter', function () { it('pt parameter must be "net" or "gross"', function () { bidRequests[1].params.priceType = 'some'; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); expect(payload).to.have.property('u', referrer); @@ -143,7 +144,7 @@ describe('TrustXAdapter', function () { it('if gdprConsent is present payload must have gdpr params', function () { const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: true}}, bidderRequest); - const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR)[0]; expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); expect(payload).to.have.property('gdpr_consent', 'AAA'); @@ -152,7 +153,7 @@ describe('TrustXAdapter', function () { it('if gdprApplies is false gdpr_applies must be 0', function () { const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: false}}, bidderRequest); - const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR)[0]; expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); expect(payload).to.have.property('gdpr_consent', 'AAA'); @@ -161,7 +162,7 @@ describe('TrustXAdapter', function () { it('if gdprApplies is undefined gdpr_applies must be 1', function () { const bidderRequestWithGDPR = Object.assign({gdprConsent: {consentString: 'AAA'}}, bidderRequest); - const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR)[0]; expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); expect(payload).to.have.property('gdpr_consent', 'AAA'); @@ -170,7 +171,7 @@ describe('TrustXAdapter', function () { it('if usPrivacy is present payload must have us_privacy param', function () { const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); - const request = spec.buildRequests(bidRequests, bidderRequestWithUSP); + const request = spec.buildRequests(bidRequests, bidderRequestWithUSP)[0]; expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); expect(payload).to.have.property('us_privacy', '1YNN'); @@ -197,7 +198,7 @@ describe('TrustXAdapter', function () { } ); - const request = spec.buildRequests(bidRequestWithKeywords, bidderRequest); + const request = spec.buildRequests(bidRequestWithKeywords, bidderRequest)[0]; expect(request.data).to.be.an('string'); const payload = parseRequest(request.data); expect(payload.keywords).to.be.an('string'); @@ -226,6 +227,438 @@ describe('TrustXAdapter', function () { }); }); + describe('buildRequests with new format', function () { + function parseRequest(data) { + return JSON.parse(data); + } + const bidderRequest = { + refererInfo: {referer: 'https://example.com'}, + bidderRequestId: '22edbae2733bf6', + auctionId: '9e2dfbfe-00c7-4f5e-9850-4044df3229c7', + timeout: 3000 + }; + const referrer = encodeURIComponent(bidderRequest.refererInfo.referer); + + let bidRequests = [ + { + 'bidder': 'trustx', + 'params': { + 'uid': '43', + 'bidFloor': 1.25, + 'useNewFormat': true + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, + 'bidId': '42dbe3a7168a6a', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '9e2dfbfe-00c7-4f5e-9850-4044df3229c7', + }, + { + 'bidder': 'trustx', + 'params': { + 'uid': '44', + 'useNewFormat': true + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '9e2dfbfe-00c7-4f5e-9850-4044df3229c7', + }, + { + 'bidder': 'trustx', + 'params': { + 'uid': '45', + 'useNewFormat': true + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'mediaTypes': { + 'video': { + 'playerSize': [[400, 600]], + 'mimes': ['video/mp4', 'video/webm', 'application/javascript', 'video/ogg'] + } + }, + 'bidId': '3150ccb55da321', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '9e2dfbfe-00c7-4f5e-9850-4044df3229c7', + }, + { + 'bidder': 'trustx', + 'params': { + 'uid': '41', + 'useNewFormat': true + }, + 'adUnitCode': 'adunit-code-2', + 'sizes': [[728, 90]], + 'mediaTypes': { + 'video': { + 'playerSize': [[400, 600]], + 'protocols': [1, 2, 3] + }, + 'banner': { + 'sizes': [[728, 90]] + } + }, + 'bidId': '3150ccb55da321', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '9e2dfbfe-00c7-4f5e-9850-4044df3229c7', + } + ]; + + it('should attach valid params to the tag', function () { + const request = spec.buildRequests([bidRequests[0]], bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.deep.equal({ + 'id': bidderRequest.bidderRequestId, + 'site': { + 'page': referrer + }, + 'tmax': bidderRequest.timeout, + 'source': { + 'tid': bidderRequest.auctionId, + 'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'} + }, + 'imp': [{ + 'id': bidRequests[0].bidId, + 'tagid': bidRequests[0].params.uid, + 'ext': {'divid': bidRequests[0].adUnitCode}, + 'bidfloor': bidRequests[0].params.bidFloor, + 'banner': { + 'w': 300, + 'h': 250, + 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] + } + }] + }); + }); + + it('make possible to process request without mediaTypes', function () { + const request = spec.buildRequests([bidRequests[0], bidRequests[1]], bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.deep.equal({ + 'id': bidderRequest.bidderRequestId, + 'site': { + 'page': referrer + }, + 'tmax': bidderRequest.timeout, + 'source': { + 'tid': bidderRequest.auctionId, + 'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'} + }, + 'imp': [{ + 'id': bidRequests[0].bidId, + 'tagid': bidRequests[0].params.uid, + 'ext': {'divid': bidRequests[0].adUnitCode}, + 'bidfloor': bidRequests[0].params.bidFloor, + 'banner': { + 'w': 300, + 'h': 250, + 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] + } + }, { + 'id': bidRequests[1].bidId, + 'tagid': bidRequests[1].params.uid, + 'ext': {'divid': bidRequests[1].adUnitCode}, + 'banner': { + 'w': 300, + 'h': 250, + 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] + } + }] + }); + }); + + it('should attach valid params to the video tag', function () { + const request = spec.buildRequests(bidRequests.slice(0, 3), bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.deep.equal({ + 'id': bidderRequest.bidderRequestId, + 'site': { + 'page': referrer + }, + 'tmax': bidderRequest.timeout, + 'source': { + 'tid': bidderRequest.auctionId, + 'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'} + }, + 'imp': [{ + 'id': bidRequests[0].bidId, + 'tagid': bidRequests[0].params.uid, + 'ext': {'divid': bidRequests[0].adUnitCode}, + 'bidfloor': bidRequests[0].params.bidFloor, + 'banner': { + 'w': 300, + 'h': 250, + 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] + } + }, { + 'id': bidRequests[1].bidId, + 'tagid': bidRequests[1].params.uid, + 'ext': {'divid': bidRequests[1].adUnitCode}, + 'banner': { + 'w': 300, + 'h': 250, + 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] + } + }, { + 'id': bidRequests[2].bidId, + 'tagid': bidRequests[2].params.uid, + 'ext': {'divid': bidRequests[2].adUnitCode}, + 'video': { + 'w': 400, + 'h': 600, + 'mimes': ['video/mp4', 'video/webm', 'application/javascript', 'video/ogg'] + } + }] + }); + }); + + it('should support mixed mediaTypes', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.deep.equal({ + 'id': bidderRequest.bidderRequestId, + 'site': { + 'page': referrer + }, + 'tmax': bidderRequest.timeout, + 'source': { + 'tid': bidderRequest.auctionId, + 'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'} + }, + 'imp': [{ + 'id': bidRequests[0].bidId, + 'tagid': bidRequests[0].params.uid, + 'ext': {'divid': bidRequests[0].adUnitCode}, + 'bidfloor': bidRequests[0].params.bidFloor, + 'banner': { + 'w': 300, + 'h': 250, + 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] + } + }, { + 'id': bidRequests[1].bidId, + 'tagid': bidRequests[1].params.uid, + 'ext': {'divid': bidRequests[1].adUnitCode}, + 'banner': { + 'w': 300, + 'h': 250, + 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] + } + }, { + 'id': bidRequests[2].bidId, + 'tagid': bidRequests[2].params.uid, + 'ext': {'divid': bidRequests[2].adUnitCode}, + 'video': { + 'w': 400, + 'h': 600, + 'mimes': ['video/mp4', 'video/webm', 'application/javascript', 'video/ogg'], + } + }, { + 'id': bidRequests[3].bidId, + 'tagid': bidRequests[3].params.uid, + 'ext': {'divid': bidRequests[3].adUnitCode}, + 'banner': { + 'w': 728, + 'h': 90, + 'format': [{'w': 728, 'h': 90}] + }, + 'video': { + 'w': 400, + 'h': 600, + 'protocols': [1, 2, 3] + } + }] + }); + }); + + it('if gdprConsent is present payload must have gdpr params', function () { + const gdprBidderRequest = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: true}}, bidderRequest); + const request = spec.buildRequests(bidRequests, gdprBidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('user'); + expect(payload.user).to.have.property('ext'); + expect(payload.user.ext).to.have.property('consent', 'AAA'); + expect(payload).to.have.property('regs'); + expect(payload.regs).to.have.property('ext'); + expect(payload.regs.ext).to.have.property('gdpr', 1); + }); + + it('if usPrivacy is present payload must have us_privacy param', function () { + const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithUSP)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('regs'); + expect(payload.regs).to.have.property('ext'); + expect(payload.regs.ext).to.have.property('us_privacy', '1YNN'); + }); + + it('if userId is present payload must have user.ext param with right keys', function () { + const eids = [ + { + source: 'pubcid.org', + uids: [{ + id: 'some-random-id-value', + atype: 1 + }] + }, + { + source: 'adserver.org', + uids: [{ + id: 'some-random-id-value', + atype: 1, + ext: { + rtiPartner: 'TDID' + } + }] + } + ]; + const bidRequestsWithUserIds = bidRequests.map((bid) => { + return Object.assign({ + userIdAsEids: eids + }, bid); + }); + const request = spec.buildRequests(bidRequestsWithUserIds, bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('user'); + expect(payload.user).to.have.property('ext'); + expect(payload.user.ext.eids).to.deep.equal(eids); + }); + + it('if schain is present payload must have source.ext.schain param', function () { + const schain = { + complete: 1, + nodes: [ + { + asi: 'indirectseller.com', + sid: '00001', + hp: 1 + } + ] + }; + const bidRequestsWithSChain = bidRequests.map((bid) => { + return Object.assign({ + schain: schain + }, bid); + }); + const request = spec.buildRequests(bidRequestsWithSChain, bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('source'); + expect(payload.source).to.have.property('ext'); + expect(payload.source.ext).to.have.property('schain'); + expect(payload.source.ext.schain).to.deep.equal(schain); + }); + + it('if content and segment is present in jwTargeting, payload must have right params', function () { + const jsContent = {id: 'test_jw_content_id'}; + const jsSegments = ['test_seg_1', 'test_seg_2']; + const bidRequestsWithJwTargeting = bidRequests.map((bid) => { + return Object.assign({ + rtd: { + jwplayer: { + targeting: { + segments: jsSegments, + content: jsContent + } + } + } + }, bid); + }); + const request = spec.buildRequests(bidRequestsWithJwTargeting, bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('user'); + expect(payload.user.data).to.deep.equal([{ + name: 'iow_labs_pub_data', + segment: [ + {name: 'jwpseg', value: jsSegments[0]}, + {name: 'jwpseg', value: jsSegments[1]} + ] + }]); + expect(payload).to.have.property('site'); + expect(payload.site.content).to.deep.equal(jsContent); + }); + + it('should contain the keyword values if it present in ortb2.(site/user)', function () { + const getConfigStub = sinon.stub(config, 'getConfig').callsFake( + arg => arg === 'ortb2.user' ? {'keywords': 'foo'} : (arg === 'ortb2.site' ? {'keywords': 'bar'} : null)); + const request = spec.buildRequests([bidRequests[0]], bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload.ext.keywords).to.deep.equal([{'key': 'user', 'value': ['foo']}, {'key': 'context', 'value': ['bar']}]); + getConfigStub.restore(); + }); + + it('shold be right tmax when timeout in config is less then timeout in bidderRequest', function() { + const getConfigStub = sinon.stub(config, 'getConfig').callsFake( + arg => arg === 'bidderTimeout' ? 2000 : null); + const request = spec.buildRequests([bidRequests[0]], bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload.tmax).to.equal(2000); + getConfigStub.restore(); + }); + it('shold be right tmax when timeout in bidderRequest is less then timeout in config', function() { + const getConfigStub = sinon.stub(config, 'getConfig').callsFake( + arg => arg === 'bidderTimeout' ? 5000 : null); + const request = spec.buildRequests([bidRequests[0]], bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload.tmax).to.equal(3000); + getConfigStub.restore(); + }); + + describe('floorModule', function () { + const floorTestData = { + 'currency': 'USD', + 'floor': 1.50 + }; + const bidRequest = Object.assign({ + getFloor: (_) => { + return floorTestData; + } + }, bidRequests[1]); + it('should return the value from getFloor if present', function () { + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload.imp[0].bidfloor).to.equal(floorTestData.floor); + }); + it('should return the getFloor.floor value if it is greater than bidfloor', function () { + const bidfloor = 0.80; + const bidRequestsWithFloor = { ...bidRequest }; + bidRequestsWithFloor.params = Object.assign({bidFloor: bidfloor}, bidRequestsWithFloor.params); + const request = spec.buildRequests([bidRequestsWithFloor], bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload.imp[0].bidfloor).to.equal(floorTestData.floor); + }); + it('should return the bidfloor value if it is greater than getFloor.floor', function () { + const bidfloor = 1.80; + const bidRequestsWithFloor = { ...bidRequest }; + bidRequestsWithFloor.params = Object.assign({bidFloor: bidfloor}, bidRequestsWithFloor.params); + const request = spec.buildRequests([bidRequestsWithFloor], bidderRequest)[0]; + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload.imp[0].bidfloor).to.equal(bidfloor); + }); + }); + }); + describe('interpretResponse', function () { const responses = [ {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 43, 'h': 250, 'w': 300}], 'seat': '1'}, @@ -252,7 +685,7 @@ describe('TrustXAdapter', function () { 'auctionId': '1cbd2feafe5e8b', } ]; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests)[0]; const expectedResponse = [ { 'requestId': '659423fff799cb', @@ -309,7 +742,7 @@ describe('TrustXAdapter', function () { 'auctionId': '1fa09aee5c8c99', } ]; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests)[0]; const expectedResponse = [ { 'requestId': '300bfeb0d71a5b', @@ -392,7 +825,7 @@ describe('TrustXAdapter', function () { 'auctionId': '1fa09aee5c84d34', } ]; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests)[0]; const result = spec.interpretResponse({'body': {'seatbid': responses.slice(3)}}, request); expect(result.length).to.equal(0); }); @@ -462,7 +895,7 @@ describe('TrustXAdapter', function () { 'auctionId': '32a1f276cb87cb8', } ]; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests)[0]; const expectedResponse = [ { 'requestId': '2164be6358b9', @@ -562,7 +995,7 @@ describe('TrustXAdapter', function () { 'auctionId': '35bcbc0f7e79c', } ]; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests)[0]; const expectedResponse = [ { 'requestId': '5126e301f4be', @@ -636,7 +1069,7 @@ describe('TrustXAdapter', function () { {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 50, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 51, content_type: 'video'}], 'seat': '2'} ]; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests)[0]; const expectedResponse = [ { 'requestId': '57dfefb80eca', @@ -715,7 +1148,7 @@ describe('TrustXAdapter', function () { {'bid': [{'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 51, content_type: 'video', w: 300, h: 250}], 'seat': '2'}, {'bid': [{'price': 1.20, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 52, content_type: 'video', w: 300, h: 250}], 'seat': '2'} ]; - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests)[0]; const expectedResponse = [ { 'requestId': 'e6e65553fc8', From 5fbef6063ccee3dddd77fddca4a2bc922e56c4f7 Mon Sep 17 00:00:00 2001 From: couchcrew-thomas Date: Wed, 14 Apr 2021 11:34:03 +0200 Subject: [PATCH 035/303] FeedAd Bid Adapter: add support for GDPR/TCF 2.0 & remove video support (#6538) * added file scaffold * added isBidRequestValid implementation * added local prototype of ad integration * added implementation for placement ID validation * fixed video context filter * applied lint to feedad bid adapter * added unit test for bid request validation * added buildRequest unit test * added unit tests for timeout and bid won callbacks * updated bid request to FeedAd API * added parsing of feedad api bid response * added transmisison of tracking events to FeedAd Api * code cleanup * updated feedad unit tests for buildRequest method * added unit tests for event tracking implementation * added unit test for interpretResponse method * added adapter documentation * added dedicated feedad example page * updated feedad adapter to use live system * updated FeedAd adapter placement ID regex * removed groups from FeedAd adapter placement ID regex * removed dedicated feedad example page * updated imports in FeedAd adapter file to use relative paths * updated FeedAd adapter unit test to use sinon.useFakeXMLHttpRequest() * added GDPR fields to the FeedAd bid request * removed video from supported media types of the FeedAd adapter * increased version code of FeedAd adapter to 1.0.2 * removed unnecessary check of bidder request * fixed unit test testing for old FeedAd version * removed video media type example from documentation file * added gvlid to FeedAd adapter --- modules/feedadBidAdapter.js | 16 +++++++-- modules/feedadBidAdapter.md | 3 -- test/spec/modules/feedadBidAdapter_spec.js | 41 ++++++++++++++++++++-- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/modules/feedadBidAdapter.js b/modules/feedadBidAdapter.js index 3992f2db5e0..54a4ef0c998 100644 --- a/modules/feedadBidAdapter.js +++ b/modules/feedadBidAdapter.js @@ -1,13 +1,13 @@ import * as utils from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {BANNER} from '../src/mediaTypes.js'; import {ajax} from '../src/ajax.js'; /** * Version of the FeedAd bid adapter * @type {string} */ -const VERSION = '1.0.0'; +const VERSION = '1.0.2'; /** * @typedef {object} FeedAdApiBidRequest @@ -61,6 +61,11 @@ const VERSION = '1.0.0'; * @property [device_platform] {1|2|3} 1 - Android | 2 - iOS | 3 - Windows */ +/** + * The IAB TCF 2.0 vendor ID for the FeedAd GmbH + */ +const TCF_VENDOR_ID = 781; + /** * Bidder network identity code * @type {string} @@ -71,7 +76,7 @@ const BIDDER_CODE = 'feedad'; * The media types supported by FeedAd * @type {MediaType[]} */ -const MEDIA_TYPES = [VIDEO, BANNER]; +const MEDIA_TYPES = [BANNER]; /** * Tag for logging @@ -204,6 +209,10 @@ function buildRequests(validBidRequests, bidderRequest) { referer: data.refererInfo.referer, transactionId: bid.transactionId }); + if (bidderRequest.gdprConsent) { + data.consentIabTcf = bidderRequest.gdprConsent.consentString; + data.gdprApplies = bidderRequest.gdprConsent.gdprApplies; + } return { method: 'POST', url: `${API_ENDPOINT}${API_PATH_BID_REQUEST}`, @@ -279,6 +288,7 @@ function trackingHandlerFactory(klass) { */ export const spec = { code: BIDDER_CODE, + gvlid: TCF_VENDOR_ID, supportedMediaTypes: MEDIA_TYPES, isBidRequestValid, buildRequests, diff --git a/modules/feedadBidAdapter.md b/modules/feedadBidAdapter.md index fd57025c29e..6f705df36b5 100644 --- a/modules/feedadBidAdapter.md +++ b/modules/feedadBidAdapter.md @@ -18,9 +18,6 @@ Prebid.JS adapter that connects to the FeedAd demand sources. mediaTypes: { banner: { // supports all banner sizes sizes: [[300, 250]], - }, - video: { // supports only outstream video - context: 'outstream' } }, bids: [ diff --git a/test/spec/modules/feedadBidAdapter_spec.js b/test/spec/modules/feedadBidAdapter_spec.js index 066ab6b21f6..6b75af0d55d 100644 --- a/test/spec/modules/feedadBidAdapter_spec.js +++ b/test/spec/modules/feedadBidAdapter_spec.js @@ -13,7 +13,7 @@ describe('FeedAdAdapter', function () { it('should only support video and banner ads', function () { expect(spec.supportedMediaTypes).to.be.a('array'); expect(spec.supportedMediaTypes).to.include(BANNER); - expect(spec.supportedMediaTypes).to.include(VIDEO); + expect(spec.supportedMediaTypes).not.to.include(VIDEO); expect(spec.supportedMediaTypes).not.to.include(NATIVE); }); it('should export the BidderSpec functions', function () { @@ -23,6 +23,9 @@ describe('FeedAdAdapter', function () { expect(spec.onTimeout).to.be.a('function'); expect(spec.onBidWon).to.be.a('function'); }); + it('should export the TCF vendor ID', function () { + expect(spec.gvlid).to.equal(781); + }) }); describe('isBidRequestValid', function () { @@ -248,6 +251,40 @@ describe('FeedAdAdapter', function () { let result = spec.buildRequests([bid, bid, bid]); expect(result).to.be.empty; }); + it('should not include GDPR data if the bidder request has none available', function () { + let bid = { + code: 'feedad', + mediaTypes: { + banner: { + sizes: [[320, 250]] + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid], bidderRequest); + expect(result.data.gdprApplies).to.be.undefined; + expect(result.data.consentIabTcf).to.be.undefined; + }); + it('should include GDPR data if the bidder requests contains it', function () { + let bid = { + code: 'feedad', + mediaTypes: { + banner: { + sizes: [[320, 250]] + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let request = Object.assign({}, bidderRequest, { + gdprConsent: { + consentString: 'the consent string', + gdprApplies: true + } + }); + let result = spec.buildRequests([bid], request); + expect(result.data.gdprApplies).to.equal(request.gdprConsent.gdprApplies); + expect(result.data.consentIabTcf).to.equal(request.gdprConsent.consentString); + }); }); describe('interpretResponse', function () { @@ -404,7 +441,7 @@ describe('FeedAdAdapter', function () { prebid_bid_id: bidId, prebid_transaction_id: transactionId, referer, - sdk_version: '1.0.0' + sdk_version: '1.0.2' }; subject(data); expect(server.requests.length).to.equal(1); From 1aeca20155c134b8e7a4da01403940564ef1e114 Mon Sep 17 00:00:00 2001 From: mamatic <52153441+mamatic@users.noreply.github.com> Date: Wed, 14 Apr 2021 12:08:12 +0200 Subject: [PATCH 036/303] Ats optional 3p endpoint - keep default behavior the same (#6586) * ATS-identityLinkIdSystem - add use3P config property to control firing of 3P envelope endpoint * ATS-identityLinkIdSystem - add notUse3P config property to control firing of 3P envelope endpoint --- .../gpt/idImportLibrary_example.html | 3 +-- integrationExamples/gpt/userId_example.html | 2 +- modules/identityLinkIdSystem.js | 2 +- modules/userId/index.js | 2 +- modules/userId/userId.md | 4 ++-- .../spec/modules/identityLinkIdSystem_spec.js | 20 +++---------------- 6 files changed, 9 insertions(+), 24 deletions(-) diff --git a/integrationExamples/gpt/idImportLibrary_example.html b/integrationExamples/gpt/idImportLibrary_example.html index b0088131858..a3ef3f168c0 100644 --- a/integrationExamples/gpt/idImportLibrary_example.html +++ b/integrationExamples/gpt/idImportLibrary_example.html @@ -46,8 +46,7 @@ name: 'identityLink', params: { pid: '14', // Set your real identityLink placement ID here - // use3P: false // true/false - If you want to use 3P endpoint to retrieve envelope. If you do not set this property to true, 3p endpoint will not be fired. By default this property is undefined and 3p request will not be fired. - }, + // notUse3P: true // true/false - If you do not want to use 3P endpoint to retrieve envelope. If you do not set this property to true, 3p endpoint will be fired. By default this propertt is undefined and 3p request will be fired.}, storage: { type: 'html5', name: 'idl_env', diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index 9d170254084..72657258ad5 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -230,7 +230,7 @@ name: 'identityLink', params: { pid: '14', // Set your real identityLink placement ID here - // use3P: false // true/false - If you want to use 3P endpoint to retrieve envelope. If you do not set this property to true, 3p endpoint will not be fired. By default this property is undefined and 3p request will not be fired. + // notUse3P: true // true/false - If you do not want to use 3P endpoint to retrieve envelope. If you do not set this property to true, 3p endpoint will be fired. By default this property is undefined and 3p request will be fired. }, storage: { type: 'cookie', diff --git a/modules/identityLinkIdSystem.js b/modules/identityLinkIdSystem.js index 7c04118e1fc..df7b03b4e6e 100644 --- a/modules/identityLinkIdSystem.js +++ b/modules/identityLinkIdSystem.js @@ -98,7 +98,7 @@ function getEnvelope(url, callback, configParams) { } }; - if (configParams.use3P && !storage.getCookie('_lr_retry_request')) { + if (!configParams.notUse3P && !storage.getCookie('_lr_retry_request')) { setRetryCookie(); utils.logInfo('identityLink: A 3P retrieval is attempted!'); setEnvelopeSource(false); diff --git a/modules/userId/index.js b/modules/userId/index.js index 0dce727ca53..8822e2e11ea 100644 --- a/modules/userId/index.js +++ b/modules/userId/index.js @@ -101,7 +101,7 @@ * @property {(LiveIntentCollectConfig|undefined)} liCollectConfig - the config for LiveIntent's collect requests * @property {(string|undefined)} pd - publisher provided data for reconciling ID5 IDs * @property {(string|undefined)} emailHash - if provided, the hashed email address of a user - * @property {(string|undefined)} use3P - use to retrieve envelope from 3p endpoint + * @property {(string|undefined)} notUse3P - use to retrieve envelope from 3p endpoint */ /** diff --git a/modules/userId/userId.md b/modules/userId/userId.md index d9379ea9c85..79f547b179f 100644 --- a/modules/userId/userId.md +++ b/modules/userId/userId.md @@ -44,7 +44,7 @@ pbjs.setConfig({ name: 'identityLink', params: { pid: '999', // Set your real identityLink placement ID here - // use3P: false // true/false - If you want to use 3P endpoint to retrieve envelope. If you do not set this property to true, 3p endpoint will not be fired. By default this propertt is undefined and 3p request will not be fired. + // notUse3P: true // true/false - If you do not want to use 3P endpoint to retrieve envelope. If you do not set this property to true, 3p endpoint will be fired. By default this property is undefined and 3p request will be fired. }, storage: { type: 'cookie', @@ -146,7 +146,7 @@ pbjs.setConfig({ name: 'identityLink', params: { pid: '999', // Set your real identityLink placement ID here - // use3P: false // true/false - If you want to use 3P endpoint to retrieve envelope. If you do not set this property to true, 3p endpoint will not be fired. By default this property is undefined and 3p request will not be fired. + // notUse3P: true // true/false - If you do not want to use 3P endpoint to retrieve envelope. If you do not set this property to true, 3p endpoint will be fired. By default this property is undefined and 3p request will be fired. }, storage: { type: 'html5', diff --git a/test/spec/modules/identityLinkIdSystem_spec.js b/test/spec/modules/identityLinkIdSystem_spec.js index ac79b2e3916..a31270c86c7 100644 --- a/test/spec/modules/identityLinkIdSystem_spec.js +++ b/test/spec/modules/identityLinkIdSystem_spec.js @@ -36,7 +36,6 @@ describe('IdentityLinkId tests', function () { it('should call the LiveRamp envelope endpoint', function () { let callBackSpy = sinon.spy(); - defaultConfigParams.params.use3P = true; let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; @@ -65,7 +64,6 @@ describe('IdentityLinkId tests', function () { }); it('should call the LiveRamp envelope endpoint with IAB consent string v1', function () { - defaultConfigParams.params.use3P = true; let callBackSpy = sinon.spy(); let consentData = { gdprApplies: true, @@ -84,7 +82,6 @@ describe('IdentityLinkId tests', function () { }); it('should call the LiveRamp envelope endpoint with IAB consent string v2', function () { - defaultConfigParams.params.use3P = true; let callBackSpy = sinon.spy(); let consentData = { gdprApplies: true, @@ -106,7 +103,6 @@ describe('IdentityLinkId tests', function () { }); it('should not throw Uncaught TypeError when envelope endpoint returns empty response', function () { - defaultConfigParams.params.use3P = true; let callBackSpy = sinon.spy(); let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); @@ -123,7 +119,6 @@ describe('IdentityLinkId tests', function () { }); it('should log an error and continue to callback if ajax request errors', function () { - defaultConfigParams.params.use3P = true; let callBackSpy = sinon.spy(); let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); @@ -148,8 +143,7 @@ describe('IdentityLinkId tests', function () { expect(request).to.be.eq(undefined); }); - it('should call the LiveRamp envelope endpoint if cookie _lr_retry_request does not exist and use3P config property was set to true', function () { - defaultConfigParams.params.use3P = true; + it('should call the LiveRamp envelope endpoint if cookie _lr_retry_request does not exist and notUse3P config property was not set', function () { let callBackSpy = sinon.spy(); let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); @@ -163,16 +157,8 @@ describe('IdentityLinkId tests', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should not call the LiveRamp envelope endpoint if config property use3P is set to false', function () { - defaultConfigParams.params.use3P = false; - let callBackSpy = sinon.spy(); - let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; - submoduleCallback(callBackSpy); - let request = server.requests[0]; - expect(request).to.be.eq(undefined); - }); - - it('should not call the LiveRamp envelope endpoint if config property use3P is undefined', function () { + it('should not call the LiveRamp envelope endpoint if config property notUse3P is set to true', function () { + defaultConfigParams.params.notUse3P = true; let callBackSpy = sinon.spy(); let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); From d51d6ebf0920632137cbf8f9385db60069ce515a Mon Sep 17 00:00:00 2001 From: vincentproxistore <56686565+vincentproxistore@users.noreply.github.com> Date: Wed, 14 Apr 2021 12:31:32 +0200 Subject: [PATCH 037/303] use another uri for cookieless (#6572) --- modules/proxistoreBidAdapter.js | 2 +- test/spec/modules/proxistoreBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/proxistoreBidAdapter.js b/modules/proxistoreBidAdapter.js index 9b1675722be..ff07ee9ede9 100644 --- a/modules/proxistoreBidAdapter.js +++ b/modules/proxistoreBidAdapter.js @@ -57,7 +57,7 @@ function _createServerRequest(bidRequests, bidderRequest) { const endPointUri = payload.gdpr.consentGiven || !payload.gdpr.applies ? `https://abs.proxistore.com/${payload.language}/v3/rtb/prebid/multi` - : `https://abs.proxistore.com/${payload.language}/v3/rtb/prebid/multi/cookieless`; + : `https://abs.cookieless-proxistore.com/${payload.language}/v3/rtb/prebid/multi`; return { method: 'POST', diff --git a/test/spec/modules/proxistoreBidAdapter_spec.js b/test/spec/modules/proxistoreBidAdapter_spec.js index e7db01828e0..bdcdca06183 100644 --- a/test/spec/modules/proxistoreBidAdapter_spec.js +++ b/test/spec/modules/proxistoreBidAdapter_spec.js @@ -54,7 +54,7 @@ describe('ProxistoreBidAdapter', function () { const url = { cookieBase: 'https://abs.proxistore.com/fr/v3/rtb/prebid/multi', cookieLess: - 'https://abs.proxistore.com/fr/v3/rtb/prebid/multi/cookieless', + 'https://abs.cookieless-proxistore.com/fr/v3/rtb/prebid/multi', }; let request = spec.buildRequests([bid], bidderRequest); it('should return a valid object', function () { From 6a6268a4ada20f45cb06aaeaf46e32f7807fb02d Mon Sep 17 00:00:00 2001 From: Matt Felstead Date: Wed, 14 Apr 2021 12:16:45 +0100 Subject: [PATCH 038/303] Pbjs Core: add new API to return the highest unused bid for a given adunit (#6342) * feat: add new API to return the highest unused bid for a given adunit code * feat: add unit tests for new API --- src/auctionManager.js | 8 +++++ src/prebid.js | 22 ++++++++++++-- test/spec/api_spec.js | 4 +++ test/spec/unit/pbjs_api_spec.js | 52 +++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 2 deletions(-) diff --git a/src/auctionManager.js b/src/auctionManager.js index 3d4bd0afe99..1aca1277aa8 100644 --- a/src/auctionManager.js +++ b/src/auctionManager.js @@ -9,6 +9,7 @@ * * @property {function(): Array} getBidsRequested - returns consolidated bid requests * @property {function(): Array} getBidsReceived - returns consolidated bid received + * @property {function(): Array} getAllBidsForAdUnitCode - returns consolidated bid received for a given adUnit * @property {function(): Array} getAdUnits - returns consolidated adUnits * @property {function(): Array} getAdUnitCodes - returns consolidated adUnitCodes * @property {function(): Object} createAuction - creates auction instance and stores it for future reference @@ -66,6 +67,13 @@ export function newAuctionManager() { .filter(bid => bid); }; + auctionManager.getAllBidsForAdUnitCode = function(adUnitCode) { + return _auctions.map((auction) => { + return auction.getBidsReceived(); + }).reduce(flatten, []) + .filter(bid => bid && bid.adUnitCode === adUnitCode) + }; + auctionManager.getAdUnits = function() { return _auctions.map(auction => auction.getAdUnits()) .reduce(flatten, []); diff --git a/src/prebid.js b/src/prebid.js index 6565c1610d8..7211371366e 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -1,12 +1,12 @@ /** @module pbjs */ import { getGlobal } from './prebidGlobal.js'; -import { adUnitsFilter, flatten, isArrayOfNums, isGptPubadsDefined, uniques } from './utils.js'; +import { adUnitsFilter, flatten, getHighestCpm, isArrayOfNums, isGptPubadsDefined, uniques } from './utils.js'; import { listenMessagesFromCreative } from './secureCreatives.js'; import { userSync } from './userSync.js'; import { config } from './config.js'; import { auctionManager } from './auctionManager.js'; -import { targeting } from './targeting.js'; +import { filters, targeting } from './targeting.js'; import { hook } from './hook.js'; import { sessionLoader } from './debugging.js'; import includes from 'core-js-pure/features/array/includes.js'; @@ -206,6 +206,24 @@ $$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCodeStr = function (adunitCode) { } }; +/** + * This function returns the query string targeting parameters available at this moment for a given ad unit. Note that some bidder's response may not have been received if you call this function too quickly after the requests are sent. + * @param adUnitCode {string} adUnitCode to get the bid responses for + * @alias module:pbjs.getHighestUnusedBidResponseForAdUnitCode + * @returns {Object} returnObj return bid + */ +$$PREBID_GLOBAL$$.getHighestUnusedBidResponseForAdUnitCode = function (adunitCode) { + if (adunitCode) { + const bid = auctionManager.getAllBidsForAdUnitCode(adunitCode) + .filter(filters.isUnusedBid) + .filter(filters.isBidNotExpired) + + return bid.length ? bid.reduce(getHighestCpm) : {} + } else { + utils.logMessage('Need to call getHighestUnusedBidResponseForAdUnitCode with adunitCode'); + } +}; + /** * This function returns the query string targeting parameters available at this moment for a given ad unit. Note that some bidder's response may not have been received if you call this function too quickly after the requests are sent. * @param adUnitCode {string} adUnitCode to get the bid responses for diff --git a/test/spec/api_spec.js b/test/spec/api_spec.js index 6d67565056f..cb6c7aa87a3 100755 --- a/test/spec/api_spec.js +++ b/test/spec/api_spec.js @@ -82,5 +82,9 @@ describe('Publisher API', function () { it('should have function $$PREBID_GLOBAL$$.getAllWinningBids', function () { assert.isFunction($$PREBID_GLOBAL$$.getAllWinningBids); }); + + it('should have function $$PREBID_GLOBAL$$.getHighestUnusedBidResponseForAdUnitCode', function () { + assert.isFunction($$PREBID_GLOBAL$$.getHighestUnusedBidResponseForAdUnitCode); + }); }); }); diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index afad1d665fd..805eae9e3bc 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -2575,6 +2575,58 @@ describe('Unit: Prebid Module', function () { }); }); + describe('getHighestUnusedBidResponseForAdUnitCode', () => { + afterEach(() => { + resetAuction(); + }) + + it('returns an empty object if there is no bid for the given adUnitCode', () => { + const highestBid = $$PREBID_GLOBAL$$.getHighestUnusedBidResponseForAdUnitCode('stallone'); + expect(highestBid).to.deep.equal({}); + }) + + it('returns undefined if adUnitCode is provided', () => { + const highestBid = $$PREBID_GLOBAL$$.getHighestUnusedBidResponseForAdUnitCode(); + expect(highestBid).to.be.undefined; + }) + + it('should ignore bids that have already been used (\'rendered\')', () => { + const _bidsReceived = getBidResponses().slice(0, 3); + _bidsReceived[0].cpm = 11 + _bidsReceived[1].cpm = 13 + _bidsReceived[2].cpm = 12 + + _bidsReceived.forEach((bid) => { + bid.adUnitCode = '/19968336/header-bid-tag-0'; + }); + + auction.getBidsReceived = function() { return _bidsReceived }; + const highestBid1 = $$PREBID_GLOBAL$$.getHighestUnusedBidResponseForAdUnitCode('/19968336/header-bid-tag-0'); + expect(highestBid1).to.deep.equal(_bidsReceived[1]) + _bidsReceived[1].status = CONSTANTS.BID_STATUS.RENDERED + const highestBid2 = $$PREBID_GLOBAL$$.getHighestUnusedBidResponseForAdUnitCode('/19968336/header-bid-tag-0'); + expect(highestBid2).to.deep.equal(_bidsReceived[2]) + }) + + it('should ignore expired bids', () => { + const _bidsReceived = getBidResponses().slice(0, 3); + _bidsReceived[0].cpm = 11 + _bidsReceived[1].cpm = 13 + _bidsReceived[2].cpm = 12 + + _bidsReceived.forEach((bid) => { + bid.adUnitCode = '/19968336/header-bid-tag-0'; + }); + + auction.getBidsReceived = function() { return _bidsReceived }; + + bidExpiryStub.restore(); + bidExpiryStub = sinon.stub(filters, 'isBidNotExpired').callsFake((bid) => bid.cpm !== 13); + const highestBid = $$PREBID_GLOBAL$$.getHighestUnusedBidResponseForAdUnitCode('/19968336/header-bid-tag-0'); + expect(highestBid).to.deep.equal(_bidsReceived[2]) + }) + }) + describe('getHighestCpm', () => { after(() => { resetAuction(); From 93ba601438117954e9e0fa685cce00924f420585 Mon Sep 17 00:00:00 2001 From: Sergio Date: Wed, 14 Apr 2021 13:59:26 +0200 Subject: [PATCH 039/303] Adpone Bid Adapter: remove usersync and pass gpdr via querystring (#6326) * remove usersync and add gpdr via querystring * wrap tests under describe adponeBidAdapter * remove bid.meta.advertiserDomains * support adomain * fix adpone advertiserDomains * fix test --- modules/adponeBidAdapter.js | 56 +++--- test/spec/modules/adponeBidAdapter_spec.js | 203 ++++++++++----------- 2 files changed, 123 insertions(+), 136 deletions(-) diff --git a/modules/adponeBidAdapter.js b/modules/adponeBidAdapter.js index f128785afff..49c0365fc87 100644 --- a/modules/adponeBidAdapter.js +++ b/modules/adponeBidAdapter.js @@ -4,34 +4,20 @@ import {triggerPixel} from '../src/utils.js'; const ADPONE_CODE = 'adpone'; const ADPONE_ENDPOINT = 'https://rtb.adpone.com/bid-request'; -const ADPONE_SYNC_ENDPOINT = 'https://eu-ads.adpone.com'; const ADPONE_REQUEST_METHOD = 'POST'; const ADPONE_CURRENCY = 'EUR'; -function _createSync() { - return { - type: 'iframe', - url: ADPONE_SYNC_ENDPOINT - } -} - -function getUserSyncs(syncOptions) { - return (syncOptions && syncOptions.iframeEnabled) ? _createSync() : ([]); -} - export const spec = { code: ADPONE_CODE, supportedMediaTypes: [BANNER], - getUserSyncs, - isBidRequestValid: bid => { return !!bid.params.placementId && !!bid.bidId && bid.bidder === 'adpone' }, - buildRequests: bidRequests => { + buildRequests: (bidRequests, bidderRequest) => { return bidRequests.map(bid => { - const url = ADPONE_ENDPOINT + '?pid=' + bid.params.placementId; + let url = ADPONE_ENDPOINT + '?pid=' + bid.params.placementId; const data = { at: 1, id: bid.bidId, @@ -49,6 +35,11 @@ export const spec = { withCredentials: true }; + if (bidderRequest && bidderRequest.gdprConsent) { + url += '&gdpr_applies=' + bidderRequest.gdprConsent.gdprApplies; + url += '&consentString=' + bidderRequest.gdprConsent.consentString; + } + return { method: ADPONE_REQUEST_METHOD, url, @@ -67,18 +58,27 @@ export const spec = { serverResponse.body.seatbid.forEach(seatbid => { if (seatbid.bid.length) { - answer = [...answer, ...seatbid.bid.filter(bid => bid.price > 0).map(bid => ({ - id: bid.id, - requestId: bidRequest.data.id, - cpm: bid.price, - ad: bid.adm, - width: bid.w || 0, - height: bid.h || 0, - currency: serverResponse.body.cur || ADPONE_CURRENCY, - netRevenue: true, - ttl: 300, - creativeId: bid.crid || 0 - }))]; + answer = [...answer, ...seatbid.bid.filter(bid => bid.price > 0).map(adponeBid => { + const bid = { + id: adponeBid.id, + requestId: bidRequest.data.id, + cpm: adponeBid.price, + ad: adponeBid.adm, + width: adponeBid.w || 0, + height: adponeBid.h || 0, + currency: serverResponse.body.cur || ADPONE_CURRENCY, + netRevenue: true, + ttl: 300, + creativeId: adponeBid.crid || 0 + }; + + if (adponeBid.meta && adponeBid.meta.adomain && adponeBid.meta.adomain.length > 0) { + bid.meta = {}; + bid.meta.advertiserDomains = adponeBid.meta.adomain; + } + + return bid + })]; } }); diff --git a/test/spec/modules/adponeBidAdapter_spec.js b/test/spec/modules/adponeBidAdapter_spec.js index 737f1c284e1..92fd672df47 100644 --- a/test/spec/modules/adponeBidAdapter_spec.js +++ b/test/spec/modules/adponeBidAdapter_spec.js @@ -110,122 +110,109 @@ describe('adponeBidAdapter', function () { expect(spec.isBidRequestValid(invalidBid)).to.be.false; }); }); -}); - -describe('interpretResponse', function () { - let serverResponse; - let bidRequest = { data: {id: '1234'} }; - - beforeEach(function () { - serverResponse = { - body: { - id: '2579e20c0bb89', - seatbid: [ - { - bid: [ - { - id: '613673EF-A07C-4486-8EE9-3FC71A7DC73D', - impid: '2579e20c0bb89_0', - price: 1, - adm: '', - adomain: [ - 'www.addomain.com' - ], - iurl: 'https://localhost11', - crid: 'creative111', - h: 250, - w: 300, - ext: { - dspid: 6 + describe('interpretResponse', function () { + let serverResponse; + let bidRequest = { data: {id: '1234'} }; + + beforeEach(function () { + serverResponse = { + body: { + id: '2579e20c0bb89', + seatbid: [ + { + bid: [ + { + id: '613673EF-A07C-4486-8EE9-3FC71A7DC73D', + impid: '2579e20c0bb89_0', + price: 1, + adm: '', + meta: { + adomain: [ + 'adpone.com' + ] + }, + iurl: 'https://localhost11', + crid: 'creative111', + h: 250, + w: 300, + ext: { + dspid: 6 + } } - } - ], - seat: 'adpone' - } - ], - cur: 'USD' - }, - }; - }); - - it('validate_response_params', function() { - const newResponse = spec.interpretResponse(serverResponse, bidRequest); - expect(newResponse[0].id).to.be.equal('613673EF-A07C-4486-8EE9-3FC71A7DC73D'); - expect(newResponse[0].requestId).to.be.equal('1234'); - expect(newResponse[0].cpm).to.be.equal(1); - expect(newResponse[0].width).to.be.equal(300); - expect(newResponse[0].height).to.be.equal(250); - expect(newResponse[0].currency).to.be.equal('USD'); - expect(newResponse[0].netRevenue).to.be.equal(true); - expect(newResponse[0].ttl).to.be.equal(300); - expect(newResponse[0].ad).to.be.equal(''); - }); + ], + seat: 'adpone' + } + ], + cur: 'USD' + }, + }; + }); - it('should correctly reorder the server response', function () { - const newResponse = spec.interpretResponse(serverResponse, bidRequest); - expect(newResponse.length).to.be.equal(1); - expect(newResponse[0]).to.deep.equal({ - id: '613673EF-A07C-4486-8EE9-3FC71A7DC73D', - requestId: '1234', - cpm: 1, - width: 300, - height: 250, - creativeId: 'creative111', - currency: 'USD', - netRevenue: true, - ttl: 300, - ad: '' + it('validate_response_params', function() { + const newResponse = spec.interpretResponse(serverResponse, bidRequest); + expect(newResponse[0].id).to.be.equal('613673EF-A07C-4486-8EE9-3FC71A7DC73D'); + expect(newResponse[0].requestId).to.be.equal('1234'); + expect(newResponse[0].cpm).to.be.equal(1); + expect(newResponse[0].width).to.be.equal(300); + expect(newResponse[0].height).to.be.equal(250); + expect(newResponse[0].currency).to.be.equal('USD'); + expect(newResponse[0].netRevenue).to.be.equal(true); + expect(newResponse[0].ttl).to.be.equal(300); + expect(newResponse[0].ad).to.be.equal(''); }); - }); - it('should not add responses if the cpm is 0 or null', function () { - serverResponse.body.seatbid[0].bid[0].price = 0; - let response = spec.interpretResponse(serverResponse, bidRequest); - expect(response).to.deep.equal([]); + it('should correctly reorder the server response', function () { + const newResponse = spec.interpretResponse(serverResponse, bidRequest); + expect(newResponse.length).to.be.equal(1); + expect(newResponse[0]).to.deep.equal({ + id: '613673EF-A07C-4486-8EE9-3FC71A7DC73D', + meta: { + advertiserDomains: [ + 'adpone.com' + ] + }, + requestId: '1234', + cpm: 1, + width: 300, + height: 250, + creativeId: 'creative111', + currency: 'USD', + netRevenue: true, + ttl: 300, + ad: '' + }); + }); - serverResponse.body.seatbid[0].bid[0].price = null; - response = spec.interpretResponse(serverResponse, bidRequest); - expect(response).to.deep.equal([]) - }); - it('should add responses if the cpm is valid', function () { - serverResponse.body.seatbid[0].bid[0].price = 0.5; - let response = spec.interpretResponse(serverResponse, bidRequest); - expect(response).to.not.deep.equal([]); - }); -}); + it('should not add responses if the cpm is 0 or null', function () { + serverResponse.body.seatbid[0].bid[0].price = 0; + let response = spec.interpretResponse(serverResponse, bidRequest); + expect(response).to.deep.equal([]); -describe('getUserSyncs', function () { - it('Verifies that getUserSyncs is a function', function () { - expect((typeof (spec.getUserSyncs)).should.equals('function')); - }); - it('Verifies getUserSyncs returns expected result', function () { - expect((typeof (spec.getUserSyncs)).should.equals('function')); - expect(spec.getUserSyncs({iframeEnabled: true})).to.deep.equal({ - type: 'iframe', - url: 'https://eu-ads.adpone.com' + serverResponse.body.seatbid[0].bid[0].price = null; + response = spec.interpretResponse(serverResponse, bidRequest); + expect(response).to.deep.equal([]) + }); + it('should add responses if the cpm is valid', function () { + serverResponse.body.seatbid[0].bid[0].price = 0.5; + let response = spec.interpretResponse(serverResponse, bidRequest); + expect(response).to.not.deep.equal([]); }); }); - it('Verifies that iframeEnabled: false returns an empty array', function () { - expect(spec.getUserSyncs({iframeEnabled: false})).to.deep.equal(EMPTY_ARRAY); - }); - it('Verifies that iframeEnabled: null returns an empty array', function () { - expect(spec.getUserSyncs(null)).to.deep.equal(EMPTY_ARRAY); - }); -}); -describe('test onBidWon function', function () { - beforeEach(function() { - sinon.stub(utils, 'triggerPixel'); - }); - afterEach(function() { - utils.triggerPixel.restore(); - }); - it('exists and is a function', () => { - expect(spec.onBidWon).to.exist.and.to.be.a('function'); - }); - it('should return nothing', function () { - var response = spec.onBidWon({}); - expect(response).to.be.an('undefined') - expect(utils.triggerPixel.called).to.equal(true); + describe('test onBidWon function', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + it('exists and is a function', () => { + expect(spec.onBidWon).to.exist.and.to.be.a('function'); + }); + it('should return nothing', function () { + var response = spec.onBidWon({}); + expect(response).to.be.an('undefined') + expect(utils.triggerPixel.called).to.equal(true); + }); }); }); From fddb1353a4f1969d72443174d1281e1dcd63be74 Mon Sep 17 00:00:00 2001 From: ym-abaranov <78230460+ym-abaranov@users.noreply.github.com> Date: Wed, 14 Apr 2021 07:45:49 -0700 Subject: [PATCH 040/303] Yieldmo bid adapter: set outstream renderer. (#6566) - adapter maintainer email: opensource@yieldmo.com --- modules/yieldmoBidAdapter.js | 60 +++++++++++++++++++++++++++++------- modules/yieldmoBidAdapter.md | 27 ++++++++++++++++ 2 files changed, 76 insertions(+), 11 deletions(-) diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index 4981534412f..9bd0d1c7f6a 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -1,8 +1,8 @@ import * as utils from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { Renderer } from '../src/Renderer.js'; import includes from 'core-js-pure/features/array/includes'; -import find from 'core-js-pure/features/array/find.js'; const BIDDER_CODE = 'yieldmo'; const CURRENCY = 'USD'; @@ -10,10 +10,14 @@ const TIME_TO_LIVE = 300; const NET_REVENUE = true; const BANNER_SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; const VIDEO_SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebidvideo'; +const OUTSTREAM_VIDEO_PLAYER_URL = 'https://prebid-outstream.yieldmo.com/bundle.js'; const OPENRTB_VIDEO_BIDPARAMS = ['placement', 'startdelay', 'skipafter', 'protocols', 'api', 'playbackmethod', 'maxduration', 'minduration', 'pos']; const OPENRTB_VIDEO_SITEPARAMS = ['name', 'domain', 'cat', 'keywords']; -const localWindow = utils.getWindowTop(); +const LOCAL_WINDOW = utils.getWindowTop(); +const DEFAULT_PLAYBACK_METHOD = 2; +const DEFAULT_START_DELAY = 0; +const VAST_TIMEOUT = 15000; export const spec = { code: BIDDER_CODE, @@ -48,12 +52,12 @@ export const spec = { page_url: bidderRequest.refererInfo.referer, bust: new Date().getTime().toString(), pr: bidderRequest.refererInfo.referer, - scrd: localWindow.devicePixelRatio || 0, + scrd: LOCAL_WINDOW.devicePixelRatio || 0, dnt: getDNT(), description: getPageDescription(), - title: localWindow.document.title || '', - w: localWindow.innerWidth, - h: localWindow.innerHeight, + title: LOCAL_WINDOW.document.title || '', + w: LOCAL_WINDOW.innerWidth, + h: LOCAL_WINDOW.innerHeight, userConsent: JSON.stringify({ // case of undefined, stringify will remove param gdprApplies: utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies') || '', @@ -203,8 +207,9 @@ function createNewBannerBid(response) { * @param bidRequest server request */ function createNewVideoBid(response, bidRequest) { - const imp = find((utils.deepAccess(bidRequest, 'data.imp') || []), imp => imp.id === response.impid); - return { + const imp = (utils.deepAccess(bidRequest, 'data.imp') || []).find(imp => imp.id === response.impid); + + let result = { requestId: imp.id, cpm: response.price, width: imp.video.w, @@ -220,6 +225,35 @@ function createNewVideoBid(response, bidRequest) { mediaType: VIDEO, }, }; + + if (imp.placement && imp.placement !== 1) { + const renderer = Renderer.install({ + url: OUTSTREAM_VIDEO_PLAYER_URL, + config: { + width: result.width, + height: result.height, + vastTimeout: VAST_TIMEOUT, + maxAllowedVastTagRedirects: 5, + allowVpaid: true, + autoPlay: true, + preload: true, + mute: true + }, + id: imp.tagid, + loaded: false, + }); + + renderer.setRender(function (bid) { + bid.renderer.push(() => { + const { id, config } = bid.renderer; + window.YMoutstreamPlayer(bid, id, config); + }); + }); + + result.renderer = renderer; + } + + return result; } /** @@ -306,10 +340,14 @@ function openRtbImpression(bidRequest) { .filter(param => includes(OPENRTB_VIDEO_BIDPARAMS, param)) .forEach(param => imp.video[param] = videoParams[param]); - if (videoParams.skippable) { - imp.video.skip = 1; + if (videoParams.skippable) imp.video.skip = 1; + if (videoParams.placement !== 1) { + imp.video = { + ...imp.video, + startdelay: DEFAULT_START_DELAY, + playbackmethod: [ DEFAULT_PLAYBACK_METHOD ] + } } - return imp; } diff --git a/modules/yieldmoBidAdapter.md b/modules/yieldmoBidAdapter.md index 1b8b7b1b741..54be295a1a1 100644 --- a/modules/yieldmoBidAdapter.md +++ b/modules/yieldmoBidAdapter.md @@ -69,3 +69,30 @@ var adUnits = [{ // Video adUnit }] }]; ``` + +Sample out-stream video ad unit config: +```javascript +var videoAdUnit = [{ + code: 'div-video-ad-1234567890', + mediaTypes: { + video: { + playerSize: [640, 480], // required + context: 'outstream', + mimes: ['video/mp4'] // required, array of strings + } + }, + bids: [{ + bidder: 'yieldmo', + params: { + placementId: '1524592390382976659', // required + video: { + placement: 3, // required, integer ( 3,4,5 ) + maxduration: 30, // required, integer + protocols: [2, 3], // required, array of integers + api: [2, 3], // required, array of integers + playbackmethod: [1,2] // required, array of integers + } + } + }] +}]; +``` From 42e36dec98c755a2b73f1e300642998840990566 Mon Sep 17 00:00:00 2001 From: Rich Audience Date: Wed, 14 Apr 2021 18:57:26 +0200 Subject: [PATCH 041/303] Richaudience Bid Adapter: add new config UserSync (#6523) * Add new config UserSync * Solved lint errors * Solved lint errors 2 * Solved lint errors 3 * Add changes * Add changes 2 * Add changes 3 * Add changes 4 * Add changes 5 * Solved issues Co-authored-by: sgimenez --- integrationExamples/gpt/gdpr_hello_world.html | 26 +- modules/richaudienceBidAdapter.js | 49 ++- .../modules/richaudienceBidAdapter_spec.js | 393 +++++++++++++++--- 3 files changed, 389 insertions(+), 79 deletions(-) diff --git a/integrationExamples/gpt/gdpr_hello_world.html b/integrationExamples/gpt/gdpr_hello_world.html index de0630178f1..2d70af8d34f 100644 --- a/integrationExamples/gpt/gdpr_hello_world.html +++ b/integrationExamples/gpt/gdpr_hello_world.html @@ -82,7 +82,7 @@ - + + + - +

Prebid.js Test

Div-1
diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index 37a9554e9a4..5e2a5e1bff5 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -31,7 +31,7 @@ export const spec = { buildRequests: function (validBidRequests, bidderRequest) { return validBidRequests.map(bid => { var payload = { - bidfloor: bid.params.bidfloor, + bidfloor: raiGetFloor(bid, config), ifa: bid.params.ifa, pid: bid.params.pid, supplyType: bid.params.supplyType, @@ -141,11 +141,15 @@ export const spec = { var syncUrl = ''; var consent = ''; + var raiSync = {}; + + raiSync = raiGetSyncInclude(config); + if (gdprConsent && typeof gdprConsent.consentString === 'string' && typeof gdprConsent.consentString != 'undefined') { consent = `consentString=${gdprConsent.consentString}` } - if (syncOptions.iframeEnabled) { + if (syncOptions.iframeEnabled && raiSync.raiIframe != 'exclude') { syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand if (consent != '') { syncUrl += `&${consent}` @@ -156,7 +160,7 @@ export const spec = { }); } - if (syncOptions.pixelEnabled && REFERER != null && syncs.length == 0) { + if (syncOptions.pixelEnabled && REFERER != null && syncs.length == 0 && raiSync.raiImage != 'exclude') { syncUrl = `https://sync.richaudience.com/bf7c142f4339da0278e83698a02b0854/?referrer=${REFERER}`; if (consent != '') { syncUrl += `&${consent}` @@ -263,3 +267,42 @@ function raiGetResolution() { } return resolution; } + +function raiGetSyncInclude(config) { + try { + let raConfig = null; + let raiSync = {}; + if (config.getConfig('userSync').filterSettings != null && typeof config.getConfig('userSync').filterSettings != 'undefined') { + raConfig = config.getConfig('userSync').filterSettings + if (raConfig.iframe != null && typeof raConfig.iframe != 'undefined') { + raiSync.raiIframe = raConfig.iframe.bidders == 'richaudience' || raConfig.iframe.bidders == '*' ? raConfig.iframe.filter : 'exclude'; + } + if (raConfig.image != null && typeof raConfig.image != 'undefined') { + raiSync.raiImage = raConfig.image.bidders == 'richaudience' || raConfig.image.bidders == '*' ? raConfig.image.filter : 'exclude'; + } + } + return raiSync; + } catch (e) { + return null; + } +} + +function raiGetFloor(bid, config) { + try { + let raiFloor; + if (bid.params.bidfloor != null) { + raiFloor = bid.params.bidfloor; + } else if (typeof bid.getFloor == 'function') { + let floorSpec = bid.getFloor({ + currency: config.getConfig('currency.adServerCurrency'), + mediaType: bid.mediaType.banner ? 'banner' : 'video', + size: '*' + }) + + raiFloor = floorSpec.floor; + } + return raiFloor + } catch (e) { + return 0 + } +} diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 5deb2463523..72410b71fb2 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -788,76 +788,343 @@ describe('Richaudience adapter tests', function () { })).to.equal(true); }); - it('Verifies user syncs iframe', function () { - var syncs = spec.getUserSyncs({ - iframeEnabled: true - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true + describe('userSync', function () { + it('Verifies user syncs iframe include', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'include'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(1); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); }); + it('Verifies user syncs iframe exclude', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'exclude'}}} + }) - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - syncs = spec.getUserSyncs({ - iframeEnabled: false - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true + var syncs = spec.getUserSyncs({ + iframeEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); }); - expect(syncs).to.have.lengthOf(0); - syncs = spec.getUserSyncs({ - iframeEnabled: true - }, [], {consentString: '', gdprApplies: false}); - expect(syncs).to.have.lengthOf(1); + it('Verifies user syncs image include', function () { + config.setConfig({ + 'userSync': {filterSettings: {image: {bidders: '*', filter: 'include'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); - syncs = spec.getUserSyncs({ - iframeEnabled: false - }, [], {consentString: '', gdprApplies: true}); - expect(syncs).to.have.lengthOf(0); + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: '', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); - config.setConfig({ - consentManagement: { - cmpApi: 'iab', - timeout: 5000, - allowAuctionWithoutConsent: true, + syncs = spec.getUserSyncs({ + iframeEnabled: false, pixelEnabled: true - } + }, [], { + consentString: null, + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); }); - }); - it('Verifies user syncs image', function () { - var syncs = spec.getUserSyncs({ - iframeEnabled: false, - pixelEnabled: true - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - referer: 'http://domain.com', - gdprApplies: true - }) - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - - syncs = spec.getUserSyncs({ - iframeEnabled: false, - pixelEnabled: true - }, [BID_RESPONSE], { - consentString: '', - referer: 'http://domain.com', - gdprApplies: true - }) - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - - syncs = spec.getUserSyncs({ - iframeEnabled: false, - pixelEnabled: true - }, [], { - consentString: null, - referer: 'http://domain.com', - gdprApplies: true - }) - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - }); + it('Verifies user syncs image exclude', function () { + config.setConfig({ + 'userSync': {filterSettings: {image: {bidders: '*', filter: 'exclude'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: '', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: true + }, [], { + consentString: null, + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(0); + }); + + it('Verifies user syncs iframe/image include', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'include'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(1); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); + }); + + it('Verifies user syncs iframe/image exclude', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'exclude'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); + }); + + it('Verifies user syncs iframe exclude / image include', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'include'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(1); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); + }); + + it('Verifies user syncs iframe include / image exclude', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'exclude'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(1); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); + }); + }) }); From 05d87735631c76a90b658453640b3c86d983a0d8 Mon Sep 17 00:00:00 2001 From: Scott Menzer Date: Wed, 14 Apr 2021 19:48:10 +0200 Subject: [PATCH 042/303] Prebid 4.35.0 Release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b8a4dc5fb4..67394ebdb33 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.35.0-pre", + "version": "4.35.0", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From a3790c27cf71d288cc3e96959110cbce88a0b9c8 Mon Sep 17 00:00:00 2001 From: Scott Menzer Date: Wed, 14 Apr 2021 20:15:04 +0200 Subject: [PATCH 043/303] Increment pre version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 67394ebdb33..58ea0d7ba30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.35.0", + "version": "4.36.0-pre", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From caead3ccccc448e4cd09d074fd9f8833f56fe9b3 Mon Sep 17 00:00:00 2001 From: Sourabh Gandhe Date: Thu, 15 Apr 2021 13:12:55 +0530 Subject: [PATCH 044/303] Deepintent ID System: add new ID module (#6537) * initial commit * feat(deepintent-dpes): adds deepintent user id module * chore(code-cleanup): removed console logs * eids config added * fix for passing the eids * docs added with minor change * tests added * remaining conflict resolution * kick off circle-ci tests manually * fix linting error * changed the atype to 3 * tests added for eids_spec.js * Change the language * added cacheIdObject signature * changed test cases * eIds passing added to adapter * docs changed removed params not required * doc added * docs added in userId base * user id tests added * lint fixes * lint fixes * code review comments fix Co-authored-by: Sourabh Gandhe Co-authored-by: ChinmoyDebnath Co-authored-by: Chris Huie --- modules/.submodules.json | 1 + modules/deepintentBidAdapter.js | 9 ++ modules/deepintentDpesIdSystem.js | 45 ++++++++ modules/deepintentDpesIdSystem.md | 43 +++++++ modules/userId/eids.js | 5 +- modules/userId/eids.md | 7 ++ modules/userId/userId.md | 14 +++ .../modules/deepintentDpesIdsystem_spec.js | 76 ++++++++++++ test/spec/modules/eids_spec.js | 12 ++ test/spec/modules/userId_spec.js | 108 +++++++++++++++--- 10 files changed, 302 insertions(+), 18 deletions(-) create mode 100644 modules/deepintentDpesIdSystem.js create mode 100644 modules/deepintentDpesIdSystem.md create mode 100644 test/spec/modules/deepintentDpesIdsystem_spec.js diff --git a/modules/.submodules.json b/modules/.submodules.json index ffa3f9df353..7ad4bedde5c 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -16,6 +16,7 @@ "zeotapIdPlusIdSystem", "haloIdSystem", "quantcastIdSystem", + "deepintentDpesIdSystem", "nextrollIdSystem", "idxIdSystem", "fabrickIdSystem", diff --git a/modules/deepintentBidAdapter.js b/modules/deepintentBidAdapter.js index c4dc23cf912..9ec6c8e5bc2 100644 --- a/modules/deepintentBidAdapter.js +++ b/modules/deepintentBidAdapter.js @@ -49,6 +49,8 @@ export const spec = { utils.deepSetValue(openRtbBidRequest, 'regs.ext.gdpr', (bidderRequest.gdprConsent.gdprApplies ? 1 : 0)); } + injectEids(openRtbBidRequest, validBidRequests); + return { method: 'POST', url: BIDDER_ENDPOINT, @@ -128,6 +130,13 @@ function buildUser(bid) { } } +function injectEids(openRtbBidRequest, validBidRequests) { + const bidUserIdAsEids = utils.deepAccess(validBidRequests, '0.userIdAsEids'); + if (utils.isArray(bidUserIdAsEids) && bidUserIdAsEids.length > 0) { + utils.deepSetValue(openRtbBidRequest, 'user.eids', bidUserIdAsEids); + } +} + function buildBanner(bid) { if (utils.deepAccess(bid, 'mediaTypes.banner')) { // Get Sizes from MediaTypes Object, Will always take first size, will be overrided by params for exact w,h diff --git a/modules/deepintentDpesIdSystem.js b/modules/deepintentDpesIdSystem.js new file mode 100644 index 00000000000..375c8c07ed1 --- /dev/null +++ b/modules/deepintentDpesIdSystem.js @@ -0,0 +1,45 @@ +/** + * This module adds DPES to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/deepintentDpesSystem + * @requires module:modules/userId + */ + +import { submodule } from '../src/hook.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const MODULE_NAME = 'deepintentId'; +export const storage = getStorageManager(null, MODULE_NAME); + +/** @type {Submodule} */ +export const deepintentDpesSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: MODULE_NAME, + /** + * decode the stored id value for passing to bid requests + * @function + * @param {{value:string}} value + * @returns {{deepintentId:Object}} + */ + decode(value, config) { + return value ? { 'deepintentId': value } : undefined; + }, + + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleConfig} config + * @param {ConsentData|undefined} consentData + * @param {Object} cacheIdObj - existing id, if any + * @return {{id: string | undefined} | undefined} + */ + getId(config, consentData, cacheIdObj) { + return cacheIdObj; + } + +}; + +submodule('userId', deepintentDpesSubmodule); diff --git a/modules/deepintentDpesIdSystem.md b/modules/deepintentDpesIdSystem.md new file mode 100644 index 00000000000..2af0fe7446e --- /dev/null +++ b/modules/deepintentDpesIdSystem.md @@ -0,0 +1,43 @@ +# Deepintent DPES ID + +The Deepintent Id is a shared, healthcare identifier which helps publisher in absence of the 3rd Party cookie matching. This lets publishers set and bid with healthcare identity . Deepintent lets users protect their privacy through advertising value chain, where Healthcare identity when setting the identity takes in consideration of users choices, as well as when passing identity on the cookie itself privacy consent strings are checked. The healthcare identity when set is not stored on Deepintent's servers but is stored on users browsers itself. User can still opt out of the ads by https://option.deepintent.com/adchoices. + +## Deepintent DPES ID Registration + +The Deepintent DPES ID is free to use, but requires a simple registration with Deepintent. Please reach to prebid@deepintent.com to get started. +Once publisher registers with deepintents platform for healthcare identity Deepintent provides the Tag code to be placed on the page, this tag code works to capture and store information as per publishers and users agreement. DPES User ID module uses this stored id and passes it on the deepintent prebid adapter. + + +## Deepintent DPES ID Configuration + +First, make sure to add the Deepintent submodule to your Prebid.js package with: + +``` +gulp build --modules=deepintentDpesIdSystem,userId +``` + +The following configuration parameters are available: + +```javascript +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'deepintentId', + storage: { + type: 'cookie', + name: '_dpes_id', + expires: 90 // storage lasts for 90 days, optional if storage type is html5 + } + }], + auctionDelay: 50 // 50ms maximum auction delay, applies to all userId modules + } +}); +``` + +| Param under userSync.userIds[] | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| name | Required | String | The name of this module: `"deepintentId"` | `"deepintentId"` | +| storage | Required | Object | Storage settings for how the User Id module will cache the Deepintent ID locally | | +| storage.type | Required | String | This is where the results of the user ID will be stored. Deepintent`"html5"` or `"cookie"`. | `"html5"` | +| storage.name | Required | String | The name of the local storage where the user ID will be stored. | `"_dpes_id"` | +| storage.expires | Optional | Integer | How long (in days) the user ID information will be stored. Deepintent recommends `90`. | `90` | \ No newline at end of file diff --git a/modules/userId/eids.js b/modules/userId/eids.js index a38417683ba..93d2ead15ea 100644 --- a/modules/userId/eids.js +++ b/modules/userId/eids.js @@ -207,7 +207,10 @@ const USER_IDS_CONFIG = { return data.id; } }, - + 'deepintentId': { + source: 'deepintent.com', + atype: 3 + }, // Admixer Id 'admixerId': { source: 'admixer.net', diff --git a/modules/userId/eids.md b/modules/userId/eids.md index 93783a2db4d..a00aedcc52e 100644 --- a/modules/userId/eids.md +++ b/modules/userId/eids.md @@ -184,6 +184,13 @@ userIdAsEids = [ id: 'some-random-id-value', atype: 3 }] + }, + { + source: 'deepintent.com', + uids: [{ + id: 'some-random-id-value', + atype: 3 + }] } ] ``` diff --git a/modules/userId/userId.md b/modules/userId/userId.md index 79f547b179f..aef50eeccdf 100644 --- a/modules/userId/userId.md +++ b/modules/userId/userId.md @@ -222,6 +222,20 @@ pbjs.setConfig({ name: 'admixerId', expires: 30 } + },{ + name: "deepintentId", + storage: { + type: "html5", + name: "_dpes_id", + expires: 90 + } + },{ + name: "deepintentId", + storage: { + type: "cookie", + name: "_dpes_id", + expires: 90 + } }], syncDelay: 5000 } diff --git a/test/spec/modules/deepintentDpesIdsystem_spec.js b/test/spec/modules/deepintentDpesIdsystem_spec.js new file mode 100644 index 00000000000..7ea5553393c --- /dev/null +++ b/test/spec/modules/deepintentDpesIdsystem_spec.js @@ -0,0 +1,76 @@ +import { expect } from 'chai'; +import find from 'core-js-pure/features/array/find.js'; +import { storage, deepintentDpesSubmodule } from 'modules/deepintentDpesIdSystem.js'; +import { init, requestBidsHook, setSubmoduleRegistry } from 'modules/userId/index.js'; +import { config } from 'src/config.js'; + +const DI_COOKIE_NAME = '_dpes_id'; +const DI_COOKIE_STORED = '{"id":"2cf40748c4f7f60d343336e08f80dc99"}'; +const DI_COOKIE_OBJECT = {id: '2cf40748c4f7f60d343336e08f80dc99'}; + +const cookieConfig = { + name: 'deepintentId', + storage: { + type: 'cookie', + name: '_dpes_id', + expires: 28 + } +}; + +const html5Config = { + name: 'deepintentId', + storage: { + type: 'html5', + name: '_dpes_id', + expires: 28 + } +} + +describe('Deepintent DPES System', () => { + let getDataFromLocalStorageStub, localStorageIsEnabledStub; + let getCookieStub, cookiesAreEnabledStub; + + beforeEach(() => { + getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); + localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); + getCookieStub = sinon.stub(storage, 'getCookie'); + cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled'); + }); + + afterEach(() => { + getDataFromLocalStorageStub.restore(); + localStorageIsEnabledStub.restore(); + getCookieStub.restore(); + cookiesAreEnabledStub.restore(); + }); + + describe('Deepintent Dpes Sytsem: test "getId" method', () => { + it('Wrong config should fail the tests', () => { + // no config + expect(deepintentDpesSubmodule.getId()).to.be.eq(undefined); + expect(deepintentDpesSubmodule.getId({ })).to.be.eq(undefined); + + expect(deepintentDpesSubmodule.getId({params: {}, storage: {}})).to.be.eq(undefined); + expect(deepintentDpesSubmodule.getId({params: {}, storage: {type: 'cookie'}})).to.be.eq(undefined); + expect(deepintentDpesSubmodule.getId({params: {}, storage: {name: '_dpes_id'}})).to.be.eq(undefined); + }); + + it('Get value stored in cookie for getId', () => { + getCookieStub.withArgs(DI_COOKIE_NAME).returns(DI_COOKIE_STORED); + let diId = deepintentDpesSubmodule.getId(cookieConfig, undefined, DI_COOKIE_OBJECT); + expect(diId).to.deep.equal(DI_COOKIE_OBJECT); + }); + + it('provides the stored deepintentId if cookie is absent but present in local storage', () => { + getDataFromLocalStorageStub.withArgs(DI_COOKIE_NAME).returns(DI_COOKIE_STORED); + let idx = deepintentDpesSubmodule.getId(html5Config, undefined, DI_COOKIE_OBJECT); + expect(idx).to.deep.equal(DI_COOKIE_OBJECT); + }); + }); + + describe('Deepintent Dpes System : test "decode" method', () => { + it('Get the correct decoded value for dpes id', () => { + expect(deepintentDpesSubmodule.decode(DI_COOKIE_OBJECT, cookieConfig)).to.deep.equal({'deepintentId': {'id': '2cf40748c4f7f60d343336e08f80dc99'}}); + }); + }); +}); diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index 86a6dff2205..1ccaab2b302 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -189,6 +189,18 @@ describe('eids array generation for known sub-modules', function() { }); }); + it('deepintentId', function() { + const userId = { + deepintentId: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'deepintent.com', + uids: [{id: 'some-random-id-value', atype: 3}] + }); + }); + it('NetId', function() { const userId = { netId: 'some-random-id-value' diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 3c852f3af5c..d61d919a5ef 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -44,6 +44,7 @@ import {tapadIdSubmodule} from 'modules/tapadIdSystem.js'; import {getPrebidInternal} from 'src/utils.js'; import {uid2IdSubmodule} from 'modules/uid2IdSystem.js'; import {admixerIdSubmodule} from 'modules/admixerIdSystem.js'; +import {deepintentDpesSubmodule} from 'modules/deepintentDpesIdSystem.js'; let assert = require('chai').assert; let expect = require('chai').expect; @@ -462,7 +463,7 @@ describe('User ID', function () { }); it('handles config with no usersync object', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule]); init(config); config.setConfig({}); // usersync is undefined, and no logInfo message for 'User ID - usersync config updated' @@ -470,14 +471,14 @@ describe('User ID', function () { }); it('handles config with empty usersync object', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule]); init(config); config.setConfig({userSync: {}}); expect(typeof utils.logInfo.args[0]).to.equal('undefined'); }); it('handles config with usersync and userIds that are empty objs', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule]); init(config); config.setConfig({ userSync: { @@ -488,7 +489,7 @@ describe('User ID', function () { }); it('handles config with usersync and userIds with empty names or that dont match a submodule.name', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule]); init(config); config.setConfig({ userSync: { @@ -505,7 +506,7 @@ describe('User ID', function () { }); it('config with 1 configurations should create 1 submodules', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule]); init(config); config.setConfig(getConfigMock(['unifiedId', 'unifiedid', 'cookie'])); @@ -513,7 +514,7 @@ describe('User ID', function () { }); it('config with 17 configurations should result in 18 submodules add', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule]); init(config); config.setConfig({ userSync: { @@ -565,14 +566,17 @@ describe('User ID', function () { }, { name: 'admixerId', storage: {name: 'admixerId', type: 'cookie'} + }, { + name: 'deepintentId', + storage: {name: 'deepintentId', type: 'cookie'} }] } }); - expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for 18 submodules'); + expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for 19 submodules'); }); it('config syncDelay updates module correctly', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule]); init(config); config.setConfig({ userSync: { @@ -587,7 +591,7 @@ describe('User ID', function () { }); it('config auctionDelay updates module correctly', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule]); init(config); config.setConfig({ userSync: { @@ -602,7 +606,7 @@ describe('User ID', function () { }); it('config auctionDelay defaults to 0 if not a number', function () { - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule]); init(config); config.setConfig({ userSync: { @@ -1702,6 +1706,53 @@ describe('User ID', function () { }, {adUnits}); }); + it('test hook from deepintentId cookies', function (done) { + // simulate existing browser local storage values + coreStorage.setCookie('deepintentId', 'testdeepintentId', (new Date(Date.now() + 5000).toUTCString())); + + setSubmoduleRegistry([deepintentDpesSubmodule]); + init(config); + config.setConfig(getConfigMock(['deepintentId', 'deepintentId', 'cookie'])); + + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.deepintentId'); + expect(bid.userId.deepintentId).to.deep.equal('testdeepintentId'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'deepintent.com', + uids: [{id: 'testdeepintentId', atype: 3}] + }); + }); + }); + coreStorage.setCookie('deepintentId', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); + + it('test hook from deepintentId html5', function (done) { + // simulate existing browser local storage values + localStorage.setItem('deepintentId', 'testdeepintentId'); + localStorage.setItem('deepintentId_exp', ''); + + setSubmoduleRegistry([deepintentDpesSubmodule]); + init(config); + config.setConfig(getConfigMock(['deepintentId', 'deepintentId', 'html5'])); + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.deepintentId'); + expect(bid.userIdAsEids[0]).to.deep.equal({ + source: 'deepintent.com', + uids: [{id: 'testdeepintentId', atype: 3}] + }); + }); + }); + localStorage.removeItem('deepintentId'); + done(); + }, {adUnits}); + }); + it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId, intentIqId, zeotapIdPlus, sharedId, netId, haloId, Criteo, UID 2.0, admixerId and mwOpenLinkId have data to pass', function (done) { coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'testunifiedid'}), (new Date(Date.now() + 5000).toUTCString())); @@ -1720,8 +1771,9 @@ describe('User ID', function () { coreStorage.setCookie('mwol', JSON.stringify({eid: 'XX-YY-ZZ-123'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('uid2id', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('admixerId', 'testadmixerId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('deepintentId', 'testdeepintentId', (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule]); init(config); config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'], ['unifiedId', 'unifiedid', 'cookie'], @@ -1737,7 +1789,8 @@ describe('User ID', function () { ['mwOpenLinkId', 'mwol', 'cookie'], ['tapadId', 'tapad_id', 'cookie'], ['uid2', 'uid2id', 'cookie'], - ['admixerId', 'admixerId', 'cookie'])); + ['admixerId', 'admixerId', 'cookie'], + ['deepintentId', 'deepintentId', 'cookie'])); requestBidsHook(function () { adUnits.forEach(unit => { @@ -1787,7 +1840,11 @@ describe('User ID', function () { expect(bid).to.have.deep.nested.property('userId.admixerId'); expect(bid.userId.admixerId).to.equal('testadmixerId'); - expect(bid.userIdAsEids.length).to.equal(14); + // also check that deepintentId was copied to bid + expect(bid).to.have.deep.nested.property('userId.deepintentId'); + expect(bid.userId.deepintentId).to.equal('testdeepintentId'); + + expect(bid.userIdAsEids.length).to.equal(15); }); }); coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); @@ -1804,6 +1861,7 @@ describe('User ID', function () { coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('uid2id', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('deepintentId', EXPIRED_COOKIE_DATE); done(); }, {adUnits}); }); @@ -1826,6 +1884,7 @@ describe('User ID', function () { coreStorage.setCookie('mwol', JSON.stringify({eid: 'XX-YY-ZZ-123'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('uid2id', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('admixerId', 'testadmixerId', (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('deepintentId', 'testdeepintentId', (new Date(Date.now() + 5000).toUTCString())); setSubmoduleRegistry([]); @@ -1849,6 +1908,7 @@ describe('User ID', function () { attachIdSystem(tapadIdSubmodule); attachIdSystem(uid2IdSubmodule); attachIdSystem(admixerIdSubmodule); + attachIdSystem(deepintentDpesSubmodule); config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'], ['unifiedId', 'unifiedid', 'cookie'], @@ -1864,7 +1924,8 @@ describe('User ID', function () { ['mwOpenLinkId', 'mwol', 'cookie'], ['tapadId', 'tapad_id', 'cookie'], ['uid2', 'uid2id', 'cookie'], - ['admixerId', 'admixerId', 'cookie'])); + ['admixerId', 'admixerId', 'cookie'], + ['deepintentId', 'deepintentId', 'cookie'])); requestBidsHook(function () { adUnits.forEach(unit => { @@ -1917,8 +1978,11 @@ describe('User ID', function () { // also check that admixerId id data was copied to bid expect(bid).to.have.deep.nested.property('userId.admixerId'); expect(bid.userId.admixerId).to.equal('testadmixerId'); + // also check that deepintentId was copied to bid + expect(bid).to.have.deep.nested.property('userId.deepintentId'); + expect(bid.userId.deepintentId).to.equal('testdeepintentId'); - expect(bid.userIdAsEids.length).to.equal(14); + expect(bid.userIdAsEids.length).to.equal(15); }); }); coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); @@ -1935,6 +1999,7 @@ describe('User ID', function () { coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('uid2id', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('deepintentId', '', EXPIRED_COOKIE_DATE); done(); }, {adUnits}); }); @@ -2192,10 +2257,11 @@ describe('User ID', function () { coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('haloId', JSON.stringify({'haloId': 'testHaloId'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('admixerId', 'testadmixerId', new Date(Date.now() + 5000).toUTCString()); + coreStorage.setCookie('deepintentId', 'testdeepintentId', new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('MOCKID', JSON.stringify({'MOCKID': '123456778'}), new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('__uid2_advertising_token', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); - setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, uid2IdSubmodule, admixerIdSubmodule]); + setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule]); init(config); config.setConfig({ @@ -2227,6 +2293,8 @@ describe('User ID', function () { name: 'mockId', storage: {name: 'MOCKID', type: 'cookie'} }, { name: 'uid2' + }, { + name: 'deepintentId', storage: {name: 'deepintentId', type: 'cookie'} }] } }); @@ -2291,7 +2359,12 @@ describe('User ID', function () { // also check that admixerId id data was copied to bid expect(bid).to.have.deep.nested.property('userId.admixerId'); expect(bid.userId.admixerId).to.equal('testadmixerId'); - expect(bid.userIdAsEids.length).to.equal(12); + + // also check that deepintentId was copied to bid + expect(bid).to.have.deep.nested.property('userId.deepintentId'); + expect(bid.userId.deepintentId).to.equal('testdeepintentId'); + + expect(bid.userIdAsEids.length).to.equal(13); }); }); coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); @@ -2305,6 +2378,7 @@ describe('User ID', function () { coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('haloId', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('deepintentId', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('MOCKID', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); done(); From bea2261291ffbb4b89100174975f100ad373440a Mon Sep 17 00:00:00 2001 From: Nick Peceniak Date: Thu, 15 Apr 2021 06:00:55 -0600 Subject: [PATCH 045/303] Update spotxBidAdpter renderer url to ensure onLoad is always called. (#6592) Co-authored-by: Nick Peceniak --- modules/spotxBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/spotxBidAdapter.js b/modules/spotxBidAdapter.js index 05e4e0ba1ef..4c9b50ca9db 100644 --- a/modules/spotxBidAdapter.js +++ b/modules/spotxBidAdapter.js @@ -365,7 +365,7 @@ export const spec = { const playersize = utils.deepAccess(currentBidRequest, 'mediaTypes.video.playerSize'); const renderer = Renderer.install({ id: 0, - url: '//', + url: '/', config: { adText: 'SpotX Outstream Video Ad via Prebid.js', player_width: playersize[0][0], From d18c6a874bf1465cf9f8427f65a2fa21c05a2454 Mon Sep 17 00:00:00 2001 From: Michael Kuryshev Date: Thu, 15 Apr 2021 17:00:24 +0300 Subject: [PATCH 046/303] VIS.X: add onSetTargeting, onBidWon & onTimeout handlers (#6532) --- modules/visxBidAdapter.js | 20 +++++++++++++++-- test/spec/modules/visxBidAdapter_spec.js | 28 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/modules/visxBidAdapter.js b/modules/visxBidAdapter.js index 725482d07c3..a5829b9cd9c 100644 --- a/modules/visxBidAdapter.js +++ b/modules/visxBidAdapter.js @@ -2,10 +2,14 @@ import * as utils from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; const BIDDER_CODE = 'visx'; -const ENDPOINT_URL = 'https://t.visx.net/hb'; +const BASE_URL = 'https://t.visx.net'; +const ENDPOINT_URL = BASE_URL + '/hb'; const TIME_TO_LIVE = 360; const DEFAULT_CUR = 'EUR'; -const ADAPTER_SYNC_URL = 'https://t.visx.net/push_sync'; +const ADAPTER_SYNC_URL = BASE_URL + '/push_sync'; +const TRACK_WIN_URL = BASE_URL + '/track/win'; +const TRACK_PENDING_URL = BASE_URL + '/track/pending'; +const TRACK_TIMEOUT_URL = BASE_URL + '/track/bid_timeout'; const LOG_ERROR_MESS = { noAuid: 'Bid from response has no auid parameter - ', noAdm: 'Bid from response has no adm parameter - ', @@ -170,6 +174,18 @@ export const spec = { url: ADAPTER_SYNC_URL + (query.length ? '?' + query.join('&') : '') }]; } + }, + onSetTargeting: function(bid) { + // Call '/track/pending' with the corresponding bid.requestId + utils.triggerPixel(TRACK_PENDING_URL + '?requestId=' + bid.requestId); + }, + onBidWon: function(bid) { + // Call '/track/win' with the corresponding bid.requestId + utils.triggerPixel(TRACK_WIN_URL + '?requestId=' + bid.requestId); + }, + onTimeout: function(timeoutData) { + // Call '/track/bid_timeout' with timeout data + utils.triggerPixel(TRACK_TIMEOUT_URL + '?data=' + JSON.stringify(timeoutData)); } }; diff --git a/test/spec/modules/visxBidAdapter_spec.js b/test/spec/modules/visxBidAdapter_spec.js index a06f530e145..db885ad314e 100755 --- a/test/spec/modules/visxBidAdapter_spec.js +++ b/test/spec/modules/visxBidAdapter_spec.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { spec } from 'modules/visxBidAdapter.js'; import { config } from 'src/config.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; describe('VisxAdapter', function () { const adapter = newBidder(spec); @@ -656,4 +657,31 @@ describe('VisxAdapter', function () { expect(result).to.deep.equal(expectedResponse); }); }); + describe('check trackers', function () { + beforeEach(function () { + sinon.stub(utils, 'triggerPixel'); + }); + + afterEach(function () { + utils.triggerPixel.restore(); + }); + + it('onSetTargeting', function () { + const requestId = '111'; + spec.onSetTargeting({ requestId }); + expect(utils.triggerPixel.calledOnceWith('https://t.visx.net/track/pending?requestId=' + requestId)).to.equal(true); + }); + + it('onBidWon', function () { + const requestId = '111'; + spec.onBidWon({ requestId }); + expect(utils.triggerPixel.calledOnceWith('https://t.visx.net/track/win?requestId=' + requestId)).to.equal(true); + }); + + it('onTimeout', function () { + const data = { timeout: 3000, bidId: '23423', params: { uid: 1 } }; + spec.onTimeout(data); + expect(utils.triggerPixel.calledOnceWith('https://t.visx.net/track/bid_timeout?data=' + JSON.stringify(data))).to.equal(true); + }); + }); }); From 6ff2cf7792beaf8b1c2577ed9b9360beb35054b0 Mon Sep 17 00:00:00 2001 From: Kajan Umakanthan Date: Thu, 15 Apr 2021 08:05:40 -0700 Subject: [PATCH 047/303] Index Exchange Bid Adapter: resolve negative size bug (#6582) --- modules/ixBidAdapter.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/ixBidAdapter.js b/modules/ixBidAdapter.js index 7b972aa37e6..0f7f967ef6b 100644 --- a/modules/ixBidAdapter.js +++ b/modules/ixBidAdapter.js @@ -492,7 +492,11 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { msd = impressions[transactionIds[i]].missingCount; } - trimImpressions(impressions[transactionIds[i]], MAX_REQ_SIZE - BASE_REQ_SIZE); + if (BASE_REQ_SIZE < MAX_REQ_SIZE) { + trimImpressions(impressions[transactionIds[i]], MAX_REQ_SIZE - BASE_REQ_SIZE); + } else { + utils.logError('ix bidder: Base request size has exceeded maximum request size.'); + } if (impressions[transactionIds[i]].hasOwnProperty('missingImps')) { msi = impressions[transactionIds[i]].missingImps.length; From 170c82d1ef3aadbf9ff3ffcde9594abeaf708ee5 Mon Sep 17 00:00:00 2001 From: Skylinar <53079123+Skylinar@users.noreply.github.com> Date: Thu, 15 Apr 2021 17:26:26 +0200 Subject: [PATCH 048/303] smartx Bid Adapter: Outstream render bugfix numeric elementId (#6588) --- modules/smartxBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/smartxBidAdapter.js b/modules/smartxBidAdapter.js index b95b31934a2..6b34e499a99 100644 --- a/modules/smartxBidAdapter.js +++ b/modules/smartxBidAdapter.js @@ -379,7 +379,7 @@ function createOutstreamScript(bid) { smartPlayObj.adResponse = bid.vastContent; - const divID = '#' + elementId; + const divID = '[id="' + elementId + '"]'; var script = document.createElement('script'); script.src = 'https://dco.smartclip.net/?plc=7777778'; script.type = 'text/javascript'; From de4098269bb2b15e285fb1b7c9b1b383d2cd19f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20DEYM=C3=88S?= <47388595+MaxSmileWanted@users.noreply.github.com> Date: Fri, 16 Apr 2021 03:46:50 +0200 Subject: [PATCH 049/303] Update cookie sync call (#6567) --- modules/smilewantedBidAdapter.js | 31 ++++++++++++++----- .../modules/smilewantedBidAdapter_spec.js | 10 +++--- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/modules/smilewantedBidAdapter.js b/modules/smilewantedBidAdapter.js index f965310abdd..fb05298a230 100644 --- a/modules/smilewantedBidAdapter.js +++ b/modules/smilewantedBidAdapter.js @@ -108,16 +108,31 @@ export const spec = { * @param {*} serverResponses A successful response from the server. * @return {Syncs[]} An array of syncs that should be executed. */ - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = [] - if (syncOptions.iframeEnabled && serverResponses.length > 0) { - if (serverResponses[0].body.cSyncUrl === 'https://csync.smilewanted.com') { - syncs.push({ - type: 'iframe', - url: serverResponses[0].body.cSyncUrl - }); + getUserSyncs: function(syncOptions, responses, gdprConsent, uspConsent) { + let params = ''; + + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + // add 'gdpr' only if 'gdprApplies' is defined + if (typeof gdprConsent.gdprApplies === 'boolean') { + params += `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + params += `?gdpr_consent=${gdprConsent.consentString}`; } } + + if (uspConsent) { + params += `${params ? '&' : '?'}us_privacy=${encodeURIComponent(uspConsent)}`; + } + + const syncs = [] + + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: 'https://csync.smilewanted.com' + params + }); + } + return syncs; } } diff --git a/test/spec/modules/smilewantedBidAdapter_spec.js b/test/spec/modules/smilewantedBidAdapter_spec.js index 0ac242ce0e1..d0d8b65a42f 100644 --- a/test/spec/modules/smilewantedBidAdapter_spec.js +++ b/test/spec/modules/smilewantedBidAdapter_spec.js @@ -305,12 +305,12 @@ describe('smilewantedBidAdapterTests', function () { }); it('SmileWanted - Verify user sync', function () { - var syncs = spec.getUserSyncs({ - iframeEnabled: true - }, [BID_RESPONSE_DISPLAY]); + var syncs = spec.getUserSyncs({iframeEnabled: true}, {}, { + consentString: 'foo' + }, '1NYN'); expect(syncs).to.have.lengthOf(1); expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.equal('https://csync.smilewanted.com'); + expect(syncs[0].url).to.equal('https://csync.smilewanted.com?gdpr_consent=foo&us_privacy=1NYN'); syncs = spec.getUserSyncs({ iframeEnabled: false @@ -320,6 +320,6 @@ describe('smilewantedBidAdapterTests', function () { syncs = spec.getUserSyncs({ iframeEnabled: true }, []); - expect(syncs).to.have.lengthOf(0); + expect(syncs).to.have.lengthOf(1); }); }); From 8745d462ad2e8c95e2a90fd80926c3a7dfcdcdf6 Mon Sep 17 00:00:00 2001 From: Nick Peceniak Date: Fri, 16 Apr 2021 03:52:49 -0600 Subject: [PATCH 050/303] Add videoCacheKey back to bid response when using spotx as cache server (#6605) Co-authored-by: Nick Peceniak --- modules/spotxBidAdapter.js | 1 + test/spec/modules/spotxBidAdapter_spec.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/modules/spotxBidAdapter.js b/modules/spotxBidAdapter.js index 4c9b50ca9db..f3728058d18 100644 --- a/modules/spotxBidAdapter.js +++ b/modules/spotxBidAdapter.js @@ -352,6 +352,7 @@ export const spec = { } else { bid.cache_key = spotxBid.ext.cache_key; bid.vastUrl = 'https://search.spotxchange.com/ad/vast.html?key=' + spotxBid.ext.cache_key + bid.videoCacheKey = spotxBid.ext.cache_key; } bid.meta = bid.meta || {}; diff --git a/test/spec/modules/spotxBidAdapter_spec.js b/test/spec/modules/spotxBidAdapter_spec.js index 873914441aa..cc94e37fdaa 100644 --- a/test/spec/modules/spotxBidAdapter_spec.js +++ b/test/spec/modules/spotxBidAdapter_spec.js @@ -495,6 +495,7 @@ describe('the spotx adapter', function () { expect(responses[0].requestId).to.equal(123); expect(responses[0].ttl).to.equal(360); expect(responses[0].vastUrl).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache123'); + expect(responses[0].videoCacheKey).to.equal('cache123'); expect(responses[0].width).to.equal(400); expect(responses[1].cache_key).to.equal('cache124'); expect(responses[1].channel_id).to.equal(12345); @@ -508,6 +509,7 @@ describe('the spotx adapter', function () { expect(responses[1].requestId).to.equal(124); expect(responses[1].ttl).to.equal(360); expect(responses[1].vastUrl).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache124'); + expect(responses[1].videoCacheKey).to.equal('cache124'); expect(responses[1].width).to.equal(200); }); }); From f65fe744bc4b80990d83e699e00b92436ce92f3e Mon Sep 17 00:00:00 2001 From: jsfledd Date: Fri, 16 Apr 2021 07:48:09 -0700 Subject: [PATCH 051/303] Nativo Bid Adapter: add new bid adapter (#6542) * Initial nativoBidAdapter document creation (js, md and spec) * Fulling working prebid using nativoBidAdapter. Support for GDPR and CCPA in user syncs. * Added defult size settings based on the largest ad unit. Added response body validation. Added consent to request url qs params. * Changed bidder endpoint url * Changed double quotes to single quotes. * Reverted package-json.lock to remove modifications from PR * Added optional bidder param 'url' so the ad server can force- match an existing placement * Lint fix. Added space after if. --- modules/nativoBidAdapter.js | 307 +++++++++++++++++++++ modules/nativoBidAdapter.md | 40 +++ test/spec/modules/nativoBidAdapter_spec.js | 227 +++++++++++++++ 3 files changed, 574 insertions(+) create mode 100644 modules/nativoBidAdapter.js create mode 100644 modules/nativoBidAdapter.md create mode 100644 test/spec/modules/nativoBidAdapter_spec.js diff --git a/modules/nativoBidAdapter.js b/modules/nativoBidAdapter.js new file mode 100644 index 00000000000..d396bd4d495 --- /dev/null +++ b/modules/nativoBidAdapter.js @@ -0,0 +1,307 @@ +import * as utils from '../src/utils.js' +import { registerBidder } from '../src/adapters/bidderFactory.js' +import { BANNER } from '../src/mediaTypes.js' +// import { config } from 'src/config' + +const BIDDER_CODE = 'nativo' +const BIDDER_ENDPOINT = 'https://exchange.postrelease.com/prebid' + +const TIME_TO_LIVE = 360 + +const SUPPORTED_AD_TYPES = [BANNER] + +const bidRequestMap = {} + +// Prebid adapter referrence doc: https://docs.prebid.org/dev-docs/bidder-adaptor.html + +export const spec = { + code: BIDDER_CODE, + aliases: ['ntv'], // short code + supportedMediaTypes: SUPPORTED_AD_TYPES, + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + return bid.params && !!bid.params.placementId + }, + + /** + * Called when the page asks Prebid.js for bids + * Make a server request from the list of BidRequests + * + * @param {Array} validBidRequests - An array of bidRequest objects, one for each AdUnit that your module is involved in. This array has been processed for special features like sizeConfig, so it’s the list that you should be looping through + * @param {Object} bidderRequest - The master bidRequest object. This object is useful because it carries a couple of bid parameters that are global to all the bids. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + const placementIds = [] + const placmentBidIdMap = {} + let placementId, pageUrl + validBidRequests.forEach((request) => { + pageUrl = pageUrl || request.params.url // Use the first url value found + placementId = request.params.placementId + placementIds.push(placementId) + placmentBidIdMap[placementId] = { + bidId: request.bidId, + size: getLargestSize(request.sizes), + } + }) + bidRequestMap[bidderRequest.bidderRequestId] = placmentBidIdMap + + if (!pageUrl) pageUrl = bidderRequest.refererInfo.referer + + let params = [ + { key: 'ntv_ptd', value: placementIds.toString() }, + { key: 'ntv_pb_rid', value: bidderRequest.bidderRequestId }, + { + key: 'ntv_url', + value: encodeURIComponent(pageUrl), + }, + ] + + if (bidderRequest.gdprConsent) { + // Put on the beginning of the qs param array + params.unshift({ + key: 'ntv_gdpr_consent', + value: bidderRequest.gdprConsent.consentString, + }) + } + + if (bidderRequest.uspConsent) { + // Put on the beginning of the qs param array + params.unshift({ key: 'us_privacy', value: bidderRequest.uspConsent }) + } + + let serverRequest = { + method: 'GET', + url: BIDDER_ENDPOINT + arrayToQS(params), + } + + return serverRequest + }, + + /** + * Will be called when the browser has received the response from your server. + * The function will parse the response and create a bidResponse object containing one or more bids. + * The adapter should indicate no valid bids by returning an empty array. + * + * @param {Object} response - Data returned from the bidding server request endpoint + * @param {Object} request - The request object used to call the server request endpoint + * @return {Array} An array of bids which were nested inside the server. + */ + interpretResponse: function (response, request) { + // If the bid response was empty, return [] + if (!response || !response.body || utils.isEmpty(response.body)) return [] + + try { + const body = + typeof response.body === 'string' + ? JSON.parse(response.body) + : response.body + + const bidResponses = [] + const seatbids = body.seatbid + + // Step through and grab pertinent data + let bidResponse, adUnit + seatbids.forEach((seatbid) => { + seatbid.bid.forEach((bid) => { + adUnit = this.getRequestId(body.id, bid.impid) + bidResponse = { + requestId: adUnit.bidId, + cpm: bid.price, + currency: body.cur, + width: bid.w || adUnit.size[0], + height: bid.h || adUnit.size[1], + creativeId: bid.crid, + dealId: bid.id, + netRevenue: true, + ttl: bid.ttl || TIME_TO_LIVE, + ad: bid.adm, + meta: { + advertiserDomains: bid.adomain, + }, + } + + bidResponses.push(bidResponse) + }) + }) + + // Don't need the map anymore as it was unique for one request/response + delete bidRequestMap[body.id] + + return bidResponses + } catch (error) { + // If there is an error, return [] + return [] + } + }, + + /** + * All user ID sync activity should be done using the getUserSyncs callback of the BaseAdapter model. + * Given an array of all the responses from the server, getUserSyncs is used to determine which user syncs should occur. + * The order of syncs in the serverResponses array matters. The most important ones should come first, since publishers may limit how many are dropped on their page. + * @param {Object} syncOptions - Which user syncs are allowed? + * @param {Array} serverResponses - Array of server's responses + * @param {Object} gdprConsent - GDPR consent data + * @param {Object} uspConsent - USP consent data + * @return {Array} The user syncs which should be dropped. + */ + getUserSyncs: function ( + syncOptions, + serverResponses, + gdprConsent, + uspConsent + ) { + // Generate consent qs string + let params = '' + // GDPR + if (gdprConsent) { + params = appendQSParamString( + params, + 'gdpr', + gdprConsent.gdprApplies ? 1 : 0 + ) + params = appendQSParamString( + params, + 'gdpr_consent', + encodeURIComponent(gdprConsent.consentString || '') + ) + } + // CCPA + if (uspConsent) { + params = appendQSParamString( + params, + 'us_privacy', + encodeURIComponent(uspConsent.uspConsent) + ) + } + + // Get sync urls from the respnse and inject cinbsent params + const types = { + iframe: syncOptions.iframeEnabled, + image: syncOptions.pixelEnabled, + } + const syncs = [] + + let body + serverResponses.forEach((response) => { + // If the bid response was empty, return [] + if (!response || !response.body || utils.isEmpty(response.body)) { + return syncs + } + + body = + typeof response.body === 'string' + ? JSON.parse(response.body) + : response.body + + // Make sure we have valid content + if (!body || !body.seatbid || body.seatbid.length === 0) return + + body.seatbid.forEach((seatbid) => { + // Grab the syncs for each seatbid + seatbid.syncUrls.forEach((sync) => { + if (types[sync.type]) { + if (sync.url.trim() !== '') { + syncs.push({ + type: sync.type, + url: sync.url.replace('{GDPR_params}', params), + }) + } + } + }) + }) + }) + + return syncs + }, + + /** + * Will be called when an adpater timed out for an auction. + * Adapter can fire a ajax or pixel call to register a timeout at thier end. + * @param {Object} timeoutData - Timeout specific data + */ + onTimeout: function (timeoutData) {}, + + /** + * Will be called when a bid from the adapter won the auction. + * @param {Object} bid - The bid that won the auction + */ + onBidWon: function (bid) {}, + + /** + * Will be called when the adserver targeting has been set for a bid from the adapter. + * @param {Object} bidder - The bid of which the targeting has been set + */ + onSetTargeting: function (bid) {}, + + /** + * Maps Prebid's bidId to Nativo's placementId values per unique bidderRequestId + * @param {String} bidderRequestId - The unique ID value associated with the bidderRequest + * @param {String} placementId - The placement ID value from Nativo + * @returns {String} - The bidId value associated with the corresponding placementId + */ + getRequestId: function (bidderRequestId, placementId) { + return ( + bidRequestMap[bidderRequestId] && + bidRequestMap[bidderRequestId][placementId] + ) + }, +} +registerBidder(spec) + +// Utils +/** + * Append QS param to existing string + * @param {String} str - String to append to + * @param {String} key - Key to append + * @param {String} value - Value to append + * @returns + */ +function appendQSParamString(str, key, value) { + return str + `${str.length ? '&' : ''}${key}=${value}` +} + +/** + * Convert an object to query string parameters + * @param {Object} obj - Object to convert + * @returns + */ +function arrayToQS(arr) { + return ( + '?' + + arr.reduce((value, obj) => { + return appendQSParamString(value, obj.key, obj.value) + }, '') + ) +} + +/** + * Get the largest size array + * @param {Array} sizes - Array of size arrays + * @returns Size array with the largest area + */ +function getLargestSize(sizes, method = area) { + if (!sizes || sizes.length === 0) return [] + if (sizes.length === 1) return sizes[0] + + return sizes.reduce((prev, current) => { + if (method(current) > method(prev)) { + return current + } else { + return prev + } + }) +} + +/** + * Calculate the area + * @param {Array} size - [width, height] + * @returns The calculated area + */ +const area = (size) => size[0] * size[1] diff --git a/modules/nativoBidAdapter.md b/modules/nativoBidAdapter.md new file mode 100644 index 00000000000..ec0980aae50 --- /dev/null +++ b/modules/nativoBidAdapter.md @@ -0,0 +1,40 @@ +# Overview + +``` +Module Name: Nativo Bid Adapter +Module Type: Bidder Adapter +Maintainer: prebiddev@nativo.com +``` + +# Description + +Module that connects to Nativo's demand sources + +# Dev + +gulp serve --modules=nativoBidAdapter + +# Test Parameters + +``` +var adUnits = [ + { + code: 'div-gpt-ad-1460505748561-0', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]], + } + }, + // Replace this object to test a new Adapter! + bids: [{ + bidder: 'nativo', + params: { + placementId: 1125609, + url: 'https://test-sites.internal.nativo.net/testing/prebid_adpater.html' + } + }] + + } + ]; + +``` diff --git a/test/spec/modules/nativoBidAdapter_spec.js b/test/spec/modules/nativoBidAdapter_spec.js new file mode 100644 index 00000000000..e1132bf1b74 --- /dev/null +++ b/test/spec/modules/nativoBidAdapter_spec.js @@ -0,0 +1,227 @@ +import { expect } from 'chai' +import { spec } from 'modules/nativoBidAdapter.js' +// import { newBidder } from 'src/adapters/bidderFactory.js' +// import * as bidderFactory from 'src/adapters/bidderFactory.js' +// import { deepClone } from 'src/utils.js' +// import { config } from 'src/config.js' + +describe('nativoBidAdapterTests', function () { + describe('isBidRequestValid', function () { + let bid = { + bidder: 'nativo', + params: { + placementId: '10433394', + }, + adUnitCode: 'adunit-code', + sizes: [ + [300, 250], + [300, 600], + ], + bidId: '27b02036ccfa6e', + bidderRequestId: '1372cd8bd8d6a8', + auctionId: 'cfc467e4-2707-48da-becb-bcaab0b2c114', + } + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true) + }) + + it('should return false when required params are not passed', function () { + let bid2 = Object.assign({}, bid) + delete bid2.params + bid2.params = {} + expect(spec.isBidRequestValid(bid2)).to.equal(false) + }) + }) + + describe('buildRequests', function () { + let bidRequests = [ + { + bidder: 'nativo', + params: { + placementId: '10433394', + }, + adUnitCode: 'adunit-code', + sizes: [ + [300, 250], + [300, 600], + ], + bidId: '27b02036ccfa6e', + bidderRequestId: '1372cd8bd8d6a8', + auctionId: 'cfc467e4-2707-48da-becb-bcaab0b2c114', + transactionId: '3b36e7e0-0c3e-4006-a279-a741239154ff', + }, + ] + + it('url should contain query string parameters', function () { + const request = spec.buildRequests(bidRequests, { + bidderRequestId: 123456, + refererInfo: { + referer: 'https://www.test.com', + }, + }) + + expect(request.url).to.exist + expect(request.url).to.be.a('string') + + expect(request.url).to.include('?') + expect(request.url).to.include('ntv_url') + expect(request.url).to.include('ntv_ptd') + }) + }) +}) + +describe('interpretResponse', function () { + let response = { + id: '126456', + seatbid: [ + { + seat: 'seat_0', + bid: [ + { + id: 'f70362ac-f3cf-4225-82a5-948b690927a6', + impid: '1', + price: 3.569, + adm: '', + h: 300, + w: 250, + cat: [], + adomain: ['test.com'], + crid: '1060_72_6760217', + }, + ], + }, + ], + cur: 'USD', + } + + it('should get correct bid response', function () { + let expectedResponse = [ + { + requestId: '1F254428-AB11-4D5E-9887-567B3F952CA5', + cpm: 3.569, + currency: 'USD', + width: 300, + height: 250, + creativeId: '1060_72_6760217', + dealId: 'f70362ac-f3cf-4225-82a5-948b690927a6', + netRevenue: true, + ttl: 360, + ad: '', + meta: { + advertiserDomains: ['test.com'], + }, + }, + ] + + let bidderRequest = { + id: 123456, + bids: [ + { + params: { + placementId: 1 + } + }, + ], + } + + // mock + spec.getRequestId = () => 123456 + + let result = spec.interpretResponse({ body: response }, { bidderRequest }) + expect(Object.keys(result[0])).to.have.deep.members( + Object.keys(expectedResponse[0]) + ) + }) + + it('handles nobid responses', function () { + let response = {} + let bidderRequest + + let result = spec.interpretResponse({ body: response }, { bidderRequest }) + expect(result.length).to.equal(0) + }) +}) + +describe('getUserSyncs', function () { + const response = [ + { + body: { + cur: 'USD', + id: 'a136dbd8-4387-48bf-b8e4-ff9c1d6056ee', + seatbid: [ + { + bid: [{}], + seat: 'seat_0', + syncUrls: [ + { + type: 'image', + url: 'pixel-tracker-test-url/?{GDPR_params}', + }, + { + type: 'iframe', + url: 'iframe-tracker-test-url/?{GDPR_params}', + }, + ], + }, + ], + }, + }, + ] + + const gdprConsent = { + gdprApplies: true, + consentString: '111111' + } + + const uspConsent = { + uspConsent: '1YYY' + } + + it('Returns empty array if no supported user syncs', function () { + let userSync = spec.getUserSyncs( + { + iframeEnabled: false, + pixelEnabled: false, + }, + response, + gdprConsent, + uspConsent + ) + expect(userSync).to.be.an('array').with.lengthOf(0) + }) + + it('Returns valid iframe user sync', function () { + let userSync = spec.getUserSyncs( + { + iframeEnabled: true, + pixelEnabled: false, + }, + response, + gdprConsent, + uspConsent + ) + 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.contain('gdpr=1&gdpr_consent=111111&us_privacy=1YYY') + }) + + it('Returns valid URL and type', function () { + let userSync = spec.getUserSyncs( + { + iframeEnabled: false, + pixelEnabled: true, + }, + response, + gdprConsent, + uspConsent + ) + 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('image') + expect(userSync[0].url).to.contain('gdpr=1&gdpr_consent=111111&us_privacy=1YYY') + }) +}) From 1b28481afff549fbe11e08b138ae58644ffe5d6d Mon Sep 17 00:00:00 2001 From: Nick Peceniak Date: Fri, 16 Apr 2021 09:58:50 -0600 Subject: [PATCH 052/303] Spotx Bid Adapter: Update endpoint to indicate request is from Prebid (#6593) --- modules/spotxBidAdapter.js | 3 ++- test/spec/modules/spotxBidAdapter_spec.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/spotxBidAdapter.js b/modules/spotxBidAdapter.js index f3728058d18..b60d25db4d6 100644 --- a/modules/spotxBidAdapter.js +++ b/modules/spotxBidAdapter.js @@ -291,9 +291,10 @@ export const spec = { if (!utils.isEmpty(userExt)) { requestPayload.user = { ext: userExt }; } + const urlQueryParams = 'src_sys=prebid' return { method: 'POST', - url: URL + channelId, + url: URL + channelId + '?' + urlQueryParams, data: requestPayload, bidRequest: bidderRequest }; diff --git a/test/spec/modules/spotxBidAdapter_spec.js b/test/spec/modules/spotxBidAdapter_spec.js index cc94e37fdaa..5d7b32eaeeb 100644 --- a/test/spec/modules/spotxBidAdapter_spec.js +++ b/test/spec/modules/spotxBidAdapter_spec.js @@ -102,7 +102,7 @@ describe('the spotx adapter', function () { it('should build a very basic request', function() { var request = spec.buildRequests([bid], bidRequestObj)[0]; expect(request.method).to.equal('POST'); - expect(request.url).to.equal('https://search.spotxchange.com/openrtb/2.3/dados/12345'); + expect(request.url).to.equal('https://search.spotxchange.com/openrtb/2.3/dados/12345?src_sys=prebid'); expect(request.bidRequest).to.equal(bidRequestObj); expect(request.data.id).to.equal(12345); expect(request.data.ext.wrap_response).to.equal(1); From dd64734e46b5f9907cd14a8e2b287ac1cfe12aad Mon Sep 17 00:00:00 2001 From: Mathieu Pheulpin Date: Fri, 16 Apr 2021 13:16:53 -0700 Subject: [PATCH 053/303] Sharethrough Bid Adapter: add support for COPPA (#6602) * Pass COPPA flag to Ad Server [#177598971] * Send true instead of 1 * Upgrade adapter version number --- modules/sharethroughBidAdapter.js | 7 +++++- .../modules/sharethroughBidAdapter_spec.js | 24 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index 24be8673615..eef18288b17 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -1,7 +1,8 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; -const VERSION = '3.3.1'; +const VERSION = '3.3.2'; const BIDDER_CODE = 'sharethrough'; const STR_ENDPOINT = 'https://btlr.sharethrough.com/WYu2BXv1/v1'; const DEFAULT_SIZE = [1, 1]; @@ -48,6 +49,10 @@ export const sharethroughAdapterSpec = { query.us_privacy = bidderRequest.uspConsent } + if (config.getConfig('coppa') === true) { + query.coppa = true + } + if (bidRequest.schain) { query.schain = JSON.stringify(bidRequest.schain); } diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index b3451a09dde..57306580ecc 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { sharethroughAdapterSpec, sharethroughInternal } from 'modules/sharethroughBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; import * as utils from '../../../src/utils.js'; +import { config } from 'src/config'; const spec = newBidder(sharethroughAdapterSpec).getSpec(); const bidRequests = [ @@ -441,6 +442,29 @@ describe('sharethrough adapter spec', function() { const builtBidRequest = spec.buildRequests([bidRequest])[0]; expect(builtBidRequest.data).to.not.include.any.keys('bidfloor'); }); + + describe('coppa', function() { + it('should add coppa to request if enabled', function() { + config.setConfig({coppa: true}); + const bidRequest = Object.assign({}, bidRequests[0]); + const builtBidRequest = spec.buildRequests([bidRequest])[0]; + expect(builtBidRequest.data.coppa).to.eq(true); + }); + + it('should not add coppa to request if disabled', function() { + config.setConfig({coppa: false}); + const bidRequest = Object.assign({}, bidRequests[0]); + const builtBidRequest = spec.buildRequests([bidRequest])[0]; + expect(builtBidRequest.data.coppa).to.be.undefined; + }); + + it('should not add coppa to request if unknown value', function() { + config.setConfig({coppa: 'something'}); + const bidRequest = Object.assign({}, bidRequests[0]); + const builtBidRequest = spec.buildRequests([bidRequest])[0]; + expect(builtBidRequest.data.coppa).to.be.undefined; + }); + }); }); describe('.interpretResponse', function() { From ef00f9b681b7b2f4d507fd6e359d01a726facbbc Mon Sep 17 00:00:00 2001 From: prebidtappx <77485538+prebidtappx@users.noreply.github.com> Date: Fri, 16 Apr 2021 22:27:47 +0200 Subject: [PATCH 054/303] tappx Bid Adapter: add video instream support and update testing (#6580) * tappxBidAdapter : update tests adding video * tappxBidAdapter : add video instream * tappxBidAdapter : update tappx md doc * tappxBidAdapter: Fix Newline required eol-last * tappxBidAdapter: update tests User sync and video reqs * tappxBidAdapter: Extra space after fix Co-authored-by: marc_tappx --- modules/tappxBidAdapter.js | 81 +++++++++++++---- modules/tappxBidAdapter.md | 33 +++++++ test/spec/modules/tappxBidAdapter_spec.js | 102 ++++++++++++++++++++-- 3 files changed, 195 insertions(+), 21 deletions(-) diff --git a/modules/tappxBidAdapter.js b/modules/tappxBidAdapter.js index 3677c3ce4c9..1228fbafaad 100644 --- a/modules/tappxBidAdapter.js +++ b/modules/tappxBidAdapter.js @@ -2,20 +2,22 @@ import * as utils from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; const BIDDER_CODE = 'tappx'; const TTL = 360; const CUR = 'USD'; -const TAPPX_BIDDER_VERSION = '0.1.10329'; +const TAPPX_BIDDER_VERSION = '0.1.10413'; const TYPE_CNN = 'prebidjs'; +const VIDEO_SUPPORT = ['instream']; + var HOST; var hostDomain; export const spec = { code: BIDDER_CODE, - supportedMediaTypes: [BANNER], + supportedMediaTypes: [BANNER, VIDEO], /** * Determines whether or not the given bid request is valid. @@ -24,11 +26,7 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function(bid) { - if ((bid.params == null) || (bid.params.endpoint == null) || (bid.params.tappxkey == null)) { - utils.logWarn(`[TAPPX]: Please review the mandatory Tappx parameters. ${JSON.stringify(bid)}`); - return false; - } - return true; + return validBasic(bid) && validMediaType(bid) }, /** @@ -63,7 +61,7 @@ export const spec = { const bids = []; responseBody.seatbid.forEach(serverSeatBid => { serverSeatBid.bid.forEach(serverBid => { - bids.push(interpretBannerBid(serverBid, originalRequest)); + bids.push(interpretBid(serverBid, originalRequest)); }); }); @@ -106,25 +104,66 @@ export const spec = { } } +function validBasic(bid) { + if ( + (bid.params == null) || + (bid.params.endpoint == null) || + (bid.params.tappxkey == null)) { + utils.logWarn(`[TAPPX]: Please review the mandatory Tappx parameters.`); + return false; + } + return true; +} + +function validMediaType(bid) { + const video = utils.deepAccess(bid, 'mediaTypes.video'); + + // Video validations + if (typeof video != 'undefined') { + if (VIDEO_SUPPORT.indexOf(video.context) === -1) { + utils.logWarn(`[TAPPX]: Please review the mandatory Tappx parameters for Video. Only "instream" is suported.`); + return false; + } + } + + return true; +} + /** * Parse the response and generate one bid object. * * @param {object} serverBid Bid by OpenRTB 2.5 * @returns {object} Prebid banner bidObject */ -function interpretBannerBid(serverBid, request) { - return { +function interpretBid(serverBid, request) { + let bidReturned = { requestId: request.bids.bidId, cpm: serverBid.price, currency: serverBid.cur ? serverBid.cur : CUR, width: serverBid.w, height: serverBid.h, - ad: serverBid.adm, ttl: TTL, creativeId: serverBid.crid, netRevenue: true, - mediaType: BANNER, } + + if (typeof serverBid.dealId != 'undefined') { bidReturned.dealId = serverBid.dealId } + + if (typeof request.bids.mediaTypes != 'undefined' && typeof request.bids.mediaTypes.video != 'undefined') { + bidReturned.vastXml = serverBid.adm; + bidReturned.vastUrl = serverBid.lurl; + bidReturned.ad = serverBid.adm; + bidReturned.mediaType = VIDEO; + } else { + bidReturned.ad = serverBid.adm; + bidReturned.mediaType = BANNER; + } + + if (typeof bidReturned.adomain != 'undefined' || bidReturned.adomain != null) { + bidReturned.meta = { advertiserDomains: request.bids.adomain }; + } + + return bidReturned; } /** @@ -136,14 +175,14 @@ function interpretBannerBid(serverBid, request) { */ function buildOneRequest(validBidRequests, bidderRequest) { HOST = utils.deepAccess(validBidRequests, 'params.host'); - let hostInfo = getHostInfo(HOST) - // hostDomain = HOST.split('/', 1)[0]; + let hostInfo = getHostInfo(HOST); hostDomain = hostInfo.domain; const ENDPOINT = utils.deepAccess(validBidRequests, 'params.endpoint'); const TAPPXKEY = utils.deepAccess(validBidRequests, 'params.tappxkey'); const BIDFLOOR = utils.deepAccess(validBidRequests, 'params.bidfloor'); const bannerMediaType = utils.deepAccess(validBidRequests, 'mediaTypes.banner'); + const videoMediaType = utils.deepAccess(validBidRequests, 'mediaTypes.video'); const { refererInfo } = bidderRequest; // let requests = []; @@ -205,6 +244,18 @@ function buildOneRequest(validBidRequests, bidderRequest) { imp.banner = banner; } + if (videoMediaType) { + let video = {}; + w = videoMediaType.playerSize[0][0]; + h = videoMediaType.playerSize[0][1]; + video.w = w; + video.h = h; + + video.mimes = videoMediaType.mimes; + + imp.video = video; + } + imp.id = validBidRequests.bidId; imp.tagid = tagid; imp.secure = 1; diff --git a/modules/tappxBidAdapter.md b/modules/tappxBidAdapter.md index d9ffd98b6c5..e6581a67d06 100644 --- a/modules/tappxBidAdapter.md +++ b/modules/tappxBidAdapter.md @@ -7,6 +7,7 @@ Maintainer: prebid@tappx.com # Description Module that connects to :tappx demand sources. +Suppots Banner and Instream Video. Please use ```tappx``` as the bidder code. Ads sizes available: [320,50], [300,250], [320,480], [1024,768], [728,90] @@ -35,3 +36,35 @@ Ads sizes available: [320,50], [300,250], [320,480], [1024,768], [728,90] } ]; ``` + + +# Video Test Parameters +``` + var adUnits = [ + { + code: 'video-ad-div', + renderer: { + options: { + text: "Tappx instream Video" + } + }, + mediaTypes: { + video: { + context: "instream", + mimes : [ "video/mp4", "application/javascript" ], + playerSize: [320, 250] + } + }, + bids: [{ + bidder: 'tappx', + params: { + host: "testing.ssp.tappx.com/rtb/v2/", + tappxkey: "pub-1234-desktop-1234", + endpoint: "VZ12TESTCTV", + bidfloor: 0.005, + test: true + } + }] + } + ]; +``` \ No newline at end of file diff --git a/test/spec/modules/tappxBidAdapter_spec.js b/test/spec/modules/tappxBidAdapter_spec.js index 1d3f9676d09..378b391a4eb 100644 --- a/test/spec/modules/tappxBidAdapter_spec.js +++ b/test/spec/modules/tappxBidAdapter_spec.js @@ -53,7 +53,7 @@ const c_BIDREQUEST = { } ] }; -const c_SERVERRESPONSE = { +const c_SERVERRESPONSE_B = { body: { id: '1c54b4f1-645f-44e6-b8ae-5d43c923ef1c', bidid: 'bid3811165568213389257', @@ -82,10 +82,40 @@ const c_SERVERRESPONSE = { }, headers: {} }; + +const c_SERVERRESPONSE_V = { + body: { + id: '1c54b4f1-645f-44e6-b8ae-5d43c923ef1c', + bidid: 'bid3811165568213389257', + seatbid: [ + { + seat: '1', + group: 0, + bid: [ + { + id: '3811165568213389257', + impid: 1, + price: 0.05, + adm: "Tappx<\/AdSystem>Tappx<\/AdTitle><\/Impression><\/Error>00:00:22<\/Duration><\/Tracking><\/Tracking><\/Tracking><\/Tracking><\/Tracking><\/Tracking><\/Tracking><\/TrackingEvents><\/ClickThrough><\/ClickTracking><\/VideoClicks><\/MediaFile><\/MediaFiles><\/Linear><\/Creative><\/Creatives><\/InLine><\/Ad><\/VAST>", + 'lurl': 'https:\/\/ssp.api.tappx.com\/rtb\/RTBv2Loss?id=5001829913749291152&ep=VZ12TESTCTV&au=test&bu=localhost&sz=6x6&pu=0.005&pt=0.01&cid=&crid=&adv=&aid=${AUCTION_ID}&bidid=${AUCTION_BID_ID}&impid=${AUCTION_IMP_ID}&sid=${AUCTION_SEAT_ID}&adid=${AUCTION_AD_ID}&ap=${AUCTION_PRICE}&cur=${AUCTION_CURRENCY}&mbr=${AUCTION_MBR}&l=${AUCTION_LOSS}', + cid: '01744fbb521e9fb10ffea926190effea', + crid: 'a13cf884e66e7c660afec059c89d98b6', + adomain: [ + ], + }, + ], + }, + ], + cur: 'USD', + }, + headers: {} +}; + const c_CONSENTSTRING = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; const c_VALIDBIDREQUESTS = [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com\/rtb\/v2\/', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'test': 1}, 'userId': {'haloId': '0000x179MZAzMqUWsFonu7Drm3eDDBMYtj5SPoWQnl89Upk3WTlCvEnKI9SshX0p6eFJ7otPYix179MZAzMqUWsFonu7Drm3eDDBMYtj5SPoWQnl89Upk3WTlCvEnKI9SshX0p6e', 'id5id': {'uid': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_rEXbz6UYtYEJelYrDaZOLkh8WcF9J0ZHmEHFKZEBlLXsgP6xqXU3BCj4Ay0Z6fw_jSOaHxMHwd-voRHqFA4Q9NwAxFcVLyPWnNGZ9VbcSAPos1wupq7Xu3MIm-Bw_0vxjhZdWNy4chM9x3i', 'ext': {'linkType': 0}}, 'intentIqId': 'GIF89a\u0000\u0000\u0000\u0000�\u0000\u0000���\u0000\u0000\u0000?�\u0000\u0000\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000A\u0000\u0000;', 'lotamePanoramaId': 'xTtLUY7GwqX2MMqSHo9RQ2YUOIBFhlASOR43I9KjvgtcrxIys3RxME96M02LTjWR', 'parrableId': {'eid': '02.YoqC9lWZh8.C8QTSiJTNgI6Pp0KCM5zZgEgwVMSsVP5W51X8cmiUHQESq9WRKB4nreqZJwsWIcNKlORhG4u25Wm6lmDOBmQ0B8hv0KP6uVQ97aouuH52zaz2ctVQTORUKkErPRPcaCJ7dKFcrNoF2i6WOR0S5Nk'}, 'pubcid': 'b1254-152f-12F5-5698-dI1eljK6C7WA', 'pubProvidedId': [{'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}]}, 'userIdAsEids': [{'source': 'audigent.com', 'uids': [{'id': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'atype': 1}]}, {'source': 'id5-sync.com', 'uids': [{'id': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'atype': 1, 'ext': {'linkType': 0}}]}], 'ortb2Imp': {'ext': {'data': {'adserver': {'name': 'gam', 'adslot': '/19968336/header-bid-tag-0'}, 'pbadslot': '/19968336/header-bid-tag-0'}}}, 'mediaTypes': {'banner': {'sizes': [[320, 480], [320, 50]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '71c0d86b-4b47-4aff-a6da-1af0b1712439', 'sizes': [[320, 480], [320, 50]], 'bidId': '264d7969b125a5', 'bidderRequestId': '1c674c14a3889c', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}]; const c_VALIDBIDAPPREQUESTS = [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com\/rtb\/v2\/', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'test': 1, 'app': {'name': 'Tappx Test', 'bundle': 'com.test.tappx', 'domain': 'tappx.com', 'publisher': { 'name': 'Tappx', 'domain': 'tappx.com' }}}, 'userId': {'haloId': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'id5id': {'uid': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'ext': {'linkType': 0}}, 'intentIqId': 'GIF89a\u0001\u0000\u0001\u0000�\u0000\u0000���\u0000\u0000\u0000!�\u0004\u0001\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000\u0002\u0002D\u0001\u0000;', 'lotamePanoramaId': '8003916b61a95b185690ec103bdf4945a70213e01818a5e5d8690b542730755a', 'parrableId': {'eid': '01.1617088921.7faa68d9570a50ea8e4f359e9b99ca4b7509e948a6175b3e5b0b8cbaf5b62424104ccfb0191ca79366de8368ed267b89a68e236df5f41f96f238e4301659e9023fec05e46399fb1ad0a0'}, 'pubcid': 'b7143795-852f-42f0-8864-5ecbea1ade4e', 'pubProvidedId': [{'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}]}, 'userIdAsEids': [{'source': 'audigent.com', 'uids': [{'id': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'atype': 1}]}, {'source': 'id5-sync.com', 'uids': [{'id': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'atype': 1, 'ext': {'linkType': 0}}]}, {'source': 'intentiq.com', 'uids': [{'id': 'GIF89a\u0001\u0000\u0001\u0000�\u0000\u0000���\u0000\u0000\u0000!�\u0004\u0001\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000\u0002\u0002D\u0001\u0000;', 'atype': 1}]}, {'source': 'crwdcntrl.net', 'uids': [{'id': '8003916b61a95b185690ec103bdf4945a70213e01818a5e5d8690b542730755a', 'atype': 1}]}, {'source': 'parrable.com', 'uids': [{'id': '01.1617088921.7faa68d9570a50ea8e4f359e9b99ca4b7509e948a6175b3e5b0b8cbaf5b62424104ccfb0191ca79366de8368ed267b89a68e236df5f41f96f238e4301659e9023fec05e46399fb1ad0a0', 'atype': 1}]}, {'source': 'pubcid.org', 'uids': [{'id': 'b7143795-852f-42f0-8864-5ecbea1ade4e', 'atype': 1}]}, {'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}], 'ortb2Imp': {'ext': {'data': {'adserver': {'name': 'gam', 'adslot': '/19968336/header-bid-tag-0'}, 'pbadslot': '/19968336/header-bid-tag-0'}}}, 'mediaTypes': {'banner': {'sizes': [[320, 480], [320, 50]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '71c0d86b-4b47-4aff-a6da-1af0b1712439', 'sizes': [[320, 480], [320, 50]], 'bidId': '264d7969b125a5', 'bidderRequestId': '1c674c14a3889c', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}]; -const c_BIDDERREQUEST = {'bidderCode': 'tappx', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'bidderRequestId': '1c674c14a3889c', 'bids': [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com\/rtb\/v2\/', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'test': 1}, 'userId': {'haloId': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'id5id': {'uid': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'ext': {'linkType': 0}}, 'intentIqId': 'GIF89a\u0000\u0000\u0000\u0000�\u0000\u0000���\u0000\u0000\u0000?�\u0000\u0000\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000A\u0000\u0000;', 'lotamePanoramaId': '8003916b61a95b185690ec103bdf4945a70213e01818a5e5d8690b542730755a', 'parrableId': {'eid': '01.1617088921.7faa68d9570a50ea8e4f359e9b99ca4b7509e948a6175b3e5b0b8cbaf5b62424104ccfb0191ca79366de8368ed267b89a68e236df5f41f96f238e4301659e9023fec05e46399fb1ad0a0'}, 'pubcid': 'b7143795-852f-42f0-8864-5ecbea1ade4e', 'pubProvidedId': [{'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}]}, 'userIdAsEids': [{'source': 'audigent.com', 'uids': [{'id': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'atype': 1}]}, {'source': 'id5-sync.com', 'uids': [{'id': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'atype': 1, 'ext': {'linkType': 0}}]}], 'ortb2Imp': {'ext': {'data': {'adserver': {'name': 'gam', 'adslot': '/19968336/header-bid-tag-0'}, 'pbadslot': '/19968336/header-bid-tag-0'}}}, 'mediaTypes': {'banner': {'sizes': [[320, 480], [320, 50]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '71c0d86b-4b47-4aff-a6da-1af0b1712439', 'sizes': [[320, 480], [320, 50]], 'bidId': '264d7969b125a5', 'bidderRequestId': '1c674c14a3889c', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}], 'auctionStart': 1617088922120, 'timeout': 700, 'refererInfo': {'referer': 'http://localhost:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true', 'reachedTop': true, 'isAmp': false, 'numIframes': 0, 'stack': ['http://localhost:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true'], 'canonicalUrl': null}, 'gdprConsent': {'consentString': c_CONSENTSTRING, 'vendorData': {'metadata': 'BO-JeiTPABAOkAAABAENABA', 'gdprApplies': true, 'hasGlobalScope': false, 'cookieVersion': 1, 'created': '2020-12-09T09:22:09.900Z', 'lastUpdated': '2021-01-14T15:44:03.600Z', 'cmpId': 0, 'cmpVersion': 1, 'consentScreen': 0, 'consentLanguage': 'EN', 'vendorListVersion': 1, 'maxVendorId': 0, 'purposeConsents': {}, 'vendorConsents': {}}, 'gdprApplies': true, 'apiVersion': 1}, 'uspConsent': '1YCC', 'start': 1611308859099}; +const c_BIDDERREQUEST_B = {'bidderCode': 'tappx', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'bidderRequestId': '1c674c14a3889c', 'bids': [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com\/rtb\/v2\/', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'test': 1}, 'userId': {'haloId': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'id5id': {'uid': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'ext': {'linkType': 0}}, 'intentIqId': 'GIF89a\u0000\u0000\u0000\u0000�\u0000\u0000���\u0000\u0000\u0000?�\u0000\u0000\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000A\u0000\u0000;', 'lotamePanoramaId': '8003916b61a95b185690ec103bdf4945a70213e01818a5e5d8690b542730755a', 'parrableId': {'eid': '01.1617088921.7faa68d9570a50ea8e4f359e9b99ca4b7509e948a6175b3e5b0b8cbaf5b62424104ccfb0191ca79366de8368ed267b89a68e236df5f41f96f238e4301659e9023fec05e46399fb1ad0a0'}, 'pubcid': 'b7143795-852f-42f0-8864-5ecbea1ade4e', 'pubProvidedId': [{'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}]}, 'userIdAsEids': [{'source': 'audigent.com', 'uids': [{'id': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'atype': 1}]}, {'source': 'id5-sync.com', 'uids': [{'id': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'atype': 1, 'ext': {'linkType': 0}}]}], 'ortb2Imp': {'ext': {'data': {'adserver': {'name': 'gam', 'adslot': '/19968336/header-bid-tag-0'}, 'pbadslot': '/19968336/header-bid-tag-0'}}}, 'mediaTypes': {'banner': {'sizes': [[320, 480], [320, 50]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '71c0d86b-4b47-4aff-a6da-1af0b1712439', 'sizes': [[320, 480], [320, 50]], 'bidId': '264d7969b125a5', 'bidderRequestId': '1c674c14a3889c', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}], 'auctionStart': 1617088922120, 'timeout': 700, 'refererInfo': {'referer': 'http://localhost:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true', 'reachedTop': true, 'isAmp': false, 'numIframes': 0, 'stack': ['http://localhost:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true'], 'canonicalUrl': null}, 'gdprConsent': {'consentString': c_CONSENTSTRING, 'vendorData': {'metadata': 'BO-JeiTPABAOkAAABAENABA', 'gdprApplies': true, 'hasGlobalScope': false, 'cookieVersion': 1, 'created': '2020-12-09T09:22:09.900Z', 'lastUpdated': '2021-01-14T15:44:03.600Z', 'cmpId': 0, 'cmpVersion': 1, 'consentScreen': 0, 'consentLanguage': 'EN', 'vendorListVersion': 1, 'maxVendorId': 0, 'purposeConsents': {}, 'vendorConsents': {}}, 'gdprApplies': true, 'apiVersion': 1}, 'uspConsent': '1YCC', 'start': 1611308859099}; +const c_BIDDERREQUEST_V = {'method': 'POST', 'url': 'https://testing.ssp.tappx.com/rtb/v2//VZ12TESTCTV?type_cnn=prebidjs&v=0.1.10329', 'data': '{"site":{"name":"localhost","bundle":"localhost","domain":"localhost"},"user":{"ext":{}},"id":"e807363f-3095-43a8-a4a6-f44196cb7318","test":1,"at":1,"tmax":1000,"bidder":"tappx","imp":[{"video":{"w":320,"h":250,"mimes":["video/mp4","application/javascript"]},"id":"28f49c71b13f2f","tagid":"localhost_typeAdBanVid_windows","secure":1,"bidfloor":0.005,"ext":{"bidder":{"tappxkey":"pub-1234-desktop-1234","endpoint":"VZ12TESTCTV","host":"testing.ssp.tappx.com/rtb/v2/"}}}],"device":{"os":"windows","ip":"peer","ua":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36","h":864,"w":1536,"dnt":0,"language":"en","make":"Google Inc."},"params":{"host":"tappx.com","bidfloor":0.005},"regs":{"gdpr":0,"ext":{}}}', 'bids': {'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com/rtb/v2/', 'tappxkey': 'pub-1234-desktop-1234', 'endpoint': 'VZ12TESTCTV', 'bidfloor': 0.005, 'test': true}, 'crumbs': {'pubcid': 'dccfe922-3823-4676-b7b2-e5ed8743154e'}, 'ortb2Imp': {'ext': {'data': {'pbadslot': 'video-ad-div'}}}, 'renderer': {'options': {'text': 'Tappx Outstream Video'}}, 'mediaTypes': {'video': {'context': 'instream', 'mimes': ['video/mp4', 'application/javascript'], 'playerSize': [[320, 250]]}}, 'adUnitCode': 'video-ad-div', 'transactionId': 'ed41c805-d14c-49c3-954d-26b98b2aa2c2', 'sizes': [[320, 250]], 'bidId': '28f49c71b13f2f', 'bidderRequestId': '1401710496dc7', 'auctionId': 'e807363f-3095-43a8-a4a6-f44196cb7318', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}} describe('Tappx bid adapter', function () { /** @@ -102,6 +132,16 @@ describe('Tappx bid adapter', function () { delete badBidRequest.bids[0].params.endpoint; assert.isFalse(spec.isBidRequestValid(badBidRequest.bids[0])); }); + + it('should return false for not instream requests', function () { + let badBidRequest_v = c_BIDDERREQUEST_V; + delete badBidRequest_v.bids.mediaTypes.banner; + badBidRequest_v.bids.mediaTypes.video = {}; + badBidRequest_v.bids.mediaTypes.video.context = 'outstream'; + badBidRequest_v.bids.mediaTypes.video.mimes = [ 'video/mp4', 'application/javascript' ]; + badBidRequest_v.bids.mediaTypes.video.playerSize = [320, 250]; + assert.isFalse(spec.isBidRequestValid(badBidRequest_v.bids)); + }); }); /** @@ -110,10 +150,12 @@ describe('Tappx bid adapter', function () { describe('buildRequest', function () { // Web Test let validBidRequests = c_VALIDBIDREQUESTS; + let validBidRequests_V = c_VALIDBIDREQUESTS; // App Test let validAppBidRequests = c_VALIDBIDAPPREQUESTS; - let bidderRequest = c_BIDDERREQUEST; + let bidderRequest = c_BIDDERREQUEST_B; + let bidderRequest_V = c_BIDDERREQUEST_V; it('should add gdpr/usp consent information to the request', function () { const request = spec.buildRequests(validBidRequests, bidderRequest); @@ -138,6 +180,20 @@ describe('Tappx bid adapter', function () { expect(data.imp[0].banner.h).to.be.oneOf([320, 50, 250, 480]); }); + it('should properly build a video request', function () { + const request = spec.buildRequests(validBidRequests_V, bidderRequest_V); + expect(request[0].url).to.match(/^(http|https):\/\/(.*)\.tappx\.com\/.+/); + expect(request[0].method).to.equal('POST'); + + const data = JSON.parse(request[0].data); + expect(data.site).to.not.equal(null); + expect(data.imp).to.have.lengthOf(1); + expect(data.imp[0].bidfloor, data).to.not.be.null; + expect(data.imp[0].banner).to.not.equal(null); + expect(data.imp[0].banner.w).to.be.oneOf([320, 50, 250, 480]); + expect(data.imp[0].banner.h).to.be.oneOf([320, 50, 250, 480]); + }); + it('should set user eids array', function () { const request = spec.buildRequests(validBidRequests, bidderRequest); @@ -165,17 +221,51 @@ describe('Tappx bid adapter', function () { * INTERPRET RESPONSE TESTS */ describe('interpretResponse', function () { - it('receive reponse with single placement', function () { - const bids = spec.interpretResponse(c_SERVERRESPONSE, c_BIDREQUEST); + it('receive banner reponse with single placement', function () { + const bids = spec.interpretResponse(c_SERVERRESPONSE_B, c_BIDDERREQUEST_B); const bid = bids[0]; expect(bid.cpm).to.exist; expect(bid.ad).to.match(/^' - } - ], - header: {someheader: 'fakedata'} + body: { + id: 'auctionid', + bidid: '84ab500420319d', + seatbid: [{ + bid: [ + { + impid: '84ab500420319d', + price: 0.45, + crid: '42', + adm: '', + w: 300, + h: 250, + adomain: ['adomain.com'], + cat: ['IAB1-4', 'IAB8-16', 'IAB25-5'], + ext: { + crType: 'banner', + advertiser_id: '777', + advertiser_name: 'advertiser', + agency_name: 'agency' + } + } + ] + }], + cur: 'USD' + }, + headers: {someheader: 'fakedata'} }; let BANNER_RESPONSE_WITHDEALID = { - body: [ - { - bidId: '84ab500420319d', - bidderCode: 'adxcg', - width: 300, - height: 250, - deal_id: '7722', - creativeId: '42', - cpm: 0.45, - currency: 'USD', - netRevenue: true, - ad: '' - } - ], - header: {someheader: 'fakedata'} + body: { + id: 'auctionid', + bidid: '84ab500420319d', + seatbid: [{ + bid: [ + { + impid: '84ab500420319d', + price: 0.45, + crid: '42', + dealid: '7722', + adm: '', + w: 300, + h: 250, + adomain: ['adomain.com'], + ext: { + crType: 'banner' + } + } + ] + }], + cur: 'USD' + } }; let VIDEO_RESPONSE = { - body: [ - { - bidId: '84ab500420319d', - bidderCode: 'adxcg', - width: 640, - height: 360, - creativeId: '42', - cpm: 0.45, - currency: 'USD', - netRevenue: true, - vastUrl: 'vastContentUrl' - } - ], - header: {someheader: 'fakedata'} + body: { + id: 'auctionid', + bidid: '84ab500420319d', + seatbid: [{ + bid: [ + { + impid: '84ab500420319d', + price: 0.45, + crid: '42', + nurl: 'vastContentUrl', + adomain: ['adomain.com'], + w: 640, + h: 360, + ext: { + crType: 'video' + } + } + ] + }], + cur: 'USD' + }, + headers: {someheader: 'fakedata'} }; - let NATIVE_RESPONSE = { - body: [ + let NATIVE_RESPONSEob = { + assets: [ { - bidId: '84ab500420319d', - bidderCode: 'adxcg', - width: 0, - height: 0, - creativeId: '42', - cpm: 0.45, - currency: 'USD', - netRevenue: true, - nativeResponse: { - assets: [ - { - id: 1, - required: 0, - title: { - text: 'titleContent' - } - }, - { - id: 2, - required: 0, - img: { - url: 'imageContent', - w: 600, - h: 600 - } - }, - { - id: 3, - required: 0, - data: { - label: 'DESC', - value: 'descriptionContent' - } - }, - { - id: 0, - required: 0, - data: { - label: 'SPONSORED', - value: 'sponsoredByContent' - } - }, - { - id: 5, - required: 0, - icon: { - url: 'iconContent', - w: 400, - h: 400 - } - } - ], - link: { - url: 'linkContent' - }, - imptrackers: ['impressionTracker1', 'impressionTracker2'] + id: 1, + required: 0, + title: { + text: 'titleContent' + } + }, + { + id: 2, + required: 0, + img: { + url: 'imageContent', + w: 600, + h: 600 + } + }, + { + id: 3, + required: 0, + data: { + label: 'DESC', + value: 'descriptionContent' + } + }, + { + id: 0, + required: 0, + data: { + label: 'SPONSORED', + value: 'sponsoredByContent' + } + }, + { + id: 5, + required: 0, + icon: { + url: 'iconContent', + w: 400, + h: 400 } } ], - header: {someheader: 'fakedata'} + link: { + url: 'linkContent' + }, + imptrackers: ['impressionTracker1', 'impressionTracker2'] + } + + let NATIVE_RESPONSE = { + body: { + id: 'auctionid', + bidid: '84ab500420319d', + seatbid: [{ + bid: [ + { + impid: '84ab500420319d', + price: 0.45, + crid: '42', + w: 0, + h: 0, + adm: JSON.stringify(NATIVE_RESPONSEob), + adomain: ['adomain.com'], + ext: { + crType: 'native' + } + } + ] + }], + cur: 'USD' + }, + headers: {someheader: 'fakedata'} }; it('handles regular responses', function () { + expect(BANNER_RESPONSE).to.exist; + expect(BANNER_RESPONSE.body).to.exist; + expect(BANNER_RESPONSE.body.id).to.exist; + expect(BANNER_RESPONSE.body.seatbid[0]).to.exist; let result = spec.interpretResponse(BANNER_RESPONSE, BIDDER_REQUEST); expect(result).to.have.lengthOf(1); @@ -452,26 +490,30 @@ describe('AdxcgAdapter', function () { expect(result[0].width).to.equal(300); expect(result[0].height).to.equal(250); expect(result[0].creativeId).to.equal(42); - expect(result[0].cpm).to.equal(0.45); + expect(result[0].cpm).to.be.within(0.45, 0.46); expect(result[0].ad).to.equal(''); expect(result[0].currency).to.equal('USD'); expect(result[0].netRevenue).to.equal(true); expect(result[0].ttl).to.equal(300); expect(result[0].dealId).to.not.exist; + expect(result[0].meta.advertiserDomains[0]).to.equal('adomain.com'); + expect(result[0].meta.advertiserId).to.be.eql('777'); + expect(result[0].meta.advertiserName).to.be.eql('advertiser'); + expect(result[0].meta.agencyName).to.be.eql('agency'); + expect(result[0].meta.advertiserDomains).to.be.eql(['adomain.com']); + expect(result[0].meta.secondaryCatIds).to.be.eql(['IAB1-4', 'IAB8-16', 'IAB25-5']); }); it('handles regular responses with dealid', function () { - let result = spec.interpretResponse( - BANNER_RESPONSE_WITHDEALID, - BIDDER_REQUEST - ); + let result = spec.interpretResponse(BANNER_RESPONSE_WITHDEALID); expect(result).to.have.lengthOf(1); expect(result[0].width).to.equal(300); expect(result[0].height).to.equal(250); expect(result[0].creativeId).to.equal(42); - expect(result[0].cpm).to.equal(0.45); + // expect(result[0].cpm).to.equal(0.45); + expect(result[0].cpm).to.be.within(0.45, 0.46); expect(result[0].ad).to.equal(''); expect(result[0].currency).to.equal('USD'); expect(result[0].netRevenue).to.equal(true); @@ -479,7 +521,7 @@ describe('AdxcgAdapter', function () { }); it('handles video responses', function () { - let result = spec.interpretResponse(VIDEO_RESPONSE, BIDDER_REQUEST); + let result = spec.interpretResponse(VIDEO_RESPONSE); expect(result).to.have.lengthOf(1); expect(result[0].width).to.equal(640); @@ -494,17 +536,19 @@ describe('AdxcgAdapter', function () { }); it('handles native responses', function () { - let result = spec.interpretResponse(NATIVE_RESPONSE, BIDDER_REQUEST); + let result = spec.interpretResponse(NATIVE_RESPONSE); expect(result[0].width).to.equal(0); expect(result[0].height).to.equal(0); - expect(result[0].mediaType).to.equal('native'); + expect(result[0].creativeId).to.equal(42); expect(result[0].cpm).to.equal(0.45); expect(result[0].currency).to.equal('USD'); expect(result[0].netRevenue).to.equal(true); expect(result[0].ttl).to.equal(300); + expect(result[0].mediaType).to.equal('native'); + expect(result[0].native.clickUrl).to.equal('linkContent'); expect(result[0].native.impressionTrackers).to.deep.equal([ 'impressionTracker1', @@ -545,4 +589,65 @@ describe('AdxcgAdapter', function () { ); }); }); + + describe('on bidWon', function () { + beforeEach(function () { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function () { + utils.triggerPixel.restore(); + }); + it('should replace burl for banner', function () { + const burl = 'burl=${' + 'AUCTION_PRICE}'; + const bid = { + 'bidderCode': 'adxcg', + 'width': 0, + 'height': 0, + 'statusMessage': 'Bid available', + 'adId': '3d0b6ff1dda89', + 'requestId': '2a423489e058a1', + 'mediaType': 'banner', + 'source': 'client', + 'ad': burl, + 'cpm': 0.66, + 'creativeId': '353538_591471', + 'currency': 'USD', + 'dealId': '', + 'netRevenue': true, + 'ttl': 300, + // 'nurl': nurl, + 'burl': burl, + 'isBurl': true, + 'auctionId': 'a92bffce-14d2-4f8f-a78a-7b9b5e4d28fa', + 'responseTimestamp': 1556867386065, + 'requestTimestamp': 1556867385916, + 'bidder': 'adxcg', + 'adUnitCode': 'div-gpt-ad-1555415275793-0', + 'timeToRespond': 149, + 'pbLg': '0.50', + 'pbMg': '0.60', + 'pbHg': '0.66', + 'pbAg': '0.65', + 'pbDg': '0.66', + 'pbCg': '', + 'size': '0x0', + 'adserverTargeting': { + 'hb_bidder': 'mgid', + 'hb_adid': '3d0b6ff1dda89', + 'hb_pb': '0.66', + 'hb_size': '0x0', + 'hb_source': 'client', + 'hb_format': 'banner', + 'hb_banner_title': 'TITLE', + 'hb_banner_image': 'hb_banner_image:3d0b6ff1dda89', + 'hb_banner_icon': 'IconURL', + 'hb_banner_linkurl': 'hb_banner_linkurl:3d0b6ff1dda89' + }, + 'status': 'targetingSet', + 'params': [{'adzoneid': '20'}] + }; + spec.onBidWon(bid); + expect(bid.burl).to.deep.equal(burl); + }); + }); }); From a460125d5f63115d12ebcc27ec6cbab808ab6942 Mon Sep 17 00:00:00 2001 From: mwehr-zeta <70167335+mwehr-zeta@users.noreply.github.com> Date: Wed, 21 Apr 2021 07:33:45 -0400 Subject: [PATCH 072/303] Zeta bid adapter: add params to bid request (#6614) * Submit Zeta Adapter to Prebid * comments addressed * demo changes * additional polishing * additional polishing * Update hello_world.html * remove extraneous changes to hello_world.html * no, really this time * additional polishing * add unit test * update to include additional OpenRTB fields and objects * Update to include addtional OpenRTB fields and objects --- modules/zetaBidAdapter.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js index 09d631b3d18..b168bf581d0 100644 --- a/modules/zetaBidAdapter.js +++ b/modules/zetaBidAdapter.js @@ -71,12 +71,22 @@ export const spec = { }; let payload = { id: bidderRequest.auctionId, - cur: [DEFAULT_CUR], imp: [impData], site: params.site ? params.site : {}, + app: params.app ? params.app : {}, device: params.device ? params.device : {}, user: params.user ? params.user : {}, - app: params.app ? params.app : {}, + at: params.at, + tmax: params.tmax, + wseat: params.wseat, + bseat: params.bseat, + allimps: params.allimps, + cur: [DEFAULT_CUR], + wlang: params.wlang, + bcat: params.bcat, + badv: params.badv, + bapp: params.bapp, + source: params.source ? params.source : {}, ext: { definerId: params.definerId } From 8ca05946a63863378cfb7d7da155d10979843c01 Mon Sep 17 00:00:00 2001 From: Adam Browning <19834421+adam-browning@users.noreply.github.com> Date: Wed, 21 Apr 2021 14:44:39 +0300 Subject: [PATCH 073/303] oneVideo Bid Adapter: content object mapping bug fix (VDEFECT-5405) (#6633) --- modules/oneVideoBidAdapter.js | 6 ++-- test/spec/modules/oneVideoBidAdapter_spec.js | 34 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/oneVideoBidAdapter.js b/modules/oneVideoBidAdapter.js index 3bf14eb11cb..60d56cfc8ad 100644 --- a/modules/oneVideoBidAdapter.js +++ b/modules/oneVideoBidAdapter.js @@ -4,7 +4,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'oneVideo'; export const spec = { code: 'oneVideo', - VERSION: '3.0.6', + VERSION: '3.0.7', ENDPOINT: 'https://ads.adaptv.advertising.com/rtb/openrtb?ext_id=', E2ETESTENDPOINT: 'https://ads-wc.v.ssp.yahoo.com/rtb/openrtb?ext_id=', SYNC_ENDPOINT1: 'https://pixel.advertising.com/ups/57304/sync?gdpr=&gdpr_consent=&_origin=0&redir=true', @@ -312,7 +312,7 @@ function getRequestData(bid, consentData, bidRequest) { } } if (bid.params.video.content && utils.isPlainObject(bid.params.video.content)) { - bidData.imp[0].content = {}; + bidData.site.content = {}; const contentStringKeys = ['id', 'title', 'series', 'season', 'genre', 'contentrating', 'language']; const contentNumberkeys = ['episode', 'prodq', 'context', 'livestream', 'len']; const contentArrayKeys = ['cat']; @@ -324,7 +324,7 @@ function getRequestData(bid, consentData, bidRequest) { (contentObjectKeys.indexOf(contentKey) > -1 && utils.isPlainObject(bid.params.video.content[contentKey])) || (contentArrayKeys.indexOf(contentKey) > -1 && utils.isArray(bid.params.video.content[contentKey]) && bid.params.video.content[contentKey].every(catStr => utils.isStr(catStr)))) { - bidData.imp[0].content[contentKey] = bid.params.video.content[contentKey]; + bidData.site.content[contentKey] = bid.params.video.content[contentKey]; } else { utils.logMessage('oneVideo bid adapter validation error: ', contentKey, ' is either not supported is OpenRTB V2.5 or value is undefined'); } diff --git a/test/spec/modules/oneVideoBidAdapter_spec.js b/test/spec/modules/oneVideoBidAdapter_spec.js index 9ee1045a6e8..903bc191b47 100644 --- a/test/spec/modules/oneVideoBidAdapter_spec.js +++ b/test/spec/modules/oneVideoBidAdapter_spec.js @@ -221,7 +221,7 @@ describe('OneVideoBidAdapter', function () { const placement = bidRequest.params.video.placement; const rewarded = bidRequest.params.video.rewarded; const inventoryid = bidRequest.params.video.inventoryid; - const VERSION = '3.0.6'; + const VERSION = '3.0.7'; expect(data.imp[0].video.w).to.equal(width); expect(data.imp[0].video.h).to.equal(height); expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor); @@ -387,37 +387,37 @@ describe('OneVideoBidAdapter', function () { bidRequest.params.video.content = null; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.be.undefined; + expect(data.site.content).to.be.undefined; }); it('should not accept content object if value is is Array ', function () { bidRequest.params.video.content = []; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.be.undefined; + expect(data.site.content).to.be.undefined; }); it('should not accept content object if value is Number ', function () { bidRequest.params.video.content = 123456; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.be.undefined; + expect(data.site.content).to.be.undefined; }); it('should not accept content object if value is String ', function () { bidRequest.params.video.content = 'keyValuePairs'; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.be.undefined; + expect(data.site.content).to.be.undefined; }); it('should not accept content object if value is Boolean ', function () { bidRequest.params.video.content = true; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.be.undefined; + expect(data.site.content).to.be.undefined; }); it('should accept content object if value is Object ', function () { bidRequest.params.video.content = {}; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.be.a('object'); + expect(data.site.content).to.be.a('object'); }); it('should not append unsupported content object keys', function () { @@ -428,7 +428,7 @@ describe('OneVideoBidAdapter', function () { }; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.be.empty; + expect(data.site.content).to.be.empty; }); it('should not append content string parameters if value is not string ', function () { @@ -443,8 +443,8 @@ describe('OneVideoBidAdapter', function () { }; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.be.a('object'); - expect(data.imp[0].content).to.be.empty + expect(data.site.content).to.be.a('object'); + expect(data.site.content).to.be.empty }); it('should not append content Number parameters if value is not Number ', function () { bidRequest.params.video.content = { @@ -456,8 +456,8 @@ describe('OneVideoBidAdapter', function () { }; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.be.a('object'); - expect(data.imp[0].content).to.be.empty + expect(data.site.content).to.be.a('object'); + expect(data.site.content).to.be.empty }); it('should not append content Array parameters if value is not Array ', function () { bidRequest.params.video.content = { @@ -465,8 +465,8 @@ describe('OneVideoBidAdapter', function () { }; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.be.a('object'); - expect(data.imp[0].content).to.be.empty + expect(data.site.content).to.be.a('object'); + expect(data.site.content).to.be.empty }); it('should not append content ext if value is not Object ', function () { bidRequest.params.video.content = { @@ -474,8 +474,8 @@ describe('OneVideoBidAdapter', function () { }; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.be.a('object'); - expect(data.imp[0].content).to.be.empty + expect(data.site.content).to.be.a('object'); + expect(data.site.content).to.be.empty }); it('should append supported parameters if value match validations ', function () { bidRequest.params.video.content = { @@ -498,7 +498,7 @@ describe('OneVideoBidAdapter', function () { }; const requests = spec.buildRequests([bidRequest], bidderRequest); const data = requests[0].data; - expect(data.imp[0].content).to.deep.equal(bidRequest.params.video.content); + expect(data.site.content).to.deep.equal(bidRequest.params.video.content); }); }); }); From eff2ae65438e8d580dacf530d83e1997e0c753d9 Mon Sep 17 00:00:00 2001 From: bretg Date: Wed, 21 Apr 2021 10:26:32 -0400 Subject: [PATCH 074/303] PR_REVIEW: added check for bidder name validity (#6491) * added check for bidder name validity * adding aliases in-scope for the validity check --- PR_REVIEW.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PR_REVIEW.md b/PR_REVIEW.md index 0519cbb7b6e..84131c177a3 100644 --- a/PR_REVIEW.md +++ b/PR_REVIEW.md @@ -38,6 +38,10 @@ General gulp commands include separate commands for serving the codebase on a bu Documentation they're supposed to be following is https://docs.prebid.org/dev-docs/bidder-adaptor.html Follow steps above for general review process. In addition, please verify the following: +- Verify the biddercode and aliases are valid: + - Lower case alphanumeric with the only special character allowed is underscore. + - The bidder code should be unique for the first 6 characters + - Reserved words that cannot be used as bidder names: all, context, data, general, prebid, and skadn - Verify that bidder has submitted valid bid params and that bids are being received. - Verify that bidder is not manipulating the prebid.js auction in any way or doing things that go against the principles of the project. If unsure check with the Tech Lead. - Verify that code re-use is being done properly and that changes introduced by a bidder don't impact other bidders. From dc6b450f3e15b5414dd3beb4e156b0116733945a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bendeg=C3=BAz=20=C3=81cs?= <30595431+acsbendi@users.noreply.github.com> Date: Wed, 21 Apr 2021 16:36:02 +0200 Subject: [PATCH 075/303] Kobler Bid Adapter: add new bid adapter (#6479) * Implemented Kobler bidder adapter. * Added missing '' to dealId example in parameters table. * Added information on supporting the Floors module. * Implemented tests for isBidRequestValid. * Implemented tests for inherited functions. * Removed unnecessary conditions and quotation marks. * Added TODO about deciding what to do in debug mode. * Added TODO about checking which currencies are allowed. * Added information on parameters read from the first bid only. * Fixed missing indexing operator when checking if mainSize is 0x0. * Implemented tests for buildRequests. * Implemented tests for interpretResponse. * Implemented tests for onBidWon. * Implemented tests for onTimeout. * Added some missing semicolons. * Removed TODO about allowed currencies. * Removed setting test in debug mode and related TODOs. * Removed optional pos parameter. * Removed optional bidfloor parameter and use floorPrice instead of floorprice. * Added support for multiple deal ID parameters. * Fixed formatting. * Added more explanation about the value of position param. * Moved pos property into Kobler-specific banner extension. * Simplifications based on PR comments. * Use getRefererInfo to get page URL for timeout notifications. * Removed TODO about auction type. * Added information on how to generate a sample bid. * Removed reading currency from currency.adServerCurrency. --- modules/koblerBidAdapter.js | 231 +++++++ modules/koblerBidAdapter.md | 67 ++ test/spec/modules/koblerBidAdapter_spec.js | 694 +++++++++++++++++++++ 3 files changed, 992 insertions(+) create mode 100644 modules/koblerBidAdapter.js create mode 100644 modules/koblerBidAdapter.md create mode 100644 test/spec/modules/koblerBidAdapter_spec.js diff --git a/modules/koblerBidAdapter.js b/modules/koblerBidAdapter.js new file mode 100644 index 00000000000..cc5b374af95 --- /dev/null +++ b/modules/koblerBidAdapter.js @@ -0,0 +1,231 @@ +import * as utils from '../src/utils.js'; +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; +import {getRefererInfo} from '../src/refererDetection.js'; + +const BIDDER_CODE = 'kobler'; +const BIDDER_ENDPOINT = 'https://bid.essrtb.com/bid/prebid_rtb_call'; +const TIMEOUT_NOTIFICATION_ENDPOINT = 'https://bid.essrtb.com/notify/prebid_timeout'; +const SUPPORTED_CURRENCY = 'USD'; +const DEFAULT_TIMEOUT = 1000; +const TIME_TO_LIVE_IN_SECONDS = 10 * 60; + +export const isBidRequestValid = function (bid) { + return !!(bid && bid.bidId && bid.params && bid.params.placementId); +}; + +export const buildRequests = function (validBidRequests, bidderRequest) { + return { + method: 'POST', + url: BIDDER_ENDPOINT, + data: buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest), + options: { + contentType: 'application/json' + } + }; +}; + +export const interpretResponse = function (serverResponse) { + const res = serverResponse.body; + const bids = [] + if (res) { + res.seatbid.forEach(sb => { + sb.bid.forEach(b => { + bids.push({ + requestId: b.impid, + cpm: b.price, + currency: res.cur, + width: b.w, + height: b.h, + creativeId: b.crid, + dealId: b.dealid, + netRevenue: true, + ttl: TIME_TO_LIVE_IN_SECONDS, + ad: b.adm, + nurl: b.nurl, + meta: { + advertiserDomains: b.adomain + } + }) + }) + }); + } + return bids; +}; + +export const onBidWon = function (bid) { + const cpm = bid.cpm || 0; + const adServerPrice = utils.deepAccess(bid, 'adserverTargeting.hb_pb', 0); + if (utils.isStr(bid.nurl) && bid.nurl !== '') { + const winNotificationUrl = utils.replaceAuctionPrice(bid.nurl, cpm) + .replace(/\${AD_SERVER_PRICE}/g, adServerPrice); + utils.triggerPixel(winNotificationUrl); + } +}; + +export const onTimeout = function (timeoutDataArray) { + if (utils.isArray(timeoutDataArray)) { + const refererInfo = getRefererInfo(); + const pageUrl = (refererInfo && refererInfo.referer) + ? refererInfo.referer + : window.location.href; + timeoutDataArray.forEach(timeoutData => { + const query = utils.parseQueryStringParameters({ + ad_unit_code: timeoutData.adUnitCode, + auction_id: timeoutData.auctionId, + bid_id: timeoutData.bidId, + timeout: timeoutData.timeout, + placement_id: utils.deepAccess(timeoutData, 'params.0.placementId'), + page_url: pageUrl, + }); + const timeoutNotificationUrl = `${TIMEOUT_NOTIFICATION_ENDPOINT}?${query}`; + utils.triggerPixel(timeoutNotificationUrl); + }); + } +}; + +function buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest) { + const imps = validBidRequests.map(buildOpenRtbImpObject); + const timeout = bidderRequest.timeout || config.getConfig('bidderTimeout') || DEFAULT_TIMEOUT; + const pageUrl = (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) + ? bidderRequest.refererInfo.referer + : window.location.href; + + const request = { + id: bidderRequest.auctionId, + at: 1, + tmax: timeout, + cur: [SUPPORTED_CURRENCY], + imp: imps, + device: { + devicetype: getDevice(), + geo: getGeo(validBidRequests[0]) + }, + site: { + page: pageUrl, + }, + test: getTest(validBidRequests[0]) + }; + + return JSON.stringify(request); +} + +function buildOpenRtbImpObject(validBidRequest) { + const sizes = getSizes(validBidRequest); + const mainSize = sizes[0]; + const floorInfo = getFloorInfo(validBidRequest, mainSize); + + return { + id: validBidRequest.bidId, + banner: { + format: buildFormatArray(sizes), + w: mainSize[0], + h: mainSize[1], + ext: { + kobler: { + pos: getPosition(validBidRequest) + } + } + }, + tagid: validBidRequest.params.placementId, + bidfloor: floorInfo.floor, + bidfloorcur: floorInfo.currency, + pmp: buildPmpObject(validBidRequest) + }; +} + +function getDevice() { + const ws = utils.getWindowSelf(); + const ua = ws.navigator.userAgent; + + if (/(tablet|ipad|playbook|silk|android 3.0|xoom|sch-i800|kindle)|(android(?!.*mobi))/i + .test(ua.toLowerCase())) { + return 5; // tablet + } + if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series([46])0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i + .test(ua.toLowerCase())) { + return 4; // phone + } + return 2; // personal computers +} + +function getGeo(validBidRequest) { + if (validBidRequest.params.zip) { + return { + zip: validBidRequest.params.zip + }; + } + return {}; +} + +function getTest(validBidRequest) { + return validBidRequest.params.test ? 1 : 0; +} + +function getSizes(validBidRequest) { + const sizes = utils.deepAccess(validBidRequest, 'mediaTypes.banner.sizes', validBidRequest.sizes); + if (utils.isArray(sizes) && sizes.length > 0) { + return sizes; + } + + return [[0, 0]]; +} + +function buildFormatArray(sizes) { + return sizes.map(size => { + return { + w: size[0], + h: size[1] + }; + }); +} + +function getPosition(validBidRequest) { + return parseInt(validBidRequest.params.position) || 0; +} + +function getFloorInfo(validBidRequest, mainSize) { + if (typeof validBidRequest.getFloor === 'function') { + const sizeParam = mainSize[0] === 0 && mainSize[1] === 0 ? '*' : mainSize; + return validBidRequest.getFloor({ + currency: SUPPORTED_CURRENCY, + mediaType: BANNER, + size: sizeParam + }); + } else { + return { + currency: SUPPORTED_CURRENCY, + floor: getFloorPrice(validBidRequest) + }; + } +} + +function getFloorPrice(validBidRequest) { + return parseFloat(validBidRequest.params.floorPrice) || 0.0; +} + +function buildPmpObject(validBidRequest) { + if (validBidRequest.params.dealIds) { + return { + deals: validBidRequest.params.dealIds.map(dealId => { + return { + id: dealId + }; + }) + }; + } + return {}; +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + isBidRequestValid, + buildRequests, + interpretResponse, + onBidWon, + onTimeout +}; + +registerBidder(spec); diff --git a/modules/koblerBidAdapter.md b/modules/koblerBidAdapter.md new file mode 100644 index 00000000000..7a7b2388367 --- /dev/null +++ b/modules/koblerBidAdapter.md @@ -0,0 +1,67 @@ +# Overview + +**Module Name**: Kobler Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: bidding-support@kobler.no + +# Description + +Connects to Kobler's demand sources. + +This adapter currently only supports Banner Ads. + +# Parameters + +| Parameter (in `params`) | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| placementId | Required | String | The identifier of the placement, it has to be issued by Kobler. | `'xjer0ch8'` | +| zip | Optional | String | Zip code of the user or the medium. When multiple ad units are submitted together, it is enough to set this parameter on the first one. | `'102 22'` | +| test | Optional | Boolean | Whether the request is for testing only. When multiple ad units are submitted together, it is enough to set this parameter on the first one. Defaults to false. | `true` | +| floorPrice | Optional | Float | Floor price in CPM and USD. Can be used as an alternative to the [Floors module](https://docs.prebid.org/dev-docs/modules/floors.html), which is also supported by this adapter. Defaults to 0. | `5.0` | +| position | Optional | Integer | The position of the ad unit. Can be used to differentiate between ad units if the same placement ID is used across multiple ad units. The first ad unit should have a `position` of 0, the second one should have a `position` of 1 and so on. Defaults to 0. | `1` | +| dealIds | Optional | Array of Strings | Array of deal IDs. | `['abc328745', 'mxw243253']` | + +# Test Parameters +```javascript + const adUnits = [{ + code: 'div-gpt-ad-1460505748561-1', + mediaTypes: { + banner: { + sizes: [[320, 250], [300, 250]], + } + }, + bids: [{ + bidder: 'kobler', + params: { + placementId: 'k5H7et3R0' + } + }] + }]; +``` + +In order to see a sample bid from Kobler (without a proper setup), you have to also do the following: +- Change the [`refererInfo` function](https://github.com/prebid/Prebid.js/blob/master/src/refererDetection.js) to return `'https://www.tv2.no/a/11734615'` as a [`referer`](https://github.com/prebid/Prebid.js/blob/caead3ccccc448e4cd09d074fd9f8833f56fe9b3/src/refererDetection.js#L169). This is necessary because Kobler only bids on recognized articles. +- Change the adapter's [`BIDDER_ENDPOINT`](https://github.com/prebid/Prebid.js/blob/master/modules/koblerBidAdapter.js#L8) to `'https://bid-service.dev.essrtb.com/bid/prebid_rtb_call'`. This endpoint belongs to the development server that is set up to always return a bid for the correct `placementId` and page URL combination. + +# Test Optional Parameters +```javascript + const adUnits = [{ + code: 'div-gpt-ad-1460505748561-1', + mediaTypes: { + banner: { + sizes: [[320, 250], [300, 250]], + } + }, + bids: [{ + bidder: 'kobler', + params: { + placementId: 'k5H7et3R0', + zip: '102 22', + test: true, + floorPrice: 5.0, + position: 1, + dealIds: ['abc328745', 'mxw243253'] + } + }] + }]; +``` diff --git a/test/spec/modules/koblerBidAdapter_spec.js b/test/spec/modules/koblerBidAdapter_spec.js new file mode 100644 index 00000000000..725c9ece118 --- /dev/null +++ b/test/spec/modules/koblerBidAdapter_spec.js @@ -0,0 +1,694 @@ +import {expect} from 'chai'; +import {spec} from 'modules/koblerBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {config} from 'src/config.js'; +import * as utils from 'src/utils.js'; +import {getRefererInfo} from 'src/refererDetection.js'; + +function createBidderRequest(auctionId, timeout, pageUrl) { + return { + auctionId: auctionId || 'c1243d83-0bed-4fdb-8c76-42b456be17d0', + timeout: timeout || 2000, + refererInfo: { + referer: pageUrl || 'example.com' + } + }; +} + +function createValidBidRequest(params, bidId, sizes) { + return { + adUnitCode: 'adunit-code', + bidId: bidId || '22c4871113f461', + bidder: 'kobler', + bidderRequestId: '15246a574e859f', + bidRequestsCount: 1, + bidderRequestsCount: 1, + mediaTypes: { + banner: { + sizes: sizes || [[300, 250], [320, 100]] + } + }, + params: params || { + placementId: 'tpw58278' + }, + transactionTd: '04314114-15bd-4638-8664-bdb8bdc60bff' + }; +} + +describe('KoblerAdapter', function () { + describe('inherited functions', function () { + it('exists and is a function', function () { + const adapter = newBidder(spec); + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + it('should not accept a request without bidId as valid', function () { + const bid = { + params: { + someParam: 'abc' + } + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.false; + }); + + it('should not accept a request without params as valid', function () { + const bid = { + bidId: 'e11768e8-3b71-4453-8698-0a2feb866589' + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.false; + }); + + it('should not accept a request without placementId as valid', function () { + const bid = { + bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', + params: { + someParam: 'abc' + } + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.false; + }); + + it('should accept a request with bidId and placementId as valid', function () { + const bid = { + bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', + params: { + someParam: 'abc', + placementId: '8bde0923-1409-4253-9594-495b58d931ba' + } + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.true; + }); + }); + + describe('buildRequests', function () { + it('should read data from bidder request', function () { + const testUrl = 'kobler.no'; + const auctionId = '8319af54-9795-4642-ba3a-6f57d6ff9100'; + const timeout = 5000; + const validBidRequests = [createValidBidRequest()]; + const bidderRequest = createBidderRequest(auctionId, timeout, testUrl); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + expect(openRtbRequest.tmax).to.be.equal(timeout); + expect(openRtbRequest.id).to.be.equal(auctionId); + expect(openRtbRequest.site.page).to.be.equal(testUrl); + }); + + it('should read data from valid bid requests', function () { + const firstSize = [400, 800]; + const secondSize = [450, 950]; + const sizes = [firstSize, secondSize]; + const placementId = 'tsjs86325'; + const bidId = '3a56a019-4835-4f75-811c-76fac6853a2c'; + const validBidRequests = [ + createValidBidRequest( + { + placementId: placementId + }, + bidId, + sizes + ) + ]; + const bidderRequest = createBidderRequest(); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + expect(openRtbRequest.imp.length).to.be.equal(1); + expect(openRtbRequest.imp[0].id).to.be.equal(bidId); + expect(openRtbRequest.imp[0].tagid).to.be.equal(placementId); + expect(openRtbRequest.imp[0].banner.w).to.be.equal(firstSize[0]); + expect(openRtbRequest.imp[0].banner.h).to.be.equal(firstSize[1]); + expect(openRtbRequest.imp[0].banner.format.length).to.be.equal(2); + expect(openRtbRequest.imp[0].banner.format[0].w).to.be.equal(firstSize[0]); + expect(openRtbRequest.imp[0].banner.format[0].h).to.be.equal(firstSize[1]); + expect(openRtbRequest.imp[0].banner.format[1].w).to.be.equal(secondSize[0]); + expect(openRtbRequest.imp[0].banner.format[1].h).to.be.equal(secondSize[1]); + }); + + it('should use 0x0 as default size', function () { + const validBidRequests = [ + createValidBidRequest( + undefined, + undefined, + [] + ) + ]; + const bidderRequest = createBidderRequest(); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + expect(openRtbRequest.imp.length).to.be.equal(1); + expect(openRtbRequest.imp[0].banner.w).to.be.equal(0); + expect(openRtbRequest.imp[0].banner.h).to.be.equal(0); + expect(openRtbRequest.imp[0].banner.format.length).to.be.equal(1); + expect(openRtbRequest.imp[0].banner.format[0].w).to.be.equal(0); + expect(openRtbRequest.imp[0].banner.format[0].h).to.be.equal(0); + }); + + it('should use 0 as default position', function () { + const validBidRequests = [createValidBidRequest()]; + const bidderRequest = createBidderRequest(); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + expect(openRtbRequest.imp.length).to.be.equal(1); + expect(openRtbRequest.imp[0].banner.ext.kobler.pos).to.be.equal(0); + }); + + it('should read zip from valid bid requests', function () { + const zip = '700 02'; + const validBidRequests = [ + createValidBidRequest( + { + placementId: 'nmah8324234', + zip: zip + } + ) + ]; + const bidderRequest = createBidderRequest(); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + expect(openRtbRequest.device.geo.zip).to.be.equal(zip); + }); + + it('should read test from valid bid requests', function () { + const validBidRequests = [ + createValidBidRequest( + { + placementId: 'zwop842799', + test: true + } + ) + ]; + const bidderRequest = createBidderRequest(); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + expect(openRtbRequest.test).to.be.equal(1); + }); + + it('should read floorPrice from valid bid requests', function () { + const floorPrice = 4.343; + const validBidRequests = [ + createValidBidRequest( + { + placementId: 'oqr3224234', + floorPrice: floorPrice + } + ) + ]; + const bidderRequest = createBidderRequest(); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + expect(openRtbRequest.imp.length).to.be.equal(1); + expect(openRtbRequest.imp[0].bidfloor).to.be.equal(floorPrice); + }); + + it('should read position from valid bid requests', function () { + const placementId = 'yzksf234592'; + const validBidRequests = [ + createValidBidRequest( + { + placementId: placementId, + position: 1 + } + ), + createValidBidRequest( + { + placementId: placementId, + position: 2 + } + ), + createValidBidRequest( + { + placementId: placementId, + position: 3 + } + ) + ]; + const bidderRequest = createBidderRequest(); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + expect(openRtbRequest.imp.length).to.be.equal(3); + expect(openRtbRequest.imp[0].banner.ext.kobler.pos).to.be.equal(1); + expect(openRtbRequest.imp[0].tagid).to.be.equal(placementId); + expect(openRtbRequest.imp[1].banner.ext.kobler.pos).to.be.equal(2); + expect(openRtbRequest.imp[1].tagid).to.be.equal(placementId); + expect(openRtbRequest.imp[2].banner.ext.kobler.pos).to.be.equal(3); + expect(openRtbRequest.imp[2].tagid).to.be.equal(placementId); + }); + + it('should read dealIds from valid bid requests', function () { + const dealIds1 = ['78214682234823']; + const dealIds2 = ['89913861235234', '27368423545328640']; + const validBidRequests = [ + createValidBidRequest( + { + placementId: 'rsl1239823', + dealIds: dealIds1 + } + ), + createValidBidRequest( + { + placementId: 'pqw234232', + dealIds: dealIds2 + } + ) + ]; + const bidderRequest = createBidderRequest(); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + expect(openRtbRequest.imp.length).to.be.equal(2); + expect(openRtbRequest.imp[0].pmp.deals.length).to.be.equal(1); + expect(openRtbRequest.imp[0].pmp.deals[0].id).to.be.equal(dealIds1[0]); + expect(openRtbRequest.imp[1].pmp.deals.length).to.be.equal(2); + expect(openRtbRequest.imp[1].pmp.deals[0].id).to.be.equal(dealIds2[0]); + expect(openRtbRequest.imp[1].pmp.deals[1].id).to.be.equal(dealIds2[1]); + }); + + it('should read timeout from config', function () { + const timeout = 4000; + const validBidRequests = [createValidBidRequest()]; + // No timeout field + const bidderRequest = { + auctionId: 'c1243d83-0bed-4fdb-8c76-42b456be17d0', + refererInfo: { + referer: 'example.com' + } + }; + config.setConfig({ + bidderTimeout: timeout + }); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + expect(openRtbRequest.tmax).to.be.equal(timeout); + }); + + it('should read floor price using floors module', function () { + const floorPriceFor580x400 = 6.5148; + const floorPriceForAnySize = 4.2343; + const validBidRequests = [ + createValidBidRequest(undefined, '98efe127-f926-4dde-b988-db8e5dba5a76', [[580, 400]]), + createValidBidRequest(undefined, 'c7698d4a-94f4-4a6b-a928-7e1facfbf752', []) + ]; + validBidRequests.forEach(validBidRequest => { + validBidRequest.getFloor = function (params) { + let floorPrice; + if (utils.isArray(params.size) && params.size[0] === 580 && params.size[1] === 400) { + floorPrice = floorPriceFor580x400; + } else if (params.size === '*') { + floorPrice = floorPriceForAnySize + } else { + floorPrice = 0 + } + return { + currency: params.currency, + floor: floorPrice + } + } + }) + const bidderRequest = createBidderRequest(); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + expect(openRtbRequest.imp.length).to.be.equal(2); + expect(openRtbRequest.imp[0].id).to.be.equal('98efe127-f926-4dde-b988-db8e5dba5a76'); + expect(openRtbRequest.imp[0].bidfloor).to.be.equal(floorPriceFor580x400); + expect(openRtbRequest.imp[1].id).to.be.equal('c7698d4a-94f4-4a6b-a928-7e1facfbf752'); + expect(openRtbRequest.imp[1].bidfloor).to.be.equal(floorPriceForAnySize); + }); + + it('should create whole OpenRTB request', function () { + const validBidRequests = [ + createValidBidRequest( + { + placementId: 'pcha322364', + zip: '0015', + floorPrice: 5.6234, + position: 1, + dealIds: ['623472534328234'] + }, + '953ee65d-d18a-484f-a840-d3056185a060', + [[400, 600]] + ), + createValidBidRequest( + { + placementId: 'sdfgoi32y4', + floorPrice: 3.2543, + position: 2, + dealIds: ['92368234753283', '263845832942'] + }, + '8320bf79-9d90-4a17-87c6-5d505706a921', + [[400, 500], [200, 250], [300, 350]] + ), + createValidBidRequest( + { + placementId: 'gwms2738647', + position: 3 + }, + 'd0de713b-32e3-4191-a2df-a007f08ffe72', + [[800, 900]] + ) + ]; + const bidderRequest = createBidderRequest( + '9ff580cf-e10e-4b66-add7-40ac0c804e21', + 4500, + 'bid.kobler.no' + ); + + const result = spec.buildRequests(validBidRequests, bidderRequest); + const openRtbRequest = JSON.parse(result.data); + + const expectedOpenRtbRequest = { + id: '9ff580cf-e10e-4b66-add7-40ac0c804e21', + at: 1, + tmax: 4500, + cur: ['USD'], + imp: [ + { + id: '953ee65d-d18a-484f-a840-d3056185a060', + banner: { + format: [ + { + w: 400, + h: 600 + } + ], + w: 400, + h: 600, + ext: { + kobler: { + pos: 1 + } + } + }, + tagid: 'pcha322364', + bidfloor: 5.6234, + bidfloorcur: 'USD', + pmp: { + deals: [ + { + id: '623472534328234' + } + ] + } + }, + { + id: '8320bf79-9d90-4a17-87c6-5d505706a921', + banner: { + format: [ + { + w: 400, + h: 500 + }, + { + w: 200, + h: 250 + }, + { + w: 300, + h: 350 + } + ], + w: 400, + h: 500, + ext: { + kobler: { + pos: 2 + } + } + }, + tagid: 'sdfgoi32y4', + bidfloor: 3.2543, + bidfloorcur: 'USD', + pmp: { + deals: [ + { + id: '92368234753283' + }, + { + id: '263845832942' + } + ] + } + }, + { + id: 'd0de713b-32e3-4191-a2df-a007f08ffe72', + banner: { + format: [ + { + w: 800, + h: 900 + } + ], + w: 800, + h: 900, + ext: { + kobler: { + pos: 3 + } + } + }, + tagid: 'gwms2738647', + bidfloor: 0, + bidfloorcur: 'USD', + pmp: {} + } + ], + device: { + devicetype: 2, + geo: { + zip: '0015' + } + }, + site: { + page: 'bid.kobler.no' + }, + test: 0 + }; + + expect(openRtbRequest).to.deep.equal(expectedOpenRtbRequest); + }); + }); + + describe('interpretResponse', function () { + it('should handle empty body', function () { + const responseWithEmptyBody = { + body: undefined + }; + const bids = spec.interpretResponse(responseWithEmptyBody) + + expect(bids.length).to.be.equal(0); + }); + + it('should generate bids from OpenRTB response', function () { + const responseWithTwoBids = { + body: { + seatbid: [ + { + bid: [ + { + impid: '6194ddef-89a4-404f-9efd-6b718fc23308', + price: 7.981, + nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=${AUCTION_PRICE}&asp=${AD_SERVER_PRICE}', + crid: 'edea9b03-3a57-41aa-9c00-abd673e22006', + dealid: '', + w: 320, + h: 250, + adm: '', + adomain: [ + 'https://kobler.no' + ] + }, + { + impid: '2ec0b40f-d3ca-4ba5-8ce3-48290565690f', + price: 6.71234, + nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=nbashgufvishdafjk23432&sp=${AUCTION_PRICE}&asp=${AD_SERVER_PRICE}', + crid: 'fa2d5af7-2678-4204-9023-44c526160742', + dealid: '2783483223432342', + w: 580, + h: 400, + adm: '', + adomain: [ + 'https://bid.kobler.no' + ] + } + ] + } + ], + cur: 'USD' + } + }; + const bids = spec.interpretResponse(responseWithTwoBids) + + const expectedBids = [ + { + requestId: '6194ddef-89a4-404f-9efd-6b718fc23308', + cpm: 7.981, + currency: 'USD', + width: 320, + height: 250, + creativeId: 'edea9b03-3a57-41aa-9c00-abd673e22006', + dealId: '', + netRevenue: true, + ttl: 600, + ad: '', + nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=${AUCTION_PRICE}&asp=${AD_SERVER_PRICE}', + meta: { + advertiserDomains: [ + 'https://kobler.no' + ] + } + }, + { + requestId: '2ec0b40f-d3ca-4ba5-8ce3-48290565690f', + cpm: 6.71234, + currency: 'USD', + width: 580, + height: 400, + creativeId: 'fa2d5af7-2678-4204-9023-44c526160742', + dealId: '2783483223432342', + netRevenue: true, + ttl: 600, + ad: '', + nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=nbashgufvishdafjk23432&sp=${AUCTION_PRICE}&asp=${AD_SERVER_PRICE}', + meta: { + advertiserDomains: [ + 'https://bid.kobler.no' + ] + } + } + ]; + expect(bids).to.deep.equal(expectedBids); + }); + }); + + describe('onBidWon', function () { + beforeEach(function () { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function () { + utils.triggerPixel.restore(); + }); + + it('Should not trigger pixel if bid does not contain nurl', function () { + spec.onBidWon({}); + + expect(utils.triggerPixel.called).to.be.false; + }); + + it('Should not trigger pixel if nurl is empty', function () { + spec.onBidWon({ + nurl: '' + }); + + expect(utils.triggerPixel.called).to.be.false; + }); + + it('Should trigger pixel with replaced nurl if nurl is not empty', function () { + spec.onBidWon({ + cpm: 8.341, + nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=${AUCTION_PRICE}&asp=${AD_SERVER_PRICE}', + adserverTargeting: { + hb_pb: 8 + } + }); + + expect(utils.triggerPixel.callCount).to.be.equal(1); + expect(utils.triggerPixel.firstCall.args[0]).to.be.equal( + 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=8.341&asp=8' + ); + }); + }); + + describe('onTimeout', function () { + beforeEach(function () { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function () { + utils.triggerPixel.restore(); + }); + + it('Should not trigger pixel if timeout data is not array', function () { + spec.onTimeout(null); + + expect(utils.triggerPixel.called).to.be.false; + }); + + it('Should not trigger pixel if timeout data is empty', function () { + spec.onTimeout([]); + + expect(utils.triggerPixel.called).to.be.false; + }); + + it('Should trigger pixel with query parameters if timeout data not empty', function () { + spec.onTimeout([ + { + adUnitCode: 'adunit-code', + auctionId: 'a1fba829-dd41-409f-acfb-b7b0ac5f30c6', + bidId: 'ef236c6c-e934-406b-a877-d7be8e8a839a', + timeout: 100, + params: [ + { + placementId: 'xrwg62731', + } + ], + }, + { + adUnitCode: 'adunit-code-2', + auctionId: 'a1fba829-dd41-409f-acfb-b7b0ac5f30c6', + bidId: 'ca4121c8-9a4a-46ba-a624-e9b64af206f2', + timeout: 100, + params: [ + { + placementId: 'bc482234', + } + ], + } + ]); + + expect(utils.triggerPixel.callCount).to.be.equal(2); + expect(utils.triggerPixel.getCall(0).args[0]).to.be.equal( + 'https://bid.essrtb.com/notify/prebid_timeout?ad_unit_code=adunit-code&' + + 'auction_id=a1fba829-dd41-409f-acfb-b7b0ac5f30c6&bid_id=ef236c6c-e934-406b-a877-d7be8e8a839a&timeout=100&' + + 'placement_id=xrwg62731&page_url=' + encodeURIComponent(getRefererInfo().referer) + ); + expect(utils.triggerPixel.getCall(1).args[0]).to.be.equal( + 'https://bid.essrtb.com/notify/prebid_timeout?ad_unit_code=adunit-code-2&' + + 'auction_id=a1fba829-dd41-409f-acfb-b7b0ac5f30c6&bid_id=ca4121c8-9a4a-46ba-a624-e9b64af206f2&timeout=100&' + + 'placement_id=bc482234&page_url=' + encodeURIComponent(getRefererInfo().referer) + ); + }); + }); +}); From e23cb2cdbdfefd32c1ba18c73a037f04a19d8e3c Mon Sep 17 00:00:00 2001 From: wojciech-bialy-wpm <67895844+wojciech-bialy-wpm@users.noreply.github.com> Date: Wed, 21 Apr 2021 16:41:06 +0200 Subject: [PATCH 076/303] sspBC Bid Adapter: update to v4.8, bugfixes, & support for sending params.publisherId (#6575) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add sspbc adapter * tests for sspbc adapter * sspBC adapter v4.5: set correct creativeId, add adomain to bid.meta, set test mode in adexchange, read site SN from bid response * sspBC adapter v4.5: set meta.advertiserDomains, update test to expect bid.meta * sspBC Adapter: add ajax tests (test ad with & without gdpr) * sspBC Adapter: remove ajax tests * Update adapter to v4.6 Update adapter to v4.6 - add notification endpoint - send bidWon and onTimeout notifications - send CMP version to user sync endpoint * Remove console logs for notification events * Change payload data in onTimeout event * Update tests for sspBC adapter Update tests for sspBC adapter: - add onBidWon test - add onTimeout test - alter getUserSyncs test * Update sspBC adapter to v4.7; enable oneCodeId mode; change module name to ensure combatibility with prebid.org downloader * sspBc adapter: Bug fixes in v4.7 - change notification format, fix oneCode detection data, convert slot number to int * sspbc adapter: fix creating bid.crid, when not present in server response * sspbc adapter: add publisher id to payload * sspbc adapter: fix onecode issues (when bid.params is present, but incomplete) * sspbc adapter: code cleanup * sspbc adapter: ver up (4.8) * sspbc-adapter: update doc * [sspbc-adapter] update test settings Co-authored-by: Wojciech Biały --- modules/sspBCBidAdapter.js | 77 +++++++++++++++++++++++++------------- modules/sspBCBidAdapter.md | 13 +++---- 2 files changed, 58 insertions(+), 32 deletions(-) diff --git a/modules/sspBCBidAdapter.js b/modules/sspBCBidAdapter.js index b6e5b88e0f4..41191b3123a 100644 --- a/modules/sspBCBidAdapter.js +++ b/modules/sspBCBidAdapter.js @@ -2,14 +2,13 @@ import * as utils from '../src/utils.js'; import { ajax } from '../src/ajax.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER } from '../src/mediaTypes.js'; -import strIncludes from 'core-js-pure/features/string/includes.js'; const BIDDER_CODE = 'sspBC'; const BIDDER_URL = 'https://ssp.wp.pl/bidder/'; const SYNC_URL = 'https://ssp.wp.pl/bidder/usersync'; const NOTIFY_URL = 'https://ssp.wp.pl/bidder/notify'; const TMAX = 450; -const BIDDER_VERSION = '4.7'; +const BIDDER_VERSION = '4.8'; const W = window; const { navigator } = W; const oneCodeDetection = {}; @@ -151,11 +150,13 @@ function mapBanner(slot) { } function mapImpression(slot) { + const { adUnitCode, bidId, params } = slot; + const { id, siteId } = params || {}; const imp = { - id: (slot.params && slot.params.id) ? slot.params.id : 'bidid-' + slot.bidId, + id: id && siteId ? id : 'bidid-' + bidId, banner: mapBanner(slot), /* native: mapNative(slot), */ - tagid: slot.adUnitCode, + tagid: adUnitCode, }; const bidfloor = (slot.params && slot.params.bidFloor) ? parseFloat(slot.params.bidFloor) : undefined; @@ -255,6 +256,7 @@ const spec = { } const siteId = setOnAny(validBidRequests, 'params.siteId'); + const publisherId = setOnAny(validBidRequests, 'params.publisherId'); const page = setOnAny(validBidRequests, 'params.page') || bidderRequest.refererInfo.referer; const domain = setOnAny(validBidRequests, 'params.domain') || utils.parseUrl(page).hostname; const tmax = setOnAny(validBidRequests, 'params.tmax') ? parseInt(setOnAny(validBidRequests, 'params.tmax'), 10) : TMAX; @@ -270,7 +272,13 @@ const spec = { const payload = { id: bidderRequest.auctionId, - site: { id: siteId, page, domain, ref }, + site: { + id: siteId, + publisher: publisherId ? { id: publisherId } : undefined, + page, + domain, + ref + }, imp: validBidRequests.map(slot => mapImpression(slot)), tmax, user: {}, @@ -290,6 +298,7 @@ const spec = { }, interpretResponse(serverResponse, request) { + const { bidderRequest } = request; const response = serverResponse.body; const bids = []; const site = JSON.parse(request.data).site; // get page and referer data from request @@ -297,50 +306,68 @@ const spec = { let seat; if (response.seatbid !== undefined) { + /* + Match response to request, by comparing bid id's + 'bidid-' prefix indicates oneCode (parameterless) request and response + */ response.seatbid.forEach(seatbid => { seat = seatbid.seat; seatbid.bid.forEach(serverBid => { - const bidRequest = request.bidderRequest.bids.filter(b => { - const bidId = b.params ? b.params.id : 'bidid-' + b.bidId; - return bidId === serverBid.impid; + // get data from bid response + const { adomain, crid, impid, exp, ext, price, w, h } = serverBid; + + const bidRequest = bidderRequest.bids.filter(b => { + const { bidId, params } = b; + const { id, siteId } = params || {}; + const currentBidId = id && siteId ? id : 'bidid-' + bidId; + return currentBidId === impid; })[0]; - site.slot = bidRequest && bidRequest.params ? bidRequest.params.slotid : undefined; - if (serverBid.ext) { + // get data from linked bidRequest + const { bidId, params } = bidRequest || {}; + + // get slot id for current bid + site.slot = params && params.id; + + if (ext) { /* bid response might include ext object containing siteId / slotId, as detected by OneCode update site / slot data in this case */ - site.id = serverBid.ext.siteid || site.id; - site.slot = serverBid.ext.slotid || site.slot; + const { siteid, slotid } = ext; + site.id = siteid || site.id; + site.slot = slotid || site.slot; } - if (bidRequest && site.id && !strIncludes(site.id, 'bidid')) { - // store site data for future notification - oneCodeDetection[bidRequest.bidId] = [site.id, site.slot]; + if (bidRequest && site.id && !site.id.includes('bidid')) { + // found a matching request; add this bid - const bidFloor = (bidRequest.params && bidRequest.params.bidFloor) ? bidRequest.params.bidFloor : 0; + // store site data for future notification + oneCodeDetection[bidId] = [site.id, site.slot]; const bid = { - requestId: bidRequest.bidId, - creativeId: serverBid.crid || 'mcad_' + request.bidderRequest.auctionId + '_' + request.bidderRequest.params.id, - cpm: serverBid.price, + requestId: bidId, + creativeId: crid || 'mcad_' + bidderRequest.auctionId + '_' + site.slot, + cpm: price, currency: response.cur, - ttl: serverBid.exp || 300, - width: serverBid.w, - height: serverBid.h, + ttl: exp || 300, + width: w, + height: h, bidderCode: BIDDER_CODE, mediaType: 'banner', meta: { - advertiserDomains: serverBid.adomain, + advertiserDomains: adomain, networkName: seat, }, netRevenue: true, - ad: renderCreative(site, response.id, serverBid, seat, request.bidderRequest), + ad: renderCreative(site, response.id, serverBid, seat, bidderRequest), }; if (bid.cpm > 0) { - if (bid.cpm >= bidFloor) { + // check bidFloor (if present in params) + const { bidFloor } = params || {}; + + if (!bidFloor || bid.cpm >= bidFloor) { bids.push(bid); } else { utils.logWarn('Discarding bid due to bidFloor setting', bid.cpm, bidFloor); diff --git a/modules/sspBCBidAdapter.md b/modules/sspBCBidAdapter.md index 67a2ba1c7ba..f22e8e6c458 100644 --- a/modules/sspBCBidAdapter.md +++ b/modules/sspBCBidAdapter.md @@ -16,10 +16,12 @@ Required parameters: Optional parameters: - site id - adslot id +- publisher id - domain - page - tmax - bidFloor +- test # Test Parameters ``` @@ -29,18 +31,15 @@ var adUnits = [ code: 'banner-div', mediaTypes: { banner: { - sizes: [[300, 250], [300,600]] + sizes: [[300, 250]] } }, bids: [{ bidder: 'sspBC', params: { - id: '006', // optional - siteId: '235911', // optional - domain: 'somesite.pl', // optional - page: 'somesite.pl/somepage.html', // optional - tmax: 250, // optional - bidFloor: 0.1 // optional + id: "006", + siteId: "235911", + test: 1 } }] } From ae44f9e483e73c73466e22bce3146539cd7d8ced Mon Sep 17 00:00:00 2001 From: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Date: Wed, 21 Apr 2021 21:31:06 -0400 Subject: [PATCH 077/303] Create module registry: update build to add installModules array to pbjs global (#6601) * - Remove module list comment on build - Add pbjs.installedModules with macro to prebid.js - Update gruntfile to replace macro with module array (if empty array all modules included)) * Removed unused code * Removed comma * Recommitting changes * Updated regex to look for either '|" in macro name. Seems there is a difference between dev/prod --- gulpfile.js | 13 ++++++++++--- src/prebid.js | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index ac8b8c2dcd5..9bf378779d1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -31,7 +31,7 @@ const execa = require('execa'); var prebid = require('./package.json'); var dateString = 'Updated : ' + (new Date()).toISOString().substring(0, 10); -var banner = '/* <%= prebid.name %> v<%= prebid.version %>\n' + dateString + '\nModules: <%= modules %> */\n'; +var banner = '/* <%= prebid.name %> v<%= prebid.version %>\n' + dateString + '*/\n'; var port = 9999; const FAKE_SERVER_HOST = argv.host ? argv.host : 'localhost'; const FAKE_SERVER_PORT = 4444; @@ -134,6 +134,12 @@ function watch(done) { done(); }; +function makeModuleList(modules) { + return modules.map(module => { + return '"' + module + '"' + }); +} + function makeDevpackPkg() { var cloned = _.cloneDeep(webpackConfig); cloned.devtool = 'source-map'; @@ -145,6 +151,7 @@ function makeDevpackPkg() { return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js')) .pipe(helpers.nameModules(externalModules)) .pipe(webpackStream(cloned, webpack)) + .pipe(replace(/('|")v\$prebid\.modulesList\$('|")/g, makeModuleList(externalModules))) .pipe(gulp.dest('build/dev')) .pipe(connect.reload()); } @@ -157,13 +164,13 @@ function makeWebpackPkg() { const analyticsSources = helpers.getAnalyticsSources(); const moduleSources = helpers.getModulePaths(externalModules); - const modulesString = getModulesListToAddInBanner(externalModules); return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js')) .pipe(helpers.nameModules(externalModules)) .pipe(webpackStream(cloned, webpack)) .pipe(uglify()) - .pipe(gulpif(file => file.basename === 'prebid-core.js', header(banner, { prebid: prebid, modules: modulesString }))) + .pipe(replace(/('|")v\$prebid\.modulesList\$('|")/g, makeModuleList(externalModules))) + .pipe(gulpif(file => file.basename === 'prebid-core.js', header(banner, { prebid: prebid}))) .pipe(gulp.dest('build/dist')); } diff --git a/src/prebid.js b/src/prebid.js index 8c5e465174f..2211e8ec2b5 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -43,6 +43,9 @@ $$PREBID_GLOBAL$$.libLoaded = true; $$PREBID_GLOBAL$$.version = 'v$prebid.version$'; utils.logInfo('Prebid.js v$prebid.version$ loaded'); +// modules list generated from build +$$PREBID_GLOBAL$$.installedModules = ['v$prebid.modulesList$']; + // create adUnit array $$PREBID_GLOBAL$$.adUnits = $$PREBID_GLOBAL$$.adUnits || []; From 3356e38690ee261953d7e33c49329829b344c639 Mon Sep 17 00:00:00 2001 From: pratik-synacor <64602199+pratik-synacor@users.noreply.github.com> Date: Thu, 22 Apr 2021 16:31:38 +0530 Subject: [PATCH 078/303] SynacorMedia Bid Adapter: Create bid.params.video object if it's not already present on the video request since it's an optional property (#6637) --- modules/synacormediaBidAdapter.js | 3 ++ .../modules/synacormediaBidAdapter_spec.js | 44 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/modules/synacormediaBidAdapter.js b/modules/synacormediaBidAdapter.js index d14fee67b23..aaff637c790 100644 --- a/modules/synacormediaBidAdapter.js +++ b/modules/synacormediaBidAdapter.js @@ -157,6 +157,9 @@ export const spec = { pos }; if (bid.mediaTypes.video) { + if (!bid.params.video) { + bid.params.video = {}; + } this.setValidVideoParams(bid.mediaTypes.video, bid.params.video); } if (bid.params.video) { diff --git a/test/spec/modules/synacormediaBidAdapter_spec.js b/test/spec/modules/synacormediaBidAdapter_spec.js index 2ead2fb689e..688f1c2c090 100644 --- a/test/spec/modules/synacormediaBidAdapter_spec.js +++ b/test/spec/modules/synacormediaBidAdapter_spec.js @@ -576,6 +576,50 @@ describe('synacormediaBidAdapter ', function () { } ]); }); + it('should create params.video object if not present on bid request and move any video params in the mediaTypes object to it', function () { + let validBidRequestVideo = { + bidder: 'synacormedia', + params: { + seatId: 'prebid', + tagId: '1234' + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [[ 640, 480 ]], + startdelay: 1, + linearity: 1, + placement: 1, + mimes: ['video/mp4'] + } + }, + adUnitCode: 'video1', + transactionId: '93e5def8-29aa-4fe8-bd3a-0298c39f189a', + sizes: [[ 640, 480 ]], + bidId: '2624fabbb078e8', + bidderRequestId: '117954d20d7c9c', + auctionId: 'defd525f-4f1e-4416-a4cb-ae53be90e706', + src: 'client', + bidRequestsCount: 1 + }; + + let req = spec.buildRequests([validBidRequestVideo], bidderRequest); + expect(req.data.imp).to.eql([ + { + video: { + h: 480, + pos: 0, + w: 640, + startdelay: 1, + linearity: 1, + placement: 1, + mimes: ['video/mp4'] + }, + id: 'v2624fabbb078e8-640x480', + tagid: '1234', + } + ]); + }); it('should contain the CCPA privacy string when UspConsent is in bidder request', function () { // banner test let req = spec.buildRequests([validBidRequest], bidderRequestWithCCPA); From b65a567d8f5ad0c11cafee1651d9723ea231d832 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 22 Apr 2021 07:12:22 -0400 Subject: [PATCH 079/303] Prebid Core: Readme.md import name change (#6638) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Delete iasBidAdapter.js * Add files via upload * Update README.md * Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d87b70710b7..23fc8342bc5 100644 --- a/README.md +++ b/README.md @@ -93,12 +93,12 @@ Or for Babel 6: Then you can use Prebid.js as any other npm depedendency ```javascript -import prebid from 'prebid.js'; +import pbjs from 'prebid.js'; import 'prebid.js/modules/rubiconBidAdapter'; // imported modules will register themselves automatically with prebid import 'prebid.js/modules/appnexusBidAdapter'; -prebid.processQueue(); // required to process existing pbjs.queue blocks and setup any further pbjs.queue execution +pbjs.processQueue(); // required to process existing pbjs.queue blocks and setup any further pbjs.queue execution -prebid.requestBids({ +pbjs.requestBids({ ... }) From 08b7e8db877a33ef880f417d271a102f3fff41ae Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 22 Apr 2021 07:19:37 -0400 Subject: [PATCH 080/303] PBS Bid Adapter: Stop overriding s2sconfig.enabled from vendor defaults (#6622) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Delete iasBidAdapter.js * Add files via upload * Update index.js --- modules/prebidServerBidAdapter/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index ff326f25840..1649733997d 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -89,7 +89,7 @@ config.setDefaults({ * @return {boolean} */ function updateConfigDefaultVendor(option) { - if (option.defaultVendor) { + if (option.defaultVendor && option.enabled !== false) { let vendor = option.defaultVendor; let optionKeys = Object.keys(option); if (S2S_VENDORS[vendor]) { From f870a084213857f27b280ce9cda82df7f387751e Mon Sep 17 00:00:00 2001 From: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Date: Thu, 22 Apr 2021 07:25:30 -0400 Subject: [PATCH 081/303] RP Bid Adapter: Bug fix for parsing ortb2.user.data (#6643) * Bug fix when parsing FPD data. Check for taxonomyname existence prior to match * Lint check --- modules/rubiconBidAdapter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index be71028f3ad..86e6525af85 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -904,7 +904,8 @@ function applyFPD(bidRequest, mediaType, data) { const MAP = {user: 'tg_v.', site: 'tg_i.', adserver: 'tg_i.dfp_ad_unit_code', pbadslot: 'tg_i.pbadslot', keywords: 'kw'}; const validate = function(prop, key) { if (key === 'data' && Array.isArray(prop)) { - return prop.filter(name => name.segment && utils.deepAccess(name, 'ext.taxonomyname').match(/iab/i)).map(value => { + return prop.filter(name => name.segment && utils.deepAccess(name, 'ext.taxonomyname') && + utils.deepAccess(name, 'ext.taxonomyname').match(/iab/i)).map(value => { let segments = value.segment.filter(obj => obj.id).reduce((result, obj) => { result.push(obj.id); return result; From 3ea23dc093246c40041bdaa3a8a1590481691fd7 Mon Sep 17 00:00:00 2001 From: Fridoom007 Date: Thu, 22 Apr 2021 18:05:14 +0300 Subject: [PATCH 082/303] AdRiver Bid Adapter: add new bid adapter (#6514) * AdRiver Bid Adapter: initial prebid.js integration * Added AdRiver Bid Adapter * AdRiver Bid Adapter: update getting floor, via getFloor() * Added internal method _getFloor() * Update test for getFloor() * Remove old currency logic * AdRiver Bid Adapter: update adriverBidAdapter.md * Delete old test parameters * AdRiver Bid Adapter: add meta.advertiserDomains * Added parameter meta.advertiserDomains to interpretResponse * Update test for meta.advertiserDomains --- modules/adriverBidAdapter.js | 188 ++++++++++++ modules/adriverBidAdapter.md | 20 ++ test/spec/modules/adriverBidAdapter_spec.js | 323 ++++++++++++++++++++ 3 files changed, 531 insertions(+) create mode 100644 modules/adriverBidAdapter.js create mode 100644 modules/adriverBidAdapter.md create mode 100644 test/spec/modules/adriverBidAdapter_spec.js diff --git a/modules/adriverBidAdapter.js b/modules/adriverBidAdapter.js new file mode 100644 index 00000000000..af0a401b355 --- /dev/null +++ b/modules/adriverBidAdapter.js @@ -0,0 +1,188 @@ +// ADRIVER BID ADAPTER for Prebid 1.13 +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'adriver'; +const ADRIVER_BID_URL = 'https://pb.adriver.ru/cgi-bin/bid.cgi'; +const TIME_TO_LIVE = 3000; + +export const spec = { + + code: BIDDER_CODE, + + /** + * Determines whether or not the given bid request is valid. + * + * @param {object} bid The bid to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + return !!bid.params.siteid; + }, + + buildRequests: function (validBidRequests) { + utils.logInfo('validBidRequests', validBidRequests); + + let win = utils.getWindowLocation(); + let customID = Math.round(Math.random() * 999999999) + '-' + Math.round(new Date() / 1000) + '-1-46-'; + let siteId = utils.getBidIdParameter('siteid', validBidRequests[0].params) + ''; + let currency = utils.getBidIdParameter('currency', validBidRequests[0].params); + currency = 'RUB'; + + const payload = { + 'at': 1, + 'cur': [currency], + 'site': { + 'name': win.origin, + 'domain': win.hostname, + 'id': siteId, + 'page': win.href + }, + 'id': customID, + 'user': { + 'buyerid': 0 + }, + 'device': { + 'ip': '195.209.111.14', + 'ua': window.navigator.userAgent + }, + 'imp': [] + }; + + utils._each(validBidRequests, (bid) => { + utils._each(bid.sizes, (sizes) => { + let width; + let height; + let par; + + let floorAndCurrency = _getFloor(bid, currency, sizes); + + let bidFloor = floorAndCurrency.floor; + let dealId = utils.getBidIdParameter('dealid', bid.params); + if (typeof sizes[0] === 'number' && typeof sizes[1] === 'number') { + width = sizes[0]; + height = sizes[1]; + } + par = { + 'id': bid.params.placementId, + 'ext': {'query': 'bn=15&custom=111=' + bid.bidId}, + 'banner': { + 'w': width || undefined, + 'h': height || undefined + }, + 'bidfloor': bidFloor || 0, + 'bidfloorcur': floorAndCurrency.currency, + 'secure': 0 + }; + if (dealId) { + par.pmp = { + 'private_auction': 1, + 'deals': [{ + 'id': dealId, + 'bidfloor': bidFloor || 0, + 'bidfloorcur': currency + }] + }; + } + utils.logInfo('par', par); + payload.imp.push(par); + }); + }); + + const payloadString = JSON.stringify(payload); + + return { + method: 'POST', + url: ADRIVER_BID_URL, + data: payloadString, + }; + }, + + interpretResponse: function (serverResponse, bidRequest) { + utils.logInfo('serverResponse.body.seatbid', serverResponse.body.seatbid); + const bidResponses = []; + let nurl = 0; + utils._each(serverResponse.body.seatbid, (seatbid) => { + utils.logInfo('_each', seatbid); + var bid = seatbid.bid[0]; + if (bid.nurl !== undefined) { + nurl = bid.nurl.split('://'); + nurl = window.location.protocol + '//' + nurl[1]; + nurl = nurl.replace(/\$\{AUCTION_PRICE\}/, bid.price); + } + + if (bid.price >= 0 && bid.impid !== undefined && nurl !== 0 && bid.dealid === undefined) { + let bidResponse = { + requestId: bid.ext || undefined, + cpm: bid.price, + width: bid.w, + height: bid.h, + creativeId: bid.impid || undefined, + currency: serverResponse.body.cur, + netRevenue: true, + ttl: TIME_TO_LIVE, + meta: { + advertiserDomains: bid.adomain + }, + ad: '' + }; + utils.logInfo('bidResponse', bidResponse); + bidResponses.push(bidResponse); + } + }); + return bidResponses; + } + +}; +registerBidder(spec); + +/** + * Gets bidfloor + * @param {Object} bid + * @param currencyPar + * @param sizes + * @returns {Object} floor + */ +function _getFloor(bid, currencyPar, sizes) { + const curMediaType = bid.mediaTypes && bid.mediaTypes.video ? 'video' : 'banner'; + let floor = 0; + const currency = currencyPar || 'RUB'; + + let currencyResult = ''; + + let isSize = false; + + if (typeof sizes[0] === 'number' && typeof sizes[1] === 'number') { + isSize = true; + } + + if (typeof bid.getFloor === 'function') { + const floorInfo = bid.getFloor({ + currency: currency, + mediaType: curMediaType, + size: isSize ? sizes : '*' + }); + + if (typeof floorInfo === 'object' && + !isNaN(parseFloat(floorInfo.floor))) { + floor = floorInfo.floor; + } + + if (typeof floorInfo === 'object' && floorInfo.currency) { + currencyResult = floorInfo.currency; + } + } + + if (!currencyResult) { + currencyResult = currency; + } + + if (floor == null) { + floor = 0; + } + + return { + floor: floor, + currency: currencyResult + }; +} diff --git a/modules/adriverBidAdapter.md b/modules/adriverBidAdapter.md new file mode 100644 index 00000000000..e5a8af28647 --- /dev/null +++ b/modules/adriverBidAdapter.md @@ -0,0 +1,20 @@ +# Overview + +Module Name: AdRiver Bidder Adapter +Module Type: Bidder Adapter +Maintainer: support@adriver.ru + +# Description + +Module that connects to AdRiver's demand sources. + +# Test Parameters + +bids: [{ + bidder: 'adriver', + params: { + siteid: '216200', + placementId: '55:test_placement', + dealid: 'dealidTest' + } +}] diff --git a/test/spec/modules/adriverBidAdapter_spec.js b/test/spec/modules/adriverBidAdapter_spec.js new file mode 100644 index 00000000000..c16bc5df5cb --- /dev/null +++ b/test/spec/modules/adriverBidAdapter_spec.js @@ -0,0 +1,323 @@ +import { expect } from 'chai'; +import { spec } from 'modules/adriverBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as bidderFactory from 'src/adapters/bidderFactory.js'; +import { auctionManager } from 'src/auctionManager.js'; +const ENDPOINT = 'https://pb.adriver.ru/cgi-bin/bid.cgi'; + +describe('adriverAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'adriver', + 'params': { + 'placementId': '55:test_placement', + 'siteid': 'testSiteID' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600], [300, 250]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + }); + + describe('buildRequests', function () { + let getAdUnitsStub; + const floor = 3; + + let bidRequests = [ + { + 'bidder': 'adriver', + 'params': { + 'placementId': '55:test_placement', + 'siteid': 'testSiteID', + 'dealid': 'dealidTest' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600], [300, 250]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'transactionId': '04f2659e-c005-4eb1-a57c-fa93145e3843' + } + ]; + + let floorTestData = { + 'currency': 'USD', + 'floor': floor + }; + bidRequests[0].getFloor = _ => { + return floorTestData; + }; + + beforeEach(function() { + getAdUnitsStub = sinon.stub(auctionManager, 'getAdUnits').callsFake(function() { + return []; + }); + }); + + afterEach(function() { + getAdUnitsStub.restore(); + }); + + it('should exist currency', function () { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + + expect(payload.cur).to.exist; + }); + + it('should exist at', function () { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + + expect(payload.at).to.exist; + expect(payload.at).to.deep.equal(1); + }); + + it('should parse imp', function () { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + + expect(payload.imp[0]).to.exist; + expect(payload.imp[0].id).to.deep.equal('55:test_placement'); + + expect(payload.imp[0].ext).to.exist; + expect(payload.imp[0].ext.query).to.deep.equal('bn=15&custom=111=' + '30b31c1838de1e'); + + expect(payload.imp[0].banner).to.exist; + expect(payload.imp[0].banner.w).to.deep.equal(300); + expect(payload.imp[0].banner.h).to.deep.equal(250); + }); + + it('should parse pmp', function () { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + + expect(payload.imp[0].pmp).to.exist; + + expect(payload.imp[0].pmp.deals).to.exist; + + expect(payload.imp[0].pmp.deals[0].bidfloor).to.exist; + expect(payload.imp[0].pmp.deals[0].bidfloor).to.deep.equal(3); + + expect(payload.imp[0].pmp.deals[0].bidfloorcur).to.exist; + expect(payload.imp[0].pmp.deals[0].bidfloorcur).to.deep.equal('RUB'); + }); + + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests); + expect(request.url).to.equal(ENDPOINT); + expect(request.method).to.equal('POST'); + }); + }); + + describe('interpretResponse', function () { + let bfStub; + before(function() { + bfStub = sinon.stub(bidderFactory, 'getIabSubCategory'); + }); + + after(function() { + bfStub.restore(); + }); + + let response = { + 'id': '221594457-1615288400-1-46-', + 'bidid': 'D8JW8XU8-L5m7qFMNQGs7i1gcuPvYMEDOKsktw6e9uLy5Eebo9HftVXb0VpKj4R2dXa93i6QmRhjextJVM4y1SqodMAh5vFOb_eVkHA', + 'seatbid': [{ + 'bid': [{ + 'id': '1', + 'impid': '/19968336/header-bid-tag-0', + 'price': 4.29, + 'h': 250, + 'w': 300, + 'adid': '7121351', + 'adomain': ['http://ikea.com'], + 'nurl': 'https://ad.adriver.ru/cgi-bin/erle.cgi?expid=D8JW8XU8-L5m7qFMNQGs7i1gcuPvYMEDOKsktw6e9uLy5Eebo9HftVXb0VpKj4R2dXa93i6QmRhjextJVM4y1SqodMAh5vFOb_eVkHA&bid=7121351&wprc=4.29&tuid=-1&custom=207=/19968336/header-bid-tag-0', + 'cid': '717570', + 'ext': '2c262a7058758d' + }] + }, { + 'bid': [{ + 'id': '1', + 'impid': '/19968336/header-bid-tag-0', + 'price': 17.67, + 'h': 600, + 'w': 300, + 'adid': '7121369', + 'adomain': ['http://ikea.com'], + 'nurl': 'https://ad.adriver.ru/cgi-bin/erle.cgi?expid=DdtToXX5cpTaMMxrJSEsOsUIXt3WmC3jOvuNI5DguDrY8edFG60Jg1M-iMkVNKQ4OiAdHSLPJLQQXMUXZfI9VbjMoGCb-zzOTPiMpshI&bid=7121369&wprc=17.67&tuid=-1&custom=207=/19968336/header-bid-tag-0', + 'cid': '717570', + 'ext': '2c262a7058758d' + }] + }], + 'cur': 'RUB' + }; + + it('should get correct bid response', function () { + let expectedResponse = [ + { + requestId: '2c262a7058758d', + cpm: 4.29, + width: 300, + height: 250, + creativeId: '/19968336/header-bid-tag-0', + currency: 'RUB', + netRevenue: true, + ttl: 3000, + meta: { + advertiserDomains: ['http://ikea.com'] + }, + ad: '' + } + ]; + let bidderRequest = { + bids: [{ + bidId: '3db3773286ee59', + adUnitCode: 'code' + }] + }; + let result = spec.interpretResponse({ body: response }, {bidderRequest}); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + }); + + it('handles nobid responses', function () { + let response = { + 'version': '0.0.1', + 'tags': [{ + 'uuid': '84ab500420319d', + 'tag_id': 5976557, + 'auction_id': '297492697822162468', + 'nobid': true + }] + }; + let bidderRequest; + + let result = spec.interpretResponse({ body: response }, {bidderRequest}); + expect(result.length).to.equal(0); + }); + }); + + describe('function _getFloor', function () { + let bidRequests = [ + { + bidder: 'adriver', + params: { + placementId: '55:test_placement', + siteid: 'testSiteID', + dealid: 'dealidTest', + }, + adUnitCode: 'adunit-code', + sizes: [[300, 250], [300, 600], [300, 250]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + transactionId: '04f2659e-c005-4eb1-a57c-fa93145e3843' + } + ]; + + const floorTestData = { + 'currency': 'RUB', + 'floor': 1.50 + }; + + const bitRequestStandard = JSON.parse(JSON.stringify(bidRequests)); + + bitRequestStandard[0].getFloor = () => { + return floorTestData; + }; + + it('valid BidRequests', function () { + const request = spec.buildRequests(bitRequestStandard); + const payload = JSON.parse(request.data); + + expect(typeof bitRequestStandard[0].getFloor).to.equal('function'); + expect(payload.imp[0].bidfloor).to.equal(1.50); + expect(payload.imp[0].bidfloorcur).to.equal('RUB'); + }); + + const bitRequestEmptyCurrency = JSON.parse(JSON.stringify(bidRequests)); + + const floorTestDataEmptyCurrency = { + 'currency': 'RUB', + 'floor': 1.50 + }; + + bitRequestEmptyCurrency[0].getFloor = () => { + return floorTestDataEmptyCurrency; + }; + + it('empty currency', function () { + const request = spec.buildRequests(bitRequestEmptyCurrency); + const payload = JSON.parse(request.data); + + expect(payload.imp[0].bidfloor).to.equal(1.50); + expect(payload.imp[0].bidfloorcur).to.equal('RUB'); + }); + + const bitRequestFloorNull = JSON.parse(JSON.stringify(bidRequests)); + + const floorTestDataFloorNull = { + 'currency': '', + 'floor': null + }; + + bitRequestFloorNull[0].getFloor = () => { + return floorTestDataFloorNull; + }; + + it('empty floor', function () { + const request = spec.buildRequests(bitRequestFloorNull); + const payload = JSON.parse(request.data); + + expect(payload.imp[0].bidfloor).to.equal(0); + }); + + const bitRequestGetFloorNotFunction = JSON.parse(JSON.stringify(bidRequests)); + + bitRequestGetFloorNotFunction[0].getFloor = 0; + + it('bid.getFloor is not a function', function () { + const request = spec.buildRequests(bitRequestGetFloorNotFunction); + const payload = JSON.parse(request.data); + + expect(payload.imp[0].bidfloor).to.equal(0); + expect(payload.imp[0].bidfloorcur).to.equal('RUB'); + }); + + const bitRequestGetFloorBySized = JSON.parse(JSON.stringify(bidRequests)); + + bitRequestGetFloorBySized[0].getFloor = (requestParams = {currency: 'USD', mediaType: '*', size: '*'}) => { + if (requestParams.size.length === 2 && requestParams.size[0] === 300 && requestParams.size[1] === 250) { + return { + 'currency': 'RUB', + 'floor': 3.33 + } + } else { + return {} + } + }; + + it('bid.getFloor get size', function () { + const request = spec.buildRequests(bitRequestGetFloorBySized); + const payload = JSON.parse(request.data); + + expect(payload.imp[0].bidfloor).to.equal(3.33); + expect(payload.imp[0].bidfloorcur).to.equal('RUB'); + expect(payload.imp[0].bidfloorcur).to.equal('RUB'); + }); + }); +}); From a1d83abdf117d4b7fbc04083e0d972368944afba Mon Sep 17 00:00:00 2001 From: ym-abaranov <78230460+ym-abaranov@users.noreply.github.com> Date: Thu, 22 Apr 2021 09:48:11 -0700 Subject: [PATCH 083/303] hotfix - placement issue fix (#6641) --- modules/yieldmoBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index b307f534b18..3cc0ab1194c 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -242,7 +242,7 @@ function createNewVideoBid(response, bidRequest) { }, }; - if (imp.placement && imp.placement !== 1) { + if (imp.video.placement && imp.video.placement !== 1) { const renderer = Renderer.install({ url: OUTSTREAM_VIDEO_PLAYER_URL, config: { From 5729c8c2f6118b74059ef97d6321335ff54bc005 Mon Sep 17 00:00:00 2001 From: robertrmartinez Date: Thu, 22 Apr 2021 09:59:50 -0700 Subject: [PATCH 084/303] Prebid 4.36.0 Release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 58ea0d7ba30..31cd746d1bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.36.0-pre", + "version": "4.36.0", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From f96dfcc76bc775cad50d4ab62f0aa141307af9e5 Mon Sep 17 00:00:00 2001 From: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Date: Thu, 22 Apr 2021 13:00:53 -0400 Subject: [PATCH 085/303] PBJS RP adapter: pass analytics flag to server (#6644) --- modules/rubiconBidAdapter.js | 6 +++++ test/spec/modules/rubiconBidAdapter_spec.js | 30 +++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 86e6525af85..ccb713f8978 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -3,6 +3,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {config} from '../src/config.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import find from 'core-js-pure/features/array/find.js'; +import { getGlobal } from '../src/prebidGlobal.js'; const DEFAULT_INTEGRATION = 'pbjs_lite'; const DEFAULT_PBS_INTEGRATION = 'pbjs'; @@ -196,6 +197,11 @@ export const spec = { } } + let modules = (getGlobal()).installedModules; + if (modules && (!modules.length || modules.indexOf('rubiconAnalyticsAdapter') !== -1)) { + utils.deepSetValue(data, 'ext.prebid.analytics', [{ 'adapter': 'rubicon', 'client-analytics': true }]); + } + let bidFloor; if (typeof bidRequest.getFloor === 'function' && !rubiConf.disableFloors) { let floorInfo; diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index f53cde3c8ab..5ec90fd5f64 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -371,6 +371,7 @@ describe('the rubicon adapter', function () { utils.logError.restore(); config.resetConfig(); resetRubiConf(); + delete $$PREBID_GLOBAL$$.installedModules; }); describe('MAS mapping / ordering', function () { @@ -1664,6 +1665,35 @@ describe('the rubicon adapter', function () { expect(request.data.ext.prebid.multibid).to.deep.equal(expected); }); + it('should pass client analytics to PBS endpoint if all modules included', function () { + createVideoBidderRequest(); + $$PREBID_GLOBAL$$.installedModules = []; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let payload = request.data; + + expect(payload.ext.prebid.analytics).to.not.be.undefined; + expect(payload.ext.prebid.analytics).to.deep.equal([{'adapter': 'rubicon', 'client-analytics': true}]); + }); + + it('should pass client analytics to PBS endpoint if rubicon analytics adapter is included', function () { + createVideoBidderRequest(); + $$PREBID_GLOBAL$$.installedModules = ['rubiconBidAdapter', 'rubiconAnalyticsAdapter']; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let payload = request.data; + + expect(payload.ext.prebid.analytics).to.not.be.undefined; + expect(payload.ext.prebid.analytics).to.deep.equal([{'adapter': 'rubicon', 'client-analytics': true}]); + }); + + it('should not pass client analytics to PBS endpoint if rubicon analytics adapter is not included', function () { + createVideoBidderRequest(); + $$PREBID_GLOBAL$$.installedModules = ['rubiconBidAdapter']; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let payload = request.data; + + expect(payload.ext.prebid.analytics).to.be.undefined; + }); + it('should send video exp param correctly when set', function () { createVideoBidderRequest(); config.setConfig({s2sConfig: {defaultTtl: 600}}); From e01e5ad6e50ac78fa372c838fad848e15d115b39 Mon Sep 17 00:00:00 2001 From: robertrmartinez Date: Thu, 22 Apr 2021 10:40:09 -0700 Subject: [PATCH 086/303] Increment pre version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31cd746d1bb..de3ad74eb51 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.36.0", + "version": "4.37.0-pre", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From 7f0e486f0f583a21be0ef70e7562d69c784176b9 Mon Sep 17 00:00:00 2001 From: Denis Logachov Date: Thu, 22 Apr 2021 20:41:59 +0300 Subject: [PATCH 087/303] Adkernel: new alias (#6608) --- modules/adkernelBidAdapter.js | 2 +- test/spec/modules/adkernelBidAdapter_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/adkernelBidAdapter.js b/modules/adkernelBidAdapter.js index b6d82aec976..3e795d176d2 100644 --- a/modules/adkernelBidAdapter.js +++ b/modules/adkernelBidAdapter.js @@ -53,7 +53,7 @@ const NATIVE_INDEX = NATIVE_MODEL.reduce((acc, val, idx) => { export const spec = { code: 'adkernel', gvlid: GVLID, - aliases: ['headbidding', 'adsolut', 'oftmediahb', 'audiencemedia', 'waardex_ak', 'roqoon', 'andbeyond', 'adbite', 'houseofpubs', 'torchad', 'stringads', 'bcm'], + aliases: ['headbidding', 'adsolut', 'oftmediahb', 'audiencemedia', 'waardex_ak', 'roqoon', 'andbeyond', 'adbite', 'houseofpubs', 'torchad', 'stringads', 'bcm', 'engageadx'], supportedMediaTypes: [BANNER, VIDEO, NATIVE], /** diff --git a/test/spec/modules/adkernelBidAdapter_spec.js b/test/spec/modules/adkernelBidAdapter_spec.js index 9881acc68df..aee24719c9c 100644 --- a/test/spec/modules/adkernelBidAdapter_spec.js +++ b/test/spec/modules/adkernelBidAdapter_spec.js @@ -565,7 +565,7 @@ describe('Adkernel adapter', function () { describe('adapter configuration', () => { it('should have aliases', () => { - expect(spec.aliases).to.have.lengthOf(12); + expect(spec.aliases).to.be.an('array').that.is.not.empty; }); }); From 9026c5dc6c0cc8b088f4618f14fa1e2788620d82 Mon Sep 17 00:00:00 2001 From: mjaworskiccx <50406214+mjaworskiccx@users.noreply.github.com> Date: Fri, 23 Apr 2021 13:25:42 +0200 Subject: [PATCH 088/303] Ccx Bid Adapter: adomain support (#6595) --- modules/ccxBidAdapter.js | 5 +++++ test/spec/modules/ccxBidAdapter_spec.js | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/ccxBidAdapter.js b/modules/ccxBidAdapter.js index ee15d6bb3ec..37b6fdc3e98 100644 --- a/modules/ccxBidAdapter.js +++ b/modules/ccxBidAdapter.js @@ -120,6 +120,11 @@ function _buildResponse (bid, currency, ttl) { currency: currency } + resp.meta = {}; + if (bid.adomain && bid.adomain.length > 0) { + resp.meta.advertiserDomains = bid.adomain; + } + if (bid.ext.type === 'video') { resp.vastXml = bid.adm } else { diff --git a/test/spec/modules/ccxBidAdapter_spec.js b/test/spec/modules/ccxBidAdapter_spec.js index f14612629b1..ef86b391e39 100644 --- a/test/spec/modules/ccxBidAdapter_spec.js +++ b/test/spec/modules/ccxBidAdapter_spec.js @@ -337,7 +337,10 @@ describe('ccxAdapter', function () { netRevenue: false, ttl: 5, currency: 'PLN', - ad: '' + ad: '', + meta: { + advertiserDomains: ['clickonometrics.com'] + } }, { requestId: '2e56e1af51a5d8', @@ -348,7 +351,10 @@ describe('ccxAdapter', function () { netRevenue: false, ttl: 5, currency: 'PLN', - vastXml: '' + vastXml: '', + meta: { + advertiserDomains: ['clickonometrics.com'] + } } ]; expect(spec.interpretResponse({body: response})).to.deep.have.same.members(bidResponses); @@ -366,7 +372,10 @@ describe('ccxAdapter', function () { netRevenue: false, ttl: 5, currency: 'PLN', - ad: '' + ad: '', + meta: { + advertiserDomains: ['clickonometrics.com'] + } } ]; expect(spec.interpretResponse({body: response})).to.deep.have.same.members(bidResponses); From 071b453375ce55cf470ea7c99f5461bfa130c353 Mon Sep 17 00:00:00 2001 From: pro-nsk <32703851+pro-nsk@users.noreply.github.com> Date: Fri, 23 Apr 2021 19:06:07 +0700 Subject: [PATCH 089/303] Qwarry Bid Adapter: added gdpr field (#6635) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix * gdpr value added * merge master * gdpr value added * qwarry bid adapter: add tests Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev --- modules/qwarryBidAdapter.js | 3 ++- test/spec/modules/qwarryBidAdapter_spec.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/qwarryBidAdapter.js b/modules/qwarryBidAdapter.js index d19ad0b4fe4..e2782d82512 100644 --- a/modules/qwarryBidAdapter.js +++ b/modules/qwarryBidAdapter.js @@ -33,7 +33,8 @@ export const spec = { if (bidderRequest && bidderRequest.gdprConsent) { payload.gdprConsent = { consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : false, - consentString: bidderRequest.gdprConsent.consentString + consentString: bidderRequest.gdprConsent.consentString, + gdpr: bidderRequest.gdprConsent.gdprApplies === true ? 1 : 0 } } diff --git a/test/spec/modules/qwarryBidAdapter_spec.js b/test/spec/modules/qwarryBidAdapter_spec.js index f15d7b488cc..5d56203131a 100644 --- a/test/spec/modules/qwarryBidAdapter_spec.js +++ b/test/spec/modules/qwarryBidAdapter_spec.js @@ -86,6 +86,7 @@ describe('qwarryBidAdapter', function () { expect(bidderRequest.data.requestId).to.equal('123') expect(bidderRequest.data.referer).to.equal('http://test.com/path.html') expect(bidderRequest.data.bids).to.deep.contains({ bidId: '456', zoneToken: 'e64782a4-8e68-4c38-965b-80ccf115d46f', pos: 7 }) + expect(bidderRequest.data.gdprConsent).to.deep.contains({ consentRequired: true, consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==', gdpr: 1 }) expect(bidderRequest.options.customHeaders).to.deep.equal({ 'Rtb-Direct': true }) expect(bidderRequest.options.contentType).to.equal('application/json') expect(bidderRequest.url).to.equal(ENDPOINT) From 7dba60cce0c083321047746013663cb51af25895 Mon Sep 17 00:00:00 2001 From: Jurij Sinickij Date: Fri, 23 Apr 2021 16:51:42 +0300 Subject: [PATCH 090/303] Adf Bid Adapter: rename adformOpenRTB adapter; add former name as alias (#6642) --- .../{adformOpenRTBBidAdapter.js => adfBidAdapter.js} | 5 +++-- .../{adformOpenRTBBidAdapter.md => adfBidAdapter.md} | 6 +++--- ...enRTBBidAdapter_spec.js => adfBidAdapter_spec.js} | 12 +++++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) rename modules/{adformOpenRTBBidAdapter.js => adfBidAdapter.js} (97%) rename modules/{adformOpenRTBBidAdapter.md => adfBidAdapter.md} (90%) rename test/spec/modules/{adformOpenRTBBidAdapter_spec.js => adfBidAdapter_spec.js} (98%) diff --git a/modules/adformOpenRTBBidAdapter.js b/modules/adfBidAdapter.js similarity index 97% rename from modules/adformOpenRTBBidAdapter.js rename to modules/adfBidAdapter.js index 3270fb5865a..8b3550e6108 100644 --- a/modules/adformOpenRTBBidAdapter.js +++ b/modules/adfBidAdapter.js @@ -10,8 +10,9 @@ import { import * as utils from '../src/utils.js'; import { config } from '../src/config.js'; -const BIDDER_CODE = 'adformOpenRTB'; +const BIDDER_CODE = 'adf'; const GVLID = 50; +const BIDDER_ALIAS = [ { code: 'adformOpenRTB', gvlid: GVLID } ]; const NATIVE_ASSET_IDS = { 0: 'title', 2: 'icon', 3: 'image', 5: 'sponsoredBy', 4: 'body', 1: 'cta' }; const NATIVE_PARAMS = { title: { @@ -47,6 +48,7 @@ const NATIVE_PARAMS = { export const spec = { code: BIDDER_CODE, + aliases: BIDDER_ALIAS, gvlid: GVLID, supportedMediaTypes: [ NATIVE ], isBidRequestValid: bid => !!bid.params.mid, @@ -170,7 +172,6 @@ export const spec = { netRevenue: bid.netRevenue === 'net', currency: cur, mediaType: NATIVE, - bidderCode: BIDDER_CODE, native: parseNative(bidResponse) }; } diff --git a/modules/adformOpenRTBBidAdapter.md b/modules/adfBidAdapter.md similarity index 90% rename from modules/adformOpenRTBBidAdapter.md rename to modules/adfBidAdapter.md index 0dd98ad07b8..190aa91ea57 100644 --- a/modules/adformOpenRTBBidAdapter.md +++ b/modules/adfBidAdapter.md @@ -1,13 +1,13 @@ # Overview -Module Name: Adform OpenRTB Adapter +Module Name: Adf Adapter Module Type: Bidder Adapter Maintainer: Scope.FL.Scripts@adform.com # Description Module that connects to Adform demand sources to fetch bids. -Only native format is supported. Using OpenRTB standard. +Only native format is supported. Using OpenRTB standard. Previous adapter name - adformOpenRTB. # Test Parameters ``` @@ -42,7 +42,7 @@ Only native format is supported. Using OpenRTB standard. } }, bids: [{ - bidder: 'adformOpenRTB', + bidder: 'adf', params: { mid: 606169, // required adxDomain: 'adx.adform.net', // optional diff --git a/test/spec/modules/adformOpenRTBBidAdapter_spec.js b/test/spec/modules/adfBidAdapter_spec.js similarity index 98% rename from test/spec/modules/adformOpenRTBBidAdapter_spec.js rename to test/spec/modules/adfBidAdapter_spec.js index 05788183e29..2c141d31bf8 100644 --- a/test/spec/modules/adformOpenRTBBidAdapter_spec.js +++ b/test/spec/modules/adfBidAdapter_spec.js @@ -1,14 +1,21 @@ // jshint esversion: 6, es3: false, node: true import {assert, expect} from 'chai'; -import {spec} from 'modules/adformOpenRTBBidAdapter.js'; +import {spec} from 'modules/adfBidAdapter.js'; import { NATIVE } from 'src/mediaTypes.js'; import { config } from 'src/config.js'; import { createEidsArray } from 'modules/userId/eids.js'; -describe('AdformOpenRTB adapter', function () { +describe('Adf adapter', function () { let serverResponse, bidRequest, bidResponses; let bids = []; + describe('backwards-compatibility', function () { + it('should have adformOpenRTB alias defined', function () { + assert.equal(spec.aliases[0].code, 'adformOpenRTB'); + assert.equal(spec.aliases[0].gvlid, 50); + }); + }); + describe('isBidRequestValid', function () { let bid = { 'bidder': 'adformOpenRTB', @@ -567,7 +574,6 @@ describe('AdformOpenRTB adapter', function () { assert.deepEqual(bids[0].netRevenue, false); assert.deepEqual(bids[0].currency, serverResponse.body.cur); assert.deepEqual(bids[0].mediaType, 'native'); - assert.deepEqual(bids[0].bidderCode, 'adformOpenRTB'); }); it('should set correct native params', function () { const bid = [ From d3c7731f4dcd8c946236afc54dc1d748a3c1c9d8 Mon Sep 17 00:00:00 2001 From: susyt Date: Fri, 23 Apr 2021 11:25:35 -0700 Subject: [PATCH 091/303] GumGum Bid Adapter: use ad response sizes when found (#6649) * adds meta field to bidresponse * adds meta mediatype and advertiserdomain default * use response sizes in bidresponse --- modules/gumgumBidAdapter.js | 11 ++++++++--- test/spec/modules/gumgumBidAdapter_spec.js | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/modules/gumgumBidAdapter.js b/modules/gumgumBidAdapter.js index 606f8335a19..4786fd04b15 100644 --- a/modules/gumgumBidAdapter.js +++ b/modules/gumgumBidAdapter.js @@ -384,7 +384,9 @@ function interpretResponse (serverResponse, bidRequest) { ad: { price: 0, id: 0, - markup: '' + markup: '', + width: 0, + height: 0 }, pag: { pvid: 0 @@ -399,7 +401,9 @@ function interpretResponse (serverResponse, bidRequest) { price: cpm, id: creativeId, markup, - cur + cur, + width: responseWidth, + height: responseHeight }, cw: wrapper, pag: { @@ -415,7 +419,8 @@ function interpretResponse (serverResponse, bidRequest) { let product = data.pi let mediaType = (product === 6 || product === 7) ? VIDEO : BANNER let isTestUnit = (product === 3 && data.si === 9) - let sizes = utils.parseSizesInput(bidRequest.sizes) + // use response sizes if available + let sizes = responseWidth && responseHeight ? [`${responseWidth}x${responseHeight}`] : utils.parseSizesInput(bidRequest.sizes) let [width, height] = sizes[0].split('x') let metaData = { advertiserDomains: advertiserDomains || [], diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js index 2365fddd01f..a7b18a16173 100644 --- a/test/spec/modules/gumgumBidAdapter_spec.js +++ b/test/spec/modules/gumgumBidAdapter_spec.js @@ -564,6 +564,25 @@ describe('gumgumAdapter', function () { expect(result.length).to.equal(0); }); + it('uses response width and height', function () { + const result = spec.interpretResponse({ body: serverResponse }, bidRequest)[0]; + expect(result.width).to.equal(serverResponse.ad.width.toString()); + expect(result.height).to.equal(serverResponse.ad.height.toString()); + }); + + it('defaults to use bidRequest sizes when width and height are not found', function () { + const { ad, jcsi, pag, thms, meta } = serverResponse + const noAdSizes = { ...ad } + delete noAdSizes.width + delete noAdSizes.height + const responseWithoutSizes = { jcsi, pag, thms, meta, ad: noAdSizes } + const request = { ...bidRequest, sizes: [[100, 200]] } + const result = spec.interpretResponse({ body: responseWithoutSizes }, request)[0]; + + expect(result.width).to.equal(request.sizes[0][0].toString()) + expect(result.height).to.equal(request.sizes[0][1].toString()) + }); + it('returns 1x1 when eligible product and size available', function () { let inscreenBidRequest = { id: 12346, From 6c0142abd4831db5416bedd4a7291dfb7b477bc8 Mon Sep 17 00:00:00 2001 From: Serhii Mozhaiskyi <57671975+smozhaiskyi-rubi@users.noreply.github.com> Date: Fri, 23 Apr 2021 22:02:13 +0300 Subject: [PATCH 092/303] Rubicon Bid Adapter: add outstream rendering (#6469) * Magnite renderer support for Oustream ads * add functions for hiding ad units * Add unit tests * adding open source location of renderer * better minification Co-authored-by: bretg --- modules/rubiconBidAdapter.js | 66 +++++++++ test/spec/modules/rubiconBidAdapter_spec.js | 147 ++++++++++++++++++++ 2 files changed, 213 insertions(+) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index ccb713f8978..b8670706b60 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -3,10 +3,13 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {config} from '../src/config.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import find from 'core-js-pure/features/array/find.js'; +import { Renderer } from '../src/Renderer.js'; import { getGlobal } from '../src/prebidGlobal.js'; const DEFAULT_INTEGRATION = 'pbjs_lite'; const DEFAULT_PBS_INTEGRATION = 'pbjs'; +const DEFAULT_RENDERER_URL = 'https://video-outstream.rubiconproject.com/apex-2.0.0.js'; +// renderer code at https://github.com/rubicon-project/apex2 let rubiConf = {}; // we are saving these as global to this module so that if a pub accidentally overwrites the entire @@ -651,6 +654,11 @@ export const spec = { if (bid.adm) { bidObject.vastXml = bid.adm; } if (bid.nurl) { bidObject.vastUrl = bid.nurl; } if (!bidObject.vastUrl && bid.nurl) { bidObject.vastUrl = bid.nurl; } + + const videoContext = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); + if (videoContext.toLowerCase() === 'outstream') { + bidObject.renderer = outstreamRenderer(bidObject); + } } else { utils.logWarn('Rubicon: video response received non-video media type'); } @@ -810,6 +818,64 @@ function _renderCreative(script, impId) { `; } +function hideGoogleAdsDiv(adUnit) { + const el = adUnit.querySelector("div[id^='google_ads']"); + if (el) { + el.style.setProperty('display', 'none'); + } +} + +function hideSmartAdServerIframe(adUnit) { + const el = adUnit.querySelector("script[id^='sas_script']"); + const nextSibling = el && el.nextSibling; + if (nextSibling && nextSibling.localName === 'iframe') { + nextSibling.style.setProperty('display', 'none'); + } +} + +function renderBid(bid) { + // hide existing ad units + const adUnitElement = document.getElementById(bid.adUnitCode); + hideGoogleAdsDiv(adUnitElement); + hideSmartAdServerIframe(adUnitElement); + + // configure renderer + const config = bid.renderer.getConfig(); + bid.renderer.push(() => { + window.MagniteApex.renderAd({ + width: bid.width, + height: bid.height, + vastUrl: bid.vastUrl, + placement: { + attachTo: `#${bid.adUnitCode}`, + align: config.align || 'center', + position: config.position || 'append' + }, + closeButton: config.closeButton || false, + label: config.label || undefined, + collapse: config.collapse || true + }); + }); +} + +function outstreamRenderer(rtbBid) { + const renderer = Renderer.install({ + id: rtbBid.adId, + url: rubiConf.rendererUrl || DEFAULT_RENDERER_URL, + config: rubiConf.rendererConfig || {}, + loaded: false, + adUnitCode: rtbBid.adUnitCode + }); + + try { + renderer.setRender(renderBid); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on renderer', err); + } + + return renderer; +} + function parseSizes(bid, mediaType) { let params = bid.params; if (mediaType === 'video') { diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index 5ec90fd5f64..6b061e3157d 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -3050,6 +3050,153 @@ describe('the rubicon adapter', function () { }); }); + describe('for outstream video', function () { + const sandbox = sinon.createSandbox(); + beforeEach(function () { + createVideoBidderRequestOutstream(); + config.setConfig({rubicon: { + rendererConfig: { + align: 'left', + closeButton: true + }, + rendererUrl: 'https://example.test/renderer.js' + }}); + window.MagniteApex = { + renderAd: function() { + return null; + } + } + }); + + afterEach(function () { + sandbox.restore(); + delete window.MagniteApex; + }); + + it('should register a successful bid', function () { + let response = { + cur: 'USD', + seatbid: [{ + bid: [{ + id: '0', + impid: 'outstream_video1', + adomain: ['test.com'], + price: 2, + crid: '4259970', + ext: { + bidder: { + rp: { + mime: 'application/javascript', + size_id: 201, + advid: 12345 + } + }, + prebid: { + targeting: { + hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64' + }, + type: 'video' + } + } + }], + group: 0, + seat: 'rubicon' + }], + }; + + let bids = spec.interpretResponse({body: response}, { + bidRequest: bidderRequest.bids[0] + }); + + expect(bids).to.be.lengthOf(1); + + expect(bids[0].seatBidId).to.equal('0'); + expect(bids[0].creativeId).to.equal('4259970'); + expect(bids[0].cpm).to.equal(2); + expect(bids[0].ttl).to.equal(300); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[0].adserverTargeting).to.deep.equal({hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64'}); + expect(bids[0].mediaType).to.equal('video'); + expect(bids[0].meta.mediaType).to.equal('video'); + expect(String(bids[0].meta.advertiserDomains)).to.equal('test.com'); + expect(bids[0].meta.advertiserId).to.equal(12345); + expect(bids[0].bidderCode).to.equal('rubicon'); + expect(bids[0].currency).to.equal('USD'); + expect(bids[0].width).to.equal(640); + expect(bids[0].height).to.equal(320); + // check custom renderer + expect(typeof bids[0].renderer).to.equal('object'); + expect(bids[0].renderer.getConfig()).to.deep.equal({ + align: 'left', + closeButton: true + }); + expect(bids[0].renderer.url).to.equal('https://example.test/renderer.js'); + }); + + it('should render ad with Magnite renderer', function () { + let response = { + cur: 'USD', + seatbid: [{ + bid: [{ + id: '0', + impid: 'outstream_video1', + adomain: ['test.com'], + price: 2, + crid: '4259970', + ext: { + bidder: { + rp: { + mime: 'application/javascript', + size_id: 201, + advid: 12345 + } + }, + prebid: { + targeting: { + hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64' + }, + type: 'video' + } + }, + nurl: 'https://test.com/vast.xml' + }], + group: 0, + seat: 'rubicon' + }], + }; + + sinon.spy(window.MagniteApex, 'renderAd'); + + let bids = spec.interpretResponse({body: response}, { + bidRequest: bidderRequest.bids[0] + }); + const bid = bids[0]; + bid.adUnitCode = 'outstream_video1_placement'; + const adUnit = document.createElement('div'); + adUnit.id = bid.adUnitCode; + document.body.appendChild(adUnit); + + bid.renderer.render(bid); + + const renderCall = window.MagniteApex.renderAd.getCall(0); + expect(renderCall.args[0]).to.deep.equal({ + closeButton: true, + collapse: true, + height: 320, + label: undefined, + placement: { + align: 'left', + attachTo: '#outstream_video1_placement', + position: 'append', + }, + vastUrl: 'https://test.com/vast.xml', + width: 640 + }); + // cleanup + adUnit.remove(); + }); + }); + describe('config with integration type', () => { it('should use the integration type provided in the config instead of the default', () => { config.setConfig({rubicon: {int_type: 'testType'}}); From 15c31c89f5a6e1a85a1d6d26090afc40b4c7d795 Mon Sep 17 00:00:00 2001 From: Anthony Lauzon Date: Fri, 23 Apr 2021 22:19:51 -0400 Subject: [PATCH 093/303] Halo RTD submodule: update docs (#6651) --- modules/haloRtdProvider.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/haloRtdProvider.md b/modules/haloRtdProvider.md index 02dc6577e49..4307618bb60 100644 --- a/modules/haloRtdProvider.md +++ b/modules/haloRtdProvider.md @@ -16,7 +16,7 @@ and the bidstream in real-time during the bid request cycle. Compile the Halo RTD module into your Prebid build: -`gulp build --modules=userId,unifiedIdSystem,rtdModule,audigentRtdProvider,appnexusBidAdapter` +`gulp build --modules=userId,unifiedIdSystem,rtdModule,haloRtdProvider,appnexusBidAdapter` Add the Halo RTD provider to your Prebid config. In this example we will configure publisher 1234 to retrieve segments from Audigent. See the From 722afa1efd40165f3fc813441a4d8705df63fb5c Mon Sep 17 00:00:00 2001 From: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Date: Sat, 24 Apr 2021 21:57:25 +0500 Subject: [PATCH 094/303] sid into tags for ZetaSsp (#6636) Co-authored-by: Surovenko Alexey --- modules/zetaSspBidAdapter.js | 3 ++- modules/zetaSspBidAdapter.md | 3 ++- test/spec/modules/zetaSspBidAdapter_spec.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/zetaSspBidAdapter.js b/modules/zetaSspBidAdapter.js index d6f2039dff1..8f4d8995800 100644 --- a/modules/zetaSspBidAdapter.js +++ b/modules/zetaSspBidAdapter.js @@ -57,7 +57,8 @@ export const spec = { user: params.user ? params.user : {}, app: params.app ? params.app : {}, ext: { - tags: params.tags ? params.tags : {} + tags: params.tags ? params.tags : {}, + sid: params.sid ? params.sid : {} } }; diff --git a/modules/zetaSspBidAdapter.md b/modules/zetaSspBidAdapter.md index 332f4b302d0..d2950bce6b9 100644 --- a/modules/zetaSspBidAdapter.md +++ b/modules/zetaSspBidAdapter.md @@ -30,7 +30,8 @@ Module that connects to Zeta's SSP buyeruid: 12345 }, tags: { - someTag: 123 + someTag: 123, + sid: 'publisherId' }, test: 1 } diff --git a/test/spec/modules/zetaSspBidAdapter_spec.js b/test/spec/modules/zetaSspBidAdapter_spec.js index 49fab977a06..bdfc64c3234 100644 --- a/test/spec/modules/zetaSspBidAdapter_spec.js +++ b/test/spec/modules/zetaSspBidAdapter_spec.js @@ -19,7 +19,8 @@ describe('Zeta Ssp Bid Adapter', function() { buyeruid: 12345 }, tags: { - someTag: 123 + someTag: 123, + sid: 'publisherId' }, test: 1 } From 4d842d28c7b54df7e1850148d8f9836fce6629a4 Mon Sep 17 00:00:00 2001 From: David Reischer Date: Mon, 26 Apr 2021 13:26:50 +0100 Subject: [PATCH 095/303] Add module name to storage manager; catch errors (#6596) --- modules/permutiveRtdProvider.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/modules/permutiveRtdProvider.js b/modules/permutiveRtdProvider.js index db431ed45a7..91e88d3e4e1 100644 --- a/modules/permutiveRtdProvider.js +++ b/modules/permutiveRtdProvider.js @@ -8,10 +8,11 @@ import { getGlobal } from '../src/prebidGlobal.js' import { submodule } from '../src/hook.js' import { getStorageManager } from '../src/storageManager.js' -import { deepSetValue, deepAccess, isFn, mergeDeep } from '../src/utils.js' +import { deepSetValue, deepAccess, isFn, mergeDeep, logError } from '../src/utils.js' import includes from 'core-js-pure/features/array/includes.js' +const MODULE_NAME = 'permutive' -export const storage = getStorageManager() +export const storage = getStorageManager(null, MODULE_NAME) function init (config, userConsent) { return true @@ -60,13 +61,19 @@ function setSegments (reqBidsConfigObj, config) { customFn(bid, data, acEnabled, utils, defaultFn) } else if (defaultFn) { defaultFn(bid, data, acEnabled) - } else { - } }) }) } +function makeSafe (fn) { + try { + fn() + } catch (e) { + logError(e) + } +} + function getCustomBidderFn (config, bidder) { const overwriteFn = deepAccess(config, `params.overwrites.${bidder}`) @@ -170,8 +177,12 @@ function readSegments (key) { /** @type {RtdSubmodule} */ export const permutiveSubmodule = { - name: 'permutive', - getBidRequestData: initSegments, + name: MODULE_NAME, + getBidRequestData: function (reqBidsConfigObj, callback, customConfig) { + makeSafe(function () { + initSegments(reqBidsConfigObj, callback, customConfig) + }) + }, init: init } From c408a6effe986cd7d2033e2f001a756be1ed8699 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Mon, 26 Apr 2021 16:42:58 +0200 Subject: [PATCH 096/303] Adnuntius Bid Adatpter: Meta field advertiser domain update. (#6652) * RTD Provider rebase * wrongly merged to master * Added meta field for advertiser domains. --- modules/adnuntiusBidAdapter.js | 4 ++++ test/spec/modules/adnuntiusBidAdapter_spec.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/modules/adnuntiusBidAdapter.js b/modules/adnuntiusBidAdapter.js index e5878ad047d..56f1bb02981 100644 --- a/modules/adnuntiusBidAdapter.js +++ b/modules/adnuntiusBidAdapter.js @@ -56,6 +56,10 @@ export const spec = { height: Number(bid.creativeHeight), creativeId: bid.creativeId, currency: (bid.bid) ? bid.bid.currency : 'EUR', + meta: { + advertiserDomains: (bid.destinationUrls.destination) ? [bid.destinationUrls.destination.split('/')[2]] : [] + + }, netRevenue: false, ttl: 360, ad: adUnit.html diff --git a/test/spec/modules/adnuntiusBidAdapter_spec.js b/test/spec/modules/adnuntiusBidAdapter_spec.js index 44afa5c59e4..d234a345b5c 100644 --- a/test/spec/modules/adnuntiusBidAdapter_spec.js +++ b/test/spec/modules/adnuntiusBidAdapter_spec.js @@ -123,6 +123,9 @@ describe('adnuntiusBidAdapter', function () { expect(interpretedResponse[0].creativeId).to.equal(ad.creativeId); expect(interpretedResponse[0].currency).to.equal(ad.bid.currency); expect(interpretedResponse[0].netRevenue).to.equal(false); + expect(interpretedResponse[0].meta).to.have.property('advertiserDomains'); + expect(interpretedResponse[0].meta.advertiserDomains).to.have.lengthOf(1); + expect(interpretedResponse[0].meta.advertiserDomains[0]).to.equal('google.com'); expect(interpretedResponse[0].ad).to.equal(serverResponse.body.adUnits[0].html); expect(interpretedResponse[0].ttl).to.equal(360); }); From 40b7ec0f2321d41a353bb808459cf34e9f5099df Mon Sep 17 00:00:00 2001 From: Roberto Hsu Wu Date: Mon, 26 Apr 2021 13:30:08 -0300 Subject: [PATCH 097/303] Gnet Bid Adapter: add new bid adapter (#6536) * Add files via upload * Add files via upload * Change params on gnetBidder * ADJ - Use parseSizesInput to get sizes ADJ - Check serverResponse object ADJ - Remove getUserSyncs function * ADJ - Change prebid endpoint * ADJ - Change endpoint on test --- modules/gnetBidAdapter.js | 101 ++++++++++++++++ modules/gnetBidAdapter.md | 33 ++++++ test/spec/modules/gnetBidAdapter_spec.js | 145 +++++++++++++++++++++++ 3 files changed, 279 insertions(+) create mode 100644 modules/gnetBidAdapter.js create mode 100644 modules/gnetBidAdapter.md create mode 100644 test/spec/modules/gnetBidAdapter_spec.js diff --git a/modules/gnetBidAdapter.js b/modules/gnetBidAdapter.js new file mode 100644 index 00000000000..3469c897a6a --- /dev/null +++ b/modules/gnetBidAdapter.js @@ -0,0 +1,101 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import * as utils from '../src/utils.js'; +import { BANNER } from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'gnet'; +const ENDPOINT = 'https://adserver.gnetproject.com/prebid.php'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + return !!(bid.params.websiteId && bid.params.externalId); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + const bidRequests = []; + const referer = bidderRequest.refererInfo.referer; + + utils._each(validBidRequests, (request) => { + const data = {}; + + data.referer = referer; + data.adUnitCode = request.adUnitCode; + data.bidId = request.bidId; + data.transactionId = request.transactionId; + + data.sizes = utils.parseSizesInput(request.sizes); + + data.params = request.params; + + const payloadString = JSON.stringify(data); + + bidRequests.push({ + method: 'POST', + url: ENDPOINT, + mode: 'no-cors', + options: { + withCredentials: false, + }, + data: payloadString + }); + }); + + return bidRequests; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse, requests) { + if (typeof serverResponse !== 'object') { + return []; + } + + const res = serverResponse && serverResponse.body; + + if (utils.isEmpty(res)) { + return []; + } + + if (res.bids) { + const bids = []; + utils._each(res.bids, (bidData) => { + const bid = { + requestId: bidData.bidId, + cpm: bidData.cpm, + currency: bidData.currency, + width: bidData.width, + height: bidData.height, + ad: bidData.ad, + ttl: 300, + creativeId: bidData.creativeId, + netRevenue: true, + }; + bids.push(bid); + }); + + return bids; + } + + return []; + }, +}; + +registerBidder(spec); diff --git a/modules/gnetBidAdapter.md b/modules/gnetBidAdapter.md new file mode 100644 index 00000000000..6dac9be17b6 --- /dev/null +++ b/modules/gnetBidAdapter.md @@ -0,0 +1,33 @@ +# Overview + +``` +Module Name: Gnet Bidder Adapter +Module Type: Bidder Adapter +Maintainer: roberto.wu@grumft.com +``` + +# Description + +Module that connects to Example's demand sources + +# Test Parameters +``` + var adUnits = [ + { + code: '/150790500/4_ZONA_IAB_300x250_5', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'gnet', + params: { + websiteId: '4', + externalId: '4d52cccf30309282256012cf30309282' + } + } + ] + } + ]; \ No newline at end of file diff --git a/test/spec/modules/gnetBidAdapter_spec.js b/test/spec/modules/gnetBidAdapter_spec.js new file mode 100644 index 00000000000..40f8ad50d78 --- /dev/null +++ b/test/spec/modules/gnetBidAdapter_spec.js @@ -0,0 +1,145 @@ +import { + expect +} from 'chai'; +import { + spec +} from 'modules/gnetBidAdapter.js'; +import { + newBidder +} from 'src/adapters/bidderFactory.js'; + +const ENDPOINT = 'https://adserver.gnetproject.com/prebid.php'; + +describe('gnetAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + let bid = { + bidder: 'gnet', + params: { + websiteId: '4', + externalId: '4d52cccf30309282256012cf30309282' + } + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [{ + bidder: 'gnet', + params: { + websiteId: '4', + externalId: '4d52cccf30309282256012cf30309282' + }, + adUnitCode: '/150790500/4_ZONA_IAB_300x250_5', + sizes: [ + [300, 250], + ], + bidId: '2a19afd5173318', + bidderRequestId: '1f4001782ac16c', + auctionId: 'aba03555-4802-4c45-9f15-05ffa8594cff', + transactionId: '894bdff6-61ec-4bec-a5a9-f36a5bfccef5' + }]; + + const bidderRequest = { + refererInfo: { + referer: 'https://gnetproject.com/' + } + }; + + it('sends bid request to ENDPOINT via POST', function () { + const requests = spec.buildRequests(bidRequests, bidderRequest); + expect(requests[0].url).to.equal(ENDPOINT); + expect(requests[0].method).to.equal('POST'); + expect(requests[0].data).to.equal(JSON.stringify({ + 'referer': 'https://gnetproject.com/', + 'adUnitCode': '/150790500/4_ZONA_IAB_300x250_5', + 'bidId': '2a19afd5173318', + 'transactionId': '894bdff6-61ec-4bec-a5a9-f36a5bfccef5', + 'sizes': ['300x250'], + 'params': { + 'websiteId': '4', + 'externalId': '4d52cccf30309282256012cf30309282' + } + })); + }); + }); + + describe('interpretResponse', function () { + const bidderRequests = [{ + bidder: 'gnet', + params: { + clientId: '123456' + }, + adUnitCode: '/150790500/4_ZONA_IAB_300x250_5', + sizes: [ + [300, 250], + ], + bidId: '2a19afd5173318', + bidderRequestId: '1f4001782ac16c', + auctionId: 'aba03555-4802-4c45-9f15-05ffa8594cff', + transactionId: '894bdff6-61ec-4bec-a5a9-f36a5bfccef5' + }]; + + it('should get correct banner bid response', function () { + const response = { + bids: [ + { + bidId: '2a19afd5173318', + cpm: 0.1, + currency: 'BRL', + width: 300, + height: 250, + ad: '

I am an ad

', + creativeId: '173560700', + } + ] + }; + + const expectedResponse = [ + { + requestId: '2a19afd5173318', + cpm: 0.1, + currency: 'BRL', + width: 300, + height: 250, + ad: '

I am an ad

', + ttl: 300, + creativeId: '173560700', + netRevenue: true + } + ]; + + const result = spec.interpretResponse({ + body: response + }, bidderRequests); + expect(result).to.have.lengthOf(1); + expect(result).to.deep.have.same.members(expectedResponse); + }); + + it('handles nobid responses', function () { + const response = ''; + + const result = spec.interpretResponse({ + body: response + }, bidderRequests); + expect(result.length).to.equal(0); + }); + }); +}); From 960c669f78ec79c9400b2a7860fea9b8fcffc0c9 Mon Sep 17 00:00:00 2001 From: TheMediaGrid <44166371+TheMediaGrid@users.noreply.github.com> Date: Mon, 26 Apr 2021 20:22:05 +0300 Subject: [PATCH 098/303] TheMediaGrid Bid Adapter: added support of PBAdSlot module (#6609) * Added TheMediaGridNM Bid Adapter * Updated required params for TheMediaGridNM Bid Adapter * Update TheMediGridNM Bid Adapter * Fix tests for TheMediaGridNM Bid Adapter * Fixes after review for TheMediaGridNM Bid Adapter * Add support of multi-format in TheMediaGrid Bid Adapter * Update sync url for grid and gridNM Bid Adapters * TheMediaGrid Bid Adapter: added keywords adUnit parameter * Update TheMediaGrid Bid Adapter to support keywords from config * Implement new request format for TheMediaGrid Bid Adapter * Fix jwpseg params for TheMediaGrid Bid Adapter * Update unit tests for The Media Grid Bid Adapter * Fix typo in TheMediaGrid Bid Adapter * Added test for jwTargeting in TheMediaGrid Bid Adapter * The new request format was made by default in TheMediaGrid Bid Adapter * Update userId format in ad request for TheMediaGrid Bid Adapter * Added bidFloor parameter for TheMediaGrid Bid Adapter * Fix for review TheMediaGrid Bid Adapter * Support floorModule in TheMediaGrid Bid Adapter * Fix empty bidfloor for TheMediaGrid Bid Adapter * Some change to restart autotests * Fix userIds format for TheMediaGrid Bid Adapter * Remove digitrust userId from TheMediaGrid Bid Adapter * Protocols was added in video section in ad request for TheMediaGrid Bid Adapter * TheMediaGrid: fix trouble with alias using * TheMediaGridNM: fix trouble with alias * TheMediaGrid Bid Adapter: added support of PBAdSlot module * TheMediaGrid Bid Adapter: fix typo --- modules/gridBidAdapter.js | 8 ++++- test/spec/modules/gridBidAdapter_spec.js | 42 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js index 964b34dcfa2..994244b8a50 100644 --- a/modules/gridBidAdapter.js +++ b/modules/gridBidAdapter.js @@ -76,7 +76,7 @@ export const spec = { if (!userIdAsEids) { userIdAsEids = bid.userIdAsEids; } - const {params: {uid, keywords}, mediaTypes, bidId, adUnitCode, rtd} = bid; + const {params: {uid, keywords}, mediaTypes, bidId, adUnitCode, rtd, ortb2Imp} = bid; bidsMap[bidId] = bid; if (!pageKeywords && !utils.isEmpty(keywords)) { pageKeywords = utils.transformBidderParamKeywords(keywords); @@ -98,6 +98,12 @@ export const spec = { divid: adUnitCode } }; + if (ortb2Imp && ortb2Imp.ext && ortb2Imp.ext.data) { + impObj.ext.data = ortb2Imp.ext.data; + if (impObj.ext.data.adserver && impObj.ext.data.adserver.adslot) { + impObj.ext.gpid = impObj.ext.data.adserver.adslot; + } + } if (bidFloor) { impObj.bidfloor = bidFloor; diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js index 2e8601bddf6..6cdef43b150 100644 --- a/test/spec/modules/gridBidAdapter_spec.js +++ b/test/spec/modules/gridBidAdapter_spec.js @@ -428,6 +428,48 @@ describe('TheMediaGrid Adapter', function () { expect(payload.tmax).to.equal(3000); getConfigStub.restore(); }); + it('should contain imp[].ext.data.adserver if available', function() { + const ortb2Imp = [{ + ext: { + data: { + adserver: { + name: 'ad_server_name', + adslot: '/111111/slot' + }, + pbadslot: '/111111/slot' + } + } + }, { + ext: { + data: { + adserver: { + name: 'ad_server_name', + adslot: '/222222/slot' + }, + pbadslot: '/222222/slot' + } + } + }]; + const bidRequestsWithOrtb2Imp = bidRequests.slice(0, 3).map((bid, ind) => { + return Object.assign(ortb2Imp[ind] ? { ortb2Imp: ortb2Imp[ind] } : {}, bid); + }); + const request = spec.buildRequests(bidRequestsWithOrtb2Imp, bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload.imp[0].ext).to.deep.equal({ + divid: bidRequests[0].adUnitCode, + data: ortb2Imp[0].ext.data, + gpid: ortb2Imp[0].ext.data.adserver.adslot + }); + expect(payload.imp[1].ext).to.deep.equal({ + divid: bidRequests[1].adUnitCode, + data: ortb2Imp[1].ext.data, + gpid: ortb2Imp[1].ext.data.adserver.adslot + }); + expect(payload.imp[2].ext).to.deep.equal({ + divid: bidRequests[2].adUnitCode + }); + }); describe('floorModule', function () { const floorTestData = { 'currency': 'USD', From d6a2ed7d151ca31e81fe2e6e61c61aec96c165a0 Mon Sep 17 00:00:00 2001 From: JonGoSonobi Date: Mon, 26 Apr 2021 21:18:53 -0400 Subject: [PATCH 099/303] Sonobi Bid Adapter: added Coppa Flag check (#6631) * Sonobi - Added Coppa Flag check * added unit test for sonobi coppa flag --- modules/sonobiBidAdapter.js | 6 ++++++ test/spec/modules/sonobiBidAdapter_spec.js | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 0e4bfb37829..e5bd76eba9f 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -140,6 +140,12 @@ export const spec = { payload.us_privacy = bidderRequest.uspConsent; } + if (config.getConfig('coppa') === true) { + payload.coppa = 1; + } else { + payload.coppa = 0; + } + // If there is no key_maker data, then don't make the request. if (isEmpty(data)) { return null; diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index d1ac200394c..0314ffb71c1 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -2,10 +2,10 @@ import { expect } from 'chai' import { spec, _getPlatform } from 'modules/sonobiBidAdapter.js' import { newBidder } from 'src/adapters/bidderFactory.js' import {userSync} from '../../../src/userSync.js'; +import { config } from 'src/config.js'; describe('SonobiBidAdapter', function () { const adapter = newBidder(spec) - describe('.code', function () { it('should return a bidder code of sonobi', function () { expect(spec.code).to.equal('sonobi') @@ -304,6 +304,20 @@ describe('SonobiBidAdapter', function () { uspConsent: 'someCCPAString' }; + it('should populate coppa as 1 if set in config', function () { + config.setConfig({coppa: true}); + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + + expect(bidRequests.data.coppa).to.equal(1); + }); + + it('should populate coppa as 0 if set in config', function () { + config.setConfig({coppa: false}); + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + + expect(bidRequests.data.coppa).to.equal(0); + }); + it('should return a properly formatted request', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests) const bidRequestsPageViewID = spec.buildRequests(bidRequest, bidderRequests) From f3624ebe0a21f525af7c5bf315c55641b38ab603 Mon Sep 17 00:00:00 2001 From: supportGothamad <75782642+supportGothamad@users.noreply.github.com> Date: Tue, 27 Apr 2021 15:05:27 +0300 Subject: [PATCH 100/303] GothamAds Bid Adapter: add at, ccpa, gdpr and coppa support (#6470) * update gothamAds adapter * update GothamAdsAdapter according to commetns. Add meta for adomains --- modules/gothamadsBidAdapter.js | 61 ++++++-- test/spec/modules/gothamadsBidAdapter_spec.js | 133 ++++++++++++------ 2 files changed, 138 insertions(+), 56 deletions(-) diff --git a/modules/gothamadsBidAdapter.js b/modules/gothamadsBidAdapter.js index f2d2a9f5261..ff6fa5221f3 100644 --- a/modules/gothamadsBidAdapter.js +++ b/modules/gothamadsBidAdapter.js @@ -1,12 +1,19 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import * as utils from '../src/utils.js'; -import {config} from '../src/config.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'gothamads'; const ACCOUNTID_MACROS = '[account_id]'; const URL_ENDPOINT = `https://us-e-node1.gothamads.com/bid?pass=${ACCOUNTID_MACROS}&integration=prebidjs`; -const NATIVE_ASSET_IDS = { 0: 'title', 2: 'icon', 3: 'image', 5: 'sponsoredBy', 4: 'body', 1: 'cta' }; +const NATIVE_ASSET_IDS = { + 0: 'title', + 2: 'icon', + 3: 'image', + 5: 'sponsoredBy', + 4: 'body', + 1: 'cta' +}; const NATIVE_PARAMS = { title: { id: 0, @@ -94,9 +101,23 @@ export const spec = { source: { tid: bidRequest.transactionId }, + regs: { + coppa: config.getConfig('coppa') === true ? 1 : 0, + ext: {} + }, tmax: bidRequest.timeout, imp: [impObject], }; + + if (bidRequest.gdprConsent && bidRequest.gdprConsent.gdprApplies) { + utils.deepSetValue(data, 'regs.ext.gdpr', bidRequest.gdprConsent.gdprApplies ? 1 : 0); + utils.deepSetValue(data, 'user.ext.consent', bidRequest.gdprConsent.consentString); + } + + if (bidRequest.uspConsent !== undefined) { + utils.deepSetValue(data, 'regs.ext.us_privacy', bidRequest.uspConsent); + } + bids.push(data) } return { @@ -114,10 +135,10 @@ export const spec = { */ interpretResponse: (serverResponse) => { if (!serverResponse || !serverResponse.body) return [] - let GothamAdskResponse = serverResponse.body; + let GothamAdsResponse = serverResponse.body; let bids = []; - for (let response of GothamAdskResponse) { + for (let response of GothamAdsResponse) { let mediaType = response.seatbid[0].bid[0].ext && response.seatbid[0].bid[0].ext.mediaType ? response.seatbid[0].bid[0].ext.mediaType : BANNER; let bid = { @@ -133,16 +154,21 @@ export const spec = { mediaType: mediaType }; + bid.meta = {}; + if (response.seatbid[0].bid[0].adomain && response.seatbid[0].bid[0].adomain.length > 0) { + bid.meta.advertiserDomains = response.seatbid[0].bid[0].adomain; + } + switch (mediaType) { case VIDEO: - bid.vastXml = response.seatbid[0].bid[0].adm - bid.vastUrl = response.seatbid[0].bid[0].ext.vastUrl - break + bid.vastXml = response.seatbid[0].bid[0].adm; + bid.vastUrl = response.seatbid[0].bid[0].ext.vastUrl; + break; case NATIVE: - bid.native = parseNative(response.seatbid[0].bid[0].adm) - break + bid.native = parseNative(response.seatbid[0].bid[0].adm); + break; default: - bid.ad = response.seatbid[0].bid[0].adm + bid.ad = response.seatbid[0].bid[0].adm; } bids.push(bid); @@ -164,18 +190,27 @@ const checkRequestType = (bidRequest, type) => { } const parseNative = admObject => { - const { assets, link, imptrackers, jstracker } = admObject.native; + const { + assets, + link, + imptrackers, + jstracker + } = admObject.native; const result = { clickUrl: link.url, clickTrackers: link.clicktrackers || undefined, impressionTrackers: imptrackers || undefined, - javascriptTrackers: jstracker ? [ jstracker ] : undefined + javascriptTrackers: jstracker ? [jstracker] : undefined }; assets.forEach(asset => { const kind = NATIVE_ASSET_IDS[asset.id]; const content = kind && asset[NATIVE_PARAMS[kind].name]; if (content) { - result[kind] = content.text || content.value || { url: content.url, width: content.w, height: content.h }; + result[kind] = content.text || content.value || { + url: content.url, + width: content.w, + height: content.h + }; } }); diff --git a/test/spec/modules/gothamadsBidAdapter_spec.js b/test/spec/modules/gothamadsBidAdapter_spec.js index c638e7a0e3e..f0a3ea253f3 100644 --- a/test/spec/modules/gothamadsBidAdapter_spec.js +++ b/test/spec/modules/gothamadsBidAdapter_spec.js @@ -1,5 +1,6 @@ import { expect } from 'chai'; import { spec } from 'modules/gothamadsBidAdapter.js'; +import { config } from 'src/config.js'; const NATIVE_BID_REQUEST = { code: 'native_example', @@ -44,7 +45,10 @@ const BANNER_BID_REQUEST = { code: 'banner_example', mediaTypes: { banner: { - sizes: [[300, 250], [300, 600]] + sizes: [ + [300, 250], + [300, 600] + ] } }, bidder: 'gothamads', @@ -53,7 +57,11 @@ const BANNER_BID_REQUEST = { accountId: 'accountId' }, timeout: 1000, - + gdprConsent: { + consentString: 'BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA', + gdprApplies: 1, + }, + uspConsent: 'uspConsent' } const bidRequest = { @@ -65,26 +73,27 @@ const bidRequest = { const VIDEO_BID_REQUEST = { code: 'video1', sizes: [640, 480], - mediaTypes: { video: { - minduration: 0, - maxduration: 999, - boxingallowed: 1, - skip: 0, - mimes: [ - 'application/javascript', - 'video/mp4' - ], - w: 1920, - h: 1080, - protocols: [ - 2 - ], - linearity: 1, - api: [ - 1, - 2 - ] - } + mediaTypes: { + video: { + minduration: 0, + maxduration: 999, + boxingallowed: 1, + skip: 0, + mimes: [ + 'application/javascript', + 'video/mp4' + ], + w: 1920, + h: 1080, + protocols: [ + 2 + ], + linearity: 1, + api: [ + 1, + 2 + ] + } }, bidder: 'gothamads', @@ -148,20 +157,29 @@ const NATIVE_BID_RESPONSE = { impid: 'request_imp_id', price: 5, adomain: ['example.com'], - adm: { native: + adm: { + native: { + assets: [{ + id: 0, + title: 'dummyText' + }, + { + id: 3, + image: imgData + }, { - assets: [ - {id: 0, title: 'dummyText'}, - {id: 3, image: imgData}, - { - id: 5, - data: {value: 'organization.name'} - } - ], - link: {url: 'example.com'}, - imptrackers: ['tracker1.com', 'tracker2.com', 'tracker3.com'], - jstracker: 'tracker1.com' + id: 5, + data: { + value: 'organization.name' + } } + ], + link: { + url: 'example.com' + }, + imptrackers: ['tracker1.com', 'tracker2.com', 'tracker3.com'], + jstracker: 'tracker1.com' + } }, crid: 'crid', ext: { @@ -171,8 +189,23 @@ const NATIVE_BID_RESPONSE = { }], }; -describe('GothamAdsAdapter', function() { - describe('isBidRequestValid', function() { +describe('GothamAdsAdapter', function () { + describe('with COPPA', function () { + beforeEach(function () { + sinon.stub(config, 'getConfig') + .withArgs('coppa') + .returns(true); + }); + afterEach(function () { + config.getConfig.restore(); + }); + + it('should send the Coppa "required" flag set to "1" in the request', function () { + let serverRequest = spec.buildRequests([BANNER_BID_REQUEST]); + expect(serverRequest.data[0].regs.coppa).to.equal(1); + }); + }); + describe('isBidRequestValid', function () { it('should return true when required params found', function () { expect(spec.isBidRequestValid(NATIVE_BID_REQUEST)).to.equal(true); }); @@ -221,6 +254,12 @@ describe('GothamAdsAdapter', function() { expect(request.data).to.exist; }); + it('check consent and ccpa string is set properly', function () { + expect(request.data[0].regs.ext.gdpr).to.equal(1); + expect(request.data[0].user.ext.consent).to.equal(BANNER_BID_REQUEST.gdprConsent.consentString); + expect(request.data[0].regs.ext.us_privacy).to.equal(BANNER_BID_REQUEST.uspConsent); + }); + it('sends bid request to our endpoint via POST', function () { expect(request.method).to.equal('POST'); }); @@ -250,7 +289,7 @@ describe('GothamAdsAdapter', function() { }); describe('interpretResponse', function () { - it('Empty response must return empty array', function() { + it('Empty response must return empty array', function () { const emptyResponse = null; let response = spec.interpretResponse(emptyResponse); @@ -273,6 +312,7 @@ describe('GothamAdsAdapter', function() { creativeId: BANNER_BID_RESPONSE.seatbid[0].bid[0].crid, dealId: BANNER_BID_RESPONSE.seatbid[0].bid[0].dealid, mediaType: 'banner', + meta: BANNER_BID_RESPONSE.seatbid[0].bid[0].adomain, ad: BANNER_BID_RESPONSE.seatbid[0].bid[0].adm } @@ -281,13 +321,14 @@ describe('GothamAdsAdapter', function() { expect(bannerResponses).to.be.an('array').that.is.not.empty; let dataItem = bannerResponses[0]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); expect(dataItem.requestId).to.equal(expectedBidResponse.requestId); expect(dataItem.cpm).to.equal(expectedBidResponse.cpm); expect(dataItem.ad).to.equal(expectedBidResponse.ad); expect(dataItem.ttl).to.equal(expectedBidResponse.ttl); expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId); expect(dataItem.netRevenue).to.be.true; + expect(dataItem.meta).to.have.property('advertiserDomains', expectedBidResponse.meta); expect(dataItem.currency).to.equal(expectedBidResponse.currency); expect(dataItem.width).to.equal(expectedBidResponse.width); expect(dataItem.height).to.equal(expectedBidResponse.height); @@ -309,6 +350,7 @@ describe('GothamAdsAdapter', function() { creativeId: VIDEO_BID_RESPONSE.seatbid[0].bid[0].crid, dealId: VIDEO_BID_RESPONSE.seatbid[0].bid[0].dealid, mediaType: 'video', + meta: VIDEO_BID_RESPONSE.seatbid[0].bid[0].adomain, vastXml: VIDEO_BID_RESPONSE.seatbid[0].bid[0].adm, vastUrl: VIDEO_BID_RESPONSE.seatbid[0].bid[0].ext.vastUrl } @@ -318,12 +360,13 @@ describe('GothamAdsAdapter', function() { expect(videoResponses).to.be.an('array').that.is.not.empty; let dataItem = videoResponses[0]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'vastXml', 'vastUrl', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); expect(dataItem.requestId).to.equal(expectedBidResponse.requestId); expect(dataItem.cpm).to.equal(expectedBidResponse.cpm); - expect(dataItem.vastXml).to.equal(expectedBidResponse.vastXml) + expect(dataItem.vastXml).to.equal(expectedBidResponse.vastXml); expect(dataItem.ttl).to.equal(expectedBidResponse.ttl); expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId); + expect(dataItem.meta).to.have.property('advertiserDomains', expectedBidResponse.meta); expect(dataItem.netRevenue).to.be.true; expect(dataItem.currency).to.equal(expectedBidResponse.currency); expect(dataItem.width).to.equal(expectedBidResponse.width); @@ -345,8 +388,11 @@ describe('GothamAdsAdapter', function() { netRevenue: true, creativeId: NATIVE_BID_RESPONSE.seatbid[0].bid[0].crid, dealId: NATIVE_BID_RESPONSE.seatbid[0].bid[0].dealid, + meta: NATIVE_BID_RESPONSE.seatbid[0].bid[0].adomain, mediaType: 'native', - native: {clickUrl: NATIVE_BID_RESPONSE.seatbid[0].bid[0].adm.native.link.url} + native: { + clickUrl: NATIVE_BID_RESPONSE.seatbid[0].bid[0].adm.native.link.url + } } let nativeResponses = spec.interpretResponse(nativeResponse); @@ -354,11 +400,12 @@ describe('GothamAdsAdapter', function() { expect(nativeResponses).to.be.an('array').that.is.not.empty; let dataItem = nativeResponses[0]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'native', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'dealId', 'mediaType'); + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); expect(dataItem.requestId).to.equal(expectedBidResponse.requestId); expect(dataItem.cpm).to.equal(expectedBidResponse.cpm); - expect(dataItem.native.clickUrl).to.equal(expectedBidResponse.native.clickUrl) + expect(dataItem.native.clickUrl).to.equal(expectedBidResponse.native.clickUrl); expect(dataItem.ttl).to.equal(expectedBidResponse.ttl); + expect(dataItem.meta).to.have.property('advertiserDomains', expectedBidResponse.meta); expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId); expect(dataItem.netRevenue).to.be.true; expect(dataItem.currency).to.equal(expectedBidResponse.currency); From cef4c899710733e6c8097a06efc3849a425a0a54 Mon Sep 17 00:00:00 2001 From: Thomas Skaarnes Nikitin <48713095+thomas-netric@users.noreply.github.com> Date: Tue, 27 Apr 2021 14:15:34 +0200 Subject: [PATCH 101/303] Rubicon Bid Adapter: Added new size - Id 558 (640x640) (#6658) --- modules/rubiconBidAdapter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index b8670706b60..6c6ac83318a 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -109,7 +109,8 @@ var sizeMap = { 288: '640x380', 548: '500x1000', 550: '980x480', - 552: '300x200' + 552: '300x200', + 558: '640x640' }; utils._each(sizeMap, (item, key) => sizeMap[item] = key); From a0241781ef02ffac7e991b43e2ef2f6a65f9e23a Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Tue, 27 Apr 2021 08:48:38 -0400 Subject: [PATCH 102/303] AOL, RTBHouse, RhythmOne, Teads, OpenX and DeepIntent Bid Adapters: add support for meta.advertiserDomains (#6656) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Delete iasBidAdapter.js * Add files via upload * Update deepintentBidAdapter.js * Update deepintentBidAdapter_spec.js * Update rtbhouseBidAdapter.js * Update rtbhouseBidAdapter_spec.js * Update deepintentBidAdapter.js * Update rtbhouseBidAdapter.js * Update rtbhouseBidAdapter.js * Update rtbhouseBidAdapter_spec.js * Update deepintentBidAdapter.js * Update rhythmoneBidAdapter.js * Update rhythmoneBidAdapter_spec.js * Update aolBidAdapter.js * Update aolBidAdapter_spec.js * Update aolBidAdapter.js * Update aolBidAdapter.js * Update teadsBidAdapter.js * Update teadsBidAdapter_spec.js * Update openxBidAdapter_spec.js * Update openxBidAdapter.js * Update openxBidAdapter.js * Update openxBidAdapter_spec.js * Update openxBidAdapter.js --- modules/aolBidAdapter.js | 3 +++ modules/deepintentBidAdapter.js | 3 +++ modules/openxBidAdapter.js | 10 ++++++---- modules/rhythmoneBidAdapter.js | 3 +++ modules/rtbhouseBidAdapter.js | 6 ++++++ modules/teadsBidAdapter.js | 3 +++ test/spec/modules/aolBidAdapter_spec.js | 3 +++ test/spec/modules/deepintentBidAdapter_spec.js | 1 + test/spec/modules/openxBidAdapter_spec.js | 10 +++++----- test/spec/modules/rhythmoneBidAdapter_spec.js | 1 + test/spec/modules/rtbhouseBidAdapter_spec.js | 2 ++ test/spec/modules/teadsBidAdapter_spec.js | 6 ++++++ 12 files changed, 42 insertions(+), 9 deletions(-) diff --git a/modules/aolBidAdapter.js b/modules/aolBidAdapter.js index c899da32340..5a5d5e6f417 100644 --- a/modules/aolBidAdapter.js +++ b/modules/aolBidAdapter.js @@ -417,6 +417,9 @@ export const spec = { currency: response.cur || 'USD', dealId: bidData.dealid, netRevenue: true, + meta: { + advertiserDomains: bidData && bidData.adomain ? bidData.adomain : [] + }, ttl: bidRequest.ttl }; }, diff --git a/modules/deepintentBidAdapter.js b/modules/deepintentBidAdapter.js index 9ec6c8e5bc2..a6a6cac6570 100644 --- a/modules/deepintentBidAdapter.js +++ b/modules/deepintentBidAdapter.js @@ -88,6 +88,9 @@ function formatResponse(bid) { width: bid && bid.w ? bid.w : 0, height: bid && bid.h ? bid.h : 0, ad: bid && bid.adm ? bid.adm : '', + meta: { + advertiserDomains: bid && bid.adomain ? bid.adomain : [] + }, creativeId: bid && bid.crid ? bid.crid : undefined, netRevenue: false, currency: bid && bid.cur ? bid.cur : 'USD', diff --git a/modules/openxBidAdapter.js b/modules/openxBidAdapter.js index 460a721cb8b..8a455f6fa25 100644 --- a/modules/openxBidAdapter.js +++ b/modules/openxBidAdapter.js @@ -13,7 +13,6 @@ const DEFAULT_CURRENCY = 'USD'; export const USER_ID_CODE_TO_QUERY_ARG = { britepoolid: 'britepoolid', // BritePool ID criteoId: 'criteoid', // CriteoID - digitrustid: 'digitrustid', // DigiTrust fabrickId: 'nuestarid', // Fabrick ID by Nuestar haloId: 'audigentid', // Halo ID from Audigent id5id: 'id5id', // ID5 ID @@ -158,6 +157,12 @@ function createBannerBidResponses(oxResponseObj, {bids, startTime}) { bidResponse.meta.brandId = adUnit.brand_id; } + if (adUnit.adomain && length(adUnit.adomain) > 0) { + bidResponse.meta.advertiserDomains = adUnit.adomain; + } else { + bidResponse.meta.advertiserDomains = []; + } + if (adUnit.adv_id) { bidResponse.meta.dspid = adUnit.adv_id; } @@ -283,9 +288,6 @@ function appendUserIdsToQueryParams(queryParams, userIds) { if (USER_ID_CODE_TO_QUERY_ARG.hasOwnProperty(userIdProviderKey)) { switch (userIdProviderKey) { - case 'digitrustid': - queryParams[key] = utils.deepAccess(userIdObjectOrValue, 'data.id'); - break; case 'lipb': queryParams[key] = userIdObjectOrValue.lipbid; break; diff --git a/modules/rhythmoneBidAdapter.js b/modules/rhythmoneBidAdapter.js index 1acbcfd0463..fa090044f05 100644 --- a/modules/rhythmoneBidAdapter.js +++ b/modules/rhythmoneBidAdapter.js @@ -253,6 +253,9 @@ function RhythmOneBidAdapter() { cpm: parseFloat(bid.price), width: bid.w, height: bid.h, + meta: { + advertiserDomains: bid.adomain + }, creativeId: bid.crid, currency: 'USD', netRevenue: true, diff --git a/modules/rtbhouseBidAdapter.js b/modules/rtbhouseBidAdapter.js index 3337c3f1b59..6b8fe05e8bb 100644 --- a/modules/rtbhouseBidAdapter.js +++ b/modules/rtbhouseBidAdapter.js @@ -302,6 +302,9 @@ function interpretBannerBid(serverBid) { width: serverBid.w, height: serverBid.h, ttl: TTL, + meta: { + advertiserDomains: serverBid.adomain + }, netRevenue: true, currency: 'USD' } @@ -320,6 +323,9 @@ function interpretNativeBid(serverBid) { width: 1, height: 1, ttl: TTL, + meta: { + advertiserDomains: serverBid.adomain + }, netRevenue: true, currency: 'USD', native: interpretNativeAd(serverBid.adm), diff --git a/modules/teadsBidAdapter.js b/modules/teadsBidAdapter.js index aad7f6762c4..32be7e62bbd 100644 --- a/modules/teadsBidAdapter.js +++ b/modules/teadsBidAdapter.js @@ -99,6 +99,9 @@ export const spec = { currency: bid.currency, netRevenue: true, ttl: bid.ttl, + meta: { + advertiserDomains: bid && bid.adomain ? bid.adomain : [] + }, ad: bid.ad, requestId: bid.bidId, creativeId: bid.creativeId, diff --git a/test/spec/modules/aolBidAdapter_spec.js b/test/spec/modules/aolBidAdapter_spec.js index 8e74e19f420..78be0618594 100644 --- a/test/spec/modules/aolBidAdapter_spec.js +++ b/test/spec/modules/aolBidAdapter_spec.js @@ -160,6 +160,9 @@ describe('AolAdapter', function () { currency: 'USD', dealId: 'deal-id', netRevenue: true, + meta: { + advertiserDomains: [] + }, ttl: bidRequest.ttl }); }); diff --git a/test/spec/modules/deepintentBidAdapter_spec.js b/test/spec/modules/deepintentBidAdapter_spec.js index 6d9b883e2bb..fcf7056fb3f 100644 --- a/test/spec/modules/deepintentBidAdapter_spec.js +++ b/test/spec/modules/deepintentBidAdapter_spec.js @@ -202,6 +202,7 @@ describe('Deepintent adapter', function () { expect(bResponse[0].height).to.equal(bannerResponse.body.seatbid[0].bid[0].h); expect(bResponse[0].currency).to.equal('USD'); expect(bResponse[0].netRevenue).to.equal(false); + expect(bResponse[0].meta.advertiserDomains).to.deep.equal(['deepintent.com']); expect(bResponse[0].ttl).to.equal(300); expect(bResponse[0].creativeId).to.equal(bannerResponse.body.seatbid[0].bid[0].crid); expect(bResponse[0].dealId).to.equal(bannerResponse.body.seatbid[0].bid[0].dealId); diff --git a/test/spec/modules/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js index 580fd3dec93..7391c8826bc 100644 --- a/test/spec/modules/openxBidAdapter_spec.js +++ b/test/spec/modules/openxBidAdapter_spec.js @@ -1043,7 +1043,6 @@ describe('OpenxAdapter', function () { const EXAMPLE_DATA_BY_ATTR = { britepoolid: '1111-britepoolid', criteoId: '1111-criteoId', - digitrustid: {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}}, fabrickId: '1111-fabrickid', haloId: '1111-haloid', id5id: {uid: '1111-id5id'}, @@ -1099,9 +1098,6 @@ describe('OpenxAdapter', function () { let userIdValue; // handle cases where userId key refers to an object switch (userIdProviderKey) { - case 'digitrustid': - userIdValue = EXAMPLE_DATA_BY_ATTR.digitrustid.data.id; - break; case 'lipb': userIdValue = EXAMPLE_DATA_BY_ATTR.lipb.lipbid; break; @@ -1574,7 +1570,11 @@ describe('OpenxAdapter', function () { expect(bid.meta.brandId).to.equal(DEFAULT_TEST_ARJ_AD_UNIT.brand_id); }); - it('should return a brand ID', function () { + it('should return an adomain', function () { + expect(bid.meta.advertiserDomains).to.deep.equal([]); + }); + + it('should return a dsp ID', function () { expect(bid.meta.dspid).to.equal(DEFAULT_TEST_ARJ_AD_UNIT.adv_id); }); }); diff --git a/test/spec/modules/rhythmoneBidAdapter_spec.js b/test/spec/modules/rhythmoneBidAdapter_spec.js index d9342332e61..93735c019e1 100644 --- a/test/spec/modules/rhythmoneBidAdapter_spec.js +++ b/test/spec/modules/rhythmoneBidAdapter_spec.js @@ -157,6 +157,7 @@ describe('rhythmone adapter tests', function () { expect(bid.width).to.equal(800); expect(bid.height).to.equal(600); expect(bid.vastUrl).to.equal('https://testdomain/rmp/placementid/0/path?reqId=1636037'); + expect(bid.meta.advertiserDomains).to.deep.equal(['test.com']); expect(bid.mediaType).to.equal('video'); expect(bid.creativeId).to.equal('cr-vid'); expect(bid.currency).to.equal('USD'); diff --git a/test/spec/modules/rtbhouseBidAdapter_spec.js b/test/spec/modules/rtbhouseBidAdapter_spec.js index efaed87dd15..77dfff35c4a 100644 --- a/test/spec/modules/rtbhouseBidAdapter_spec.js +++ b/test/spec/modules/rtbhouseBidAdapter_spec.js @@ -424,6 +424,7 @@ describe('RTBHouseAdapter', () => { 'mediaType': 'banner', 'currency': 'USD', 'ttl': 300, + 'meta': { advertiserDomains: ['rtbhouse.com'] }, 'netRevenue': true } ]; @@ -486,6 +487,7 @@ describe('RTBHouseAdapter', () => { it('should contain native assets in valid format', () => { const bids = spec.interpretResponse({body: response}, {}); + expect(bids[0].meta.advertiserDomains).to.deep.equal(['rtbhouse.com']); expect(bids[0].native).to.deep.equal({ title: 'Title text', clickUrl: encodeURIComponent('https://example.com'), diff --git a/test/spec/modules/teadsBidAdapter_spec.js b/test/spec/modules/teadsBidAdapter_spec.js index a6ae17ec8ff..3e1c3e78903 100644 --- a/test/spec/modules/teadsBidAdapter_spec.js +++ b/test/spec/modules/teadsBidAdapter_spec.js @@ -494,6 +494,9 @@ describe('teadsBidAdapter', () => { 'height': 250, 'currency': 'USD', 'netRevenue': true, + 'meta': { + advertiserDomains: [] + }, 'ttl': 360, 'ad': AD_SCRIPT, 'requestId': '3ede2a3fa0db94', @@ -505,6 +508,9 @@ describe('teadsBidAdapter', () => { 'height': 200, 'currency': 'USD', 'netRevenue': true, + 'meta': { + advertiserDomains: [] + }, 'ttl': 360, 'ad': AD_SCRIPT, 'requestId': '4fef3b4gb1ec15', From 1f046823dd05f5b8c6d9094aad1350a67f35a6ee Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Tue, 27 Apr 2021 18:29:48 +0200 Subject: [PATCH 103/303] Adnuntius Bid Adapter: bugfix to set undefined if no bids (#6662) * RTD Provider rebase * wrongly merged to master * Added meta field for advertiser domains. * Fixing bug where losing bids throw undefined into the response. * Wrapped if-statement --- modules/adnuntiusBidAdapter.js | 8 ++++---- test/spec/modules/adnuntiusBidAdapter_spec.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/adnuntiusBidAdapter.js b/modules/adnuntiusBidAdapter.js index 56f1bb02981..8752e37a96f 100644 --- a/modules/adnuntiusBidAdapter.js +++ b/modules/adnuntiusBidAdapter.js @@ -68,10 +68,10 @@ export const spec = { } else return response }, {}); - const bidResponse = bidRequest.bid.map(bid => bid.bidId) - .reduce((request, adunitId) => - request.concat(bidResponsesById[adunitId]) - , []); + const bidResponse = bidRequest.bid.map(bid => bid.bidId).reduce((request, adunitId) => { + if (bidResponsesById[adunitId]) { request.push(bidResponsesById[adunitId]) } + return request + }, []); return bidResponse }, diff --git a/test/spec/modules/adnuntiusBidAdapter_spec.js b/test/spec/modules/adnuntiusBidAdapter_spec.js index d234a345b5c..62073fc6aaa 100644 --- a/test/spec/modules/adnuntiusBidAdapter_spec.js +++ b/test/spec/modules/adnuntiusBidAdapter_spec.js @@ -78,8 +78,15 @@ describe('adnuntiusBidAdapter', function () { 'lineItemId': 'scyjdyv3mzgdsnpf', 'layoutId': 'sw6gtws2rdj1kwby', 'layoutName': 'Responsive image' - } + }, + ] + }, + { + 'auId': '000000000008b6bc', + 'targetId': '456', + 'matchedAdCount': 0, + 'responseId': 'adn-rsp-1460129238', } ] } @@ -115,7 +122,6 @@ describe('adnuntiusBidAdapter', function () { it('should return valid response when passed valid server response', function () { const interpretedResponse = spec.interpretResponse(serverResponse, singleBidRequest); const ad = serverResponse.body.adUnits[0].ads[0] - expect(interpretedResponse).to.have.lengthOf(1); expect(interpretedResponse[0].cpm).to.equal(ad.cpm.amount); expect(interpretedResponse[0].width).to.equal(Number(ad.creativeWidth)); From 71d75c4f212995ec49e9928f59ff19ee539a8b31 Mon Sep 17 00:00:00 2001 From: Robert Ray Martinez III Date: Tue, 27 Apr 2021 11:53:22 -0700 Subject: [PATCH 104/303] pass auctionId (#6664) --- modules/rubiconAnalyticsAdapter.js | 3 ++- test/spec/modules/rubiconAnalyticsAdapter_spec.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/rubiconAnalyticsAdapter.js b/modules/rubiconAnalyticsAdapter.js index f06af144b54..3237facb2e7 100644 --- a/modules/rubiconAnalyticsAdapter.js +++ b/modules/rubiconAnalyticsAdapter.js @@ -231,7 +231,8 @@ function sendMessage(auctionId, bidWonId) { clientTimeoutMillis: auctionCache.timeout, samplingFactor, accountId, - adUnits: Object.keys(adUnitMap).map(i => adUnitMap[i]) + adUnits: Object.keys(adUnitMap).map(i => adUnitMap[i]), + requestId: auctionId }; // pick our of top level floor data we want to send! diff --git a/test/spec/modules/rubiconAnalyticsAdapter_spec.js b/test/spec/modules/rubiconAnalyticsAdapter_spec.js index 3cfaa448472..df8bf03b56a 100644 --- a/test/spec/modules/rubiconAnalyticsAdapter_spec.js +++ b/test/spec/modules/rubiconAnalyticsAdapter_spec.js @@ -374,6 +374,7 @@ const ANALYTICS_MESSAGE = { 'referrerHostname': 'www.test.com', 'auctions': [ { + 'requestId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', 'clientTimeoutMillis': 3000, 'serverTimeoutMillis': 1000, 'accountId': 1001, From a96f1f953269ebe8be3795a036a27d6b38cf9ffa Mon Sep 17 00:00:00 2001 From: jackhsiehucf <77815341+jackhsiehucf@users.noreply.github.com> Date: Wed, 28 Apr 2021 16:58:36 +0800 Subject: [PATCH 105/303] ucfunnel Bid Adapter: add support for Unified ID 2 (#6647) * Add a new ucfunnel Adapter and test page * Add a new ucfunnel Adapter and test page * 1. Use prebid lib in the repo to keep updated 2. Replace var with let 3. Put JSON.parse(JSON.stringify()) into try catch block * utils.getTopWindowLocation is a function * Change to modules from adapters * Migrate to module design * [Dev Fix] Remove width and height which can be got from ad unit id * Update ucfunnelBidAdapter to fit into new spec * Correct the endpoint. Fix the error of query string * Add test case for ucfunnelBidAdapter * Fix lint error * Update version number * Combine all checks on bid request * Add GDPR support for ucfunnel adapter * Add in-stream video and native support for ucfunnel adapter * Remove demo page. Add more test cases. * Change request method from POST to GET * Remove unnecessary comment * Support vastXml and vastUrl for video request * update TTL to 30 mins * Avoid using arrow function which is not discuraged in mocha * ucfunnel tdid support * ucfunnel fix error message in debug mode * ucfunnel adapter add bidfloor parameter * ucfunnel adapter support CCPA * ucfunnel adapter native support clicktrackers * ucfunnel adapter change cookie sync setting * ucfunnel adapter update request parameter * Update ucfunnelBidAdapter * ucfunnel adapter add currency in ad response * ucfunnel adapter support uid2 Co-authored-by: root Co-authored-by: Ryan Chou Co-authored-by: ucfunnel Co-authored-by: jack.hsieh --- modules/ucfunnelBidAdapter.js | 5 +++++ test/spec/modules/ucfunnelBidAdapter_spec.js | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/ucfunnelBidAdapter.js b/modules/ucfunnelBidAdapter.js index 4003c6ed5fd..9b9134a8ef0 100644 --- a/modules/ucfunnelBidAdapter.js +++ b/modules/ucfunnelBidAdapter.js @@ -331,6 +331,11 @@ function addUserId(bidData, userId) { bidData[userIdProviderKey + '_linkType'] = userIdObjectOrValue.ext.linkType; } break; + case 'uid2': + if (userIdObjectOrValue.id) { + bidData['eids'] = userIdProviderKey + ',' + userIdObjectOrValue.id + } + break; default: bidData[userIdProviderKey] = userIdObjectOrValue; break; diff --git a/test/spec/modules/ucfunnelBidAdapter_spec.js b/test/spec/modules/ucfunnelBidAdapter_spec.js index a2939eb95c3..d7e82338ff3 100644 --- a/test/spec/modules/ucfunnelBidAdapter_spec.js +++ b/test/spec/modules/ucfunnelBidAdapter_spec.js @@ -16,7 +16,8 @@ const userId = { 'pubcid': 'd8aa10fa-d86c-451d-aad8-5f16162a9e64', 'sharedid': {'id': '01ESHXW4HD29KMF387T63JQ9H5', 'third': '01ESHXW4HD29KMF387T63JQ9H5'}, 'tdid': 'D6885E90-2A7A-4E0F-87CB-7734ED1B99A3', - 'haloId': {} + 'haloId': {}, + 'uid2': {'id': 'eb33b0cb-8d35-4722-b9c0-1a31d4064888'} } const validBannerBidReq = { @@ -158,6 +159,7 @@ describe('ucfunnel Adapter', function () { expect(data.adid).to.equal('ad-34BBD2AA24B678BBFD4E7B9EE3B872D'); expect(data.w).to.equal(width); expect(data.h).to.equal(height); + expect(data.eids).to.equal('uid2,eb33b0cb-8d35-4722-b9c0-1a31d4064888'); expect(data.schain).to.equal('1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com'); }); From 3419fc9e74397ff4cf5a264bf22d6d290eba5436 Mon Sep 17 00:00:00 2001 From: yuvalgg <57989766+yuvalgg@users.noreply.github.com> Date: Wed, 28 Apr 2021 15:27:53 +0300 Subject: [PATCH 106/303] Intent IQ ID Systems: first party updates (#6618) * New features in iiq * intentIqIdSystem.js updated logic & tests * Tests fix * api update * tests update --- modules/intentIqIdSystem.js | 129 ++++++++++++++++++--- test/spec/modules/intentIqIdSystem_spec.js | 60 +++++++--- 2 files changed, 159 insertions(+), 30 deletions(-) diff --git a/modules/intentIqIdSystem.js b/modules/intentIqIdSystem.js index c22a6dbc7aa..98732da95d5 100644 --- a/modules/intentIqIdSystem.js +++ b/modules/intentIqIdSystem.js @@ -8,32 +8,111 @@ import * as utils from '../src/utils.js' import {ajax} from '../src/ajax.js'; import {submodule} from '../src/hook.js' +import {getStorageManager} from '../src/storageManager.js'; + +const PCID_EXPIRY = 365; const MODULE_NAME = 'intentIqId'; +export const FIRST_PARTY_KEY = '_iiq_fdata'; + +export const storage = getStorageManager(undefined, MODULE_NAME); const NOT_AVAILABLE = 'NA'; /** - * Verify the id is valid - Id value or Not Found (ignore not available response) - * @param id - * @returns {boolean|*|boolean} + * Verify the response is valid - Id value or Not Found (ignore not available response) + * @param response + * @param respJson - parsed json response + * @returns {boolean} */ -function isValidId(id) { - return id && id != '' && id != NOT_AVAILABLE && isValidResponse(id); +function isValidResponse(response, respJson) { + if (!response || response == '' || response === NOT_AVAILABLE) { + // Empty or NA response + return false; + } else if (respJson && (respJson.RESULT === NOT_AVAILABLE || respJson.data == '' || respJson.data === NOT_AVAILABLE)) { + // Response type is json with value NA + return false; + } else { return true; } } /** - * Ignore not available response JSON - * @param obj + * Verify the response json is valid + * @param respJson - parsed json response * @returns {boolean} */ -function isValidResponse(obj) { +function isValidResponseJson(respJson) { + if (respJson && 'data' in respJson) { + return true; + } else { return false; } +} + +/** + * Generate standard UUID string + * @return {string} + */ +function generateGUID() { + let d = new Date().getTime(); + const guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + const r = (d + Math.random() * 16) % 16 | 0; + d = Math.floor(d / 16); + return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); + }); + return guid; +} + +/** + * Read Intent IQ data from cookie or local storage + * @param key + * @return {string} + */ +export function readData(key) { try { - obj = JSON.parse(obj); - return obj && obj['RESULT'] != NOT_AVAILABLE; + if (storage.hasLocalStorage()) { + return storage.getDataFromLocalStorage(key); + } + if (storage.cookiesAreEnabled()) { + return storage.getCookie(key); + } + } catch (error) { + utils.logError(error); + } +} + +/** + * Store Intent IQ data in either cookie or local storage + * expiration date: 365 days + * @param key + * @param {string} value IntentIQ ID value to sintentIqIdSystem_spec.jstore + */ +function storeData(key, value) { + try { + utils.logInfo(MODULE_NAME + ': storing data: key=' + key + ' value=' + value); + + if (value) { + if (storage.hasLocalStorage()) { + storage.setDataInLocalStorage(key, value); + } + const expiresStr = (new Date(Date.now() + (PCID_EXPIRY * (60 * 60 * 24 * 1000)))).toUTCString(); + if (storage.cookiesAreEnabled()) { + storage.setCookie(key, value, expiresStr, 'LAX'); + } + } } catch (error) { utils.logError(error); - return true; + } +} + +/** + * Parse json if possible, else return null + * @param data + * @param {object|null} + */ +function tryParse(data) { + try { + return JSON.parse(data); + } catch (err) { + utils.logError(err); + return null; } } @@ -51,7 +130,7 @@ export const intentIqIdSubmodule = { * @returns {{intentIqId: {string}}|undefined} */ decode(value) { - return isValidId(value) ? { 'intentIqId': value } : undefined; + return isValidResponse(value, undefined) ? { 'intentIqId': value } : undefined; }, /** * performs action to obtain id and return a value in the callback's response argument @@ -66,22 +145,42 @@ export const intentIqIdSubmodule = { return; } + // Read Intent IQ 1st party id or generate it if none exists + let firstPartyData = tryParse(readData(FIRST_PARTY_KEY)); + if (!firstPartyData || !firstPartyData.pcid) { + const firstPartyId = generateGUID(); + firstPartyData = { 'pcid': firstPartyId }; + storeData(FIRST_PARTY_KEY, JSON.stringify(firstPartyData)); + } + // use protocol relative urls for http or https let url = `https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=${configParams.partner}&pt=17&dpn=1`; url += configParams.pcid ? '&pcid=' + encodeURIComponent(configParams.pcid) : ''; url += configParams.pai ? '&pai=' + encodeURIComponent(configParams.pai) : ''; + if (firstPartyData) { + url += firstPartyData.pcid ? '&iiqidtype=2&iiqpcid=' + encodeURIComponent(firstPartyData.pcid) : ''; + url += firstPartyData.pid ? '&pid=' + encodeURIComponent(firstPartyData.pid) : ''; + } const resp = function (callback) { const callbacks = { success: response => { - if (isValidId(response)) { - callback(response); + let respJson = tryParse(response); + if (isValidResponse(response, respJson) && isValidResponseJson(respJson)) { + // Store pid field if found in response json + if (firstPartyData && 'pcid' in firstPartyData && 'pid' in respJson) { + firstPartyData = { + 'pcid': firstPartyData.pcid, + 'pid': respJson.pid } + storeData(FIRST_PARTY_KEY, JSON.stringify(firstPartyData)); + } + callback(respJson.data); } else { callback(); } }, error: error => { - utils.logError(`${MODULE_NAME}: ID fetch encountered an error`, error); + utils.logError(MODULE_NAME + ': ID fetch encountered an error', error); callback(); } }; diff --git a/test/spec/modules/intentIqIdSystem_spec.js b/test/spec/modules/intentIqIdSystem_spec.js index 4b45342cb6f..7e819195b9f 100644 --- a/test/spec/modules/intentIqIdSystem_spec.js +++ b/test/spec/modules/intentIqIdSystem_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import {intentIqIdSubmodule} from 'modules/intentIqIdSystem.js'; +import {intentIqIdSubmodule, readData, FIRST_PARTY_KEY} from 'modules/intentIqIdSystem.js'; import * as utils from 'src/utils.js'; import {server} from 'test/mocks/xhr.js'; @@ -46,7 +46,7 @@ describe('IntentIQ tests', function () { let submoduleCallback = intentIqIdSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1'); + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&iiqidtype=2&iiqpcid='); request.respond( 200, responseHeader, @@ -55,9 +55,9 @@ describe('IntentIQ tests', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should ignore NA and invalid responses', function () { - let resp = JSON.stringify({'RESULT': 'NA'}); - expect(intentIqIdSubmodule.decode(resp)).to.equal(undefined); + it('should ignore NA and invalid responses in decode', function () { + // let resp = JSON.stringify({'RESULT': 'NA'}); + // expect(intentIqIdSubmodule.decode(resp)).to.equal(undefined); expect(intentIqIdSubmodule.decode('NA')).to.equal(undefined); expect(intentIqIdSubmodule.decode('')).to.equal(undefined); expect(intentIqIdSubmodule.decode(undefined)).to.equal(undefined); @@ -68,7 +68,7 @@ describe('IntentIQ tests', function () { let submoduleCallback = intentIqIdSubmodule.getId(paiConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pai=11'); + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pai=11&iiqidtype=2&iiqpcid='); request.respond( 200, responseHeader, @@ -82,7 +82,7 @@ describe('IntentIQ tests', function () { let submoduleCallback = intentIqIdSubmodule.getId(pcidConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pcid=12'); + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pcid=12&iiqidtype=2&iiqpcid='); request.respond( 200, responseHeader, @@ -96,7 +96,7 @@ describe('IntentIQ tests', function () { let submoduleCallback = intentIqIdSubmodule.getId(allConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pcid=12&pai=11'); + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pcid=12&pai=11&iiqidtype=2&iiqpcid='); request.respond( 200, responseHeader, @@ -110,7 +110,7 @@ describe('IntentIQ tests', function () { let submoduleCallback = intentIqIdSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1'); + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&iiqidtype=2&iiqpcid='); request.respond( 204, responseHeader, @@ -118,7 +118,6 @@ describe('IntentIQ tests', function () { ); expect(callBackSpy.calledOnce).to.be.true; expect(request.response).to.equal(''); - expect(logErrorStub.calledOnce).to.not.be.true; }); it('should log an error and continue to callback if ajax request errors', function () { @@ -126,7 +125,7 @@ describe('IntentIQ tests', function () { let submoduleCallback = intentIqIdSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1'); + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&iiqidtype=2&iiqpcid='); request.respond( 503, responseHeader, @@ -135,17 +134,48 @@ describe('IntentIQ tests', function () { expect(callBackSpy.calledOnce).to.be.true; }); - it('should log an error and continue to callback if ajax request errors', function () { + it('should ignore {RESULT: NA} in get id', function () { let callBackSpy = sinon.spy(); let submoduleCallback = intentIqIdSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1'); + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&iiqidtype=2&iiqpcid='); request.respond( - 503, + 200, responseHeader, - 'Unavailable' + JSON.stringify({RESULT: 'NA'}) + ); + expect(callBackSpy.calledOnce).to.be.true; + expect(callBackSpy.args[0][0]).to.be.undefined; + }); + + it('should ignore NA in get id', function () { + let callBackSpy = sinon.spy(); + let submoduleCallback = intentIqIdSubmodule.getId(defaultConfigParams).callback; + submoduleCallback(callBackSpy); + let request = server.requests[0]; + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&iiqidtype=2&iiqpcid='); + request.respond( + 200, + responseHeader, + 'NA' + ); + expect(callBackSpy.calledOnce).to.be.true; + expect(callBackSpy.args[0][0]).to.be.undefined; + }); + + it('should parse result from json response', function () { + let callBackSpy = sinon.spy(); + let submoduleCallback = intentIqIdSubmodule.getId(allConfigParams).callback; + submoduleCallback(callBackSpy); + let request = server.requests[0]; + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pcid=12&pai=11&iiqidtype=2&iiqpcid='); + request.respond( + 200, + responseHeader, + JSON.stringify({pid: 'test_pid', data: 'test_personid'}) ); expect(callBackSpy.calledOnce).to.be.true; + expect(callBackSpy.args[0][0]).to.be.eq('test_personid'); }); }); From 9dee62404e815c2960a1e8c89619cb9d4a268df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rok=20Su=C5=A1nik?= Date: Wed, 28 Apr 2021 16:55:26 +0200 Subject: [PATCH 107/303] Outbrain Bid Adapter: fix usersync query parameter formatting (#6668) --- modules/outbrainBidAdapter.js | 10 +++++---- test/spec/modules/outbrainBidAdapter_spec.js | 22 ++++++-------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/modules/outbrainBidAdapter.js b/modules/outbrainBidAdapter.js index 304cdf2088c..c0af09c2b50 100644 --- a/modules/outbrainBidAdapter.js +++ b/modules/outbrainBidAdapter.js @@ -147,18 +147,20 @@ export const spec = { getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => { const syncs = []; let syncUrl = config.getConfig('outbrain.usersyncUrl'); + + let query = []; if (syncOptions.pixelEnabled && syncUrl) { if (gdprConsent) { - syncUrl += '&gdpr=' + (gdprConsent.gdprApplies & 1); - syncUrl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''); + query.push('gdpr=' + (gdprConsent.gdprApplies & 1)); + query.push('gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || '')); } if (uspConsent) { - syncUrl += '&us_privacy=' + encodeURIComponent(uspConsent); + query.push('us_privacy=' + encodeURIComponent(uspConsent)); } syncs.push({ type: 'image', - url: syncUrl + url: syncUrl + (query.length ? '?' + query.join('&') : '') }); } return syncs; diff --git a/test/spec/modules/outbrainBidAdapter_spec.js b/test/spec/modules/outbrainBidAdapter_spec.js index 9671adf826e..4bdd657f419 100644 --- a/test/spec/modules/outbrainBidAdapter_spec.js +++ b/test/spec/modules/outbrainBidAdapter_spec.js @@ -493,19 +493,9 @@ describe('Outbrain Adapter', function () { config.resetConfig() }) - it('should return user sync if pixel enabled', function () { - const ret = spec.getUserSyncs({pixelEnabled: true}) - expect(ret).to.deep.equal([{type: 'image', url: 'https://usersync-url.com'}]) - }) it('should return user sync if pixel enabled with outbrain config', function () { - config.resetConfig() - config.setConfig({ - outbrain: { - usersyncUrl: 'https://usersync-url.com', - } - }) const ret = spec.getUserSyncs({pixelEnabled: true}) - expect(ret).to.deep.equal([{type: 'image', url: 'https://usersync-url.com'}]) + expect(ret).to.deep.equal([{type: 'image', url: usersyncUrl}]) }) it('should not return user sync if pixel disabled', function () { @@ -521,25 +511,25 @@ describe('Outbrain Adapter', function () { it('should pass GDPR consent', function() { expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, undefined)).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=1&gdpr_consent=foo` + type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=foo` }]); expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: false, consentString: 'foo'}, undefined)).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=0&gdpr_consent=foo` + type: 'image', url: `${usersyncUrl}?gdpr=0&gdpr_consent=foo` }]); expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: undefined}, undefined)).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=1&gdpr_consent=` + type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=` }]); }); it('should pass US consent', function() { expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined, '1NYN')).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&us_privacy=1NYN` + type: 'image', url: `${usersyncUrl}?us_privacy=1NYN` }]); }); it('should pass GDPR and US consent', function() { expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, '1NYN')).to.deep.equal([{ - type: 'image', url: `${usersyncUrl}&gdpr=1&gdpr_consent=foo&us_privacy=1NYN` + type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=foo&us_privacy=1NYN` }]); }); }) From 43203d277440afda89ef8673a6c334ead648f1a9 Mon Sep 17 00:00:00 2001 From: John Rosendahl Date: Wed, 28 Apr 2021 10:00:01 -0600 Subject: [PATCH 108/303] Sovrn Bid Adapter: added FPD support (#6639) * added FPD support * using proper package-lock.json --- modules/sovrnBidAdapter.js | 28 +-- test/spec/modules/sovrnBidAdapter_spec.js | 220 ++++++++++++---------- 2 files changed, 131 insertions(+), 117 deletions(-) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index 9ec4d339753..708cb110dbd 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -2,6 +2,7 @@ import * as utils from '../src/utils.js' import { registerBidder } from '../src/adapters/bidderFactory.js' import { BANNER } from '../src/mediaTypes.js' import { createEidsArray } from './userId/eids.js'; +import {config} from '../src/config.js'; export const spec = { code: 'sovrn', @@ -72,30 +73,29 @@ export const spec = { bidfloor: floorInfo.floor } - const segmentsString = utils.getBidIdParameter('segments', bid.params) + imp.ext = utils.getBidIdParameter('ext', bid.ortb2Imp) || undefined + const segmentsString = utils.getBidIdParameter('segments', bid.params) if (segmentsString) { - imp.ext = { - deals: segmentsString.split(',').map(deal => deal.trim()) - } + imp.ext = imp.ext || {} + imp.ext.deals = segmentsString.split(',').map(deal => deal.trim()) } + sovrnImps.push(imp) + }) - sovrnImps.push(imp); - }); - - const page = bidderRequest.refererInfo.referer + const fpd = config.getConfig('ortb2') || {} + const site = fpd.site || {} + site.page = bidderRequest.refererInfo.referer // clever trick to get the domain - const domain = utils.parseUrl(page).hostname + site.domain = utils.parseUrl(site.page).hostname const sovrnBidReq = { id: utils.getUniqueIdentifierStr(), imp: sovrnImps, - site: { - page, - domain - } - }; + site: site, + user: fpd.user || {} + } if (schain) { sovrnBidReq.source = { diff --git a/test/spec/modules/sovrnBidAdapter_spec.js b/test/spec/modules/sovrnBidAdapter_spec.js index 84a0069c0b4..1050fdf4856 100644 --- a/test/spec/modules/sovrnBidAdapter_spec.js +++ b/test/spec/modules/sovrnBidAdapter_spec.js @@ -1,13 +1,14 @@ import {expect} from 'chai'; -import {LogError, spec} from 'modules/sovrnBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; +import {spec} from 'modules/sovrnBidAdapter.js'; +import {config} from 'src/config.js'; +import * as utils from 'src/utils.js' const ENDPOINT = `https://ap.lijit.com/rtb/bid?src=$$REPO_AND_VERSION$$`; const adUnitBidRequest = { 'bidder': 'sovrn', 'params': { - 'tagid': '403370' + 'tagid': 403370 }, 'adUnitCode': 'adunit-code', 'sizes': [ @@ -18,82 +19,61 @@ const adUnitBidRequest = { 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', } +const bidderRequest = { + refererInfo: { + referer: 'http://example.com/page.html', + } +}; describe('sovrnBidAdapter', function() { - const adapter = newBidder(spec); - describe('isBidRequestValid', function () { - const bid = { - 'bidder': 'sovrn', - 'params': { - 'tagid': '403370' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); + expect(spec.isBidRequestValid(adUnitBidRequest)).to.equal(true); }); it('should return false when tagid not passed correctly', function () { - bid.params.tagid = 'ABCD'; - expect(spec.isBidRequestValid(bid)).to.equal(false); + const bid = {...adUnitBidRequest} + const params = adUnitBidRequest.params + bid.params = {...params} + bid.params.tagid = 'ABCD' + expect(spec.isBidRequestValid(bid)).to.equal(false) }); it('should return false when require params are not passed', function () { - let bid = Object.assign({}, bid); + const bid = {...adUnitBidRequest} bid.params = {}; expect(spec.isBidRequestValid(bid)).to.equal(false); }); }); describe('buildRequests', function () { - const bidRequests = [{ - 'bidder': 'sovrn', - 'params': { - 'tagid': '403370' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - const bidderRequest = { - refererInfo: { - referer: 'http://example.com/page.html', - } - }; - const request = spec.buildRequests(bidRequests, bidderRequest); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('attaches source and version to endpoint URL as query params', function () { - expect(request.url).to.equal(ENDPOINT) - }); - - it('sets the proper banner object', function() { - const payload = JSON.parse(request.data) - expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]) - expect(payload.imp[0].banner.w).to.equal(1) - expect(payload.imp[0].banner.h).to.equal(1) - }) - - it('includes the ad unit code int the request', function() { - const payload = JSON.parse(request.data); - expect(payload.imp[0].adunitcode).to.equal('adunit-code') + describe('basic bid parameters', function() { + const bidRequests = [adUnitBidRequest]; + const request = spec.buildRequests(bidRequests, bidderRequest); + + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('attaches source and version to endpoint URL as query params', function () { + expect(request.url).to.equal(ENDPOINT) + }); + + it('sets the proper banner object', function() { + const payload = JSON.parse(request.data) + expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]) + expect(payload.imp[0].banner.w).to.equal(1) + expect(payload.imp[0].banner.h).to.equal(1) + }) + + it('includes the ad unit code int the request', function() { + const payload = JSON.parse(request.data); + expect(payload.imp[0].adunitcode).to.equal('adunit-code') + }) + + it('converts tagid to string', function () { + expect(request.data).to.contain('"tagid":"403370"') + }); }) it('accepts a single array as a size', function() { @@ -109,11 +89,6 @@ describe('sovrnBidAdapter', function() { 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475' }] - const bidderRequest = { - refererInfo: { - referer: 'http://example.com/page.html', - } - } const request = spec.buildRequests(singleSize, bidderRequest) const payload = JSON.parse(request.data) expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}]) @@ -149,7 +124,7 @@ describe('sovrnBidAdapter', function() { it('sends gdpr info if exists', function () { let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; - let bidderRequest = { + const bidderRequest = { 'bidderCode': 'sovrn', 'auctionId': '1d1a030790a475', 'bidderRequestId': '22edbae2733bf6', @@ -162,9 +137,9 @@ describe('sovrnBidAdapter', function() { referer: 'http://example.com/page.html', } }; - bidderRequest.bids = bidRequests; + bidderRequest.bids = [adUnitBidRequest]; - const data = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data); + const data = JSON.parse(spec.buildRequests([adUnitBidRequest], bidderRequest).data); expect(data.regs.ext.gdpr).to.exist.and.to.be.a('number'); expect(data.regs.ext.gdpr).to.equal(1); @@ -173,8 +148,8 @@ describe('sovrnBidAdapter', function() { }); it('should send us_privacy if bidderRequest has a value for uspConsent', function () { - let uspString = '1NYN'; - let bidderRequest = { + const uspString = '1NYN'; + const bidderRequest = { 'bidderCode': 'sovrn', 'auctionId': '1d1a030790a475', 'bidderRequestId': '22edbae2733bf6', @@ -184,39 +159,13 @@ describe('sovrnBidAdapter', function() { referer: 'http://example.com/page.html', } }; - bidderRequest.bids = bidRequests; + bidderRequest.bids = [adUnitBidRequest]; - const data = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data); + const data = JSON.parse(spec.buildRequests([adUnitBidRequest], bidderRequest).data); expect(data.regs.ext['us_privacy']).to.equal(uspString); }); - it('converts tagid to string', function () { - const ivBidRequests = [{ - 'bidder': 'sovrn', - 'params': { - 'tagid': 403370, - 'iv': 'vet' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - const bidderRequest = { - refererInfo: { - referer: 'http://example.com/page.html', - } - }; - const request = spec.buildRequests(ivBidRequests, bidderRequest); - - expect(request.data).to.contain('"tagid":"403370"') - }); - it('should add schain if present', function() { const schainRequests = [{ 'bidder': 'sovrn', @@ -243,7 +192,7 @@ describe('sovrnBidAdapter', function() { } ] } - }].concat(bidRequests); + }].concat(adUnitBidRequest); const bidderRequest = { refererInfo: { referer: 'http://example.com/page.html', @@ -272,7 +221,7 @@ describe('sovrnBidAdapter', function() { 'criteoId': 'A_CRITEO_ID', 'tdid': 'SOMESORTOFID', } - }].concat(bidRequests); + }].concat(adUnitBidRequest); const bidderRequest = { refererInfo: { referer: 'http://example.com/page.html', @@ -293,6 +242,7 @@ describe('sovrnBidAdapter', function() { }); it('should ignore empty segments', function() { + const request = spec.buildRequests([adUnitBidRequest], bidderRequest) const payload = JSON.parse(request.data) expect(payload.imp[0].ext).to.be.undefined }) @@ -337,6 +287,70 @@ describe('sovrnBidAdapter', function() { const payload = JSON.parse(request.data) expect(payload.imp[0].bidfloor).to.equal(2.00) }) + describe('First Party Data', function () { + let sandbox + + beforeEach(function() { + sandbox = sinon.sandbox.create() + }) + afterEach(function() { + sandbox.restore() + }) + it('should provide first party data if provided', function() { + sandbox.stub(config, 'getConfig').callsFake(key => { + const cfg = { + ortb2: { + site: { + keywords: 'test keyword' + }, + user: { + data: 'some user data' + } + } + }; + return utils.deepAccess(cfg, key); + }); + const request = spec.buildRequests([adUnitBidRequest], bidderRequest) + const payload = JSON.parse(request.data) + expect(payload.user.data).to.equal('some user data') + expect(payload.site.keywords).to.equal('test keyword') + expect(payload.site.page).to.equal('http://example.com/page.html') + expect(payload.site.domain).to.equal('example.com') + }) + it('should append impression first party data', function () { + const fpdBid = {...adUnitBidRequest} + fpdBid.ortb2Imp = { + ext: { + data: { + pbadslot: 'homepage-top-rect', + adUnitSpecificAttribute: '123' + } + } + } + const request = spec.buildRequests([fpdBid], bidderRequest) + const payload = JSON.parse(request.data) + expect(payload.imp[0].ext.data.pbadslot).to.equal('homepage-top-rect') + expect(payload.imp[0].ext.data.adUnitSpecificAttribute).to.equal('123') + }) + it('should not overwrite deals when impression fpd is present', function() { + const fpdBid = {...adUnitBidRequest} + fpdBid.params = {...adUnitBidRequest.params} + fpdBid.params.segments = 'seg1, seg2' + fpdBid.ortb2Imp = { + ext: { + data: { + pbadslot: 'homepage-top-rect', + adUnitSpecificAttribute: '123' + } + } + } + const request = spec.buildRequests([fpdBid], bidderRequest) + const payload = JSON.parse(request.data) + expect(payload.imp[0].ext.data.pbadslot).to.equal('homepage-top-rect') + expect(payload.imp[0].ext.data.adUnitSpecificAttribute).to.equal('123') + expect(payload.imp[0].ext.deals).to.deep.equal(['seg1', 'seg2']) + }) + }) }); describe('interpretResponse', function () { From 97964ef56d39b618ab1152e2e7edfd283beb6247 Mon Sep 17 00:00:00 2001 From: Reinout Stevens Date: Wed, 28 Apr 2021 18:41:51 +0200 Subject: [PATCH 109/303] Consent Management Module: TCFApi in Iframe callId fix (#6634) * fix random id * lint * fix for real Co-authored-by: Reinout Stevens --- modules/consentManagement.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/consentManagement.js b/modules/consentManagement.js index 67af2baf959..6a13e73b8a2 100644 --- a/modules/consentManagement.js +++ b/modules/consentManagement.js @@ -199,13 +199,13 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { function callCmpWhileInIframe(commandName, cmpFrame, moduleCallback) { let apiName = (cmpVersion === 2) ? '__tcfapi' : '__cmp'; - let callId = Math.random() + ''; let callName = `${apiName}Call`; /* Setup up a __cmp function to do the postMessage and stash the callback. - This function behaves (from the caller's perspective identicially to the in-frame __cmp call */ + This function behaves (from the caller's perspective identicially to the in-frame __cmp call */ if (cmpVersion === 2) { window[apiName] = function (cmd, cmpVersion, callback, arg) { + let callId = Math.random() + ''; let msg = { [callName]: { command: cmd, @@ -226,6 +226,7 @@ function lookupIabConsent(cmpSuccess, cmpError, hookConfig) { window[apiName](commandName, cmpVersion, moduleCallback); } else { window[apiName] = function (cmd, arg, callback) { + let callId = Math.random() + ''; let msg = { [callName]: { command: cmd, From e5f9f57c2499ab50086a0590d3aa907f436b7980 Mon Sep 17 00:00:00 2001 From: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Date: Wed, 28 Apr 2021 12:47:46 -0400 Subject: [PATCH 110/303] add support for non-purpose1 consent domains to appnexus and PBS bid adapters (#6484) * add support for non-purpose1 consent domains * fix logic and consentdata to clientSideSyncs * update openx vendor config --- .../gpt/prebidServer_example.html | 2 +- modules/appnexusBidAdapter.js | 19 ++-- modules/prebidServerBidAdapter/config.js | 30 ++++- modules/prebidServerBidAdapter/index.js | 64 +++++++++-- test/spec/modules/appnexusBidAdapter_spec.js | 4 +- .../modules/prebidServerBidAdapter_spec.js | 103 ++++++++++++------ 6 files changed, 157 insertions(+), 65 deletions(-) diff --git a/integrationExamples/gpt/prebidServer_example.html b/integrationExamples/gpt/prebidServer_example.html index 7761178efa8..37902edd979 100644 --- a/integrationExamples/gpt/prebidServer_example.html +++ b/integrationExamples/gpt/prebidServer_example.html @@ -56,10 +56,10 @@ s2sConfig : { accountId : '1', enabled : true, //default value set to false + defaultVendor: 'appnexus', bidders : ['appnexus'], timeout : 1000, //default value is 1000 adapter : 'prebidServer', //if we have any other s2s adapter, default value is s2s - endpoint : 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' } }); diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 6feec56e919..deb091fb2b7 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -11,6 +11,7 @@ import { getStorageManager } from '../src/storageManager.js'; const BIDDER_CODE = 'appnexus'; const URL = 'https://ib.adnxs.com/ut/v3/prebid'; +const URL_SIMPLE = 'https://ib.adnxs-simple.com/ut/v3/prebid'; const VIDEO_TARGETING = ['id', 'minduration', 'maxduration', 'skippable', 'playback_method', 'frameworks', 'context', 'skipoffset']; const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; @@ -53,9 +54,9 @@ const NATIVE_MAPPING = { }; const SOURCE = 'pbjs'; const MAX_IMPS_PER_REQUEST = 15; -const mappingFileUrl = 'https://acdn.adnxs.com/prebid/appnexus-mapping/mappings.json'; +const mappingFileUrl = 'https://acdn.adnxs-simple.com/prebid/appnexus-mapping/mappings.json'; const SCRIPT_TAG_START = ' { + if (utils.isStr(option[prop])) { + let temp = option[prop]; + option[prop] = { p1Consent: temp, noP1Consent: temp }; + } + }); +} + /** * @param {(S2SConfig[]|S2SConfig)} options */ @@ -135,6 +146,7 @@ function setS2sConfig(options) { const activeBidders = []; const optionsValid = normalizedOptions.every((option, i, array) => { + formatUrlParams(options); const updateSuccess = updateConfigDefaultVendor(option); if (updateSuccess !== false) { const valid = validateConfigRequiredProps(option); @@ -205,7 +217,7 @@ function queueSync(bidderCodes, gdprConsent, uspConsent, s2sConfig) { } const jsonPayload = JSON.stringify(payload); - ajax(s2sConfig.syncEndpoint, + ajax(getMatchingConsentUrl(s2sConfig.syncEndpoint, gdprConsent), (response) => { try { response = JSON.parse(response); @@ -285,11 +297,20 @@ function doBidderSync(type, url, bidder, done) { * * @param {Array} bidders a list of bidder names */ -function doClientSideSyncs(bidders) { +function doClientSideSyncs(bidders, gdprConsent, uspConsent) { bidders.forEach(bidder => { let clientAdapter = adapterManager.getBidAdapter(bidder); if (clientAdapter && clientAdapter.registerSyncs) { - clientAdapter.registerSyncs([]); + config.runWithBidder( + bidder, + utils.bind.call( + clientAdapter.registerSyncs, + clientAdapter, + [], + gdprConsent, + uspConsent + ) + ); } }); } @@ -978,6 +999,29 @@ function bidWonHandler(bid) { } } +function hasPurpose1Consent(gdprConsent) { + let result = true; + if (gdprConsent) { + if (gdprConsent.gdprApplies && gdprConsent.apiVersion === 2) { + result = !!(utils.deepAccess(gdprConsent, 'vendorData.purpose.consents.1') === true); + } + } + return result; +} + +function getMatchingConsentUrl(urlProp, gdprConsent) { + return hasPurpose1Consent(gdprConsent) ? urlProp.p1Consent : urlProp.noP1Consent; +} + +function getConsentData(bidRequests) { + let gdprConsent, uspConsent; + if (Array.isArray(bidRequests) && bidRequests.length > 0) { + gdprConsent = bidRequests[0].gdprConsent; + uspConsent = bidRequests[0].uspConsent; + } + return { gdprConsent, uspConsent }; +} + /** * Bidder adapter for Prebid Server */ @@ -987,6 +1031,7 @@ export function PrebidServer() { /* Prebid executes this function when the page asks to send out bid requests */ baseAdapter.callBids = function(s2sBidRequest, bidRequests, addBidResponse, done, ajax) { const adUnits = utils.deepClone(s2sBidRequest.ad_units); + let { gdprConsent, uspConsent } = getConsentData(bidRequests); // at this point ad units should have a size array either directly or mapped so filter for that const validAdUnits = adUnits.filter(unit => @@ -1000,13 +1045,7 @@ export function PrebidServer() { .filter(utils.uniques); if (Array.isArray(_s2sConfigs)) { - if (s2sBidRequest.s2sConfig && s2sBidRequest.s2sConfig.syncEndpoint) { - let gdprConsent, uspConsent; - if (Array.isArray(bidRequests) && bidRequests.length > 0) { - gdprConsent = bidRequests[0].gdprConsent; - uspConsent = bidRequests[0].uspConsent; - } - + if (s2sBidRequest.s2sConfig && s2sBidRequest.s2sConfig.syncEndpoint && getMatchingConsentUrl(s2sBidRequest.s2sConfig.syncEndpoint, gdprConsent)) { let syncBidders = s2sBidRequest.s2sConfig.bidders .map(bidder => adapterManager.aliasRegistry[bidder] || bidder) .filter((bidder, index, array) => (array.indexOf(bidder) === index)); @@ -1019,7 +1058,7 @@ export function PrebidServer() { utils.logInfo('BidRequest: ' + requestJson); if (request && requestJson) { ajax( - s2sBidRequest.s2sConfig.endpoint, + getMatchingConsentUrl(s2sBidRequest.s2sConfig.endpoint, gdprConsent), { success: response => handleResponse(response, requestedBidders, bidRequests, addBidResponse, done, s2sBidRequest.s2sConfig), error: done @@ -1035,6 +1074,7 @@ export function PrebidServer() { function handleResponse(response, requestedBidders, bidderRequests, addBidResponse, done, s2sConfig) { let result; let bids = []; + let { gdprConsent, uspConsent } = getConsentData(bidderRequests); try { result = JSON.parse(response); @@ -1061,7 +1101,7 @@ export function PrebidServer() { } done(); - doClientSideSyncs(requestedBidders); + doClientSideSyncs(requestedBidders, gdprConsent, uspConsent); } // Listen for bid won to call wurl diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 3a3f4effcb8..935bc23be03 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -796,7 +796,7 @@ describe('AppNexusAdapter', function () { config.getConfig.restore(); }); - it('should set withCredentials to false if purpose 1 consent is not given', function () { + it('should set simple domain variant if purpose 1 consent is not given', function () { let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; let bidderRequest = { 'bidderCode': 'appnexus', @@ -819,7 +819,7 @@ describe('AppNexusAdapter', function () { bidderRequest.bids = bidRequests; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.options).to.deep.equal({withCredentials: false}); + expect(request.url).to.equal('https://ib.adnxs-simple.com/ut/v3/prebid'); }); it('should populate eids when supported userIds are available', function () { diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 937d67677d9..b7be4948b0e 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -15,7 +15,10 @@ let CONFIG = { bidders: ['appnexus'], timeout: 1000, cacheMarkup: 2, - endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + endpoint: { + p1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction', + noP1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + } }; const REQUEST = { @@ -513,7 +516,7 @@ describe('S2S Adapter', function () { it('should default video placement if not defined and instream', function () { let ortb2Config = utils.deepClone(CONFIG); - ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + ortb2Config.endpoint.p1Consent = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; config.setConfig({ s2sConfig: ortb2Config }); @@ -592,7 +595,7 @@ describe('S2S Adapter', function () { it('check gdpr info gets added into cookie_sync request: have consent data', function () { let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync'; + cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; let consentConfig = { consentManagement: { cmpApi: 'iab' }, s2sConfig: cookieSyncConfig }; config.setConfig(consentConfig); @@ -618,7 +621,7 @@ describe('S2S Adapter', function () { it('check gdpr info gets added into cookie_sync request: have consent data but gdprApplies is false', function () { let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync'; + cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; let consentConfig = { consentManagement: { cmpApi: 'iab' }, s2sConfig: cookieSyncConfig }; config.setConfig(consentConfig); @@ -641,7 +644,7 @@ describe('S2S Adapter', function () { it('checks gdpr info gets added to cookie_sync request: applies is false', function () { let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync'; + cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; let consentConfig = { consentManagement: { cmpApi: 'iab' }, s2sConfig: cookieSyncConfig }; config.setConfig(consentConfig); @@ -690,7 +693,7 @@ describe('S2S Adapter', function () { it('is added to cookie_sync request when in bidRequest', function () { let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync'; + cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; config.setConfig({ s2sConfig: cookieSyncConfig }); let uspBidRequest = utils.deepClone(BID_REQUESTS); @@ -742,7 +745,7 @@ describe('S2S Adapter', function () { it('is added to cookie_sync request when in bidRequest', function () { let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync'; + cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; config.setConfig({ s2sConfig: cookieSyncConfig }); let consentBidRequest = utils.deepClone(BID_REQUESTS); @@ -789,7 +792,9 @@ describe('S2S Adapter', function () { it('adds device and app objects to request for OpenRTB', function () { const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + endpoint: { + p1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + } }); const _config = { @@ -1094,7 +1099,9 @@ describe('S2S Adapter', function () { it('skips pbs alias when skipPbsAliasing is enabled in adapter', function() { const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + endpoint: { + p1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + } }); config.setConfig({ s2sConfig: s2sConfig }); @@ -1123,7 +1130,9 @@ describe('S2S Adapter', function () { it('skips dynamic aliases to request when skipPbsAliasing enabled', function () { const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + endpoint: { + p1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + } }); config.setConfig({ s2sConfig: s2sConfig }); @@ -1155,7 +1164,9 @@ describe('S2S Adapter', function () { it('converts appnexus params to expected format for PBS', function () { const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + endpoint: { + p1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + } }); config.setConfig({ s2sConfig: s2sConfig }); @@ -1184,7 +1195,7 @@ describe('S2S Adapter', function () { it('adds limit to the cookie_sync request if userSyncLimit is greater than 0', function () { let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync'; + cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; cookieSyncConfig.userSyncLimit = 1; const s2sBidRequest = utils.deepClone(REQUEST); @@ -1203,7 +1214,7 @@ describe('S2S Adapter', function () { it('does not add limit to cooke_sync request if userSyncLimit is missing or 0', function () { let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync'; + cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; config.setConfig({ s2sConfig: cookieSyncConfig }); const s2sBidRequest = utils.deepClone(REQUEST); @@ -2020,7 +2031,9 @@ describe('S2S Adapter', function () { it('handles OpenRTB video responses', function () { const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebidserverurl/openrtb2/auction?querystring=param' + endpoint: { + p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' + } }); config.setConfig({ s2sConfig }); @@ -2042,7 +2055,9 @@ describe('S2S Adapter', function () { it('handles response cache from ext.prebid.cache.vastXml', function () { const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebidserverurl/openrtb2/auction?querystring=param' + endpoint: { + p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' + } }); config.setConfig({ s2sConfig }); const cacheResponse = utils.deepClone(RESPONSE_OPENRTB_VIDEO); @@ -2071,7 +2086,9 @@ describe('S2S Adapter', function () { it('add adserverTargeting object to bids when ext.prebid.targeting is defined', function () { const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebidserverurl/openrtb2/auction?querystring=param' + endpoint: { + p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' + } }); config.setConfig({ s2sConfig }); const cacheResponse = utils.deepClone(RESPONSE_OPENRTB_VIDEO); @@ -2102,7 +2119,9 @@ describe('S2S Adapter', function () { it('handles response cache from ext.prebid.targeting', function () { const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebidserverurl/openrtb2/auction?querystring=param' + endpoint: { + p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' + } }); config.setConfig({ s2sConfig }); const cacheResponse = utils.deepClone(RESPONSE_OPENRTB_VIDEO); @@ -2130,7 +2149,9 @@ describe('S2S Adapter', function () { it('handles response cache from ext.prebid.targeting with wurl', function () { const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebidserverurl/openrtb2/auction?querystring=param' + endpoint: { + p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' + } }); config.setConfig({ s2sConfig }); const cacheResponse = utils.deepClone(RESPONSE_OPENRTB_VIDEO); @@ -2157,7 +2178,9 @@ describe('S2S Adapter', function () { it('handles response cache from ext.prebid.targeting with wurl and removes invalid targeting', function () { const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebidserverurl/openrtb2/auction?querystring=param' + endpoint: { + p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' + } }); config.setConfig({ s2sConfig }); const cacheResponse = utils.deepClone(RESPONSE_OPENRTB_VIDEO); @@ -2192,7 +2215,9 @@ describe('S2S Adapter', function () { it('add request property pbsBidId with ext.prebid.bidid value', function () { const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebidserverurl/openrtb2/auction?querystring=param' + endpoint: { + p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' + } }); config.setConfig({ s2sConfig }); const cacheResponse = utils.deepClone(RESPONSE_OPENRTB_VIDEO); @@ -2216,7 +2241,9 @@ describe('S2S Adapter', function () { bidId: '123' }); const s2sConfig = Object.assign({}, CONFIG, { - endpoint: 'https://prebidserverurl/openrtb2/auction?querystring=param' + endpoint: { + p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' + } }); config.setConfig({ s2sConfig }); @@ -2260,7 +2287,9 @@ describe('S2S Adapter', function () { config.setConfig({ s2sConfig: Object.assign({}, CONFIG, { - endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + endpoint: { + p1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + } }) }); }); @@ -2349,7 +2378,9 @@ describe('S2S Adapter', function () { bidders: ['appnexus'], timeout: 1000, adapter: 'prebidServer', - endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + endpoint: { + p1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + } }; config.setConfig({ s2sConfig: options }); @@ -2362,7 +2393,9 @@ describe('S2S Adapter', function () { enabled: true, timeout: 1000, adapter: 's2s', - endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + endpoint: { + p1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' + } }; config.setConfig({ s2sConfig: options }); @@ -2409,8 +2442,8 @@ describe('S2S Adapter', function () { expect(vendorConfig).to.have.property('adapter', 'prebidServer'); expect(vendorConfig.bidders).to.deep.equal(['appnexus']); expect(vendorConfig.enabled).to.be.true; - expect(vendorConfig).to.have.property('endpoint', 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'); - expect(vendorConfig).to.have.property('syncEndpoint', 'https://prebid.adnxs.com/pbs/v1/cookie_sync'); + expect(vendorConfig.endpoint).to.deep.equal({p1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction', noP1Consent: 'https://prebid.adnxs-simple.com/pbs/v1/openrtb2/auction'}); + expect(vendorConfig.syncEndpoint).to.deep.equal({p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync', noP1Consent: 'https://prebid.adnxs-simple.com/pbs/v1/cookie_sync'}); expect(vendorConfig).to.have.property('timeout', 750); }); @@ -2430,8 +2463,8 @@ describe('S2S Adapter', function () { expect(vendorConfig).to.have.property('adapter', 'prebidServer'); expect(vendorConfig.bidders).to.deep.equal(['rubicon']); expect(vendorConfig.enabled).to.be.true; - expect(vendorConfig).to.have.property('endpoint', 'https://prebid-server.rubiconproject.com/openrtb2/auction'); - expect(vendorConfig).to.have.property('syncEndpoint', 'https://prebid-server.rubiconproject.com/cookie_sync'); + expect(vendorConfig.endpoint).to.deep.equal({p1Consent: 'https://prebid-server.rubiconproject.com/openrtb2/auction', noP1Consent: 'https://prebid-server.rubiconproject.com/openrtb2/auction'}); + expect(vendorConfig.syncEndpoint).to.deep.equal({p1Consent: 'https://prebid-server.rubiconproject.com/cookie_sync', noP1Consent: 'https://prebid-server.rubiconproject.com/cookie_sync'}); expect(vendorConfig).to.have.property('timeout', 750); }); @@ -2450,8 +2483,8 @@ describe('S2S Adapter', function () { 'bidders': ['rubicon'], 'defaultVendor': 'rubicon', 'enabled': true, - 'endpoint': 'https://prebid-server.rubiconproject.com/openrtb2/auction', - 'syncEndpoint': 'https://prebid-server.rubiconproject.com/cookie_sync', + 'endpoint': {p1Consent: 'https://prebid-server.rubiconproject.com/openrtb2/auction', noP1Consent: 'https://prebid-server.rubiconproject.com/openrtb2/auction'}, + 'syncEndpoint': {p1Consent: 'https://prebid-server.rubiconproject.com/cookie_sync', noP1Consent: 'https://prebid-server.rubiconproject.com/cookie_sync'}, 'timeout': 750 }) }); @@ -2472,8 +2505,8 @@ describe('S2S Adapter', function () { accountId: 'abc', bidders: ['rubicon'], defaultVendor: 'rubicon', - endpoint: 'https://prebid-server.rubiconproject.com/openrtb2/auction', - syncEndpoint: 'https://prebid-server.rubiconproject.com/cookie_sync', + endpoint: {p1Consent: 'https://prebid-server.rubiconproject.com/openrtb2/auction', noP1Consent: 'https://prebid-server.rubiconproject.com/openrtb2/auction'}, + syncEndpoint: {p1Consent: 'https://prebid-server.rubiconproject.com/cookie_sync', noP1Consent: 'https://prebid-server.rubiconproject.com/cookie_sync'}, }) }); @@ -2521,7 +2554,7 @@ describe('S2S Adapter', function () { // Add syncEndpoint so that the request goes to the User Sync endpoint // Modify the bidders property to include an alias for Rubicon adapter - s2sConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync'; + s2sConfig.syncEndpoint = {p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync'}; s2sConfig.bidders = ['appnexus', 'rubicon-alias']; const s2sBidRequest = utils.deepClone(REQUEST); @@ -2592,7 +2625,7 @@ describe('S2S Adapter', function () { it('should add cooperative sync flag to cookie_sync request if property is present', function () { let s2sConfig = utils.deepClone(CONFIG); s2sConfig.coopSync = false; - s2sConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync'; + s2sConfig.syncEndpoint = {p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync'}; const s2sBidRequest = utils.deepClone(REQUEST); s2sBidRequest.s2sConfig = s2sConfig; @@ -2607,7 +2640,7 @@ describe('S2S Adapter', function () { it('should not add cooperative sync flag to cookie_sync request if property is not present', function () { let s2sConfig = utils.deepClone(CONFIG); - s2sConfig.syncEndpoint = 'https://prebid.adnxs.com/pbs/v1/cookie_sync'; + s2sConfig.syncEndpoint = {p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync'}; const s2sBidRequest = utils.deepClone(REQUEST); s2sBidRequest.s2sConfig = s2sConfig; From 09dcc38c0633510e1b504c631ba8bb7e1b0010f9 Mon Sep 17 00:00:00 2001 From: TheMediaGrid <44166371+TheMediaGrid@users.noreply.github.com> Date: Wed, 28 Apr 2021 19:48:00 +0300 Subject: [PATCH 111/303] TheMediaGrid Bid Adapter: Coppa support (#6655) * Added TheMediaGridNM Bid Adapter * Updated required params for TheMediaGridNM Bid Adapter * Update TheMediGridNM Bid Adapter * Fix tests for TheMediaGridNM Bid Adapter * Fixes after review for TheMediaGridNM Bid Adapter * Add support of multi-format in TheMediaGrid Bid Adapter * Update sync url for grid and gridNM Bid Adapters * TheMediaGrid Bid Adapter: added keywords adUnit parameter * Update TheMediaGrid Bid Adapter to support keywords from config * Implement new request format for TheMediaGrid Bid Adapter * Fix jwpseg params for TheMediaGrid Bid Adapter * Update unit tests for The Media Grid Bid Adapter * Fix typo in TheMediaGrid Bid Adapter * Added test for jwTargeting in TheMediaGrid Bid Adapter * The new request format was made by default in TheMediaGrid Bid Adapter * Update userId format in ad request for TheMediaGrid Bid Adapter * Added bidFloor parameter for TheMediaGrid Bid Adapter * Fix for review TheMediaGrid Bid Adapter * Support floorModule in TheMediaGrid Bid Adapter * Fix empty bidfloor for TheMediaGrid Bid Adapter * Some change to restart autotests * Fix userIds format for TheMediaGrid Bid Adapter * Remove digitrust userId from TheMediaGrid Bid Adapter * Protocols was added in video section in ad request for TheMediaGrid Bid Adapter * TheMediaGrid: fix trouble with alias using * TheMediaGridNM: fix trouble with alias * TheMediaGrid Bid Adapter: added support of PBAdSlot module * TheMediaGrid Bid Adapter: fix typo * TheMediaGrid Bid Adapter: support coppa --- modules/gridBidAdapter.js | 11 +++++++++-- test/spec/modules/gridBidAdapter_spec.js | 10 ++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js index 994244b8a50..e7b42fc48e1 100644 --- a/modules/gridBidAdapter.js +++ b/modules/gridBidAdapter.js @@ -1,8 +1,8 @@ import * as utils from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; import { Renderer } from '../src/Renderer.js'; import { VIDEO, BANNER } from '../src/mediaTypes.js'; -import {config} from '../src/config.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'grid'; const ENDPOINT_URL = 'https://grid.bidswitch.net/hbjson'; @@ -219,6 +219,13 @@ export const spec = { request.regs.ext.us_privacy = uspConsent; } + if (config.getConfig('coppa') === true) { + if (!request.regs) { + request.regs = {}; + } + request.regs.coppa = 1; + } + return { method: 'POST', url: ENDPOINT_URL, diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js index 6cdef43b150..f2e70614562 100644 --- a/test/spec/modules/gridBidAdapter_spec.js +++ b/test/spec/modules/gridBidAdapter_spec.js @@ -428,6 +428,16 @@ describe('TheMediaGrid Adapter', function () { expect(payload.tmax).to.equal(3000); getConfigStub.restore(); }); + it('should contain regs.coppa if coppa is true in config', function () { + const getConfigStub = sinon.stub(config, 'getConfig').callsFake( + arg => arg === 'coppa' ? true : null); + const request = spec.buildRequests([bidRequests[0]], bidderRequest); + expect(request.data).to.be.an('string'); + const payload = parseRequest(request.data); + expect(payload).to.have.property('regs'); + expect(payload.regs).to.have.property('coppa', 1); + getConfigStub.restore(); + }); it('should contain imp[].ext.data.adserver if available', function() { const ortb2Imp = [{ ext: { From 581a699c3b479761af81917a6b29b32fb869000e Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Wed, 28 Apr 2021 09:48:48 -0700 Subject: [PATCH 112/303] Trigger AUCTION_DEBUG from utils.logWarn with type set to WARNING (#6645) * added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * emit AUCTION_DEBUG for logWarn with type WARNING * fixed the unit test case --- src/utils.js | 1 + test/spec/AnalyticsAdapter_spec.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils.js b/src/utils.js index bd3257ab7e7..7d273807ce7 100644 --- a/src/utils.js +++ b/src/utils.js @@ -264,6 +264,7 @@ export function logWarn() { if (debugTurnedOn() && consoleWarnExists) { console.warn.apply(console, decorateLog(arguments, 'WARNING:')); } + events.emit(CONSTANTS.EVENTS.AUCTION_DEBUG, {type: 'WARNING', arguments: arguments}); } export function logError() { diff --git a/test/spec/AnalyticsAdapter_spec.js b/test/spec/AnalyticsAdapter_spec.js index 71fb9f87fa0..2b36848bd8f 100644 --- a/test/spec/AnalyticsAdapter_spec.js +++ b/test/spec/AnalyticsAdapter_spec.js @@ -49,8 +49,10 @@ FEATURE: Analytics Adapters API events.emit(eventType, args); adapter.enableAnalytics(); - let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.deep.equal({args: {wat: 'wot'}, eventType: 'bidResponse'}); + // As now AUCTION_DEBUG is triggered for WARNINGS too, the BID_RESPONSE goes last in the array + const index = server.requests.length - 1; + let result = JSON.parse(server.requests[index].requestBody); + expect(result).to.deep.equal({eventType: 'bidResponse', args: {wat: 'wot'}}); }); describe(`WHEN an event occurs after enable analytics\n`, function () { From 75bb9e316fe330d885b93209107ce01b7821b134 Mon Sep 17 00:00:00 2001 From: prebidtappx <77485538+prebidtappx@users.noreply.github.com> Date: Wed, 28 Apr 2021 19:27:08 +0200 Subject: [PATCH 113/303] Tappx Bid Adapter: optional ext on request (#6659) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * UPDATE: add initial UID * UPDATE: UID change user ext * UPDATE: UID clean logs * UPDATE: add host info * UPDATE: tappx bid adapter universal id * UPDATE: fix bidder param * UPDATE: tappxBidAdapter tests * tappxBidAdapter - fix spacing * tappxBidAdapter: add test user eids array * tappxBidAdapter: update eids array * FIX: package-lock.json * Conversant adapter: add adomain, remove digitrust (#6495) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Update conversantBidAdapter.js * Update conversantBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Rads Bid Adapter: add GDPR support & user sync support (#6455) * Proxistore Bid Adapter: add cookieless url endpoint & use floor module (#6427) * use floor module * call cookieless endpoint when necessary * test endpoint url * change url endpoint * delete console log * fix tests * add language to url * use ortb interface * unit test * update test unit * create proxistore module * add unit tests and documentation * delete modules * delete module * add proxistore rtd submodule * delete proxistore module * spacing * change url * AdYoulike Bid Adapter: Add an "Insertion" tracking for Native mediatype (#6481) * add insertion event * add missing campaign ID parameter * update unit test with new tracking checked * Dspx Bid Adapter : add user sync support (#6456) * Add sync support for dspx adapter * Dspx Bid Adapter : add user sync support Co-authored-by: Alexander * Multibid Module: add new module to handle multiple bids from single bidder & update rubicon adapter (#6404) * Multibid module - create new module - Expands the number of key value pairs going to the ad server in the normal Prebid way by establishing the concept of a "dynamic alias" First commit * Continued updates from 1st commit * Adding logWarn for filtered bids * Update to include passing multibid configuration to PBS requests * Update to rubicon bid adapter to pass query param rp_maxbids value taken from bidderRequest.bidLimit * Update to config to look for camelcase property names according to spec. These convert to all lowercase when passed to PBS endpoint * Adjust RP adapter to always include maxbids value - default is 1 * Added support for bidders array in multibid config * Fixed floor comparison to be <= bid cpm as oppossed to just < bid cpm. Updated md file to fix camelCase tpyo * Update to include originalBidderRequest in video call to prebid cache * Update to ignore adpod bids from multibid and allow them to return as normal bids * Adding uid2 to submodules.json (#6508) * NextRoll ID System: add new ID module (#6396) * Add Nextroll ID Module * Add nextroll to eids * Make configuration value names consistent with Adapter Module * Use parnerId instead of sellerId * Add nextroll to userId and eids md files * Remove storage configuration * Rename nextroll -> nextrollId * Add nextrollId to common ID specs * Qwarry Bid Adapter: add GDPR and consent string handling (#6489) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: pro-nsk <32703851+pro-nsk@users.noreply.github.com> * Zemanta Bid Adapter: add support for new params & consent strings to usersync URL (#6468) * add gvl id to spec * add support for bcat and badv params * add consent strings to usersync url * add bcat and badv params to doc * Automatad Bid Adapter: Add meta.advertiserDomains to bid response (#6509) * added bid meta with advertiserDomains * Adhese Bid Adapter: add support for caching video content (#6501) * adpod category support test * Revert "adpod category support test" This reverts commit 70a3cf2ad5db94757addd9e08c3a083caca282d0. * adpod category support test * Revert "adpod category support test" This reverts commit 70a3cf2ad5db94757addd9e08c3a083caca282d0. * Adhese Bid Adapter: cache video content Co-authored-by: Tim Sturtewagen Co-authored-by: Mateusz * update apacdex unit test to disable debug mode (#6511) * Telaria: not setting adid (#6507) * Prebid 4.33.0 Release * increment pre version * rubicon: removing maxduration as a required bidder parameter (#6513) * Zemanta adapter: add advertiserDomains (#6517) * Lemma Bid Adapter: accepting the floor to use the getFloor function (#6497) * lemmaBidAdapter.js Added lemma bid adapter file * lemmaBidAdapter.md Added lemma bid adapter md file * lemmaBidAdapter_spec.js Added lemma bid adapter test spec file * Update lemmaBidAdapter.js Fixed automated code review alert comparison between inconvertible types * Update lemmaBidAdapter.js Fixed review changes * Update lemmaBidAdapter.md Correct parameter value. * Update lemmaBidAdapter.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter_spec.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.md Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.js Added user sync support into bid adapter. * updated include modules file extension. updated include modules js file extension. * Update lemmaBidAdapter_spec.js Added unit test for user sync feature. * Update lemmaBidAdapter.js Fixed format error. * Update lemmaBidAdapter_spec.js Fixed format error and typo error. * Set mediaType key value into bid object Set mediaType key value into the bid object. * Update lemmaBidAdapter.js remove duplicate function * Update lemmaBidAdapter.js Remove non supported code. * Update lemmaBidAdapter_spec.js Remove GDPR test cases. * Update lemmaBidAdapter.js Made changes for accepting the floor to use the getFloor function * Update lemmaBidAdapter.js correct undefined keyword name. * Update lemmaBidAdapter_spec.js Added test coverage floor value * Update lemmaBidAdapter.js Remove trailing spaces on lines 379 and 381. * Update lemmaBidAdapter_spec.js Added getFloor function test case changes, Please review it. * Update lemmaBidAdapter_spec.js * Update lemmaBidAdapter.js * Update lemmaBidAdapter.js Fixed lint issue. * Update lemmaBidAdapter_spec.js Fixed test cases. * Update lemmaBidAdapter_spec.js Made suggested changes. Please review it. Co-authored-by: Abhijit Mane * Mediasquare Bid Adapter: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event (#6480) * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * removing status as it does not seem populated when called * add tests * Update nextroll ID variable name to match published ID module (#6519) * Merkle User ID Module: updates to user id submodule (#6503) * AdKernel Bid/Analytics Adapters: user privacy related changes (#6488) * SynacorMedia: remove adId from the bid response (#6520) * Rubicon: making doc data types consistent (#6526) * Synacormedia Bid Adapter: add meta.advertiserDomains (#6527) * Adloox Analytics Adapter: add new analytics adapter (#6308) * gulp: fix supplying list of browsers to test against The following now works: gulp test --browserstack --nolint --nolintfix --browsers=bs_ie_11_windows_10 --file 'test/spec/modules/adloox{AnalyticsAdapter,AdServerVideo,RtdProvider}_spec.js' * instreamTracking: unit test tidy From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * adloaderStub: expose stub for other unit tests to use From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * Adloox analytic module * Seedtag adapter: Fixing bug preventing to receive the right params onTimeout. (#6525) * adot bid adapter: add publisher path from bidder config to endpoint url (#6476) * Admixer ID System: add userId submodule (#6238) * Migrating to Prebid 1.0 * Migrating to Prebid 1.0 * Fix spec * add gdpr and usp * remove changes in gdpr_hello_world.html * Update gdpr_hello_world.html add spaces * add user syncs * remove comments * tests * admixer id system * admixer id system * admixer id system eids.md userId.md * admixer id system .submodules.json * admixer id system Co-authored-by: atkachov * PBJS Core: call custom render func after loadscript if provided (#6422) * Pubxai Analytics Adapter: bug fixes and code revamp (#6474) * Updated PubxAiAnalytics adapter - Bug fixes and Code restructuring * Updated endpoint URLs * Changed array.includes to array.indexOf to fix IE issue * Code cleanup and changes as suggested. * Updated browser testing order and edge browser token * PBJS Core: canBidderRegisterSync ignoring iframe sync disabled by default (#6535) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Update userSync.js * Update userSync_spec.js * Added automatic tzo and targetId to adserver request. (#6534) * Impactify Bid Adapter: add new bid adapter (#6518) * Add impactify adapter with MD file * Add impactify adapter * Prebid 4.34.0 Release * Increment pre version * Prebid server adapter: add config for openx hosting (#6530) * Yieldmo adapter: add meta data to bids (#6550) * Smartx Bid Adapter: Add meta.advertiserDomains support (#6547) * Onevideo / Adap.tv Adapter: updated example configuration (#6546) * Mass Deal Rendering Module: support multiple custom configs for dealId and rendering (#6500) * ZetaSsp Bid Adapter: add new bid adapter (#6432) * Adnuntius Bid Adapter: Fix for bid too low. (#6557) * Added automatic tzo and targetId to adserver request. * Fixing issues with bid price being too low. * Fixing issues with bid price being too low. * ReadPeak Bid Adapter: fix api issues, add gdpr consent, & getfloor module support (#6548) * BetweenBidAdatper: added sharedid support (#6531) * adWMG Bid Adapter: update endpoints for cookie sync (#6544) * Support floorCPM parameter, fix some minor bugs * fix space-in-parens circleci error * example fix * clean usersync URL * spaces * spaces * add new unit tests, compatibility with IE11 * remove logInfo * Check for floorCPM value * Check params before sending * New endpoints * code format * new endpoint for cookie sync * update tests Co-authored-by: Mikhail Dykun * Yieldmo Bid Adapter: add support for the floors module (#6541) * Sortable Bid Adapter: add eids support (#6565) * Add Sortable adapter for Prebid 3.x Update tests to reflect changes. * Add .js in imports * hostname not host: don't include port * Trivial change to trigger build: failure wasn't our adapter * More failures in other adapters * PR Feedback - use https for URL - fix examples in markdown - request to endpoint should work now * Feedback: add native and video examples * Update unit tests Co-authored-by: Shannon Broekhoven * Outbrain Bid Adapter: replacing Zemanta (#6558) * Sirdata Real-time Data Module: add new RTD module (#6515) * Logicad Bid Adapter: add support for userid modules (#6529) * ATS-identityLinkIdSystem - add use3P config property to control firing of 3P envelope endpoint (#6568) * Proxistore Bid Adapter: add support for tcf v2 consent (#6543) * use tcf v2 consent * set cosentGiven to false and test Gdpr api v2 * BlueBillyWig Bid Adapter: add renderer customization options (#6540) * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Update bluebillywigBidAdapter test parameters to match renderer to rendererCode rename * Blue Billywig - Also pass through site config with OpenRTB request * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Code quality update, always hit user syncs, improved video params * Remove unnecessary export * Add rendererSettings param to bluebillywig adapter * Kick off CircleCi tests manually Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie * OpenX Bid Adapter: Set Deal ID for video requests (#6573) * 33Across Bid Adapter: add support for User ID modules (#6554) * pubGENIUS bid adapter: support floor module (#6555) * Welect Bid Adapter: update url of API (#6570) * update api url * update api url in tests * Bright Mountain Media Bid Adapter: change bidder code to bmtm; alias old name (#6574) * Adtelligent Bid Adapter: add adUrl support & new alias (#6559) * add adUrl support * add adUrl test * Bright Mountain Media Bid Adapter: Change Endpoint URL (#6576) * tappxBidAdapter: update * tasppxBidAdapter: add video * tappxBidAdapter: update video * tappxBidAdapter: update name interpret banner * tappxBidAdapter: add tests for video * tappxBidAdapter: add adomain * tappxBidAdapter: update adapter version * tappxBidAdapter: update interpretBid adomain and dealid * tappxBidAdapter: update isBidRequestValid * tappxBidAdapter: update tests. Adding video to isBidRequestValid * tappxBidAdapter: update doc .md file * Tappx - Allow optional ext object * Tappx - CircleCI hotfixes * Tappx - CircleCI hotfixes2 * Tappx - Avoid outBrain Co-authored-by: marc_tappx Co-authored-by: Patrick McCann Co-authored-by: onlsol <48312668+onlsol@users.noreply.github.com> Co-authored-by: vincentproxistore <56686565+vincentproxistore@users.noreply.github.com> Co-authored-by: guiann Co-authored-by: Alexander Co-authored-by: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Co-authored-by: SKOCHERI <37454420+SKOCHERI@users.noreply.github.com> Co-authored-by: Abimael Martinez Co-authored-by: artemiokost Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: pro-nsk <32703851+pro-nsk@users.noreply.github.com> Co-authored-by: Rok Sušnik Co-authored-by: Kanchika - Automatad Co-authored-by: Paweł L Co-authored-by: Tim Sturtewagen Co-authored-by: Mateusz Co-authored-by: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Co-authored-by: bretg Co-authored-by: Jason Snellbaker Co-authored-by: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Co-authored-by: Abhijit Mane Co-authored-by: matthieularere-msq <63732822+matthieularere-msq@users.noreply.github.com> Co-authored-by: Denis Logachov Co-authored-by: RAJKUMAR NATARAJAN Co-authored-by: Alexander Clouter Co-authored-by: Laura Morillo-Velarde Co-authored-by: Giudici-a <34242194+Giudici-a@users.noreply.github.com> Co-authored-by: Galphimbl Co-authored-by: atkachov Co-authored-by: Jérémie Girault Co-authored-by: Phaneendra Hegde Co-authored-by: Mikael Lundin Co-authored-by: Thomas Co-authored-by: Mike Chowla Co-authored-by: Deivydas Šabaras Co-authored-by: ym-atsymuk <81176595+ym-atsymuk@users.noreply.github.com> Co-authored-by: Skylinar <53079123+Skylinar@users.noreply.github.com> Co-authored-by: Adam Browning <19834421+adam-browning@users.noreply.github.com> Co-authored-by: Catalin Ciocov Co-authored-by: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Co-authored-by: readpeaktuomo <66239046+readpeaktuomo@users.noreply.github.com> Co-authored-by: Ignat Khaylov Co-authored-by: nyakove <43004249+nyakove@users.noreply.github.com> Co-authored-by: Mikhail Dykun Co-authored-by: ym-dlabuzov <81709888+ym-dlabuzov@users.noreply.github.com> Co-authored-by: karentnarvaez <61426156+karentnarvaez@users.noreply.github.com> Co-authored-by: Shannon Broekhoven Co-authored-by: nouchy <33549554+nouchy@users.noreply.github.com> Co-authored-by: logicad Co-authored-by: mamatic <52153441+mamatic@users.noreply.github.com> Co-authored-by: Klaas-Jan Boon Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie Co-authored-by: Kenan Gillet <1706856+kenan-gillet@users.noreply.github.com> Co-authored-by: Aparna Rao Co-authored-by: Meng <5110935+edmonl@users.noreply.github.com> Co-authored-by: Nick Duitz <42961155+nduitz@users.noreply.github.com> Co-authored-by: BrightMountainMedia <69471268+BrightMountainMediaInc@users.noreply.github.com> Co-authored-by: Gena Co-authored-by: Albert Grandes --- modules/tappxBidAdapter.js | 6 +++++- modules/tappxBidAdapter.md | 2 +- test/spec/modules/tappxBidAdapter_spec.js | 25 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/modules/tappxBidAdapter.js b/modules/tappxBidAdapter.js index 1228fbafaad..1cf5a0f8be7 100644 --- a/modules/tappxBidAdapter.js +++ b/modules/tappxBidAdapter.js @@ -181,6 +181,7 @@ function buildOneRequest(validBidRequests, bidderRequest) { const ENDPOINT = utils.deepAccess(validBidRequests, 'params.endpoint'); const TAPPXKEY = utils.deepAccess(validBidRequests, 'params.tappxkey'); const BIDFLOOR = utils.deepAccess(validBidRequests, 'params.bidfloor'); + const BIDEXTRA = utils.deepAccess(validBidRequests, 'params.ext'); const bannerMediaType = utils.deepAccess(validBidRequests, 'mediaTypes.banner'); const videoMediaType = utils.deepAccess(validBidRequests, 'mediaTypes.video'); const { refererInfo } = bidderRequest; @@ -266,6 +267,7 @@ function buildOneRequest(validBidRequests, bidderRequest) { bidder.tappxkey = TAPPXKEY; bidder.endpoint = ENDPOINT; bidder.host = hostInfo.url; + bidder.ext = (typeof BIDEXTRA == 'object') ? BIDEXTRA : undefined; imp.ext = {}; imp.ext.bidder = bidder; @@ -336,7 +338,9 @@ function buildOneRequest(validBidRequests, bidderRequest) { payload.params = params; payload.regs = regs; // < Payload - + utils.logMessage('---------------------'); + utils.logMessage(JSON.stringify(payload)); + utils.logMessage('---------------------'); return { method: 'POST', url: `https://${HOST}/${ENDPOINT}?type_cnn=${TYPE_CNN}&v=${TAPPX_BIDDER_VERSION}`, diff --git a/modules/tappxBidAdapter.md b/modules/tappxBidAdapter.md index e6581a67d06..a07bb2d88d1 100644 --- a/modules/tappxBidAdapter.md +++ b/modules/tappxBidAdapter.md @@ -67,4 +67,4 @@ Ads sizes available: [320,50], [300,250], [320,480], [1024,768], [728,90] }] } ]; -``` \ No newline at end of file +``` diff --git a/test/spec/modules/tappxBidAdapter_spec.js b/test/spec/modules/tappxBidAdapter_spec.js index 378b391a4eb..8197c4f44dd 100644 --- a/test/spec/modules/tappxBidAdapter_spec.js +++ b/test/spec/modules/tappxBidAdapter_spec.js @@ -215,6 +215,31 @@ describe('Tappx bid adapter', function () { expect(data.imp[0].banner.w).to.be.oneOf([320, 50, 250, 480]); expect(data.imp[0].banner.h).to.be.oneOf([320, 50, 250, 480]); }); + + it('should properly build a ext optional object', function() { + let extBidRequest = c_VALIDBIDREQUESTS; + extBidRequest[0].params.ext = {'optionalData': '1234'}; + let extBidderRequest = c_BIDDERREQUEST_B; + extBidderRequest.bids[0].ext = {'optionalData': '1234'}; + + const request = spec.buildRequests(extBidRequest, extBidderRequest); + const data = JSON.parse(request[0].data); + expect(data.imp[0].ext.bidder.ext).to.be.an('object'); + expect(data.imp[0].ext.bidder.ext.optionalData).to.be.equal('1234'); + }); + + it('should ignore ext optional if is not a object', function() { + let badExtBidRequest = c_VALIDBIDREQUESTS; + badExtBidRequest[0].params.ext = 'stringValue'; + let badExtBidderRequest = c_BIDDERREQUEST_B; + badExtBidderRequest.bids[0].ext = 'stringValue'; + + const request = spec.buildRequests(badExtBidRequest, badExtBidderRequest); + const data = JSON.parse(request[0].data); + expect(data.imp[0].ext.bidder.ext).not.to.be.an('string'); + expect(data.imp[0].ext.bidder.ext).to.be.an('undefined'); + expect(data.imp[0].ext.bidder).to.not.have.property('ext') + }); }); /** From 75d8c527a2e70efb68ba464aaffb5661c311ece0 Mon Sep 17 00:00:00 2001 From: Eric Harper Date: Wed, 28 Apr 2021 13:46:52 -0400 Subject: [PATCH 114/303] Prebid 4.37.0 Release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de3ad74eb51..5a16fe6798b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.37.0-pre", + "version": "4.37.0", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From c21ad7e264140c42e8e492e2315b2ad225e8c9a7 Mon Sep 17 00:00:00 2001 From: Adam Browning <19834421+adam-browning@users.noreply.github.com> Date: Thu, 29 Apr 2021 01:09:32 +0300 Subject: [PATCH 115/303] oneVideo Bid Adapter: Price Floors Module Support (SAPR-16735) (#6672) --- modules/oneVideoBidAdapter.js | 20 +++- test/spec/modules/oneVideoBidAdapter_spec.js | 103 +++++++++++++++++-- 2 files changed, 112 insertions(+), 11 deletions(-) diff --git a/modules/oneVideoBidAdapter.js b/modules/oneVideoBidAdapter.js index 60d56cfc8ad..e57c9d12ff7 100644 --- a/modules/oneVideoBidAdapter.js +++ b/modules/oneVideoBidAdapter.js @@ -4,7 +4,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'oneVideo'; export const spec = { code: 'oneVideo', - VERSION: '3.0.7', + VERSION: '3.1.0', ENDPOINT: 'https://ads.adaptv.advertising.com/rtb/openrtb?ext_id=', E2ETESTENDPOINT: 'https://ads-wc.v.ssp.yahoo.com/rtb/openrtb?ext_id=', SYNC_ENDPOINT1: 'https://pixel.advertising.com/ups/57304/sync?gdpr=&gdpr_consent=&_origin=0&redir=true', @@ -165,14 +165,17 @@ function getRequestData(bid, consentData, bidRequest) { let loc = bidRequest.refererInfo.referer; let page = (bid.params.site && bid.params.site.page) ? (bid.params.site.page) : (loc.href); let ref = (bid.params.site && bid.params.site.referrer) ? bid.params.site.referrer : bidRequest.refererInfo.referer; + let getFloorRequestObject = { + currency: bid.params.cur || 'USD', + mediaType: 'video', + size: '*' + }; let bidData = { id: utils.generateUUID(), at: 2, - cur: bid.cur || 'USD', imp: [{ id: '1', secure: isSecure(), - bidfloor: bid.params.bidfloor, ext: { hb: 1, prebidver: '$prebid.version$', @@ -226,6 +229,7 @@ function getRequestData(bid, consentData, bidRequest) { bidData.imp[0].video.linearity = 1; bidData.imp[0].video.protocols = bid.params.video.protocols || [2, 5]; } else if (bid.params.video.display == 1) { + getFloorRequestObject.mediaType = 'banner'; bidData.imp[0].banner = { mimes: bid.params.video.mimes, w: bid.params.video.playerWidth, @@ -244,6 +248,15 @@ function getRequestData(bid, consentData, bidRequest) { bidData.imp[0].banner.ext.minduration = bid.params.video.minduration } } + + if (utils.isFn(bid.getFloor)) { + let floorData = bid.getFloor(getFloorRequestObject); + bidData.imp[0].bidfloor = floorData.floor; + bidData.cur = floorData.currency; + } else { + bidData.imp[0].bidfloor = bid.params.bidfloor; + }; + if (bid.params.video.inventoryid) { bidData.imp[0].ext.inventoryid = bid.params.video.inventoryid } @@ -294,6 +307,7 @@ function getRequestData(bid, consentData, bidRequest) { } } if (bid.params.video.e2etest) { + utils.logMessage('+++ oneVideoBidAdapter: E2E test mode enabled. \n The following parameters are being overridden by e2etest mode:\n* bidfloor:null\n* width:300\n* height:250\n* mimes: video/mp4, application/javascript\n* api:2\n* site.page/ref: verizonmedia.com\n* tmax:1000'); bidData.imp[0].bidfloor = null; bidData.imp[0].video.w = 300; bidData.imp[0].video.h = 250; diff --git a/test/spec/modules/oneVideoBidAdapter_spec.js b/test/spec/modules/oneVideoBidAdapter_spec.js index 903bc191b47..3f5304dce0a 100644 --- a/test/spec/modules/oneVideoBidAdapter_spec.js +++ b/test/spec/modules/oneVideoBidAdapter_spec.js @@ -1,10 +1,5 @@ -import { - expect -} from 'chai'; -import { - spec -} from 'modules/oneVideoBidAdapter.js'; -import * as utils from 'src/utils.js'; +import { expect } from 'chai'; +import { spec } from 'modules/oneVideoBidAdapter.js'; describe('OneVideoBidAdapter', function () { let bidRequest; @@ -221,7 +216,7 @@ describe('OneVideoBidAdapter', function () { const placement = bidRequest.params.video.placement; const rewarded = bidRequest.params.video.rewarded; const inventoryid = bidRequest.params.video.inventoryid; - const VERSION = '3.0.7'; + const VERSION = '3.1.0'; expect(data.imp[0].video.w).to.equal(width); expect(data.imp[0].video.h).to.equal(height); expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor); @@ -503,6 +498,98 @@ describe('OneVideoBidAdapter', function () { }); }); + describe('price floor module validations', function () { + beforeEach(function () { + bidRequest.getFloor = (floorObj) => { + return { + floor: bidRequest.floors.values[floorObj.mediaType + '|640x480'], + currency: floorObj.currency, + mediaType: floorObj.mediaType + } + } + }); + + it('should get bidfloor from getFloor method', function () { + bidRequest.params.cur = 'EUR'; + bidRequest.floors = { + currency: 'EUR', + values: { + 'video|640x480': 5.55 + } + }; + const requests = spec.buildRequests([bidRequest], bidderRequest); + const data = requests[0].data; + expect(data.cur).is.a('string'); + expect(data.cur).to.equal('EUR'); + expect(data.imp[0].bidfloor).is.a('number'); + expect(data.imp[0].bidfloor).to.equal(5.55); + }); + + it('should use adUnit/module currency & floor instead of bid.params.bidfloor', function () { + bidRequest.params.cur = 'EUR'; + bidRequest.params.bidfloor = 3.33; + bidRequest.floors = { + currency: 'EUR', + values: { + 'video|640x480': 5.55 + } + }; + const requests = spec.buildRequests([bidRequest], bidderRequest); + const data = requests[0].data; + expect(data.cur).is.a('string'); + expect(data.cur).to.equal('EUR'); + expect(data.imp[0].bidfloor).is.a('number'); + expect(data.imp[0].bidfloor).to.equal(5.55); + }); + + it('should load banner instead of video floor when DAP is active bid.params.video.display = 1', function () { + bidRequest.params.video.display = 1; + bidRequest.params.cur = 'EUR'; + bidRequest.mediaTypes = { + banner: { + sizes: [ + [640, 480] + ] + } + }; + bidRequest.floors = { + currency: 'EUR', + values: { + 'banner|640x480': 2.22, + 'video|640x480': 9.99 + } + }; + const requests = spec.buildRequests([bidRequest], bidderRequest); + const data = requests[0].data; + expect(data.cur).is.a('string'); + expect(data.cur).to.equal('EUR'); + expect(data.imp[0].bidfloor).is.a('number'); + expect(data.imp[0].bidfloor).to.equal(2.22); + }) + + it('should load video floor when multi-format adUnit is present', function () { + bidRequest.params.cur = 'EUR'; + bidRequest.mediaTypes.banner = { + sizes: [ + [640, 480] + ] + }; + bidRequest.floors = { + currency: 'EUR', + values: { + 'banner|640x480': 2.22, + 'video|640x480': 9.99 + } + }; + const requests = spec.buildRequests([bidRequest], bidderRequest); + const data = requests[0].data; + expect(data.cur).is.a('string'); + expect(data.cur).to.equal('EUR'); + expect(data.imp[0].bidfloor).is.a('number'); + expect(data.imp[0].bidfloor).to.equal(9.99); + }) + }) + describe('spec.interpretResponse', function () { it('should return no bids if the response is not valid', function () { const bidResponse = spec.interpretResponse({ From d9a78013ee361d9e2a7ad6e85f8a4e6efc297ee0 Mon Sep 17 00:00:00 2001 From: Nepomuk Seiler Date: Thu, 29 Apr 2021 11:37:23 +0200 Subject: [PATCH 116/303] Spread adUnit.ortb2Imp.ext into imp object (#6494) --- modules/prebidServerBidAdapter/index.js | 10 +++++-- .../modules/prebidServerBidAdapter_spec.js | 26 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 4e396717cb2..38a499c794e 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -625,6 +625,7 @@ const OPEN_RTB_PROTOCOL = { } // get bidder params in form { : {...params} } + // initialize reduce function with the user defined `ext` properties on the ad unit const ext = adUnit.bids.reduce((acc, bid) => { const adapter = adapterManager.bidderRegistry[bid.bidder]; if (adapter && adapter.getSpec().transformBidParams) { @@ -632,7 +633,7 @@ const OPEN_RTB_PROTOCOL = { } acc[bid.bidder] = (s2sConfig.adapterOptions && s2sConfig.adapterOptions[bid.bidder]) ? Object.assign({}, bid.params, s2sConfig.adapterOptions[bid.bidder]) : bid.params; return acc; - }, {}); + }, {...utils.deepAccess(adUnit, 'ortb2Imp.ext')}); const imp = { id: adUnit.code, ext, secure: s2sConfig.secure }; @@ -643,7 +644,12 @@ const OPEN_RTB_PROTOCOL = { * @type {(string|undefined)} */ if (prop === 'pbadslot') { - if (typeof ortb2[prop] === 'string' && ortb2[prop]) utils.deepSetValue(imp, 'ext.data.pbadslot', ortb2[prop]); + if (typeof ortb2[prop] === 'string' && ortb2[prop]) { + utils.deepSetValue(imp, 'ext.data.pbadslot', ortb2[prop]); + } else { + // remove pbadslot property if it doesn't meet the spec + delete imp.ext.data.pbadslot; + } } else if (prop === 'adserver') { /** * Copy GAM AdUnit and Name to imp diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index b7be4948b0e..a6afed8ba3e 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -1825,6 +1825,32 @@ describe('S2S Adapter', function () { }); }); + describe('ext.prebid config', function () { + it('should send \"imp.ext.prebid.storedrequest.id\" if \"ortb2Imp.ext.prebid.storedrequest.id\" is set', function () { + const consentConfig = { s2sConfig: CONFIG }; + config.setConfig(consentConfig); + const bidRequest = utils.deepClone(REQUEST); + const storedRequestId = 'my-id'; + bidRequest.ad_units[0].ortb2Imp = { + ext: { + prebid: { + storedrequest: { + id: storedRequestId + } + } + } + }; + + adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax); + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); + + expect(parsedRequestBody.imp).to.be.a('array'); + expect(parsedRequestBody.imp[0]).to.be.a('object'); + expect(parsedRequestBody.imp[0]).to.have.deep.nested.property('ext.prebid.storedrequest.id'); + expect(parsedRequestBody.imp[0].ext.prebid.storedrequest.id).to.equal(storedRequestId); + }); + }); + describe('response handler', function () { beforeEach(function () { sinon.stub(utils, 'triggerPixel'); From 98964095eba4141ceef8a7ba7347e2125528b33c Mon Sep 17 00:00:00 2001 From: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Date: Thu, 29 Apr 2021 12:07:53 -0400 Subject: [PATCH 117/303] appnexus bid adapter - ensure withCredentials is always passed (#6675) --- modules/appnexusBidAdapter.js | 5 ++++- test/spec/modules/appnexusBidAdapter_spec.js | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index deb091fb2b7..a48e3c0fde3 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -483,7 +483,10 @@ function hasPurpose1Consent(bidderRequest) { function formatRequest(payload, bidderRequest) { let request = []; - let options = {}; + let options = { + withCredentials: true + }; + let endpointUrl = URL; if (!hasPurpose1Consent(bidderRequest)) { diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 935bc23be03..2b7c5835604 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -644,7 +644,7 @@ describe('AppNexusAdapter', function () { bidderRequest.bids = bidRequests; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.options).to.be.empty; + expect(request.options).to.deep.equal({withCredentials: true}); const payload = JSON.parse(request.data); expect(payload.gdpr_consent).to.exist; @@ -796,6 +796,12 @@ describe('AppNexusAdapter', function () { config.getConfig.restore(); }); + it('should always set withCredentials: true on the request.options', function () { + let bidRequest = Object.assign({}, bidRequests[0]); + const request = spec.buildRequests([bidRequest]); + expect(request.options.withCredentials).to.equal(true); + }); + it('should set simple domain variant if purpose 1 consent is not given', function () { let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; let bidderRequest = { From e2062447abd900e1b7ad028eaa3bae6913c57ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Fern=C3=A1ndez?= Date: Thu, 29 Apr 2021 19:24:46 +0000 Subject: [PATCH 118/303] Axonix Bid Adapter: Fixed interpretResponse, support email (#6667) * Fixed interpretResponse, support email * onBidWon gets single bids * replaceAuctionPrice call fix * Version bump --- modules/axonixBidAdapter.js | 25 +++--- modules/axonixBidAdapter.md | 2 +- test/spec/modules/axonixBidAdapter_spec.js | 100 +++++++++++---------- 3 files changed, 65 insertions(+), 62 deletions(-) diff --git a/modules/axonixBidAdapter.js b/modules/axonixBidAdapter.js index 224486467f3..daaac27e6a4 100644 --- a/modules/axonixBidAdapter.js +++ b/modules/axonixBidAdapter.js @@ -5,7 +5,7 @@ import * as utils from '../src/utils.js'; import { ajax } from '../src/ajax.js'; const BIDDER_CODE = 'axonix'; -const BIDDER_VERSION = '1.0.1'; +const BIDDER_VERSION = '1.0.2'; const CURRENCY = 'USD'; const DEFAULT_REGION = 'us-east-1'; @@ -140,15 +140,17 @@ export const spec = { }, interpretResponse: function(serverResponse) { - if (!utils.isArray(serverResponse)) { + const response = serverResponse ? serverResponse.body : []; + + if (!utils.isArray(response)) { return []; } const responses = []; - for (const response of serverResponse) { - if (response.requestId) { - responses.push(Object.assign(response, { + for (const resp of response) { + if (resp.requestId) { + responses.push(Object.assign(resp, { ttl: config.getConfig('_bidderTimeout') })); } @@ -171,15 +173,12 @@ export const spec = { } }, - onBidWon: function(bids) { - for (const bid of bids) { - const { nurl } = bid || {}; + onBidWon: function(bid) { + const { nurl } = bid || {}; - if (bid.nurl) { - utils.replaceAuctionPrice(nurl, bid.cpm) - utils.triggerPixel(nurl); - }; - } + if (bid.nurl) { + utils.triggerPixel(utils.replaceAuctionPrice(nurl, bid.cpm)); + }; } } diff --git a/modules/axonixBidAdapter.md b/modules/axonixBidAdapter.md index 1ff59f17828..7a4606d5502 100644 --- a/modules/axonixBidAdapter.md +++ b/modules/axonixBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name : Axonix Bidder Adapter Module Type : Bidder Adapter -Maintainer : support-prebid@axonix.com +Maintainer : support+prebid@axonix.com ``` # Description diff --git a/test/spec/modules/axonixBidAdapter_spec.js b/test/spec/modules/axonixBidAdapter_spec.js index aac1cbe08ff..a952d527600 100644 --- a/test/spec/modules/axonixBidAdapter_spec.js +++ b/test/spec/modules/axonixBidAdapter_spec.js @@ -71,47 +71,51 @@ describe('AxonixBidAdapter', function () { }; const BANNER_RESPONSE = { - requestId: 'f08b3a8dcff747eabada295dcf94eee0', - cpm: 6, - currency: 'USD', - width: 300, - height: 250, - ad: '', - creativeId: 'abc', - netRevenue: false, - meta: { - networkId: 'nid', - advertiserDomains: [ - 'https://the.url' - ], - secondaryCatIds: [ - 'IAB1' - ], - mediaType: 'banner' - }, - nurl: 'https://win.url' + body: [{ + requestId: 'f08b3a8dcff747eabada295dcf94eee0', + cpm: 6, + currency: 'USD', + width: 300, + height: 250, + ad: '', + creativeId: 'abc', + netRevenue: false, + meta: { + networkId: 'nid', + advertiserDomains: [ + 'https://the.url' + ], + secondaryCatIds: [ + 'IAB1' + ], + mediaType: 'banner' + }, + nurl: 'https://win.url' + }] }; const VIDEO_RESPONSE = { - requestId: 'f08b3a8dcff747eabada295dcf94eee0', - cpm: 6, - currency: 'USD', - width: 300, - height: 250, - ad: '', - creativeId: 'abc', - netRevenue: false, - meta: { - networkId: 'nid', - advertiserDomains: [ - 'https://the.url' - ], - secondaryCatIds: [ - 'IAB1' - ], - mediaType: 'video' - }, - nurl: 'https://win.url' + body: [{ + requestId: 'f08b3a8dcff747eabada295dcf94eee0', + cpm: 6, + currency: 'USD', + width: 300, + height: 250, + ad: '', + creativeId: 'abc', + netRevenue: false, + meta: { + networkId: 'nid', + advertiserDomains: [ + 'https://the.url' + ], + secondaryCatIds: [ + 'IAB1' + ], + mediaType: 'video' + }, + nurl: 'https://win.url' + }] }; describe('inherited functions', function () { @@ -311,21 +315,21 @@ describe('AxonixBidAdapter', function () { it('ignores unparseable responses', function() { expect(spec.interpretResponse('invalid')).to.be.an('array').that.is.empty; expect(spec.interpretResponse(['invalid'])).to.be.an('array').that.is.empty; - expect(spec.interpretResponse([{ invalid: 'object' }])).to.be.an('array').that.is.empty; + expect(spec.interpretResponse({ body: [{ invalid: 'object' }] })).to.be.an('array').that.is.empty; }); it('parses banner responses', function () { - const response = spec.interpretResponse([BANNER_RESPONSE]); + const response = spec.interpretResponse(BANNER_RESPONSE); expect(response).to.be.an('array').that.is.not.empty; - expect(response[0]).to.equal(BANNER_RESPONSE); + expect(response[0]).to.equal(BANNER_RESPONSE.body[0]); }); it('parses 1 video responses', function () { - const response = spec.interpretResponse([VIDEO_RESPONSE]); + const response = spec.interpretResponse(VIDEO_RESPONSE); expect(response).to.be.an('array').that.is.not.empty; - expect(response[0]).to.equal(VIDEO_RESPONSE); + expect(response[0]).to.equal(VIDEO_RESPONSE.body[0]); }); it.skip('parses 1 native responses', function () { @@ -346,17 +350,17 @@ describe('AxonixBidAdapter', function () { }); it('called once', function () { - spec.onBidWon(spec.interpretResponse([BANNER_RESPONSE])); + spec.onBidWon(BANNER_RESPONSE.body[0]); expect(utils.triggerPixel.calledOnce).to.equal(true); }); it('called false', function () { - spec.onBidWon([{ cpm: '2.21' }]); + spec.onBidWon({ cpm: '2.21' }); expect(utils.triggerPixel.called).to.equal(false); }); it('when there is no notification expected server side, none is called', function () { - var response = spec.onBidWon([]); + var response = spec.onBidWon({}); expect(utils.triggerPixel.called).to.equal(false); expect(response).to.be.an('undefined') }); @@ -364,11 +368,11 @@ describe('AxonixBidAdapter', function () { describe('onTimeout', function () { it('banner response', () => { - spec.onTimeout(spec.interpretResponse([BANNER_RESPONSE])); + spec.onTimeout(spec.interpretResponse(BANNER_RESPONSE)); }); it('video response', () => { - spec.onTimeout(spec.interpretResponse([VIDEO_RESPONSE])); + spec.onTimeout(spec.interpretResponse(VIDEO_RESPONSE)); }); }); }); From e93f4555c3faf2ad2ade6626a12dbb66d59bde45 Mon Sep 17 00:00:00 2001 From: cs83 Date: Fri, 30 Apr 2021 13:06:27 +0300 Subject: [PATCH 119/303] Smartico Bid Adapter: add new bid adapter (#6486) * Adding smartico adapter * bug #6486 fix, added maintainer email * bug #6486 fix, modified test parameters * bug #6486 fix, modified test parameters #2 * #6486 applied review related updates & fixes * #6486 applied review related updates & fixes #2 * #6486 applied review related updates & fixes #3 Co-authored-by: Dmitri --- modules/smarticoBidAdapter.js | 116 ++++++++++++++++++ modules/smarticoBidAdapter.md | 32 +++++ test/spec/modules/smarticoBidAdapter_spec.js | 118 +++++++++++++++++++ 3 files changed, 266 insertions(+) create mode 100644 modules/smarticoBidAdapter.js create mode 100644 modules/smarticoBidAdapter.md create mode 100644 test/spec/modules/smarticoBidAdapter_spec.js diff --git a/modules/smarticoBidAdapter.js b/modules/smarticoBidAdapter.js new file mode 100644 index 00000000000..9107ce5f908 --- /dev/null +++ b/modules/smarticoBidAdapter.js @@ -0,0 +1,116 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import find from 'core-js-pure/features/array/find.js'; + +const SMARTICO_CONFIG = { + bidRequestUrl: 'https://trmads.eu/preBidRequest', + widgetUrl: 'https://trmads.eu/get', + method: 'POST' +} + +const BIDDER_CODE = 'smartico'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + isBidRequestValid: function (bid) { + return !!(bid && bid.params && bid.params.token && bid.params.placementId); + }, + buildRequests: function (validBidRequests, bidderRequest) { + var i + var j + var bid + var bidParam + var bidParams = [] + var sizes + var frameWidth = Math.round(window.screen.width) + var frameHeight = Math.round(window.screen.height) + for (i = 0; i < validBidRequests.length; i++) { + bid = validBidRequests[i] + if (bid.sizes) { + sizes = bid.sizes + } else if (typeof (BANNER) != 'undefined' && bid.mediaTypes && bid.mediaTypes[BANNER] && bid.mediaTypes[BANNER].sizes) { + sizes = bid.mediaTypes[BANNER].sizes + } else if (frameWidth && frameHeight) { + sizes = [[frameWidth, frameHeight]] + } else { + sizes = [] + } + for (j = 0; j < sizes.length; j++) { + bidParam = { + token: bid.params.token || '', + bidId: bid.bidId, + 'banner-format-width': sizes[j][0], + 'banner-format-height': sizes[j][1] + } + if (bid.params.bannerFormat) { + bidParam['banner-format'] = bid.params.bannerFormat + } + if (bid.params.language) { + bidParam.language = bid.params.language + } + if (bid.params.region) { + bidParam.region = bid.params.region + } + if (bid.params.regions && (bid.params.regions instanceof String || (bid.params.regions instanceof Array && bid.params.regions.length))) { + bidParam.regions = bid.params.regions + if (bidParam.regions instanceof Array) { + bidParam.regions = bidParam.regions.join(',') + } + } + bidParams.push(bidParam) + } + } + + var ServerRequestObjects = { + method: SMARTICO_CONFIG.method, + url: SMARTICO_CONFIG.bidRequestUrl, + bids: validBidRequests, + data: {bidParams: bidParams, auctionId: bidderRequest.auctionId, origin: window.location.origin} + } + + return ServerRequestObjects; + }, + interpretResponse: function (serverResponse, bidRequest) { + var i + var bid + var bidObject + var url + var html + var ad + var token + var language + var scriptId + var bidResponses = [] + + for (i = 0; i < serverResponse.length; i++) { + ad = serverResponse[i]; + bid = find(bidRequest.bids, bid => bid.bidId === ad.bidId) + if (bid) { + token = bid.params.token || '' + + language = bid.params.language || SMARTICO_CONFIG.language || '' + + scriptId = encodeURIComponent('smartico-widget-' + bid.params.placementId + '-' + i) + + url = SMARTICO_CONFIG.widgetUrl + '?token=' + encodeURIComponent(token) + '&auction-id=' + encodeURIComponent(bid.auctionId) + '&from-auction-buffer=1&own_session=1&ad=' + encodeURIComponent(ad.id) + '&scriptid=' + scriptId + (ad.bannerFormatAlias ? '&banner-format=' + encodeURIComponent(ad.bannerFormatAlias) : '') + (language ? '&language=' + encodeURIComponent(language) : '') + + html = '', @@ -479,12 +471,12 @@ describe('validate native', function () { afterEach(function () {}); - it('should reject bid if no image sizes are defined', function () { + it('should accept bid if no image sizes are defined', function () { let result = nativeBidIsValid(validBid, bidReq); expect(result).to.be.true; result = nativeBidIsValid(noIconDimBid, bidReq); - expect(result).to.be.false; + expect(result).to.be.true; result = nativeBidIsValid(noImgDimBid, bidReq); - expect(result).to.be.false; + expect(result).to.be.true; }); }); From f9272fc06c8f64bb542951be99499098a6b02e5a Mon Sep 17 00:00:00 2001 From: Robert Ray Martinez III Date: Wed, 12 May 2021 10:55:27 -0700 Subject: [PATCH 166/303] Prebid Server Bid Adapter: Bugfix for not taking defaultVendor enabled (#6740) * quick fix for enabled s2s bug * move enabled check outside of defaultVendor if --- modules/prebidServerBidAdapter/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 38a499c794e..4ca61cae452 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -72,7 +72,6 @@ let eidPermissions; * @type {S2SDefaultConfig} */ const s2sDefaultConfig = { - enabled: false, timeout: 1000, maxBids: 1, adapter: 'prebidServer', @@ -89,7 +88,7 @@ config.setDefaults({ * @return {boolean} */ function updateConfigDefaultVendor(option) { - if (option.defaultVendor && option.enabled !== false) { + if (option.defaultVendor) { let vendor = option.defaultVendor; let optionKeys = Object.keys(option); if (S2S_VENDORS[vendor]) { @@ -105,6 +104,8 @@ function updateConfigDefaultVendor(option) { return false; } } + // this is how we can know if user / defaultVendor has set it, or if we should default to false + return option.enabled = typeof option.enabled === 'boolean' ? option.enabled : false; } /** @@ -163,6 +164,7 @@ function setS2sConfig(options) { return true; } } + utils.logWarn('prebidServer: s2s config is disabled'); return false; }); From f999c0da11e286d9361bb09b8faedf8db30ce70a Mon Sep 17 00:00:00 2001 From: Jason Snellbaker Date: Wed, 12 May 2021 15:35:56 -0400 Subject: [PATCH 167/303] Prebid 4.39.0 Release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a04743eab39..4085ca3df08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.39.0-pre", + "version": "4.39.0", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From 5215ade32747facd4fb4c4f932d44b9b49c9daa7 Mon Sep 17 00:00:00 2001 From: Jason Snellbaker Date: Wed, 12 May 2021 15:52:46 -0400 Subject: [PATCH 168/303] increment pre version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4085ca3df08..05f68f4a009 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.39.0", + "version": "4.40.0-pre", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From b132a4ba9d10a78bdea1a04fc2088d0957126385 Mon Sep 17 00:00:00 2001 From: John Salis Date: Thu, 13 May 2021 08:46:35 -0400 Subject: [PATCH 169/303] Beachfront Bid Adapter: add schain support (#6751) * add schain support to beachfront adapter * remove unnecessary mock tests for outstream player Co-authored-by: John Salis --- modules/beachfrontBidAdapter.js | 11 ++ modules/beachfrontBidAdapter.md | 2 +- .../spec/modules/beachfrontBidAdapter_spec.js | 101 ++++++++---------- 3 files changed, 55 insertions(+), 59 deletions(-) diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index 44755a78864..8ddc0ca5ba9 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -351,6 +351,9 @@ function createVideoRequestData(bid, bidderRequest) { regs: { ext: {} }, + source: { + ext: {} + }, user: { ext: {} }, @@ -367,6 +370,10 @@ function createVideoRequestData(bid, bidderRequest) { payload.user.ext.consent = consentString; } + if (bid.schain) { + payload.source.ext.schain = bid.schain; + } + if (eids.length > 0) { payload.user.ext.eids = eids; } @@ -416,6 +423,10 @@ function createBannerRequestData(bids, bidderRequest) { payload.gdprConsent = consentString; } + if (bids[0] && bids[0].schain) { + payload.schain = bids[0].schain; + } + SUPPORTED_USER_IDS.forEach(({ key, queryParam }) => { let id = bids[0] && bids[0].userId && bids[0].userId[key]; if (id) { diff --git a/modules/beachfrontBidAdapter.md b/modules/beachfrontBidAdapter.md index 0a6b8b73da4..a2eb79ee331 100644 --- a/modules/beachfrontBidAdapter.md +++ b/modules/beachfrontBidAdapter.md @@ -4,7 +4,7 @@ Module Name: Beachfront Bid Adapter Module Type: Bidder Adapter -Maintainer: john@beachfront.com +Maintainer: prebid@beachfront.com # Description diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index 43c71dd6349..c7ae5c799ac 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -1,5 +1,4 @@ import { expect } from 'chai'; -import sinon from 'sinon'; import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter.js'; import { parseUrl } from 'src/utils.js'; @@ -278,6 +277,27 @@ describe('BeachfrontAdapter', function () { expect(data.user.ext.consent).to.equal(consentString); }); + it('must add schain data to the request', () => { + const schain = { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'directseller.com', + sid: '00001', + rid: 'BidRequest1', + hp: 1 + } + ] + }; + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { video: {} }; + bidRequest.schain = schain; + const requests = spec.buildRequests([ bidRequest ]); + const data = requests[0].data; + expect(data.source.ext.schain).to.deep.equal(schain); + }); + it('must add the Trade Desk User ID to the request', () => { const tdid = '4321'; const bidRequest = bidRequests[0]; @@ -446,6 +466,27 @@ describe('BeachfrontAdapter', function () { expect(data.gdprConsent).to.equal(consentString); }); + it('must add schain data to the request', () => { + const schain = { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'directseller.com', + sid: '00001', + rid: 'BidRequest1', + hp: 1 + } + ] + }; + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { banner: {} }; + bidRequest.schain = schain; + const requests = spec.buildRequests([ bidRequest ]); + const data = requests[0].data; + expect(data.schain).to.deep.equal(schain); + }); + it('must add the Trade Desk User ID to the request', () => { const tdid = '4321'; const bidRequest = bidRequests[0]; @@ -654,63 +695,7 @@ describe('BeachfrontAdapter', function () { id: bidRequest.bidId, url: OUTSTREAM_SRC }); - }); - - it('should initialize a player for outstream bids', () => { - const width = 640; - const height = 480; - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { - video: { - context: 'outstream', - playerSize: [ width, height ] - } - }; - const serverResponse = { - bidPrice: 5.00, - url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', - crid: '123abc' - }; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - window.Beachfront = { Player: sinon.spy() }; - bidResponse.adUnitCode = bidRequest.adUnitCode; - bidResponse.renderer.render(bidResponse); - sinon.assert.calledWith(window.Beachfront.Player, bidResponse.adUnitCode, sinon.match({ - adTagUrl: bidResponse.vastUrl, - width: bidResponse.width, - height: bidResponse.height, - expandInView: false, - collapseOnComplete: true - })); - delete window.Beachfront; - }); - - it('should configure outstream player settings from the bidder params', () => { - const width = 640; - const height = 480; - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { - video: { - context: 'outstream', - playerSize: [ width, height ] - } - }; - bidRequest.params.player = { - expandInView: true, - collapseOnComplete: false, - progressColor: 'green' - }; - const serverResponse = { - bidPrice: 5.00, - url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', - crid: '123abc' - }; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - window.Beachfront = { Player: sinon.spy() }; - bidResponse.adUnitCode = bidRequest.adUnitCode; - bidResponse.renderer.render(bidResponse); - sinon.assert.calledWith(window.Beachfront.Player, bidResponse.adUnitCode, sinon.match(bidRequest.params.player)); - delete window.Beachfront; + expect(bidResponse.renderer.render).to.be.a('function'); }); }); From 73690781de088db65e8871a9a0437fbb95a2986a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Mar=C3=ADn?= Date: Thu, 13 May 2021 15:03:40 +0200 Subject: [PATCH 170/303] fix: Webpack v5 complain about named export from JSON modules (#6755) --- modules/gdprEnforcement.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/gdprEnforcement.js b/modules/gdprEnforcement.js index adbccd8666d..02a2da3a7a4 100644 --- a/modules/gdprEnforcement.js +++ b/modules/gdprEnforcement.js @@ -12,7 +12,7 @@ import { registerSyncInner } from '../src/adapters/bidderFactory.js'; import { getHook } from '../src/hook.js'; import { validateStorageEnforcement } from '../src/storageManager.js'; import events from '../src/events.js'; -import { EVENTS } from '../src/constants.json'; +import CONSTANTS from '../src/constants.json'; const TCF2 = { 'purpose1': { id: 1, name: 'storage' }, @@ -345,10 +345,10 @@ function emitTCF2FinalResults() { analyticsBlocked: formatArray(analyticsBlocked) }; - events.emit(EVENTS.TCF2_ENFORCEMENT, tcf2FinalResults); + events.emit(CONSTANTS.EVENTS.TCF2_ENFORCEMENT, tcf2FinalResults); } -events.on(EVENTS.AUCTION_END, emitTCF2FinalResults); +events.on(CONSTANTS.EVENTS.AUCTION_END, emitTCF2FinalResults); /* Set of callback functions used to detect presence of a TCF rule, passed as the second argument to find(). From 752e0c2757227f50313554c4af467eacb44a5c76 Mon Sep 17 00:00:00 2001 From: Danny Khatib Date: Thu, 13 May 2021 07:58:50 -0700 Subject: [PATCH 171/303] Pbs bid adapter: constants import styling for webpack v5 upgrade (#6723) * mapping spotx dealid to bid object * using proper syntax to import default json module * kick off tests * es lint fix Co-authored-by: Danny Khatib Co-authored-by: Chris Huie <3444727+ChrisHuie@users.noreply.github.com> --- modules/prebidServerBidAdapter/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 4ca61cae452..d91858ed9b2 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -1,7 +1,7 @@ import Adapter from '../../src/adapter.js'; import { createBid } from '../../src/bidfactory.js'; import * as utils from '../../src/utils.js'; -import { STATUS, S2S, EVENTS } from '../../src/constants.json'; +import CONSTANTS from '../../src/constants.json'; import adapterManager from '../../src/adapterManager.js'; import { config } from '../../src/config.js'; import { VIDEO, NATIVE } from '../../src/mediaTypes.js'; @@ -16,7 +16,7 @@ import { getPrebidInternal } from '../../src/utils.js'; const getConfig = config.getConfig; -const TYPE = S2S.SRC; +const TYPE = CONSTANTS.S2S.SRC; let _syncCount = 0; const DEFAULT_S2S_TTL = 60; const DEFAULT_S2S_CURRENCY = 'USD'; @@ -840,7 +840,7 @@ const OPEN_RTB_PROTOCOL = { } const cpm = bid.price; - const status = cpm !== 0 ? STATUS.GOOD : STATUS.NO_BID; + const status = cpm !== 0 ? CONSTANTS.STATUS.GOOD : CONSTANTS.STATUS.NO_BID; let bidObject = createBid(status, bidRequest || { bidder: seatbid.seat, src: TYPE @@ -1099,7 +1099,7 @@ export function PrebidServer() { } }); - bidderRequests.forEach(bidderRequest => events.emit(EVENTS.BIDDER_DONE, bidderRequest)); + bidderRequests.forEach(bidderRequest => events.emit(CONSTANTS.EVENTS.BIDDER_DONE, bidderRequest)); } catch (error) { utils.logError(error); } @@ -1113,7 +1113,7 @@ export function PrebidServer() { } // Listen for bid won to call wurl - events.on(EVENTS.BID_WON, bidWonHandler); + events.on(CONSTANTS.EVENTS.BID_WON, bidWonHandler); return Object.assign(this, { callBids: baseAdapter.callBids, From 3f02a15968d16d1aa9cddc48ed73098cc5677006 Mon Sep 17 00:00:00 2001 From: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Date: Thu, 13 May 2021 14:31:40 -0400 Subject: [PATCH 172/303] First Party Data module: Add new module and two submodules to populate defaults and validate ortb2 (#6452) * Creating fpd module * Continued work on FPD module. - Data validation - Pubcid optout check - Misc Fixes * Revert userId update. Committed in error * Added first party data unit tests and fixed bug * Added an unsubscribe for tests to run properly * Reworked logic to use bidderRequests hook to update global/bidder configs instead of subscribing - former method was preventing tests from completing properly * Merge master * Removing unused references. Fixing device data to point to device.h/device.w * Update to include opt out configuration for enrichments/validations * Modified logic to use ortb2 configuration mapping. This will allow for entries to be added/removed/modified from configuration as opposed to be specifically called out in the validation functions * Removed LGTM unneeded defensive code for check on object 'cur' * Remove unused conditional * Fix lint error * Updates to remove currency enrichment as well as optout for user object * Added optout flag to user.yob and user.gender fields * Added test for arbitrary values Added more comments * Broke module out into module and two submodules * Updated cur to validate as an array of strings not just a string Updated comments --- modules/.submodules.json | 4 + modules/enrichmentFpdModule.js | 107 ++++ modules/fpdModule/index.js | 58 +++ modules/fpdModule/index.md | 46 ++ modules/validationFpdModule/config.js | 125 +++++ modules/validationFpdModule/index.js | 232 +++++++++ test/spec/modules/enrichmentFpdModule_spec.js | 97 ++++ test/spec/modules/fpdModule_spec.js | 464 ++++++++++++++++++ test/spec/modules/validationFpdModule_spec.js | 313 ++++++++++++ 9 files changed, 1446 insertions(+) create mode 100644 modules/enrichmentFpdModule.js create mode 100644 modules/fpdModule/index.js create mode 100644 modules/fpdModule/index.md create mode 100644 modules/validationFpdModule/config.js create mode 100644 modules/validationFpdModule/index.js create mode 100644 test/spec/modules/enrichmentFpdModule_spec.js create mode 100644 test/spec/modules/fpdModule_spec.js create mode 100644 test/spec/modules/validationFpdModule_spec.js diff --git a/modules/.submodules.json b/modules/.submodules.json index 7760d31cfff..a8804321278 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -41,5 +41,9 @@ "reconciliationRtdProvider", "geoedgeRtdProvider", "sirdataRtdProvider" + ], + "fpdModule": [ + "enrichmentFpdModule", + "validationFpdModule" ] } diff --git a/modules/enrichmentFpdModule.js b/modules/enrichmentFpdModule.js new file mode 100644 index 00000000000..a1d815917e0 --- /dev/null +++ b/modules/enrichmentFpdModule.js @@ -0,0 +1,107 @@ +/** + * This module sets default values and validates ortb2 first part data + * @module modules/firstPartyData + */ +import * as utils from '../src/utils.js'; +import { submodule } from '../src/hook.js' +import { getRefererInfo } from '../src/refererDetection.js' + +let ortb2 = {}; +let win = (window === window.top) ? window : window.top; + +/** + * Checks for referer and if exists merges into ortb2 global data + */ +function setReferer() { + if (getRefererInfo().referer) utils.mergeDeep(ortb2, { site: { ref: getRefererInfo().referer } }); +} + +/** + * Checks for canonical url and if exists merges into ortb2 global data + */ +function setPage() { + if (getRefererInfo().canonicalUrl) utils.mergeDeep(ortb2, { site: { page: getRefererInfo().canonicalUrl } }); +} + +/** + * Checks for canonical url and if exists retrieves domain and merges into ortb2 global data + */ +function setDomain() { + let parseDomain = function(url) { + if (!url || typeof url !== 'string' || url.length === 0) return; + + var match = url.match(/^(?:https?:\/\/)?(?:www\.)?(.*?(?=(\?|\#|\/|$)))/i); + + return match && match[1]; + }; + + let domain = parseDomain(getRefererInfo().canonicalUrl) + + if (domain) utils.mergeDeep(ortb2, { site: { domain: domain } }); +} + +/** + * Checks for screen/device width and height and sets dimensions + */ +function setDimensions() { + let width; + let height; + + try { + width = win.innerWidth || win.document.documentElement.clientWidth || win.document.body.clientWidth; + height = win.innerHeight || win.document.documentElement.clientHeight || win.document.body.clientHeight; + } catch (e) { + width = window.innerWidth || window.document.documentElement.clientWidth || window.document.body.clientWidth; + height = window.innerHeight || window.document.documentElement.clientHeight || window.document.body.clientHeight; + } + + utils.mergeDeep(ortb2, { device: { w: width, h: height } }); +} + +/** + * Scans page for meta keywords, and if exists, merges into site.keywords + */ +function setKeywords() { + let keywords; + + try { + keywords = win.document.querySelector("meta[name='keywords']"); + } catch (e) { + keywords = window.document.querySelector("meta[name='keywords']"); + } + + if (keywords && keywords.content) utils.mergeDeep(ortb2, { site: { keywords: keywords.content.replace(/\s/g, '') } }); +} + +/** + * Resets modules global ortb2 data + */ +const resetOrtb2 = () => { ortb2 = {} }; + +function runEnrichments() { + setReferer(); + setPage(); + setDomain(); + setDimensions(); + setKeywords(); + + return ortb2; +} + +/** + * Sets default values to ortb2 if exists and adds currency and ortb2 setConfig callbacks on init + */ +export function initSubmodule(fpdConf, data) { + resetOrtb2(); + + return (!fpdConf.skipEnrichments) ? utils.mergeDeep(runEnrichments(), data) : data; +} + +/** @type {firstPartyDataSubmodule} */ +export const enrichmentsSubmodule = { + name: 'enrichments', + queue: 2, + init: initSubmodule +} + +submodule('firstPartyData', enrichmentsSubmodule) diff --git a/modules/fpdModule/index.js b/modules/fpdModule/index.js new file mode 100644 index 00000000000..427547a4e4d --- /dev/null +++ b/modules/fpdModule/index.js @@ -0,0 +1,58 @@ +/** + * This module sets default values and validates ortb2 first part data + * @module modules/firstPartyData + */ +import { config } from '../../src/config.js'; +import { module, getHook } from '../../src/hook.js'; +import { getGlobal } from '../../src/prebidGlobal.js'; +import { addBidderRequests } from '../../src/auction.js'; + +let submodules = []; + +/** + * enable submodule in User ID + * @param {RtdSubmodule} submodule + */ +export function registerSubmodules(submodule) { + submodules.push(submodule); +} + +export function init() { + let modConf = config.getConfig('firstPartyData') || {}; + let ortb2 = config.getConfig('ortb2') || {}; + + submodules.sort((a, b) => { + return ((a.queue || 1) - (b.queue || 1)); + }).forEach(submodule => { + ortb2 = submodule.init(modConf, ortb2); + }); + + config.setConfig({ortb2}); +} + +/** + * BidderRequests hook to intiate module and reset modules ortb2 data object + */ +function addBidderRequestHook(fn, bidderRequests) { + init(); + fn.call(this, bidderRequests); + // Removes hook after run + addBidderRequests.getHooks({ hook: addBidderRequestHook }).remove(); +} + +/** + * Sets bidderRequests hook + */ +function setupHook() { + getHook('addBidderRequests').before(addBidderRequestHook); +} + +module('firstPartyData', registerSubmodules); + +// Runs setupHook on initial load +setupHook(); + +/** + * Global function to reinitiate module + */ +(getGlobal()).refreshFpd = setupHook; diff --git a/modules/fpdModule/index.md b/modules/fpdModule/index.md new file mode 100644 index 00000000000..638c966883a --- /dev/null +++ b/modules/fpdModule/index.md @@ -0,0 +1,46 @@ +# Overview + +``` +Module Name: First Party Data Module +``` + +# Description + +Module to perform the following functions to allow for consistent set of first party data using the following submodules. + +Enrichment Submodule: +- populate available data into object: referer, meta-keywords, cur + +Validation Submodule: +- verify OpenRTB datatypes, remove/warn any that are likely to choke downstream readers +- verify that certain OpenRTB attributes are not specified +- optionally suppress user FPD based on the existence of _pubcid_optout + + +1. Module initializes on first load and set bidRequestHook +2. When hook runs, corresponding submodule init functions are run to perform enrichments/validations dependant on submodule +3. After hook complete, it is disabled - meaning module only runs on first auction +4. To reinitiate the module, run pbjs.refreshFPD(), which allows module to rerun as if initial load + + +This module will automatically run first party data enrichments and validations dependant on which submodules are included. There is no configuration required. In order to load the module and submodule(s) and opt out of either enrichements or validations, use the below opt out configuration + +# Module Control Configuration + +``` + +pbjs.setConfig({ + firstPartyData: { + skipValidations: true, // default to false + skipEnrichments: true // default to false + } +}); + +``` + +# Requirements + +At least one of the submodules must be included in order to successfully run the corresponding above operations. + +enrichmentFpdModule +validationFpdModule \ No newline at end of file diff --git a/modules/validationFpdModule/config.js b/modules/validationFpdModule/config.js new file mode 100644 index 00000000000..f6adfea70eb --- /dev/null +++ b/modules/validationFpdModule/config.js @@ -0,0 +1,125 @@ +/** + * Data type map + */ +const TYPES = { + string: 'string', + object: 'object', + number: 'number', +}; + +/** + * Template to define what ortb2 attributes should be validated + * Accepted fields: + * -- invalid - {Boolean} if true, field is not valid + * -- type - {String} valid data type of field + * -- isArray - {Boolean} if true, field must be an array + * -- childType - {String} used in conjuction with isArray: true, defines valid type of array indices + * -- children - {Object} defines child properties needed to be validated (used only if type: object) + * -- required - {Array} array of strings defining any required properties for object (used only if type: object) + * -- optoutApplies - {Boolean} if true, optout logic will filter if applicable (currently only applies to user object) + */ +export const ORTB_MAP = { + imp: { + invalid: true + }, + cur: { + type: TYPES.object, + isArray: true, + childType: TYPES.string + }, + device: { + type: TYPES.object, + children: { + w: { type: TYPES.number }, + h: { type: TYPES.number } + } + }, + site: { + type: TYPES.object, + children: { + name: { type: TYPES.string }, + domain: { type: TYPES.string }, + page: { type: TYPES.string }, + ref: { type: TYPES.string }, + keywords: { type: TYPES.string }, + search: { type: TYPES.string }, + cat: { + type: TYPES.object, + isArray: true, + childType: TYPES.string + }, + sectioncat: { + type: TYPES.object, + isArray: true, + childType: TYPES.string + }, + pagecat: { + type: TYPES.object, + isArray: true, + childType: TYPES.string + }, + content: { + type: TYPES.object, + isArray: false, + children: { + data: { + type: TYPES.object, + isArray: true, + childType: TYPES.object, + required: ['name', 'segment'], + children: { + segment: { + type: TYPES.object, + isArray: true, + childType: TYPES.object, + required: ['id'], + children: { + id: { type: TYPES.string } + } + }, + name: { type: TYPES.string }, + ext: { type: TYPES.object }, + } + } + } + }, + publisher: { + type: TYPES.object, + isArray: false + }, + } + }, + user: { + type: TYPES.object, + children: { + yob: { + type: TYPES.number, + optoutApplies: true + }, + gender: { + type: TYPES.string, + optoutApplies: true + }, + keywords: { type: TYPES.string }, + data: { + type: TYPES.object, + isArray: true, + childType: TYPES.object, + required: ['name', 'segment'], + children: { + segment: { + type: TYPES.object, + isArray: true, + childType: TYPES.object, + required: ['id'], + children: { + id: { type: TYPES.string } + } + }, + name: { type: TYPES.string }, + ext: { type: TYPES.object }, + } + } + } + } +} diff --git a/modules/validationFpdModule/index.js b/modules/validationFpdModule/index.js new file mode 100644 index 00000000000..c23f7e09316 --- /dev/null +++ b/modules/validationFpdModule/index.js @@ -0,0 +1,232 @@ +/** + * This module sets default values and validates ortb2 first part data + * @module modules/firstPartyData + */ +import { config } from '../../src/config.js'; +import * as utils from '../../src/utils.js'; +import { ORTB_MAP } from './config.js'; +import { submodule } from '../../src/hook.js'; +import { getStorageManager } from '../../src/storageManager.js'; + +const STORAGE = getStorageManager(); +let optout; + +/** + * Check if data passed is empty + * @param {*} value to test against + * @returns {Boolean} is value empty + */ +function isEmptyData(data) { + let check = true; + + if (typeof data === 'object' && !utils.isEmpty(data)) { + check = false; + } else if (typeof data !== 'object' && (utils.isNumber(data) || data)) { + check = false; + } + + return check; +} + +/** + * Check if required keys exist in data object + * @param {Object} data object + * @param {Array} array of required keys + * @param {String} object path (for printing warning) + * @param {Number} index of object value in the data array (for printing warning) + * @returns {Boolean} is requirements fulfilled + */ +function getRequiredData(obj, required, parent, i) { + let check = true; + + required.forEach(key => { + if (!obj[key] || isEmptyData(obj[key])) { + check = false; + utils.logWarn(`Filtered ${parent}[] value at index ${i} in ortb2 data: missing required property ${key}`); + } + }); + + return check; +} + +/** + * Check if data type is valid + * @param {*} value to test against + * @param {Object} object containing type definition and if should be array bool + * @returns {Boolean} is type fulfilled + */ +function typeValidation(data, mapping) { + let check = false; + + switch (mapping.type) { + case 'string': + if (typeof data === 'string') check = true; + break; + case 'number': + if (typeof data === 'number' && isFinite(data)) check = true; + break; + case 'object': + if (typeof data === 'object') { + if ((Array.isArray(data) && mapping.isArray) || (!Array.isArray(data) && !mapping.isArray)) check = true; + } + break; + } + + return check; +} + +/** + * Validates ortb2 data arrays and filters out invalid data + * @param {Array} ortb2 data array + * @param {Object} object defining child type and if array + * @param {String} config path of data array + * @param {String} parent path for logging warnings + * @returns {Array} validated/filtered data + */ +export function filterArrayData(arr, child, path, parent) { + arr = arr.filter((index, i) => { + let check = typeValidation(index, {type: child.type, isArray: child.isArray}); + + if (check && Array.isArray(index) === Boolean(child.isArray)) { + return true; + } + + utils.logWarn(`Filtered ${parent}[] value at index ${i} in ortb2 data: expected type ${child.type}`); + }).filter((index, i) => { + let requiredCheck = true; + let mapping = utils.deepAccess(ORTB_MAP, path); + + if (mapping && mapping.required) requiredCheck = getRequiredData(index, mapping.required, parent, i); + + if (requiredCheck) return true; + }).reduce((result, value, i) => { + let typeBool = false; + let mapping = utils.deepAccess(ORTB_MAP, path); + + switch (child.type) { + case 'string': + result.push(value); + break; + case 'object': + if (mapping && mapping.children) { + let validObject = validateFpd(value, path + '.children.', parent + '.'); + if (Object.keys(validObject).length) { + let requiredCheck = getRequiredData(validObject, mapping.required, parent, i); + + if (requiredCheck) { + result.push(validObject); + typeBool = true; + } + } + } else { + result.push(value); + typeBool = true; + } + break; + } + + if (!typeBool) utils.logWarn(`Filtered ${parent}[] value at index ${i} in ortb2 data: expected type ${child.type}`); + + return result; + }, []); + + return arr; +} + +/** + * Validates ortb2 object and filters out invalid data + * @param {Object} ortb2 object + * @param {String} config path of data array + * @param {String} parent path for logging warnings + * @returns {Object} validated/filtered data + */ +export function validateFpd(fpd, path = '', parent = '') { + if (!fpd) return {}; + + // Filter out imp property if exists + let validObject = Object.assign({}, Object.keys(fpd).filter(key => { + let mapping = utils.deepAccess(ORTB_MAP, path + key); + + if (!mapping || !mapping.invalid) return key; + + utils.logWarn(`Filtered ${parent}${key} property in ortb2 data: invalid property`); + }).filter(key => { + let mapping = utils.deepAccess(ORTB_MAP, path + key); + // let typeBool = false; + let typeBool = (mapping) ? typeValidation(fpd[key], {type: mapping.type, isArray: mapping.isArray}) : true; + + if (typeBool || !mapping) return key; + + utils.logWarn(`Filtered ${parent}${key} property in ortb2 data: expected type ${(mapping.isArray) ? 'array' : mapping.type}`); + }).reduce((result, key) => { + let mapping = utils.deepAccess(ORTB_MAP, path + key); + let modified = {}; + + if (mapping) { + if (mapping.optoutApplies && optout) { + utils.logWarn(`Filtered ${parent}${key} data: pubcid optout found`); + return result; + } + + modified = (mapping.type === 'object' && !mapping.isArray) + ? validateFpd(fpd[key], path + key + '.children.', parent + key + '.') + : (mapping.isArray && mapping.childType) + ? filterArrayData(fpd[key], { type: mapping.childType, isArray: mapping.childisArray }, path + key, parent + key) : fpd[key]; + + // Check if modified data has data and return + (!isEmptyData(modified)) ? result[key] = modified + : utils.logWarn(`Filtered ${parent}${key} property in ortb2 data: empty data found`); + } else { + result[key] = fpd[key]; + } + + return result; + }, {})); + + // Return validated data + return validObject; +} + +/** + * Run validation on global and bidder config data for ortb2 + */ +function runValidations(data) { + let conf = validateFpd(data); + + let bidderDuplicate = { ...config.getBidderConfig() }; + + Object.keys(bidderDuplicate).forEach(bidder => { + let modConf = Object.keys(bidderDuplicate[bidder]).reduce((res, key) => { + let valid = (key !== 'ortb2') ? bidderDuplicate[bidder][key] : validateFpd(bidderDuplicate[bidder][key]); + + if (valid) res[key] = valid; + + return res; + }, {}); + + if (Object.keys(modConf).length) config.setBidderConfig({ bidders: [bidder], config: modConf }); + }); + + return conf; +} + +/** + * Sets default values to ortb2 if exists and adds currency and ortb2 setConfig callbacks on init + */ +export function initSubmodule(fpdConf, data) { + // Checks for existsnece of pubcid optout cookie/storage + // if exists, filters user data out + optout = (STORAGE.cookiesAreEnabled() && STORAGE.getCookie('_pubcid_optout')) || + (STORAGE.hasLocalStorage() && STORAGE.getDataFromLocalStorage('_pubcid_optout')); + + return (!fpdConf.skipValidations) ? runValidations(data) : data; +} + +/** @type {firstPartyDataSubmodule} */ +export const validationSubmodule = { + name: 'validation', + queue: 1, + init: initSubmodule +} + +submodule('firstPartyData', validationSubmodule) diff --git a/test/spec/modules/enrichmentFpdModule_spec.js b/test/spec/modules/enrichmentFpdModule_spec.js new file mode 100644 index 00000000000..e5271143f2c --- /dev/null +++ b/test/spec/modules/enrichmentFpdModule_spec.js @@ -0,0 +1,97 @@ +import { expect } from 'chai'; +import * as utils from 'src/utils.js'; +import { getRefererInfo } from 'src/refererDetection.js'; +import { initSubmodule } from 'modules/enrichmentFpdModule.js'; + +describe('the first party data enrichment module', function() { + let width; + let widthStub; + let height; + let heightStub; + let querySelectorStub; + let canonical; + let keywords; + + before(function() { + canonical = document.createElement('link'); + canonical.rel = 'canonical'; + keywords = document.createElement('meta'); + keywords.name = 'keywords'; + }); + + beforeEach(function() { + querySelectorStub = sinon.stub(window.top.document, 'querySelector'); + querySelectorStub.withArgs("link[rel='canonical']").returns(canonical); + querySelectorStub.withArgs("meta[name='keywords']").returns(keywords); + widthStub = sinon.stub(window.top, 'innerWidth').get(function() { + return width; + }); + heightStub = sinon.stub(window.top, 'innerHeight').get(function() { + return height; + }); + }); + + afterEach(function() { + widthStub.restore(); + heightStub.restore(); + querySelectorStub.restore(); + canonical = document.createElement('link'); + canonical.rel = 'canonical'; + keywords = document.createElement('meta'); + keywords.name = 'keywords'; + }); + + it('adds ref and device values', function() { + width = 800; + height = 500; + + let validated = initSubmodule({}, {}); + + expect(validated.site.ref).to.equal(getRefererInfo().referer); + expect(validated.site.page).to.be.undefined; + expect(validated.site.domain).to.be.undefined; + expect(validated.device).to.deep.equal({ w: 800, h: 500 }); + expect(validated.site.keywords).to.be.undefined; + }); + + it('adds page and domain values if canonical url exists', function() { + width = 800; + height = 500; + canonical.href = 'https://www.domain.com/path?query=12345'; + + let validated = initSubmodule({}, {}); + + expect(validated.site.ref).to.equal(getRefererInfo().referer); + expect(validated.site.page).to.equal('https://www.domain.com/path?query=12345'); + expect(validated.site.domain).to.equal('domain.com'); + expect(validated.device).to.deep.equal({ w: 800, h: 500 }); + expect(validated.site.keywords).to.be.undefined; + }); + + it('adds keyword value if keyword meta content exists', function() { + width = 800; + height = 500; + keywords.content = 'value1,value2,value3'; + + let validated = initSubmodule({}, {}); + + expect(validated.site.ref).to.equal(getRefererInfo().referer); + expect(validated.site.page).to.be.undefined; + expect(validated.site.domain).to.be.undefined; + expect(validated.device).to.deep.equal({ w: 800, h: 500 }); + expect(validated.site.keywords).to.equal('value1,value2,value3'); + }); + + it('does not overwrite existing data from getConfig ortb2', function() { + width = 800; + height = 500; + + let validated = initSubmodule({}, {device: {w: 1200, h: 700}, site: {ref: 'https://someUrl.com', page: 'test.com'}}); + + expect(validated.site.ref).to.equal('https://someUrl.com'); + expect(validated.site.page).to.equal('test.com'); + expect(validated.site.domain).to.be.undefined; + expect(validated.device).to.deep.equal({ w: 1200, h: 700 }); + expect(validated.site.keywords).to.be.undefined; + }); +}); diff --git a/test/spec/modules/fpdModule_spec.js b/test/spec/modules/fpdModule_spec.js new file mode 100644 index 00000000000..c2a6c41835e --- /dev/null +++ b/test/spec/modules/fpdModule_spec.js @@ -0,0 +1,464 @@ +import {expect} from 'chai'; +import * as utils from 'src/utils.js'; +import {config} from 'src/config.js'; +import {getRefererInfo} from 'src/refererDetection.js'; +import {init, registerSubmodules} from 'modules/fpdModule/index.js'; +import * as enrichmentModule from 'modules/enrichmentFpdModule.js'; +import * as validationModule from 'modules/validationFpdModule/index.js'; + +let enrichments = { + name: 'enrichments', + queue: 2, + init: enrichmentModule.initSubmodule +}; +let validations = { + name: 'validations', + queue: 1, + init: validationModule.initSubmodule +}; + +describe('the first party data module', function () { + let ortb2 = { + device: { + h: 911, + w: 1733 + }, + user: { + data: [{ + segment: [{ + id: 'foo' + }], + name: 'bar', + ext: 'string' + }] + }, + site: { + content: { + data: [{ + segment: [{ + id: 'test' + }], + name: 'content', + ext: { + foo: 'bar' + } + }] + } + } + }; + + let conf = { + device: { + h: 500, + w: 750 + }, + user: { + keywords: 'test1, test2', + gender: 'f', + data: [{ + segment: [{ + id: 'test' + }], + name: 'alt' + }] + }, + site: { + ref: 'domain.com', + page: 'www.domain.com/test', + ext: { + data: { + inventory: ['first'] + } + } + } + }; + + afterEach(function () { + config.resetConfig(); + }); + + describe('first party data intitializing', function () { + let width; + let widthStub; + let height; + let heightStub; + let querySelectorStub; + let canonical; + let keywords; + + before(function() { + canonical = document.createElement('link'); + canonical.rel = 'canonical'; + keywords = document.createElement('meta'); + keywords.name = 'keywords'; + }); + + beforeEach(function() { + querySelectorStub = sinon.stub(window.top.document, 'querySelector'); + querySelectorStub.withArgs("link[rel='canonical']").returns(canonical); + querySelectorStub.withArgs("meta[name='keywords']").returns(keywords); + widthStub = sinon.stub(window.top, 'innerWidth').get(function () { + return width; + }); + heightStub = sinon.stub(window.top, 'innerHeight').get(function () { + return height; + }); + }); + + afterEach(function() { + widthStub.restore(); + heightStub.restore(); + querySelectorStub.restore(); + canonical = document.createElement('link'); + canonical.rel = 'canonical'; + keywords = document.createElement('meta'); + keywords.name = 'keywords'; + }); + + it('sets default referer and dimension values to ortb2 data', function () { + registerSubmodules(enrichments); + registerSubmodules(validations); + + let validated; + + width = 1120; + height = 750; + + init(); + + validated = config.getConfig('ortb2'); + expect(validated.site.ref).to.equal(getRefererInfo().referer); + expect(validated.site.page).to.be.undefined; + expect(validated.site.domain).to.be.undefined; + expect(validated.device).to.deep.equal({w: 1120, h: 750}); + expect(validated.site.keywords).to.be.undefined; + }); + + it('sets page and domain values to ortb2 data if canonical link exists', function () { + let validated; + + canonical.href = 'https://www.domain.com/path?query=12345'; + + init(); + + validated = config.getConfig('ortb2'); + expect(validated.site.ref).to.equal(getRefererInfo().referer); + expect(validated.site.page).to.equal('https://www.domain.com/path?query=12345'); + expect(validated.site.domain).to.equal('domain.com'); + expect(validated.device).to.deep.to.equal({w: 1120, h: 750}); + expect(validated.site.keywords).to.be.undefined; + }); + + it('sets keyword values to ortb2 data if keywords meta exists', function () { + let validated; + + keywords.content = 'value1,value2,value3'; + + init(); + + validated = config.getConfig('ortb2'); + expect(validated.site.ref).to.equal(getRefererInfo().referer); + expect(validated.site.page).to.be.undefined; + expect(validated.site.domain).to.be.undefined; + expect(validated.device).to.deep.to.equal({w: 1120, h: 750}); + expect(validated.site.keywords).to.equal('value1,value2,value3'); + }); + + it('only sets values that do not exist in ortb2 config', function () { + let validated; + + config.setConfig({ortb2: {site: {ref: 'https://testpage.com', domain: 'newDomain.com'}}}); + + init(); + + validated = config.getConfig('ortb2'); + expect(validated.site.ref).to.equal('https://testpage.com'); + expect(validated.site.page).to.be.undefined; + expect(validated.site.domain).to.equal('newDomain.com'); + expect(validated.device).to.deep.to.equal({w: 1120, h: 750}); + expect(validated.site.keywords).to.be.undefined; + }); + + it('filters ortb2 data that is set', function () { + let validated; + let conf = { + ortb2: { + user: { + data: {}, + gender: 'f', + age: 45 + }, + site: { + content: { + data: [{ + segment: { + test: 1 + }, + name: 'foo' + }, { + segment: [{ + id: 'test' + }, { + id: 3 + }], + name: 'bar' + }] + } + }, + device: { + w: 1, + h: 1 + } + } + }; + + config.setConfig(conf); + canonical.href = 'https://www.domain.com/path?query=12345'; + width = 1120; + height = 750; + + init(); + + validated = config.getConfig('ortb2'); + expect(validated.site.ref).to.equal(getRefererInfo().referer); + expect(validated.site.page).to.equal('https://www.domain.com/path?query=12345'); + expect(validated.site.domain).to.equal('domain.com'); + expect(validated.site.content.data).to.deep.equal([{segment: [{id: 'test'}], name: 'bar'}]); + expect(validated.user.data).to.be.undefined; + expect(validated.device).to.deep.to.equal({w: 1, h: 1}); + expect(validated.site.keywords).to.be.undefined; + }); + + it('should not overwrite existing data with default settings', function () { + let validated; + let conf = { + ortb2: { + site: { + ref: 'https://referer.com' + } + } + }; + + config.setConfig(conf); + + init(); + + validated = config.getConfig('ortb2'); + expect(validated.site.ref).to.equal('https://referer.com'); + }); + + it('should allow overwrite default data with setConfig', function () { + let validated; + let conf = { + ortb2: { + site: { + ref: 'https://referer.com' + } + } + }; + + config.setConfig(conf); + + init(); + + validated = config.getConfig('ortb2'); + expect(validated.site.ref).to.equal('https://referer.com'); + }); + + it('should filter all data', function () { + let validated; + let conf = { + imp: [], + site: { + name: 123, + domain: 456, + page: 789, + ref: 987, + keywords: ['keywords'], + search: 654, + cat: 'cat', + sectioncat: 'sectioncat', + pagecat: 'pagecat', + content: { + data: [{ + name: 1, + segment: [] + }] + } + }, + user: { + yob: 'twenty', + gender: 0, + keywords: ['foobar'], + data: ['test'] + }, + device: [800, 450], + cur: { + adServerCurrency: 'USD' + } + }; + + config.setConfig({'firstPartyData': {skipEnrichments: true}}); + + config.setConfig({ortb2: conf}); + + init(); + + validated = config.getConfig('ortb2'); + expect(validated).to.deep.equal({}); + }); + + it('should add enrichments but not alter any arbitrary ortb2 data', function () { + let validated; + let conf = { + site: { + ext: { + data: { + inventory: ['value1'] + } + } + }, + user: { + ext: { + data: { + visitor: ['value2'] + } + } + }, + cur: ['USD'] + }; + + config.setConfig({ortb2: conf}); + + init(); + + validated = config.getConfig('ortb2'); + expect(validated.site.ref).to.equal(getRefererInfo().referer); + expect(validated.site.ext.data).to.deep.equal({inventory: ['value1']}); + expect(validated.user.ext.data).to.deep.equal({visitor: ['value2']}); + expect(validated.cur).to.deep.equal(['USD']); + }); + + it('should filter bidderConfig data', function () { + let validated; + let conf = { + bidders: ['bidderA', 'bidderB'], + config: { + ortb2: { + site: { + keywords: 'other', + ref: 'https://domain.com' + }, + user: { + keywords: 'test', + data: [{ + segment: [{id: 4}], + name: 't' + }] + } + } + } + }; + + config.setBidderConfig(conf); + + init(); + + validated = config.getBidderConfig(); + expect(validated.bidderA.ortb2).to.not.be.undefined; + expect(validated.bidderA.ortb2.user.data).to.be.undefined; + expect(validated.bidderA.ortb2.user.keywords).to.equal('test'); + expect(validated.bidderA.ortb2.site.keywords).to.equal('other'); + expect(validated.bidderA.ortb2.site.ref).to.equal('https://domain.com'); + }); + + it('should not filter bidderConfig data as it is valid', function () { + let validated; + let conf = { + bidders: ['bidderA', 'bidderB'], + config: { + ortb2: { + site: { + keywords: 'other', + ref: 'https://domain.com' + }, + user: { + keywords: 'test', + data: [{ + segment: [{id: 'data1_id'}], + name: 'data1' + }] + } + } + } + }; + + config.setBidderConfig(conf); + + init(); + + validated = config.getBidderConfig(); + expect(validated.bidderA.ortb2).to.not.be.undefined; + expect(validated.bidderA.ortb2.user.data).to.deep.equal([{segment: [{id: 'data1_id'}], name: 'data1'}]); + expect(validated.bidderA.ortb2.user.keywords).to.equal('test'); + expect(validated.bidderA.ortb2.site.keywords).to.equal('other'); + expect(validated.bidderA.ortb2.site.ref).to.equal('https://domain.com'); + }); + + it('should not set default values if skipEnrichments is turned on', function () { + let validated; + config.setConfig({'firstPartyData': {skipEnrichments: true}}); + + let conf = { + site: { + keywords: 'other' + }, + user: { + keywords: 'test', + data: [{ + segment: [{id: 'data1_id'}], + name: 'data1' + }] + } + } + ; + + config.setConfig({ortb2: conf}); + + init(); + + validated = config.getConfig(); + expect(validated.ortb2).to.not.be.undefined; + expect(validated.ortb2.device).to.be.undefined; + expect(validated.ortb2.site.ref).to.be.undefined; + expect(validated.ortb2.site.page).to.be.undefined; + expect(validated.ortb2.site.domain).to.be.undefined; + }); + + it('should not validate ortb2 data if skipValidations is turned on', function () { + let validated; + config.setConfig({'firstPartyData': {skipValidations: true}}); + + let conf = { + site: { + keywords: 'other' + }, + user: { + keywords: 'test', + data: [{ + segment: [{id: 'nonfiltered'}] + }] + } + } + ; + + config.setConfig({ortb2: conf}); + + init(); + + validated = config.getConfig(); + expect(validated.ortb2).to.not.be.undefined; + expect(validated.ortb2.user.data).to.deep.equal([{segment: [{id: 'nonfiltered'}]}]); + }); + }); +}); diff --git a/test/spec/modules/validationFpdModule_spec.js b/test/spec/modules/validationFpdModule_spec.js new file mode 100644 index 00000000000..9e8072cb9ed --- /dev/null +++ b/test/spec/modules/validationFpdModule_spec.js @@ -0,0 +1,313 @@ +import {expect} from 'chai'; +import * as utils from 'src/utils.js'; +import { + filterArrayData, + validateFpd +} from 'modules/validationFpdModule/index.js'; + +describe('the first party data validation module', function () { + let ortb2 = { + device: { + h: 911, + w: 1733 + }, + user: { + data: [{ + segment: [{ + id: 'foo' + }], + name: 'bar', + ext: 'string' + }] + }, + site: { + content: { + data: [{ + segment: [{ + id: 'test' + }], + name: 'content', + ext: { + foo: 'bar' + } + }] + } + } + }; + + let conf = { + device: { + h: 500, + w: 750 + }, + user: { + keywords: 'test1, test2', + gender: 'f', + data: [{ + segment: [{ + id: 'test' + }], + name: 'alt' + }] + }, + site: { + ref: 'domain.com', + page: 'www.domain.com/test', + ext: { + data: { + inventory: ['first'] + } + } + } + }; + + describe('filtering first party array data', function () { + it('returns empty array if no valid data', function () { + let arr = [{}]; + let path = 'site.children.cat'; + let child = {type: 'string'}; + let parent = 'site'; + let key = 'cat'; + let validated = filterArrayData(arr, child, path, parent, key); + expect(validated).to.deep.equal([]); + }); + + it('filters invalid type of array data', function () { + let arr = ['foo', {test: 1}]; + let path = 'site.children.cat'; + let child = {type: 'string'}; + let parent = 'site'; + let key = 'cat'; + let validated = filterArrayData(arr, child, path, parent, key); + expect(validated).to.deep.equal(['foo']); + }); + + it('filters all data for missing required children', function () { + let arr = [{test: 1}]; + let path = 'site.children.content.children.data'; + let child = {type: 'object'}; + let parent = 'site'; + let key = 'data'; + let validated = filterArrayData(arr, child, path, parent, key); + expect(validated).to.deep.equal([]); + }); + + it('filters all data for invalid required children types', function () { + let arr = [{name: 'foo', segment: 1}]; + let path = 'site.children.content.children.data'; + let child = {type: 'object'}; + let parent = 'site'; + let key = 'data'; + let validated = filterArrayData(arr, child, path, parent, key); + expect(validated).to.deep.equal([]); + }); + + it('returns only data with valid required nested children types', function () { + let arr = [{name: 'foo', segment: [{id: '1'}, {id: 2}, 'foobar']}]; + let path = 'site.children.content.children.data'; + let child = {type: 'object'}; + let parent = 'site'; + let key = 'data'; + let validated = filterArrayData(arr, child, path, parent, key); + expect(validated).to.deep.equal([{name: 'foo', segment: [{id: '1'}]}]); + }); + }); + + describe('validating first party data', function () { + it('filters user.data[0].ext for incorrect type', function () { + let validated; + let duplicate = utils.deepClone(ortb2); + let expected = { + device: { + h: 911, + w: 1733 + }, + user: { + data: [{ + segment: [{ + id: 'foo' + }], + name: 'bar' + }] + }, + site: { + content: { + data: [{ + segment: [{ + id: 'test' + }], + name: 'content', + ext: { + foo: 'bar' + } + }] + } + } + }; + + validated = validateFpd(duplicate); + expect(validated).to.deep.equal(expected); + }); + + it('filters user and site for empty data', function () { + let validated; + let duplicate = utils.deepClone(ortb2); + let expected = { + device: { + h: 911, + w: 1733 + } + }; + + duplicate.user.data = []; + duplicate.site.content.data = []; + + validated = validateFpd(duplicate); + expect(validated).to.deep.equal(expected); + }); + + it('filters user for empty valid segment values', function () { + let validated; + let duplicate = utils.deepClone(ortb2); + let expected = { + device: { + h: 911, + w: 1733 + }, + site: { + content: { + data: [{ + segment: [{ + id: 'test' + }], + name: 'content', + ext: { + foo: 'bar' + } + }] + } + } + }; + + duplicate.user.data[0].segment.push({test: 3}); + duplicate.user.data[0].segment[0] = {foo: 'bar'}; + + validated = validateFpd(duplicate); + expect(validated).to.deep.equal(expected); + }); + + it('filters user.data[0].ext and site.content.data[0].segement[1] for invalid data', function () { + let validated; + let duplicate = utils.deepClone(ortb2); + let expected = { + device: { + h: 911, + w: 1733 + }, + user: { + data: [{ + segment: [{ + id: 'foo' + }], + name: 'bar' + }] + }, + site: { + content: { + data: [{ + segment: [{ + id: 'test' + }], + name: 'content', + ext: { + foo: 'bar' + } + }] + } + } + }; + + duplicate.site.content.data[0].segment.push({test: 3}); + + validated = validateFpd(duplicate); + expect(validated).to.deep.equal(expected); + }); + + it('filters device for invalid data types', function () { + let validated; + let duplicate = utils.deepClone(ortb2); + duplicate.device = { + h: '1', + w: '1' + } + + let expected = { + user: { + data: [{ + segment: [{ + id: 'foo' + }], + name: 'bar' + }] + }, + site: { + content: { + data: [{ + segment: [{ + id: 'test' + }], + name: 'content', + ext: { + foo: 'bar' + } + }] + } + } + }; + + duplicate.site.content.data[0].segment.push({test: 3}); + + validated = validateFpd(duplicate); + expect(validated).to.deep.equal(expected); + }); + + it('filters cur for invalid data type', function () { + let validated; + let duplicate = utils.deepClone(ortb2); + duplicate.cur = 8; + + let expected = { + device: { + h: 911, + w: 1733 + }, + user: { + data: [{ + segment: [{ + id: 'foo' + }], + name: 'bar' + }] + }, + site: { + content: { + data: [{ + segment: [{ + id: 'test' + }], + name: 'content', + ext: { + foo: 'bar' + } + }] + } + } + }; + + duplicate.site.content.data[0].segment.push({test: 3}); + + validated = validateFpd(duplicate); + expect(validated).to.deep.equal(expected); + }); + }); +}); From 2b8f888dc11d727f49867309f37e492d65eaee96 Mon Sep 17 00:00:00 2001 From: htang555 Date: Fri, 14 May 2021 07:26:42 -0400 Subject: [PATCH 173/303] Datablocks bid adapter: update adapter to conform to new bid server's format (#6696) * update datablocks bid adapter * remove TODO and fix linting errors * updated readme and changed insights to ortb2 * fixed ortb2 change Co-authored-by: John Mayor --- modules/datablocksAnalyticsAdapter.js | 2 +- modules/datablocksBidAdapter.js | 862 ++++++++++++------ modules/datablocksBidAdapter.md | 30 +- .../spec/modules/datablocksBidAdapter_spec.js | 601 +++++++----- 4 files changed, 988 insertions(+), 507 deletions(-) diff --git a/modules/datablocksAnalyticsAdapter.js b/modules/datablocksAnalyticsAdapter.js index 5e977155284..3e4e9e95a4f 100644 --- a/modules/datablocksAnalyticsAdapter.js +++ b/modules/datablocksAnalyticsAdapter.js @@ -16,4 +16,4 @@ adapterManager.registerAnalyticsAdapter({ code: 'datablocks' }); -export default datablocksAdapter; +export default datablocksAdapter; \ No newline at end of file diff --git a/modules/datablocksBidAdapter.js b/modules/datablocksBidAdapter.js index b00a3eae659..038a521308d 100644 --- a/modules/datablocksBidAdapter.js +++ b/modules/datablocksBidAdapter.js @@ -1,330 +1,634 @@ -import * as utils from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -const NATIVE_MAP = { - 'body': 2, - 'body2': 10, - 'price': 6, - 'displayUrl': 11, - 'cta': 12 -}; -const NATIVE_IMAGE = [{ - id: 1, - required: 1, +import { config } from '../src/config.js'; +import * as utils from '../src/utils.js'; +import { BANNER, NATIVE } from '../src/mediaTypes.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { ajax } from '../src/ajax.js'; +export const storage = getStorageManager(); + +const NATIVE_ID_MAP = {}; +const NATIVE_PARAMS = { title: { - len: 140 - } -}, { - id: 2, - required: 1, - img: { type: 3 } -}, { - id: 3, - required: 1, - data: { - type: 11 - } -}, { - id: 4, - required: 0, - data: { + id: 1, + name: 'title' + }, + icon: { + id: 2, + type: 1, + name: 'img' + }, + image: { + id: 3, + type: 3, + name: 'img' + }, + body: { + id: 4, + name: 'data', type: 2 + }, + sponsoredBy: { + id: 5, + name: 'data', + type: 1 + }, + cta: { + id: 6, + type: 12, + name: 'data' + }, + body2: { + id: 7, + name: 'data', + type: 10 + }, + rating: { + id: 8, + name: 'data', + type: 3 + }, + likes: { + id: 9, + name: 'data', + type: 4 + }, + downloads: { + id: 10, + name: 'data', + type: 5 + }, + displayUrl: { + id: 11, + name: 'data', + type: 11 + }, + price: { + id: 12, + name: 'data', + type: 6 + }, + salePrice: { + id: 13, + name: 'data', + type: 7 + }, + address: { + id: 14, + name: 'data', + type: 9 + }, + phone: { + id: 15, + name: 'data', + type: 8 } -}, { - id: 5, - required: 0, - img: { type: 1 } -}, { - id: 6, - required: 0, - data: { - type: 12 - } -}]; +}; -const VIDEO_PARAMS = ['mimes', 'minduration', 'maxduration', 'protocols', 'w', 'h', 'startdelay', - 'placement', 'linearity', 'skip', 'skipmin', 'skipafter', 'sequence', 'battr', 'maxextended', - 'minbitrate', 'maxbitrate', 'boxingallowed', 'playbackmethod', 'playbackend', 'delivery', - 'pos', 'companionad', 'api', 'companiontype', 'ext']; +Object.keys(NATIVE_PARAMS).forEach((key) => { + NATIVE_ID_MAP[NATIVE_PARAMS[key].id] = key; +}); +// DEFINE THE PREBID BIDDER SPEC export const spec = { - supportedMediaTypes: [BANNER, NATIVE, VIDEO], + supportedMediaTypes: [BANNER, NATIVE], code: 'datablocks', + + // DATABLOCKS SCOPED OBJECT + db_obj: {metrics_host: 'prebid.datablocks.net', metrics: [], metrics_timer: null, metrics_queue_time: 1000, vis_optout: false, source_id: 0}, + + // STORE THE DATABLOCKS BUYERID IN STORAGE + store_dbid: function(dbid) { + let stored = false; + + // CREATE 1 YEAR EXPIRY DATE + let d = new Date(); + d.setTime(Date.now() + (365 * 24 * 60 * 60 * 1000)); + + // TRY TO STORE IN COOKIE + if (storage.cookiesAreEnabled) { + storage.setCookie('_db_dbid', dbid, d.toUTCString(), 'None', null); + stored = true; + } + + // TRY TO STORE IN LOCAL STORAGE + if (storage.localStorageIsEnabled) { + storage.setDataInLocalStorage('_db_dbid', dbid); + stored = true; + } + + return stored; + }, + + // FETCH DATABLOCKS BUYERID FROM STORAGE + get_dbid: function() { + let dbId = ''; + if (storage.cookiesAreEnabled) { + dbId = storage.getCookie('_db_dbid') || ''; + } + + if (!dbId && storage.localStorageIsEnabled) { + dbId = storage.getDataFromLocalStorage('_db_dbid') || ''; + } + return dbId; + }, + + // STORE SYNCS IN STORAGE + store_syncs: function(syncs) { + if (storage.localStorageIsEnabled) { + let syncObj = {}; + syncs.forEach(sync => { + syncObj[sync.id] = sync.uid; + }); + + // FETCH EXISTING SYNCS AND MERGE NEW INTO STORAGE + let storedSyncs = this.get_syncs(); + storage.setDataInLocalStorage('_db_syncs', JSON.stringify(Object.assign(storedSyncs, syncObj))); + + return true; + } + }, + + // GET SYNCS FROM STORAGE + get_syncs: function() { + if (storage.localStorageIsEnabled) { + let syncData = storage.getDataFromLocalStorage('_db_syncs'); + if (syncData) { + return JSON.parse(syncData); + } else { + return {}; + } + } else { + return {}; + } + }, + + // ADD METRIC DATA TO THE METRICS RESPONSE QUEUE + queue_metric: function(metric) { + if (typeof metric === 'object') { + // PUT METRICS IN THE QUEUE + this.db_obj.metrics.push(metric); + + // RESET PREVIOUS TIMER + if (this.db_obj.metrics_timer) { + clearTimeout(this.db_obj.metrics_timer); + } + + // SETUP THE TIMER TO FIRE BACK THE DATA + let scope = this; + this.db_obj.metrics_timer = setTimeout(function() { + scope.send_metrics(); + }, this.db_obj.metrics_queue_time); + + return true; + } else { + return false; + } + }, + + // POST CONSOLIDATED METRICS BACK TO SERVER + send_metrics: function() { + // POST TO SERVER + ajax(`https://${this.db_obj.metrics_host}/a/pb/`, null, JSON.stringify(this.db_obj.metrics), {method: 'POST', withCredentials: true}); + + // RESET THE QUEUE OF METRIC DATA + this.db_obj.metrics = []; + + return true; + }, + + // GET BASIC CLIENT INFORMATION + get_client_info: function () { + let botTest = new BotClientTests(); + let win = utils.getWindowTop(); + return { + 'wiw': win.innerWidth, + 'wih': win.innerHeight, + 'saw': screen ? screen.availWidth : null, + 'sah': screen ? screen.availHeight : null, + 'scd': screen ? screen.colorDepth : null, + 'sw': screen ? screen.width : null, + 'sh': screen ? screen.height : null, + 'whl': win.history.length, + 'wxo': win.pageXOffset, + 'wyo': win.pageYOffset, + 'wpr': win.devicePixelRatio, + 'is_bot': botTest.doTests(), + 'is_hid': win.document.hidden, + 'vs': win.document.visibilityState + }; + }, + + // LISTEN FOR GPT VIEWABILITY EVENTS + get_viewability: function(bid) { + // ONLY RUN ONCE IF PUBLISHER HAS OPTED IN + if (!this.db_obj.vis_optout && !this.db_obj.vis_run) { + this.db_obj.vis_run = true; + + // ADD GPT EVENT LISTENERS + let scope = this; + if (utils.isGptPubadsDefined()) { + if (typeof window['googletag'].pubads().addEventListener == 'function') { + window['googletag'].pubads().addEventListener('impressionViewable', function(event) { + scope.queue_metric({type: 'slot_view', source_id: scope.db_obj.source_id, auction_id: bid.auctionId, div_id: event.slot.getSlotElementId(), slot_id: event.slot.getSlotId().getAdUnitPath()}); + }); + window['googletag'].pubads().addEventListener('slotRenderEnded', function(event) { + scope.queue_metric({type: 'slot_render', source_id: scope.db_obj.source_id, auction_id: bid.auctionId, div_id: event.slot.getSlotElementId(), slot_id: event.slot.getSlotId().getAdUnitPath()}); + }) + } + } + } + }, + + // VALIDATE THE BID REQUEST isBidRequestValid: function(bid) { - return !!(bid.params.host && bid.params.sourceId && - bid.mediaTypes && (bid.mediaTypes.banner || bid.mediaTypes.native || bid.mediaTypes.video)); + // SET GLOBAL VARS FROM BIDDER CONFIG + this.db_obj.source_id = bid.params.source_id; + if (bid.params.vis_optout) { + this.db_obj.vis_optout = true; + } + + return !!(bid.params.source_id && bid.mediaTypes && (bid.mediaTypes.banner || bid.mediaTypes.native)); }, - buildRequests: function(validBidRequests, bidderRequest) { - if (!validBidRequests.length) { return []; } - let imps = {}; - let site = {}; - let device = {}; - let refurl = utils.parseUrl(bidderRequest.referrer); - let requests = []; + // GENERATE THE RTB REQUEST + buildRequests: function(validRequests, bidderRequest) { + // RETURN EMPTY IF THERE ARE NO VALID REQUESTS + if (!validRequests.length) { + return []; + } - validBidRequests.forEach(bidRequest => { + // CONVERT PREBID NATIVE REQUEST OBJ INTO RTB OBJ + function createNativeRequest(bid) { + const assets = []; + if (bid.nativeParams) { + Object.keys(bid.nativeParams).forEach((key) => { + if (NATIVE_PARAMS[key]) { + const {name, type, id} = NATIVE_PARAMS[key]; + const assetObj = type ? {type} : {}; + let {len, sizes, required, aspect_ratios: aRatios} = bid.nativeParams[key]; + if (len) { + assetObj.len = len; + } + if (aRatios && aRatios[0]) { + aRatios = aRatios[0]; + let wmin = aRatios.min_width || 0; + let hmin = aRatios.ratio_height * wmin / aRatios.ratio_width | 0; + assetObj.wmin = wmin; + assetObj.hmin = hmin; + } + if (sizes && sizes.length) { + sizes = [].concat(...sizes); + assetObj.w = sizes[0]; + assetObj.h = sizes[1]; + } + const asset = {required: required ? 1 : 0, id}; + asset[name] = assetObj; + assets.push(asset); + } + }); + } + return { + ver: '1.2', + request: { + assets: assets, + context: 1, + plcmttype: 1, + ver: '1.2' + } + } + } + let imps = []; + // ITERATE THE VALID REQUESTS AND GENERATE IMP OBJECT + validRequests.forEach(bidRequest => { + // BUILD THE IMP OBJECT let imp = { id: bidRequest.bidId, - tagid: bidRequest.adUnitCode, - secure: window.location.protocol == 'https:' + tagid: bidRequest.params.tagid || bidRequest.adUnitCode, + placement_id: bidRequest.params.placement_id || 0, + secure: window.location.protocol == 'https:', + ortb2: utils.deepAccess(bidRequest, `ortb2Imp`) || {}, + floor: {} } + // CHECK FOR FLOORS + if (typeof bidRequest.getFloor === 'function') { + imp.floor = bidRequest.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*' + }); + } + + // BUILD THE SIZES if (utils.deepAccess(bidRequest, `mediaTypes.banner`)) { - let sizes = bidRequest.mediaTypes.banner.sizes; - if (sizes.length == 1) { + let sizes = utils.getAdUnitSizes(bidRequest); + if (sizes.length) { imp.banner = { w: sizes[0][0], - h: sizes[0][1] - } - } else if (sizes.length > 1) { - imp.banner = { + h: sizes[0][1], format: sizes.map(size => ({ w: size[0], h: size[1] })) }; - } else { - return; - } - } else if (utils.deepAccess(bidRequest, 'mediaTypes.native')) { - let nativeImp = bidRequest.mediaTypes.native; - - if (nativeImp.type) { - let nativeAssets = []; - switch (nativeImp.type) { - case 'image': - nativeAssets = NATIVE_IMAGE; - break; - default: - return; - } - imp.native = JSON.stringify({ assets: nativeAssets }); - } else { - let nativeAssets = []; - let nativeKeys = Object.keys(nativeImp); - nativeKeys.forEach((nativeKey, index) => { - let required = !!nativeImp[nativeKey].required; - let assetId = index + 1; - switch (nativeKey) { - case 'title': - nativeAssets.push({ - id: assetId, - required: required, - title: { - len: nativeImp[nativeKey].len || 140 - } - }); - break; - case 'body': // desc - case 'body2': // desc2 - case 'price': - case 'display_url': - let data = { - id: assetId, - required: required, - data: { - type: NATIVE_MAP[nativeKey] - } - } - if (nativeImp[nativeKey].data && nativeImp[nativeKey].data.len) { data.data.len = nativeImp[nativeKey].data.len; } - - nativeAssets.push(data); - break; - case 'image': - if (nativeImp[nativeKey].sizes && nativeImp[nativeKey].sizes.length) { - nativeAssets.push({ - id: assetId, - required: required, - image: { - type: 3, - w: nativeImp[nativeKey].sizes[0], - h: nativeImp[nativeKey].sizes[1] - } - }) - } - } - }); - imp.native = { - request: JSON.stringify({native: {assets: nativeAssets}}) - }; - } - } else if (utils.deepAccess(bidRequest, 'mediaTypes.video')) { - let video = bidRequest.mediaTypes.video; - let sizes = video.playerSize || bidRequest.sizes || []; - if (sizes.length && Array.isArray(sizes[0])) { - imp.video = { - w: sizes[0][0], - h: sizes[0][1] - }; - } else if (sizes.length == 2 && !Array.isArray(sizes[0])) { - imp.video = { - w: sizes[0], - h: sizes[1] - }; - } else { - return; - } - - if (video.durationRangeSec) { - if (Array.isArray(video.durationRangeSec)) { - if (video.durationRangeSec.length == 1) { - imp.video.maxduration = video.durationRangeSec[0]; - } else if (video.durationRangeSec.length == 2) { - imp.video.minduration = video.durationRangeSec[0]; - imp.video.maxduration = video.durationRangeSec[1]; - } - } else { - imp.video.maxduration = video.durationRangeSec; - } - } - if (bidRequest.params.video) { - Object.keys(bidRequest.params.video).forEach(k => { - if (VIDEO_PARAMS.indexOf(k) > -1) { - imp.video[k] = bidRequest.params.video[k]; - } - }) + // ADD TO THE LIST OF IMP REQUESTS + imps.push(imp); } + } else if (utils.deepAccess(bidRequest, `mediaTypes.native`)) { + // ADD TO THE LIST OF IMP REQUESTS + imp.native = createNativeRequest(bidRequest); + imps.push(imp); } - let host = bidRequest.params.host; - let sourceId = bidRequest.params.sourceId; - imps[host] = imps[host] || {}; - let hostImp = imps[host][sourceId] = imps[host][sourceId] || { imps: [] }; - hostImp.imps.push(imp); - hostImp.subid = hostImp.imps.subid || bidRequest.params.subid || 'blank'; - hostImp.path = 'search'; - hostImp.idParam = 'sid'; - hostImp.protocol = '//'; }); - // Generate Site obj - site.domain = refurl.hostname; - site.page = refurl.protocol + '://' + refurl.hostname + refurl.pathname; + // RETURN EMPTY IF THERE WERE NO PROPER ADUNIT REQUESTS TO BE MADE + if (!imps.length) { + return []; + } + + // GENERATE SITE OBJECT + let site = { + domain: window.location.host, + page: bidderRequest.refererInfo.referer, + schain: validRequests[0].schain || {}, + ext: { + p_domain: config.getConfig('publisherDomain'), + rt: bidderRequest.refererInfo.reachedTop, + frames: bidderRequest.refererInfo.numIframes, + stack: bidderRequest.refererInfo.stack, + timeout: config.getConfig('bidderTimeout') + }, + } + + // ADD REF URL IF FOUND if (self === top && document.referrer) { site.ref = document.referrer; } + + // ADD META KEYWORDS IF FOUND let keywords = document.getElementsByTagName('meta')['keywords']; if (keywords && keywords.content) { site.keywords = keywords.content; } - // Generate Device obj. - device.ip = 'peer'; - device.ua = window.navigator.userAgent; - device.js = 1; - device.language = ((navigator.language || navigator.userLanguage || '').split('-'))[0] || 'en'; - - RtbRequest(device, site, imps).forEach(formatted => { - requests.push({ - method: 'POST', - url: formatted.url, - data: formatted.body, - options: { - withCredentials: false + // GENERATE DEVICE OBJECT + let device = { + ip: 'peer', + ua: window.navigator.userAgent, + js: 1, + language: ((navigator.language || navigator.userLanguage || '').split('-'))[0] || 'en', + buyerid: this.get_dbid() || 0, + ext: { + pb_eids: validRequests[0].userIdAsEids || {}, + syncs: this.get_syncs() || {}, + coppa: config.getConfig('coppa') || 0, + gdpr: bidderRequest.gdprConsent || {}, + usp: bidderRequest.uspConsent || {}, + client_info: this.get_client_info(), + ortb2: config.getConfig('ortb2') || {} + } + }; + + let sourceId = validRequests[0].params.source_id || 0; + let host = validRequests[0].params.host || 'prebid.datablocks.net'; + + // RETURN WITH THE REQUEST AND PAYLOAD + return { + method: 'POST', + url: `https://${sourceId}.${host}/openrtb/?sid=${sourceId}`, + data: { + id: bidderRequest.auctionId, + imp: imps, + site: site, + device: device + }, + options: { + withCredentials: true + } + }; + }, + + // INITIATE USER SYNCING + getUserSyncs: function(options, rtbResponse, gdprConsent) { + const syncs = []; + let bidResponse = rtbResponse[0].body; + let scope = this; + + // LISTEN FOR SYNC DATA FROM IFRAME TYPE SYNC + window.addEventListener('message', function (event) { + if (event.data.sentinel && event.data.sentinel === 'dblks_syncData') { + // STORE FOUND SYNCS + if (event.data.syncs) { + scope.store_syncs(event.data.syncs); } - }) + } }); - return requests; - - function RtbRequest(device, site, imps) { - let collection = []; - Object.keys(imps).forEach(host => { - let sourceIds = imps[host]; - Object.keys(sourceIds).forEach(sourceId => { - let impObj = sourceIds[sourceId]; - collection.push({ - url: `https://${host}/${impObj.path}/?${impObj.idParam}=${sourceId}`, - body: { - id: bidderRequest.auctionId, - imp: impObj.imps, - site: Object.assign({ id: impObj.subid || 'blank' }, site), - device: Object.assign({}, device) - } - }) - }) + + // POPULATE GDPR INFORMATION + let gdprData = { + gdpr: 0, + gdprConsent: '' + } + if (typeof gdprConsent === 'object') { + if (typeof gdprConsent.gdprApplies === 'boolean') { + gdprData.gdpr = Number(gdprConsent.gdprApplies); + gdprData.gdprConsent = gdprConsent.consentString; + } else { + gdprData.gdprConsent = gdprConsent.consentString; + } + } + + // EXTRACT BUYERID COOKIE VALUE FROM BID RESPONSE AND PUT INTO STORAGE + let dbBuyerId = this.get_dbid() || ''; + if (bidResponse.ext && bidResponse.ext.buyerid) { + dbBuyerId = bidResponse.ext.buyerid; + this.store_dbid(dbBuyerId); + } + + // EXTRACT USERSYNCS FROM BID RESPONSE + if (bidResponse.ext && bidResponse.ext.syncs) { + bidResponse.ext.syncs.forEach(sync => { + if (checkValid(sync)) { + syncs.push(addParams(sync)); + } }) + } + + // APPEND PARAMS TO SYNC URL + function addParams(sync) { + // PARSE THE URL + let url = new URL(sync.url); + let urlParams = Object.assign({}, Object.fromEntries(url.searchParams)); + + // APPLY EXTRA VARS + urlParams.gdpr = gdprData.gdpr; + urlParams.gdprConsent = gdprData.gdprConsent; + urlParams.bidid = bidResponse.bidid; + urlParams.id = bidResponse.id; + urlParams.uid = dbBuyerId; + + // REBUILD URL + sync.url = `${url.origin}${url.pathname}?${Object.keys(urlParams).map(key => key + '=' + encodeURIComponent(urlParams[key])).join('&')}`; - return collection; + // RETURN THE REBUILT URL + return sync; } + + // ENSURE THAT THE SYNC TYPE IS VALID AND HAS PERMISSION + function checkValid(sync) { + if (!sync.type || !sync.url) { + return false; + } + switch (sync.type) { + case 'iframe': + return options.iframeEnabled; + case 'image': + return options.pixelEnabled; + default: + return false; + } + } + return syncs; }, - interpretResponse: function(serverResponse, bidRequest) { - if (!serverResponse || !serverResponse.body || !serverResponse.body.seatbid) { - return []; + + // DATABLOCKS WON THE AUCTION - REPORT SUCCESS + onBidWon: function(bid) { + this.queue_metric({type: 'bid_won', source_id: bid.params[0].source_id, req_id: bid.requestId, slot_id: bid.adUnitCode, auction_id: bid.auctionId, size: bid.size, cpm: bid.cpm, pb: bid.adserverTargeting.hb_pb, rt: bid.timeToRespond, ttl: bid.ttl}); + }, + + // TARGETING HAS BEEN SET + onSetTargeting: function(bid) { + // LISTEN FOR VIEWABILITY EVENTS + this.get_viewability(bid); + }, + + // PARSE THE RTB RESPONSE AND RETURN FINAL RESULTS + interpretResponse: function(rtbResponse, bidRequest) { + // CONVERT NATIVE RTB RESPONSE INTO PREBID RESPONSE + function parseNative(native) { + const {assets, link, imptrackers, jstracker} = native; + const result = { + clickUrl: link.url, + clickTrackers: link.clicktrackers || [], + impressionTrackers: imptrackers || [], + javascriptTrackers: jstracker ? [jstracker] : [] + }; + + (assets || []).forEach((asset) => { + const {id, img, data, title} = asset; + const key = NATIVE_ID_MAP[id]; + if (key) { + if (!utils.isEmpty(title)) { + result.title = title.text + } else if (!utils.isEmpty(img)) { + result[key] = { + url: img.url, + height: img.h, + width: img.w + } + } else if (!utils.isEmpty(data)) { + result[key] = data.value; + } + } + }); + + return result; } - let body = serverResponse.body; - - let bids = body.seatbid - .map(seatbid => seatbid.bid) - .reduce((memo, bid) => memo.concat(bid), []); - let req = bidRequest.data; - let reqImps = req.imp; - - return bids.map(rtbBid => { - let imp; - for (let i in reqImps) { - let testImp = reqImps[i] - if (testImp.id == rtbBid.impid) { - imp = testImp; + + let bids = []; + let resBids = utils.deepAccess(rtbResponse, 'body.seatbid') || []; + resBids.forEach(bid => { + let resultItem = {requestId: bid.id, cpm: bid.price, creativeId: bid.crid, currency: bid.currency || 'USD', netRevenue: true, ttl: bid.ttl || 360}; + + let mediaType = utils.deepAccess(bid, 'ext.mtype') || ''; + switch (mediaType) { + case 'banner': + bids.push(Object.assign({}, resultItem, {mediaType: BANNER, width: bid.w, height: bid.h, ad: bid.adm})); + break; + + case 'native': + let nativeResult = JSON.parse(bid.adm); + bids.push(Object.assign({}, resultItem, {mediaType: NATIVE, native: parseNative(nativeResult.native)})); + break; + + default: break; - } } - let br = { - requestId: rtbBid.impid, - cpm: rtbBid.price, - creativeId: rtbBid.crid, - currency: rtbBid.currency || 'USD', - netRevenue: true, - ttl: 360 - }; - if (!imp) { - return br; - } else if (imp.banner) { - br.mediaType = BANNER; - br.width = rtbBid.w; - br.height = rtbBid.h; - br.ad = rtbBid.adm; - } else if (imp.native) { - br.mediaType = NATIVE; - - let reverseNativeMap = {}; - let nativeKeys = Object.keys(NATIVE_MAP); - nativeKeys.forEach(k => { - reverseNativeMap[NATIVE_MAP[k]] = k; - }); + }) - let idMap = {}; - let nativeReq = JSON.parse(imp.native.request); - if (nativeReq.native && nativeReq.native.assets) { - nativeReq.native.assets.forEach(asset => { - if (asset.data) { idMap[asset.id] = reverseNativeMap[asset.data.type]; } - }) + return bids; + } +}; + +// DETECT BOTS +export class BotClientTests { + constructor() { + this.tests = { + headless_chrome: function() { + if (self.navigator) { + if (self.navigator.webdriver) { + return true; + } } - const nativeResponse = JSON.parse(rtbBid.adm); - const { assets, link, imptrackers, jstrackers } = nativeResponse.native; - const result = { - clickUrl: link.url, - clickTrackers: link.clicktrackers || undefined, - impressionTrackers: imptrackers || undefined, - javascriptTrackers: jstrackers ? [jstrackers] : undefined - }; - assets.forEach(asset => { - if (asset.title) { - result.title = asset.title.text; - } else if (asset.img) { - result.image = asset.img.url; - } else if (idMap[asset.id]) { - result[idMap[asset.id]] = asset.data.value; + return false; + }, + user_agent: function() { + try { + var re = new RegExp('(googlebot\/|bot|Googlebot-Mobile|Googlebot-Image|Google favicon|Mediapartners-Google|bingbot|slurp|java|wget|curl|Commons-HttpClient|Python-urllib|libwww|httpunit|nutch|phpcrawl|msnbot|jyxobot|FAST-WebCrawler|FAST Enterprise Crawler|biglotron|teoma|convera|seekbot|gigablast|exabot|ngbot|ia_archiver|GingerCrawler|webmon |httrack|webcrawler|grub.org|UsineNouvelleCrawler|antibot|netresearchserver|speedy|fluffy|bibnum.bnf|findlink|msrbot|panscient|yacybot|AISearchBot|IOI|ips-agent|tagoobot|MJ12bot|dotbot|woriobot|yanga|buzzbot|mlbot|yandexbot|purebot|Linguee Bot|Voyager|CyberPatrol|voilabot|baiduspider|citeseerxbot|spbot|twengabot|postrank|turnitinbot|scribdbot|page2rss|sitebot|linkdex|Adidxbot|blekkobot|ezooms|dotbot|Mail.RU_Bot|discobot|heritrix|findthatfile|europarchive.org|NerdByNature.Bot|sistrix crawler|ahrefsbot|Aboundex|domaincrawler|wbsearchbot|summify|ccbot|edisterbot|seznambot|ec2linkfinder|gslfbot|aihitbot|intelium_bot|facebookexternalhit|yeti|RetrevoPageAnalyzer|lb-spider|sogou|lssbot|careerbot|wotbox|wocbot|ichiro|DuckDuckBot|lssrocketcrawler|drupact|webcompanycrawler|acoonbot|openindexspider|gnam gnam spider|web-archive-net.com.bot|backlinkcrawler|coccoc|integromedb|content crawler spider|toplistbot|seokicks-robot|it2media-domain-crawler|ip-web-crawler.com|siteexplorer.info|elisabot|proximic|changedetection|blexbot|arabot|WeSEE:Search|niki-bot|CrystalSemanticsBot|rogerbot|360Spider|psbot|InterfaxScanBot|Lipperhey SEO Service|CC Metadata Scaper|g00g1e.net|GrapeshotCrawler|urlappendbot|brainobot|fr-crawler|binlar|SimpleCrawler|Livelapbot|Twitterbot|cXensebot|smtbot|bnf.fr_bot|A6-Indexer|ADmantX|Facebot|Twitterbot|OrangeBot|memorybot|AdvBot|MegaIndex|SemanticScholarBot|ltx71|nerdybot|xovibot|BUbiNG|Qwantify|archive.org_bot|Applebot|TweetmemeBot|crawler4j|findxbot|SemrushBot|yoozBot|lipperhey|y!j-asr|Domain Re-Animator Bot|AddThis)', 'i'); + if (re.test(navigator.userAgent)) { + return true; } - }) - br.native = result; - } else if (imp.video) { - br.mediaType = VIDEO; - br.width = rtbBid.w; - br.height = rtbBid.h; - if (rtbBid.adm) { br.vastXml = rtbBid.adm; } else if (rtbBid.nurl) { br.vastUrl = rtbBid.nurl; } + return false; + } catch (e) { + return false; + } + }, + + selenium: function () { + let response = false; + + if (window && document) { + let results = [ + 'webdriver' in window, + '_Selenium_IDE_Recorder' in window, + 'callSelenium' in window, + '_selenium' in window, + '__webdriver_script_fn' in document, + '__driver_evaluate' in document, + '__webdriver_evaluate' in document, + '__selenium_evaluate' in document, + '__fxdriver_evaluate' in document, + '__driver_unwrapped' in document, + '__webdriver_unwrapped' in document, + '__selenium_unwrapped' in document, + '__fxdriver_unwrapped' in document, + '__webdriver_script_func' in document, + document.documentElement.getAttribute('selenium') !== null, + document.documentElement.getAttribute('webdriver') !== null, + document.documentElement.getAttribute('driver') !== null + ]; + + results.forEach(result => { + if (result === true) { + response = true; + } + }) + } + + return response; + }, + } + } + + doTests() { + let response = false; + for (const [, t] of Object.entries(this.tests)) { + if (t() === true) { + response = true; } - return br; - }); + } + return response; } +} -}; +// INIT OUR BIDDER WITH PREBID registerBidder(spec); diff --git a/modules/datablocksBidAdapter.md b/modules/datablocksBidAdapter.md index e30cd361974..2730443d72d 100644 --- a/modules/datablocksBidAdapter.md +++ b/modules/datablocksBidAdapter.md @@ -8,8 +8,8 @@ Maintainer: support@datablocks.net # Description -Connects to Datablocks Version 5 Platform -Banner Native and Video +Connects to Datablocks Exchange +Banner and Native # Test Parameters @@ -27,12 +27,13 @@ Banner Native and Video { bidder: 'datablocks', params: { - sourceId: 12345, + source_id: 12345, host: 'prebid.datablocks.net' } } ] - }, { + }, + { code: 'native-div', mediaTypes : { native: { @@ -44,28 +45,9 @@ Banner Native and Video { bidder: 'datablocks', params: { - sourceId: 12345, + source_id: 12345, host: 'prebid.datablocks.net' } - }, { - code: 'video-div', - mediaTypes : { - video: { - playerSize:[500,400], - durationRangeSec:[15,30], - context: "linear" - } - }, - bids: [ - { - bidder: 'datablocks', - params: { - sourceId: 12345, - host: 'prebid.datablocks.net', - video: { - mimes:["video/flv"] - } - } } ] } diff --git a/test/spec/modules/datablocksBidAdapter_spec.js b/test/spec/modules/datablocksBidAdapter_spec.js index 18b8aac7371..147000f2363 100644 --- a/test/spec/modules/datablocksBidAdapter_spec.js +++ b/test/spec/modules/datablocksBidAdapter_spec.js @@ -1,12 +1,15 @@ import { expect } from 'chai'; import { spec } from '../../../modules/datablocksBidAdapter.js'; +import { BotClientTests } from '../../../modules/datablocksBidAdapter.js'; +import { getStorageManager } from '../../../src/storageManager.js'; +export let storage = getStorageManager(); -let bid = { +const bid = { bidId: '2dd581a2b6281d', bidder: 'datablocks', bidderRequestId: '145e1d6a7837c9', params: { - sourceId: 7560, + source_id: 7560, host: 'v5demo.datablocks.net' }, adUnitCode: '/19968336/header-bid-tag-0', @@ -24,12 +27,12 @@ let bid = { transactionId: '1ccbee15-f6f6-46ce-8998-58fe5542e8e1' }; -let bid2 = { +const bid2 = { bidId: '2dd581a2b624324g', bidder: 'datablocks', bidderRequestId: '145e1d6a7837543', params: { - sourceId: 7560, + source_id: 7560, host: 'v5demo.datablocks.net' }, adUnitCode: '/19968336/header-bid-tag-0', @@ -43,7 +46,7 @@ let bid2 = { transactionId: '1ccbee15-f6f6-46ce-8998-58fe55425432' }; -let nativeBid = { +const nativeBid = { adUnitCode: '/19968336/header-bid-tag-0', auctionId: '160c78a4-f808-410f-b682-d8728f3a79ee', bidId: '332045ee374a99', @@ -78,41 +81,18 @@ let nativeBid = { } }, params: { - sourceId: 7560, + source_id: 7560, host: 'v5demo.datablocks.net' }, transactionId: '0a4e9788-4def-4b94-bc25-564d7cac99f6' } -let videoBid = { - adUnitCode: '/19968336/header-bid-tag-0', - auctionId: '160c78a4-f808-410f-b682-d8728f3a79e1', - bidId: '332045ee374b99', - bidder: 'datablocks', - bidderRequestId: '15d9012765e36d', - mediaTypes: { - video: { - context: 'instream', - playerSize: [501, 400], - durationRangeSec: [15, 60] - } - }, - params: { - sourceId: 7560, - host: 'v5demo.datablocks.net', - video: { - minduration: 14 - } - }, - transactionId: '0a4e9788-4def-4b94-bc25-564d7cac99f7' -} - const bidderRequest = { auctionId: '8bfef1be-d3ac-4d18-8859-754c7b4cf017', auctionStart: Date.now(), biddeCode: 'datablocks', bidderRequestId: '10c47a5fc3c41', - bids: [bid, bid2, nativeBid, videoBid], + bids: [bid, bid2, nativeBid], refererInfo: { numIframes: 0, reachedTop: true, @@ -123,208 +103,423 @@ const bidderRequest = { timeout: 10000 }; -let resObject = { +const res_object = { body: { - id: '10c47a5fc3c41', - bidid: '166895245-28-11347-1', - seatbid: [{ - seat: '7560', - bid: [{ - id: '1090738570', - impid: '2966b257c81d27', - price: 24.000000, - adm: 'RON', - cid: '55', - adid: '177654', - crid: '177656', - cat: [], - api: [], - w: 300, - h: 250 - }, { - id: '1090738571', - impid: '2966b257c81d28', - price: 24.000000, - adm: 'RON', - cid: '55', - adid: '177654', - crid: '177656', - cat: [], - api: [], - w: 728, - h: 90 - }, { - id: '1090738570', - impid: '15d9012765e36c', - price: 24.000000, - adm: '{"native":{"ver":"1.2","assets":[{"id":1,"required":1,"title":{"text":"Example Title"}},{"id":2,"required":1,"data":{"value":"Example Body"}},{"id":3,"required":1,"img":{"url":"https://example.image.com/"}}],"link":{"url":"https://click.example.com/c/264597/?fcid=29699699045816"},"imptrackers":["https://impression.example.com/i/264597/?fcid=29699699045816"]}}', - cid: '132145', - adid: '154321', - crid: '177432', - cat: [], - api: [] - }, { - id: '1090738575', - impid: '15d9012765e36f', - price: 25.000000, - cid: '12345', - adid: '12345', - crid: '123456', - nurl: 'https://click.v5demo.datablocks.net/m//?fcid=435235435432', - cat: [], - api: [], - w: 500, - h: 400 - }] - }], - cur: 'USD', - ext: {} + 'id': '10c47a5fc3c41', + 'bidid': '217868445-30021-19053-0', + 'seatbid': [ + { + 'id': '22621593137287', + 'impid': '1', + 'adm': 'John is great', + 'adomain': ['medianet.com'], + 'price': 0.430000, + 'cid': '2524568', + 'adid': '0', + 'crid': '0', + 'cat': [], + 'w': 300, + 'h': 250, + 'ext': { + 'type': 'CPM', + 'mtype': 'banner' + } + }, + { + 'id': '22645215457415', + 'impid': '2', + 'adm': 'john is the best', + 'adomain': ['td.com'], + 'price': 0.580000, + 'cid': '2524574', + 'adid': '0', + 'crid': '0', + 'cat': [], + 'w': 728, + 'h': 90, + 'ext': { + 'type': 'CPM', + 'mtype': 'banner' + } + }, + + { + 'id': '22645215457416', + 'impid': '3', + 'adm': '{"native":{"ver":"1.2","assets":[{"id":1,"required":1,"title":{"text":"John is amazing"}},{"id":5,"required":1,"data":{"value":"Sponsored by John"}},{"id":3,"required":1,"img":{"url":"https://example.image.com/", "h":"360", "w":"360"}}],"link":{"url":"https://click.example.com/c/264597/?fcid=29699699045816"},"imptrackers":["https://impression.example.com/i/264597/?fcid=29699699045816"]}}', + 'adomain': ['td.com'], + 'price': 10.00, + 'cid': '2524574', + 'adid': '0', + 'crid': '0', + 'cat': [], + 'ext': { + 'type': 'CPM', + 'mtype': 'native' + } + } + ], + 'cur': 'USD', + 'ext': { + 'version': '1.2.93', + 'buyerid': '1234567', + 'syncs': [ + { + 'type': 'iframe', + 'url': 'https://s.0cf.io' + }, + { + 'type': 'image', + 'url': 'https://us.dblks.net/set_uid/' + } + ] + } } -}; -let bidRequest = { +} + +let bid_request = { method: 'POST', - url: 'https://v5demo.datablocks.net/search/?sid=7560', + url: 'https://prebid.datablocks.net/openrtb/?sid=2523014', options: { - withCredentials: false + withCredentials: true }, data: { - device: { - ip: 'peer', - ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) Ap…ML, like Gecko) Chrome/73.0.3683.86 Safari/537.36', - js: 1, - language: 'en' - }, - id: '10c47a5fc3c41', - imp: [{ - banner: { w: 300, h: 250 }, - id: '2966b257c81d27', - secure: false, - tagid: '/19968336/header-bid-tag-0' - }, { - banner: { w: 728, h: 90 }, - id: '2966b257c81d28', - secure: false, - tagid: '/19968336/header-bid-tag-0' - }, { - id: '15d9012765e36c', - native: {request: '{"native":{"assets":[{"id":"1","required":true,"title":{"len":140}},{"id":"2","required":true,"data":{"type":2}},{"id":"3","img":{"w":728,"h":90,"type":3}}]}}'}, - secure: false, - tagid: '/19968336/header-bid-tag-0' - }, { - id: '15d9012765e36f', - video: {w: 500, h: 400, minduration: 15, maxduration: 60}, - secure: false, - tagid: '/19968336/header-bid-tag-0' - }], - site: { - domain: '', - id: 'blank', - page: 'https://v5demo.datablocks.net/test' - } + 'id': 'c09c6e47-8bdb-4884-a46d-93165322b368', + 'imp': [{ + 'id': '1', + 'tagid': '/19968336/header-bid-tag-0', + 'placement_id': 0, + 'secure': true, + 'banner': { + 'w': 300, + 'h': 250, + 'format': [{ + 'w': 300, + 'h': 250 + }, { + 'w': 300, + 'h': 600 + }] + } + }, { + 'id': '2', + 'tagid': '/19968336/header-bid-tag-1', + 'placement_id': 12345, + 'secure': true, + 'banner': { + 'w': 729, + 'h': 90, + 'format': [{ + 'w': 729, + 'h': 90 + }, { + 'w': 970, + 'h': 250 + }] + } + }, { + 'id': '3', + 'tagid': '/19968336/prebid_multiformat_test', + 'placement_id': 0, + 'secure': true, + 'native': { + 'ver': '1.2', + 'request': { + 'assets': [{ + 'required': 1, + 'id': 1, + 'title': {} + }, { + 'required': 1, + 'id': 3, + 'img': { + 'type': 3 + } + }, { + 'required': 1, + 'id': 5, + 'data': { + 'type': 1 + } + }], + 'context': 1, + 'plcmttype': 1, + 'ver': '1.2' + } + } + }], + 'site': { + 'domain': 'test.datablocks.net', + 'page': 'https://test.datablocks.net/index.html', + 'schain': {}, + 'ext': { + 'p_domain': 'https://test.datablocks.net', + 'rt': true, + 'frames': 0, + 'stack': ['https://test.datablocks.net/index.html'], + 'timeout': 3000 + }, + 'keywords': 'HTML, CSS, JavaScript' + }, + 'device': { + 'ip': 'peer', + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36', + 'js': 1, + 'language': 'en', + 'buyerid': '1234567', + 'ext': { + 'pb_eids': [{ + 'source': 'criteo.com', + 'uids': [{ + 'id': 'test', + 'atype': 1 + }] + }], + 'syncs': { + '1000': 'db_4044853', + '1001': true + }, + 'coppa': 0, + 'gdpr': {}, + 'usp': {}, + 'client_info': { + 'wiw': 2560, + 'wih': 1281, + 'saw': 2560, + 'sah': 1417, + 'scd': 24, + 'sw': 2560, + 'sh': 1440, + 'whl': 4, + 'wxo': 0, + 'wyo': 0, + 'wpr': 2, + 'is_bot': false, + 'is_hid': false, + 'vs': 'hidden' + }, + 'fpd': {} + } + } } } describe('DatablocksAdapter', function() { + describe('All needed functions are available', function() { + it(`isBidRequestValid is present and type function`, function () { + expect(spec.isBidRequestValid).to.exist.and.to.be.a('function') + }); + + it(`buildRequests is present and type function`, function () { + expect(spec.buildRequests).to.exist.and.to.be.a('function') + }); + + it(`getUserSyncs is present and type function`, function () { + expect(spec.getUserSyncs).to.exist.and.to.be.a('function') + }); + + it(`onBidWon is present and type function`, function () { + expect(spec.onBidWon).to.exist.and.to.be.a('function') + }); + + it(`onSetTargeting is present and type function`, function () { + expect(spec.onSetTargeting).to.exist.and.to.be.a('function') + }); + + it(`interpretResponse is present and type function`, function () { + expect(spec.interpretResponse).to.exist.and.to.be.a('function') + }); + + it(`store_dbid is present and type function`, function () { + expect(spec.store_dbid).to.exist.and.to.be.a('function') + }); + + it(`get_dbid is present and type function`, function () { + expect(spec.get_dbid).to.exist.and.to.be.a('function') + }); + + it(`store_syncs is present and type function`, function () { + expect(spec.store_syncs).to.exist.and.to.be.a('function') + }); + + it(`get_syncs is present and type function`, function () { + expect(spec.get_syncs).to.exist.and.to.be.a('function') + }); + + it(`queue_metric is present and type function`, function () { + expect(spec.queue_metric).to.exist.and.to.be.a('function') + }); + + it(`send_metrics is present and type function`, function () { + expect(spec.send_metrics).to.exist.and.to.be.a('function') + }); + + it(`get_client_info is present and type function`, function () { + expect(spec.get_client_info).to.exist.and.to.be.a('function') + }); + + it(`get_viewability is present and type function`, function () { + expect(spec.get_viewability).to.exist.and.to.be.a('function') + }); + }); + + describe('get / store dbid', function() { + it('Should return true / undefined', function() { + expect(spec.store_dbid('12345')).to.be.true; + expect(spec.get_dbid()).to.be.a('string'); + }); + }) + + describe('get / store syncs', function() { + it('Should return true / array', function() { + expect(spec.store_syncs([{id: 1, uid: 'test'}])).to.be.true; + expect(spec.get_syncs()).to.be.a('object'); + }); + }) + + describe('queue / send metrics', function() { + it('Should return true', function() { + expect(spec.queue_metric({type: 'test'})).to.be.true; + expect(spec.queue_metric('string')).to.be.false; + expect(spec.send_metrics()).to.be.true; + }); + }) + + describe('get_viewability', function() { + it('Should return undefined', function() { + expect(spec.get_viewability()).to.equal(undefined); + }); + }) + + describe('get client info', function() { + it('Should return object', function() { + let client_info = spec.get_client_info() + expect(client_info).to.be.a('object'); + expect(client_info).to.have.all.keys('wiw', 'wih', 'saw', 'sah', 'scd', 'sw', 'sh', 'whl', 'wxo', 'wyo', 'wpr', 'is_bot', 'is_hid', 'vs'); + }); + + it('bot test should return boolean', function() { + let bot_test = new BotClientTests(); + expect(bot_test.doTests()).to.be.a('boolean'); + }); + }) + describe('isBidRequestValid', function() { - it('Should return true when sourceId and Host are set', function() { + it('Should return true when source_id and Host are set', function() { expect(spec.isBidRequestValid(bid)).to.be.true; }); - it('Should return false when host/sourceId is not set', function() { + it('Should return false when host/source_id is not set', function() { let moddedBid = Object.assign({}, bid); - delete moddedBid.params.sourceId; - delete moddedBid.params.host; - expect(spec.isBidRequestValid(bid)).to.be.false; + delete moddedBid.params.source_id; + expect(spec.isBidRequestValid(moddedBid)).to.be.false; + }); + + it('Should return true when viewability reporting is opted out', function() { + let moddedBid = Object.assign({}, bid); + moddedBid.params.vis_optout = true; + spec.isBidRequestValid(moddedBid); + expect(spec.db_obj.vis_optout).to.be.true; + }); + }) + + describe('getUserSyncs', function() { + it('Should return array of syncs', function() { + expect(spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [res_object], {gdprApplies: true, gdpr: 1, gdpr_consent: 'consent_string'}, {})).to.an('array'); + }); + }); + + describe('onSetTargeting', function() { + it('Should return undefined', function() { + expect(spec.onSetTargeting()).to.equal(undefined); + }); + }); + + describe('onBidWon', function() { + it('Should return undefined', function() { + let won_bid = {params: [{source_id: 1}], requestId: 1, adUnitCode: 'unit', auctionId: 1, size: '300x250', cpm: 10, adserverTargeting: {hb_pb: 10}, timeToRespond: 10, ttl: 10}; + expect(spec.onBidWon(won_bid)).to.equal(undefined); }); }); describe('buildRequests', function() { - let requests = spec.buildRequests([bid, bid2, nativeBid, videoBid], bidderRequest); + let request = spec.buildRequests([bid, bid2, nativeBid], bidderRequest); + + expect(request).to.exist; + it('Returns POST method', function() { + expect(request.method).to.exist; + expect(request.method).to.equal('POST'); + }); + + it('Returns valid URL', function() { + expect(request.url).to.exist; + expect(request.url).to.equal('https://7560.v5demo.datablocks.net/openrtb/?sid=7560'); + }); + it('Creates an array of request objects', function() { - expect(requests).to.be.an('array').that.is.not.empty; + expect(request.data.imp).to.be.an('array').that.is.not.empty; }); - requests.forEach(request => { - expect(request).to.exist; - it('Returns POST method', function() { - expect(request.method).to.exist; - expect(request.method).to.equal('POST'); - }); - it('Returns valid URL', function() { - expect(request.url).to.exist; - expect(request.url).to.equal('https://v5demo.datablocks.net/search/?sid=7560'); - }); + it('Should be a valid openRTB request', function() { + let data = request.data; - it('Should be a valid openRTB request', function() { - let data = request.data; - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('device', 'imp', 'site', 'id'); - expect(data.id).to.be.a('string'); - - let imps = data['imp']; - imps.forEach((imp, index) => { - let curBid = bidderRequest.bids[index]; - if (imp.banner) { - expect(imp).to.have.all.keys('banner', 'id', 'secure', 'tagid'); - expect(imp.banner).to.be.a('object'); - } else if (imp.native) { - expect(imp).to.have.all.keys('native', 'id', 'secure', 'tagid'); - expect(imp.native).to.have.all.keys('request'); - expect(imp.native.request).to.be.a('string'); - let native = JSON.parse(imp.native.request); - expect(native).to.be.a('object'); - } else if (imp.video) { - expect(imp).to.have.all.keys('video', 'id', 'secure', 'tagid'); - expect(imp.video).to.have.all.keys('w', 'h', 'minduration', 'maxduration') - } else { - expect(true).to.equal(false); - } - - expect(imp.id).to.be.a('string'); - expect(imp.id).to.equal(curBid.bidId); - expect(imp.tagid).to.be.a('string'); - expect(imp.tagid).to.equal(curBid.adUnitCode); - expect(imp.secure).to.equal(false); - }) - - expect(data.device.ip).to.equal('peer'); - }); - }) + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('device', 'imp', 'site', 'id'); + expect(data.id).to.be.a('string'); + expect(data.imp).to.be.a('array'); + expect(data.device.ip).to.equal('peer'); + + let imps = data['imp']; + imps.forEach((imp, index) => { + let curBid = bidderRequest.bids[index]; + if (imp.banner) { + expect(imp.banner).to.be.a('object'); + expect(imp).to.have.all.keys('banner', 'id', 'secure', 'tagid', 'placement_id', 'ortb2', 'floor'); + } else if (imp.native) { + expect(imp).to.have.all.keys('native', 'id', 'secure', 'tagid', 'placement_id', 'ortb2', 'floor'); + expect(imp.native).to.have.all.keys('request', 'ver'); + expect(imp.native.request).to.be.a('object'); + } else { + expect(true).to.equal(false); + } + + expect(imp.id).to.be.a('string'); + expect(imp.id).to.equal(curBid.bidId); + expect(imp.tagid).to.be.a('string'); + expect(imp.tagid).to.equal(curBid.adUnitCode); + expect(imp.secure).to.equal(false); + }) + }); it('Returns empty data if no valid requests are passed', function() { - let request = spec.buildRequests([]); - expect(request).to.be.an('array').that.is.empty; + let test_request = spec.buildRequests([]); + expect(test_request).to.be.an('array').that.is.empty; }); }); + describe('interpretResponse', function() { - let serverResponses = spec.interpretResponse(resObject, bidRequest); + let response = spec.interpretResponse(res_object, bid_request); + it('Returns an array of valid server responses if response object is valid', function() { - expect(serverResponses).to.be.an('array').that.is.not.empty; - for (let i = 0; i < serverResponses.length; i++) { - let dataItem = serverResponses[i]; - expect(Object.keys(dataItem)).to.include('cpm', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'mediaType', 'requestId'); - expect(dataItem.requestId).to.be.a('string'); - expect(dataItem.cpm).to.be.a('number'); - expect(dataItem.ttl).to.be.a('number'); - expect(dataItem.creativeId).to.be.a('string'); - expect(dataItem.netRevenue).to.be.a('boolean'); - expect(dataItem.currency).to.be.a('string'); - expect(dataItem.mediaType).to.be.a('string'); - - if (dataItem.mediaType == 'banner') { - expect(dataItem.ad).to.be.a('string'); - expect(dataItem.width).to.be.a('number'); - expect(dataItem.height).to.be.a('number'); - } else if (dataItem.mediaType == 'native') { - expect(dataItem.native.title).to.be.a('string'); - expect(dataItem.native.body).to.be.a('string'); - expect(dataItem.native.clickUrl).to.be.a('string'); - } else if (dataItem.mediaType == 'video') { - expect(dataItem.vastUrl).to.be.a('string'); - expect(dataItem.width).to.be.a('number'); - expect(dataItem.height).to.be.a('number'); + expect(response).to.be.an('array').that.is.not.empty; + + response.forEach(bid => { + expect(parseInt(bid.requestId)).to.be.a('number').greaterThan(0); + expect(bid.cpm).to.be.a('number'); + expect(bid.creativeId).to.be.a('string'); + expect(bid.currency).to.be.a('string'); + expect(bid.netRevenue).to.be.a('boolean'); + expect(bid.ttl).to.be.a('number'); + expect(bid.mediaType).to.be.a('string'); + + if (bid.mediaType == 'banner') { + expect(bid.width).to.be.a('number'); + expect(bid.height).to.be.a('number'); + expect(bid.ad).to.be.a('string'); + } else if (bid.mediaType == 'native') { + expect(bid.native).to.be.a('object'); } - } + }) + it('Returns an empty array if invalid response is passed', function() { serverResponses = spec.interpretResponse('invalid_response'); expect(serverResponses).to.be.an('array').that.is.empty; From 78a00fd21c5f29e37f02d2d30fa28ca8ffbaa9e8 Mon Sep 17 00:00:00 2001 From: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Date: Fri, 14 May 2021 08:33:09 -0400 Subject: [PATCH 174/303] Update to videoCache to include auction Id in vasttrack payload (#6757) --- src/videoCache.js | 1 + test/spec/videoCache_spec.js | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/videoCache.js b/src/videoCache.js index 9f1fd7e4117..9e378d90574 100644 --- a/src/videoCache.js +++ b/src/videoCache.js @@ -71,6 +71,7 @@ function toStorageRequest(bid) { if (config.getConfig('cache.vasttrack')) { payload.bidder = bid.bidder; payload.bidid = bid.requestId; + payload.aid = bid.auctionId; // function has a thisArg set to bidderRequest for accessing the auctionStart if (utils.isPlainObject(this) && this.hasOwnProperty('auctionStart')) { payload.timestamp = this.auctionStart; diff --git a/test/spec/videoCache_spec.js b/test/spec/videoCache_spec.js index 6bb214af8a0..554db3ebe4e 100644 --- a/test/spec/videoCache_spec.js +++ b/test/spec/videoCache_spec.js @@ -201,13 +201,15 @@ describe('The video cache', function () { ttl: 25, customCacheKey: customKey1, requestId: '12345abc', - bidder: 'appnexus' + bidder: 'appnexus', + auctionId: '1234-56789-abcde' }, { vastXml: vastXml2, ttl: 25, customCacheKey: customKey2, requestId: 'cba54321', - bidder: 'rubicon' + bidder: 'rubicon', + auctionId: '1234-56789-abcde' }]; store(bids, function () { }); @@ -222,6 +224,7 @@ describe('The video cache', function () { ttlseconds: 25, key: customKey1, bidid: '12345abc', + aid: '1234-56789-abcde', bidder: 'appnexus' }, { type: 'xml', @@ -229,6 +232,7 @@ describe('The video cache', function () { ttlseconds: 25, key: customKey2, bidid: 'cba54321', + aid: '1234-56789-abcde', bidder: 'rubicon' }] }; @@ -254,13 +258,15 @@ describe('The video cache', function () { ttl: 25, customCacheKey: customKey1, requestId: '12345abc', - bidder: 'appnexus' + bidder: 'appnexus', + auctionId: '1234-56789-abcde' }, { vastXml: vastXml2, ttl: 25, customCacheKey: customKey2, requestId: 'cba54321', - bidder: 'rubicon' + bidder: 'rubicon', + auctionId: '1234-56789-abcde' }]; store(bids, function () { }, getMockBidRequest()); @@ -276,6 +282,7 @@ describe('The video cache', function () { key: customKey1, bidid: '12345abc', bidder: 'appnexus', + aid: '1234-56789-abcde', timestamp: 1510852447530 }, { type: 'xml', @@ -284,6 +291,7 @@ describe('The video cache', function () { key: customKey2, bidid: 'cba54321', bidder: 'rubicon', + aid: '1234-56789-abcde', timestamp: 1510852447530 }] }; From 3c5ce3e8841a40ed311a404b46af3ddc36a866b4 Mon Sep 17 00:00:00 2001 From: Chris Huie <3444727+ChrisHuie@users.noreply.github.com> Date: Fri, 14 May 2021 06:37:26 -0700 Subject: [PATCH 175/303] Revert "Datablocks bid adapter: update adapter to conform to new bid server's format (#6696)" (#6763) This reverts commit 2b8f888dc11d727f49867309f37e492d65eaee96. --- modules/datablocksAnalyticsAdapter.js | 2 +- modules/datablocksBidAdapter.js | 862 ++++++------------ modules/datablocksBidAdapter.md | 30 +- .../spec/modules/datablocksBidAdapter_spec.js | 601 +++++------- 4 files changed, 507 insertions(+), 988 deletions(-) diff --git a/modules/datablocksAnalyticsAdapter.js b/modules/datablocksAnalyticsAdapter.js index 3e4e9e95a4f..5e977155284 100644 --- a/modules/datablocksAnalyticsAdapter.js +++ b/modules/datablocksAnalyticsAdapter.js @@ -16,4 +16,4 @@ adapterManager.registerAnalyticsAdapter({ code: 'datablocks' }); -export default datablocksAdapter; \ No newline at end of file +export default datablocksAdapter; diff --git a/modules/datablocksBidAdapter.js b/modules/datablocksBidAdapter.js index 038a521308d..b00a3eae659 100644 --- a/modules/datablocksBidAdapter.js +++ b/modules/datablocksBidAdapter.js @@ -1,634 +1,330 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; import * as utils from '../src/utils.js'; -import { BANNER, NATIVE } from '../src/mediaTypes.js'; -import { getStorageManager } from '../src/storageManager.js'; -import { ajax } from '../src/ajax.js'; -export const storage = getStorageManager(); - -const NATIVE_ID_MAP = {}; -const NATIVE_PARAMS = { +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +const NATIVE_MAP = { + 'body': 2, + 'body2': 10, + 'price': 6, + 'displayUrl': 11, + 'cta': 12 +}; +const NATIVE_IMAGE = [{ + id: 1, + required: 1, title: { - id: 1, - name: 'title' - }, - icon: { - id: 2, - type: 1, - name: 'img' - }, - image: { - id: 3, - type: 3, - name: 'img' - }, - body: { - id: 4, - name: 'data', - type: 2 - }, - sponsoredBy: { - id: 5, - name: 'data', - type: 1 - }, - cta: { - id: 6, - type: 12, - name: 'data' - }, - body2: { - id: 7, - name: 'data', - type: 10 - }, - rating: { - id: 8, - name: 'data', - type: 3 - }, - likes: { - id: 9, - name: 'data', - type: 4 - }, - downloads: { - id: 10, - name: 'data', - type: 5 - }, - displayUrl: { - id: 11, - name: 'data', + len: 140 + } +}, { + id: 2, + required: 1, + img: { type: 3 } +}, { + id: 3, + required: 1, + data: { type: 11 - }, - price: { - id: 12, - name: 'data', - type: 6 - }, - salePrice: { - id: 13, - name: 'data', - type: 7 - }, - address: { - id: 14, - name: 'data', - type: 9 - }, - phone: { - id: 15, - name: 'data', - type: 8 } -}; +}, { + id: 4, + required: 0, + data: { + type: 2 + } +}, { + id: 5, + required: 0, + img: { type: 1 } +}, { + id: 6, + required: 0, + data: { + type: 12 + } +}]; -Object.keys(NATIVE_PARAMS).forEach((key) => { - NATIVE_ID_MAP[NATIVE_PARAMS[key].id] = key; -}); +const VIDEO_PARAMS = ['mimes', 'minduration', 'maxduration', 'protocols', 'w', 'h', 'startdelay', + 'placement', 'linearity', 'skip', 'skipmin', 'skipafter', 'sequence', 'battr', 'maxextended', + 'minbitrate', 'maxbitrate', 'boxingallowed', 'playbackmethod', 'playbackend', 'delivery', + 'pos', 'companionad', 'api', 'companiontype', 'ext']; -// DEFINE THE PREBID BIDDER SPEC export const spec = { - supportedMediaTypes: [BANNER, NATIVE], + supportedMediaTypes: [BANNER, NATIVE, VIDEO], code: 'datablocks', - - // DATABLOCKS SCOPED OBJECT - db_obj: {metrics_host: 'prebid.datablocks.net', metrics: [], metrics_timer: null, metrics_queue_time: 1000, vis_optout: false, source_id: 0}, - - // STORE THE DATABLOCKS BUYERID IN STORAGE - store_dbid: function(dbid) { - let stored = false; - - // CREATE 1 YEAR EXPIRY DATE - let d = new Date(); - d.setTime(Date.now() + (365 * 24 * 60 * 60 * 1000)); - - // TRY TO STORE IN COOKIE - if (storage.cookiesAreEnabled) { - storage.setCookie('_db_dbid', dbid, d.toUTCString(), 'None', null); - stored = true; - } - - // TRY TO STORE IN LOCAL STORAGE - if (storage.localStorageIsEnabled) { - storage.setDataInLocalStorage('_db_dbid', dbid); - stored = true; - } - - return stored; - }, - - // FETCH DATABLOCKS BUYERID FROM STORAGE - get_dbid: function() { - let dbId = ''; - if (storage.cookiesAreEnabled) { - dbId = storage.getCookie('_db_dbid') || ''; - } - - if (!dbId && storage.localStorageIsEnabled) { - dbId = storage.getDataFromLocalStorage('_db_dbid') || ''; - } - return dbId; - }, - - // STORE SYNCS IN STORAGE - store_syncs: function(syncs) { - if (storage.localStorageIsEnabled) { - let syncObj = {}; - syncs.forEach(sync => { - syncObj[sync.id] = sync.uid; - }); - - // FETCH EXISTING SYNCS AND MERGE NEW INTO STORAGE - let storedSyncs = this.get_syncs(); - storage.setDataInLocalStorage('_db_syncs', JSON.stringify(Object.assign(storedSyncs, syncObj))); - - return true; - } - }, - - // GET SYNCS FROM STORAGE - get_syncs: function() { - if (storage.localStorageIsEnabled) { - let syncData = storage.getDataFromLocalStorage('_db_syncs'); - if (syncData) { - return JSON.parse(syncData); - } else { - return {}; - } - } else { - return {}; - } - }, - - // ADD METRIC DATA TO THE METRICS RESPONSE QUEUE - queue_metric: function(metric) { - if (typeof metric === 'object') { - // PUT METRICS IN THE QUEUE - this.db_obj.metrics.push(metric); - - // RESET PREVIOUS TIMER - if (this.db_obj.metrics_timer) { - clearTimeout(this.db_obj.metrics_timer); - } - - // SETUP THE TIMER TO FIRE BACK THE DATA - let scope = this; - this.db_obj.metrics_timer = setTimeout(function() { - scope.send_metrics(); - }, this.db_obj.metrics_queue_time); - - return true; - } else { - return false; - } - }, - - // POST CONSOLIDATED METRICS BACK TO SERVER - send_metrics: function() { - // POST TO SERVER - ajax(`https://${this.db_obj.metrics_host}/a/pb/`, null, JSON.stringify(this.db_obj.metrics), {method: 'POST', withCredentials: true}); - - // RESET THE QUEUE OF METRIC DATA - this.db_obj.metrics = []; - - return true; - }, - - // GET BASIC CLIENT INFORMATION - get_client_info: function () { - let botTest = new BotClientTests(); - let win = utils.getWindowTop(); - return { - 'wiw': win.innerWidth, - 'wih': win.innerHeight, - 'saw': screen ? screen.availWidth : null, - 'sah': screen ? screen.availHeight : null, - 'scd': screen ? screen.colorDepth : null, - 'sw': screen ? screen.width : null, - 'sh': screen ? screen.height : null, - 'whl': win.history.length, - 'wxo': win.pageXOffset, - 'wyo': win.pageYOffset, - 'wpr': win.devicePixelRatio, - 'is_bot': botTest.doTests(), - 'is_hid': win.document.hidden, - 'vs': win.document.visibilityState - }; - }, - - // LISTEN FOR GPT VIEWABILITY EVENTS - get_viewability: function(bid) { - // ONLY RUN ONCE IF PUBLISHER HAS OPTED IN - if (!this.db_obj.vis_optout && !this.db_obj.vis_run) { - this.db_obj.vis_run = true; - - // ADD GPT EVENT LISTENERS - let scope = this; - if (utils.isGptPubadsDefined()) { - if (typeof window['googletag'].pubads().addEventListener == 'function') { - window['googletag'].pubads().addEventListener('impressionViewable', function(event) { - scope.queue_metric({type: 'slot_view', source_id: scope.db_obj.source_id, auction_id: bid.auctionId, div_id: event.slot.getSlotElementId(), slot_id: event.slot.getSlotId().getAdUnitPath()}); - }); - window['googletag'].pubads().addEventListener('slotRenderEnded', function(event) { - scope.queue_metric({type: 'slot_render', source_id: scope.db_obj.source_id, auction_id: bid.auctionId, div_id: event.slot.getSlotElementId(), slot_id: event.slot.getSlotId().getAdUnitPath()}); - }) - } - } - } - }, - - // VALIDATE THE BID REQUEST isBidRequestValid: function(bid) { - // SET GLOBAL VARS FROM BIDDER CONFIG - this.db_obj.source_id = bid.params.source_id; - if (bid.params.vis_optout) { - this.db_obj.vis_optout = true; - } - - return !!(bid.params.source_id && bid.mediaTypes && (bid.mediaTypes.banner || bid.mediaTypes.native)); + return !!(bid.params.host && bid.params.sourceId && + bid.mediaTypes && (bid.mediaTypes.banner || bid.mediaTypes.native || bid.mediaTypes.video)); }, + buildRequests: function(validBidRequests, bidderRequest) { + if (!validBidRequests.length) { return []; } - // GENERATE THE RTB REQUEST - buildRequests: function(validRequests, bidderRequest) { - // RETURN EMPTY IF THERE ARE NO VALID REQUESTS - if (!validRequests.length) { - return []; - } + let imps = {}; + let site = {}; + let device = {}; + let refurl = utils.parseUrl(bidderRequest.referrer); + let requests = []; - // CONVERT PREBID NATIVE REQUEST OBJ INTO RTB OBJ - function createNativeRequest(bid) { - const assets = []; - if (bid.nativeParams) { - Object.keys(bid.nativeParams).forEach((key) => { - if (NATIVE_PARAMS[key]) { - const {name, type, id} = NATIVE_PARAMS[key]; - const assetObj = type ? {type} : {}; - let {len, sizes, required, aspect_ratios: aRatios} = bid.nativeParams[key]; - if (len) { - assetObj.len = len; - } - if (aRatios && aRatios[0]) { - aRatios = aRatios[0]; - let wmin = aRatios.min_width || 0; - let hmin = aRatios.ratio_height * wmin / aRatios.ratio_width | 0; - assetObj.wmin = wmin; - assetObj.hmin = hmin; - } - if (sizes && sizes.length) { - sizes = [].concat(...sizes); - assetObj.w = sizes[0]; - assetObj.h = sizes[1]; - } - const asset = {required: required ? 1 : 0, id}; - asset[name] = assetObj; - assets.push(asset); - } - }); - } - return { - ver: '1.2', - request: { - assets: assets, - context: 1, - plcmttype: 1, - ver: '1.2' - } - } - } - let imps = []; - // ITERATE THE VALID REQUESTS AND GENERATE IMP OBJECT - validRequests.forEach(bidRequest => { - // BUILD THE IMP OBJECT + validBidRequests.forEach(bidRequest => { let imp = { id: bidRequest.bidId, - tagid: bidRequest.params.tagid || bidRequest.adUnitCode, - placement_id: bidRequest.params.placement_id || 0, - secure: window.location.protocol == 'https:', - ortb2: utils.deepAccess(bidRequest, `ortb2Imp`) || {}, - floor: {} + tagid: bidRequest.adUnitCode, + secure: window.location.protocol == 'https:' } - // CHECK FOR FLOORS - if (typeof bidRequest.getFloor === 'function') { - imp.floor = bidRequest.getFloor({ - currency: 'USD', - mediaType: '*', - size: '*' - }); - } - - // BUILD THE SIZES if (utils.deepAccess(bidRequest, `mediaTypes.banner`)) { - let sizes = utils.getAdUnitSizes(bidRequest); - if (sizes.length) { + let sizes = bidRequest.mediaTypes.banner.sizes; + if (sizes.length == 1) { imp.banner = { w: sizes[0][0], - h: sizes[0][1], + h: sizes[0][1] + } + } else if (sizes.length > 1) { + imp.banner = { format: sizes.map(size => ({ w: size[0], h: size[1] })) }; + } else { + return; + } + } else if (utils.deepAccess(bidRequest, 'mediaTypes.native')) { + let nativeImp = bidRequest.mediaTypes.native; + + if (nativeImp.type) { + let nativeAssets = []; + switch (nativeImp.type) { + case 'image': + nativeAssets = NATIVE_IMAGE; + break; + default: + return; + } + imp.native = JSON.stringify({ assets: nativeAssets }); + } else { + let nativeAssets = []; + let nativeKeys = Object.keys(nativeImp); + nativeKeys.forEach((nativeKey, index) => { + let required = !!nativeImp[nativeKey].required; + let assetId = index + 1; + switch (nativeKey) { + case 'title': + nativeAssets.push({ + id: assetId, + required: required, + title: { + len: nativeImp[nativeKey].len || 140 + } + }); + break; + case 'body': // desc + case 'body2': // desc2 + case 'price': + case 'display_url': + let data = { + id: assetId, + required: required, + data: { + type: NATIVE_MAP[nativeKey] + } + } + if (nativeImp[nativeKey].data && nativeImp[nativeKey].data.len) { data.data.len = nativeImp[nativeKey].data.len; } + + nativeAssets.push(data); + break; + case 'image': + if (nativeImp[nativeKey].sizes && nativeImp[nativeKey].sizes.length) { + nativeAssets.push({ + id: assetId, + required: required, + image: { + type: 3, + w: nativeImp[nativeKey].sizes[0], + h: nativeImp[nativeKey].sizes[1] + } + }) + } + } + }); + imp.native = { + request: JSON.stringify({native: {assets: nativeAssets}}) + }; + } + } else if (utils.deepAccess(bidRequest, 'mediaTypes.video')) { + let video = bidRequest.mediaTypes.video; + let sizes = video.playerSize || bidRequest.sizes || []; + if (sizes.length && Array.isArray(sizes[0])) { + imp.video = { + w: sizes[0][0], + h: sizes[0][1] + }; + } else if (sizes.length == 2 && !Array.isArray(sizes[0])) { + imp.video = { + w: sizes[0], + h: sizes[1] + }; + } else { + return; + } + + if (video.durationRangeSec) { + if (Array.isArray(video.durationRangeSec)) { + if (video.durationRangeSec.length == 1) { + imp.video.maxduration = video.durationRangeSec[0]; + } else if (video.durationRangeSec.length == 2) { + imp.video.minduration = video.durationRangeSec[0]; + imp.video.maxduration = video.durationRangeSec[1]; + } + } else { + imp.video.maxduration = video.durationRangeSec; + } + } - // ADD TO THE LIST OF IMP REQUESTS - imps.push(imp); + if (bidRequest.params.video) { + Object.keys(bidRequest.params.video).forEach(k => { + if (VIDEO_PARAMS.indexOf(k) > -1) { + imp.video[k] = bidRequest.params.video[k]; + } + }) } - } else if (utils.deepAccess(bidRequest, `mediaTypes.native`)) { - // ADD TO THE LIST OF IMP REQUESTS - imp.native = createNativeRequest(bidRequest); - imps.push(imp); } + let host = bidRequest.params.host; + let sourceId = bidRequest.params.sourceId; + imps[host] = imps[host] || {}; + let hostImp = imps[host][sourceId] = imps[host][sourceId] || { imps: [] }; + hostImp.imps.push(imp); + hostImp.subid = hostImp.imps.subid || bidRequest.params.subid || 'blank'; + hostImp.path = 'search'; + hostImp.idParam = 'sid'; + hostImp.protocol = '//'; }); - // RETURN EMPTY IF THERE WERE NO PROPER ADUNIT REQUESTS TO BE MADE - if (!imps.length) { - return []; - } - - // GENERATE SITE OBJECT - let site = { - domain: window.location.host, - page: bidderRequest.refererInfo.referer, - schain: validRequests[0].schain || {}, - ext: { - p_domain: config.getConfig('publisherDomain'), - rt: bidderRequest.refererInfo.reachedTop, - frames: bidderRequest.refererInfo.numIframes, - stack: bidderRequest.refererInfo.stack, - timeout: config.getConfig('bidderTimeout') - }, - } - - // ADD REF URL IF FOUND + // Generate Site obj + site.domain = refurl.hostname; + site.page = refurl.protocol + '://' + refurl.hostname + refurl.pathname; if (self === top && document.referrer) { site.ref = document.referrer; } - - // ADD META KEYWORDS IF FOUND let keywords = document.getElementsByTagName('meta')['keywords']; if (keywords && keywords.content) { site.keywords = keywords.content; } - // GENERATE DEVICE OBJECT - let device = { - ip: 'peer', - ua: window.navigator.userAgent, - js: 1, - language: ((navigator.language || navigator.userLanguage || '').split('-'))[0] || 'en', - buyerid: this.get_dbid() || 0, - ext: { - pb_eids: validRequests[0].userIdAsEids || {}, - syncs: this.get_syncs() || {}, - coppa: config.getConfig('coppa') || 0, - gdpr: bidderRequest.gdprConsent || {}, - usp: bidderRequest.uspConsent || {}, - client_info: this.get_client_info(), - ortb2: config.getConfig('ortb2') || {} - } - }; - - let sourceId = validRequests[0].params.source_id || 0; - let host = validRequests[0].params.host || 'prebid.datablocks.net'; - - // RETURN WITH THE REQUEST AND PAYLOAD - return { - method: 'POST', - url: `https://${sourceId}.${host}/openrtb/?sid=${sourceId}`, - data: { - id: bidderRequest.auctionId, - imp: imps, - site: site, - device: device - }, - options: { - withCredentials: true - } - }; - }, - - // INITIATE USER SYNCING - getUserSyncs: function(options, rtbResponse, gdprConsent) { - const syncs = []; - let bidResponse = rtbResponse[0].body; - let scope = this; - - // LISTEN FOR SYNC DATA FROM IFRAME TYPE SYNC - window.addEventListener('message', function (event) { - if (event.data.sentinel && event.data.sentinel === 'dblks_syncData') { - // STORE FOUND SYNCS - if (event.data.syncs) { - scope.store_syncs(event.data.syncs); + // Generate Device obj. + device.ip = 'peer'; + device.ua = window.navigator.userAgent; + device.js = 1; + device.language = ((navigator.language || navigator.userLanguage || '').split('-'))[0] || 'en'; + + RtbRequest(device, site, imps).forEach(formatted => { + requests.push({ + method: 'POST', + url: formatted.url, + data: formatted.body, + options: { + withCredentials: false } - } + }) }); - - // POPULATE GDPR INFORMATION - let gdprData = { - gdpr: 0, - gdprConsent: '' - } - if (typeof gdprConsent === 'object') { - if (typeof gdprConsent.gdprApplies === 'boolean') { - gdprData.gdpr = Number(gdprConsent.gdprApplies); - gdprData.gdprConsent = gdprConsent.consentString; - } else { - gdprData.gdprConsent = gdprConsent.consentString; - } - } - - // EXTRACT BUYERID COOKIE VALUE FROM BID RESPONSE AND PUT INTO STORAGE - let dbBuyerId = this.get_dbid() || ''; - if (bidResponse.ext && bidResponse.ext.buyerid) { - dbBuyerId = bidResponse.ext.buyerid; - this.store_dbid(dbBuyerId); - } - - // EXTRACT USERSYNCS FROM BID RESPONSE - if (bidResponse.ext && bidResponse.ext.syncs) { - bidResponse.ext.syncs.forEach(sync => { - if (checkValid(sync)) { - syncs.push(addParams(sync)); - } + return requests; + + function RtbRequest(device, site, imps) { + let collection = []; + Object.keys(imps).forEach(host => { + let sourceIds = imps[host]; + Object.keys(sourceIds).forEach(sourceId => { + let impObj = sourceIds[sourceId]; + collection.push({ + url: `https://${host}/${impObj.path}/?${impObj.idParam}=${sourceId}`, + body: { + id: bidderRequest.auctionId, + imp: impObj.imps, + site: Object.assign({ id: impObj.subid || 'blank' }, site), + device: Object.assign({}, device) + } + }) + }) }) - } - - // APPEND PARAMS TO SYNC URL - function addParams(sync) { - // PARSE THE URL - let url = new URL(sync.url); - let urlParams = Object.assign({}, Object.fromEntries(url.searchParams)); - - // APPLY EXTRA VARS - urlParams.gdpr = gdprData.gdpr; - urlParams.gdprConsent = gdprData.gdprConsent; - urlParams.bidid = bidResponse.bidid; - urlParams.id = bidResponse.id; - urlParams.uid = dbBuyerId; - - // REBUILD URL - sync.url = `${url.origin}${url.pathname}?${Object.keys(urlParams).map(key => key + '=' + encodeURIComponent(urlParams[key])).join('&')}`; - // RETURN THE REBUILT URL - return sync; + return collection; } - - // ENSURE THAT THE SYNC TYPE IS VALID AND HAS PERMISSION - function checkValid(sync) { - if (!sync.type || !sync.url) { - return false; - } - switch (sync.type) { - case 'iframe': - return options.iframeEnabled; - case 'image': - return options.pixelEnabled; - default: - return false; - } - } - return syncs; - }, - - // DATABLOCKS WON THE AUCTION - REPORT SUCCESS - onBidWon: function(bid) { - this.queue_metric({type: 'bid_won', source_id: bid.params[0].source_id, req_id: bid.requestId, slot_id: bid.adUnitCode, auction_id: bid.auctionId, size: bid.size, cpm: bid.cpm, pb: bid.adserverTargeting.hb_pb, rt: bid.timeToRespond, ttl: bid.ttl}); }, - - // TARGETING HAS BEEN SET - onSetTargeting: function(bid) { - // LISTEN FOR VIEWABILITY EVENTS - this.get_viewability(bid); - }, - - // PARSE THE RTB RESPONSE AND RETURN FINAL RESULTS - interpretResponse: function(rtbResponse, bidRequest) { - // CONVERT NATIVE RTB RESPONSE INTO PREBID RESPONSE - function parseNative(native) { - const {assets, link, imptrackers, jstracker} = native; - const result = { - clickUrl: link.url, - clickTrackers: link.clicktrackers || [], - impressionTrackers: imptrackers || [], - javascriptTrackers: jstracker ? [jstracker] : [] - }; - - (assets || []).forEach((asset) => { - const {id, img, data, title} = asset; - const key = NATIVE_ID_MAP[id]; - if (key) { - if (!utils.isEmpty(title)) { - result.title = title.text - } else if (!utils.isEmpty(img)) { - result[key] = { - url: img.url, - height: img.h, - width: img.w - } - } else if (!utils.isEmpty(data)) { - result[key] = data.value; - } - } - }); - - return result; + interpretResponse: function(serverResponse, bidRequest) { + if (!serverResponse || !serverResponse.body || !serverResponse.body.seatbid) { + return []; } - - let bids = []; - let resBids = utils.deepAccess(rtbResponse, 'body.seatbid') || []; - resBids.forEach(bid => { - let resultItem = {requestId: bid.id, cpm: bid.price, creativeId: bid.crid, currency: bid.currency || 'USD', netRevenue: true, ttl: bid.ttl || 360}; - - let mediaType = utils.deepAccess(bid, 'ext.mtype') || ''; - switch (mediaType) { - case 'banner': - bids.push(Object.assign({}, resultItem, {mediaType: BANNER, width: bid.w, height: bid.h, ad: bid.adm})); - break; - - case 'native': - let nativeResult = JSON.parse(bid.adm); - bids.push(Object.assign({}, resultItem, {mediaType: NATIVE, native: parseNative(nativeResult.native)})); - break; - - default: + let body = serverResponse.body; + + let bids = body.seatbid + .map(seatbid => seatbid.bid) + .reduce((memo, bid) => memo.concat(bid), []); + let req = bidRequest.data; + let reqImps = req.imp; + + return bids.map(rtbBid => { + let imp; + for (let i in reqImps) { + let testImp = reqImps[i] + if (testImp.id == rtbBid.impid) { + imp = testImp; break; - } - }) - - return bids; - } -}; - -// DETECT BOTS -export class BotClientTests { - constructor() { - this.tests = { - headless_chrome: function() { - if (self.navigator) { - if (self.navigator.webdriver) { - return true; - } } + } + let br = { + requestId: rtbBid.impid, + cpm: rtbBid.price, + creativeId: rtbBid.crid, + currency: rtbBid.currency || 'USD', + netRevenue: true, + ttl: 360 + }; + if (!imp) { + return br; + } else if (imp.banner) { + br.mediaType = BANNER; + br.width = rtbBid.w; + br.height = rtbBid.h; + br.ad = rtbBid.adm; + } else if (imp.native) { + br.mediaType = NATIVE; + + let reverseNativeMap = {}; + let nativeKeys = Object.keys(NATIVE_MAP); + nativeKeys.forEach(k => { + reverseNativeMap[NATIVE_MAP[k]] = k; + }); - return false; - }, - user_agent: function() { - try { - var re = new RegExp('(googlebot\/|bot|Googlebot-Mobile|Googlebot-Image|Google favicon|Mediapartners-Google|bingbot|slurp|java|wget|curl|Commons-HttpClient|Python-urllib|libwww|httpunit|nutch|phpcrawl|msnbot|jyxobot|FAST-WebCrawler|FAST Enterprise Crawler|biglotron|teoma|convera|seekbot|gigablast|exabot|ngbot|ia_archiver|GingerCrawler|webmon |httrack|webcrawler|grub.org|UsineNouvelleCrawler|antibot|netresearchserver|speedy|fluffy|bibnum.bnf|findlink|msrbot|panscient|yacybot|AISearchBot|IOI|ips-agent|tagoobot|MJ12bot|dotbot|woriobot|yanga|buzzbot|mlbot|yandexbot|purebot|Linguee Bot|Voyager|CyberPatrol|voilabot|baiduspider|citeseerxbot|spbot|twengabot|postrank|turnitinbot|scribdbot|page2rss|sitebot|linkdex|Adidxbot|blekkobot|ezooms|dotbot|Mail.RU_Bot|discobot|heritrix|findthatfile|europarchive.org|NerdByNature.Bot|sistrix crawler|ahrefsbot|Aboundex|domaincrawler|wbsearchbot|summify|ccbot|edisterbot|seznambot|ec2linkfinder|gslfbot|aihitbot|intelium_bot|facebookexternalhit|yeti|RetrevoPageAnalyzer|lb-spider|sogou|lssbot|careerbot|wotbox|wocbot|ichiro|DuckDuckBot|lssrocketcrawler|drupact|webcompanycrawler|acoonbot|openindexspider|gnam gnam spider|web-archive-net.com.bot|backlinkcrawler|coccoc|integromedb|content crawler spider|toplistbot|seokicks-robot|it2media-domain-crawler|ip-web-crawler.com|siteexplorer.info|elisabot|proximic|changedetection|blexbot|arabot|WeSEE:Search|niki-bot|CrystalSemanticsBot|rogerbot|360Spider|psbot|InterfaxScanBot|Lipperhey SEO Service|CC Metadata Scaper|g00g1e.net|GrapeshotCrawler|urlappendbot|brainobot|fr-crawler|binlar|SimpleCrawler|Livelapbot|Twitterbot|cXensebot|smtbot|bnf.fr_bot|A6-Indexer|ADmantX|Facebot|Twitterbot|OrangeBot|memorybot|AdvBot|MegaIndex|SemanticScholarBot|ltx71|nerdybot|xovibot|BUbiNG|Qwantify|archive.org_bot|Applebot|TweetmemeBot|crawler4j|findxbot|SemrushBot|yoozBot|lipperhey|y!j-asr|Domain Re-Animator Bot|AddThis)', 'i'); - if (re.test(navigator.userAgent)) { - return true; - } - return false; - } catch (e) { - return false; - } - }, - - selenium: function () { - let response = false; - - if (window && document) { - let results = [ - 'webdriver' in window, - '_Selenium_IDE_Recorder' in window, - 'callSelenium' in window, - '_selenium' in window, - '__webdriver_script_fn' in document, - '__driver_evaluate' in document, - '__webdriver_evaluate' in document, - '__selenium_evaluate' in document, - '__fxdriver_evaluate' in document, - '__driver_unwrapped' in document, - '__webdriver_unwrapped' in document, - '__selenium_unwrapped' in document, - '__fxdriver_unwrapped' in document, - '__webdriver_script_func' in document, - document.documentElement.getAttribute('selenium') !== null, - document.documentElement.getAttribute('webdriver') !== null, - document.documentElement.getAttribute('driver') !== null - ]; - - results.forEach(result => { - if (result === true) { - response = true; - } + let idMap = {}; + let nativeReq = JSON.parse(imp.native.request); + if (nativeReq.native && nativeReq.native.assets) { + nativeReq.native.assets.forEach(asset => { + if (asset.data) { idMap[asset.id] = reverseNativeMap[asset.data.type]; } }) } - return response; - }, - } - } - - doTests() { - let response = false; - for (const [, t] of Object.entries(this.tests)) { - if (t() === true) { - response = true; + const nativeResponse = JSON.parse(rtbBid.adm); + const { assets, link, imptrackers, jstrackers } = nativeResponse.native; + const result = { + clickUrl: link.url, + clickTrackers: link.clicktrackers || undefined, + impressionTrackers: imptrackers || undefined, + javascriptTrackers: jstrackers ? [jstrackers] : undefined + }; + assets.forEach(asset => { + if (asset.title) { + result.title = asset.title.text; + } else if (asset.img) { + result.image = asset.img.url; + } else if (idMap[asset.id]) { + result[idMap[asset.id]] = asset.data.value; + } + }) + br.native = result; + } else if (imp.video) { + br.mediaType = VIDEO; + br.width = rtbBid.w; + br.height = rtbBid.h; + if (rtbBid.adm) { br.vastXml = rtbBid.adm; } else if (rtbBid.nurl) { br.vastUrl = rtbBid.nurl; } } - } - return response; + return br; + }); } -} -// INIT OUR BIDDER WITH PREBID +}; registerBidder(spec); diff --git a/modules/datablocksBidAdapter.md b/modules/datablocksBidAdapter.md index 2730443d72d..e30cd361974 100644 --- a/modules/datablocksBidAdapter.md +++ b/modules/datablocksBidAdapter.md @@ -8,8 +8,8 @@ Maintainer: support@datablocks.net # Description -Connects to Datablocks Exchange -Banner and Native +Connects to Datablocks Version 5 Platform +Banner Native and Video # Test Parameters @@ -27,13 +27,12 @@ Banner and Native { bidder: 'datablocks', params: { - source_id: 12345, + sourceId: 12345, host: 'prebid.datablocks.net' } } ] - }, - { + }, { code: 'native-div', mediaTypes : { native: { @@ -45,9 +44,28 @@ Banner and Native { bidder: 'datablocks', params: { - source_id: 12345, + sourceId: 12345, host: 'prebid.datablocks.net' } + }, { + code: 'video-div', + mediaTypes : { + video: { + playerSize:[500,400], + durationRangeSec:[15,30], + context: "linear" + } + }, + bids: [ + { + bidder: 'datablocks', + params: { + sourceId: 12345, + host: 'prebid.datablocks.net', + video: { + mimes:["video/flv"] + } + } } ] } diff --git a/test/spec/modules/datablocksBidAdapter_spec.js b/test/spec/modules/datablocksBidAdapter_spec.js index 147000f2363..18b8aac7371 100644 --- a/test/spec/modules/datablocksBidAdapter_spec.js +++ b/test/spec/modules/datablocksBidAdapter_spec.js @@ -1,15 +1,12 @@ import { expect } from 'chai'; import { spec } from '../../../modules/datablocksBidAdapter.js'; -import { BotClientTests } from '../../../modules/datablocksBidAdapter.js'; -import { getStorageManager } from '../../../src/storageManager.js'; -export let storage = getStorageManager(); -const bid = { +let bid = { bidId: '2dd581a2b6281d', bidder: 'datablocks', bidderRequestId: '145e1d6a7837c9', params: { - source_id: 7560, + sourceId: 7560, host: 'v5demo.datablocks.net' }, adUnitCode: '/19968336/header-bid-tag-0', @@ -27,12 +24,12 @@ const bid = { transactionId: '1ccbee15-f6f6-46ce-8998-58fe5542e8e1' }; -const bid2 = { +let bid2 = { bidId: '2dd581a2b624324g', bidder: 'datablocks', bidderRequestId: '145e1d6a7837543', params: { - source_id: 7560, + sourceId: 7560, host: 'v5demo.datablocks.net' }, adUnitCode: '/19968336/header-bid-tag-0', @@ -46,7 +43,7 @@ const bid2 = { transactionId: '1ccbee15-f6f6-46ce-8998-58fe55425432' }; -const nativeBid = { +let nativeBid = { adUnitCode: '/19968336/header-bid-tag-0', auctionId: '160c78a4-f808-410f-b682-d8728f3a79ee', bidId: '332045ee374a99', @@ -81,18 +78,41 @@ const nativeBid = { } }, params: { - source_id: 7560, + sourceId: 7560, host: 'v5demo.datablocks.net' }, transactionId: '0a4e9788-4def-4b94-bc25-564d7cac99f6' } +let videoBid = { + adUnitCode: '/19968336/header-bid-tag-0', + auctionId: '160c78a4-f808-410f-b682-d8728f3a79e1', + bidId: '332045ee374b99', + bidder: 'datablocks', + bidderRequestId: '15d9012765e36d', + mediaTypes: { + video: { + context: 'instream', + playerSize: [501, 400], + durationRangeSec: [15, 60] + } + }, + params: { + sourceId: 7560, + host: 'v5demo.datablocks.net', + video: { + minduration: 14 + } + }, + transactionId: '0a4e9788-4def-4b94-bc25-564d7cac99f7' +} + const bidderRequest = { auctionId: '8bfef1be-d3ac-4d18-8859-754c7b4cf017', auctionStart: Date.now(), biddeCode: 'datablocks', bidderRequestId: '10c47a5fc3c41', - bids: [bid, bid2, nativeBid], + bids: [bid, bid2, nativeBid, videoBid], refererInfo: { numIframes: 0, reachedTop: true, @@ -103,423 +123,208 @@ const bidderRequest = { timeout: 10000 }; -const res_object = { +let resObject = { body: { - 'id': '10c47a5fc3c41', - 'bidid': '217868445-30021-19053-0', - 'seatbid': [ - { - 'id': '22621593137287', - 'impid': '1', - 'adm': 'John is great', - 'adomain': ['medianet.com'], - 'price': 0.430000, - 'cid': '2524568', - 'adid': '0', - 'crid': '0', - 'cat': [], - 'w': 300, - 'h': 250, - 'ext': { - 'type': 'CPM', - 'mtype': 'banner' - } - }, - { - 'id': '22645215457415', - 'impid': '2', - 'adm': 'john is the best', - 'adomain': ['td.com'], - 'price': 0.580000, - 'cid': '2524574', - 'adid': '0', - 'crid': '0', - 'cat': [], - 'w': 728, - 'h': 90, - 'ext': { - 'type': 'CPM', - 'mtype': 'banner' - } - }, - - { - 'id': '22645215457416', - 'impid': '3', - 'adm': '{"native":{"ver":"1.2","assets":[{"id":1,"required":1,"title":{"text":"John is amazing"}},{"id":5,"required":1,"data":{"value":"Sponsored by John"}},{"id":3,"required":1,"img":{"url":"https://example.image.com/", "h":"360", "w":"360"}}],"link":{"url":"https://click.example.com/c/264597/?fcid=29699699045816"},"imptrackers":["https://impression.example.com/i/264597/?fcid=29699699045816"]}}', - 'adomain': ['td.com'], - 'price': 10.00, - 'cid': '2524574', - 'adid': '0', - 'crid': '0', - 'cat': [], - 'ext': { - 'type': 'CPM', - 'mtype': 'native' - } - } - ], - 'cur': 'USD', - 'ext': { - 'version': '1.2.93', - 'buyerid': '1234567', - 'syncs': [ - { - 'type': 'iframe', - 'url': 'https://s.0cf.io' - }, - { - 'type': 'image', - 'url': 'https://us.dblks.net/set_uid/' - } - ] - } + id: '10c47a5fc3c41', + bidid: '166895245-28-11347-1', + seatbid: [{ + seat: '7560', + bid: [{ + id: '1090738570', + impid: '2966b257c81d27', + price: 24.000000, + adm: 'RON', + cid: '55', + adid: '177654', + crid: '177656', + cat: [], + api: [], + w: 300, + h: 250 + }, { + id: '1090738571', + impid: '2966b257c81d28', + price: 24.000000, + adm: 'RON', + cid: '55', + adid: '177654', + crid: '177656', + cat: [], + api: [], + w: 728, + h: 90 + }, { + id: '1090738570', + impid: '15d9012765e36c', + price: 24.000000, + adm: '{"native":{"ver":"1.2","assets":[{"id":1,"required":1,"title":{"text":"Example Title"}},{"id":2,"required":1,"data":{"value":"Example Body"}},{"id":3,"required":1,"img":{"url":"https://example.image.com/"}}],"link":{"url":"https://click.example.com/c/264597/?fcid=29699699045816"},"imptrackers":["https://impression.example.com/i/264597/?fcid=29699699045816"]}}', + cid: '132145', + adid: '154321', + crid: '177432', + cat: [], + api: [] + }, { + id: '1090738575', + impid: '15d9012765e36f', + price: 25.000000, + cid: '12345', + adid: '12345', + crid: '123456', + nurl: 'https://click.v5demo.datablocks.net/m//?fcid=435235435432', + cat: [], + api: [], + w: 500, + h: 400 + }] + }], + cur: 'USD', + ext: {} } -} - -let bid_request = { +}; +let bidRequest = { method: 'POST', - url: 'https://prebid.datablocks.net/openrtb/?sid=2523014', + url: 'https://v5demo.datablocks.net/search/?sid=7560', options: { - withCredentials: true + withCredentials: false }, data: { - 'id': 'c09c6e47-8bdb-4884-a46d-93165322b368', - 'imp': [{ - 'id': '1', - 'tagid': '/19968336/header-bid-tag-0', - 'placement_id': 0, - 'secure': true, - 'banner': { - 'w': 300, - 'h': 250, - 'format': [{ - 'w': 300, - 'h': 250 - }, { - 'w': 300, - 'h': 600 - }] - } - }, { - 'id': '2', - 'tagid': '/19968336/header-bid-tag-1', - 'placement_id': 12345, - 'secure': true, - 'banner': { - 'w': 729, - 'h': 90, - 'format': [{ - 'w': 729, - 'h': 90 - }, { - 'w': 970, - 'h': 250 - }] - } - }, { - 'id': '3', - 'tagid': '/19968336/prebid_multiformat_test', - 'placement_id': 0, - 'secure': true, - 'native': { - 'ver': '1.2', - 'request': { - 'assets': [{ - 'required': 1, - 'id': 1, - 'title': {} - }, { - 'required': 1, - 'id': 3, - 'img': { - 'type': 3 - } - }, { - 'required': 1, - 'id': 5, - 'data': { - 'type': 1 - } - }], - 'context': 1, - 'plcmttype': 1, - 'ver': '1.2' - } - } - }], - 'site': { - 'domain': 'test.datablocks.net', - 'page': 'https://test.datablocks.net/index.html', - 'schain': {}, - 'ext': { - 'p_domain': 'https://test.datablocks.net', - 'rt': true, - 'frames': 0, - 'stack': ['https://test.datablocks.net/index.html'], - 'timeout': 3000 - }, - 'keywords': 'HTML, CSS, JavaScript' - }, - 'device': { - 'ip': 'peer', - 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36', - 'js': 1, - 'language': 'en', - 'buyerid': '1234567', - 'ext': { - 'pb_eids': [{ - 'source': 'criteo.com', - 'uids': [{ - 'id': 'test', - 'atype': 1 - }] - }], - 'syncs': { - '1000': 'db_4044853', - '1001': true - }, - 'coppa': 0, - 'gdpr': {}, - 'usp': {}, - 'client_info': { - 'wiw': 2560, - 'wih': 1281, - 'saw': 2560, - 'sah': 1417, - 'scd': 24, - 'sw': 2560, - 'sh': 1440, - 'whl': 4, - 'wxo': 0, - 'wyo': 0, - 'wpr': 2, - 'is_bot': false, - 'is_hid': false, - 'vs': 'hidden' - }, - 'fpd': {} - } - } + device: { + ip: 'peer', + ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) Ap…ML, like Gecko) Chrome/73.0.3683.86 Safari/537.36', + js: 1, + language: 'en' + }, + id: '10c47a5fc3c41', + imp: [{ + banner: { w: 300, h: 250 }, + id: '2966b257c81d27', + secure: false, + tagid: '/19968336/header-bid-tag-0' + }, { + banner: { w: 728, h: 90 }, + id: '2966b257c81d28', + secure: false, + tagid: '/19968336/header-bid-tag-0' + }, { + id: '15d9012765e36c', + native: {request: '{"native":{"assets":[{"id":"1","required":true,"title":{"len":140}},{"id":"2","required":true,"data":{"type":2}},{"id":"3","img":{"w":728,"h":90,"type":3}}]}}'}, + secure: false, + tagid: '/19968336/header-bid-tag-0' + }, { + id: '15d9012765e36f', + video: {w: 500, h: 400, minduration: 15, maxduration: 60}, + secure: false, + tagid: '/19968336/header-bid-tag-0' + }], + site: { + domain: '', + id: 'blank', + page: 'https://v5demo.datablocks.net/test' + } } } describe('DatablocksAdapter', function() { - describe('All needed functions are available', function() { - it(`isBidRequestValid is present and type function`, function () { - expect(spec.isBidRequestValid).to.exist.and.to.be.a('function') - }); - - it(`buildRequests is present and type function`, function () { - expect(spec.buildRequests).to.exist.and.to.be.a('function') - }); - - it(`getUserSyncs is present and type function`, function () { - expect(spec.getUserSyncs).to.exist.and.to.be.a('function') - }); - - it(`onBidWon is present and type function`, function () { - expect(spec.onBidWon).to.exist.and.to.be.a('function') - }); - - it(`onSetTargeting is present and type function`, function () { - expect(spec.onSetTargeting).to.exist.and.to.be.a('function') - }); - - it(`interpretResponse is present and type function`, function () { - expect(spec.interpretResponse).to.exist.and.to.be.a('function') - }); - - it(`store_dbid is present and type function`, function () { - expect(spec.store_dbid).to.exist.and.to.be.a('function') - }); - - it(`get_dbid is present and type function`, function () { - expect(spec.get_dbid).to.exist.and.to.be.a('function') - }); - - it(`store_syncs is present and type function`, function () { - expect(spec.store_syncs).to.exist.and.to.be.a('function') - }); - - it(`get_syncs is present and type function`, function () { - expect(spec.get_syncs).to.exist.and.to.be.a('function') - }); - - it(`queue_metric is present and type function`, function () { - expect(spec.queue_metric).to.exist.and.to.be.a('function') - }); - - it(`send_metrics is present and type function`, function () { - expect(spec.send_metrics).to.exist.and.to.be.a('function') - }); - - it(`get_client_info is present and type function`, function () { - expect(spec.get_client_info).to.exist.and.to.be.a('function') - }); - - it(`get_viewability is present and type function`, function () { - expect(spec.get_viewability).to.exist.and.to.be.a('function') - }); - }); - - describe('get / store dbid', function() { - it('Should return true / undefined', function() { - expect(spec.store_dbid('12345')).to.be.true; - expect(spec.get_dbid()).to.be.a('string'); - }); - }) - - describe('get / store syncs', function() { - it('Should return true / array', function() { - expect(spec.store_syncs([{id: 1, uid: 'test'}])).to.be.true; - expect(spec.get_syncs()).to.be.a('object'); - }); - }) - - describe('queue / send metrics', function() { - it('Should return true', function() { - expect(spec.queue_metric({type: 'test'})).to.be.true; - expect(spec.queue_metric('string')).to.be.false; - expect(spec.send_metrics()).to.be.true; - }); - }) - - describe('get_viewability', function() { - it('Should return undefined', function() { - expect(spec.get_viewability()).to.equal(undefined); - }); - }) - - describe('get client info', function() { - it('Should return object', function() { - let client_info = spec.get_client_info() - expect(client_info).to.be.a('object'); - expect(client_info).to.have.all.keys('wiw', 'wih', 'saw', 'sah', 'scd', 'sw', 'sh', 'whl', 'wxo', 'wyo', 'wpr', 'is_bot', 'is_hid', 'vs'); - }); - - it('bot test should return boolean', function() { - let bot_test = new BotClientTests(); - expect(bot_test.doTests()).to.be.a('boolean'); - }); - }) - describe('isBidRequestValid', function() { - it('Should return true when source_id and Host are set', function() { + it('Should return true when sourceId and Host are set', function() { expect(spec.isBidRequestValid(bid)).to.be.true; }); - it('Should return false when host/source_id is not set', function() { + it('Should return false when host/sourceId is not set', function() { let moddedBid = Object.assign({}, bid); - delete moddedBid.params.source_id; - expect(spec.isBidRequestValid(moddedBid)).to.be.false; - }); - - it('Should return true when viewability reporting is opted out', function() { - let moddedBid = Object.assign({}, bid); - moddedBid.params.vis_optout = true; - spec.isBidRequestValid(moddedBid); - expect(spec.db_obj.vis_optout).to.be.true; - }); - }) - - describe('getUserSyncs', function() { - it('Should return array of syncs', function() { - expect(spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [res_object], {gdprApplies: true, gdpr: 1, gdpr_consent: 'consent_string'}, {})).to.an('array'); - }); - }); - - describe('onSetTargeting', function() { - it('Should return undefined', function() { - expect(spec.onSetTargeting()).to.equal(undefined); - }); - }); - - describe('onBidWon', function() { - it('Should return undefined', function() { - let won_bid = {params: [{source_id: 1}], requestId: 1, adUnitCode: 'unit', auctionId: 1, size: '300x250', cpm: 10, adserverTargeting: {hb_pb: 10}, timeToRespond: 10, ttl: 10}; - expect(spec.onBidWon(won_bid)).to.equal(undefined); + delete moddedBid.params.sourceId; + delete moddedBid.params.host; + expect(spec.isBidRequestValid(bid)).to.be.false; }); }); describe('buildRequests', function() { - let request = spec.buildRequests([bid, bid2, nativeBid], bidderRequest); - - expect(request).to.exist; - it('Returns POST method', function() { - expect(request.method).to.exist; - expect(request.method).to.equal('POST'); - }); - - it('Returns valid URL', function() { - expect(request.url).to.exist; - expect(request.url).to.equal('https://7560.v5demo.datablocks.net/openrtb/?sid=7560'); - }); - + let requests = spec.buildRequests([bid, bid2, nativeBid, videoBid], bidderRequest); it('Creates an array of request objects', function() { - expect(request.data.imp).to.be.an('array').that.is.not.empty; + expect(requests).to.be.an('array').that.is.not.empty; }); - it('Should be a valid openRTB request', function() { - let data = request.data; - - expect(data).to.be.an('object'); - expect(data).to.have.all.keys('device', 'imp', 'site', 'id'); - expect(data.id).to.be.a('string'); - expect(data.imp).to.be.a('array'); - expect(data.device.ip).to.equal('peer'); - - let imps = data['imp']; - imps.forEach((imp, index) => { - let curBid = bidderRequest.bids[index]; - if (imp.banner) { - expect(imp.banner).to.be.a('object'); - expect(imp).to.have.all.keys('banner', 'id', 'secure', 'tagid', 'placement_id', 'ortb2', 'floor'); - } else if (imp.native) { - expect(imp).to.have.all.keys('native', 'id', 'secure', 'tagid', 'placement_id', 'ortb2', 'floor'); - expect(imp.native).to.have.all.keys('request', 'ver'); - expect(imp.native.request).to.be.a('object'); - } else { - expect(true).to.equal(false); - } + requests.forEach(request => { + expect(request).to.exist; + it('Returns POST method', function() { + expect(request.method).to.exist; + expect(request.method).to.equal('POST'); + }); + it('Returns valid URL', function() { + expect(request.url).to.exist; + expect(request.url).to.equal('https://v5demo.datablocks.net/search/?sid=7560'); + }); - expect(imp.id).to.be.a('string'); - expect(imp.id).to.equal(curBid.bidId); - expect(imp.tagid).to.be.a('string'); - expect(imp.tagid).to.equal(curBid.adUnitCode); - expect(imp.secure).to.equal(false); - }) - }); + it('Should be a valid openRTB request', function() { + let data = request.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('device', 'imp', 'site', 'id'); + expect(data.id).to.be.a('string'); + + let imps = data['imp']; + imps.forEach((imp, index) => { + let curBid = bidderRequest.bids[index]; + if (imp.banner) { + expect(imp).to.have.all.keys('banner', 'id', 'secure', 'tagid'); + expect(imp.banner).to.be.a('object'); + } else if (imp.native) { + expect(imp).to.have.all.keys('native', 'id', 'secure', 'tagid'); + expect(imp.native).to.have.all.keys('request'); + expect(imp.native.request).to.be.a('string'); + let native = JSON.parse(imp.native.request); + expect(native).to.be.a('object'); + } else if (imp.video) { + expect(imp).to.have.all.keys('video', 'id', 'secure', 'tagid'); + expect(imp.video).to.have.all.keys('w', 'h', 'minduration', 'maxduration') + } else { + expect(true).to.equal(false); + } + + expect(imp.id).to.be.a('string'); + expect(imp.id).to.equal(curBid.bidId); + expect(imp.tagid).to.be.a('string'); + expect(imp.tagid).to.equal(curBid.adUnitCode); + expect(imp.secure).to.equal(false); + }) + + expect(data.device.ip).to.equal('peer'); + }); + }) it('Returns empty data if no valid requests are passed', function() { - let test_request = spec.buildRequests([]); - expect(test_request).to.be.an('array').that.is.empty; + let request = spec.buildRequests([]); + expect(request).to.be.an('array').that.is.empty; }); }); - describe('interpretResponse', function() { - let response = spec.interpretResponse(res_object, bid_request); - + let serverResponses = spec.interpretResponse(resObject, bidRequest); it('Returns an array of valid server responses if response object is valid', function() { - expect(response).to.be.an('array').that.is.not.empty; - - response.forEach(bid => { - expect(parseInt(bid.requestId)).to.be.a('number').greaterThan(0); - expect(bid.cpm).to.be.a('number'); - expect(bid.creativeId).to.be.a('string'); - expect(bid.currency).to.be.a('string'); - expect(bid.netRevenue).to.be.a('boolean'); - expect(bid.ttl).to.be.a('number'); - expect(bid.mediaType).to.be.a('string'); - - if (bid.mediaType == 'banner') { - expect(bid.width).to.be.a('number'); - expect(bid.height).to.be.a('number'); - expect(bid.ad).to.be.a('string'); - } else if (bid.mediaType == 'native') { - expect(bid.native).to.be.a('object'); + expect(serverResponses).to.be.an('array').that.is.not.empty; + for (let i = 0; i < serverResponses.length; i++) { + let dataItem = serverResponses[i]; + expect(Object.keys(dataItem)).to.include('cpm', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'mediaType', 'requestId'); + expect(dataItem.requestId).to.be.a('string'); + expect(dataItem.cpm).to.be.a('number'); + expect(dataItem.ttl).to.be.a('number'); + expect(dataItem.creativeId).to.be.a('string'); + expect(dataItem.netRevenue).to.be.a('boolean'); + expect(dataItem.currency).to.be.a('string'); + expect(dataItem.mediaType).to.be.a('string'); + + if (dataItem.mediaType == 'banner') { + expect(dataItem.ad).to.be.a('string'); + expect(dataItem.width).to.be.a('number'); + expect(dataItem.height).to.be.a('number'); + } else if (dataItem.mediaType == 'native') { + expect(dataItem.native.title).to.be.a('string'); + expect(dataItem.native.body).to.be.a('string'); + expect(dataItem.native.clickUrl).to.be.a('string'); + } else if (dataItem.mediaType == 'video') { + expect(dataItem.vastUrl).to.be.a('string'); + expect(dataItem.width).to.be.a('number'); + expect(dataItem.height).to.be.a('number'); } - }) - + } it('Returns an empty array if invalid response is passed', function() { serverResponses = spec.interpretResponse('invalid_response'); expect(serverResponses).to.be.an('array').that.is.empty; From 4e61f9d6f15a2af7577498b65ef074e7ef21da11 Mon Sep 17 00:00:00 2001 From: Max Duval Date: Fri, 14 May 2021 15:26:13 +0100 Subject: [PATCH 176/303] clarify dependency on global rtdModule (#6759) As discussed with David from Permutive --- modules/permutiveRtdProvider.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/permutiveRtdProvider.md b/modules/permutiveRtdProvider.md index fe8c34c1b5c..3738c6e8be7 100644 --- a/modules/permutiveRtdProvider.md +++ b/modules/permutiveRtdProvider.md @@ -4,8 +4,11 @@ This submodule reads segments from Permutive and attaches them as targeting keys ## Usage Compile the Permutive RTD module into your Prebid build: ``` -gulp build --modules=permutiveRtdProvider +gulp build --modules=rtdModule,permutiveRtdProvider ``` + +> Note that the global RTD module, `rtdModule`, is a prerequisite of the Permutive RTD module. + You then need to enable the Permutive RTD in your Prebid configuration, using the below format: ```javascript From e533e1bbc8fa5c7fbc051b67c35c8aa488d89506 Mon Sep 17 00:00:00 2001 From: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Date: Fri, 14 May 2021 11:06:40 -0400 Subject: [PATCH 177/303] Update to PBS bid adapter for video bids, pass along w and h respectively and filter out contxt and playerSize params as PBS does not use them (#6682) --- modules/prebidServerBidAdapter/index.js | 12 ++++++++++- .../modules/prebidServerBidAdapter_spec.js | 20 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index d91858ed9b2..616cec47ff1 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -601,7 +601,17 @@ const OPEN_RTB_PROTOCOL = { if (videoParams.context === 'instream' && !videoParams.hasOwnProperty('placement')) { videoParams.placement = 1; } - mediaTypes['video'] = videoParams; + + mediaTypes['video'] = Object.keys(videoParams).filter(param => param !== 'context') + .reduce((result, param) => { + if (param === 'playerSize') { + result.w = utils.deepAccess(videoParams, `${param}.0.0`); + result.h = utils.deepAccess(videoParams, `${param}.0.1`); + } else { + result[param] = videoParams[param]; + } + return result; + }, {}); } } diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index a6afed8ba3e..147ade6c77b 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -530,6 +530,26 @@ describe('S2S Adapter', function () { expect(requestBid.imp[0].video.placement).to.equal(1); }); + it('converts video mediaType properties into openRTB format', function () { + let ortb2Config = utils.deepClone(CONFIG); + ortb2Config.endpoint.p1Consent = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + + config.setConfig({ s2sConfig: ortb2Config }); + + let videoBid = utils.deepClone(VIDEO_REQUEST); + videoBid.ad_units[0].mediaTypes.video.context = 'instream'; + adapter.callBids(videoBid, BID_REQUESTS, addBidResponse, done, ajax); + + const requestBid = JSON.parse(server.requests[0].requestBody); + expect(requestBid.imp[0].banner).to.not.exist; + expect(requestBid.imp[0].video).to.exist; + expect(requestBid.imp[0].video.placement).to.equal(1); + expect(requestBid.imp[0].video.w).to.equal(640); + expect(requestBid.imp[0].video.h).to.equal(480); + expect(requestBid.imp[0].video.playerSize).to.be.undefined; + expect(requestBid.imp[0].video.context).to.be.undefined; + }); + it('exists and is a function', function () { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); From ea6d7d6c68e4c2906fb780ce0327fcdd3f2a93c0 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 14 May 2021 13:28:32 -0400 Subject: [PATCH 178/303] Sovrn and Sharethrough Bid Adapters: support for advertiserDomains (#6764) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Delete iasBidAdapter.js * Add files via upload * Update openxBidAdapter.js * Update openxBidAdapter.js * Update sovrnBidAdapter.js * Update sharethroughBidAdapter.js * Update sharethroughBidAdapter_spec.js * Update sovrnBidAdapter_spec.js * Update sovrnBidAdapter_spec.js * Update sharethroughBidAdapter_spec.js * Update sharethroughBidAdapter_spec.js * Update sharethroughBidAdapter_spec.js --- modules/sharethroughBidAdapter.js | 1 + modules/sovrnBidAdapter.js | 3 ++- test/spec/modules/sharethroughBidAdapter_spec.js | 5 +++-- test/spec/modules/sovrnBidAdapter_spec.js | 12 ++++++++---- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index eef18288b17..68ccde0da46 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -109,6 +109,7 @@ export const sharethroughAdapterSpec = { currency: 'USD', netRevenue: true, ttl: 360, + meta: { advertiserDomains: creative.creative && creative.creative.adomain ? creative.creative.adomain : [] }, ad: generateAd(body, req) }]; }, diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index 708cb110dbd..cba90e7d434 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -160,7 +160,8 @@ export const spec = { netRevenue: true, mediaType: BANNER, ad: decodeURIComponent(`${sovrnBid.adm}`), - ttl: sovrnBid.ext ? (sovrnBid.ext.ttl || 90) : 90 + ttl: sovrnBid.ext ? (sovrnBid.ext.ttl || 90) : 90, + meta: { advertiserDomains: sovrnBid && sovrnBid.adomain ? sovrnBid.adomain : [] } }); }); } diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index f741f985f9f..5c8e01536dd 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -473,7 +473,7 @@ describe('sharethrough adapter spec', function() { describe('.interpretResponse', function() { it('returns a correctly parsed out response', function() { - expect(spec.interpretResponse(bidderResponse, prebidRequests[0])[0]).to.include( + expect(spec.interpretResponse(bidderResponse, prebidRequests[0])[0]).to.deep.include( { width: 1, height: 1, @@ -482,7 +482,8 @@ describe('sharethrough adapter spec', function() { dealId: 'aDealId', currency: 'USD', netRevenue: true, - ttl: 360 + ttl: 360, + meta: { advertiserDomains: [] } }); }); diff --git a/test/spec/modules/sovrnBidAdapter_spec.js b/test/spec/modules/sovrnBidAdapter_spec.js index 1050fdf4856..729c48c28f4 100644 --- a/test/spec/modules/sovrnBidAdapter_spec.js +++ b/test/spec/modules/sovrnBidAdapter_spec.js @@ -387,7 +387,8 @@ describe('sovrnBidAdapter', function() { 'netRevenue': true, 'mediaType': 'banner', 'ad': decodeURIComponent(`>`), - 'ttl': 60000 + 'ttl': 60000, + 'meta': { advertiserDomains: [] } }]; let result = spec.interpretResponse(response); @@ -407,7 +408,8 @@ describe('sovrnBidAdapter', function() { 'netRevenue': true, 'mediaType': 'banner', 'ad': decodeURIComponent(``), - 'ttl': 90 + 'ttl': 90, + 'meta': { advertiserDomains: [] } }]; let result = spec.interpretResponse(response); @@ -428,7 +430,8 @@ describe('sovrnBidAdapter', function() { 'netRevenue': true, 'mediaType': 'banner', 'ad': decodeURIComponent(``), - 'ttl': 90 + 'ttl': 90, + 'meta': { advertiserDomains: [] } }]; let result = spec.interpretResponse(response); @@ -449,7 +452,8 @@ describe('sovrnBidAdapter', function() { 'netRevenue': true, 'mediaType': 'banner', 'ad': decodeURIComponent(``), - 'ttl': 480 + 'ttl': 480, + 'meta': { advertiserDomains: [] } }]; let result = spec.interpretResponse(response); From 3d376682fefe470da71c80f9822026b4a7d7111e Mon Sep 17 00:00:00 2001 From: jackhsiehucf <77815341+jackhsiehucf@users.noreply.github.com> Date: Mon, 17 May 2021 19:04:42 +0800 Subject: [PATCH 179/303] ucfunnel Bid Adapter: add support for FLoC and Verizon Media ConnectID (#6744) * Add a new ucfunnel Adapter and test page * Add a new ucfunnel Adapter and test page * 1. Use prebid lib in the repo to keep updated 2. Replace var with let 3. Put JSON.parse(JSON.stringify()) into try catch block * utils.getTopWindowLocation is a function * Change to modules from adapters * Migrate to module design * [Dev Fix] Remove width and height which can be got from ad unit id * Update ucfunnelBidAdapter to fit into new spec * Correct the endpoint. Fix the error of query string * Add test case for ucfunnelBidAdapter * Fix lint error * Update version number * Combine all checks on bid request * Add GDPR support for ucfunnel adapter * Add in-stream video and native support for ucfunnel adapter * Remove demo page. Add more test cases. * Change request method from POST to GET * Remove unnecessary comment * Support vastXml and vastUrl for video request * update TTL to 30 mins * Avoid using arrow function which is not discuraged in mocha * ucfunnel tdid support * ucfunnel fix error message in debug mode * ucfunnel adapter add bidfloor parameter * ucfunnel adapter support CCPA * ucfunnel adapter native support clicktrackers * ucfunnel adapter change cookie sync setting * ucfunnel adapter update request parameter * Update ucfunnelBidAdapter * ucfunnel adapter add currency in ad response * ucfunnel adapter support uid2 * ucfunnel Bid Adapter: add support for FLoC and Verizon Media ConnectID Co-authored-by: root Co-authored-by: Ryan Chou Co-authored-by: ucfunnel Co-authored-by: jack.hsieh --- modules/ucfunnelBidAdapter.js | 17 ++++++++++++++++- test/spec/modules/ucfunnelBidAdapter_spec.js | 7 +++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/ucfunnelBidAdapter.js b/modules/ucfunnelBidAdapter.js index 9b9134a8ef0..734aba97789 100644 --- a/modules/ucfunnelBidAdapter.js +++ b/modules/ucfunnelBidAdapter.js @@ -300,6 +300,7 @@ function getRequestData(bid, bidderRequest) { } function addUserId(bidData, userId) { + bidData['eids'] = ''; utils._each(userId, (userIdObjectOrValue, userIdProviderKey) => { switch (userIdProviderKey) { case 'sharedid': @@ -333,7 +334,21 @@ function addUserId(bidData, userId) { break; case 'uid2': if (userIdObjectOrValue.id) { - bidData['eids'] = userIdProviderKey + ',' + userIdObjectOrValue.id + bidData['eids'] = (bidData['eids'].length > 0) + ? (bidData['eids'] + '!' + userIdProviderKey + ',' + userIdObjectOrValue.id) + : (userIdProviderKey + ',' + userIdObjectOrValue.id); + } + break; + case 'connectid': + if (userIdObjectOrValue) { + bidData['eids'] = (bidData['eids'].length > 0) + ? (bidData['eids'] + '!verizonMediaId,' + userIdObjectOrValue) + : ('verizonMediaId,' + userIdObjectOrValue); + } + break; + case 'flocId': + if (userIdObjectOrValue.id) { + bidData['cid'] = userIdObjectOrValue.id; } break; default: diff --git a/test/spec/modules/ucfunnelBidAdapter_spec.js b/test/spec/modules/ucfunnelBidAdapter_spec.js index d7e82338ff3..bee420f40d4 100644 --- a/test/spec/modules/ucfunnelBidAdapter_spec.js +++ b/test/spec/modules/ucfunnelBidAdapter_spec.js @@ -17,7 +17,9 @@ const userId = { 'sharedid': {'id': '01ESHXW4HD29KMF387T63JQ9H5', 'third': '01ESHXW4HD29KMF387T63JQ9H5'}, 'tdid': 'D6885E90-2A7A-4E0F-87CB-7734ED1B99A3', 'haloId': {}, - 'uid2': {'id': 'eb33b0cb-8d35-4722-b9c0-1a31d4064888'} + 'uid2': {'id': 'eb33b0cb-8d35-4722-b9c0-1a31d4064888'}, + 'flocId': {'id': '12144', 'version': 'chrome.1.1'}, + 'connectid': '4567' } const validBannerBidReq = { @@ -159,7 +161,8 @@ describe('ucfunnel Adapter', function () { expect(data.adid).to.equal('ad-34BBD2AA24B678BBFD4E7B9EE3B872D'); expect(data.w).to.equal(width); expect(data.h).to.equal(height); - expect(data.eids).to.equal('uid2,eb33b0cb-8d35-4722-b9c0-1a31d4064888'); + expect(data.eids).to.equal('uid2,eb33b0cb-8d35-4722-b9c0-1a31d4064888!verizonMediaId,4567'); + expect(data.cid).to.equal('12144'); expect(data.schain).to.equal('1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com'); }); From 9c0a4bf4f72512542423799afe028470548d3c06 Mon Sep 17 00:00:00 2001 From: Max Duval Date: Mon, 17 May 2021 16:31:56 +0100 Subject: [PATCH 180/303] Permutive Rtd Submodule: register submodule in submodules list (#6768) --- modules/.submodules.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/.submodules.json b/modules/.submodules.json index a8804321278..0a10044a78e 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -36,10 +36,11 @@ ], "rtdModule": [ "browsiRtdProvider", + "geoedgeRtdProvider", "haloRtdProvider", "jwplayerRtdProvider", + "permutiveRtdProvider", "reconciliationRtdProvider", - "geoedgeRtdProvider", "sirdataRtdProvider" ], "fpdModule": [ From eaad22d72fe6cea5301e253c25aa7a5ee1046acf Mon Sep 17 00:00:00 2001 From: John Salis Date: Mon, 17 May 2021 14:04:48 -0400 Subject: [PATCH 181/303] Beachfront Bid Adapter: update beachfront example docs (#6774) Co-authored-by: John Salis --- modules/beachfrontBidAdapter.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/modules/beachfrontBidAdapter.md b/modules/beachfrontBidAdapter.md index a2eb79ee331..9de415f8fc5 100644 --- a/modules/beachfrontBidAdapter.md +++ b/modules/beachfrontBidAdapter.md @@ -18,7 +18,8 @@ Module that connects to Beachfront's demand sources mediaTypes: { video: { context: 'instream', - playerSize: [ 640, 360 ] + playerSize: [640, 360], + mimes: ['video/mp4', 'application/javascript'] } }, bids: [ @@ -26,10 +27,7 @@ Module that connects to Beachfront's demand sources bidder: 'beachfront', params: { bidfloor: 0.01, - appId: '11bc5dd5-7421-4dd8-c926-40fa653bec76', - video: { - mimes: [ 'video/mp4', 'application/javascript' ] - } + appId: '11bc5dd5-7421-4dd8-c926-40fa653bec76' } } ] @@ -37,7 +35,7 @@ Module that connects to Beachfront's demand sources code: 'test-banner', mediaTypes: { banner: { - sizes: [ 300, 250 ] + sizes: [300, 250] } }, bids: [ @@ -61,10 +59,11 @@ Module that connects to Beachfront's demand sources mediaTypes: { video: { context: 'outstream', - playerSize: [ 640, 360 ] + playerSize: [640, 360], + mimes: ['video/mp4', 'application/javascript'] }, banner: { - sizes: [ 300, 250 ] + sizes: [300, 250] } }, bids: [ @@ -74,7 +73,6 @@ Module that connects to Beachfront's demand sources video: { bidfloor: 0.01, appId: '11bc5dd5-7421-4dd8-c926-40fa653bec76', - mimes: [ 'video/mp4', 'application/javascript' ] }, banner: { bidfloor: 0.01, @@ -95,7 +93,8 @@ Module that connects to Beachfront's demand sources mediaTypes: { video: { context: 'outstream', - playerSize: [ 640, 360 ] + playerSize: [ 640, 360 ], + mimes: ['video/mp4', 'application/javascript'] } }, bids: [ @@ -104,8 +103,7 @@ Module that connects to Beachfront's demand sources params: { video: { bidfloor: 0.01, - appId: '11bc5dd5-7421-4dd8-c926-40fa653bec76', - mimes: [ 'video/mp4', 'application/javascript' ] + appId: '11bc5dd5-7421-4dd8-c926-40fa653bec76' }, player: { progressColor: '#50A8FA', From 59313368e39276193963f19f702e2d79761ee1d2 Mon Sep 17 00:00:00 2001 From: hdwmsconfig Date: Mon, 17 May 2021 15:29:54 -0300 Subject: [PATCH 182/303] Eplanning Bid Adapter: Adjust endpoint parameter formatting (#6772) --- modules/eplanningBidAdapter.js | 3 +-- test/spec/modules/eplanningBidAdapter_spec.js | 11 +++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/modules/eplanningBidAdapter.js b/modules/eplanningBidAdapter.js index d62d1ee46e8..98a0e290575 100644 --- a/modules/eplanningBidAdapter.js +++ b/modules/eplanningBidAdapter.js @@ -58,7 +58,6 @@ export const spec = { rnd: rnd, e: spaces.str, ur: pageUrl || FILE, - r: 'pbjs', pbv: '$prebid.version$', ncb: '1', vs: spaces.vs @@ -85,7 +84,7 @@ export const spec = { } const userIds = (getGlobal()).getUserIds(); for (var id in userIds) { - params[id] = (typeof userIds[id] === 'object') ? encodeURIComponent(JSON.stringify(userIds[id])) : encodeURIComponent(userIds[id]); + params['e_' + id] = (typeof userIds[id] === 'object') ? encodeURIComponent(JSON.stringify(userIds[id])) : encodeURIComponent(userIds[id]); } } diff --git a/test/spec/modules/eplanningBidAdapter_spec.js b/test/spec/modules/eplanningBidAdapter_spec.js index 2ab26cfe57d..1d3a8344170 100644 --- a/test/spec/modules/eplanningBidAdapter_spec.js +++ b/test/spec/modules/eplanningBidAdapter_spec.js @@ -324,11 +324,6 @@ describe('E-Planning Adapter', function () { expect(method).to.equal('GET'); }); - it('should return r parameter with value pbjs', function () { - const r = spec.buildRequests(bidRequests, bidderRequest).data.r; - expect(r).to.equal('pbjs'); - }); - it('should return pbv parameter with value prebid version', function () { const pbv = spec.buildRequests(bidRequests, bidderRequest).data.pbv; expect(pbv).to.equal('$prebid.version$'); @@ -922,9 +917,9 @@ describe('E-Planning Adapter', function () { const request = spec.buildRequests(bidRequests, bidderRequest); const dataRequest = request.data; - expect('D6885E90-2A7A-4E0F-87CB-7734ED1B99A3').to.equal(dataRequest.tdid); - expect('c29cb2ae-769d-42f6-891a-f53cadee823d').to.equal(dataRequest.pubcid); - expect(expected_id5id).to.equal(dataRequest.id5id); + expect('D6885E90-2A7A-4E0F-87CB-7734ED1B99A3').to.equal(dataRequest.e_tdid); + expect('c29cb2ae-769d-42f6-891a-f53cadee823d').to.equal(dataRequest.e_pubcid); + expect(expected_id5id).to.equal(dataRequest.e_id5id); }); }); }); From a9232fdb8530d2480fec22a900e300755d486d4f Mon Sep 17 00:00:00 2001 From: John Salis Date: Mon, 17 May 2021 14:35:27 -0400 Subject: [PATCH 183/303] Beachfront Bid Adapter: add Unified ID 2.0 support (#6770) --- modules/beachfrontBidAdapter.js | 7 +++-- .../spec/modules/beachfrontBidAdapter_spec.js | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index 8ddc0ca5ba9..7466b3d6a68 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -19,7 +19,8 @@ export const DEFAULT_MIMES = ['video/mp4', 'application/javascript']; export const SUPPORTED_USER_IDS = [ { key: 'tdid', source: 'adserver.org', rtiPartner: 'TDID', queryParam: 'tdid' }, - { key: 'idl_env', source: 'liveramp.com', rtiPartner: 'idl', queryParam: 'idl' } + { key: 'idl_env', source: 'liveramp.com', rtiPartner: 'idl', queryParam: 'idl' }, + { key: 'uid2.id', source: 'uidapi.com', rtiPartner: 'UID2', queryParam: 'uid2' } ]; let appId = ''; @@ -279,7 +280,7 @@ function getEids(bid) { function getUserId(bid) { return ({ key, source, rtiPartner }) => { - let id = bid.userId && bid.userId[key]; + let id = utils.deepAccess(bid, `userId.${key}`); return id ? formatEid(id, source, rtiPartner) : null; }; } @@ -428,7 +429,7 @@ function createBannerRequestData(bids, bidderRequest) { } SUPPORTED_USER_IDS.forEach(({ key, queryParam }) => { - let id = bids[0] && bids[0].userId && bids[0].userId[key]; + let id = utils.deepAccess(bids, `0.userId.${key}`) if (id) { payload[queryParam] = id; } diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index c7ae5c799ac..605ccc464cb 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -333,6 +333,24 @@ describe('BeachfrontAdapter', function () { }] }); }); + + it('must add the Unified ID 2.0 to the request', () => { + const uid2 = { id: '4321' }; + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { video: {} }; + bidRequest.userId = { uid2 }; + const requests = spec.buildRequests([ bidRequest ]); + const data = requests[0].data; + expect(data.user.ext.eids[0]).to.deep.equal({ + source: 'uidapi.com', + uids: [{ + id: uid2.id, + ext: { + rtiPartner: 'UID2' + } + }] + }); + }); }); describe('for banner bids', function () { @@ -506,6 +524,16 @@ describe('BeachfrontAdapter', function () { const data = requests[0].data; expect(data.idl).to.equal(idl_env); }); + + it('must add the Unified ID 2.0 to the request', () => { + const uid2 = { id: '4321' }; + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { banner: {} }; + bidRequest.userId = { uid2 }; + const requests = spec.buildRequests([ bidRequest ]); + const data = requests[0].data; + expect(data.uid2).to.equal(uid2.id); + }); }); describe('for multi-format bids', function () { From 5aec9205e7995774a15938c41e6523d2b65cb426 Mon Sep 17 00:00:00 2001 From: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Date: Mon, 17 May 2021 14:51:06 -0400 Subject: [PATCH 184/303] appnexus bid adapter - create stub for meta.advertiserDomains (#6753) --- modules/appnexusBidAdapter.js | 5 +++++ test/spec/modules/appnexusBidAdapter_spec.js | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index f3c53e6fcb3..d28bf391aa5 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -578,6 +578,11 @@ function newBid(serverBid, rtbBid, bidderRequest) { } }; + // WE DON'T FULLY SUPPORT THIS ATM - future spot for adomain code; creating a stub for 5.0 compliance + if (rtbBid.adomain) { + bid.meta = Object.assign({}, bid.meta, { advertiserDomains: [] }); + } + if (rtbBid.advertiser_id) { bid.meta = Object.assign({}, bid.meta, { advertiserId: rtbBid.advertiser_id }); } diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 919b36ff71a..c875cba12bc 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -1280,6 +1280,21 @@ describe('AppNexusAdapter', function () { } let result = spec.interpretResponse({ body: responseAdvertiserId }, {bidderRequest}); expect(Object.keys(result[0].meta)).to.include.members(['advertiserId']); - }) + }); + + it('should add advertiserDomains', function() { + let responseAdvertiserId = deepClone(response); + responseAdvertiserId.tags[0].ads[0].adomain = ['123']; + + let bidderRequest = { + bids: [{ + bidId: '3db3773286ee59', + adUnitCode: 'code' + }] + } + let result = spec.interpretResponse({ body: responseAdvertiserId }, {bidderRequest}); + expect(Object.keys(result[0].meta)).to.include.members(['advertiserDomains']); + expect(Object.keys(result[0].meta.advertiserDomains)).to.deep.equal([]); + }); }); }); From 4d90d7ad6813dbb3981323455f9e01c994679e09 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 17 May 2021 13:49:06 -0700 Subject: [PATCH 185/303] Conversant adapter - picks up additional params from mediaTypes.video (#6775) --- modules/conversantBidAdapter.js | 7 ++++--- modules/conversantBidAdapter.md | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/conversantBidAdapter.js b/modules/conversantBidAdapter.js index 74cd97ad019..806f276fb72 100644 --- a/modules/conversantBidAdapter.js +++ b/modules/conversantBidAdapter.js @@ -33,10 +33,11 @@ export const spec = { } if (isVideoRequest(bid)) { - if (!bid.params.mimes) { + const mimes = bid.params.mimes || utils.deepAccess(bid, 'mediaTypes.video.mimes'); + if (!mimes) { // Give a warning but let it pass utils.logWarn(BIDDER_CODE + ': mimes should be specified for videos'); - } else if (!utils.isArray(bid.params.mimes) || !bid.params.mimes.every(s => utils.isStr(s))) { + } else if (!utils.isArray(mimes) || !mimes.every(s => utils.isStr(s))) { utils.logWarn(BIDDER_CODE + ': mimes must be an array of strings'); return false; } @@ -90,7 +91,7 @@ export const spec = { copyOptProperty(bid.params.position, video, 'pos'); copyOptProperty(bid.params.mimes || videoData.mimes, video, 'mimes'); - copyOptProperty(bid.params.maxduration, video, 'maxduration'); + copyOptProperty(bid.params.maxduration || videoData.maxduration, video, 'maxduration'); copyOptProperty(bid.params.protocols || videoData.protocols, video, 'protocols'); copyOptProperty(bid.params.api || videoData.api, video, 'api'); diff --git a/modules/conversantBidAdapter.md b/modules/conversantBidAdapter.md index fba793adad2..07d9abf918b 100644 --- a/modules/conversantBidAdapter.md +++ b/modules/conversantBidAdapter.md @@ -29,17 +29,17 @@ var adUnits = [ mediaTypes: { video: { context: 'instream', - playerSize: [640, 480] + playerSize: [640, 480], + api: [2], + protocols: [1, 2], + mimes: ['video/mp4'] } }, bids: [{ bidder: "conversant", params: { site_id: '108060', - api: [2], - protocols: [1, 2], - white_label_url: 'https://web.hb.ad.cpe.dotomi.com/s2s/header/24', - mimes: ['video/mp4'] + white_label_url: 'https://web.hb.ad.cpe.dotomi.com/s2s/header/24' } }] }]; From d2195cad1fbef8bea600ea02f2975c4df1072105 Mon Sep 17 00:00:00 2001 From: relaido <63339139+relaido@users.noreply.github.com> Date: Tue, 18 May 2021 17:40:12 +0900 Subject: [PATCH 186/303] Relaido Adapter : size of the banner is checked and the banner can be bid on. (#6776) * add relaido adapter * remove event listener * fixed UserSyncs and e.data * fix conflicts * take size each mediaType Co-authored-by: ishigami_shingo Co-authored-by: cmertv-sishigami Co-authored-by: t_bun --- modules/relaidoBidAdapter.js | 70 ++++++++++----------- test/spec/modules/relaidoBidAdapter_spec.js | 35 ++++++++++- 2 files changed, 67 insertions(+), 38 deletions(-) diff --git a/modules/relaidoBidAdapter.js b/modules/relaidoBidAdapter.js index c77afbe6ec5..92709b7c047 100644 --- a/modules/relaidoBidAdapter.js +++ b/modules/relaidoBidAdapter.js @@ -6,7 +6,7 @@ import { getStorageManager } from '../src/storageManager.js'; const BIDDER_CODE = 'relaido'; const BIDDER_DOMAIN = 'api.relaido.jp'; -const ADAPTER_VERSION = '1.0.2'; +const ADAPTER_VERSION = '1.0.3'; const DEFAULT_TTL = 300; const UUID_KEY = 'relaido_uuid'; @@ -17,21 +17,17 @@ function isBidRequestValid(bid) { utils.logWarn('placementId param is reqeuired.'); return false; } - if (hasVideoMediaType(bid)) { - if (!isVideoValid(bid)) { - utils.logWarn('Invalid mediaType video.'); - return false; - } - } else if (hasBannerMediaType(bid)) { - if (!isBannerValid(bid)) { - utils.logWarn('Invalid mediaType banner.'); - return false; - } + if (hasVideoMediaType(bid) && isVideoValid(bid)) { + return true; } else { - utils.logWarn('Invalid mediaTypes input banner or video.'); - return false; + utils.logWarn('Invalid mediaType video.'); } - return true; + if (hasBannerMediaType(bid) && isBannerValid(bid)) { + return true; + } else { + utils.logWarn('Invalid mediaType banner.'); + } + return false; } function buildRequests(validBidRequests, bidderRequest) { @@ -43,7 +39,21 @@ function buildRequests(validBidRequests, bidderRequest) { const bidDomain = bidRequest.params.domain || BIDDER_DOMAIN; const bidUrl = `https://${bidDomain}/bid/v1/prebid/${placementId}`; const uuid = getUuid(); - const mediaType = getMediaType(bidRequest); + let mediaType = ''; + let width = 0; + let height = 0; + + if (hasVideoMediaType(bidRequest) && isVideoValid(bidRequest)) { + const playerSize = getValidSizes(utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize')); + width = playerSize[0][0]; + height = playerSize[0][1]; + mediaType = VIDEO; + } else if (hasBannerMediaType(bidRequest) && isBannerValid(bidRequest)) { + const sizes = getValidSizes(utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes')); + width = sizes[0][0]; + height = sizes[0][1]; + mediaType = BANNER; + } let payload = { version: ADAPTER_VERSION, @@ -57,18 +67,10 @@ function buildRequests(validBidRequests, bidderRequest) { transaction_id: bidRequest.transactionId, media_type: mediaType, uuid: uuid, + width: width, + height: height }; - if (hasVideoMediaType(bidRequest)) { - const playerSize = getValidSizes(utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize')); - payload.width = playerSize[0][0]; - payload.height = playerSize[0][1]; - } else if (hasBannerMediaType(bidRequest)) { - const sizes = getValidSizes(utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes')); - payload.width = sizes[0][0]; - payload.height = sizes[0][1]; - } - // It may not be encoded, so add it at the end of the payload payload.ref = bidderRequest.refererInfo.referer; @@ -83,10 +85,9 @@ function buildRequests(validBidRequests, bidderRequest) { player: bidRequest.params.player, width: payload.width, height: payload.height, - mediaType: mediaType, + mediaType: payload.media_type }); } - return bidRequests; } @@ -162,6 +163,7 @@ function onTimeout(data) { auction_id: utils.deepAccess(data, '0.auctionId'), bid_id: utils.deepAccess(data, '0.bidId'), ad_unit_code: utils.deepAccess(data, '0.adUnitCode'), + version: ADAPTER_VERSION, ref: window.location.href, }).replace(/\&$/, ''); const bidDomain = utils.deepAccess(data, '0.params.0.domain') || BIDDER_DOMAIN; @@ -248,15 +250,6 @@ export function isMobile() { return false; } -function getMediaType(bid) { - if (hasVideoMediaType(bid)) { - return VIDEO; - } else if (hasBannerMediaType(bid)) { - return BANNER; - } - return ''; -} - function hasBannerMediaType(bid) { return !!utils.deepAccess(bid, 'mediaTypes.banner'); } @@ -272,7 +265,10 @@ function getValidSizes(sizes) { if (utils.isArray(sizes[i]) && sizes[i].length == 2) { const width = sizes[i][0]; const height = sizes[i][1]; - if ((width >= 300 && height >= 250) || (width == 1 && height == 1)) { + if (width == 1 && height == 1) { + return [[1, 1]]; + } + if ((width >= 300 && height >= 250)) { result.push([width, height]); } } diff --git a/test/spec/modules/relaidoBidAdapter_spec.js b/test/spec/modules/relaidoBidAdapter_spec.js index ebc62752f16..91aa6b05e6e 100644 --- a/test/spec/modules/relaidoBidAdapter_spec.js +++ b/test/spec/modules/relaidoBidAdapter_spec.js @@ -208,10 +208,18 @@ describe('RelaidoAdapter', function () { }); it('should build bid requests by banner', function () { + setUAMobile(); bidRequest.mediaTypes = { + video: { + context: 'outstream', + playerSize: [ + [320, 180] + ] + }, banner: { sizes: [ - [640, 360] + [640, 360], + [1, 1] ] } }; @@ -221,6 +229,31 @@ describe('RelaidoAdapter', function () { expect(request.mediaType).to.equal('banner'); }); + it('should take 1x1 size', function () { + setUAMobile(); + bidRequest.mediaTypes = { + video: { + context: 'outstream', + playerSize: [ + [320, 180] + ] + }, + banner: { + sizes: [ + [640, 360], + [1, 1] + ] + } + }; + const bidRequests = spec.buildRequests([bidRequest], bidderRequest); + expect(bidRequests).to.have.lengthOf(1); + const request = bidRequests[0]; + + // eslint-disable-next-line no-console + console.log(bidRequests); + expect(request.width).to.equal(1); + }); + it('The referrer should be the last', function () { const bidRequests = spec.buildRequests([bidRequest], bidderRequest); expect(bidRequests).to.have.lengthOf(1); From 6c6affed808e75191c6c6717bb133d8075d76cce Mon Sep 17 00:00:00 2001 From: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Date: Tue, 18 May 2021 14:54:15 +0600 Subject: [PATCH 187/303] ZetaSspBidAdapter fix typo (#6777) Co-authored-by: Surovenko Alexey --- modules/zetaSspBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/zetaSspBidAdapter.js b/modules/zetaSspBidAdapter.js index 8f4d8995800..e267942862b 100644 --- a/modules/zetaSspBidAdapter.js +++ b/modules/zetaSspBidAdapter.js @@ -4,8 +4,8 @@ import {BANNER} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; const BIDDER_CODE = 'zeta_global_ssp'; -const ENDPOINT_URL = 'https:/ssp.disqus.com/bid'; -const USER_SYNC_URL = 'https:/ssp.disqus.com/match'; +const ENDPOINT_URL = 'https://ssp.disqus.com/bid'; +const USER_SYNC_URL = 'https://ssp.disqus.com/match'; const DEFAULT_CUR = 'USD'; const TTL = 200; const NET_REV = true; From e92009dd749979ed5af00db2d2be2d8a28acd0b4 Mon Sep 17 00:00:00 2001 From: Olivier Date: Tue, 18 May 2021 12:35:11 +0200 Subject: [PATCH 188/303] Adagio Bid Adapter: handle meta.advertiserDomains (and more) (#6781) Related to #6650 --- modules/adagioBidAdapter.js | 6 ++- test/spec/modules/adagioBidAdapter_spec.js | 51 +++++++++++++++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/modules/adagioBidAdapter.js b/modules/adagioBidAdapter.js index 134303bf400..66653567dab 100644 --- a/modules/adagioBidAdapter.js +++ b/modules/adagioBidAdapter.js @@ -14,7 +14,7 @@ import { OUTSTREAM } from '../src/video.js'; export const BIDDER_CODE = 'adagio'; export const LOG_PREFIX = 'Adagio:'; -export const VERSION = '2.8.0'; +export const VERSION = '2.10.0'; export const FEATURES_VERSION = '1'; export const ENDPOINT = 'https://mp.4dex.io/prebid'; export const SUPPORTED_MEDIA_TYPES = [BANNER, NATIVE, VIDEO]; @@ -1019,6 +1019,10 @@ export const spec = { const bidReq = (find(bidRequest.data.adUnits, bid => bid.bidId === bidObj.requestId)); if (bidReq) { + bidObj.meta = utils.deepAccess(bidObj, 'meta', {}); + bidObj.meta.mediaType = bidObj.mediaType; + bidObj.meta.advertiserDomains = (Array.isArray(bidObj.aDomain) && bidObj.aDomain.length) ? bidObj.aDomain : []; + if (bidObj.mediaType === VIDEO) { const mediaTypeContext = utils.deepAccess(bidReq, 'mediaTypes.video.context'); // Adagio SSP returns a `vastXml` only. No `vastUrl` nor `videoCacheKey`. diff --git a/test/spec/modules/adagioBidAdapter_spec.js b/test/spec/modules/adagioBidAdapter_spec.js index 3707c19e471..6ee42e47950 100644 --- a/test/spec/modules/adagioBidAdapter_spec.js +++ b/test/spec/modules/adagioBidAdapter_spec.js @@ -755,7 +755,14 @@ describe('Adagio bid adapter', () => { netRevenue: true, requestId: 'c180kg4267tyqz', ttl: 360, - width: 300 + width: 300, + aDomain: ['advertiser.com'], + mediaType: 'banner', + meta: { + advertiserId: '80', + advertiserName: 'An Advertiser', + networkId: '110' + } }] } }; @@ -821,13 +828,53 @@ describe('Adagio bid adapter', () => { pagetype: 'ARTICLE', category: 'NEWS', subcategory: 'SPORT', - environment: 'desktop' + environment: 'desktop', + aDomain: ['advertiser.com'], + mediaType: 'banner', + meta: { + advertiserId: '80', + advertiserName: 'An Advertiser', + advertiserDomains: ['advertiser.com'], + networkId: '110', + mediaType: 'banner' + } }]; expect(spec.interpretResponse(serverResponse, bidRequest)).to.be.an('array'); expect(spec.interpretResponse(serverResponse, bidRequest)).to.deep.equal(expectedResponse); }); + it('Meta props should be limited if no bid.meta is provided', function() { + const altServerResponse = utils.deepClone(serverResponse); + delete altServerResponse.body.bids[0].meta; + + let expectedResponse = [{ + ad: '
', + cpm: 1, + creativeId: 'creativeId', + currency: 'EUR', + height: 250, + netRevenue: true, + requestId: 'c180kg4267tyqz', + ttl: 360, + width: 300, + placement: 'PAVE_ATF', + site: 'SITE-NAME', + pagetype: 'ARTICLE', + category: 'NEWS', + subcategory: 'SPORT', + environment: 'desktop', + aDomain: ['advertiser.com'], + mediaType: 'banner', + meta: { + advertiserDomains: ['advertiser.com'], + mediaType: 'banner' + } + }]; + + expect(spec.interpretResponse(altServerResponse, bidRequest)).to.deep.equal(expectedResponse); + }); + it('should populate ADAGIO queue with ssp-data', function() { sandbox.stub(Date, 'now').returns(12345); From 3b6442e8889fdb7e58748af7d8e809a112f7c7ab Mon Sep 17 00:00:00 2001 From: pm-shashank-jain <40654031+pm-shashank-jain@users.noreply.github.com> Date: Tue, 18 May 2021 17:59:23 +0530 Subject: [PATCH 189/303] PubMatic Adapter: add support for FloCID (#6749) * changes to support native in pubmaticbid adapter * Removed port from endpoint * Removed protocol from endpoint * Formatting * Fix request payload * Updated test case * Changed request and response as per ortb spec * Change in request and response * Removed comments and extra code * Code Review comments * Code Review Comments and Test cases for request and response * Removed data type as all data asset types are handled * Code Review Changes * Code Review Comments * Supporting both banner and native and sending 0x0 in case of native * Bug Fixes * Bug response not processed by prebid * Change warning message * Fixed typo * Do not send request in case of invalid native bid * Do not send request in case of invalid native requests * objects converted to strings in log for debug purposes * Fixed logic to check for required parmas * Fixed typo for stringify * documentation for native * Review comments from Prebid * Typo * Typo * Updated pub id for native * Code Review * Support for pubid * Test Cases for PubCommonId in PubMatic adapter * Delete yarn.lock * Rename adaptermanager.js to adapterManager.js * Rename yieldNexusBidAdapter.js to yieldnexusBidAdapter.js * Rename yieldNexusBidAdapter.md to yieldnexusBidAdapter.md * Rename yieldNexusBidAdapter_spec.js to yieldnexusBidAdapter_spec.yieldnexusBidAdaptera * Rename yieldnexusBidAdapter_spec.yieldnexusBidAdaptera to yieldnexusBidAdapter_spec.js * bluebillywig outstream player support in pubmatic adapter * removed pubcommon id test cases * BBW Renderer * Pubmatic should work with provided renderer * Review Comments * changes for flocId * code review comments * fixed for eids * code review comments * unit test cases for floc * updated md file * code review comment --- modules/pubmaticBidAdapter.js | 68 +++++++++++++++++++- test/spec/modules/pubmaticBidAdapter_spec.js | 62 ++++++++++++++++++ 2 files changed, 128 insertions(+), 2 deletions(-) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index c6ecea48abf..ff934204b43 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -107,6 +107,11 @@ const dealChannelValues = { 5: 'PREF', 6: 'PMPG' }; + +const FLOC_FORMAT = { + 'EID': 1, + 'SEGMENT': 2 +} // BB stands for Blue BillyWig const BB_RENDERER = { bootstrapPlayer: function(bid) { @@ -708,8 +713,67 @@ function _addFloorFromFloorModule(impObj, bid) { impObj.bidfloor = ((!isNaN(bidFloor) && bidFloor > 0) ? bidFloor : UNDEFINED); } +function _getFlocId(validBidRequests, flocFormat) { + var flocIdObject = null; + var flocId = utils.deepAccess(validBidRequests, '0.userId.flocId'); + if (flocId && flocId.id) { + switch (flocFormat) { + case FLOC_FORMAT.SEGMENT: + flocIdObject = { + id: 'FLOC', + name: 'FLOC', + ext: { + ver: flocId.version + }, + segment: [{ + id: flocId.id, + name: 'chrome.com', + value: flocId.id.toString() + }] + } + break; + case FLOC_FORMAT.EID: + default: + flocIdObject = { + source: 'chrome.com', + uids: [ + { + atype: 1, + id: flocId.id, + ext: { + ver: flocId.version + } + }, + ] + } + break; + } + } + return flocIdObject; +} + +function _handleFlocId(payload, validBidRequests) { + var flocObject = _getFlocId(validBidRequests, FLOC_FORMAT.SEGMENT); + if (flocObject) { + if (!payload.user) { + payload.user = {}; + } + if (!payload.user.data) { + payload.user.data = []; + } + payload.user.data.push(flocObject); + } +} + function _handleEids(payload, validBidRequests) { - const bidUserIdAsEids = utils.deepAccess(validBidRequests, '0.userIdAsEids'); + let bidUserIdAsEids = utils.deepAccess(validBidRequests, '0.userIdAsEids'); + let flocObject = _getFlocId(validBidRequests, FLOC_FORMAT.EID); + if (flocObject) { + if (!bidUserIdAsEids) { + bidUserIdAsEids = []; + } + bidUserIdAsEids.push(flocObject); + } if (utils.isArray(bidUserIdAsEids) && bidUserIdAsEids.length > 0) { utils.deepSetValue(payload, 'user.eids', bidUserIdAsEids); } @@ -1029,7 +1093,7 @@ export const spec = { _handleDealCustomTargetings(payload, dctrArr, validBidRequests); _handleEids(payload, validBidRequests); _blockedIabCategoriesValidation(payload, blockedIabCategories); - + _handleFlocId(payload, validBidRequests); // First Party Data const commonFpd = config.getConfig('ortb2') || {}; if (commonFpd.site) { diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index 28e79a69e55..e8948fdc2d3 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -2096,6 +2096,68 @@ describe('PubMatic adapter', function () { expect(data.user.eids).to.equal(undefined); }); }); + + describe('FlocId', function() { + it('send the FlocId if it is present', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.flocId = { + id: '1234', + version: 'chrome1.1' + } + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'chrome.com', + 'uids': [{ + 'id': '1234', + 'atype': 1, + 'ext': { + 'ver': 'chrome1.1' + } + }] + }]); + expect(data.user.data).to.deep.equal([{ + id: 'FLOC', + name: 'FLOC', + ext: { + ver: 'chrome1.1' + }, + segment: [{ + id: '1234', + name: 'chrome.com', + value: '1234' + }] + }]); + }); + + it('appnend the flocId if userIds are present', function() { + bidRequests[0].userId = {}; + bidRequests[0].userId.netId = 'netid-user-id'; + bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); + bidRequests[0].userId.flocId = { + id: '1234', + version: 'chrome1.1' + } + let request = spec.buildRequests(bidRequests, {}); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'netid.de', + 'uids': [{ + 'id': 'netid-user-id', + 'atype': 1 + }] + }, { + 'source': 'chrome.com', + 'uids': [{ + 'id': '1234', + 'atype': 1, + 'ext': { + 'ver': 'chrome1.1' + } + }] + }]); + }); + }); }); it('Request params check for video ad', function () { From 4319b59cc1287901d16dd42b8b8191beb37d8947 Mon Sep 17 00:00:00 2001 From: PWyrembak Date: Tue, 18 May 2021 18:17:32 +0300 Subject: [PATCH 190/303] TrustX Bid Adapter: added additional sync url (#6771) --- modules/trustxBidAdapter.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/modules/trustxBidAdapter.js b/modules/trustxBidAdapter.js index 3116400edf7..9f8de30a0d4 100644 --- a/modules/trustxBidAdapter.js +++ b/modules/trustxBidAdapter.js @@ -7,6 +7,7 @@ import { config } from '../src/config.js'; const BIDDER_CODE = 'trustx'; const ENDPOINT_URL = 'https://sofia.trustx.org/hb'; const NEW_ENDPOINT_URL = 'https://grid.bidswitch.net/hbjson?sp=trustx'; +const ADDITIONAL_SYNC_URL = 'https://x.bidswitch.net/sync?ssp=themediagrid'; const TIME_TO_LIVE = 360; const ADAPTER_SYNC_URL = 'https://sofia.trustx.org/push_sync'; const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; @@ -93,12 +94,32 @@ export const spec = { if (errorMessage) utils.logError(errorMessage); return bidResponses; }, - getUserSyncs: function(syncOptions) { + getUserSyncs: function(syncOptions, responses, gdprConsent, uspConsent) { if (syncOptions.pixelEnabled) { - return [{ + const syncsPerBidder = config.getConfig('userSync.syncsPerBidder'); + let params = []; + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + if (typeof gdprConsent.gdprApplies === 'boolean') { + params.push(`gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`); + } else { + params.push(`gdpr_consent=${gdprConsent.consentString}`); + } + } + if (uspConsent) { + params.push(`us_privacy=${uspConsent}`); + } + const stringParams = params.join('&'); + const syncs = [{ type: 'image', - url: ADAPTER_SYNC_URL + url: ADAPTER_SYNC_URL + (stringParams ? `?${stringParams}` : '') }]; + if (syncsPerBidder > 1) { + syncs.push({ + type: 'image', + url: ADDITIONAL_SYNC_URL + (stringParams ? `&${stringParams}` : '') + }); + } + return syncs; } } } From c198fa7212bee455ee3c3b19d7add1037e40b1c0 Mon Sep 17 00:00:00 2001 From: Stefano <50023896+bkse-stefanodechicchis@users.noreply.github.com> Date: Tue, 18 May 2021 18:42:38 +0200 Subject: [PATCH 191/303] Bucksense Bid Adapter: add adomain to adapter (#6779) * Update bucksenseBidAdapter.js Added support for advertiserDomains * Update bucksenseBidAdapter_spec.js Co-authored-by: Patrick McCann --- modules/bucksenseBidAdapter.js | 6 +++++- test/spec/modules/bucksenseBidAdapter_spec.js | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/bucksenseBidAdapter.js b/modules/bucksenseBidAdapter.js index 3f327e62121..46d0dfe3590 100644 --- a/modules/bucksenseBidAdapter.js +++ b/modules/bucksenseBidAdapter.js @@ -90,6 +90,7 @@ export const spec = { var sCurrency = oResponse.currency || 'USD'; var bNetRevenue = oResponse.netRevenue || true; var sAd = oResponse.ad || ''; + var sAdomains = oResponse.adomains || []; if (request && sRequestID.length == 0) { utils.logInfo(WHO + ' interpretResponse() - use RequestID from Placments'); @@ -110,7 +111,10 @@ export const spec = { creativeId: sCreativeID, currency: sCurrency, netRevenue: bNetRevenue, - ad: sAd + ad: sAd, + meta: { + advertiserDomains: sAdomains + } }; bidResponses.push(bidResponse); } else { diff --git a/test/spec/modules/bucksenseBidAdapter_spec.js b/test/spec/modules/bucksenseBidAdapter_spec.js index f49a63d2003..b977c3a9dd1 100644 --- a/test/spec/modules/bucksenseBidAdapter_spec.js +++ b/test/spec/modules/bucksenseBidAdapter_spec.js @@ -128,7 +128,10 @@ describe('Bucksense Adapter', function() { 'creativeId': 'creative002', 'currency': 'USD', 'netRevenue': false, - 'ad': '
' + 'ad': '
', + 'meta': { + 'advertiserDomains': ['http://www.bucksense.com/'] + } } }; }); From 0c8a30820f25d06a400e75fcff1de676dd6c42f1 Mon Sep 17 00:00:00 2001 From: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Date: Tue, 18 May 2021 13:33:54 -0400 Subject: [PATCH 192/303] Update to PBS Bid Adapter and RP Bid Adapter to pass PBJS version in auction requests (#6767) --- modules/prebidServerBidAdapter/index.js | 3 ++ modules/rubiconBidAdapter.js | 4 +++ .../modules/prebidServerBidAdapter_spec.js | 30 +++++++++++++++++++ test/spec/modules/rubiconBidAdapter_spec.js | 2 ++ 4 files changed, 39 insertions(+) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index 616cec47ff1..ec5d05f0fe0 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -732,6 +732,9 @@ const OPEN_RTB_PROTOCOL = { } }; + // Sets pbjs version, can be overwritten below if channel exists in s2sConfig.extPrebid + request.ext.prebid = Object.assign(request.ext.prebid, {channel: {name: 'pbjs', version: $$PREBID_GLOBAL$$.version}}) + // s2sConfig video.ext.prebid is passed through openrtb to PBS if (s2sConfig.extPrebid && typeof s2sConfig.extPrebid === 'object') { request.ext.prebid = Object.assign(request.ext.prebid, s2sConfig.extPrebid); diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 9fb112eb765..078b5404baf 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -174,6 +174,10 @@ export const spec = { }], ext: { prebid: { + channel: { + name: 'pbjs', + version: $$PREBID_GLOBAL$$.version + }, cache: { vastxml: { returnCreative: rubiConf.returnVast === true diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index 147ade6c77b..6833daf49cf 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -1143,6 +1143,10 @@ describe('S2S Adapter', function () { targeting: { includebidderkeys: false, includewinners: true + }, + channel: { + name: 'pbjs', + version: 'v$prebid.version$' } } }); @@ -1177,6 +1181,10 @@ describe('S2S Adapter', function () { targeting: { includebidderkeys: false, includewinners: true + }, + channel: { + name: 'pbjs', + version: 'v$prebid.version$' } } }); @@ -1630,6 +1638,28 @@ describe('S2S Adapter', function () { expect(parsedRequestBody.ext.prebid.multibid).to.deep.equal(expected); }); + it('sets and passes pbjs version in request if channel does not exist in s2sConfig', () => { + const s2sBidRequest = utils.deepClone(REQUEST); + const bidRequests = utils.deepClone(BID_REQUESTS); + + adapter.callBids(s2sBidRequest, bidRequests, addBidResponse, done, ajax); + + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); + expect(parsedRequestBody.ext.prebid.channel).to.deep.equal({name: 'pbjs', version: 'v$prebid.version$'}); + }); + + it('does not set pbjs version in request if channel does exist in s2sConfig', () => { + const s2sBidRequest = utils.deepClone(REQUEST); + const bidRequests = utils.deepClone(BID_REQUESTS); + + utils.deepSetValue(s2sBidRequest, 's2sConfig.extPrebid.channel', {test: 1}); + + adapter.callBids(s2sBidRequest, bidRequests, addBidResponse, done, ajax); + + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); + expect(parsedRequestBody.ext.prebid.channel).to.deep.equal({test: 1}); + }); + it('passes first party data in request', () => { const s2sBidRequest = utils.deepClone(REQUEST); const bidRequests = utils.deepClone(BID_REQUESTS); diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index 5669e03759a..1964d0d6ecc 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -1520,6 +1520,8 @@ describe('the rubicon adapter', function () { expect(imp.ext.rubicon.video.skip).to.equal(1); expect(imp.ext.rubicon.video.skipafter).to.equal(15); expect(imp.ext.prebid.auctiontimestamp).to.equal(1472239426000); + // should contain version + expect(post.ext.prebid.channel).to.deep.equal({name: 'pbjs', version: 'v$prebid.version$'}); expect(post.user.ext.consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); // EIDs should exist expect(post.user.ext).to.have.property('eids').that.is.an('array'); From ff72a3df486801ce24eb927d654d299220d9e1ca Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Tue, 18 May 2021 17:11:50 -0400 Subject: [PATCH 193/303] AOL Bid Adapter: Remove client side support for already deprecated endpoint floor support (#6743) --- modules/aolBidAdapter.js | 4 ---- test/spec/modules/aolBidAdapter_spec.js | 19 ------------------- 2 files changed, 23 deletions(-) diff --git a/modules/aolBidAdapter.js b/modules/aolBidAdapter.js index 5a5d5e6f417..14b529f4973 100644 --- a/modules/aolBidAdapter.js +++ b/modules/aolBidAdapter.js @@ -271,10 +271,6 @@ export const spec = { formatMarketplaceDynamicParams(params = {}, consentData = {}) { let queryParams = {}; - if (params.bidFloor) { - queryParams.bidfloor = params.bidFloor; - } - Object.assign(queryParams, this.formatKeyValues(params.keyValues)); Object.assign(queryParams, this.formatConsentData(consentData)); diff --git a/test/spec/modules/aolBidAdapter_spec.js b/test/spec/modules/aolBidAdapter_spec.js index 78be0618594..50622180ad0 100644 --- a/test/spec/modules/aolBidAdapter_spec.js +++ b/test/spec/modules/aolBidAdapter_spec.js @@ -369,18 +369,6 @@ describe('AolAdapter', function () { expect(request.url).not.to.contain('bidfloor='); }); - it('should return url with bidFloor option if it is present', function () { - let bidRequest = createCustomBidRequest({ - params: { - placement: 1234567, - network: '9599.1', - bidFloor: 0.80 - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('bidfloor=0.8'); - }); - it('should return url with key values if keyValues param is present', function () { let bidRequest = createCustomBidRequest({ params: { @@ -781,13 +769,6 @@ describe('AolAdapter', function () { }); expect(spec.formatMarketplaceDynamicParams()).to.be.equal('param1=val1;param2=val2;param3=val3;'); }); - - it('should return formatted bid floor param when it is present', function () { - let params = { - bidFloor: 0.45 - }; - expect(spec.formatMarketplaceDynamicParams(params)).to.be.equal('bidfloor=0.45;'); - }); }); describe('formatOneMobileDynamicParams()', function () { From 5fb4041298c6f42d69b9f92d30d9c5cfccf1d235 Mon Sep 17 00:00:00 2001 From: prebidtappx <77485538+prebidtappx@users.noreply.github.com> Date: Wed, 19 May 2021 11:53:12 +0200 Subject: [PATCH 194/303] tappx Bid Adapter: update isBidRequestValid and fix request url (#6761) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * UPDATE: add initial UID * UPDATE: UID change user ext * UPDATE: UID clean logs * UPDATE: add host info * UPDATE: tappx bid adapter universal id * UPDATE: fix bidder param * UPDATE: tappxBidAdapter tests * tappxBidAdapter - fix spacing * tappxBidAdapter: add test user eids array * tappxBidAdapter: update eids array * FIX: package-lock.json * Conversant adapter: add adomain, remove digitrust (#6495) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Update conversantBidAdapter.js * Update conversantBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Rads Bid Adapter: add GDPR support & user sync support (#6455) * Proxistore Bid Adapter: add cookieless url endpoint & use floor module (#6427) * use floor module * call cookieless endpoint when necessary * test endpoint url * change url endpoint * delete console log * fix tests * add language to url * use ortb interface * unit test * update test unit * create proxistore module * add unit tests and documentation * delete modules * delete module * add proxistore rtd submodule * delete proxistore module * spacing * change url * AdYoulike Bid Adapter: Add an "Insertion" tracking for Native mediatype (#6481) * add insertion event * add missing campaign ID parameter * update unit test with new tracking checked * Dspx Bid Adapter : add user sync support (#6456) * Add sync support for dspx adapter * Dspx Bid Adapter : add user sync support Co-authored-by: Alexander * Multibid Module: add new module to handle multiple bids from single bidder & update rubicon adapter (#6404) * Multibid module - create new module - Expands the number of key value pairs going to the ad server in the normal Prebid way by establishing the concept of a "dynamic alias" First commit * Continued updates from 1st commit * Adding logWarn for filtered bids * Update to include passing multibid configuration to PBS requests * Update to rubicon bid adapter to pass query param rp_maxbids value taken from bidderRequest.bidLimit * Update to config to look for camelcase property names according to spec. These convert to all lowercase when passed to PBS endpoint * Adjust RP adapter to always include maxbids value - default is 1 * Added support for bidders array in multibid config * Fixed floor comparison to be <= bid cpm as oppossed to just < bid cpm. Updated md file to fix camelCase tpyo * Update to include originalBidderRequest in video call to prebid cache * Update to ignore adpod bids from multibid and allow them to return as normal bids * Adding uid2 to submodules.json (#6508) * NextRoll ID System: add new ID module (#6396) * Add Nextroll ID Module * Add nextroll to eids * Make configuration value names consistent with Adapter Module * Use parnerId instead of sellerId * Add nextroll to userId and eids md files * Remove storage configuration * Rename nextroll -> nextrollId * Add nextrollId to common ID specs * Qwarry Bid Adapter: add GDPR and consent string handling (#6489) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: pro-nsk <32703851+pro-nsk@users.noreply.github.com> * Zemanta Bid Adapter: add support for new params & consent strings to usersync URL (#6468) * add gvl id to spec * add support for bcat and badv params * add consent strings to usersync url * add bcat and badv params to doc * Automatad Bid Adapter: Add meta.advertiserDomains to bid response (#6509) * added bid meta with advertiserDomains * Adhese Bid Adapter: add support for caching video content (#6501) * adpod category support test * Revert "adpod category support test" This reverts commit 70a3cf2ad5db94757addd9e08c3a083caca282d0. * adpod category support test * Revert "adpod category support test" This reverts commit 70a3cf2ad5db94757addd9e08c3a083caca282d0. * Adhese Bid Adapter: cache video content Co-authored-by: Tim Sturtewagen Co-authored-by: Mateusz * update apacdex unit test to disable debug mode (#6511) * Telaria: not setting adid (#6507) * Prebid 4.33.0 Release * increment pre version * rubicon: removing maxduration as a required bidder parameter (#6513) * Zemanta adapter: add advertiserDomains (#6517) * Lemma Bid Adapter: accepting the floor to use the getFloor function (#6497) * lemmaBidAdapter.js Added lemma bid adapter file * lemmaBidAdapter.md Added lemma bid adapter md file * lemmaBidAdapter_spec.js Added lemma bid adapter test spec file * Update lemmaBidAdapter.js Fixed automated code review alert comparison between inconvertible types * Update lemmaBidAdapter.js Fixed review changes * Update lemmaBidAdapter.md Correct parameter value. * Update lemmaBidAdapter.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter_spec.js Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.md Lemma Bid Adapter - v3.0 compliance * Update lemmaBidAdapter.js Added user sync support into bid adapter. * updated include modules file extension. updated include modules js file extension. * Update lemmaBidAdapter_spec.js Added unit test for user sync feature. * Update lemmaBidAdapter.js Fixed format error. * Update lemmaBidAdapter_spec.js Fixed format error and typo error. * Set mediaType key value into bid object Set mediaType key value into the bid object. * Update lemmaBidAdapter.js remove duplicate function * Update lemmaBidAdapter.js Remove non supported code. * Update lemmaBidAdapter_spec.js Remove GDPR test cases. * Update lemmaBidAdapter.js Made changes for accepting the floor to use the getFloor function * Update lemmaBidAdapter.js correct undefined keyword name. * Update lemmaBidAdapter_spec.js Added test coverage floor value * Update lemmaBidAdapter.js Remove trailing spaces on lines 379 and 381. * Update lemmaBidAdapter_spec.js Added getFloor function test case changes, Please review it. * Update lemmaBidAdapter_spec.js * Update lemmaBidAdapter.js * Update lemmaBidAdapter.js Fixed lint issue. * Update lemmaBidAdapter_spec.js Fixed test cases. * Update lemmaBidAdapter_spec.js Made suggested changes. Please review it. Co-authored-by: Abhijit Mane * Mediasquare Bid Adapter: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event (#6480) * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * Mediasquare bidder: fix getUserSyncs issue with empty bids + add metrics to onBidWon Event * removing status as it does not seem populated when called * add tests * Update nextroll ID variable name to match published ID module (#6519) * Merkle User ID Module: updates to user id submodule (#6503) * AdKernel Bid/Analytics Adapters: user privacy related changes (#6488) * SynacorMedia: remove adId from the bid response (#6520) * Rubicon: making doc data types consistent (#6526) * Synacormedia Bid Adapter: add meta.advertiserDomains (#6527) * Adloox Analytics Adapter: add new analytics adapter (#6308) * gulp: fix supplying list of browsers to test against The following now works: gulp test --browserstack --nolint --nolintfix --browsers=bs_ie_11_windows_10 --file 'test/spec/modules/adloox{AnalyticsAdapter,AdServerVideo,RtdProvider}_spec.js' * instreamTracking: unit test tidy From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * adloaderStub: expose stub for other unit tests to use From @robertrmartinez in https://github.com/prebid/Prebid.js/pull/6308#issuecomment-810537538 * Adloox analytic module * Seedtag adapter: Fixing bug preventing to receive the right params onTimeout. (#6525) * adot bid adapter: add publisher path from bidder config to endpoint url (#6476) * Admixer ID System: add userId submodule (#6238) * Migrating to Prebid 1.0 * Migrating to Prebid 1.0 * Fix spec * add gdpr and usp * remove changes in gdpr_hello_world.html * Update gdpr_hello_world.html add spaces * add user syncs * remove comments * tests * admixer id system * admixer id system * admixer id system eids.md userId.md * admixer id system .submodules.json * admixer id system Co-authored-by: atkachov * PBJS Core: call custom render func after loadscript if provided (#6422) * Pubxai Analytics Adapter: bug fixes and code revamp (#6474) * Updated PubxAiAnalytics adapter - Bug fixes and Code restructuring * Updated endpoint URLs * Changed array.includes to array.indexOf to fix IE issue * Code cleanup and changes as suggested. * Updated browser testing order and edge browser token * PBJS Core: canBidderRegisterSync ignoring iframe sync disabled by default (#6535) * Update eids.js * Update eids_spec.js * Update eids.js * Update pubmaticBidAdapter_spec.js * Update eids.js * Update eids_spec.js * Update conversantBidAdapter_spec.js * Update rubiconBidAdapter_spec.js * Update conversantBidAdapter_spec.js * Delete test/spec/adapters directory * Update userId_spec.js * Update userSync.js * Update userSync_spec.js * Added automatic tzo and targetId to adserver request. (#6534) * Impactify Bid Adapter: add new bid adapter (#6518) * Add impactify adapter with MD file * Add impactify adapter * Prebid 4.34.0 Release * Increment pre version * Prebid server adapter: add config for openx hosting (#6530) * Yieldmo adapter: add meta data to bids (#6550) * Smartx Bid Adapter: Add meta.advertiserDomains support (#6547) * Onevideo / Adap.tv Adapter: updated example configuration (#6546) * Mass Deal Rendering Module: support multiple custom configs for dealId and rendering (#6500) * ZetaSsp Bid Adapter: add new bid adapter (#6432) * Adnuntius Bid Adapter: Fix for bid too low. (#6557) * Added automatic tzo and targetId to adserver request. * Fixing issues with bid price being too low. * Fixing issues with bid price being too low. * ReadPeak Bid Adapter: fix api issues, add gdpr consent, & getfloor module support (#6548) * BetweenBidAdatper: added sharedid support (#6531) * adWMG Bid Adapter: update endpoints for cookie sync (#6544) * Support floorCPM parameter, fix some minor bugs * fix space-in-parens circleci error * example fix * clean usersync URL * spaces * spaces * add new unit tests, compatibility with IE11 * remove logInfo * Check for floorCPM value * Check params before sending * New endpoints * code format * new endpoint for cookie sync * update tests Co-authored-by: Mikhail Dykun * Yieldmo Bid Adapter: add support for the floors module (#6541) * Sortable Bid Adapter: add eids support (#6565) * Add Sortable adapter for Prebid 3.x Update tests to reflect changes. * Add .js in imports * hostname not host: don't include port * Trivial change to trigger build: failure wasn't our adapter * More failures in other adapters * PR Feedback - use https for URL - fix examples in markdown - request to endpoint should work now * Feedback: add native and video examples * Update unit tests Co-authored-by: Shannon Broekhoven * Outbrain Bid Adapter: replacing Zemanta (#6558) * Sirdata Real-time Data Module: add new RTD module (#6515) * Logicad Bid Adapter: add support for userid modules (#6529) * ATS-identityLinkIdSystem - add use3P config property to control firing of 3P envelope endpoint (#6568) * Proxistore Bid Adapter: add support for tcf v2 consent (#6543) * use tcf v2 consent * set cosentGiven to false and test Gdpr api v2 * BlueBillyWig Bid Adapter: add renderer customization options (#6540) * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Update bluebillywigBidAdapter test parameters to match renderer to rendererCode rename * Blue Billywig - Also pass through site config with OpenRTB request * add Blue Billywig adapter * Blue Billywig Adapter - update according to review feedback * Blue Billywig Adapter - update to try and pass CircleCI * Remove the last for .. of in bluebillywigBidAdapter.js, hopefully... * Code quality update, always hit user syncs, improved video params * Remove unnecessary export * Add rendererSettings param to bluebillywig adapter * Kick off CircleCi tests manually Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie * OpenX Bid Adapter: Set Deal ID for video requests (#6573) * 33Across Bid Adapter: add support for User ID modules (#6554) * pubGENIUS bid adapter: support floor module (#6555) * Welect Bid Adapter: update url of API (#6570) * update api url * update api url in tests * Bright Mountain Media Bid Adapter: change bidder code to bmtm; alias old name (#6574) * Adtelligent Bid Adapter: add adUrl support & new alias (#6559) * add adUrl support * add adUrl test * Bright Mountain Media Bid Adapter: Change Endpoint URL (#6576) * tappxBidAdapter: update * tasppxBidAdapter: add video * tappxBidAdapter: update video * tappxBidAdapter: update name interpret banner * tappxBidAdapter: add tests for video * tappxBidAdapter: add adomain * tappxBidAdapter: update adapter version * tappxBidAdapter: update interpretBid adomain and dealid * tappxBidAdapter: update isBidRequestValid * tappxBidAdapter: update tests. Adding video to isBidRequestValid * tappxBidAdapter: update doc .md file * tappxBidAdapter: update isBidRequestValid * tappxBidAdapter: update ads sizes available * tappxBidAdapter: update isBidRequestValid * tappxBidAdapter: update host depending tappx endpoint * tappxBidAdapter: update tappx adapter version * tappxBidAdapter: add EOL * revert outbrain cahnges to untrack in this pr * tappxBidAdapter: update isBidRequestValid tests * tappxBidAdapter: fix circleci error Co-authored-by: marc_tappx Co-authored-by: Patrick McCann Co-authored-by: onlsol <48312668+onlsol@users.noreply.github.com> Co-authored-by: vincentproxistore <56686565+vincentproxistore@users.noreply.github.com> Co-authored-by: guiann Co-authored-by: Alexander Co-authored-by: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Co-authored-by: SKOCHERI <37454420+SKOCHERI@users.noreply.github.com> Co-authored-by: Abimael Martinez Co-authored-by: artemiokost Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: pro-nsk <32703851+pro-nsk@users.noreply.github.com> Co-authored-by: Rok Sušnik Co-authored-by: Kanchika - Automatad Co-authored-by: Paweł L Co-authored-by: Tim Sturtewagen Co-authored-by: Mateusz Co-authored-by: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Co-authored-by: bretg Co-authored-by: Jason Snellbaker Co-authored-by: Lemma Dev <54662130+lemmadev@users.noreply.github.com> Co-authored-by: Abhijit Mane Co-authored-by: matthieularere-msq <63732822+matthieularere-msq@users.noreply.github.com> Co-authored-by: Denis Logachov Co-authored-by: RAJKUMAR NATARAJAN Co-authored-by: Alexander Clouter Co-authored-by: Laura Morillo-Velarde Co-authored-by: Giudici-a <34242194+Giudici-a@users.noreply.github.com> Co-authored-by: Galphimbl Co-authored-by: atkachov Co-authored-by: Jérémie Girault Co-authored-by: Phaneendra Hegde Co-authored-by: Mikael Lundin Co-authored-by: Thomas Co-authored-by: Mike Chowla Co-authored-by: Deivydas Šabaras Co-authored-by: ym-atsymuk <81176595+ym-atsymuk@users.noreply.github.com> Co-authored-by: Skylinar <53079123+Skylinar@users.noreply.github.com> Co-authored-by: Adam Browning <19834421+adam-browning@users.noreply.github.com> Co-authored-by: Catalin Ciocov Co-authored-by: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Co-authored-by: readpeaktuomo <66239046+readpeaktuomo@users.noreply.github.com> Co-authored-by: Ignat Khaylov Co-authored-by: nyakove <43004249+nyakove@users.noreply.github.com> Co-authored-by: Mikhail Dykun Co-authored-by: ym-dlabuzov <81709888+ym-dlabuzov@users.noreply.github.com> Co-authored-by: karentnarvaez <61426156+karentnarvaez@users.noreply.github.com> Co-authored-by: Shannon Broekhoven Co-authored-by: nouchy <33549554+nouchy@users.noreply.github.com> Co-authored-by: logicad Co-authored-by: mamatic <52153441+mamatic@users.noreply.github.com> Co-authored-by: Klaas-Jan Boon Co-authored-by: Klaas-Jan Boon Co-authored-by: Chris Huie Co-authored-by: Kenan Gillet <1706856+kenan-gillet@users.noreply.github.com> Co-authored-by: Aparna Rao Co-authored-by: Meng <5110935+edmonl@users.noreply.github.com> Co-authored-by: Nick Duitz <42961155+nduitz@users.noreply.github.com> Co-authored-by: BrightMountainMedia <69471268+BrightMountainMediaInc@users.noreply.github.com> Co-authored-by: Gena Co-authored-by: Chris Huie <3444727+ChrisHuie@users.noreply.github.com> --- modules/tappxBidAdapter.js | 57 +++++++++++++++-------- modules/tappxBidAdapter.md | 2 +- test/spec/modules/tappxBidAdapter_spec.js | 34 ++++++++++++-- 3 files changed, 67 insertions(+), 26 deletions(-) diff --git a/modules/tappxBidAdapter.js b/modules/tappxBidAdapter.js index d8f6654a567..566795a204b 100644 --- a/modules/tappxBidAdapter.js +++ b/modules/tappxBidAdapter.js @@ -8,11 +8,10 @@ import { config } from '../src/config.js'; const BIDDER_CODE = 'tappx'; const TTL = 360; const CUR = 'USD'; -const TAPPX_BIDDER_VERSION = '0.1.10420'; +const TAPPX_BIDDER_VERSION = '0.1.10514'; const TYPE_CNN = 'prebidjs'; const VIDEO_SUPPORT = ['instream']; -var HOST; var hostDomain; export const spec = { @@ -105,13 +104,31 @@ export const spec = { } function validBasic(bid) { - if ( - (bid.params == null) || - (bid.params.endpoint == null) || - (bid.params.tappxkey == null)) { + if (bid.params == null) { utils.logWarn(`[TAPPX]: Please review the mandatory Tappx parameters.`); return false; } + + if (bid.params.tappxkey == null) { + utils.logWarn(`[TAPPX]: Please review the mandatory Tappxkey parameter.`); + return false; + } + + if (bid.params.host == null) { + utils.logWarn(`[TAPPX]: Please review the mandatory Host parameter.`); + return false; + } + + let classicEndpoint = true + if ((new RegExp(`^(vz.*|zz.*)\.*$`, 'i')).test(bid.params.host)) { + classicEndpoint = false + } + + if (classicEndpoint && bid.params.endpoint == null) { + utils.logWarn(`[TAPPX]: Please review the mandatory endpoint Tappx parameters.`); + return false; + } + return true; } @@ -174,11 +191,10 @@ function interpretBid(serverBid, request) { * @return response ad */ function buildOneRequest(validBidRequests, bidderRequest) { - HOST = utils.deepAccess(validBidRequests, 'params.host'); - let hostInfo = getHostInfo(HOST); + let hostInfo = getHostInfo(validBidRequests); + const ENDPOINT = hostInfo.endpoint; hostDomain = hostInfo.domain; - const ENDPOINT = utils.deepAccess(validBidRequests, 'params.endpoint'); const TAPPXKEY = utils.deepAccess(validBidRequests, 'params.tappxkey'); const BIDFLOOR = utils.deepAccess(validBidRequests, 'params.bidfloor'); const BIDEXTRA = utils.deepAccess(validBidRequests, 'params.ext'); @@ -359,7 +375,7 @@ function buildOneRequest(validBidRequests, bidderRequest) { return { method: 'POST', - url: `https://${HOST}/${ENDPOINT}?type_cnn=${TYPE_CNN}&v=${TAPPX_BIDDER_VERSION}`, + url: `${hostInfo.url}?type_cnn=${TYPE_CNN}&v=${TAPPX_BIDDER_VERSION}`, data: JSON.stringify(payload), bids: validBidRequests }; @@ -375,23 +391,24 @@ function getOs() { if (ua == null) { return 'unknown'; } else if (ua.match(/(iPhone|iPod|iPad)/)) { return 'ios'; } else if (ua.match(/Android/)) { return 'android'; } else if (ua.match(/Window/)) { return 'windows'; } else { return 'unknown'; } } -function getHostInfo(hostParam) { +function getHostInfo(validBidRequests) { let domainInfo = {}; + let endpoint = utils.deepAccess(validBidRequests, 'params.endpoint'); + let hostParam = utils.deepAccess(validBidRequests, 'params.host'); domainInfo.domain = hostParam.split('/', 1)[0]; - domainInfo.url = hostParam; - let regexNewEndpoints = new RegExp(`^(vz.*|zz.*|testing)\.ssp\.tappx\.com$`, 'i'); - let regexClassicEndpoints = new RegExp(`^[a-z]{3}\.[a-z]{3}\.tappx\.com$`, 'i'); + let regexNewEndpoints = new RegExp(`^(vz.*|zz.*)\.pub\.tappx\.com$`, 'i'); + let regexClassicEndpoints = new RegExp(`^([a-z]{3}|testing)\.[a-z]{3}\.tappx\.com$`, 'i'); if (regexNewEndpoints.test(domainInfo.domain)) { - let endpoint = domainInfo.domain.split('.', 1)[0] - if (endpoint.toUpperCase().indexOf('TESTING') === -1) { - domainInfo.endpoint = endpoint - domainInfo.new_endpoint = true; - } + domainInfo.newEndpoint = true; + domainInfo.endpoint = domainInfo.domain.split('.', 1)[0] + domainInfo.url = `https://${hostParam}` } else if (regexClassicEndpoints.test(domainInfo.domain)) { - domainInfo.new_endpoint = false; + domainInfo.newEndpoint = false; + domainInfo.endpoint = endpoint + domainInfo.url = `https://${hostParam}${endpoint}` } return domainInfo; diff --git a/modules/tappxBidAdapter.md b/modules/tappxBidAdapter.md index a07bb2d88d1..776b24bb07c 100644 --- a/modules/tappxBidAdapter.md +++ b/modules/tappxBidAdapter.md @@ -9,7 +9,7 @@ Maintainer: prebid@tappx.com Module that connects to :tappx demand sources. Suppots Banner and Instream Video. Please use ```tappx``` as the bidder code. -Ads sizes available: [320,50], [300,250], [320,480], [1024,768], [728,90] +Ads sizes available: [300,250], [320,50], [320,480], [480,320], [728,90], [768,1024], [1024,768] # Banner Test Parameters ``` diff --git a/test/spec/modules/tappxBidAdapter_spec.js b/test/spec/modules/tappxBidAdapter_spec.js index 54c4f8c9dca..9fab7d858e1 100644 --- a/test/spec/modules/tappxBidAdapter_spec.js +++ b/test/spec/modules/tappxBidAdapter_spec.js @@ -126,11 +126,35 @@ describe('Tappx bid adapter', function () { assert.isTrue(spec.isBidRequestValid(c_BIDREQUEST.bids[0]), JSON.stringify(c_BIDREQUEST)); }); - it('should return false when required params are missing', function () { - let badBidRequest = c_BIDREQUEST; - delete badBidRequest.bids[0].params.tappxkey; - delete badBidRequest.bids[0].params.endpoint; - assert.isFalse(spec.isBidRequestValid(badBidRequest.bids[0])); + it('should return false when params are missing', function () { + let badBidRequestParam = JSON.parse(JSON.stringify(c_BIDREQUEST)); + delete badBidRequestParam.bids[0].params; + assert.isFalse(spec.isBidRequestValid(badBidRequestParam.bids[0])); + }); + + it('should return false when tappxkey is missing', function () { + let badBidRequestTpxkey = JSON.parse(JSON.stringify(c_BIDREQUEST)); ; + delete badBidRequestTpxkey.bids[0].params.tappxkey; + assert.isFalse(spec.isBidRequestValid(badBidRequestTpxkey.bids[0])); + }); + + it('should return false when host is missing', function () { + let badBidRequestHost = JSON.parse(JSON.stringify(c_BIDREQUEST)); ; + delete badBidRequestHost.bids[0].params.host; + assert.isFalse(spec.isBidRequestValid(badBidRequestHost.bids[0])); + }); + + it('should return false when classic endpoint is missing', function () { + let badBidRequestClEp = JSON.parse(JSON.stringify(c_BIDREQUEST)); ; + delete badBidRequestClEp.bids[0].params.endpoint; + assert.isFalse(spec.isBidRequestValid(badBidRequestClEp.bids[0])); + }); + + it('should return true when endpoint is not set for new endpoints', function () { + let badBidRequestNwEp = JSON.parse(JSON.stringify(c_BIDREQUEST)); ; + delete badBidRequestNwEp.bids[0].params.endpoint; + badBidRequestNwEp.bids[0].params.host = 'zztesting.ssp.tappx.com/rtb/v2/'; + assert.isTrue(spec.isBidRequestValid(badBidRequestNwEp.bids[0])); }); it('should return false for not instream requests', function () { From a5b50837afb87b7076752f621970c3d39e7d6e21 Mon Sep 17 00:00:00 2001 From: pro-nsk <32703851+pro-nsk@users.noreply.github.com> Date: Wed, 19 May 2021 17:45:51 +0700 Subject: [PATCH 195/303] Qwarry Bid Adapter: add sizes (#6787) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix * gdpr value added * merge master * gdpr value added * qwarry bid adapter: add tests * Qwarry bid adapter: remove gdpr field from request * qwarry bid adapter: add sizes * qwarry bid adapter: add sizes Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev --- modules/qwarryBidAdapter.js | 7 ++++++- test/spec/modules/qwarryBidAdapter_spec.js | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/qwarryBidAdapter.js b/modules/qwarryBidAdapter.js index d19ad0b4fe4..7ed5e5c984c 100644 --- a/modules/qwarryBidAdapter.js +++ b/modules/qwarryBidAdapter.js @@ -20,7 +20,8 @@ export const spec = { bids.push({ bidId: bidRequest.bidId, zoneToken: bidRequest.params.zoneToken, - pos: bidRequest.params.pos + pos: bidRequest.params.pos, + sizes: prepareSizes(bidRequest.sizes) }) }) @@ -90,4 +91,8 @@ export const spec = { } } +function prepareSizes(sizes) { + return sizes && sizes.map(size => ({ width: size[0], height: size[1] })); +} + registerBidder(spec); diff --git a/test/spec/modules/qwarryBidAdapter_spec.js b/test/spec/modules/qwarryBidAdapter_spec.js index 5d297d32014..06d4af0756c 100644 --- a/test/spec/modules/qwarryBidAdapter_spec.js +++ b/test/spec/modules/qwarryBidAdapter_spec.js @@ -5,6 +5,7 @@ import { newBidder } from 'src/adapters/bidderFactory.js' const REQUEST = { 'bidId': '456', 'bidder': 'qwarry', + 'sizes': [[100, 200], [300, 400]], 'params': { zoneToken: 'e64782a4-8e68-4c38-965b-80ccf115d46f', pos: 7 @@ -85,7 +86,7 @@ describe('qwarryBidAdapter', function () { expect(bidderRequest.method).to.equal('POST') expect(bidderRequest.data.requestId).to.equal('123') expect(bidderRequest.data.referer).to.equal('http://test.com/path.html') - expect(bidderRequest.data.bids).to.deep.contains({ bidId: '456', zoneToken: 'e64782a4-8e68-4c38-965b-80ccf115d46f', pos: 7 }) + expect(bidderRequest.data.bids).to.deep.contains({ bidId: '456', zoneToken: 'e64782a4-8e68-4c38-965b-80ccf115d46f', pos: 7, sizes: [{ width: 100, height: 200 }, { width: 300, height: 400 }] }) expect(bidderRequest.data.gdprConsent).to.deep.contains({ consentRequired: true, consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==' }) expect(bidderRequest.options.customHeaders).to.deep.equal({ 'Rtb-Direct': true }) expect(bidderRequest.options.contentType).to.equal('application/json') From c3463221febad83379da612a3088599e4d8e595c Mon Sep 17 00:00:00 2001 From: Rahul Shandilya <67756716+c3p-0@users.noreply.github.com> Date: Wed, 19 May 2021 18:53:34 +0530 Subject: [PATCH 196/303] Medianet bid adapter: floor module support (#6713) * Medianet floor module support * removing backslash from wildcard --- modules/medianetBidAdapter.js | 29 ++++++++++++++ test/spec/modules/medianetBidAdapter_spec.js | 41 ++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/modules/medianetBidAdapter.js b/modules/medianetBidAdapter.js index a2dc8bdfd03..1a4269a8a1d 100644 --- a/modules/medianetBidAdapter.js +++ b/modules/medianetBidAdapter.js @@ -221,10 +221,39 @@ function slotParams(bidRequest) { } else { params.ext.visibility = SLOT_VISIBILITY.NOT_DETERMINED; } + const floorInfo = getBidFloorByType(bidRequest); + if (floorInfo && floorInfo.length > 0) { + params.bidfloors = floorInfo; + } return params; } +function getBidFloorByType(bidRequest) { + let floorInfo = []; + if (typeof bidRequest.getFloor === 'function') { + [BANNER, VIDEO, NATIVE].forEach(mediaType => { + if (bidRequest.mediaTypes.hasOwnProperty(mediaType)) { + if (mediaType == BANNER) { + bidRequest.mediaTypes.banner.sizes.forEach( + size => { + setFloorInfo(bidRequest, mediaType, size, floorInfo) + } + ) + } else { + setFloorInfo(bidRequest, mediaType, '*', floorInfo) + } + } + }); + } + return floorInfo; +} +function setFloorInfo(bidRequest, mediaType, size, floorInfo) { + let floor = bidRequest.getFloor({currency: 'USD', mediaType: mediaType, size: size}); + if (size.length > 1) floor.size = size; + floor.mediaType = mediaType; + floorInfo.push(floor); +} function getMinSize(sizes) { return sizes.reduce((min, size) => size.h * size.w < min.h * min.w ? size : min); } diff --git a/test/spec/modules/medianetBidAdapter_spec.js b/test/spec/modules/medianetBidAdapter_spec.js index 1eeb167601e..adb9663ba7c 100644 --- a/test/spec/modules/medianetBidAdapter_spec.js +++ b/test/spec/modules/medianetBidAdapter_spec.js @@ -1446,4 +1446,45 @@ describe('Media.net bid adapter', function () { let bids = spec.interpretResponse(SERVER_VIDEO_OUTSTREAM_RESPONSE_VALID_BID, []); expect(bids[0].context).to.equal('outstream'); }); + describe('buildRequests floor tests', function () { + let floor; + let getFloor = function(req) { + return floor[req.mediaType]; + }; + beforeEach(function () { + floor = { + 'banner': { + 'currency': 'USD', + 'floor': 1 + } + }; + $$PREBID_GLOBAL$$.medianetGlobals = {}; + + let documentStub = sandbox.stub(document, 'getElementById'); + let boundingRect = { + top: 50, + left: 50, + bottom: 100, + right: 100 + }; + documentStub.withArgs('div-gpt-ad-1460505748561-123').returns({ + getBoundingClientRect: () => boundingRect + }); + documentStub.withArgs('div-gpt-ad-1460505748561-0').returns({ + getBoundingClientRect: () => boundingRect + }); + let windowSizeStub = sandbox.stub(spec, 'getWindowSize'); + windowSizeStub.returns({ + w: 1000, + h: 1000 + }); + VALID_BID_REQUEST[0].getFloor = getFloor; + }); + + it('should build valid payload with floor', function () { + let requestObj = spec.buildRequests(VALID_BID_REQUEST, VALID_AUCTIONDATA); + requestObj = JSON.parse(requestObj.data); + expect(requestObj.imp[0].hasOwnProperty('bidfloors')).to.equal(true); + }); + }); }); From 566c8ae9db52b0d15f266937d182c12065686244 Mon Sep 17 00:00:00 2001 From: Ignat Khaylov Date: Wed, 19 May 2021 17:23:15 +0300 Subject: [PATCH 197/303] add adomain support (#6791) Co-authored-by: Ignat Khaylov --- modules/betweenBidAdapter.js | 5 +++- test/spec/modules/betweenBidAdapter_spec.js | 33 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/modules/betweenBidAdapter.js b/modules/betweenBidAdapter.js index f6360332368..5a351def958 100644 --- a/modules/betweenBidAdapter.js +++ b/modules/betweenBidAdapter.js @@ -104,7 +104,10 @@ export const spec = { creativeId: serverResponse.body[i].creativeid, currency: serverResponse.body[i].currency || 'RUB', netRevenue: serverResponse.body[i].netRevenue || true, - ad: serverResponse.body[i].ad + ad: serverResponse.body[i].ad, + meta: { + advertiserDomains: serverResponse.body[i].adomain ? serverResponse.body[i].adomain : [] + } }; bidResponses.push(bidResponse); } diff --git a/test/spec/modules/betweenBidAdapter_spec.js b/test/spec/modules/betweenBidAdapter_spec.js index 1b1ccd9efd2..0e772e7be02 100644 --- a/test/spec/modules/betweenBidAdapter_spec.js +++ b/test/spec/modules/betweenBidAdapter_spec.js @@ -267,4 +267,37 @@ describe('betweenBidAdapterTests', function () { const shid3 = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid3; expect(shid).to.equal('01EXQE7JKNDRDDVATB0S2GX1NT') && expect(shid3).to.equal(''); }); + it('check adomain', function() { + const serverResponse = { + body: [{ + bidid: 'bid1234', + cpm: 1.12, + w: 240, + h: 400, + currency: 'USD', + ad: 'Ad html', + adomain: ['domain1.com', 'domain2.com'] + }] + }; + const bids = spec.interpretResponse(serverResponse); + expect(bids).to.have.lengthOf(1); + const bid = bids[0]; + expect(bid.meta.advertiserDomains).to.deep.equal(['domain1.com', 'domain2.com']); + }); + it('check server response without adomain', function() { + const serverResponse = { + body: [{ + bidid: 'bid1234', + cpm: 1.12, + w: 240, + h: 400, + currency: 'USD', + ad: 'Ad html', + }] + }; + const bids = spec.interpretResponse(serverResponse); + expect(bids).to.have.lengthOf(1); + const bid = bids[0]; + expect(bid.meta.advertiserDomains).to.deep.equal([]); + }); }); From cb3ae12f5a8e79386afaea94277b5bb278532fff Mon Sep 17 00:00:00 2001 From: John Salis Date: Wed, 19 May 2021 12:04:41 -0400 Subject: [PATCH 198/303] Beachfront Bid Adapter: add floors module support (#6752) * add price floors support to beachfront adapter * revert doc changes to create separate pull request Co-authored-by: John Salis --- modules/beachfrontBidAdapter.js | 23 ++++++++---- .../spec/modules/beachfrontBidAdapter_spec.js | 36 +++++++++++++++++++ 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index 7466b3d6a68..da5f385b0da 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -6,9 +6,10 @@ import { VIDEO, BANNER } from '../src/mediaTypes.js'; import find from 'core-js-pure/features/array/find.js'; import includes from 'core-js-pure/features/array/includes.js'; -const ADAPTER_VERSION = '1.15'; +const ADAPTER_VERSION = '1.16'; const ADAPTER_NAME = 'BFIO_PREBID'; const OUTSTREAM = 'outstream'; +const CURRENCY = 'USD'; export const VIDEO_ENDPOINT = 'https://reachms.bfmio.com/bid.json?exchange_id='; export const BANNER_ENDPOINT = 'https://display.bfmio.com/prebid_display'; @@ -79,7 +80,7 @@ export const spec = { creativeId: response.crid || response.cmpId, renderer: context === OUTSTREAM ? createRenderer(bidRequest) : null, mediaType: VIDEO, - currency: 'USD', + currency: CURRENCY, netRevenue: true, ttl: 300 }; @@ -111,7 +112,7 @@ export const spec = { width: bid.w, height: bid.h, mediaType: BANNER, - currency: 'USD', + currency: CURRENCY, netRevenue: true, ttl: 300 }; @@ -251,6 +252,16 @@ function getPlayerBidParam(bid, key, defaultValue) { return param === undefined ? defaultValue : param; } +function getBannerBidFloor(bid) { + let floorInfo = utils.isFn(bid.getFloor) ? bid.getFloor({ currency: CURRENCY, mediaType: 'banner', size: '*' }) : {}; + return floorInfo.floor || getBannerBidParam(bid, 'bidfloor'); +} + +function getVideoBidFloor(bid) { + let floorInfo = utils.isFn(bid.getFloor) ? bid.getFloor({ currency: CURRENCY, mediaType: 'video', size: '*' }) : {}; + return floorInfo.floor || getVideoBidParam(bid, 'bidfloor'); +} + function isVideoBidValid(bid) { return isVideoBid(bid) && getVideoBidParam(bid, 'appId') && getVideoBidParam(bid, 'bidfloor'); } @@ -316,7 +327,7 @@ function createVideoRequestData(bid, bidderRequest) { let firstSize = getFirstSize(sizes); let video = getVideoTargetingParams(bid); let appId = getVideoBidParam(bid, 'appId'); - let bidfloor = getVideoBidParam(bid, 'bidfloor'); + let bidfloor = getVideoBidFloor(bid); let tagid = getVideoBidParam(bid, 'tagid'); let topLocation = getTopWindowLocation(bidderRequest); let eids = getEids(bid); @@ -358,7 +369,7 @@ function createVideoRequestData(bid, bidderRequest) { user: { ext: {} }, - cur: ['USD'] + cur: [CURRENCY] }; if (bidderRequest && bidderRequest.uspConsent) { @@ -394,7 +405,7 @@ function createBannerRequestData(bids, bidderRequest) { return { slot: bid.adUnitCode, id: getBannerBidParam(bid, 'appId'), - bidfloor: getBannerBidParam(bid, 'bidfloor'), + bidfloor: getBannerBidFloor(bid), tagid: getBannerBidParam(bid, 'tagid'), sizes: getBannerSizes(bid) }; diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index 605ccc464cb..fc74ec8a2aa 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -171,6 +171,24 @@ describe('BeachfrontAdapter', function () { expect(data.cur).to.deep.equal(['USD']); }); + it('must read from the floors module if available', function () { + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { video: {} }; + bidRequest.getFloor = () => ({ currency: 'USD', floor: 1.16 }); + const requests = spec.buildRequests([ bidRequest ]); + const data = requests[0].data; + expect(data.imp[0].bidfloor).to.equal(1.16); + }); + + it('must use the bid floor param if no value is returned from the floors module', function () { + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { video: {} }; + bidRequest.getFloor = () => ({}); + const requests = spec.buildRequests([ bidRequest ]); + const data = requests[0].data; + expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor); + }); + it('must parse bid size from a nested array', function () { const width = 640; const height = 480; @@ -403,6 +421,24 @@ describe('BeachfrontAdapter', function () { expect(data.ua).to.equal(navigator.userAgent); }); + it('must read from the floors module if available', function () { + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { banner: {} }; + bidRequest.getFloor = () => ({ currency: 'USD', floor: 1.16 }); + const requests = spec.buildRequests([ bidRequest ]); + const data = requests[0].data; + expect(data.slots[0].bidfloor).to.equal(1.16); + }); + + it('must use the bid floor param if no value is returned from the floors module', function () { + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { banner: {} }; + bidRequest.getFloor = () => ({}); + const requests = spec.buildRequests([ bidRequest ]); + const data = requests[0].data; + expect(data.slots[0].bidfloor).to.equal(bidRequest.params.bidfloor); + }); + it('must parse bid size from a nested array', function () { const width = 300; const height = 250; From d662340c08b529dcdef71ca28068ffa376418eb1 Mon Sep 17 00:00:00 2001 From: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Date: Wed, 19 May 2021 22:43:24 +0600 Subject: [PATCH 199/303] Zeta Ssp Bid Adapter: merge fpd.device and params.device (#6786) --- modules/zetaSspBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/zetaSspBidAdapter.js b/modules/zetaSspBidAdapter.js index e267942862b..450608a82f4 100644 --- a/modules/zetaSspBidAdapter.js +++ b/modules/zetaSspBidAdapter.js @@ -53,7 +53,7 @@ export const spec = { cur: [DEFAULT_CUR], imp: [impData], site: params.site ? params.site : {}, - device: fpd.device ? fpd.device : {}, + device: {...fpd.device, ...params.device}, user: params.user ? params.user : {}, app: params.app ? params.app : {}, ext: { From 03ad46db7e4b02e8835c53a4bb2a01a8290f1606 Mon Sep 17 00:00:00 2001 From: Meng <5110935+edmonl@users.noreply.github.com> Date: Wed, 19 May 2021 13:05:32 -0400 Subject: [PATCH 200/303] pubGENIUS bid adapter: read more video params from mediaTypes.video (#6793) --- modules/pubgeniusBidAdapter.js | 17 ++++++++++++++++- modules/pubgeniusBidAdapter.md | 12 ++++++------ test/spec/modules/pubgeniusBidAdapter_spec.js | 3 +++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/modules/pubgeniusBidAdapter.js b/modules/pubgeniusBidAdapter.js index 2df2d25f627..89dea545434 100644 --- a/modules/pubgeniusBidAdapter.js +++ b/modules/pubgeniusBidAdapter.js @@ -149,7 +149,22 @@ export const spec = { function buildVideoParams(videoMediaType, videoParams) { videoMediaType = videoMediaType || {}; - const params = pick(videoMediaType, ['api', 'mimes', 'protocols', 'playbackmethod']); + const params = pick(videoMediaType, [ + 'mimes', + 'minduration', + 'maxduration', + 'protocols', + 'startdelay', + 'placement', + 'skip', + 'skipafter', + 'minbitrate', + 'maxbitrate', + 'delivery', + 'playbackmethod', + 'api', + 'linearity', + ]); switch (videoMediaType.context) { case 'instream': diff --git a/modules/pubgeniusBidAdapter.md b/modules/pubgeniusBidAdapter.md index 66e0c382285..2a10b421de2 100644 --- a/modules/pubgeniusBidAdapter.md +++ b/modules/pubgeniusBidAdapter.md @@ -65,16 +65,16 @@ var adUnits = [ adUnitId: '1001', test: true, - // other video parameters as in OpenRTB v2.5 spec + // Other video parameters can be put here as in OpenRTB v2.5 spec. + // This overrides the same parameters in mediaTypes.video. video: { - skip: 1 - - // the following overrides mediaTypes.video of the ad unit placement: 1, + + // w and h overrides mediaTypes.video.playerSize. w: 640, h: 360, - mimes: ['video/mp4'], - protocols: [3], + + skip: 1 } } } diff --git a/test/spec/modules/pubgeniusBidAdapter_spec.js b/test/spec/modules/pubgeniusBidAdapter_spec.js index 57b83fced06..6568f7aa782 100644 --- a/test/spec/modules/pubgeniusBidAdapter_spec.js +++ b/test/spec/modules/pubgeniusBidAdapter_spec.js @@ -370,6 +370,8 @@ describe('pubGENIUS adapter', () => { protocols: [2, 3], api: [1, 2], playbackmethod: [3, 4], + maxduration: 10, + linearity: 1, }, }; bidRequest.params.video = { @@ -394,6 +396,7 @@ describe('pubGENIUS adapter', () => { skipafter: 1, playbackmethod: [3, 4], api: [1, 2], + linearity: 1, }; expect(buildRequests([bidRequest], bidderRequest)).to.deep.equal(expectedRequest); From 3f4922f72fc572e2da70c25fdb8551d18339b81c Mon Sep 17 00:00:00 2001 From: mmoschovas <63253416+mmoschovas@users.noreply.github.com> Date: Wed, 19 May 2021 15:56:13 -0400 Subject: [PATCH 201/303] Remove camel case for adserver.adslot value in RP Analytics Adapter (#6795) --- modules/rubiconAnalyticsAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rubiconAnalyticsAdapter.js b/modules/rubiconAnalyticsAdapter.js index 3237facb2e7..5a2e02b8f89 100644 --- a/modules/rubiconAnalyticsAdapter.js +++ b/modules/rubiconAnalyticsAdapter.js @@ -664,7 +664,7 @@ let rubiconAdapter = Object.assign({}, baseAdapter, { }, 'gam', () => { if (utils.deepAccess(bid, 'ortb2Imp.ext.data.adserver.name') === 'gam') { - return {adSlot: bid.ortb2Imp.ext.data.adserver.adSlot} + return {adSlot: bid.ortb2Imp.ext.data.adserver.adslot} } }, 'pbAdSlot', () => utils.deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'), From f0af380141b95fee70a9e87b2aa483e75a9d5f6a Mon Sep 17 00:00:00 2001 From: Mike Chowla Date: Wed, 19 May 2021 13:12:32 -0700 Subject: [PATCH 202/303] Prebid 4.40.0 Release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 05f68f4a009..ecf293403b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.40.0-pre", + "version": "4.40.0", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From 507c437f9ae74ef8c6bfcd8f1171dbeafac2c2e4 Mon Sep 17 00:00:00 2001 From: Mike Chowla Date: Wed, 19 May 2021 13:48:34 -0700 Subject: [PATCH 203/303] Increment pre version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ecf293403b7..f7176162f8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.40.0", + "version": "4.41.0-pre", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From a031f8d39496414e211dd40d019a4adb05d59031 Mon Sep 17 00:00:00 2001 From: mjaworskiccx <50406214+mjaworskiccx@users.noreply.github.com> Date: Thu, 20 May 2021 10:14:33 +0200 Subject: [PATCH 204/303] CCX Bid Adapter: add support for mediatypes video parameters (#6736) * adomain support * adomain support * adomain support * adomain support * adomain support * video params * docs changes --- modules/ccxBidAdapter.js | 12 ++--- modules/ccxBidAdapter.md | 58 +++---------------------- test/spec/modules/ccxBidAdapter_spec.js | 54 +++++++++++++++++++++++ 3 files changed, 66 insertions(+), 58 deletions(-) diff --git a/modules/ccxBidAdapter.js b/modules/ccxBidAdapter.js index 37b6fdc3e98..2160e539040 100644 --- a/modules/ccxBidAdapter.js +++ b/modules/ccxBidAdapter.js @@ -94,12 +94,12 @@ function _buildBid (bid) { } } - placement.video.protocols = utils.deepAccess(bid, 'params.video.protocols') || SUPPORTED_VIDEO_PROTOCOLS - placement.video.mimes = utils.deepAccess(bid, 'params.video.mimes') || SUPPORTED_VIDEO_MIMES - placement.video.playbackmethod = utils.deepAccess(bid, 'params.video.playbackmethod') || SUPPORTED_VIDEO_PLAYBACK_METHODS - placement.video.skip = utils.deepAccess(bid, 'params.video.skip') || 0 - if (placement.video.skip === 1 && utils.deepAccess(bid, 'params.video.skipafter')) { - placement.video.skipafter = utils.deepAccess(bid, 'params.video.skipafter') + placement.video.protocols = utils.deepAccess(bid, 'mediaTypes.video.protocols') || utils.deepAccess(bid, 'params.video.protocols') || SUPPORTED_VIDEO_PROTOCOLS + placement.video.mimes = utils.deepAccess(bid, 'mediaTypes.video.mimes') || utils.deepAccess(bid, 'params.video.mimes') || SUPPORTED_VIDEO_MIMES + placement.video.playbackmethod = utils.deepAccess(bid, 'mediaTypes.video.playbackmethod') || utils.deepAccess(bid, 'params.video.playbackmethod') || SUPPORTED_VIDEO_PLAYBACK_METHODS + placement.video.skip = utils.deepAccess(bid, 'mediaTypes.video.skip') || utils.deepAccess(bid, 'params.video.skip') || 0 + if (placement.video.skip === 1 && (utils.deepAccess(bid, 'mediaTypes.video.skipafter') || utils.deepAccess(bid, 'params.video.skipafter'))) { + placement.video.skipafter = utils.deepAccess(bid, 'mediaTypes.video.skipafter') || utils.deepAccess(bid, 'params.video.skipafter') } } diff --git a/modules/ccxBidAdapter.md b/modules/ccxBidAdapter.md index 740457dd099..7d86507bccb 100644 --- a/modules/ccxBidAdapter.md +++ b/modules/ccxBidAdapter.md @@ -32,67 +32,21 @@ Module that connects to Clickonometrics's demand sources mediaTypes: { video: { playerSize: [1920, 1080] - + protocols: [2, 3, 5, 6], //default + mimes: ["video/mp4", "video/x-flv"], //default + playbackmethod: [1, 2, 3, 4], //default + skip: 1, //default 0 + skipafter: 5 //delete this key if skip = 0 } }, bids: [ { bidder: "ccx", params: { - placementId: 3287742, - //following options are not required, default values will be used. Uncomment if you want to use custom values - /*video: { - //check OpenRTB documentation for following options description - protocols: [2, 3, 5, 6], //default - mimes: ["video/mp4", "video/x-flv"], //default - playbackmethod: [1, 2, 3, 4], //default - skip: 1, //default 0 - skipafter: 5 //delete this key if skip = 0 - }*/ + placementId: 3287742 } } ] } ]; - -# Pre 1.0 Support - - var adUnits = [ - { - code: 'test-banner', - mediaType: 'banner', - sizes: [300, 250], - bids: [ - { - bidder: "ccx", - params: { - placementId: 3286844 - } - } - ] - }, - { - code: 'test-video', - mediaType: 'video', - sizes: [1920, 1080] - bids: [ - { - bidder: "ccx", - params: { - placementId: 3287742, - //following options are not required, default values will be used. Uncomment if you want to use custom values - /*video: { - //check OpenRTB documentation for following options description - protocols: [2, 3, 5, 6], //default - mimes: ["video/mp4", "video/x-flv"], //default - playbackmethod: [1, 2, 3, 4], //default - skip: 1, //default 0 - skipafter: 5 //delete this key if skip = 0 - }*/ - } - } - ] - } - - ]; \ No newline at end of file diff --git a/test/spec/modules/ccxBidAdapter_spec.js b/test/spec/modules/ccxBidAdapter_spec.js index ef86b391e39..d346a14d38a 100644 --- a/test/spec/modules/ccxBidAdapter_spec.js +++ b/test/spec/modules/ccxBidAdapter_spec.js @@ -434,4 +434,58 @@ describe('ccxAdapter', function () { expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.be.empty; }); }); + describe('mediaTypesVideoParams', function () { + it('Valid video mediaTypes', function () { + let bids = [ + { + adUnitCode: 'video', + auctionId: '0b9de793-8eda-481e-a548-c187d58b28d9', + bidId: '3u94t90ut39tt3t', + bidder: 'ccx', + bidderRequestId: '23ur20r239r2r', + mediaTypes: { + video: { + playerSize: [[640, 480]], + protocols: [2, 3, 5, 6], + mimes: ['video/mp4', 'video/x-flv'], + playbackmethod: [1, 2, 3, 4], + skip: 1, + skipafter: 5 + } + }, + params: { + placementId: 608 + }, + sizes: [[640, 480]], + transactionId: 'aefddd38-cfa0-48ab-8bdd-325de4bab5f9' + } + ]; + + let imps = [ + { + video: { + w: 640, + h: 480, + protocols: [2, 3, 5, 6], + mimes: ['video/mp4', 'video/x-flv'], + playbackmethod: [1, 2, 3, 4], + skip: 1, + skipafter: 5 + }, + id: '3u94t90ut39tt3t', + secure: 1, + ext: { + pid: 608 + } + } + ]; + + let bidsClone = utils.deepClone(bids); + + let response = spec.buildRequests(bidsClone, {'bids': bidsClone}); + let data = JSON.parse(response.data); + + expect(data.imp).to.deep.have.same.members(imps); + }); + }); }); From a2401ae1aa6b1158cfc376765962ccc2e3e4e046 Mon Sep 17 00:00:00 2001 From: Kajan Umakanthan Date: Thu, 20 May 2021 05:39:08 -0700 Subject: [PATCH 205/303] Index Exchange Bid Adapter: adds support for floc (#6758) --- modules/ixBidAdapter.js | 92 +++++++++++---------- test/spec/modules/ixBidAdapter_spec.js | 106 ++++++++++++++++++++++++- 2 files changed, 157 insertions(+), 41 deletions(-) diff --git a/modules/ixBidAdapter.js b/modules/ixBidAdapter.js index 64a3237e02a..3be919453a3 100644 --- a/modules/ixBidAdapter.js +++ b/modules/ixBidAdapter.js @@ -23,6 +23,33 @@ const PRICE_TO_DOLLAR_FACTOR = { const USER_SYNC_URL = 'https://js-sec.indexww.com/um/ixmatch.html'; const FLOOR_SOURCE = { PBJS: 'p', IX: 'x' }; +// determines which eids we send and the rtiPartner field in ext +const SOURCE_RTI_MAPPING = { + 'liveramp.com': 'idl', + 'netid.de': 'NETID', + 'neustar.biz': 'fabrickId', + 'zeotap.com': 'zeotapIdPlus', + 'uidapi.com': 'UID2', + 'adserver.org': 'TDID' +}; + +const PROVIDERS = [ + 'britepoolid', + 'id5id', + 'lipbid', + 'haloId', + 'criteoId', + 'lotamePanoramaId', + 'merkleId', + 'parrableId', + 'connectid', + 'sharedid', + 'tapadId', + 'quantcastId', + 'pubcid', + 'TDID', + 'flocId' +] /** * Transform valid bid request config object to banner impression object that will be sent to ad server. @@ -285,35 +312,37 @@ function getBidRequest(id, impressions) { * From the userIdAsEids array, filter for the ones our adserver can use, and modify them * for our purposes, e.g. add rtiPartner * @param {array} allEids userIdAsEids passed in by prebid + * @param {object} flocId flocId passed in by prebid * @return {object} contains toSend (eids to send to the adserver) and seenSources (used to filter * identity info from IX Library) */ -function getEidInfo(allEids) { - // determines which eids we send and the rtiPartner field in ext - var sourceRTIMapping = { - 'liveramp.com': 'idl', - 'netid.de': 'NETID', - 'neustar.biz': 'fabrickId', - 'zeotap.com': 'zeotapIdPlus', - 'uidapi.com': 'UID2' - }; - var toSend = []; - var seenSources = {}; +function getEidInfo(allEids, flocData) { + let toSend = []; + let seenSources = {}; if (utils.isArray(allEids)) { - for (var i = 0; i < allEids.length; i++) { - if (sourceRTIMapping[allEids[i].source] && utils.deepAccess(allEids[i], 'uids.0')) { - seenSources[allEids[i].source] = 1; - allEids[i].uids[0].ext = { - rtiPartner: sourceRTIMapping[allEids[i].source] + for (const eid of allEids) { + if (SOURCE_RTI_MAPPING[eid.source] && utils.deepAccess(eid, 'uids.0')) { + seenSources[eid.source] = true; + eid.uids[0].ext = { + rtiPartner: SOURCE_RTI_MAPPING[eid.source] }; - delete allEids[i].uids[0].atype; - toSend.push(allEids[i]); + delete eid.uids[0].atype; + toSend.push(eid); } } } - return { toSend: toSend, seenSources: seenSources }; -} + const isValidFlocId = flocData && flocData.id && flocData.version; + if (isValidFlocId) { + const flocEid = { + 'source': 'chrome.com', + 'uids': [{ 'id': flocData.id, 'ext': { 'rtiPartner': 'flocId', 'ver': flocData.version } }] + }; + toSend.push(flocEid); + seenSources['chrome.com'] = true; + } + return { toSend, seenSources }; +} /** * Builds a request object to be sent to the ad server based on bid requests. * @@ -327,10 +356,9 @@ function getEidInfo(allEids) { function buildRequest(validBidRequests, bidderRequest, impressions, version) { // Always use secure HTTPS protocol. let baseUrl = SECURE_BID_URL; - // Get ids from Prebid User ID Modules - var eidInfo = getEidInfo(utils.deepAccess(validBidRequests, '0.userIdAsEids')); - var userEids = eidInfo.toSend; + let eidInfo = getEidInfo(utils.deepAccess(validBidRequests, '0.userIdAsEids'), utils.deepAccess(validBidRequests, '0.userId.flocId')); + let userEids = eidInfo.toSend; // RTI ids will be included in the bid request if the function getIdentityInfo() is loaded // and if the data for the partner exist @@ -570,23 +598,7 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { function _getUserIds(bidRequest) { const userIds = bidRequest.userId || {}; - const PROVIDERS = [ - 'britepoolid', - 'id5id', - 'lipbid', - 'haloId', - 'criteoId', - 'lotamePanoramaId', - 'merkleId', - 'parrableId', - 'connectid', - 'sharedid', - 'tapadId', - 'quantcastId', - 'pubcid' - ] - - return PROVIDERS.filter(provider => utils.deepAccess(userIds, provider)) + return PROVIDERS.filter(provider => userIds[provider]); } /** diff --git a/test/spec/modules/ixBidAdapter_spec.js b/test/spec/modules/ixBidAdapter_spec.js index e0d45913fd9..50920965b60 100644 --- a/test/spec/modules/ixBidAdapter_spec.js +++ b/test/spec/modules/ixBidAdapter_spec.js @@ -462,9 +462,23 @@ describe('IndexexchangeAdapter', function () { ]; const DEFAULT_USERID_BID_DATA = { - lotamePanoramaId: 'bd738d136bdaa841117fe9b331bb4' + lotamePanoramaId: 'bd738d136bdaa841117fe9b331bb4', + flocId: {id: '1234', version: 'chrome.1.2'} }; + const DEFAULT_FLOC_USERID_PAYLOAD = [ + { + source: 'chrome.com', + uids: [{ + id: DEFAULT_USERID_BID_DATA.flocId.id, + ext: { + rtiPartner: 'flocId', + ver: DEFAULT_USERID_BID_DATA.flocId.version + } + }] + } + ]; + describe('inherited functions', function () { it('should exists and is a function', function () { const adapter = newBidder(spec); @@ -903,6 +917,96 @@ describe('IndexexchangeAdapter', function () { expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[4]); }); + it('IX adapter reads floc id from prebid userId and adds it to eids when there is not other eids', function() { + const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); + cloneValidBid[0].userId = utils.deepClone(DEFAULT_USERID_BID_DATA); + const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; + const payload = JSON.parse(request.data.r); + + expect(payload.user.eids).to.have.lengthOf(1); + expect(payload.user.eids).to.deep.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); + }); + + it('IX adapter reads floc id from prebid userId and appends it to eids', function() { + const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); + cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); + cloneValidBid[0].userId = utils.deepClone(DEFAULT_USERID_BID_DATA); + const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; + const payload = JSON.parse(request.data.r); + + expect(payload.user.eids).to.have.lengthOf(6); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[0]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[1]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[2]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[3]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[4]); + expect(payload.user.eids).to.deep.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); + }); + + it('IX adapter reads empty floc obj from prebid userId it, floc is not added to eids', function() { + const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); + cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); + cloneValidBid[0].userId = {'flocId': {}} + const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; + const payload = JSON.parse(request.data.r); + + expect(payload.user.eids).to.have.lengthOf(5); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[0]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[1]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[2]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[3]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[4]); + expect(payload.user.eids).should.not.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); + }); + + it('IX adapter reads floc obj from prebid userId it version is missing, floc is not added to eids', function() { + const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); + cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); + cloneValidBid[0].userId = {'flocId': {'id': 'abcd'}} + const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; + const payload = JSON.parse(request.data.r); + + expect(payload.user.eids).to.have.lengthOf(5); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[0]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[1]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[2]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[3]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[4]); + expect(payload.user.eids).should.not.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); + }); + + it('IX adapter reads floc obj from prebid userId it ID is missing, floc is not added to eids', function() { + const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); + cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); + cloneValidBid[0].userId = {'flocId': {'version': 'chrome.a.b.c'}} + const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; + const payload = JSON.parse(request.data.r); + + expect(payload.user.eids).to.have.lengthOf(5); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[0]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[1]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[2]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[3]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[4]); + expect(payload.user.eids).should.not.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); + }); + + it('IX adapter reads floc id with empty id from prebid userId and it does not added to eids', function() { + const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); + cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); + cloneValidBid[0].userId = {flocID: {id: '', ver: 'chrome.1.2.3'}}; + const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; + const payload = JSON.parse(request.data.r); + + expect(payload.user.eids).to.have.lengthOf(5); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[0]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[1]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[2]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[3]); + expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[4]); + expect(payload.user.eids).should.not.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); + }); + it('We continue to send in IXL identity info and Prebid takes precedence over IXL', function () { validIdentityResponse = { AdserverOrgIp: { From 1adc2e70ef6df386ee6abee95c1615bb652f9038 Mon Sep 17 00:00:00 2001 From: rcheptanariu <35690143+rcheptanariu@users.noreply.github.com> Date: Thu, 20 May 2021 15:53:59 +0300 Subject: [PATCH 206/303] InvibesBidAdapter - multiposition support & support for multiple id modules (#6506) --- modules/invibesBidAdapter.js | 119 ++++++++++---------- test/spec/modules/invibesBidAdapter_spec.js | 41 +++++-- 2 files changed, 95 insertions(+), 65 deletions(-) diff --git a/modules/invibesBidAdapter.js b/modules/invibesBidAdapter.js index d4d26b1e017..7d2942eea55 100644 --- a/modules/invibesBidAdapter.js +++ b/modules/invibesBidAdapter.js @@ -8,10 +8,10 @@ const CONSTANTS = { SYNC_ENDPOINT: 'https://k.r66net.com/GetUserSync', TIME_TO_LIVE: 300, DEFAULT_CURRENCY: 'EUR', - PREBID_VERSION: 5, + PREBID_VERSION: 6, METHOD: 'GET', INVIBES_VENDOR_ID: 436, - USERID_PROVIDERS: ['pubcid', 'pubProvidedId'] + USERID_PROVIDERS: ['pubcid', 'pubProvidedId', 'uid2', 'zeotapIdPlus', 'id5id'] }; const storage = getStorageManager(CONSTANTS.INVIBES_VENDOR_ID); @@ -168,12 +168,6 @@ function handleResponse(responseObj, bidRequests) { responseObj = responseObj.body || responseObj; responseObj = responseObj.videoAdContentResult || responseObj; - let bidModel = responseObj.BidModel; - if (typeof bidModel !== 'object') { - utils.logInfo('Invibes Adapter - Bidding is not configured'); - return []; - } - if (typeof invibes.bidResponse === 'object') { utils.logInfo('Invibes Adapter - Bid response already received. Invibes only responds to one bid request per user visit'); return []; @@ -181,51 +175,69 @@ function handleResponse(responseObj, bidRequests) { invibes.bidResponse = responseObj; - let ads = responseObj.Ads; + const bidResponses = []; + for (let i = 0; i < bidRequests.length; i++) { + let bidRequest = bidRequests[i]; - if (!Array.isArray(ads) || ads.length < 1) { - if (responseObj.AdReason != null) { - utils.logInfo('Invibes Adapter - ' + responseObj.AdReason); + let requestPlacement = null; + if (responseObj.AdPlacements != null) { + for (let j = 0; j < responseObj.AdPlacements.length; j++) { + let bidModel = responseObj.AdPlacements[j].BidModel; + if (bidModel != null && bidModel.PlacementId == bidRequest.params.placementId) { + requestPlacement = responseObj.AdPlacements[j]; + break; + } + } + } else { + let bidModel = responseObj.BidModel; + if (bidModel != null && bidModel.PlacementId == bidRequest.params.placementId) { + requestPlacement = responseObj; + } } - utils.logInfo('Invibes Adapter - No ads available'); - return []; + let bid = createBid(bidRequest, requestPlacement); + if (bid !== null) { + bidResponses.push(bid); + } } - let ad = ads[0]; + return bidResponses; +} - if (bidModel.PlacementId == null) { - utils.logInfo('Invibes Adapter - No Placement Id in response'); - return []; +function createBid(bidRequest, requestPlacement) { + if (requestPlacement === null || requestPlacement.BidModel === null) { + utils.logInfo('Invibes Adapter - Placement not configured for bidding ' + bidRequest.params.placementId); + return null; } - const bidResponses = []; - for (let i = 0; i < bidRequests.length; i++) { - let bidRequest = bidRequests[i]; - - if (bidModel.PlacementId == bidRequest.params.placementId) { - let size = getBiggerSize(bidRequest.sizes); - - bidResponses.push({ - requestId: bidRequest.bidId, - cpm: ad.BidPrice, - width: bidModel.Width || size[0], - height: bidModel.Height || size[1], - creativeId: ad.VideoExposedId, - currency: bidModel.Currency || CONSTANTS.DEFAULT_CURRENCY, - netRevenue: true, - ttl: CONSTANTS.TIME_TO_LIVE, - ad: renderCreative(bidModel) - }); - - const now = Date.now(); - ivLogger.info('Bid auction started at ' + bidModel.AuctionStartTime + ' . Invibes registered the bid at ' + now + ' ; bid request took a total of ' + (now - bidModel.AuctionStartTime) + ' ms.'); - } else { - utils.logInfo('Invibes Adapter - Incorrect Placement Id: ' + bidRequest.params.placementId); + let bidModel = requestPlacement.BidModel; + let ads = requestPlacement.Ads; + if (!Array.isArray(ads) || ads.length < 1) { + if (requestPlacement.AdReason != null) { + utils.logInfo('Invibes Adapter - No ads ' + requestPlacement.AdReason); } + + utils.logInfo('Invibes Adapter - No ads available'); + return null; } - return bidResponses; + let ad = ads[0]; + let size = getBiggerSize(bidRequest.sizes); + + const now = Date.now(); + utils.logInfo('Bid auction started at ' + bidModel.AuctionStartTime + ' . Invibes registered the bid at ' + now + ' ; bid request took a total of ' + (now - bidModel.AuctionStartTime) + ' ms.'); + + return { + requestId: bidRequest.bidId, + cpm: ad.BidPrice, + width: bidModel.Width || size[0], + height: bidModel.Height || size[1], + creativeId: ad.VideoExposedId, + currency: bidModel.Currency || CONSTANTS.DEFAULT_CURRENCY, + netRevenue: true, + ttl: CONSTANTS.TIME_TO_LIVE, + ad: renderCreative(bidModel) + }; } function generateRandomId() { @@ -357,17 +369,6 @@ function getCappedCampaignsAsString() { .join(','); } -const noop = function () { -}; - -function initLogger() { - if (storage.hasLocalStorage() && localStorage.InvibesDEBUG) { - return window.console; - } - - return {info: noop, error: noop, log: noop, warn: noop, debug: noop}; -} - function buildSyncUrl() { let syncUrl = _customUserSync || CONSTANTS.SYNC_ENDPOINT; syncUrl += '?visitId=' + invibes.visitId; @@ -392,7 +393,7 @@ function readGdprConsent(gdprConsent) { if (!gdprConsent.vendorData.gdprApplies || gdprConsent.vendorData.hasGlobalConsent) { var index; - for (index = 0; index < invibes.purposes; ++index) { + for (index = 0; index < invibes.purposes.length; ++index) { invibes.purposes[index] = true; } @@ -448,7 +449,13 @@ function tryCopyValueToArray(value, target, length) { } if (value.hasOwnProperty(prop)) { - target[i] = !((value[prop] === false || value[prop] === 'false' || value[prop] == null)); + let parsedProp = parseInt(prop); + if (isNaN(parsedProp)) { + target[i] = !((value[prop] === false || value[prop] === 'false' || value[prop] == null)); + } else { + target[parsedProp - 1] = !((value[prop] === false || value[prop] === 'false' || value[prop] == null)); + } + i++; } } @@ -515,8 +522,6 @@ function getVendorLegitimateInterest(vendorData) { return {}; } -const ivLogger = initLogger(); - /// Local domain cookie management ===================== invibes.Uid = { generate: function () { diff --git a/test/spec/modules/invibesBidAdapter_spec.js b/test/spec/modules/invibesBidAdapter_spec.js index ee3624b5b16..6a59bf98dad 100644 --- a/test/spec/modules/invibesBidAdapter_spec.js +++ b/test/spec/modules/invibesBidAdapter_spec.js @@ -736,6 +736,30 @@ describe('invibesBidAdapter:', function () { ` }]; + let multiResponse = { + AdPlacements: [{ + Ads: [{ + BidPrice: 0.5, + VideoExposedId: 123 + }], + BidModel: { + BidVersion: 1, + PlacementId: '12345', + AuctionStartTime: Date.now(), + CreativeHtml: '' + } + }] + }; + + let invalidResponse = { + AdPlacements: [{ + Ads: [{ + BidPrice: 0.5, + VideoExposedId: 123 + }] + }] + }; + context('when the response is not valid', function () { it('handles response with no bids requested', function () { let emptyResult = spec.interpretResponse({body: response}); @@ -781,24 +805,25 @@ describe('invibesBidAdapter:', function () { let emptyResult = spec.interpretResponse({BidModel: {}, Ads: [{BidPrice: 1}]}, {bidRequests}); expect(emptyResult).to.be.empty; }); + + it('handles response when bid model is missing', function () { + let emptyResult = spec.interpretResponse(invalidResponse); + expect(emptyResult).to.be.empty; + }); }); - context('when the response is valid', function () { - it('responds with a valid bid', function () { - // top.window.invibes.setCookie('a', 'b', 370); - // top.window.invibes.setCookie('c', 'd', 0); - let result = spec.interpretResponse({body: response}, {bidRequests}); + context('when the multiresponse is valid', function () { + it('responds with a valid multiresponse bid', function () { + let result = spec.interpretResponse({body: multiResponse}, {bidRequests}); expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); }); - it('responds with a valid bid and uses logger', function () { - localStorage.InvibesDEBUG = true; + it('responds with a valid singleresponse bid', function () { let result = spec.interpretResponse({body: response}, {bidRequests}); expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); }); it('does not make multiple bids', function () { - localStorage.InvibesDEBUG = false; let result = spec.interpretResponse({body: response}, {bidRequests}); let secondResult = spec.interpretResponse({body: response}, {bidRequests}); expect(secondResult).to.be.empty; From 8388dd3e00c4112c6a5d21cc0930fc1c57c491a7 Mon Sep 17 00:00:00 2001 From: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Date: Thu, 20 May 2021 14:34:36 -0400 Subject: [PATCH 207/303] appnexus bid adapter: add support for flocid (#6801) --- modules/appnexusBidAdapter.js | 1 + test/spec/modules/appnexusBidAdapter_spec.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index d28bf391aa5..df686f15885 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -244,6 +244,7 @@ export const spec = { if (bidRequests[0].userId) { let eids = []; + addUserId(eids, utils.deepAccess(bidRequests[0], `userId.flocId.id`), 'chrome.com', null); addUserId(eids, utils.deepAccess(bidRequests[0], `userId.criteoId`), 'criteo.com', null); addUserId(eids, utils.deepAccess(bidRequests[0], `userId.netId`), 'netid.de', null); addUserId(eids, utils.deepAccess(bidRequests[0], `userId.idl_env`), 'liveramp.com', null); diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index c875cba12bc..2c8703e648d 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -875,7 +875,11 @@ describe('AppNexusAdapter', function () { tdid: 'sample-userid', criteoId: 'sample-criteo-userid', netId: 'sample-netId-userid', - idl_env: 'sample-idl-userid' + idl_env: 'sample-idl-userid', + flocId: { + id: 'sample-flocid-value', + version: 'chrome.1.0' + } } }); @@ -892,6 +896,11 @@ describe('AppNexusAdapter', function () { id: 'sample-criteo-userid', }); + expect(payload.eids).to.deep.include({ + source: 'chrome.com', + id: 'sample-flocid-value' + }); + expect(payload.eids).to.deep.include({ source: 'netid.de', id: 'sample-netId-userid', From 2e2b4258a5cf12e2d744b7d1f344081db2aeb9f7 Mon Sep 17 00:00:00 2001 From: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Date: Thu, 20 May 2021 15:04:21 -0400 Subject: [PATCH 208/303] appnexus bid adapter: add support for uid2 (#6802) --- modules/appnexusBidAdapter.js | 1 + test/spec/modules/appnexusBidAdapter_spec.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index df686f15885..404a8c04d14 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -249,6 +249,7 @@ export const spec = { addUserId(eids, utils.deepAccess(bidRequests[0], `userId.netId`), 'netid.de', null); addUserId(eids, utils.deepAccess(bidRequests[0], `userId.idl_env`), 'liveramp.com', null); addUserId(eids, utils.deepAccess(bidRequests[0], `userId.tdid`), 'adserver.org', 'TDID'); + addUserId(eids, utils.deepAccess(bidRequests[0], `userId.uid2.id`), 'uidapi.com', 'UID2'); if (eids.length) { payload.eids = eids; diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 2c8703e648d..4baecdd1ba8 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -873,6 +873,7 @@ describe('AppNexusAdapter', function () { const bidRequest = Object.assign({}, bidRequests[0], { userId: { tdid: 'sample-userid', + uid2: { id: 'sample-uid2-value' }, criteoId: 'sample-criteo-userid', netId: 'sample-netId-userid', idl_env: 'sample-idl-userid', @@ -909,7 +910,13 @@ describe('AppNexusAdapter', function () { expect(payload.eids).to.deep.include({ source: 'liveramp.com', id: 'sample-idl-userid' - }) + }); + + expect(payload.eids).to.deep.include({ + source: 'uidapi.com', + id: 'sample-uid2-value', + rti_partner: 'UID2' + }); }); it('should populate iab_support object at the root level if omid support is detected', function () { From 889ff70bdd69f5058a903d124c8506e1f3658bb8 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 20 May 2021 15:18:59 -0400 Subject: [PATCH 209/303] Delete xhbBidAdapter.js --- modules/xhbBidAdapter.js | 457 --------------------------------------- 1 file changed, 457 deletions(-) delete mode 100644 modules/xhbBidAdapter.js diff --git a/modules/xhbBidAdapter.js b/modules/xhbBidAdapter.js deleted file mode 100644 index 9363eb97ddc..00000000000 --- a/modules/xhbBidAdapter.js +++ /dev/null @@ -1,457 +0,0 @@ -import { Renderer } from '../src/Renderer.js'; -import * as utils from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import find from 'core-js-pure/features/array/find.js'; -import includes from 'core-js-pure/features/array/includes.js'; - -const BIDDER_CODE = 'xhb'; -const URL = 'https://ib.adnxs.com/ut/v3/prebid'; -const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration', - 'startdelay', 'skippable', 'playback_method', 'frameworks']; -const USER_PARAMS = ['age', 'external_uid', 'segments', 'gender', 'dnt', 'language']; -const NATIVE_MAPPING = { - body: 'description', - cta: 'ctatext', - image: { - serverName: 'main_image', - requiredParams: { required: true }, - minimumParams: { sizes: [{}] }, - }, - icon: { - serverName: 'icon', - requiredParams: { required: true }, - minimumParams: { sizes: [{}] }, - }, - sponsoredBy: 'sponsored_by', -}; -const SOURCE = 'pbjs'; - -export const spec = { - code: BIDDER_CODE, - aliases: [], - supportedMediaTypes: [BANNER, VIDEO, NATIVE], - - /** - * Determines whether or not the given bid request is valid. - * - * @param {object} bid The bid to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!(bid.params.placementId || (bid.params.member && bid.params.invCode)); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(bidRequests, bidderRequest) { - const tags = bidRequests.map(bidToTag); - const userObjBid = find(bidRequests, hasUserInfo); - let userObj; - if (userObjBid) { - userObj = {}; - Object.keys(userObjBid.params.user) - .filter(param => includes(USER_PARAMS, param)) - .forEach(param => userObj[param] = userObjBid.params.user[param]); - } - - const memberIdBid = find(bidRequests, hasMemberId); - const member = memberIdBid ? parseInt(memberIdBid.params.member, 10) : 0; - - const payload = { - tags: [...tags], - user: userObj, - sdk: { - source: SOURCE, - version: '$prebid.version$' - } - }; - if (member > 0) { - payload.member_id = member; - } - - if (bidderRequest && bidderRequest.gdprConsent) { - // note - objects for impbus use underscore instead of camelCase - payload.gdpr_consent = { - consent_string: bidderRequest.gdprConsent.consentString, - consent_required: bidderRequest.gdprConsent.gdprApplies - }; - } - - const payloadString = JSON.stringify(payload); - return { - method: 'POST', - url: URL, - data: payloadString, - bidderRequest - }; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, {bidderRequest}) { - serverResponse = serverResponse.body; - const bids = []; - if (!serverResponse || serverResponse.error) { - let errorMessage = `in response for ${bidderRequest.bidderCode} adapter`; - if (serverResponse && serverResponse.error) { errorMessage += `: ${serverResponse.error}`; } - utils.logError(errorMessage); - return bids; - } - - if (serverResponse.tags) { - serverResponse.tags.forEach(serverBid => { - const rtbBid = getRtbBid(serverBid); - if (rtbBid) { - if (rtbBid.cpm !== 0 && includes(this.supportedMediaTypes, rtbBid.ad_type)) { - const bid = newBid(serverBid, rtbBid, bidderRequest); - bid.mediaType = parseMediaType(rtbBid); - bids.push(bid); - } - } - }); - } - return bids; - }, - - getUserSyncs: function(syncOptions) { - if (syncOptions.iframeEnabled) { - return [{ - type: 'iframe', - url: 'https://acdn.adnxs.com/dmp/async_usersync.html' - }]; - } - } -}; - -function newRenderer(adUnitCode, rtbBid, rendererOptions = {}) { - const renderer = Renderer.install({ - id: rtbBid.renderer_id, - url: rtbBid.renderer_url, - config: rendererOptions, - loaded: false, - }); - - try { - renderer.setRender(outstreamRender); - } catch (err) { - utils.logWarn('Prebid Error calling setRender on renderer', err); - } - - renderer.setEventHandlers({ - impression: () => utils.logMessage('xhb outstream video impression event'), - loaded: () => utils.logMessage('xhb outstream video loaded event'), - ended: () => { - utils.logMessage('xhb outstream renderer video event'); - document.querySelector(`#${adUnitCode}`).style.display = 'none'; - } - }); - return renderer; -} - -/* Turn keywords parameter into ut-compatible format */ -function getKeywords(keywords) { - let arrs = []; - - utils._each(keywords, (v, k) => { - if (utils.isArray(v)) { - let values = []; - utils._each(v, (val) => { - val = utils.getValueString('keywords.' + k, val); - if (val) { values.push(val); } - }); - v = values; - } else { - v = utils.getValueString('keywords.' + k, v); - if (utils.isStr(v)) { - v = [v]; - } else { - return; - } // unsuported types - don't send a key - } - arrs.push({key: k, value: v}); - }); - - return arrs; -} - -/** - * Unpack the Server's Bid into a Prebid-compatible one. - * @param serverBid - * @param rtbBid - * @param bidderRequest - * @return Bid - */ -function newBid(serverBid, rtbBid, bidderRequest) { - const bid = { - requestId: serverBid.uuid, - cpm: 0.00, - creativeId: rtbBid.creative_id, - dealId: 99999999, - currency: 'USD', - netRevenue: true, - ttl: 300, - appnexus: { - buyerMemberId: rtbBid.buyer_member_id - } - }; - - if (rtbBid.rtb.video) { - Object.assign(bid, { - width: rtbBid.rtb.video.player_width, - height: rtbBid.rtb.video.player_height, - vastUrl: rtbBid.rtb.video.asset_url, - vastImpUrl: rtbBid.notify_url, - ttl: 3600 - }); - // This supports Outstream Video - if (rtbBid.renderer_url) { - const rendererOptions = utils.deepAccess( - bidderRequest.bids[0], - 'renderer.options' - ); - - Object.assign(bid, { - adResponse: serverBid, - renderer: newRenderer(bid.adUnitCode, rtbBid, rendererOptions) - }); - bid.adResponse.ad = bid.adResponse.ads[0]; - bid.adResponse.ad.video = bid.adResponse.ad.rtb.video; - } - } else if (rtbBid.rtb[NATIVE]) { - const nativeAd = rtbBid.rtb[NATIVE]; - bid[NATIVE] = { - title: nativeAd.title, - body: nativeAd.desc, - cta: nativeAd.ctatext, - sponsoredBy: nativeAd.sponsored, - clickUrl: nativeAd.link.url, - clickTrackers: nativeAd.link.click_trackers, - impressionTrackers: nativeAd.impression_trackers, - javascriptTrackers: nativeAd.javascript_trackers, - }; - if (nativeAd.main_img) { - bid['native'].image = { - url: nativeAd.main_img.url, - height: nativeAd.main_img.height, - width: nativeAd.main_img.width, - }; - } - if (nativeAd.icon) { - bid['native'].icon = { - url: nativeAd.icon.url, - height: nativeAd.icon.height, - width: nativeAd.icon.width, - }; - } - } else { - Object.assign(bid, { - width: rtbBid.rtb.banner.width, - height: rtbBid.rtb.banner.height, - ad: rtbBid.rtb.banner.content - }); - try { - const url = rtbBid.rtb.trackers[0].impression_urls[0]; - const tracker = utils.createTrackPixelHtml(url); - bid.ad += tracker; - } catch (error) { - utils.logError('Error appending tracking pixel', error); - } - } - - return bid; -} - -function bidToTag(bid) { - const tag = {}; - tag.sizes = transformSizes(bid.sizes); - tag.primary_size = tag.sizes[0]; - tag.ad_types = []; - tag.uuid = bid.bidId; - if (bid.params.placementId) { - tag.id = parseInt(bid.params.placementId, 10); - } else { - tag.code = bid.params.invCode; - } - tag.allow_smaller_sizes = bid.params.allowSmallerSizes || false; - tag.use_pmt_rule = bid.params.usePaymentRule || false; - tag.prebid = true; - tag.disable_psa = true; - if (bid.params.reserve) { - tag.reserve = bid.params.reserve; - } - if (bid.params.position) { - tag.position = {'above': 1, 'below': 2}[bid.params.position] || 0; - } - if (bid.params.trafficSourceCode) { - tag.traffic_source_code = bid.params.trafficSourceCode; - } - if (bid.params.privateSizes) { - tag.private_sizes = transformSizes(bid.params.privateSizes); - } - if (bid.params.supplyType) { - tag.supply_type = bid.params.supplyType; - } - if (bid.params.pubClick) { - tag.pubclick = bid.params.pubClick; - } - if (bid.params.extInvCode) { - tag.ext_inv_code = bid.params.extInvCode; - } - if (bid.params.externalImpId) { - tag.external_imp_id = bid.params.externalImpId; - } - if (!utils.isEmpty(bid.params.keywords)) { - tag.keywords = getKeywords(bid.params.keywords); - } - - if (bid.mediaType === NATIVE || utils.deepAccess(bid, `mediaTypes.${NATIVE}`)) { - tag.ad_types.push(NATIVE); - - if (bid.nativeParams) { - const nativeRequest = buildNativeRequest(bid.nativeParams); - tag[NATIVE] = {layouts: [nativeRequest]}; - } - } - - const videoMediaType = utils.deepAccess(bid, `mediaTypes.${VIDEO}`); - const context = utils.deepAccess(bid, 'mediaTypes.video.context'); - - if (bid.mediaType === VIDEO || videoMediaType) { - tag.ad_types.push(VIDEO); - } - - // instream gets vastUrl, outstream gets vastXml - if (bid.mediaType === VIDEO || (videoMediaType && context !== 'outstream')) { - tag.require_asset_url = true; - } - - if (bid.params.video) { - tag.video = {}; - // place any valid video params on the tag - Object.keys(bid.params.video) - .filter(param => includes(VIDEO_TARGETING, param)) - .forEach(param => tag.video[param] = bid.params.video[param]); - } - - if ( - (utils.isEmpty(bid.mediaType) && utils.isEmpty(bid.mediaTypes)) || - (bid.mediaType === BANNER || (bid.mediaTypes && bid.mediaTypes[BANNER])) - ) { - tag.ad_types.push(BANNER); - } - - return tag; -} - -/* Turn bid request sizes into ut-compatible format */ -function transformSizes(requestSizes) { - let sizes = []; - let sizeObj = {}; - - if (utils.isArray(requestSizes) && requestSizes.length === 2 && - !utils.isArray(requestSizes[0])) { - sizeObj.width = parseInt(requestSizes[0], 10); - sizeObj.height = parseInt(requestSizes[1], 10); - sizes.push(sizeObj); - } else if (typeof requestSizes === 'object') { - for (let i = 0; i < requestSizes.length; i++) { - let size = requestSizes[i]; - sizeObj = {}; - sizeObj.width = parseInt(size[0], 10); - sizeObj.height = parseInt(size[1], 10); - sizes.push(sizeObj); - } - } - - return sizes; -} - -function hasUserInfo(bid) { - return !!bid.params.user; -} - -function hasMemberId(bid) { - return !!parseInt(bid.params.member, 10); -} - -function getRtbBid(tag) { - return tag && tag.ads && tag.ads.length && find(tag.ads, ad => ad.rtb); -} - -function buildNativeRequest(params) { - const request = {}; - - // map standard prebid native asset identifier to /ut parameters - // e.g., tag specifies `body` but /ut only knows `description`. - // mapping may be in form {tag: ''} or - // {tag: {serverName: '', requiredParams: {...}}} - Object.keys(params).forEach(key => { - // check if one of the forms is used, otherwise - // a mapping wasn't specified so pass the key straight through - const requestKey = - (NATIVE_MAPPING[key] && NATIVE_MAPPING[key].serverName) || - NATIVE_MAPPING[key] || - key; - - // required params are always passed on request - const requiredParams = NATIVE_MAPPING[key] && NATIVE_MAPPING[key].requiredParams; - request[requestKey] = Object.assign({}, requiredParams, params[key]); - - // minimum params are passed if no non-required params given on adunit - const minimumParams = NATIVE_MAPPING[key] && NATIVE_MAPPING[key].minimumParams; - - if (requiredParams && minimumParams) { - // subtract required keys from adunit keys - const adunitKeys = Object.keys(params[key]); - const requiredKeys = Object.keys(requiredParams); - const remaining = adunitKeys.filter(key => !includes(requiredKeys, key)); - - // if none are left over, the minimum params needs to be sent - if (remaining.length === 0) { - request[requestKey] = Object.assign({}, request[requestKey], minimumParams); - } - } - }); - - return request; -} - -function outstreamRender(bid) { - // push to render queue because ANOutstreamVideo may not be loaded yet - bid.renderer.push(() => { - window.ANOutstreamVideo.renderAd({ - tagId: bid.adResponse.tag_id, - sizes: [bid.getSize().split('x')], - targetId: bid.adUnitCode, // target div id to render video - uuid: bid.adResponse.uuid, - adResponse: bid.adResponse, - rendererOptions: bid.renderer.getConfig() - }, handleOutstreamRendererEvents.bind(null, bid)); - }); -} - -function handleOutstreamRendererEvents(bid, id, eventName) { - bid.renderer.handleVideoEvent({ id, eventName }); -} - -function parseMediaType(rtbBid) { - const adType = rtbBid.ad_type; - if (adType === VIDEO) { - return VIDEO; - } else if (adType === NATIVE) { - return NATIVE; - } else { - return BANNER; - } -} - -registerBidder(spec); From bb02ee1dea06ed8ecc6f779ebcd541092b06e39c Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 20 May 2021 16:02:31 -0400 Subject: [PATCH 210/303] Restore xhb (#6803) --- modules/xhbBidAdapter.js | 457 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 457 insertions(+) create mode 100644 modules/xhbBidAdapter.js diff --git a/modules/xhbBidAdapter.js b/modules/xhbBidAdapter.js new file mode 100644 index 00000000000..9363eb97ddc --- /dev/null +++ b/modules/xhbBidAdapter.js @@ -0,0 +1,457 @@ +import { Renderer } from '../src/Renderer.js'; +import * as utils from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import find from 'core-js-pure/features/array/find.js'; +import includes from 'core-js-pure/features/array/includes.js'; + +const BIDDER_CODE = 'xhb'; +const URL = 'https://ib.adnxs.com/ut/v3/prebid'; +const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration', + 'startdelay', 'skippable', 'playback_method', 'frameworks']; +const USER_PARAMS = ['age', 'external_uid', 'segments', 'gender', 'dnt', 'language']; +const NATIVE_MAPPING = { + body: 'description', + cta: 'ctatext', + image: { + serverName: 'main_image', + requiredParams: { required: true }, + minimumParams: { sizes: [{}] }, + }, + icon: { + serverName: 'icon', + requiredParams: { required: true }, + minimumParams: { sizes: [{}] }, + }, + sponsoredBy: 'sponsored_by', +}; +const SOURCE = 'pbjs'; + +export const spec = { + code: BIDDER_CODE, + aliases: [], + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {object} bid The bid to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + return !!(bid.params.placementId || (bid.params.member && bid.params.invCode)); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(bidRequests, bidderRequest) { + const tags = bidRequests.map(bidToTag); + const userObjBid = find(bidRequests, hasUserInfo); + let userObj; + if (userObjBid) { + userObj = {}; + Object.keys(userObjBid.params.user) + .filter(param => includes(USER_PARAMS, param)) + .forEach(param => userObj[param] = userObjBid.params.user[param]); + } + + const memberIdBid = find(bidRequests, hasMemberId); + const member = memberIdBid ? parseInt(memberIdBid.params.member, 10) : 0; + + const payload = { + tags: [...tags], + user: userObj, + sdk: { + source: SOURCE, + version: '$prebid.version$' + } + }; + if (member > 0) { + payload.member_id = member; + } + + if (bidderRequest && bidderRequest.gdprConsent) { + // note - objects for impbus use underscore instead of camelCase + payload.gdpr_consent = { + consent_string: bidderRequest.gdprConsent.consentString, + consent_required: bidderRequest.gdprConsent.gdprApplies + }; + } + + const payloadString = JSON.stringify(payload); + return { + method: 'POST', + url: URL, + data: payloadString, + bidderRequest + }; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, {bidderRequest}) { + serverResponse = serverResponse.body; + const bids = []; + if (!serverResponse || serverResponse.error) { + let errorMessage = `in response for ${bidderRequest.bidderCode} adapter`; + if (serverResponse && serverResponse.error) { errorMessage += `: ${serverResponse.error}`; } + utils.logError(errorMessage); + return bids; + } + + if (serverResponse.tags) { + serverResponse.tags.forEach(serverBid => { + const rtbBid = getRtbBid(serverBid); + if (rtbBid) { + if (rtbBid.cpm !== 0 && includes(this.supportedMediaTypes, rtbBid.ad_type)) { + const bid = newBid(serverBid, rtbBid, bidderRequest); + bid.mediaType = parseMediaType(rtbBid); + bids.push(bid); + } + } + }); + } + return bids; + }, + + getUserSyncs: function(syncOptions) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: 'https://acdn.adnxs.com/dmp/async_usersync.html' + }]; + } + } +}; + +function newRenderer(adUnitCode, rtbBid, rendererOptions = {}) { + const renderer = Renderer.install({ + id: rtbBid.renderer_id, + url: rtbBid.renderer_url, + config: rendererOptions, + loaded: false, + }); + + try { + renderer.setRender(outstreamRender); + } catch (err) { + utils.logWarn('Prebid Error calling setRender on renderer', err); + } + + renderer.setEventHandlers({ + impression: () => utils.logMessage('xhb outstream video impression event'), + loaded: () => utils.logMessage('xhb outstream video loaded event'), + ended: () => { + utils.logMessage('xhb outstream renderer video event'); + document.querySelector(`#${adUnitCode}`).style.display = 'none'; + } + }); + return renderer; +} + +/* Turn keywords parameter into ut-compatible format */ +function getKeywords(keywords) { + let arrs = []; + + utils._each(keywords, (v, k) => { + if (utils.isArray(v)) { + let values = []; + utils._each(v, (val) => { + val = utils.getValueString('keywords.' + k, val); + if (val) { values.push(val); } + }); + v = values; + } else { + v = utils.getValueString('keywords.' + k, v); + if (utils.isStr(v)) { + v = [v]; + } else { + return; + } // unsuported types - don't send a key + } + arrs.push({key: k, value: v}); + }); + + return arrs; +} + +/** + * Unpack the Server's Bid into a Prebid-compatible one. + * @param serverBid + * @param rtbBid + * @param bidderRequest + * @return Bid + */ +function newBid(serverBid, rtbBid, bidderRequest) { + const bid = { + requestId: serverBid.uuid, + cpm: 0.00, + creativeId: rtbBid.creative_id, + dealId: 99999999, + currency: 'USD', + netRevenue: true, + ttl: 300, + appnexus: { + buyerMemberId: rtbBid.buyer_member_id + } + }; + + if (rtbBid.rtb.video) { + Object.assign(bid, { + width: rtbBid.rtb.video.player_width, + height: rtbBid.rtb.video.player_height, + vastUrl: rtbBid.rtb.video.asset_url, + vastImpUrl: rtbBid.notify_url, + ttl: 3600 + }); + // This supports Outstream Video + if (rtbBid.renderer_url) { + const rendererOptions = utils.deepAccess( + bidderRequest.bids[0], + 'renderer.options' + ); + + Object.assign(bid, { + adResponse: serverBid, + renderer: newRenderer(bid.adUnitCode, rtbBid, rendererOptions) + }); + bid.adResponse.ad = bid.adResponse.ads[0]; + bid.adResponse.ad.video = bid.adResponse.ad.rtb.video; + } + } else if (rtbBid.rtb[NATIVE]) { + const nativeAd = rtbBid.rtb[NATIVE]; + bid[NATIVE] = { + title: nativeAd.title, + body: nativeAd.desc, + cta: nativeAd.ctatext, + sponsoredBy: nativeAd.sponsored, + clickUrl: nativeAd.link.url, + clickTrackers: nativeAd.link.click_trackers, + impressionTrackers: nativeAd.impression_trackers, + javascriptTrackers: nativeAd.javascript_trackers, + }; + if (nativeAd.main_img) { + bid['native'].image = { + url: nativeAd.main_img.url, + height: nativeAd.main_img.height, + width: nativeAd.main_img.width, + }; + } + if (nativeAd.icon) { + bid['native'].icon = { + url: nativeAd.icon.url, + height: nativeAd.icon.height, + width: nativeAd.icon.width, + }; + } + } else { + Object.assign(bid, { + width: rtbBid.rtb.banner.width, + height: rtbBid.rtb.banner.height, + ad: rtbBid.rtb.banner.content + }); + try { + const url = rtbBid.rtb.trackers[0].impression_urls[0]; + const tracker = utils.createTrackPixelHtml(url); + bid.ad += tracker; + } catch (error) { + utils.logError('Error appending tracking pixel', error); + } + } + + return bid; +} + +function bidToTag(bid) { + const tag = {}; + tag.sizes = transformSizes(bid.sizes); + tag.primary_size = tag.sizes[0]; + tag.ad_types = []; + tag.uuid = bid.bidId; + if (bid.params.placementId) { + tag.id = parseInt(bid.params.placementId, 10); + } else { + tag.code = bid.params.invCode; + } + tag.allow_smaller_sizes = bid.params.allowSmallerSizes || false; + tag.use_pmt_rule = bid.params.usePaymentRule || false; + tag.prebid = true; + tag.disable_psa = true; + if (bid.params.reserve) { + tag.reserve = bid.params.reserve; + } + if (bid.params.position) { + tag.position = {'above': 1, 'below': 2}[bid.params.position] || 0; + } + if (bid.params.trafficSourceCode) { + tag.traffic_source_code = bid.params.trafficSourceCode; + } + if (bid.params.privateSizes) { + tag.private_sizes = transformSizes(bid.params.privateSizes); + } + if (bid.params.supplyType) { + tag.supply_type = bid.params.supplyType; + } + if (bid.params.pubClick) { + tag.pubclick = bid.params.pubClick; + } + if (bid.params.extInvCode) { + tag.ext_inv_code = bid.params.extInvCode; + } + if (bid.params.externalImpId) { + tag.external_imp_id = bid.params.externalImpId; + } + if (!utils.isEmpty(bid.params.keywords)) { + tag.keywords = getKeywords(bid.params.keywords); + } + + if (bid.mediaType === NATIVE || utils.deepAccess(bid, `mediaTypes.${NATIVE}`)) { + tag.ad_types.push(NATIVE); + + if (bid.nativeParams) { + const nativeRequest = buildNativeRequest(bid.nativeParams); + tag[NATIVE] = {layouts: [nativeRequest]}; + } + } + + const videoMediaType = utils.deepAccess(bid, `mediaTypes.${VIDEO}`); + const context = utils.deepAccess(bid, 'mediaTypes.video.context'); + + if (bid.mediaType === VIDEO || videoMediaType) { + tag.ad_types.push(VIDEO); + } + + // instream gets vastUrl, outstream gets vastXml + if (bid.mediaType === VIDEO || (videoMediaType && context !== 'outstream')) { + tag.require_asset_url = true; + } + + if (bid.params.video) { + tag.video = {}; + // place any valid video params on the tag + Object.keys(bid.params.video) + .filter(param => includes(VIDEO_TARGETING, param)) + .forEach(param => tag.video[param] = bid.params.video[param]); + } + + if ( + (utils.isEmpty(bid.mediaType) && utils.isEmpty(bid.mediaTypes)) || + (bid.mediaType === BANNER || (bid.mediaTypes && bid.mediaTypes[BANNER])) + ) { + tag.ad_types.push(BANNER); + } + + return tag; +} + +/* Turn bid request sizes into ut-compatible format */ +function transformSizes(requestSizes) { + let sizes = []; + let sizeObj = {}; + + if (utils.isArray(requestSizes) && requestSizes.length === 2 && + !utils.isArray(requestSizes[0])) { + sizeObj.width = parseInt(requestSizes[0], 10); + sizeObj.height = parseInt(requestSizes[1], 10); + sizes.push(sizeObj); + } else if (typeof requestSizes === 'object') { + for (let i = 0; i < requestSizes.length; i++) { + let size = requestSizes[i]; + sizeObj = {}; + sizeObj.width = parseInt(size[0], 10); + sizeObj.height = parseInt(size[1], 10); + sizes.push(sizeObj); + } + } + + return sizes; +} + +function hasUserInfo(bid) { + return !!bid.params.user; +} + +function hasMemberId(bid) { + return !!parseInt(bid.params.member, 10); +} + +function getRtbBid(tag) { + return tag && tag.ads && tag.ads.length && find(tag.ads, ad => ad.rtb); +} + +function buildNativeRequest(params) { + const request = {}; + + // map standard prebid native asset identifier to /ut parameters + // e.g., tag specifies `body` but /ut only knows `description`. + // mapping may be in form {tag: ''} or + // {tag: {serverName: '', requiredParams: {...}}} + Object.keys(params).forEach(key => { + // check if one of the forms is used, otherwise + // a mapping wasn't specified so pass the key straight through + const requestKey = + (NATIVE_MAPPING[key] && NATIVE_MAPPING[key].serverName) || + NATIVE_MAPPING[key] || + key; + + // required params are always passed on request + const requiredParams = NATIVE_MAPPING[key] && NATIVE_MAPPING[key].requiredParams; + request[requestKey] = Object.assign({}, requiredParams, params[key]); + + // minimum params are passed if no non-required params given on adunit + const minimumParams = NATIVE_MAPPING[key] && NATIVE_MAPPING[key].minimumParams; + + if (requiredParams && minimumParams) { + // subtract required keys from adunit keys + const adunitKeys = Object.keys(params[key]); + const requiredKeys = Object.keys(requiredParams); + const remaining = adunitKeys.filter(key => !includes(requiredKeys, key)); + + // if none are left over, the minimum params needs to be sent + if (remaining.length === 0) { + request[requestKey] = Object.assign({}, request[requestKey], minimumParams); + } + } + }); + + return request; +} + +function outstreamRender(bid) { + // push to render queue because ANOutstreamVideo may not be loaded yet + bid.renderer.push(() => { + window.ANOutstreamVideo.renderAd({ + tagId: bid.adResponse.tag_id, + sizes: [bid.getSize().split('x')], + targetId: bid.adUnitCode, // target div id to render video + uuid: bid.adResponse.uuid, + adResponse: bid.adResponse, + rendererOptions: bid.renderer.getConfig() + }, handleOutstreamRendererEvents.bind(null, bid)); + }); +} + +function handleOutstreamRendererEvents(bid, id, eventName) { + bid.renderer.handleVideoEvent({ id, eventName }); +} + +function parseMediaType(rtbBid) { + const adType = rtbBid.ad_type; + if (adType === VIDEO) { + return VIDEO; + } else if (adType === NATIVE) { + return NATIVE; + } else { + return BANNER; + } +} + +registerBidder(spec); From 2feed6832c9e675a973f37628f021ae81272b488 Mon Sep 17 00:00:00 2001 From: Dan Bogdan <43830380+EMXDigital@users.noreply.github.com> Date: Fri, 21 May 2021 02:45:11 -0700 Subject: [PATCH 211/303] EMX Digital Bid Adapter: floor module and advertiserDomain support (#6805) --- modules/emx_digitalBidAdapter.js | 28 +++++++++- .../modules/emx_digitalBidAdapter_spec.js | 52 ++++++++++++++++--- 2 files changed, 72 insertions(+), 8 deletions(-) diff --git a/modules/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js index 41a5af6d703..bcdcd7393f7 100644 --- a/modules/emx_digitalBidAdapter.js +++ b/modules/emx_digitalBidAdapter.js @@ -223,7 +223,7 @@ export const spec = { utils._each(validBidRequests, function (bid) { let tagid = utils.getBidIdParameter('tagid', bid.params); - let bidfloor = parseFloat(utils.getBidIdParameter('bidfloor', bid.params)) || 0; + let bidfloor = parseFloat(getBidFloor(bid)) || 0; let isVideo = !!bid.mediaTypes.video; let data = { id: bid.bidId, @@ -287,6 +287,14 @@ export const spec = { bidResponse = emxAdapter.formatVideoResponse(bidResponse, Object.assign({}, emxBid), bidRequest); } bidResponse.mediaType = (isVideo ? VIDEO : BANNER); + + // support for adomain in prebid 5.0 + if (emxBid.adomain && emxBid.adomain.length) { + bidResponse.meta = { + advertiserDomains: emxBid.adomain + }; + } + emxBidResponses.push(bidResponse); }); } @@ -312,4 +320,22 @@ export const spec = { return syncs; } }; + +// support floors module in prebid 5.0 +function getBidFloor(bid) { + if (!utils.isFn(bid.getFloor)) { + return parseFloat(utils.getBidIdParameter('bidfloor', bid.params)); + } + + let floor = bid.getFloor({ + currency: DEFAULT_CUR, + mediaType: '*', + size: '*' + }); + if (utils.isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') { + return floor.floor; + } + return null; +} + registerBidder(spec); diff --git a/test/spec/modules/emx_digitalBidAdapter_spec.js b/test/spec/modules/emx_digitalBidAdapter_spec.js index 855ffa0a0b7..0f82122b9c1 100644 --- a/test/spec/modules/emx_digitalBidAdapter_spec.js +++ b/test/spec/modules/emx_digitalBidAdapter_spec.js @@ -253,12 +253,38 @@ describe('emx_digital Adapter', function () { expect(queryParams[1]).to.match(new RegExp('^ts=\d*', 'g')); }); - it('builds with bid floor', function () { - const bidRequestWithBidFloor = utils.deepClone(bidderRequest.bids); - bidRequestWithBidFloor[0].params.bidfloor = 1; - const requestWithFloor = spec.buildRequests(bidRequestWithBidFloor, bidderRequest); + it('builds bidfloor value from bid param when getFloor function does not exist', function () { + const bidRequestWithFloor = utils.deepClone(bidderRequest.bids); + bidRequestWithFloor[0].params.bidfloor = 1; + const requestWithFloor = spec.buildRequests(bidRequestWithFloor, bidderRequest); const data = JSON.parse(requestWithFloor.data); - expect(data.imp[0].bidfloor).to.equal(bidRequestWithBidFloor[0].params.bidfloor); + expect(data.imp[0].bidfloor).to.equal(bidRequestWithFloor[0].params.bidfloor); + }); + + it('builds bidfloor value from getFloor function when it exists', function () { + const floorResponse = { currency: 'USD', floor: 3 }; + const bidRequestWithGetFloor = utils.deepClone(bidderRequest.bids); + bidRequestWithGetFloor[0].getFloor = () => floorResponse; + const requestWithGetFloor = spec.buildRequests(bidRequestWithGetFloor, bidderRequest); + const data = JSON.parse(requestWithGetFloor.data); + expect(data.imp[0].bidfloor).to.equal(3); + }); + + it('builds bidfloor value from getFloor when both floor and getFloor function exists', function () { + const floorResponse = { currency: 'USD', floor: 3 }; + const bidRequestWithBothFloors = utils.deepClone(bidderRequest.bids); + bidRequestWithBothFloors[0].params.bidfloor = 1; + bidRequestWithBothFloors[0].getFloor = () => floorResponse; + const requestWithBothFloors = spec.buildRequests(bidRequestWithBothFloors, bidderRequest); + const data = JSON.parse(requestWithBothFloors.data); + expect(data.imp[0].bidfloor).to.equal(3); + }); + + it('empty bidfloor value when floor and getFloor is not defined', function () { + const bidRequestWithoutFloor = utils.deepClone(bidderRequest.bids); + const requestWithoutFloor = spec.buildRequests(bidRequestWithoutFloor, bidderRequest); + const data = JSON.parse(requestWithoutFloor.data); + expect(data.imp[0].bidfloor).to.not.exist; }); it('builds request properly', function () { @@ -470,7 +496,8 @@ describe('emx_digital Adapter', function () { 'id': '987654321cba', 'price': 0.5, 'ttl': 300, - 'w': 300 + 'w': 300, + 'adomain': ['example.com'] }], 'seat': '1356' }, { @@ -498,7 +525,10 @@ describe('emx_digital Adapter', function () { 'netRevneue': true, 'mediaType': 'banner', 'ad': '', - 'ttl': 300 + 'ttl': 300, + 'meta': { + 'advertiserDomains': ['example.com'] + } }, { 'requestId': '12819a18-56e1-4256-b836-b69a10202668', 'cpm': 0.7, @@ -630,6 +660,14 @@ describe('emx_digital Adapter', function () { body: badAdmServerResponse })); }); + + it('returns valid advertiser domain', function () { + const bidResponse = utils.deepClone(serverResponse); + let result = spec.interpretResponse({body: bidResponse}); + expect(result[0].meta.advertiserDomains).to.deep.equal(expectedResponse[0].meta.advertiserDomains); + // case where adomains are not in request + expect(result[1].meta).to.not.exist; + }); }); describe('getUserSyncs', function () { From 6637abe6caa5750a3918caa1cedc344a423f315a Mon Sep 17 00:00:00 2001 From: lksharma Date: Fri, 21 May 2021 08:26:07 -0400 Subject: [PATCH 212/303] Index Exchange Bid Adapter: coppa support, dealid & ttl field updates (#6782) * set bidderRequestId to be a string in r.id * set coppa value in r.reqs.coppa * added support for seat[].bid[].exp ttl value * read dealid from openrtb first, then fallback to ext * use utils.isInteger Co-authored-by: Kajan Umakanthan Co-authored-by: punkiller --- modules/ixBidAdapter.js | 20 ++-- test/spec/modules/ixBidAdapter_spec.js | 124 +++++++++++++++++++++++-- 2 files changed, 129 insertions(+), 15 deletions(-) diff --git a/modules/ixBidAdapter.js b/modules/ixBidAdapter.js index 3be919453a3..6970eefeac2 100644 --- a/modules/ixBidAdapter.js +++ b/modules/ixBidAdapter.js @@ -2,7 +2,6 @@ import * as utils from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; import find from 'core-js-pure/features/array/find.js'; -import isInteger from 'core-js-pure/features/number/is-integer.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'ix'; @@ -206,6 +205,8 @@ function _applyFloor(bid, imp, mediaType) { */ function parseBid(rawBid, currency, bidRequest) { const bid = {}; + const isValidExpiry = !!((utils.deepAccess(rawBid, 'exp') && utils.isInteger(rawBid.exp))); + const dealID = utils.deepAccess(rawBid, 'dealid') || utils.deepAccess(rawBid, 'ext.dealid'); if (PRICE_TO_DOLLAR_FACTOR.hasOwnProperty(currency)) { bid.cpm = rawBid.price / PRICE_TO_DOLLAR_FACTOR[currency]; @@ -215,7 +216,10 @@ function parseBid(rawBid, currency, bidRequest) { bid.requestId = rawBid.impid; - bid.dealId = utils.deepAccess(rawBid, 'ext.dealid'); + if (dealID) { + bid.dealId = dealID; + } + bid.netRevenue = NET_REVENUE; bid.currency = currency; bid.creativeId = rawBid.hasOwnProperty('crid') ? rawBid.crid : '-'; @@ -226,13 +230,13 @@ function parseBid(rawBid, currency, bidRequest) { bid.width = bidRequest.video.w; bid.height = bidRequest.video.h; bid.mediaType = VIDEO; - bid.ttl = VIDEO_TIME_TO_LIVE; + bid.ttl = isValidExpiry ? rawBid.exp : VIDEO_TIME_TO_LIVE; } else { bid.ad = rawBid.adm; bid.width = rawBid.w; bid.height = rawBid.h; bid.mediaType = BANNER; - bid.ttl = BANNER_TIME_TO_LIVE; + bid.ttl = isValidExpiry ? rawBid.exp : BANNER_TIME_TO_LIVE; } bid.meta = {}; @@ -253,7 +257,7 @@ function parseBid(rawBid, currency, bidRequest) { * @return {boolean} True if this is a valid size format, and false otherwise. */ function isValidSize(size) { - return Array.isArray(size) && size.length === 2 && isInteger(size[0]) && isInteger(size[1]); + return Array.isArray(size) && size.length === 2 && utils.isInteger(size[0]) && utils.isInteger(size[1]); } /** @@ -385,7 +389,7 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { const r = {}; // Since bidderRequestId are the same for different bid request, just use the first one. - r.id = validBidRequests[0].bidderRequestId; + r.id = validBidRequests[0].bidderRequestId.toString(); r.site = {}; r.ext = {}; @@ -452,6 +456,10 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { } } + if (config.getConfig('coppa')) { + utils.deepSetValue(r, 'regs.coppa', 1); + } + const payload = {}; // Parse additional runtime configs. diff --git a/test/spec/modules/ixBidAdapter_spec.js b/test/spec/modules/ixBidAdapter_spec.js index 50920965b60..c026dfd3efc 100644 --- a/test/spec/modules/ixBidAdapter_spec.js +++ b/test/spec/modules/ixBidAdapter_spec.js @@ -1221,7 +1221,7 @@ describe('IndexexchangeAdapter', function () { }); describe('buildRequests', function () { - const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; + let request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; const requestUrl = request.url; const requestMethod = request.method; const query = request.data; @@ -1254,6 +1254,7 @@ describe('IndexexchangeAdapter', function () { it('payload should have correct format and value', function () { const payload = JSON.parse(query.r); expect(payload.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidderRequestId); + expect(payload.id).to.be.a('string'); expect(payload.site).to.exist; expect(payload.site.page).to.equal(DEFAULT_OPTION.refererInfo.referer); expect(payload.site.ref).to.equal(document.referrer); @@ -1265,6 +1266,18 @@ describe('IndexexchangeAdapter', function () { expect(payload.imp).to.have.lengthOf(2); }); + it('payload should have correct format and value for r.id when bidderRequestId is a number ', function () { + const bidWithIntId = utils.deepClone(DEFAULT_BANNER_VALID_BID); + bidWithIntId[0].bidderRequestId = 123456; + + request = spec.buildRequests(bidWithIntId, DEFAULT_OPTION)[0]; + + const payload = JSON.parse(request.data.r); + expect(bidWithIntId[0].bidderRequestId).to.be.a('number'); + expect(payload.id).to.equal(bidWithIntId[0].bidderRequestId.toString()); + expect(payload.id).to.be.a('string'); + }); + it('payload should not include schain when not provided', function () { const payload = JSON.parse(queryWithoutSchain.r); expect(payload.source).to.not.exist; // source object currently only written for schain @@ -1963,7 +1976,6 @@ describe('IndexexchangeAdapter', function () { currency: 'USD', ttl: 300, netRevenue: true, - dealId: undefined, meta: { networkId: 50, brandId: 303325, @@ -1989,7 +2001,6 @@ describe('IndexexchangeAdapter', function () { currency: 'USD', ttl: 300, netRevenue: true, - dealId: undefined, meta: { networkId: 50, brandId: 303325, @@ -2016,7 +2027,6 @@ describe('IndexexchangeAdapter', function () { currency: 'USD', ttl: 300, netRevenue: true, - dealId: undefined, meta: { networkId: 50, brandId: 303325, @@ -2043,7 +2053,6 @@ describe('IndexexchangeAdapter', function () { currency: 'JPY', ttl: 300, netRevenue: true, - dealId: undefined, meta: { networkId: 50, brandId: 303325, @@ -2056,9 +2065,38 @@ describe('IndexexchangeAdapter', function () { expect(result[0]).to.deep.equal(expectedParse[0]); }); - it('should set dealId correctly', function () { + it('should prioritize bid[].dealid over bid[].ext.dealid ', function () { + const bidResponse = utils.deepClone(DEFAULT_BANNER_BID_RESPONSE); + bidResponse.seatbid[0].bid[0].ext.dealid = 'ext-deal'; + bidResponse.seatbid[0].bid[0].dealid = 'outter-deal'; + const expectedParse = [ + { + requestId: '1a2b3c4d', + cpm: 1, + creativeId: '12345', + width: 300, + height: 250, + mediaType: 'banner', + ad: '', + currency: 'USD', + ttl: 300, + netRevenue: true, + dealId: 'outter-deal', + meta: { + networkId: 50, + brandId: 303325, + brandName: 'OECTA', + advertiserDomains: ['www.abc.com'] + } + } + ]; + const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA }); + + expect(result[0].dealId).to.equal(expectedParse[0].dealId); + }); + + it('should not set bid[].dealid if dealid is not present', function () { const bidResponse = utils.deepClone(DEFAULT_BANNER_BID_RESPONSE); - bidResponse.seatbid[0].bid[0].ext.dealid = 'deal'; const expectedParse = [ { requestId: '1a2b3c4d', @@ -2071,7 +2109,6 @@ describe('IndexexchangeAdapter', function () { currency: 'USD', ttl: 300, netRevenue: true, - dealId: 'deal', meta: { networkId: 50, brandId: 303325, @@ -2084,6 +2121,34 @@ describe('IndexexchangeAdapter', function () { expect(result[0]).to.deep.equal(expectedParse[0]); }); + it('should use set bid[].ext.dealid if bid[].dealid is not present', function () { + const bidResponse = utils.deepClone(DEFAULT_BANNER_BID_RESPONSE); + bidResponse.seatbid[0].bid[0].ext.dealid = 'ext-deal'; + const expectedParse = [ + { + requestId: '1a2b3c4d', + cpm: 1, + creativeId: '12345', + width: 300, + height: 250, + mediaType: 'banner', + ad: '', + currency: 'USD', + ttl: 300, + dealId: 'ext-deal', + netRevenue: true, + meta: { + networkId: 50, + brandId: 303325, + brandName: 'OECTA', + advertiserDomains: ['www.abc.com'] + } + } + ]; + const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA }); + expect(result[0].dealId).to.deep.equal(expectedParse[0].dealId); + }); + it('should get correct bid response for video ad', function () { const expectedParse = [ { @@ -2096,7 +2161,6 @@ describe('IndexexchangeAdapter', function () { currency: 'USD', ttl: 3600, netRevenue: true, - dealId: undefined, vastUrl: 'www.abcd.com/vast', meta: { networkId: 51, @@ -2142,6 +2206,26 @@ describe('IndexexchangeAdapter', function () { expect(requestWithoutreferInfo.site.page).to.equal(options.refererInfo.referer); expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT); }); + + it('should set bid[].ttl to seatbid[].bid[].exp value from response', function () { + const BANNER_RESPONSE_WITH_EXP = utils.deepClone(DEFAULT_BANNER_BID_RESPONSE); + const VIDEO_RESPONSE_WITH_EXP = utils.deepClone(DEFAULT_VIDEO_BID_RESPONSE); + VIDEO_RESPONSE_WITH_EXP.seatbid[0].bid[0].exp = 200; + BANNER_RESPONSE_WITH_EXP.seatbid[0].bid[0].exp = 100; + const bannerResult = spec.interpretResponse({ body: BANNER_RESPONSE_WITH_EXP }, { data: DEFAULT_BIDDER_REQUEST_DATA }); + const videoResult = spec.interpretResponse({ body: VIDEO_RESPONSE_WITH_EXP }, { data: DEFAULT_BIDDER_REQUEST_DATA }); + + expect(bannerResult[0].ttl).to.equal(100); + expect(videoResult[0].ttl).to.equal(200); + }); + + it('should default bid[].ttl if seat[].bid[].exp is not in the resposne', function () { + const bannerResult = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data: DEFAULT_BIDDER_REQUEST_DATA }); + const videoResult = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { data: DEFAULT_BIDDER_REQUEST_DATA }); + + expect(bannerResult[0].ttl).to.equal(300); + expect(videoResult[0].ttl).to.equal(3600); + }); }); describe('bidrequest consent', function () { @@ -2248,5 +2332,27 @@ describe('IndexexchangeAdapter', function () { expect(utils.deepAccess(requestWithConsent, 'user.ext.consented_providers_settings')).to.not.exist; expect(utils.deepAccess(requestWithConsent, 'user.ext.consent')).to.not.exist; }); + + it('should set coppa to 1 in config when enabled', () => { + config.setConfig({ coppa: true }) + const bid = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION); + const r = JSON.parse(bid[0].data.r); + + expect(r.regs.coppa).to.equal(1); + }); + it('should not set coppa in config when disabled', () => { + config.setConfig({ coppa: false }) + const bid = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION); + const r = JSON.parse(bid[0].data.r); + + expect(r.regs.coppa).to.be.undefined; + }); + it('should not set coppa when not specified in config', () => { + config.resetConfig(); + const bid = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION); + const r = JSON.parse(bid[0].data.r); + + expect(r.regs.coppa).to.be.undefined; + }); }); }); From 0d845fed2c1b1a46da21a8adf034ff3c19d2ae26 Mon Sep 17 00:00:00 2001 From: Steven Francolla Date: Fri, 21 May 2021 13:27:32 -0400 Subject: [PATCH 213/303] Update permutiveRtdProvider.md (#6810) Updated to reflect current audience connector support. --- modules/permutiveRtdProvider.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/permutiveRtdProvider.md b/modules/permutiveRtdProvider.md index 3738c6e8be7..39f9a2aaaa5 100644 --- a/modules/permutiveRtdProvider.md +++ b/modules/permutiveRtdProvider.md @@ -20,7 +20,7 @@ pbjs.setConfig({ name: 'permutive', waitForIt: true, // should be true if there's an `auctionDelay` params: { - acBidders: ['appnexus', 'rubicon', 'ozone'] + acBidders: ['appnexus'] } }] }, @@ -31,16 +31,16 @@ pbjs.setConfig({ ## Supported Bidders The below bidders are currently support by the Permutive RTD module. Please reach out to your Permutive Account Manager to request support for any additional bidders. -| Bidder | ID | First-party segments | Audience Connector | +| Bidder | ID | Custom First-Party Segments | Audience Connector ("acBidders") | | ----------- | ---------- | -------------------- | ------------------ | | Xandr | `appnexus` | Yes | Yes | -| Magnite | `rubicon` | Yes | Yes | +| Magnite | `rubicon` | Yes | No | | Ozone | `ozone` | No | Yes | | TrustX | `trustx` | No | Yes | * **First-party segments:** When enabling the respective Activation for a segment in Permutive, this module will automatically attach that segment to the bid request. There is no need to enable individual bidders in the module configuration, it will automatically reflect which SSP integrations you have enabled in Permutive. Permutive segments will be sent in the `permutive` key-value. -* **Audience Connector:** You'll need to define which bidder should receive Audience Connector segments. You need to include the `ID` of any bidder in the `acBidders` array. Audience Connector segments will be sent in the `p_standard` key-value. +* **Audience Connector:** You'll need to define which bidder should receive Audience Connector segments. You need to include the `ID` of any bidder in the `acBidders` array. Audience Connector segments will be sent in the `p_standard` key-value. The segments produced by Audience Connector are not supported for PMPs at this time. ## Parameters @@ -66,7 +66,7 @@ pbjs.setConfig({ name: 'permutive', waitForIt: true, params: { - acBidders: ['appnexus', 'rubicon'], + acBidders: ['appnexus'], maxSegs: 450, overwrites: { rubicon: function (bid, data, acEnabled, utils, defaultFn) { From 95fd60692eae073173e896babd5267a23bf2b63f Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 21 May 2021 10:44:03 -0700 Subject: [PATCH 214/303] Conversant adapter - add support for the floor module (#6798) --- modules/conversantBidAdapter.js | 26 ++++++- .../spec/modules/conversantBidAdapter_spec.js | 73 +++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/modules/conversantBidAdapter.js b/modules/conversantBidAdapter.js index 806f276fb72..5af399365bd 100644 --- a/modules/conversantBidAdapter.js +++ b/modules/conversantBidAdapter.js @@ -62,7 +62,7 @@ export const spec = { let bidurl = URL; const conversantImps = validBidRequests.map(function(bid) { - const bidfloor = utils.getBidIdParameter('bidfloor', bid.params); + const bidfloor = getBidFloor(bid); siteId = utils.getBidIdParameter('site_id', bid.params) || siteId; pubcidName = utils.getBidIdParameter('pubcid_name', bid.params) || pubcidName; @@ -378,4 +378,28 @@ function readStoredValue(key) { return storedValue; } +/** + * Get the floor price from bid.params for backward compatibility. + * If not found, then check floor module. + * @param bid A valid bid object + * @returns {*|number} floor price + */ +function getBidFloor(bid) { + let floor = utils.getBidIdParameter('bidfloor', bid.params); + + if (!floor && utils.isFn(bid.getFloor)) { + const floorObj = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*' + }); + + if (utils.isPlainObject(floorObj) && !isNaN(floorObj.floor) && floorObj.currency === 'USD') { + floor = floorObj.floor; + } + } + + return floor +} + registerBidder(spec); diff --git a/test/spec/modules/conversantBidAdapter_spec.js b/test/spec/modules/conversantBidAdapter_spec.js index 1c24fb7694a..96a7f419341 100644 --- a/test/spec/modules/conversantBidAdapter_spec.js +++ b/test/spec/modules/conversantBidAdapter_spec.js @@ -588,4 +588,77 @@ describe('Conversant adapter tests', function() { expect(payload).to.have.deep.nested.property('user.ext.fpc', 'fghijk'); }); }); + + describe('price floor module', function() { + let bidRequest; + beforeEach(function() { + bidRequest = [utils.deepClone(bidRequests[0])]; + delete bidRequest[0].params.bidfloor; + }); + + it('obtain floor from getFloor', function() { + bidRequest[0].getFloor = () => { + return { + currency: 'USD', + floor: 3.21 + }; + }; + + const payload = spec.buildRequests(bidRequest).data; + expect(payload.imp[0]).to.have.property('bidfloor', 3.21); + }); + + it('obtain floor from params', function() { + bidRequest[0].getFloor = () => { + return { + currency: 'USD', + floor: 3.21 + }; + }; + bidRequest[0].params.bidfloor = 0.6; + + const payload = spec.buildRequests(bidRequest).data; + expect(payload.imp[0]).to.have.property('bidfloor', 0.6); + }); + + it('unsupported currency', function() { + bidRequest[0].getFloor = () => { + return { + currency: 'EUR', + floor: 1.23 + }; + }; + + const payload = spec.buildRequests(bidRequest).data; + expect(payload.imp[0]).to.have.property('bidfloor', 0); + }); + + it('bad floor value', function() { + bidRequest[0].getFloor = () => { + return { + currency: 'USD', + floor: 'test' + }; + }; + + const payload = spec.buildRequests(bidRequest).data; + expect(payload.imp[0]).to.have.property('bidfloor', 0); + }); + + it('empty floor object', function() { + bidRequest[0].getFloor = () => { + return {}; + }; + + const payload = spec.buildRequests(bidRequest).data; + expect(payload.imp[0]).to.have.property('bidfloor', 0); + }); + + it('undefined floor result', function() { + bidRequest[0].getFloor = () => {}; + + const payload = spec.buildRequests(bidRequest).data; + expect(payload.imp[0]).to.have.property('bidfloor', 0); + }); + }); }); From bda27a428c0b98d7bb51d9d1928b1ecf2aad9e43 Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Fri, 21 May 2021 15:19:01 -0400 Subject: [PATCH 215/303] JW Player RTD Module - dev doc improvements (#6811) --- modules/jwplayerRtdProvider.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/jwplayerRtdProvider.md b/modules/jwplayerRtdProvider.md index 0723e8cbb6c..7fb1bb13d74 100644 --- a/modules/jwplayerRtdProvider.md +++ b/modules/jwplayerRtdProvider.md @@ -2,7 +2,7 @@ The purpose of this Real Time Data Provider is to allow publishers to target aga having to integrate with the Player Bidding product. This prebid module makes JW Player's video ad targeting information accessible to Bid Adapters. -#Usage for Publishers: +# Usage for Publishers: Compile the JW Player RTD Provider into your Prebid build: @@ -30,7 +30,7 @@ Lastly, include the content's media ID and/or the player's ID in the matching Ad ```javascript const adUnit = { code: '/19968336/prebid_native_example_1', - ... + ..., ortb2Imp: { ext: { data: { @@ -51,10 +51,12 @@ pbjs.que.push(function() { }); }); ``` +**Note**: The player ID is the ID of the HTML div element used when instantiating the player. +You can retrieve this ID by calling `player.id`, where player is the JW Player instance variable. **Note**: You may also include `jwTargeting` information in the prebid config's `ortb2.site.ext.data`. Information provided in the adUnit will always supersede, and information in the config will be used as a fallback. -##Prefetching +## Prefetching In order to prefetch targeting information for certain media, include the media IDs in the `jwplayerDataProvider` var and set `waitForIt` to `true`: ```javascript @@ -76,7 +78,7 @@ realTimeData = { }; ``` -#Usage for Bid Adapters: +# Usage for Bid Adapters: Implement the `buildRequests` function. When it is called, the `bidRequests` param will be an array of bids. Each bid for which targeting information was found will conform to the following object structure: @@ -118,6 +120,6 @@ To view an example: **Note:** the mediaIds in the example are placeholder values; replace them with your existing IDs. -#Maintainer info +# Maintainer info Maintained by JW Player. For any questions, comments or feedback please contact Karim Mourra, karim@jwplayer.com From 849359e0dace95327dfad144e1112cb9c733f839 Mon Sep 17 00:00:00 2001 From: Brian Schmidt Date: Sat, 22 May 2021 04:52:54 -0700 Subject: [PATCH 216/303] update OpenX adapter to support mediaTypes.video and gpid (#6813) --- modules/openxBidAdapter.js | 56 +++++++++--- modules/openxBidAdapter.md | 4 +- test/spec/modules/openxBidAdapter_spec.js | 101 +++++++++++++++++----- 3 files changed, 128 insertions(+), 33 deletions(-) diff --git a/modules/openxBidAdapter.js b/modules/openxBidAdapter.js index 8a455f6fa25..a398a20a5c5 100644 --- a/modules/openxBidAdapter.js +++ b/modules/openxBidAdapter.js @@ -2,8 +2,12 @@ import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import * as utils from '../src/utils.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import includes from 'core-js-pure/features/array/includes.js' const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; +const VIDEO_TARGETING = ['startdelay', 'mimes', 'minduration', 'maxduration', + 'startdelay', 'skippable', 'playbackmethod', 'api', 'protocols', 'boxingallowed', + 'linearity', 'delivery', 'protocol', 'placement', 'minbitrate', 'maxbitrate']; const BIDDER_CODE = 'openx'; const BIDDER_CONFIG = 'hb_pb'; const BIDDER_VERSION = '3.0.3'; @@ -326,7 +330,12 @@ function buildOXBannerRequest(bids, bidderRequest) { let auids = utils._map(bids, bid => bid.params.unit); queryParams.aus = utils._map(bids, bid => utils.parseSizesInput(bid.mediaTypes.banner.sizes).join(',')).join('|'); - queryParams.divIds = utils._map(bids, bid => encodeURIComponent(bid.adUnitCode)).join(','); + queryParams.divids = utils._map(bids, bid => encodeURIComponent(bid.adUnitCode)).join(','); + // gpid + queryParams.aucs = utils._map(bids, function (bid) { + let gpid = utils.deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); + return encodeURIComponent(gpid || '') + }).join(','); if (auids.some(auid => auid)) { queryParams.auid = auids.join(','); @@ -382,6 +391,7 @@ function buildOXVideoRequest(bid, bidderRequest) { } function generateVideoParameters(bid, bidderRequest) { + const videoMediaType = utils.deepAccess(bid, `mediaTypes.video`); let queryParams = buildCommonQueryParamsFromBids([bid], bidderRequest); let oxVideoConfig = utils.deepAccess(bid, 'params.video') || {}; let context = utils.deepAccess(bid, 'mediaTypes.video.context'); @@ -401,16 +411,35 @@ function generateVideoParameters(bid, bidderRequest) { height = parseInt(playerSize[1], 10); } - Object.keys(oxVideoConfig).forEach(function (key) { - if (key === 'openrtb') { - oxVideoConfig[key].w = width || oxVideoConfig[key].w; - oxVideoConfig[key].v = height || oxVideoConfig[key].v; - queryParams[key] = JSON.stringify(oxVideoConfig[key]); - } else if (!(key in queryParams) && key !== 'url') { - // only allow video-related attributes - queryParams[key] = oxVideoConfig[key]; - } - }); + let openRtbParams = {w: width, h: height}; + + // legacy openrtb params could be in video, openrtb, or video.openrtb + let legacyParams = bid.params.video || bid.params.openrtb || {}; + if (legacyParams.openrtb) { + legacyParams = legacyParams.openrtb; + } + // support for video object or full openrtb object + if (utils.isArray(legacyParams.imp)) { + legacyParams = legacyParams.imp[0].video; + } + Object.keys(legacyParams) + .filter(param => includes(VIDEO_TARGETING, param)) + .forEach(param => openRtbParams[param] = legacyParams[param]); + + // 5.0 openrtb video params + Object.keys(videoMediaType) + .filter(param => includes(VIDEO_TARGETING, param)) + .forEach(param => openRtbParams[param] = videoMediaType[param]); + + let openRtbReq = { + imp: [ + { + video: openRtbParams + } + ] + } + + queryParams['openrtb'] = JSON.stringify(openRtbReq); queryParams.auid = bid.params.unit; // override prebid config with openx config if available @@ -429,6 +458,11 @@ function generateVideoParameters(bid, bidderRequest) { queryParams.vtest = 1; } + let gpid = utils.deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); + if (gpid) { + queryParams.aucs = encodeURIComponent(gpid) + } + // each video bid makes a separate request enrichQueryWithFloors(queryParams, VIDEO, [bid]); diff --git a/modules/openxBidAdapter.md b/modules/openxBidAdapter.md index 965b8ee1948..68e41a93b18 100644 --- a/modules/openxBidAdapter.md +++ b/modules/openxBidAdapter.md @@ -98,7 +98,7 @@ pbjs.setConfig({ ``` # Additional Details -[Banner Ads](https://docs.openx.com/Content/developers/containers/prebid-adapter.html) +[Banner Ads](https://docs.openx.com/publishers/prebid-adapter-web/) -[Video Ads](https://docs.openx.com/Content/developers/containers/prebid-video-adapter.html) +[Video Ads](https://docs.openx.com/publishers/prebid-adapter-video/) diff --git a/test/spec/modules/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js index 7391c8826bc..2a380277e55 100644 --- a/test/spec/modules/openxBidAdapter_spec.js +++ b/test/spec/modules/openxBidAdapter_spec.js @@ -341,7 +341,8 @@ describe('OpenxAdapter', function () { }, 'bidId': 'test-bid-id-1', 'bidderRequestId': 'test-bid-request-1', - 'auctionId': 'test-auction-1' + 'auctionId': 'test-auction-1', + 'ortb2Imp': { ext: { data: { pbadslot: '/12345/my-gpt-tag-0' } } } }, { 'bidder': 'openx', 'params': { @@ -356,7 +357,8 @@ describe('OpenxAdapter', function () { }, 'bidId': 'test-bid-id-2', 'bidderRequestId': 'test-bid-request-2', - 'auctionId': 'test-auction-2' + 'auctionId': 'test-auction-2', + 'ortb2Imp': { ext: { data: { pbadslot: '/12345/my-gpt-tag-1' } } } }]; const bidRequestsWithPlatform = [{ @@ -450,7 +452,12 @@ describe('OpenxAdapter', function () { it('should send the adunit codes', function () { const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - expect(request[0].data.divIds).to.equal(`${encodeURIComponent(bidRequestsWithMediaTypes[0].adUnitCode)},${encodeURIComponent(bidRequestsWithMediaTypes[1].adUnitCode)}`); + expect(request[0].data.divids).to.equal(`${encodeURIComponent(bidRequestsWithMediaTypes[0].adUnitCode)},${encodeURIComponent(bidRequestsWithMediaTypes[1].adUnitCode)}`); + }); + + it('should send the gpids', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].data.aucs).to.equal(`${encodeURIComponent('/12345/my-gpt-tag-0')},${encodeURIComponent('/12345/my-gpt-tag-1')}`); }); it('should send ad unit ids when any are defined', function () { @@ -1238,7 +1245,8 @@ describe('OpenxAdapter', function () { 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', - 'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e' + 'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e', + 'ortb2Imp': { ext: { data: { pbadslot: '/12345/my-gpt-tag-0' } } } }]; const mockBidderRequest = {refererInfo: {}}; @@ -1254,6 +1262,7 @@ describe('OpenxAdapter', function () { expect(dataParams.auid).to.equal('12345678'); expect(dataParams.vht).to.equal(480); expect(dataParams.vwd).to.equal(640); + expect(dataParams.aucs).to.equal(encodeURIComponent('/12345/my-gpt-tag-0')); }); it('shouldn\'t have the test parameter', function () { @@ -1313,45 +1322,97 @@ describe('OpenxAdapter', function () { expect(request[0].data.ju).to.not.equal(myUrl); }); - describe('when using the openRtb param', function () { - it('should covert the param to a JSON string', function () { - let myOpenRTBObject = {}; + describe('when using the openrtb video params', function () { + it('should parse legacy params.video.openrtb', function () { + let myOpenRTBObject = {mimes: ['application/javascript']}; videoBidRequest.params.video = { openrtb: myOpenRTBObject }; + const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} const request = spec.buildRequests([videoBidRequest], mockBidderRequest); - expect(request[0].data.openrtb).to.equal(JSON.stringify(myOpenRTBObject)); + expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); }); - it("should use the bidRequest's playerSize when it is available", function () { - const width = 200; - const height = 100; - const myOpenRTBObject = {v: height, w: width}; + it('should parse legacy params.openrtb', function () { + let myOpenRTBObject = {mimes: ['application/javascript']}; + videoBidRequest.params.openrtb = myOpenRTBObject; + const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} + const request = spec.buildRequests([videoBidRequest], mockBidderRequest); + + expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); + }); + + it('should parse legacy params.video', function () { + let myOpenRTBObject = {mimes: ['application/javascript']}; + videoBidRequest.params.video = myOpenRTBObject; + const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} + const request = spec.buildRequests([videoBidRequest], mockBidderRequest); + + expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); + }); + + it('should parse legacy params.video as full openrtb', function () { + let myOpenRTBObject = {imp: [{video: {mimes: ['application/javascript']}}]}; + videoBidRequest.params.video = myOpenRTBObject; + const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} + const request = spec.buildRequests([videoBidRequest], mockBidderRequest); + + expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); + }); + + it('should parse legacy video.openrtb', function () { + let myOpenRTBObject = {mimes: ['application/javascript']}; + videoBidRequest.params.video = { + openrtb: myOpenRTBObject + }; + const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} + const request = spec.buildRequests([videoBidRequest], mockBidderRequest); + + expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); + }); + + it('should omit filtered values for legacy', function () { + let myOpenRTBObject = {mimes: ['application/javascript'], dont: 'use'}; videoBidRequest.params.video = { openrtb: myOpenRTBObject }; + const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} + const request = spec.buildRequests([videoBidRequest], mockBidderRequest); + + expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); + }); + + it('should parse mediatypes.video', function () { + videoBidRequest.mediaTypes.video.mimes = ['application/javascript'] + videoBidRequest.mediaTypes.video.minduration = 15 const request = spec.buildRequests([videoBidRequest], mockBidderRequest); const openRtbRequestParams = JSON.parse(request[0].data.openrtb); + expect(openRtbRequestParams.imp[0].video.mimes).to.eql(['application/javascript']); + expect(openRtbRequestParams.imp[0].video.minduration).to.equal(15); + }); - expect(openRtbRequestParams.w).to.not.equal(width); - expect(openRtbRequestParams.v).to.not.equal(height); + it('should filter mediatypes.video', function () { + videoBidRequest.mediaTypes.video.mimes = ['application/javascript'] + videoBidRequest.mediaTypes.video.minnothing = 15 + const request = spec.buildRequests([videoBidRequest], mockBidderRequest); + const openRtbRequestParams = JSON.parse(request[0].data.openrtb); + expect(openRtbRequestParams.imp[0].video.mimes).to.eql(['application/javascript']); + expect(openRtbRequestParams.imp[0].video.minnothing).to.equal(undefined); }); - it('should use the the openRTB\'s sizing when the bidRequest\'s playerSize is not available', function () { + it("should use the bidRequest's playerSize", function () { const width = 200; const height = 100; const myOpenRTBObject = {v: height, w: width}; videoBidRequest.params.video = { openrtb: myOpenRTBObject }; - videoBidRequest.mediaTypes.video.playerSize = undefined; - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); const openRtbRequestParams = JSON.parse(request[0].data.openrtb); - expect(openRtbRequestParams.w).to.equal(width); - expect(openRtbRequestParams.v).to.equal(height); + expect(openRtbRequestParams.imp[0].video.w).to.equal(640); + expect(openRtbRequestParams.imp[0].video.h).to.equal(480); }); }); }); @@ -1465,7 +1526,7 @@ describe('OpenxAdapter', function () { const request = spec.buildRequests([multiformatBid], mockBidderRequest); const dataParams = request[0].data; - expect(dataParams.divIds).to.have.string(multiformatBid.adUnitCode); + expect(dataParams.divids).to.have.string(multiformatBid.adUnitCode); }); }); From a0732135ad39c3f00c90c75a5af7364e44c7dc77 Mon Sep 17 00:00:00 2001 From: pratik-synacor <64602199+pratik-synacor@users.noreply.github.com> Date: Mon, 24 May 2021 13:19:20 +0530 Subject: [PATCH 217/303] SynacorMedia Bid Adapter: Add userID support (#6790) * SynacorMedia Bid Adapter: Add userID support * SynacorMedia Bid Adapter: User ID Support - Remove an unncessary conditional and use indexOf vs includes for IE11 support --- modules/synacormediaBidAdapter.js | 24 +++++++ .../modules/synacormediaBidAdapter_spec.js | 72 ++++++++++++++++++- 2 files changed, 95 insertions(+), 1 deletion(-) diff --git a/modules/synacormediaBidAdapter.js b/modules/synacormediaBidAdapter.js index aaff637c790..7694f5d838e 100644 --- a/modules/synacormediaBidAdapter.js +++ b/modules/synacormediaBidAdapter.js @@ -14,6 +14,12 @@ const BLOCKED_AD_SIZES = [ '1x1', '1x2' ]; +const SUPPORTED_USER_ID_SOURCES = [ + 'liveramp.com', // Liveramp IdentityLink + 'nextroll.com', // NextRoll XID + 'verizonmedia.com', // Verizon Media ConnectID + 'pubcid.org' // PubCommon ID +]; export const spec = { code: 'synacormedia', supportedMediaTypes: [ BANNER, VIDEO ], @@ -91,6 +97,14 @@ export const spec = { deepSetValue(openRtbBidRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent); } + // User ID + if (validBidReqs[0] && validBidReqs[0].userIdAsEids && Array.isArray(validBidReqs[0].userIdAsEids)) { + const eids = this.processEids(validBidReqs[0].userIdAsEids); + if (eids.length) { + deepSetValue(openRtbBidRequest, 'user.ext.eids', eids); + } + } + if (openRtbBidRequest.imp.length && seatId) { return { method: 'POST', @@ -104,6 +118,16 @@ export const spec = { } }, + processEids: function(userIdAsEids) { + const eids = []; + userIdAsEids.forEach(function(eid) { + if (SUPPORTED_USER_ID_SOURCES.indexOf(eid.source) > -1) { + eids.push(eid); + } + }); + return eids; + }, + buildBannerImpressions: function (adSizes, bid, tagIdOrPlacementId, pos, bidFloor, videoOrBannerKey) { let format = []; let imps = []; diff --git a/test/spec/modules/synacormediaBidAdapter_spec.js b/test/spec/modules/synacormediaBidAdapter_spec.js index 688f1c2c090..5f3633ec311 100644 --- a/test/spec/modules/synacormediaBidAdapter_spec.js +++ b/test/spec/modules/synacormediaBidAdapter_spec.js @@ -191,6 +191,62 @@ describe('synacormediaBidAdapter ', function () { uspConsent: '1YYY' }; + let validBidRequestWithUserIds = { + bidId: '9876abcd', + sizes: [[300, 250], [300, 600]], + params: { + seatId: 'prebid', + tagId: '1234', + bidfloor: '0.50' + }, + userIdAsEids: [ + { + source: 'pubcid.org', + uids: [{ + id: 'cid0032l2344jskdsl3', + atype: 1 + }] + }, + { + source: 'liveramp.com', + uids: [{ + id: 'lrv39010k42dl', + atype: 1, + ext: { + rtiPartner: 'TDID' + } + }] + }, + { + source: 'neustar.biz', + uids: [{ + id: 'neustar809-044-23njhwer3', + atype: 1 + }] + } + ] + }; + + let expectedEids = [ + { + source: 'pubcid.org', + uids: [{ + id: 'cid0032l2344jskdsl3', + atype: 1 + }] + }, + { + source: 'liveramp.com', + uids: [{ + id: 'lrv39010k42dl', + atype: 1, + ext: { + rtiPartner: 'TDID' + } + }] + } + ]; + let expectedDataImp1 = { banner: { format: [ @@ -631,7 +687,21 @@ describe('synacormediaBidAdapter ', function () { expect(req.data.id).to.equal('xyz123'); expect(req.data.regs.ext.us_privacy).to.equal('1YYY'); expect(req.data.imp).to.eql([expectedDataImp1]); - }) + }); + it('should contain user object when user ids are present in the bidder request', function () { + let req = spec.buildRequests([validBidRequestWithUserIds], bidderRequest); + expect(req).be.an('object'); + expect(req).to.have.property('method', 'POST'); + expect(req).to.have.property('url'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?'); + expect(req.data).to.exist.and.to.be.an('object'); + expect(req.data.id).to.equal('xyz123'); + expect(req.data.user).be.an('object'); + expect(req.data.user).to.have.property('ext'); + expect(req.data.user.ext).to.have.property('eids'); + expect(req.data.user.ext.eids).to.eql(expectedEids); + expect(req.data.imp).to.eql([expectedDataImp1]); + }); }); describe('Bid Requests with placementId should be backward compatible ', function () { From 8335d6701a0aa08f027ef0f69f205392abee3454 Mon Sep 17 00:00:00 2001 From: Michael Kuryshev Date: Mon, 24 May 2021 13:25:49 +0200 Subject: [PATCH 218/303] VIS.X: change tracking win & pending url's (#6815) --- modules/visxBidAdapter.js | 16 ++++-- test/spec/modules/visxBidAdapter_spec.js | 66 +++++++++++++++++++++--- 2 files changed, 70 insertions(+), 12 deletions(-) diff --git a/modules/visxBidAdapter.js b/modules/visxBidAdapter.js index 63f4121724e..12004cc35af 100644 --- a/modules/visxBidAdapter.js +++ b/modules/visxBidAdapter.js @@ -10,8 +10,6 @@ const ENDPOINT_URL = BASE_URL + '/hb'; const TIME_TO_LIVE = 360; const DEFAULT_CUR = 'EUR'; const ADAPTER_SYNC_URL = BASE_URL + '/push_sync'; -const TRACK_WIN_URL = BASE_URL + '/track/win'; -const TRACK_PENDING_URL = BASE_URL + '/track/pending'; const TRACK_TIMEOUT_URL = BASE_URL + '/track/bid_timeout'; const LOG_ERROR_MESS = { noAuid: 'Bid from response has no auid parameter - ', @@ -191,11 +189,15 @@ export const spec = { }, onSetTargeting: function(bid) { // Call '/track/pending' with the corresponding bid.requestId - utils.triggerPixel(TRACK_PENDING_URL + '?requestId=' + bid.requestId); + if (bid.ext && bid.ext.events && bid.ext.events.pending) { + utils.triggerPixel(bid.ext.events.pending); + } }, onBidWon: function(bid) { // Call '/track/win' with the corresponding bid.requestId - utils.triggerPixel(TRACK_WIN_URL + '?requestId=' + bid.requestId); + if (bid.ext && bid.ext.events && bid.ext.events.win) { + utils.triggerPixel(bid.ext.events.win); + } }, onTimeout: function(timeoutData) { // Call '/track/bid_timeout' with timeout data @@ -240,9 +242,13 @@ function _addBidResponse(serverBid, bidsMap, currency, bidResponses, bidsWithout currency: reqCurrency, netRevenue: true, ttl: TIME_TO_LIVE, - dealId: serverBid.dealid + dealId: serverBid.dealid, }; + if (serverBid.ext && serverBid.ext.prebid) { + bidResponse.ext = serverBid.ext.prebid; + } + if (!_isVideoBid(bid)) { bidResponse.ad = serverBid.adm; } else { diff --git a/test/spec/modules/visxBidAdapter_spec.js b/test/spec/modules/visxBidAdapter_spec.js index 7a85d40c790..fa902480cd7 100755 --- a/test/spec/modules/visxBidAdapter_spec.js +++ b/test/spec/modules/visxBidAdapter_spec.js @@ -460,7 +460,7 @@ describe('VisxAdapter', function () { ]; const response = Object.assign({}, responses[0]); - Object.assign(response.bid[0], {'cur': 'PLN'}); + response.bid = [Object.assign({}, response.bid[0], {'cur': 'PLN'})]; const result = spec.interpretResponse({'body': {'seatbid': [response]}}, request); expect(result).to.deep.equal(expectedResponse); getConfigStub.restore(); @@ -756,6 +756,56 @@ describe('VisxAdapter', function () { const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); expect(result).to.deep.equal(expectedResponse); }); + + it('should get right ext data in bid response', function () { + const bidRequests = [ + { + 'bidder': 'visx', + 'params': { + 'uid': '903535' + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '659423fff799cb', + 'bidderRequestId': '5f2009617a7c0a', + 'auctionId': '1cbd2feafe5e8b', + } + ]; + const request = spec.buildRequests(bidRequests); + const pendingUrl = 'https://t.visx.net/track/pending/123123123'; + const winUrl = 'https://t.visx.net/track/win/53245341'; + const expectedResponse = [ + { + 'requestId': '659423fff799cb', + 'cpm': 1.15, + 'creativeId': 903535, + 'dealId': undefined, + 'width': 300, + 'height': 250, + 'ad': '
test content 1
', + 'currency': 'EUR', + 'netRevenue': true, + 'ttl': 360, + 'ext': { + 'events': { + 'pending': pendingUrl, + 'win': winUrl + } + } + } + ]; + const serverResponse = Object.assign({}, responses[0]); + serverResponse.bid = [Object.assign({}, {ext: { + prebid: { + events: { + 'pending': pendingUrl, + 'win': winUrl + } + } + }}, serverResponse.bid[0])]; + const result = spec.interpretResponse({'body': {'seatbid': [serverResponse]}}, request); + expect(result).to.deep.equal(expectedResponse); + }); }); describe('check trackers', function () { beforeEach(function () { @@ -767,15 +817,17 @@ describe('VisxAdapter', function () { }); it('onSetTargeting', function () { - const requestId = '111'; - spec.onSetTargeting({ requestId }); - expect(utils.triggerPixel.calledOnceWith('https://t.visx.net/track/pending?requestId=' + requestId)).to.equal(true); + const trackUrl = 'https://t.visx.net/track/pending/123123123'; + const bid = { ext: { events: { pending: trackUrl } } }; + spec.onSetTargeting(bid); + expect(utils.triggerPixel.calledOnceWith(trackUrl)).to.equal(true); }); it('onBidWon', function () { - const requestId = '111'; - spec.onBidWon({ requestId }); - expect(utils.triggerPixel.calledOnceWith('https://t.visx.net/track/win?requestId=' + requestId)).to.equal(true); + const trackUrl = 'https://t.visx.net/track/win/123123123'; + const bid = { ext: { events: { win: trackUrl } } }; + spec.onBidWon(bid); + expect(utils.triggerPixel.calledOnceWith(trackUrl)).to.equal(true); }); it('onTimeout', function () { From 21c70b2657847eb67f7084e4394c57aacce9588b Mon Sep 17 00:00:00 2001 From: Jonathan Nadarajah <50102657+jogury@users.noreply.github.com> Date: Mon, 24 May 2021 21:36:35 +0200 Subject: [PATCH 219/303] Ogury Bid Adapter: add new adapter (#6729) --- modules/oguryBidAdapter.js | 135 ++++++++++ modules/oguryBidAdapter.md | 35 +++ test/spec/modules/oguryBidAdapter_spec.js | 312 ++++++++++++++++++++++ 3 files changed, 482 insertions(+) create mode 100644 modules/oguryBidAdapter.js create mode 100644 modules/oguryBidAdapter.md create mode 100644 test/spec/modules/oguryBidAdapter_spec.js diff --git a/modules/oguryBidAdapter.js b/modules/oguryBidAdapter.js new file mode 100644 index 00000000000..0b4982bc8dc --- /dev/null +++ b/modules/oguryBidAdapter.js @@ -0,0 +1,135 @@ +'use strict'; + +import { BANNER } from '../src/mediaTypes.js'; +import { getAdUnitSizes, logWarn, isFn } from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'ogury'; +const DEFAULT_TIMEOUT = 1000; +const BID_HOST = 'https://webmobile.presage.io/api/header-bidding-request'; + +function isBidRequestValid(bid) { + const adUnitSizes = getAdUnitSizes(bid); + + const isValidSizes = Boolean(adUnitSizes) && adUnitSizes.length > 0; + const isValidAdUnitId = !!bid.params.adUnitId; + const isValidAssetKey = !!bid.params.assetKey; + + return (isValidSizes && isValidAdUnitId && isValidAssetKey); +} + +function buildRequests(validBidRequests, bidderRequest) { + const openRtbBidRequestBanner = { + id: bidderRequest.auctionId, + tmax: DEFAULT_TIMEOUT, + at: 2, + regs: { + ext: { + gdpr: 1 + }, + }, + site: { + domain: location.hostname + }, + user: { + ext: { + consent: '' + } + }, + imp: [] + }; + + if (bidderRequest.hasOwnProperty('gdprConsent') && + bidderRequest.gdprConsent.hasOwnProperty('gdprApplies')) { + openRtbBidRequestBanner.regs.ext.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0 + } + + if (bidderRequest.hasOwnProperty('gdprConsent') && + bidderRequest.gdprConsent.hasOwnProperty('consentString') && + bidderRequest.gdprConsent.consentString.length > 0) { + openRtbBidRequestBanner.user.ext.consent = bidderRequest.gdprConsent.consentString + } + + validBidRequests.forEach((bidRequest) => { + const sizes = getAdUnitSizes(bidRequest) + .map(size => ({ w: size[0], h: size[1] })); + + if (bidRequest.hasOwnProperty('mediaTypes') && + bidRequest.mediaTypes.hasOwnProperty('banner')) { + openRtbBidRequestBanner.site.id = bidRequest.params.assetKey; + + openRtbBidRequestBanner.imp.push({ + id: bidRequest.bidId, + tagid: bidRequest.params.adUnitId, + bidfloor: getFloor(bidRequest), + banner: { + format: sizes + } + }); + } + }); + + return { + method: 'POST', + url: BID_HOST, + data: openRtbBidRequestBanner + }; +} + +function interpretResponse(openRtbBidResponse) { + if (!openRtbBidResponse || + !openRtbBidResponse.body || + typeof openRtbBidResponse.body != 'object' || + Object.keys(openRtbBidResponse.body).length === 0) { + logWarn('no response or body is malformed'); + return []; + } + + const bidResponses = []; + + openRtbBidResponse.body.seatbid.forEach((seatbid) => { + seatbid.bid.forEach((bid) => { + let bidResponse = { + requestId: bid.impid, + cpm: bid.price, + currency: 'USD', + width: bid.w, + height: bid.h, + creativeId: bid.id, + netRevenue: true, + ttl: 60, + meta: { + advertiserDomains: bid.adomain + } + }; + + bidResponse.ad = bid.adm; + + bidResponses.push(bidResponse); + }); + }); + return bidResponses; +} + +function getFloor(bid) { + if (!isFn(bid.getFloor)) { + return 0; + } + let floorResult = bid.getFloor({ + currency: 'USD', + mediaType: 'banner', + size: '*' + }); + return floorResult.currency === 'USD' ? floorResult.floor : 0; +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + isBidRequestValid, + buildRequests, + interpretResponse, + getFloor +} + +registerBidder(spec); diff --git a/modules/oguryBidAdapter.md b/modules/oguryBidAdapter.md new file mode 100644 index 00000000000..00896762dc4 --- /dev/null +++ b/modules/oguryBidAdapter.md @@ -0,0 +1,35 @@ +# Overview + +``` +Module Name: Ogury Bidder Adapter +Module Type: Bidder Adapter +Maintainer: web.inventory@ogury.co +``` + +# Description + +Module that connects to Ogury's SSP solution +Ogury bid adapter supports Banner media type. + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], // a display size + } + }, + bids: [ + { + bidder: "ogury", + params: { + assetKey: 'OGY-CA41D116484F', + adUnitId: '2c4d61d0-90aa-0139-0cda-0242ac120004' + } + } + ] + } + ]; +``` diff --git a/test/spec/modules/oguryBidAdapter_spec.js b/test/spec/modules/oguryBidAdapter_spec.js new file mode 100644 index 00000000000..d08bf2c8430 --- /dev/null +++ b/test/spec/modules/oguryBidAdapter_spec.js @@ -0,0 +1,312 @@ +import { expect } from 'chai'; +import { spec } from 'modules/oguryBidAdapter'; +import { deepClone } from 'src/utils.js'; + +const BID_HOST = 'https://webmobile.presage.io/api/header-bidding-request'; + +describe('OguryBidAdapter', function () { + let bidRequests; + let bidderRequest; + + bidRequests = [ + { + adUnitCode: 'adUnitCode', + auctionId: 'auctionId', + bidId: 'bidId', + bidder: 'ogury', + params: { + assetKey: 'OGY-assetkey', + adUnitId: 'adunitId', + }, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + getFloor: ({ size, currency, mediaType }) => { + const floorResult = { + currency: 'USD', + floor: 0 + }; + + if (mediaType === 'banner') { + floorResult.floor = 4; + } else { + floorResult.floor = 1000; + } + + return floorResult; + }, + transactionId: 'transactionId' + }, + { + adUnitCode: 'adUnitCode2', + auctionId: 'auctionId', + bidId: 'bidId2', + bidder: 'ogury', + params: { + assetKey: 'OGY-assetkey', + adUnitId: 'adunitId2' + }, + mediaTypes: { + banner: { + sizes: [[600, 500]] + } + }, + transactionId: 'transactionId2' + }, + ]; + + bidderRequest = { + auctionId: bidRequests[0].auctionId, + gdprConsent: {consentString: 'myConsentString', vendorData: {}, gdprApplies: true}, + }; + + describe('isBidRequestValid', function () { + it('should validate correct bid', () => { + let validBid = deepClone(bidRequests[0]); + + let isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true); + }); + + it('should not validate incorrect bid', () => { + let invalidBid = deepClone(bidRequests[0]); + delete invalidBid.sizes; + delete invalidBid.mediaTypes; + + let isValid = spec.isBidRequestValid(invalidBid); + expect(isValid).to.equal(false); + }); + + it('should not validate bid if adunit is not present', () => { + let invalidBid = deepClone(bidRequests[0]); + delete invalidBid.params.adUnitId; + + let isValid = spec.isBidRequestValid(invalidBid); + expect(isValid).to.equal(false); + }); + + it('should not validate bid if assetKet is not present', () => { + let invalidBid = deepClone(bidRequests[0]); + delete invalidBid.params.assetKey; + + let isValid = spec.isBidRequestValid(invalidBid); + expect(isValid).to.equal(false); + }); + + it('should validate bid if getFloor is not present', () => { + let invalidBid = deepClone(bidRequests[1]); + delete invalidBid.getFloor; + + let isValid = spec.isBidRequestValid(invalidBid); + expect(isValid).to.equal(true); + }); + }); + + describe('buildRequests', function () { + const defaultTimeout = 1000; + const expectedRequestObject = { + id: bidRequests[0].auctionId, + at: 2, + tmax: defaultTimeout, + imp: [{ + id: bidRequests[0].bidId, + tagid: bidRequests[0].params.adUnitId, + bidfloor: 4, + banner: { + format: [{ + w: 300, + h: 250 + }] + } + }, { + id: bidRequests[1].bidId, + tagid: bidRequests[1].params.adUnitId, + bidfloor: 0, + banner: { + format: [{ + w: 600, + h: 500 + }] + } + }], + regs: { + ext: { + gdpr: 1 + }, + }, + site: { + id: bidRequests[0].params.assetKey, + domain: window.location.hostname, + }, + user: { + ext: { + consent: bidderRequest.gdprConsent.consentString + }, + } + }; + + it('sends bid request to ENDPOINT via POST', function () { + const validBidRequests = deepClone(bidRequests) + + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.url).to.equal(BID_HOST); + expect(request.method).to.equal('POST'); + }); + + it('bid request object should be conform', function () { + const validBidRequests = deepClone(bidRequests) + + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.data).to.deep.equal(expectedRequestObject); + expect(request.data.regs.ext.gdpr).to.be.a('number'); + }); + + it('should not add gdpr infos if not present', () => { + const bidderRequestWithoutGdpr = { + ...bidderRequest, + gdprConsent: {}, + } + const expectedRequestObjectWithoutGdpr = { + ...expectedRequestObject, + regs: { + ext: { + gdpr: 1 + }, + }, + user: { + ext: { + consent: '' + }, + } + }; + + const validBidRequests = bidRequests + + const request = spec.buildRequests(validBidRequests, bidderRequestWithoutGdpr); + expect(request.data).to.deep.equal(expectedRequestObjectWithoutGdpr); + expect(request.data.regs.ext.gdpr).to.be.a('number'); + }); + + it('should handle bidFloor undefined', () => { + const expectedRequestWithUndefinedFloor = { + ...expectedRequestObject + }; + + const validBidRequests = deepClone(bidRequests); + validBidRequests[1] = { + ...validBidRequests[1], + getFloor: undefined + }; + + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.data).to.deep.equal(expectedRequestWithUndefinedFloor); + }); + + it('should handle bidFloor when is not function', () => { + const expectedRequestWithNotAFunctionFloor = { + ...expectedRequestObject + }; + + let validBidRequests = deepClone(bidRequests); + validBidRequests[1] = { + ...validBidRequests[1], + getFloor: 'getFloor' + }; + + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.data).to.deep.equal(expectedRequestWithNotAFunctionFloor); + }); + + it('should handle bidFloor when currency is not USD', () => { + const expectedRequestWithUnsupportedFloorCurrency = deepClone(expectedRequestObject) + expectedRequestWithUnsupportedFloorCurrency.imp[0].bidfloor = 0; + let validBidRequests = deepClone(bidRequests); + validBidRequests[0] = { + ...validBidRequests[0], + getFloor: ({ size, currency, mediaType }) => { + return { + currency: 'EUR', + floor: 4 + } + } + }; + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.data).to.deep.equal(expectedRequestWithUnsupportedFloorCurrency); + }); + }); + + describe('interpretResponse', function () { + let openRtbBidResponse = { + body: { + id: 'id_of_bid_response', + seatbid: [{ + bid: [{ + id: 'advertId', + impid: 'bidId', + price: 100, + nurl: 'url', + adm: `test creative
cookies
`, + adomain: ['renault.fr'], + w: 300, + h: 250 + }, { + id: 'advertId2', + impid: 'bidId2', + price: 150, + nurl: 'url2', + adm: `test creative
cookies
`, + adomain: ['peugeot.fr'], + w: 600, + h: 500 + }], + }] + } + }; + + it('should correctly interpret bidResponse', () => { + let expectedInterpretedBidResponse = [{ + requestId: openRtbBidResponse.body.seatbid[0].bid[0].impid, + cpm: openRtbBidResponse.body.seatbid[0].bid[0].price, + currency: 'USD', + width: openRtbBidResponse.body.seatbid[0].bid[0].w, + height: openRtbBidResponse.body.seatbid[0].bid[0].h, + ad: openRtbBidResponse.body.seatbid[0].bid[0].adm, + ttl: 60, + creativeId: openRtbBidResponse.body.seatbid[0].bid[0].id, + netRevenue: true, + meta: { + advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[0].adomain + } + }, { + requestId: openRtbBidResponse.body.seatbid[0].bid[1].impid, + cpm: openRtbBidResponse.body.seatbid[0].bid[1].price, + currency: 'USD', + width: openRtbBidResponse.body.seatbid[0].bid[1].w, + height: openRtbBidResponse.body.seatbid[0].bid[1].h, + ad: openRtbBidResponse.body.seatbid[0].bid[1].adm, + ttl: 60, + creativeId: openRtbBidResponse.body.seatbid[0].bid[1].id, + netRevenue: true, + meta: { + advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[1].adomain + } + }] + + let request = spec.buildRequests(bidRequests, bidderRequest); + let result = spec.interpretResponse(openRtbBidResponse, request); + + expect(result).to.deep.equal(expectedInterpretedBidResponse) + }); + + it('should return empty array if error during parsing', () => { + const wrongOpenRtbBidReponse = 'wrong data' + let request = spec.buildRequests(bidRequests, bidderRequest); + let result = spec.interpretResponse(wrongOpenRtbBidReponse, request); + + expect(result).to.be.instanceof(Array); + expect(result.length).to.equal(0) + }) + }); +}); From 01dc3c6e989b7ebadc8ab41834fbf16f7966776c Mon Sep 17 00:00:00 2001 From: Ian Flournoy Date: Mon, 24 May 2021 17:34:06 -0400 Subject: [PATCH 220/303] ParrableIdSystem: Store third-party cookie support status in first-party cookie (#6741) * Add tpcSupport, read it from xxhr and store it in compound cookie * Parse a cookie boolean number (0, 1) as a boolean value * Improve conditions * Add tests * Tests passing * Read the cookie splitting parrableId and params (tpc, tpcUntil) * Adapt tests * Revert linting in test task * Convert Date.now to seconds on reading cookie * Add tests * Replace Math.trunc with Math.floor * kick off test * unfollowed local fork, kick off test * Increase cookie expire time to 20s Co-authored-by: Victor Co-authored-by: Chris Huie <3444727+ChrisHuie@users.noreply.github.com> --- modules/parrableIdSystem.js | 61 ++++++--- test/spec/modules/parrableIdSystem_spec.js | 149 ++++++++++++++++++++- 2 files changed, 191 insertions(+), 19 deletions(-) diff --git a/modules/parrableIdSystem.js b/modules/parrableIdSystem.js index 826dd9a933a..36ac7070ec1 100644 --- a/modules/parrableIdSystem.js +++ b/modules/parrableIdSystem.js @@ -34,25 +34,36 @@ function deserializeParrableId(parrableIdStr) { values.forEach(function(value) { const pair = value.split(':'); - // unpack a value of 1 as true - parrableId[pair[0]] = +pair[1] === 1 ? true : pair[1]; + if (+pair[1] === 1 || (pair[1] !== null && +pair[1] === 0)) { // unpack a value of 0 or 1 as boolean + parrableId[pair[0]] = Boolean(+pair[1]); + } else if (!isNaN(pair[1])) { // convert to number if is a number + parrableId[pair[0]] = +pair[1] + } else { + parrableId[pair[0]] = pair[1] + } }); return parrableId; } -function serializeParrableId(parrableId) { +function serializeParrableId(parrableIdAndParams) { let components = []; - if (parrableId.eid) { - components.push('eid:' + parrableId.eid); + if (parrableIdAndParams.eid) { + components.push('eid:' + parrableIdAndParams.eid); } - if (parrableId.ibaOptout) { + if (parrableIdAndParams.ibaOptout) { components.push('ibaOptout:1'); } - if (parrableId.ccpaOptout) { + if (parrableIdAndParams.ccpaOptout) { components.push('ccpaOptout:1'); } + if (parrableIdAndParams.tpcSupport !== undefined) { + const tpcSupportComponent = parrableIdAndParams.tpcSupport === true ? 'tpc:1' : 'tpc:0'; + const tpcUntil = `tpcUntil:${parrableIdAndParams.tpcUntil}`; + components.push(tpcSupportComponent); + components.push(tpcUntil); + } return components.join(','); } @@ -84,14 +95,21 @@ function encodeBase64UrlSafe(base64) { function readCookie() { const parrableIdStr = storage.getCookie(PARRABLE_COOKIE_NAME); if (parrableIdStr) { - return deserializeParrableId(decodeURIComponent(parrableIdStr)); + const parsedCookie = deserializeParrableId(decodeURIComponent(parrableIdStr)); + const { tpc, tpcUntil, ...parrableId } = parsedCookie; + let { eid, ibaOptout, ccpaOptout, ...params } = parsedCookie; + + if ((Date.now() / 1000) >= tpcUntil) { + params.tpc = undefined; + } + return { parrableId, params }; } return null; } -function writeCookie(parrableId) { - if (parrableId) { - const parrableIdStr = encodeURIComponent(serializeParrableId(parrableId)); +function writeCookie(parrableIdAndParams) { + if (parrableIdAndParams) { + const parrableIdStr = encodeURIComponent(serializeParrableId(parrableIdAndParams)); storage.setCookie(PARRABLE_COOKIE_NAME, parrableIdStr, getExpirationDate(), 'lax'); } } @@ -175,10 +193,14 @@ function shouldFilterImpression(configParams, parrableId) { return isBlocked() || !isAllowed(); } +function epochFromTtl(ttl) { + return Math.floor((Date.now() / 1000) + ttl); +} + function fetchId(configParams, gdprConsentData) { if (!isValidConfig(configParams)) return; - let parrableId = readCookie(); + let { parrableId, params } = readCookie() || {}; if (!parrableId) { parrableId = readLegacyCookies(); migrateLegacyCookies(parrableId); @@ -188,12 +210,13 @@ function fetchId(configParams, gdprConsentData) { return null; } - const eid = (parrableId) ? parrableId.eid : null; + const eid = parrableId ? parrableId.eid : null; const refererInfo = getRefererInfo(); + const tpcSupport = params ? params.tpc : null const uspString = uspDataHandler.getConsentData(); const gdprApplies = (gdprConsentData && typeof gdprConsentData.gdprApplies === 'boolean' && gdprConsentData.gdprApplies); const gdprConsentString = (gdprConsentData && gdprApplies && gdprConsentData.consentString) || ''; - const partners = configParams.partners || configParams.partner + const partners = configParams.partners || configParams.partner; const trackers = typeof partners === 'string' ? partners.split(',') : partners; @@ -203,7 +226,8 @@ function fetchId(configParams, gdprConsentData) { trackers, url: refererInfo.referer, prebidVersion: '$prebid.version$', - isIframe: utils.inIframe() + isIframe: utils.inIframe(), + tpcSupport }; const searchParams = { @@ -229,6 +253,7 @@ function fetchId(configParams, gdprConsentData) { const callbacks = { success: response => { let newParrableId = parrableId ? utils.deepClone(parrableId) : {}; + let newParams = {}; if (response) { try { let responseObj = JSON.parse(response); @@ -242,12 +267,16 @@ function fetchId(configParams, gdprConsentData) { if (responseObj.ibaOptout === true) { newParrableId.ibaOptout = true; } + if (responseObj.tpcSupport !== undefined) { + newParams.tpcSupport = responseObj.tpcSupport; + newParams.tpcUntil = epochFromTtl(responseObj.tpcSupportTtl); + } } } catch (error) { utils.logError(error); cb(); } - writeCookie(newParrableId); + writeCookie({ ...newParrableId, ...newParams }); cb(newParrableId); } else { utils.logError('parrableId: ID fetch returned an empty result'); diff --git a/test/spec/modules/parrableIdSystem_spec.js b/test/spec/modules/parrableIdSystem_spec.js index 3f517a66c68..c18574aec7b 100644 --- a/test/spec/modules/parrableIdSystem_spec.js +++ b/test/spec/modules/parrableIdSystem_spec.js @@ -12,6 +12,7 @@ import { server } from 'test/mocks/xhr.js'; const storage = newStorageManager(); const EXPIRED_COOKIE_DATE = 'Thu, 01 Jan 1970 00:00:01 GMT'; +const EXPIRE_COOKIE_TIME = 20000; const P_COOKIE_NAME = '_parrable_id'; const P_COOKIE_EID = '01.1563917337.test-eid'; const P_XHR_EID = '01.1588030911.test-new-eid' @@ -21,6 +22,7 @@ const P_CONFIG_MOCK = { partners: 'parrable_test_partner_123,parrable_test_partner_456' } }; +const RESPONSE_HEADERS = { 'Content-Type': 'application/json' }; function getConfigMock() { return { @@ -57,6 +59,11 @@ function serializeParrableId(parrableId) { if (parrableId.ccpaOptout) { str += ',ccpaOptout:1'; } + if (parrableId.tpc !== undefined) { + const tpcSupportComponent = parrableId.tpc === true ? 'tpc:1' : 'tpc:0'; + str += `,${tpcSupportComponent}`; + str += `,tpcUntil:${parrableId.tpcUntil}`; + } return str; } @@ -65,7 +72,7 @@ function writeParrableCookie(parrableId) { storage.setCookie( P_COOKIE_NAME, cookieValue, - (new Date(Date.now() + 5000).toUTCString()), + (new Date(Date.now() + EXPIRE_COOKIE_TIME).toUTCString()), 'lax' ); } @@ -125,7 +132,6 @@ describe('Parrable ID System', function() { { 'Content-Type': 'text/plain' }, JSON.stringify({ eid: P_XHR_EID }) ); - expect(callbackSpy.lastCall.lastArg).to.deep.equal({ eid: P_XHR_EID }); @@ -242,6 +248,143 @@ describe('Parrable ID System', function() { }) }); }); + + describe('third party cookie support status', function () { + let logErrorStub; + let callbackSpy = sinon.spy(); + + beforeEach(function() { + logErrorStub = sinon.stub(utils, 'logError'); + }); + + afterEach(function () { + callbackSpy.resetHistory(); + removeParrableCookie(); + }); + + afterEach(function() { + logErrorStub.restore(); + }); + + describe('when getting tpcSupport from XHR response', function () { + let request; + let dateNowStub; + const dateNowMock = Date.now(); + const tpcSupportTtl = 1; + + before(() => { + dateNowStub = sinon.stub(Date, 'now').returns(dateNowMock); + }); + + after(() => { + dateNowStub.restore(); + }); + + it('should set tpcSupport: true and tpcUntil in the cookie', function () { + let { callback } = parrableIdSubmodule.getId(P_CONFIG_MOCK); + callback(callbackSpy); + request = server.requests[0]; + + request.respond( + 200, + RESPONSE_HEADERS, + JSON.stringify({ eid: P_XHR_EID, tpcSupport: true, tpcSupportTtl }) + ); + + expect(storage.getCookie(P_COOKIE_NAME)).to.equal( + encodeURIComponent('eid:' + P_XHR_EID + ',tpc:1,tpcUntil:' + Math.floor((dateNowMock / 1000) + tpcSupportTtl)) + ); + }); + + it('should set tpcSupport: false and tpcUntil in the cookie', function () { + let { callback } = parrableIdSubmodule.getId(P_CONFIG_MOCK); + callback(callbackSpy); + request = server.requests[0]; + request.respond( + 200, + RESPONSE_HEADERS, + JSON.stringify({ eid: P_XHR_EID, tpcSupport: false, tpcSupportTtl }) + ); + + expect(storage.getCookie(P_COOKIE_NAME)).to.equal( + encodeURIComponent('eid:' + P_XHR_EID + ',tpc:0,tpcUntil:' + Math.floor((dateNowMock / 1000) + tpcSupportTtl)) + ); + }); + + it('should not set tpcSupport in the cookie', function () { + let { callback } = parrableIdSubmodule.getId(P_CONFIG_MOCK); + callback(callbackSpy); + request = server.requests[0]; + + request.respond( + 200, + RESPONSE_HEADERS, + JSON.stringify({ eid: P_XHR_EID }) + ); + + expect(storage.getCookie(P_COOKIE_NAME)).to.equal( + encodeURIComponent('eid:' + P_XHR_EID) + ); + }); + }); + + describe('when getting tpcSupport from cookie', function () { + let request; + let dateNowStub; + const dateNowMock = Date.now(); + const tpcSupportTtl = dateNowMock; + const tpcUntilExpired = 1; + + before(() => { + dateNowStub = sinon.stub(Date, 'now').returns(dateNowMock); + }); + + after(() => { + dateNowStub.restore(); + }); + + it('should send tpcSupport in the XHR', function () { + writeParrableCookie({ + eid: P_COOKIE_EID, + tpc: true, + tpcUntil: (dateNowMock / 1000) + 1 + }); + let { callback } = parrableIdSubmodule.getId(P_CONFIG_MOCK); + callback(callbackSpy); + request = server.requests[0]; + + let queryParams = utils.parseQS(request.url.split('?')[1]); + let data = JSON.parse(atob(decodeBase64UrlSafe(queryParams.data))); + + expect(data.tpcSupport).to.equal(true); + }); + + it('should unset tpcSupport from cookie when tpcUntil reached', function () { + writeParrableCookie({ + eid: P_COOKIE_EID, + tpcSupport: true, + tpcUntil: tpcUntilExpired + }); + let { callback } = parrableIdSubmodule.getId(P_CONFIG_MOCK); + callback(callbackSpy); + request = server.requests[0]; + + request.respond( + 200, + RESPONSE_HEADERS, + JSON.stringify({ eid: P_XHR_EID, tpcSupport: false, tpcSupportTtl }) + ); + + let queryParams = utils.parseQS(request.url.split('?')[1]); + let data = JSON.parse(atob(decodeBase64UrlSafe(queryParams.data))); + + expect(data.tpcSupport).to.equal(undefined); + expect(storage.getCookie(P_COOKIE_NAME)).to.equal( + encodeURIComponent('eid:' + P_XHR_EID + ',tpc:0,tpcUntil:' + Math.floor((dateNowMock / 1000) + tpcSupportTtl)) + ); + }); + }); + }); }); describe('parrableIdSystem.decode()', function() { @@ -529,7 +672,7 @@ describe('Parrable ID System', function() { }); }); - describe('partners parsing', () => { + describe('partners parsing', function () { let callbackSpy = sinon.spy(); const partnersTestCase = [ From 49f5134c555571e1c3db4cf1b19d8706f533978a Mon Sep 17 00:00:00 2001 From: Scott Menzer Date: Tue, 25 May 2021 11:46:04 +0200 Subject: [PATCH 221/303] update ID5 docs for PD string links (#6824) --- modules/id5IdSystem.md | 4 ++-- modules/userId/userId.md | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/id5IdSystem.md b/modules/id5IdSystem.md index 6a662361492..8ffe29e091f 100644 --- a/modules/id5IdSystem.md +++ b/modules/id5IdSystem.md @@ -1,6 +1,6 @@ # ID5 Universal ID -The ID5 Universal ID is a shared, neutral identifier that publishers and ad tech platforms can use to recognise users even in environments where 3rd party cookies are not available. The ID5 Universal ID is designed to respect users' privacy choices and publishers’ preferences throughout the advertising value chain. For more information about the ID5 Universal ID and detailed integration docs, please visit [our documentation](https://wiki.id5.io/x/BIAZ). We also recommend that you sign up for our [release notes](https://id5.io/universal-id/release-notes) to stay up-to-date with any changes to the implementation of the ID5 Universal ID in Prebid. +The ID5 Universal ID is a shared, neutral identifier that publishers and ad tech platforms can use to recognise users even in environments where 3rd party cookies are not available. The ID5 Universal ID is designed to respect users' privacy choices and publishers’ preferences throughout the advertising value chain. For more information about the ID5 Universal ID and detailed integration docs, please visit [our documentation](https://support.id5.io/portal/en/kb/articles/prebid-js-user-id-module). We also recommend that you sign up for our [release notes](https://id5.io/universal-id/release-notes) to stay up-to-date with any changes to the implementation of the ID5 Universal ID in Prebid. ## ID5 Universal ID Registration @@ -48,7 +48,7 @@ pbjs.setConfig({ | name | Required | String | The name of this module: `"id5Id"` | `"id5Id"` | | params | Required | Object | Details for the ID5 Universal ID. | | | params.partner | Required | Number | This is the ID5 Partner Number obtained from registering with ID5. | `173` | -| params.pd | Optional | String | Publisher-supplied data used for linking ID5 IDs across domains. See [our documentation](https://wiki.id5.io/x/BIAZ) for details on generating the string. Omit the parameter or leave as an empty string if no data to supply | `"MT1iNTBjY..."` | +| params.pd | Optional | String | Partner-supplied data used for linking ID5 IDs across domains. See [our documentation](https://support.id5.io/portal/en/kb/articles/passing-partner-data-to-id5) for details on generating the string. Omit the parameter or leave as an empty string if no data to supply | `"MT1iNTBjY..."` | | params.provider | Optional | String | An identifier provided by ID5 to technology partners who manage Prebid setups on behalf of publishers. Reach out to [ID5](mailto:prebid@id5.io) if you have questions about this parameter | `pubmatic-identity-hub` | | params.abTesting | Optional | Object | Allows publishers to easily run an A/B Test. If enabled and the user is in the Control Group, the ID5 ID will NOT be exposed to bid adapters for that request | Disabled by default | | params.abTesting.enabled | Optional | Boolean | Set this to `true` to turn on this feature | `true` or `false` | diff --git a/modules/userId/userId.md b/modules/userId/userId.md index 5d78a447572..5cf4a6c2128 100644 --- a/modules/userId/userId.md +++ b/modules/userId/userId.md @@ -36,7 +36,7 @@ pbjs.setConfig({ name: "id5Id", params: { partner: 173, // Set your real ID5 partner ID here for production, please ask for one at https://id5.io/universal-id - pd: "some-pd-string" // See https://wiki.id5.io/x/BIAZ for details + pd: "some-pd-string" // See https://support.id5.io/portal/en/kb/articles/passing-partner-data-to-id5 for details }, storage: { type: "html5", // ID5 requires html5 @@ -107,7 +107,7 @@ pbjs.setConfig({ type: "cookie", name: "merkleId", expires: 30 - } + } },{ name: 'uid2' } @@ -126,7 +126,7 @@ pbjs.setConfig({ },{ name: 'flocId', params: { - token: "Registered token or default sharedid.org token" // Default sharedid.org token: "A3dHTSoNUMjjERBLlrvJSelNnwWUCwVQhZ5tNQ+sll7y+LkPPVZXtB77u2y7CweRIxiYaGwGXNlW1/dFp8VMEgIAAAB+eyJvcmlnaW4iOiJodHRwczovL3NoYXJlZGlkLm9yZzo0NDMiLCJmZWF0dXJlIjoiSW50ZXJlc3RDb2hvcnRBUEkiLCJleHBpcnkiOjE2MjYyMjA3OTksImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9" + token: "Registered token or default sharedid.org token" // Default sharedid.org token: "A3dHTSoNUMjjERBLlrvJSelNnwWUCwVQhZ5tNQ+sll7y+LkPPVZXtB77u2y7CweRIxiYaGwGXNlW1/dFp8VMEgIAAAB+eyJvcmlnaW4iOiJodHRwczovL3NoYXJlZGlkLm9yZzo0NDMiLCJmZWF0dXJlIjoiSW50ZXJlc3RDb2hvcnRBUEkiLCJleHBpcnkiOjE2MjYyMjA3OTksImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9" } }], syncDelay: 5000, @@ -192,7 +192,7 @@ pbjs.setConfig({ name: 'id5Id', params: { partner: 173, // Set your real ID5 partner ID here for production, please ask for one at https://id5.io/universal-id - pd: 'some-pd-string' // See https://wiki.id5.io/x/BIAZ for details + pd: 'some-pd-string' // See https://support.id5.io/portal/en/kb/articles/passing-partner-data-to-id5 for details }, storage: { type: 'html5', @@ -224,7 +224,7 @@ pbjs.setConfig({ type: "html5", name: "merkleId", expires: 30 - } + } }, { name: 'admixerId', params: { From 5a337021215b609faf19180fb5143c53293d8e36 Mon Sep 17 00:00:00 2001 From: Olivier Date: Tue, 25 May 2021 12:11:17 +0200 Subject: [PATCH 222/303] Adagio Bid Adapter: decrease adapter weight (#6699) --- allowedModules.js | 1 - modules/adagioBidAdapter.js | 79 ++++++---------------- package-lock.json | 5 -- package.json | 1 - test/spec/modules/adagioBidAdapter_spec.js | 2 + 5 files changed, 24 insertions(+), 64 deletions(-) diff --git a/allowedModules.js b/allowedModules.js index d8e8b69f593..2d23b35c501 100644 --- a/allowedModules.js +++ b/allowedModules.js @@ -12,7 +12,6 @@ module.exports = { 'modules': [ ...sharedWhiteList, 'criteo-direct-rsa-validate', - 'jsencrypt', 'crypto-js', 'live-connect' // Maintained by LiveIntent : https://github.com/liveintent-berlin/live-connect/ ], diff --git a/modules/adagioBidAdapter.js b/modules/adagioBidAdapter.js index 66653567dab..aed1a1682dc 100644 --- a/modules/adagioBidAdapter.js +++ b/modules/adagioBidAdapter.js @@ -3,33 +3,27 @@ import * as utils from '../src/utils.js'; import { config } from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { loadExternalScript } from '../src/adloader.js'; -import JSEncrypt from 'jsencrypt/bin/jsencrypt.js'; -import sha256 from 'crypto-js/sha256.js'; +import { verify } from 'criteo-direct-rsa-validate/build/verify.js'; import { getStorageManager } from '../src/storageManager.js'; import { getRefererInfo } from '../src/refererDetection.js'; import { createEidsArray } from './userId/eids.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import { Renderer } from '../src/Renderer.js'; import { OUTSTREAM } from '../src/video.js'; - -export const BIDDER_CODE = 'adagio'; -export const LOG_PREFIX = 'Adagio:'; -export const VERSION = '2.10.0'; -export const FEATURES_VERSION = '1'; +const BIDDER_CODE = 'adagio'; +const LOG_PREFIX = 'Adagio:'; +export const VERSION = '2.11.0'; +const FEATURES_VERSION = '1'; export const ENDPOINT = 'https://mp.4dex.io/prebid'; -export const SUPPORTED_MEDIA_TYPES = [BANNER, NATIVE, VIDEO]; -export const ADAGIO_TAG_URL = 'https://script.4dex.io/localstore.js'; -export const ADAGIO_LOCALSTORAGE_KEY = 'adagioScript'; -export const GVLID = 617; +const SUPPORTED_MEDIA_TYPES = [BANNER, NATIVE, VIDEO]; +const ADAGIO_TAG_URL = 'https://script.4dex.io/localstore.js'; +const ADAGIO_LOCALSTORAGE_KEY = 'adagioScript'; +const GVLID = 617; export const storage = getStorageManager(GVLID, 'adagio'); export const RENDERER_URL = 'https://script.4dex.io/outstream-player.js'; -export const MAX_SESS_DURATION = 30 * 60 * 1000; -export const ADAGIO_PUBKEY = `-----BEGIN PUBLIC KEY----- -MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9el0+OEn6fvEh1RdVHQu4cnT0 -jFSzIbGJJyg3cKqvtE6A0iaz9PkIdJIvSSSNrmJv+lRGKPEyRA/VnzJIieL39Ngl -t0b0lsHN+W4n9kitS/DZ/xnxWK/9vxhv0ZtL1LL/rwR5Mup7rmJbNtDoNBw4TIGj -pV6EP3MTLosuUEpLaQIDAQAB ------END PUBLIC KEY-----`; +const MAX_SESS_DURATION = 30 * 60 * 1000; +const ADAGIO_PUBKEY = 'AL16XT44Sfp+8SHVF1UdC7hydPSMVLMhsYknKDdwqq+0ToDSJrP0+Qh0ki9JJI2uYm/6VEYo8TJED9WfMkiJ4vf02CW3RvSWwc35bif2SK1L8Nn/GfFYr/2/GG/Rm0vUsv+vBHky6nuuYls20Og0HDhMgaOlXoQ/cxMuiy5QSktp'; +const ADAGIO_PUBKEY_E = 65537; // This provide a whitelist and a basic validation // of OpenRTB 2.5 options used by the Adagio SSP. @@ -81,10 +75,7 @@ export function adagioScriptFromLocalStorageCb(ls) { const hash = r[2]; const content = r[3]; - var jsEncrypt = new JSEncrypt(); - jsEncrypt.setPublicKey(ADAGIO_PUBKEY); - - if (jsEncrypt.verify(content, hash, sha256)) { + if (verify(content, hash, ADAGIO_PUBKEY, ADAGIO_PUBKEY_E)) { utils.logInfo(`${LOG_PREFIX} start script.`); Function(ls)(); // eslint-disable-line no-new-func } else { @@ -524,19 +515,8 @@ function autoDetectAdUnitElementId(adUnitCode) { function autoDetectEnvironment() { const device = _features.getDevice(); - let environment; - switch (device) { - case 2: - environment = 'desktop'; - break; - case 4: - environment = 'mobile'; - break; - case 5: - environment = 'tablet'; - break; - }; - return environment; + const map = { 2: 'desktop', 4: 'mobile', 5: 'tablet' }; + return map[device] || 'unknown'; }; function supportIObs() { @@ -653,25 +633,12 @@ function _getGdprConsent(bidderRequest) { allowAuctionWithoutConsent } = bidderRequest.gdprConsent; - const consent = {}; - - if (apiVersion !== undefined) { - consent.apiVersion = apiVersion; - } - - if (consentString !== undefined) { - consent.consentString = consentString; - } - - if (gdprApplies !== undefined) { - consent.consentRequired = (gdprApplies) ? 1 : 0; - } - - if (allowAuctionWithoutConsent !== undefined) { - consent.allowAuctionWithoutConsent = allowAuctionWithoutConsent ? 1 : 0; - } - - return consent; + return utils.cleanObj({ + apiVersion, + consentString, + consentRequired: gdprApplies ? 1 : 0, + allowAuctionWithoutConsent: allowAuctionWithoutConsent ? 1 : 0 + }); } function _getCoppa() { @@ -685,9 +652,7 @@ function _getUspConsent(bidderRequest) { } function _getSchain(bidRequest) { - if (utils.deepAccess(bidRequest, 'schain')) { - return bidRequest.schain; - } + return utils.deepAccess(bidRequest, 'schain'); } function _getEids(bidRequest) { diff --git a/package-lock.json b/package-lock.json index 3c4e59cdba7..a6a58a530de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15084,11 +15084,6 @@ } } }, - "jsencrypt": { - "version": "3.0.0-rc.1", - "resolved": "https://registry.npmjs.org/jsencrypt/-/jsencrypt-3.0.0-rc.1.tgz", - "integrity": "sha512-gcvGaqerlUJy1Kq6tNgPYteVEoWNemu+9hBe2CdsCIz4rVcwjoTQ72iD1W76/PRMlnkzG0yVh7nwOOMOOUfKmg==" - }, "jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", diff --git a/package.json b/package.json index f7176162f8e..66f1976d4ce 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,6 @@ "dset": "2.0.1", "express": "^4.15.4", "fun-hooks": "^0.9.9", - "jsencrypt": "^3.0.0-rc.1", "just-clone": "^1.0.2", "live-connect-js": "2.0.0" } diff --git a/test/spec/modules/adagioBidAdapter_spec.js b/test/spec/modules/adagioBidAdapter_spec.js index 6ee42e47950..6e0b82cbab8 100644 --- a/test/spec/modules/adagioBidAdapter_spec.js +++ b/test/spec/modules/adagioBidAdapter_spec.js @@ -579,6 +579,7 @@ describe('Adagio bid adapter', () => { const expected = { consentString, + allowAuctionWithoutConsent: 0, consentRequired: 1, apiVersion: 2 }; @@ -615,6 +616,7 @@ describe('Adagio bid adapter', () => { const expected = { consentString, consentRequired: 0, + allowAuctionWithoutConsent: 0, apiVersion: 2 }; From 585c7107645ee9f79befb9d17d2cf8c6000b0d00 Mon Sep 17 00:00:00 2001 From: pm-shashank-jain <40654031+pm-shashank-jain@users.noreply.github.com> Date: Tue, 25 May 2021 16:11:29 +0530 Subject: [PATCH 223/303] PubMatic Adapter : Support For Video Params from AdUnit MediaTypes (#6773) --- modules/pubmaticBidAdapter.js | 128 +++--- test/spec/modules/pubmaticBidAdapter_spec.js | 415 +++++++++++++++++-- 2 files changed, 450 insertions(+), 93 deletions(-) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index ff934204b43..79356415ddf 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -48,7 +48,8 @@ const VIDEO_CUSTOM_PARAMS = { 'linearity': DATA_TYPES.NUMBER, 'placement': DATA_TYPES.NUMBER, 'minbitrate': DATA_TYPES.NUMBER, - 'maxbitrate': DATA_TYPES.NUMBER + 'maxbitrate': DATA_TYPES.NUMBER, + 'skip': DATA_TYPES.NUMBER } const NATIVE_ASSETS = { @@ -167,6 +168,12 @@ const BB_RENDERER = { } }; +const MEDIATYPE = [ + BANNER, + VIDEO, + NATIVE +] + let publisherId = 0; let isInvalidNativeRequest = false; let NATIVE_ASSET_ID_TO_KEY_MAP = {}; @@ -531,7 +538,7 @@ function _createBannerRequest(bid) { } function _createVideoRequest(bid) { - var videoData = bid.params.video; + var videoData = utils.mergeDeep(utils.deepAccess(bid.mediaTypes, 'video'), bid.params.video); var videoObj; if (videoData !== UNDEFINED) { @@ -549,11 +556,6 @@ function _createVideoRequest(bid) { videoObj.w = parseInt(bid.mediaTypes.video.playerSize[0], 10); videoObj.h = parseInt(bid.mediaTypes.video.playerSize[1], 10); } - if (bid.params.video.hasOwnProperty('skippable')) { - videoObj.ext = { - 'video_skippable': bid.params.video.skippable ? 1 : 0 - }; - } } else { videoObj = UNDEFINED; utils.logWarn(LOG_WARN_PREFIX + 'Error: Video config params missing for adunit: ' + bid.params.adUnit + ' with mediaType set as video. Ignoring video impression in the adunit.'); @@ -581,6 +583,28 @@ function _addPMPDealsInImpression(impObj, bid) { } } +function _addDealCustomTargetings(imp, bid) { + var dctr = ''; + var dctrLen; + if (bid.params.dctr) { + dctr = bid.params.dctr; + if (utils.isStr(dctr) && dctr.length > 0) { + var arr = dctr.split('|'); + dctr = ''; + arr.forEach(val => { + dctr += (val.length > 0) ? (val.trim() + '|') : ''; + }); + dctrLen = dctr.length; + if (dctr.substring(dctrLen, dctrLen - 1) === '|') { + dctr = dctr.substring(0, dctrLen - 1); + } + imp.ext['key_val'] = dctr.trim() + } else { + utils.logWarn(LOG_WARN_PREFIX + 'Ignoring param : dctr with value : ' + dctr + ', expects string-value, found empty or non-string value'); + } + } +} + function _createImpressionObject(bid, conf) { var impObj = {}; var bannerObj; @@ -602,7 +626,7 @@ function _createImpressionObject(bid, conf) { }; _addPMPDealsInImpression(impObj, bid); - + _addDealCustomTargetings(impObj, bid); if (bid.hasOwnProperty('mediaTypes')) { for (mediaTypes in bid.mediaTypes) { switch (mediaTypes) { @@ -779,22 +803,28 @@ function _handleEids(payload, validBidRequests) { } } -function _checkMediaType(adm, newBid) { +function _checkMediaType(bid, newBid) { // Create a regex here to check the strings - var admStr = ''; - var videoRegex = new RegExp(/VAST\s+version/); - if (adm.indexOf('span class="PubAPIAd"') >= 0) { - newBid.mediaType = BANNER; - } else if (videoRegex.test(adm)) { - newBid.mediaType = VIDEO; + if (bid.ext && bid.ext['BidType'] != undefined) { + newBid.mediaType = MEDIATYPE[bid.ext.BidType]; } else { - try { - admStr = JSON.parse(adm.replace(/\\/g, '')); - if (admStr && admStr.native) { - newBid.mediaType = NATIVE; + utils.logInfo(LOG_WARN_PREFIX + 'bid.ext.BidType does not exist, checking alternatively for mediaType') + var adm = bid.adm; + var admStr = ''; + var videoRegex = new RegExp(/VAST\s+version/); + if (adm.indexOf('span class="PubAPIAd"') >= 0) { + newBid.mediaType = BANNER; + } else if (videoRegex.test(adm)) { + newBid.mediaType = VIDEO; + } else { + try { + admStr = JSON.parse(adm.replace(/\\/g, '')); + if (admStr && admStr.native) { + newBid.mediaType = NATIVE; + } + } catch (e) { + utils.logWarn(LOG_WARN_PREFIX + 'Error: Cannot parse native reponse for ad response: ' + adm); } - } catch (e) { - utils.logWarn(LOG_WARN_PREFIX + 'Error: Cannot parse native reponse for ad response: ' + adm); } } } @@ -884,38 +914,6 @@ function _blockedIabCategoriesValidation(payload, blockedIabCategories) { } } -function _handleDealCustomTargetings(payload, dctrArr, validBidRequests) { - var dctr = ''; - var dctrLen; - // set dctr value in site.ext, if present in validBidRequests[0], else ignore - if (dctrArr.length > 0) { - if (validBidRequests[0].params.hasOwnProperty('dctr')) { - dctr = validBidRequests[0].params.dctr; - if (utils.isStr(dctr) && dctr.length > 0) { - var arr = dctr.split('|'); - dctr = ''; - arr.forEach(val => { - dctr += (val.length > 0) ? (val.trim() + '|') : ''; - }); - dctrLen = dctr.length; - if (dctr.substring(dctrLen, dctrLen - 1) === '|') { - dctr = dctr.substring(0, dctrLen - 1); - } - payload.site.ext = { - key_val: dctr.trim() - } - } else { - utils.logWarn(LOG_WARN_PREFIX + 'Ignoring param : dctr with value : ' + dctr + ', expects string-value, found empty or non-string value'); - } - if (dctrArr.length > 1) { - utils.logWarn(LOG_WARN_PREFIX + 'dctr value found in more than 1 adunits. Value from 1st adunit will be picked. Ignoring values from subsequent adunits'); - } - } else { - utils.logWarn(LOG_WARN_PREFIX + 'dctr value not found in 1st adunit, ignoring values from subsequent adunits'); - } - } -} - function _assignRenderer(newBid, request) { let bidParams, context, adUnitCode; if (request.bidderRequest && request.bidderRequest.bids) { @@ -950,22 +948,17 @@ export const spec = { return false; } // video ad validation - if (bid.params.hasOwnProperty('video')) { - if (!bid.params.video.hasOwnProperty('mimes') || !utils.isArray(bid.params.video.mimes) || bid.params.video.mimes.length === 0) { + if (bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) { + if (!bid.mediaTypes.video.mimes || (bid.params.video && (!bid.params.video.hasOwnProperty('mimes') || !utils.isArray(bid.params.video.mimes) || bid.params.video.mimes.length === 0))) { utils.logWarn(LOG_WARN_PREFIX + 'Error: For video ads, mimes is mandatory and must specify atlease 1 mime value. Call to OpenBid will not be sent for ad unit:' + JSON.stringify(bid)); return false; } - if (bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) { - if (!bid.mediaTypes[VIDEO].hasOwnProperty('context')) { - utils.logError(`${LOG_WARN_PREFIX}: no context specified in bid. Rejecting bid: `, bid); - return false; - } - if (bid.mediaTypes[VIDEO].context === 'outstream' && !utils.isStr(bid.params.outstreamAU) && !bid.hasOwnProperty('renderer') && !bid.mediaTypes[VIDEO].hasOwnProperty('renderer')) { - utils.logError(`${LOG_WARN_PREFIX}: for "outstream" bids either outstreamAU parameter must be provided or ad unit supplied renderer is required. Rejecting bid: `, bid); - return false; - } - } else { - utils.logError(`${LOG_WARN_PREFIX}: mediaTypes or mediaTypes.video is not specified. Rejecting bid: `, bid); + if (!bid.mediaTypes[VIDEO].hasOwnProperty('context')) { + utils.logError(`${LOG_WARN_PREFIX}: no context specified in bid. Rejecting bid: `, bid); + return false; + } + if (bid.mediaTypes[VIDEO].context === 'outstream' && !utils.isStr(bid.params.outstreamAU) && !bid.hasOwnProperty('renderer') && !bid.mediaTypes[VIDEO].hasOwnProperty('renderer')) { + utils.logError(`${LOG_WARN_PREFIX}: for "outstream" bids either outstreamAU parameter must be provided or ad unit supplied renderer is required. Rejecting bid: `, bid); return false; } } @@ -1090,7 +1083,6 @@ export const spec = { utils.deepSetValue(payload, 'regs.coppa', 1); } - _handleDealCustomTargetings(payload, dctrArr, validBidRequests); _handleEids(payload, validBidRequests); _blockedIabCategoriesValidation(payload, blockedIabCategories); _handleFlocId(payload, validBidRequests); @@ -1164,7 +1156,7 @@ export const spec = { if (parsedRequest.imp && parsedRequest.imp.length > 0) { parsedRequest.imp.forEach(req => { if (bid.impid === req.id) { - _checkMediaType(bid.adm, newBid); + _checkMediaType(bid, newBid); switch (newBid.mediaType) { case BANNER: break; diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index e8948fdc2d3..ae0b351c367 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -791,6 +791,151 @@ describe('PubMatic adapter', function () { isValid = spec.isBidRequestValid(validBid); expect(isValid).to.equal(true); }); + + it('should check for context if video is present', function() { + let bid = { + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5890' + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }, + isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(true); + }) + + it('should return false if context is not present in video', function() { + let bid = { + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5890' + }, + 'mediaTypes': { + 'video': { + 'w': 640, + 'h': 480, + 'protocols': [1, 2, 5], + 'mimes': ['video/flv'], + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }, + isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(false); + }) + + it('should check for mimes if video is present', function() { + let bid = { + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5890' + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }, + isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(true); + }) + + it('should return false if mimes is not present in video', function() { + let bid = { + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5890' + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }, + isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(false); + }) }); describe('Request formation', function () { @@ -858,8 +1003,6 @@ describe('PubMatic adapter', function () { expect(data.site.domain).to.be.a('string'); // domain should be set expect(data.site.page).to.equal(bidRequests[0].params.kadpageurl); // forced pageURL expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id - expect(data.site.ext).to.exist.and.to.be.an('object'); // dctr parameter - expect(data.site.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr); expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude @@ -879,6 +1022,7 @@ describe('PubMatic adapter', function () { expect(data.imp[0].banner.w).to.equal(300); // width expect(data.imp[0].banner.h).to.equal(250); // height expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid + expect(data.imp[0].ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr); expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); expect(data.source.ext.schain).to.deep.equal(bidRequests[0].schain); }); @@ -967,7 +1111,6 @@ describe('PubMatic adapter', function () { expect(data.app.bundle).to.equal('org.prebid.mobile.demoapp'); expect(data.app.domain).to.equal('prebid.org'); expect(data.app.publisher.id).to.equal(bidRequests[0].params.publisherId); - expect(data.app.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr); expect(data.site).to.not.exist; sandbox.restore(); }); @@ -994,7 +1137,6 @@ describe('PubMatic adapter', function () { expect(data.app.bundle).to.equal('org.prebid.mobile.demoapp'); expect(data.app.domain).to.equal('prebid.org'); expect(data.app.publisher.id).to.equal(bidRequests[0].params.publisherId); - expect(data.app.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr); expect(data.app.content).to.deep.equal(content); expect(data.site).to.not.exist; sandbox.restore(); @@ -1026,7 +1168,6 @@ describe('PubMatic adapter', function () { expect(data.app.bundle).to.equal('org.prebid.mobile.demoapp'); expect(data.app.domain).to.equal('prebid.org'); expect(data.app.publisher.id).to.equal(bidRequests[0].params.publisherId); - expect(data.app.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr); expect(data.app.content).to.deep.equal(appContent); expect(data.site).to.not.exist; sandbox.restore(); @@ -1043,8 +1184,6 @@ describe('PubMatic adapter', function () { expect(data.site.domain).to.be.a('string'); // domain should be set expect(data.site.page).to.equal(bidRequests[0].params.kadpageurl); // forced pageURL expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id - expect(data.site.ext).to.exist.and.to.be.an('object'); // dctr parameter - expect(data.site.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr); expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude @@ -1063,6 +1202,7 @@ describe('PubMatic adapter', function () { expect(data.imp[0].banner.w).to.equal(728); // width expect(data.imp[0].banner.h).to.equal(90); // height expect(data.imp[0].banner.format).to.deep.equal([{w: 160, h: 600}]); + expect(data.imp[0].ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr); expect(data.imp[0].ext.pmZoneId).to.equal(bidRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); }); @@ -2167,7 +2307,6 @@ describe('PubMatic adapter', function () { let data = JSON.parse(request.data); expect(data.imp[0].video).to.exist; expect(data.imp[0].tagid).to.equal('Div1'); - expect(data.imp[0].video.ext['video_skippable']).to.equal(videoBidRequests[0].params.video.skippable ? 1 : 0); expect(data.imp[0]['video']['mimes']).to.exist.and.to.be.an('array'); expect(data.imp[0]['video']['mimes'][0]).to.equal(videoBidRequests[0].params.video['mimes'][0]); expect(data.imp[0]['video']['mimes'][1]).to.equal(videoBidRequests[0].params.video['mimes'][1]); @@ -2237,7 +2376,6 @@ describe('PubMatic adapter', function () { // video imp object check expect(data.imp[1].video).to.exist; expect(data.imp[1].tagid).to.equal('Div1'); - expect(data.imp[1].video.ext['video_skippable']).to.equal(multipleMediaRequests[1].params.video.skippable ? 1 : 0); expect(data.imp[1]['video']['mimes']).to.exist.and.to.be.an('array'); expect(data.imp[1]['video']['mimes'][0]).to.equal(multipleMediaRequests[1].params.video['mimes'][0]); expect(data.imp[1]['video']['mimes'][1]).to.equal(multipleMediaRequests[1].params.video['mimes'][1]); @@ -2556,6 +2694,93 @@ describe('PubMatic adapter', function () { expect(data.video).to.exist; expect(data.native).to.not.exist; }); + + it('should build video impression if video params are present in adunit.mediaTypes instead of bid.params', function() { + let videoReq = [{ + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5890', + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': 'adc36682-887c-41e9-9848-8b72c08332c0', + 'sizes': [ + [640, 480] + ], + 'bidId': '21b59b1353ba82', + 'bidderRequestId': '1a08245305e6dd', + 'auctionId': 'bad3a743-7491-4d19-9a96-b0a69dd24a67', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }] + let request = spec.buildRequests(videoReq, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.video).to.exist; + }); + + it('should build video impression with overwriting video params present in adunit.mediaTypes with bid.params', function() { + let videoReq = [{ + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5890', + 'video': { + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 5], + 'linearity': 1 + } + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': 'adc36682-887c-41e9-9848-8b72c08332c0', + 'sizes': [ + [640, 480] + ], + 'bidId': '21b59b1353ba82', + 'bidderRequestId': '1a08245305e6dd', + 'auctionId': 'bad3a743-7491-4d19-9a96-b0a69dd24a67', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }] + let request = spec.buildRequests(videoReq, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; + + expect(data.video).to.exist; + expect(data.video.linearity).to.equal(1); + }); }); it('Request params dctr check', function () { @@ -2565,17 +2790,6 @@ describe('PubMatic adapter', function () { params: { publisherId: '301', adSlot: '/15671365/DMDemo@300x250:0', - kadfloor: '1.2', - pmzoneid: 'aabc, ddef', - kadpageurl: 'www.publisher.com', - yob: '1986', - gender: 'M', - lat: '12.3', - lon: '23.7', - wiid: '1234567890', - profId: '100', - verId: '200', - currency: 'AUD', dctr: 'key1=val1|key2=val2,!val3' }, placementCode: '/19968336/header-bid-tag-1', @@ -2621,11 +2835,11 @@ describe('PubMatic adapter', function () { dctr is found in adunit[0] */ - expect(data.site.ext).to.exist.and.to.be.an('object'); // dctr parameter - expect(data.site.ext.key_val).to.exist.and.to.equal(multipleBidRequests[0].params.dctr); + expect(data.imp[0].ext).to.exist.and.to.be.an('object'); // dctr parameter + expect(data.imp[0].ext.key_val).to.exist.and.to.equal(multipleBidRequests[0].params.dctr); /* case 2 - - dctr not present in adunit[0] + dctr not present in adunit[0] but present in adunit[1] */ delete multipleBidRequests[0].params.dctr; request = spec.buildRequests(multipleBidRequests, { @@ -2633,7 +2847,9 @@ describe('PubMatic adapter', function () { }); data = JSON.parse(request.data); - expect(data.site.ext).to.not.exist; + expect(data.imp[0].ext).to.exist.and.to.deep.equal({}); + expect(data.imp[1].ext).to.exist.and.to.be.an('object'); // dctr parameter + expect(data.imp[1].ext.key_val).to.exist.and.to.equal(multipleBidRequests[1].params.dctr); /* case 3 - dctr is present in adunit[0], but is not a string value @@ -2644,7 +2860,7 @@ describe('PubMatic adapter', function () { }); data = JSON.parse(request.data); - expect(data.site.ext).to.not.exist; + expect(data.imp[0].ext).to.exist.and.to.deep.equal({}); }); it('Request params deals check', function () { @@ -3028,6 +3244,155 @@ describe('PubMatic adapter', function () { let response = spec.interpretResponse(bidResponses, request); expect(response[0].renderer).to.not.exist; }); + + it('should assign mediaType by reading bid.ext.mediaType', function() { + let newvideoRequests = [{ + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5670', + 'video': { + 'mimes': ['video/mp4'], + 'skippable': true, + 'protocols': [1, 2, 5], + 'linearity': 1 + } + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }]; + let newvideoBidResponses = { + 'body': { + 'id': '1621441141473', + 'cur': 'USD', + 'customdata': 'openrtb1', + 'ext': { + 'buyid': 'myBuyId' + }, + 'seatbid': [{ + 'bid': [{ + 'id': '2c95df014cfe97', + 'impid': '2c95df014cfe97', + 'price': 4.2, + 'cid': 'test1', + 'crid': 'test2', + 'adm': "Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1", + 'w': 0, + 'h': 0, + 'dealId': 'ASEA-MS-KLY-TTD-DESKTOP-ID-VID-6S-030420', + 'ext': { + 'BidType': 1 + } + }], + 'ext': { + 'buyid': 'myBuyId' + } + }] + }, + 'headers': {} + } + let newrequest = spec.buildRequests(newvideoRequests, { + auctionId: 'new-auction-id' + }); + let newresponse = spec.interpretResponse(newvideoBidResponses, newrequest); + expect(newresponse[0].mediaType).to.equal('video') + }) + + it('should assign mediaType even if bid.ext.mediaType does not exists', function() { + let newvideoRequests = [{ + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5670', + 'video': { + 'mimes': ['video/mp4'], + 'skippable': true, + 'protocols': [1, 2, 5], + 'linearity': 1 + } + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }]; + let newvideoBidResponses = { + 'body': { + 'id': '1621441141473', + 'cur': 'USD', + 'customdata': 'openrtb1', + 'ext': { + 'buyid': 'myBuyId' + }, + 'seatbid': [{ + 'bid': [{ + 'id': '2c95df014cfe97', + 'impid': '2c95df014cfe97', + 'price': 4.2, + 'cid': 'test1', + 'crid': 'test2', + 'adm': "Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1", + 'w': 0, + 'h': 0, + 'dealId': 'ASEA-MS-KLY-TTD-DESKTOP-ID-VID-6S-030420' + }], + 'ext': { + 'buyid': 'myBuyId' + } + }] + }, + 'headers': {} + } + let newrequest = spec.buildRequests(newvideoRequests, { + auctionId: 'new-auction-id' + }); + let newresponse = spec.interpretResponse(newvideoBidResponses, newrequest); + expect(newresponse[0].mediaType).to.equal('video') + }) }); describe('getUserSyncs', function() { From 180ddafbb8ebf30f00055e871f615243a2f4deb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bendeg=C3=BAz=20=C3=81cs?= <30595431+acsbendi@users.noreply.github.com> Date: Tue, 25 May 2021 22:38:28 +0200 Subject: [PATCH 224/303] Fill currency parameters for Kobler adapter. (#6825) --- modules/koblerBidAdapter.js | 11 ++++++-- test/spec/modules/koblerBidAdapter_spec.js | 31 +++++++++++++++------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/modules/koblerBidAdapter.js b/modules/koblerBidAdapter.js index cc5b374af95..59d1639a329 100644 --- a/modules/koblerBidAdapter.js +++ b/modules/koblerBidAdapter.js @@ -27,11 +27,14 @@ export const buildRequests = function (validBidRequests, bidderRequest) { }; export const interpretResponse = function (serverResponse) { + const adServerPriceCurrency = config.getConfig('currency.adServerCurrency') || SUPPORTED_CURRENCY; const res = serverResponse.body; const bids = [] if (res) { res.seatbid.forEach(sb => { sb.bid.forEach(b => { + const adWithCorrectCurrency = b.adm + .replace(/\${AUCTION_PRICE_CURRENCY}/g, adServerPriceCurrency); bids.push({ requestId: b.impid, cpm: b.price, @@ -42,7 +45,7 @@ export const interpretResponse = function (serverResponse) { dealId: b.dealid, netRevenue: true, ttl: TIME_TO_LIVE_IN_SECONDS, - ad: b.adm, + ad: adWithCorrectCurrency, nurl: b.nurl, meta: { advertiserDomains: b.adomain @@ -56,10 +59,14 @@ export const interpretResponse = function (serverResponse) { export const onBidWon = function (bid) { const cpm = bid.cpm || 0; + const cpmCurrency = bid.currency || SUPPORTED_CURRENCY; const adServerPrice = utils.deepAccess(bid, 'adserverTargeting.hb_pb', 0); + const adServerPriceCurrency = config.getConfig('currency.adServerCurrency') || SUPPORTED_CURRENCY; if (utils.isStr(bid.nurl) && bid.nurl !== '') { const winNotificationUrl = utils.replaceAuctionPrice(bid.nurl, cpm) - .replace(/\${AD_SERVER_PRICE}/g, adServerPrice); + .replace(/\${AUCTION_PRICE_CURRENCY}/g, cpmCurrency) + .replace(/\${AD_SERVER_PRICE}/g, adServerPrice) + .replace(/\${AD_SERVER_PRICE_CURRENCY}/g, adServerPriceCurrency); utils.triggerPixel(winNotificationUrl); } }; diff --git a/test/spec/modules/koblerBidAdapter_spec.js b/test/spec/modules/koblerBidAdapter_spec.js index 725c9ece118..76c2c287989 100644 --- a/test/spec/modules/koblerBidAdapter_spec.js +++ b/test/spec/modules/koblerBidAdapter_spec.js @@ -513,6 +513,11 @@ describe('KoblerAdapter', function () { }); it('should generate bids from OpenRTB response', function () { + config.setConfig({ + 'currency': { + 'adServerCurrency': 'NOK' + } + }); const responseWithTwoBids = { body: { seatbid: [ @@ -521,12 +526,12 @@ describe('KoblerAdapter', function () { { impid: '6194ddef-89a4-404f-9efd-6b718fc23308', price: 7.981, - nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=${AUCTION_PRICE}&asp=${AD_SERVER_PRICE}', + nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=${AUCTION_PRICE}&sp_cur=${AUCTION_PRICE_CURRENCY}&asp=${AD_SERVER_PRICE}&asp_cur=${AD_SERVER_PRICE_CURRENCY}', crid: 'edea9b03-3a57-41aa-9c00-abd673e22006', dealid: '', w: 320, h: 250, - adm: '', + adm: '', adomain: [ 'https://kobler.no' ] @@ -534,12 +539,12 @@ describe('KoblerAdapter', function () { { impid: '2ec0b40f-d3ca-4ba5-8ce3-48290565690f', price: 6.71234, - nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=nbashgufvishdafjk23432&sp=${AUCTION_PRICE}&asp=${AD_SERVER_PRICE}', + nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=nbashgufvishdafjk23432&sp=${AUCTION_PRICE}&sp_cur=${AUCTION_PRICE_CURRENCY}&asp=${AD_SERVER_PRICE}&asp_cur=${AD_SERVER_PRICE_CURRENCY}', crid: 'fa2d5af7-2678-4204-9023-44c526160742', dealid: '2783483223432342', w: 580, h: 400, - adm: '', + adm: '', adomain: [ 'https://bid.kobler.no' ] @@ -563,8 +568,8 @@ describe('KoblerAdapter', function () { dealId: '', netRevenue: true, ttl: 600, - ad: '', - nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=${AUCTION_PRICE}&asp=${AD_SERVER_PRICE}', + ad: '', + nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=${AUCTION_PRICE}&sp_cur=${AUCTION_PRICE_CURRENCY}&asp=${AD_SERVER_PRICE}&asp_cur=${AD_SERVER_PRICE_CURRENCY}', meta: { advertiserDomains: [ 'https://kobler.no' @@ -581,8 +586,8 @@ describe('KoblerAdapter', function () { dealId: '2783483223432342', netRevenue: true, ttl: 600, - ad: '', - nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=nbashgufvishdafjk23432&sp=${AUCTION_PRICE}&asp=${AD_SERVER_PRICE}', + ad: '', + nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=nbashgufvishdafjk23432&sp=${AUCTION_PRICE}&sp_cur=${AUCTION_PRICE_CURRENCY}&asp=${AD_SERVER_PRICE}&asp_cur=${AD_SERVER_PRICE_CURRENCY}', meta: { advertiserDomains: [ 'https://bid.kobler.no' @@ -617,9 +622,15 @@ describe('KoblerAdapter', function () { }); it('Should trigger pixel with replaced nurl if nurl is not empty', function () { + config.setConfig({ + 'currency': { + 'adServerCurrency': 'NOK' + } + }); spec.onBidWon({ cpm: 8.341, - nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=${AUCTION_PRICE}&asp=${AD_SERVER_PRICE}', + currency: 'NOK', + nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=${AUCTION_PRICE}&sp_cur=${AUCTION_PRICE_CURRENCY}&asp=${AD_SERVER_PRICE}&asp_cur=${AD_SERVER_PRICE_CURRENCY}', adserverTargeting: { hb_pb: 8 } @@ -627,7 +638,7 @@ describe('KoblerAdapter', function () { expect(utils.triggerPixel.callCount).to.be.equal(1); expect(utils.triggerPixel.firstCall.args[0]).to.be.equal( - 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=8.341&asp=8' + 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=8.341&sp_cur=NOK&asp=8&asp_cur=NOK' ); }); }); From 6580bf446ab0196fa48f34de3969510bb2dae698 Mon Sep 17 00:00:00 2001 From: Jurij Sinickij Date: Tue, 25 May 2021 23:57:11 +0300 Subject: [PATCH 225/303] Adf Bid Adapter: banner and video media type support added (#6726) --- modules/adfBidAdapter.js | 130 +++++++++-- modules/adfBidAdapter.md | 47 ++-- test/spec/modules/adfBidAdapter_spec.js | 289 +++++++++++++++++++++--- 3 files changed, 399 insertions(+), 67 deletions(-) diff --git a/modules/adfBidAdapter.js b/modules/adfBidAdapter.js index 8b3550e6108..5893891eba6 100644 --- a/modules/adfBidAdapter.js +++ b/modules/adfBidAdapter.js @@ -5,10 +5,13 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { - NATIVE + NATIVE, BANNER, VIDEO } from '../src/mediaTypes.js'; import * as utils from '../src/utils.js'; import { config } from '../src/config.js'; +import { Renderer } from '../src/Renderer.js'; + +const { getConfig } = config; const BIDDER_CODE = 'adf'; const GVLID = 50; @@ -45,28 +48,58 @@ const NATIVE_PARAMS = { name: 'data' } }; +const OUTSTREAM_RENDERER_URL = 'https://s2.adform.net/banners/scripts/video/outstream/render.js'; export const spec = { code: BIDDER_CODE, aliases: BIDDER_ALIAS, gvlid: GVLID, - supportedMediaTypes: [ NATIVE ], + supportedMediaTypes: [ NATIVE, BANNER, VIDEO ], isBidRequestValid: bid => !!bid.params.mid, buildRequests: (validBidRequests, bidderRequest) => { - const page = bidderRequest.refererInfo.referer; + let app, site; + + const commonFpd = getConfig('ortb2') || {}; + let { user } = commonFpd; + + if (typeof getConfig('app') === 'object') { + app = getConfig('app') || {}; + if (commonFpd.app) { + utils.mergeDeep(app, commonFpd.app); + } + } else { + site = getConfig('site') || {}; + if (commonFpd.site) { + utils.mergeDeep(site, commonFpd.site); + } + + if (!site.page) { + site.page = bidderRequest.refererInfo.referer; + } + } + + const device = getConfig('device') || {}; + device.w = device.w || window.innerWidth; + device.h = device.h || window.innerHeight; + device.ua = device.ua || navigator.userAgent; + const adxDomain = setOnAny(validBidRequests, 'params.adxDomain') || 'adx.adform.net'; - const ua = navigator.userAgent; + const pt = setOnAny(validBidRequests, 'params.pt') || setOnAny(validBidRequests, 'params.priceType') || 'net'; - const tid = validBidRequests[0].transactionId; // ??? check with ssp + const tid = validBidRequests[0].transactionId; const test = setOnAny(validBidRequests, 'params.test'); - const publisher = setOnAny(validBidRequests, 'params.publisher'); - const siteId = setOnAny(validBidRequests, 'params.siteId'); - const currency = config.getConfig('currency.adServerCurrency'); + const currency = getConfig('currency.adServerCurrency'); const cur = currency && [ currency ]; const eids = setOnAny(validBidRequests, 'userIdAsEids'); const imp = validBidRequests.map((bid, id) => { bid.netRevenue = pt; + + const imp = { + id: id + 1, + tagid: bid.params.mid + }; + const assets = utils._map(bid.nativeParams, (bidParams, key) => { const props = NATIVE_PARAMS[key]; const asset = { @@ -102,21 +135,51 @@ export const spec = { } }).filter(Boolean); - return { - id: id + 1, - tagid: bid.params.mid, - native: { + if (assets.length) { + imp.native = { request: { assets } - } - }; + }; + + bid.mediaType = NATIVE; + return imp; + } + + const bannerParams = utils.deepAccess(bid, 'mediaTypes.banner'); + + if (bannerParams && bannerParams.sizes) { + const sizes = utils.parseSizesInput(bannerParams.sizes); + const format = sizes.map(size => { + const [ width, height ] = size.split('x'); + const w = parseInt(width, 10); + const h = parseInt(height, 10); + return { w, h }; + }); + + imp.banner = { + format + }; + bid.mediaType = BANNER; + + return imp; + } + + const videoParams = utils.deepAccess(bid, 'mediaTypes.video'); + if (videoParams) { + imp.video = videoParams; + bid.mediaType = VIDEO; + + return imp; + } }); const request = { id: bidderRequest.auctionId, - site: { id: siteId, page, publisher }, - device: { ua }, + site, + app, + user, + device, source: { tid, fd: 1 }, ext: { pt }, cur, @@ -128,8 +191,8 @@ export const spec = { request.test = 1; } if (utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies') !== undefined) { - request.user = { ext: { consent: bidderRequest.gdprConsent.consentString } }; - request.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies & 1 } }; + utils.deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString); + utils.deepSetValue(request, 'regs.ext.gdpr', bidderRequest.gdprConsent.gdprApplies & 1); } if (bidderRequest.uspConsent) { @@ -164,16 +227,35 @@ export const spec = { return bids.map((bid, id) => { const bidResponse = bidResponses[id]; if (bidResponse) { - return { + const result = { requestId: bid.bidId, cpm: bidResponse.price, creativeId: bidResponse.crid, ttl: 360, netRevenue: bid.netRevenue === 'net', currency: cur, - mediaType: NATIVE, - native: parseNative(bidResponse) + mediaType: bid.mediaType, + width: bidResponse.w, + height: bidResponse.h, + dealId: bidResponse.dealid, + meta: { + mediaType: bid.mediaType, + advertiserDomains: bidResponse.adomain + } }; + + if (bidResponse.native) { + result.native = parseNative(bidResponse); + } else { + result[ bid.mediaType === VIDEO ? 'vastXml' : 'ad' ] = bidResponse.adm; + } + + if (!bid.renderer && bid.mediaType === VIDEO && utils.deepAccess(bid, 'mediaTypes.video.context') === 'outstream') { + result.renderer = Renderer.install({id: bid.bidId, url: OUTSTREAM_RENDERER_URL, adUnitCode: bid.adUnitCode}); + result.renderer.setRender(renderer); + } + + return result; } }).filter(Boolean); } @@ -212,3 +294,9 @@ function setOnAny(collection, key) { function flatten(arr) { return [].concat(...arr); } + +function renderer(bid) { + bid.renderer.push(() => { + window.Adform.renderOutstream(bid); + }); +} diff --git a/modules/adfBidAdapter.md b/modules/adfBidAdapter.md index 190aa91ea57..10264e6f486 100644 --- a/modules/adfBidAdapter.md +++ b/modules/adfBidAdapter.md @@ -7,15 +7,12 @@ Maintainer: Scope.FL.Scripts@adform.com # Description Module that connects to Adform demand sources to fetch bids. -Only native format is supported. Using OpenRTB standard. Previous adapter name - adformOpenRTB. +Banner, video and native formats are supported. Using OpenRTB standard. Previous adapter name - adformOpenRTB. # Test Parameters ``` - var adUnits = [ + var adUnits = [{ code: '/19968336/prebid_native_example_1', - sizes: [ - [360, 360] - ], mediaTypes: { native: { image: { @@ -44,16 +41,36 @@ Only native format is supported. Using OpenRTB standard. Previous adapter name - bids: [{ bidder: 'adf', params: { - mid: 606169, // required - adxDomain: 'adx.adform.net', // optional - siteId: '23455', // optional - priceType: 'gross' // optional, default is 'net' - publisher: { // optional block - id: "2706", - name: "Publishers Name", - domain: "publisher.com" - } + mid: 606169, // required + adxDomain: 'adx.adform.net' // optional + } + }] + }, { + code: '/19968336/prebid_banner_example_1', + mediaTypes: { + banner: { + sizes: [[ 300, 250 ]] + } + } + bids: [{ + bidder: 'adf', + params: { + mid: 1038466 + } + }] + }, { + code: '/19968336/prebid_video_example_1', + mediaTypes: { + video: { + context: 'outstream', + mimes: ['video/mp4'] + } + } + bids: [{ + bidder: 'adf', + params: { + mid: 822732 } }] - ]; + }]; ``` diff --git a/test/spec/modules/adfBidAdapter_spec.js b/test/spec/modules/adfBidAdapter_spec.js index 2c141d31bf8..ae92af32a1e 100644 --- a/test/spec/modules/adfBidAdapter_spec.js +++ b/test/spec/modules/adfBidAdapter_spec.js @@ -35,11 +35,13 @@ describe('Adf adapter', function () { }); describe('buildRequests', function () { + beforeEach(function () { + config.resetConfig(); + }); it('should send request with correct structure', function () { let validBidRequests = [{ bidId: 'bidId', params: { - siteId: 'siteId', adxDomain: '10.8.57.207' } }]; @@ -53,7 +55,7 @@ describe('Adf adapter', function () { describe('user privacy', function () { it('should send GDPR Consent data to adform if gdprApplies', function () { - let validBidRequests = [{ bidId: 'bidId', params: { siteId: 'siteId', test: 1 } }]; + let validBidRequests = [{ bidId: 'bidId', params: { test: 1 } }]; let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { referer: 'page' } }; let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); @@ -63,7 +65,7 @@ describe('Adf adapter', function () { }); it('should send gdpr as number', function () { - let validBidRequests = [{ bidId: 'bidId', params: { siteId: 'siteId', test: 1 } }]; + let validBidRequests = [{ bidId: 'bidId', params: { test: 1 } }]; let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { referer: 'page' } }; let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); @@ -72,7 +74,7 @@ describe('Adf adapter', function () { }); it('should send CCPA Consent data to adform', function () { - let validBidRequests = [{ bidId: 'bidId', params: { siteId: 'siteId', test: 1 } }]; + let validBidRequests = [{ bidId: 'bidId', params: { test: 1 } }]; let bidderRequest = { uspConsent: '1YA-', refererInfo: { referer: 'page' } }; let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); @@ -118,7 +120,7 @@ describe('Adf adapter', function () { it('should add test and is_debug to request, if test is set in parameters', function () { let validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId', test: 1 } + params: { test: 1 } }]; let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); @@ -151,26 +153,66 @@ describe('Adf adapter', function () { }); it('should send info about device', function () { + config.setConfig({ + device: { w: 100, h: 100 } + }); let validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId' } + params: { mid: '1000' } }]; let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); assert.equal(request.device.ua, navigator.userAgent); + assert.equal(request.device.w, 100); + assert.equal(request.device.h, 100); + }); + + it('should send app info', function () { + config.setConfig({ + app: { id: 'appid' }, + ortb2: { app: { name: 'appname' } } + }); + let validBidRequests = [{ + bidId: 'bidId', + params: { mid: '1000' } + }]; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + + assert.equal(request.app.id, 'appid'); + assert.equal(request.app.name, 'appname'); + assert.equal(request.site, undefined); }); + it('should send info about the site', function () { + config.setConfig({ + site: { + id: '123123', + publisher: { + domain: 'publisher.domain.com' + } + }, + ortb2: { + site: { + publisher: { + name: 'publisher\'s name' + } + } + } + }); let validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId', publisher: {id: '123123', domain: 'publisher.domain.com', name: 'publisher\'s name'} } + params: { mid: '1000' } }]; let refererInfo = { referer: 'page' }; let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo }).data); assert.deepEqual(request.site, { page: refererInfo.referer, - publisher: validBidRequests[0].params.publisher, - id: validBidRequests[0].params.siteId + publisher: { + domain: 'publisher.domain.com', + name: 'publisher\'s name' + }, + id: '123123' }); }); @@ -213,7 +255,7 @@ describe('Adf adapter', function () { it('should send correct priceType value', function () { let validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId', priceType: 'net' } + params: { priceType: 'net' } }]; let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); @@ -237,13 +279,16 @@ describe('Adf adapter', function () { it('should add incrementing values of id', function () { let validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId' } + params: { mid: '1000' }, + mediaTypes: {video: {}} }, { bidId: 'bidId2', - params: { siteId: 'siteId' } + params: { mid: '1000' }, + mediaTypes: {video: {}} }, { bidId: 'bidId3', - params: { siteId: 'siteId' } + params: { mid: '1000' }, + mediaTypes: {video: {}} }]; let imps = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp; @@ -253,21 +298,106 @@ describe('Adf adapter', function () { }); it('should add mid', function () { - let validBidRequests = [{ bidId: 'bidId', params: { siteId: 'siteId', mid: 1000 } }, - { bidId: 'bidId2', params: { siteId: 'siteId', mid: 1001 } }, - { bidId: 'bidId3', params: { siteId: 'siteId', mid: 1002 } }]; + let validBidRequests = [{ bidId: 'bidId', params: {mid: 1000}, mediaTypes: {video: {}} }, + { bidId: 'bidId2', params: {mid: 1001}, mediaTypes: {video: {}} }, + { bidId: 'bidId3', params: {mid: 1002}, mediaTypes: {video: {}} }]; let imps = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp; for (let i = 0; i < 3; i++) { assert.equal(imps[i].tagid, validBidRequests[i].params.mid); } }); + describe('multiple media types', function () { + it('should use single media type for bidding', function () { + let validBidRequests = [{ + bidId: 'bidId', + params: { mid: 1000 }, + mediaTypes: { + banner: { + sizes: [[100, 100], [200, 300]] + }, + video: {} + } + }, { + bidId: 'bidId1', + params: { mid: 1000 }, + mediaTypes: { + video: {}, + native: {} + } + }, { + bidId: 'bidId2', + params: { mid: 1000 }, + nativeParams: { + title: { required: true, len: 140 } + }, + mediaTypes: { + banner: { + sizes: [[100, 100], [200, 300]] + }, + native: {} + } + }]; + let [ banner, video, native ] = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp; + + assert.ok(banner.banner); + assert.equal(banner.video, undefined); + assert.equal(banner.native, undefined); + assert.ok(video.video); + assert.equal(video.banner, undefined); + assert.equal(video.native, undefined); + assert.ok(native.native); + assert.equal(native.video, undefined); + assert.equal(native.banner, undefined); + }); + }); + + describe('banner', function () { + it('should convert sizes to openrtb format', function () { + let validBidRequests = [{ + bidId: 'bidId', + params: { mid: 1000 }, + mediaTypes: { + banner: { + sizes: [[100, 100], [200, 300]] + } + } + }]; + let { banner } = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0]; + assert.deepEqual(banner, { + format: [ { w: 100, h: 100 }, { w: 200, h: 300 } ] + }); + }); + }); + + describe('video', function () { + it('should pass video mediatype config', function () { + let validBidRequests = [{ + bidId: 'bidId', + params: { mid: 1000 }, + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream', + mimes: ['video/mp4'] + } + } + }]; + let { video } = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0]; + assert.deepEqual(video, { + playerSize: [640, 480], + context: 'outstream', + mimes: ['video/mp4'] + }); + }); + }); + describe('native', function () { describe('assets', function () { it('should set correct asset id', function () { let validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { title: { required: true, len: 140 }, image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, @@ -283,7 +413,7 @@ describe('Adf adapter', function () { it('should add required key if it is necessary', function () { let validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { title: { required: true, len: 140 }, image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, @@ -303,7 +433,7 @@ describe('Adf adapter', function () { it('should map img and data assets', function () { let validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { title: { required: true, len: 140 }, image: { required: true, sizes: [150, 50] }, @@ -330,7 +460,7 @@ describe('Adf adapter', function () { it('should flatten sizes and utilise first pair', function () { const validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { image: { sizes: [[200, 300], [100, 200]] @@ -348,7 +478,7 @@ describe('Adf adapter', function () { it('should utilise aspect_ratios', function () { const validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { image: { aspect_ratios: [{ @@ -380,7 +510,7 @@ describe('Adf adapter', function () { it('should not throw error if aspect_ratios config is not defined', function () { const validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { image: { aspect_ratios: [] @@ -398,7 +528,7 @@ describe('Adf adapter', function () { it('should expect any dimensions if min_width not passed', function () { const validBidRequests = [{ bidId: 'bidId', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { image: { aspect_ratios: [{ @@ -441,7 +571,7 @@ describe('Adf adapter', function () { bids: [ { bidId: 'bidId1', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { title: { required: true, len: 140 }, image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, @@ -450,7 +580,7 @@ describe('Adf adapter', function () { }, { bidId: 'bidId2', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { title: { required: true, len: 140 }, image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, @@ -482,7 +612,7 @@ describe('Adf adapter', function () { bids: [ { bidId: 'bidId1', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { title: { required: true, len: 140 }, image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, @@ -491,7 +621,7 @@ describe('Adf adapter', function () { }, { bidId: 'bidId2', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { title: { required: true, len: 140 }, image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, @@ -500,7 +630,7 @@ describe('Adf adapter', function () { }, { bidId: 'bidId3', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { title: { required: true, len: 140 }, image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, @@ -509,7 +639,7 @@ describe('Adf adapter', function () { }, { bidId: 'bidId4', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, nativeParams: { title: { required: true, len: 140 }, image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, @@ -543,7 +673,9 @@ describe('Adf adapter', function () { assets: [], link: { url: 'link' }, imptrackers: ['imptrackers url1', 'imptrackers url2'] - } + }, + dealid: 'deal-id', + adomain: [ 'demo.com' ] } ] }], @@ -555,7 +687,8 @@ describe('Adf adapter', function () { bids: [ { bidId: 'bidId1', - params: { siteId: 'siteId', mid: 1000 }, + params: { mid: 1000 }, + mediaType: 'native', nativeParams: { title: { required: true, len: 140 }, image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, @@ -574,6 +707,9 @@ describe('Adf adapter', function () { assert.deepEqual(bids[0].netRevenue, false); assert.deepEqual(bids[0].currency, serverResponse.body.cur); assert.deepEqual(bids[0].mediaType, 'native'); + assert.deepEqual(bids[0].meta.mediaType, 'native'); + assert.deepEqual(bids[0].meta.advertiserDomains, [ 'demo.com' ]); + assert.deepEqual(bids[0].dealId, 'deal-id'); }); it('should set correct native params', function () { const bid = [ @@ -678,5 +814,96 @@ describe('Adf adapter', function () { const result = spec.interpretResponse(serverResponse, bidRequest)[0]; assert.ok(!result); }); + + describe('banner', function () { + it('should set ad content on response', function () { + let serverResponse = { + body: { + seatbid: [{ + bid: [{ impid: '1', adm: '' }] + }] + } + }; + let bidRequest = { + data: {}, + bids: [ + { + bidId: 'bidId1', + params: { mid: 1000 }, + mediaType: 'banner' + } + ] + }; + + bids = spec.interpretResponse(serverResponse, bidRequest); + assert.equal(bids.length, 1); + assert.equal(bids[0].ad, ''); + }); + }); + + describe('video', function () { + it('should set vastXml on response', function () { + let serverResponse = { + body: { + seatbid: [{ + bid: [{ impid: '1', adm: '' }] + }] + } + }; + let bidRequest = { + data: {}, + bids: [ + { + bidId: 'bidId1', + params: { mid: 1000 }, + mediaType: 'video' + } + ] + }; + + bids = spec.interpretResponse(serverResponse, bidRequest); + assert.equal(bids.length, 1); + assert.equal(bids[0].vastXml, ''); + }); + + it('should add renderer for outstream bids', function () { + let serverResponse = { + body: { + seatbid: [{ + bid: [{ impid: '1', adm: '' }, { impid: '2', adm: '' }] + }] + } + }; + let bidRequest = { + data: {}, + bids: [ + { + bidId: 'bidId1', + params: { mid: 1000 }, + mediaType: 'video', + mediaTypes: { + video: { + context: 'outstream' + } + } + }, + { + bidId: 'bidId2', + params: { mid: 1000 }, + mediaType: 'video', + mediaTypes: { + video: { + constext: 'instream' + } + } + } + ] + }; + + bids = spec.interpretResponse(serverResponse, bidRequest); + assert.ok(bids[0].renderer); + assert.equal(bids[1].renderer, undefined); + }); + }); }); }); From cc68ad49c6a41a4af964c2235ce34105fcea2603 Mon Sep 17 00:00:00 2001 From: Mike Groh Date: Tue, 25 May 2021 21:11:06 -0400 Subject: [PATCH 226/303] Trion bid adapter: support for meta advertiserDomains (#6829) * Adding files associated with the trion adapter update to the newest prebid version(1.0). * Updating pull request with safer checks for user sync and general clean up/consistency of tests. * removing a call to bidder code for pull request review. also removing the test that requires it * there were some changes to the bid factory after our initial release that we didn't account for. Changing adapter to account for response body and required params. * Revert "there were some changes to the bid factory after our initial release that we didn't account for. Changing adapter to account for response body and required params." This reverts commit 324d15785fb61c92db9c0a37f1001f47721e3a25. * there were some changes to the bid factory after our initial release that we didn't account for. Changing adapter to account for response body and required params. * adding safety checks to Trion adapter * Sending up to trion endpoint if there is bot traffic or the browser tab is not visible. * sending the wrong param in the test. * Trion test cleanup. returning document and window states to their original form after tests. * Trion test cleanup. using before and after to alter window and document objects in tests. * re-adding trion adapter to prebid project to stop using deprecated function for page url for 3.0 release * minor formatting change * accept size array from media types banner over the sizes array from pubs. * updating trion bid adapter to be us privacy and gdpr compliant * encoding consent strings for test * Trion adapter update. Changing request params to trion including removing support for optional 're' param, cleaning up existing params to send 1/0 instead of null when non is present and adding prebid version. * adding support for meta advertiserDomains in trion bid adapter for future use Co-authored-by: Mike Groh --- modules/trionBidAdapter.js | 3 +++ test/spec/modules/trionBidAdapter_spec.js | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/modules/trionBidAdapter.js b/modules/trionBidAdapter.js index 37d54e60cd2..e9e030ce33f 100644 --- a/modules/trionBidAdapter.js +++ b/modules/trionBidAdapter.js @@ -53,6 +53,9 @@ export const spec = { bid.creativeId = result.creativeId; bid.currency = result.currency; bid.netRevenue = result.netRevenue; + if (result.adomain) { + bid.meta = {advertiserDomains: result.adomain} + } bidResponses.push(bid); } } diff --git a/test/spec/modules/trionBidAdapter_spec.js b/test/spec/modules/trionBidAdapter_spec.js index ae329b4a028..0fc03caa563 100644 --- a/test/spec/modules/trionBidAdapter_spec.js +++ b/test/spec/modules/trionBidAdapter_spec.js @@ -1,6 +1,7 @@ import {expect} from 'chai'; import * as utils from 'src/utils.js'; import {spec, acceptPostMessage, getStorageData, setStorageData} from 'modules/trionBidAdapter.js'; +import {deepClone} from 'src/utils.js'; const CONSTANTS = require('src/constants.json'); const adloader = require('src/adloader'); @@ -316,6 +317,14 @@ describe('Trion adapter tests', function () { expect(response[0].cpm).to.equal(bidCpm); TRION_BID_RESPONSE.result.cpm = 100; }); + + it('advertiserDomains is included when sent by server', function () { + TRION_BID_RESPONSE.result.adomain = ['test_adomain']; + let response = spec.interpretResponse({body: TRION_BID_RESPONSE}, {bidRequest: TRION_BID}); + expect(Object.keys(response[0].meta)).to.include.members(['advertiserDomains']); + expect(response[0].meta.advertiserDomains).to.deep.equal(['test_adomain']); + delete TRION_BID_RESPONSE.result.adomain; + }); }); describe('getUserSyncs', function () { From c48e71e7f1d363c5486ece6ba7696c8589f0e4ff Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Wed, 26 May 2021 02:28:31 -0700 Subject: [PATCH 227/303] Release Drafter: update to minor as the default (#6827) --- .github/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 8984252f4c3..a3246cffd6d 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -22,7 +22,7 @@ version-resolver: patch: labels: - 'patch' - default: patch + default: minor template: | ## In This Release $CHANGES From 61aadfb1c5410213a3b9971c4f31a3a0b8d9e00a Mon Sep 17 00:00:00 2001 From: JonGoSonobi Date: Wed, 26 May 2021 10:09:24 -0400 Subject: [PATCH 228/303] Sonobi bid adapter: add support for gpid and set advertiserDomains (#6826) * added gpid to sonobi bidder adapter. It tries to get the gpt ad unit code * added advertiser domain to bid meta --- modules/sonobiBidAdapter.js | 24 ++++++++-- test/spec/modules/sonobiBidAdapter_spec.js | 55 +++++++++++++++++++--- 2 files changed, 68 insertions(+), 11 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index e5bd76eba9f..eb6009079ac 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -1,5 +1,5 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { parseSizesInput, logError, generateUUID, isEmpty, deepAccess, logWarn, logMessage, deepClone } from '../src/utils.js'; +import { parseSizesInput, logError, generateUUID, isEmpty, deepAccess, logWarn, logMessage, deepClone, getGptSlotInfoForAdUnitCode } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; import { Renderer } from '../src/Renderer.js'; @@ -60,11 +60,11 @@ export const spec = { if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)) { slotIdentifier = slotIdentifier.charAt(0) === '/' ? slotIdentifier : '/' + slotIdentifier; return { - [`${slotIdentifier}|${bid.bidId}`]: `${_validateSize(bid)}${_validateFloor(bid)}` + [`${slotIdentifier}|${bid.bidId}`]: `${_validateSize(bid)}${_validateFloor(bid)}${_validateGPID(bid)}` } } else if (/^[0-9a-fA-F]{20}$/.test(slotIdentifier) && slotIdentifier.length === 20) { return { - [bid.bidId]: `${slotIdentifier}|${_validateSize(bid)}${_validateFloor(bid)}` + [bid.bidId]: `${slotIdentifier}|${_validateSize(bid)}${_validateFloor(bid)}${_validateGPID(bid)}` } } else { logError(`The ad unit code or Sonobi Placement id for slot ${bid.bidId} is invalid`); @@ -199,6 +199,10 @@ export const spec = { width = 1, height = 1 ] = bid.sbi_size.split('x'); + let aDomains = []; + if (bid.sbi_adomain) { + aDomains = [bid.sbi_adomain] + } const bids = { requestId: bidId, cpm: Number(bid.sbi_mouse), @@ -209,7 +213,10 @@ export const spec = { creativeId: bid.sbi_crid || bid.sbi_aid, aid: bid.sbi_aid, netRevenue: true, - currency: 'USD' + currency: 'USD', + meta: { + advertiserDomains: aDomains + } }; if (bid.sbi_dozer) { @@ -302,6 +309,15 @@ function _validateFloor (bid) { return ''; } +function _validateGPID(bid) { + const gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot') || deepAccess(getGptSlotInfoForAdUnitCode(bid.adUnitCode), 'gptSlot') || bid.params.ad_unit; + + if (gpid) { + return `|gpid=${gpid}` + } + return '' +} + const _creative = (mediaType, referer) => (sbiDc, sbiAid) => { if (mediaType === 'video' || mediaType === 'outstream') { return _videoCreative(sbiDc, sbiAid, referer) diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 0314ffb71c1..79bfa86b216 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -3,6 +3,7 @@ import { spec, _getPlatform } from 'modules/sonobiBidAdapter.js' import { newBidder } from 'src/adapters/bidderFactory.js' import {userSync} from '../../../src/userSync.js'; import { config } from 'src/config.js'; +import * as utils from '../../../src/utils.js'; describe('SonobiBidAdapter', function () { const adapter = newBidder(spec) @@ -239,9 +240,12 @@ describe('SonobiBidAdapter', function () { describe('.buildRequests', function () { beforeEach(function() { sinon.stub(userSync, 'canBidderRegisterSync'); + sinon.stub(utils, 'getGptSlotInfoForAdUnitCode') + .onFirstCall().returns({gptSlot: '/123123/gpt_publisher/adunit-code-3', divId: 'adunit-code-3-div-id'}) }); afterEach(function() { userSync.canBidderRegisterSync.restore(); + utils.getGptSlotInfoForAdUnitCode.restore(); }); let bidRequest = [{ 'schain': { @@ -271,6 +275,24 @@ describe('SonobiBidAdapter', function () { 'adUnitCode': 'adunit-code-1', 'sizes': [[300, 250], [300, 600]], 'bidId': '30b31c1838de1f', + ortb2Imp: { + ext: { + data: { + pbadslot: '/123123/gpt_publisher/adunit-code-1' + } + } + } + }, + { + 'bidder': 'sonobi', + 'params': { + 'placement_id': '1a2b3c4d5e6f1a2b3c4e', + 'sizes': [[300, 250], [300, 600]], + 'referrer': 'overrides_top_window_location' + }, + 'adUnitCode': 'adunit-code-3', + 'sizes': [[120, 600], [300, 600], [160, 600]], + 'bidId': '30b31c1838de1d', }, { 'bidder': 'sonobi', @@ -285,8 +307,9 @@ describe('SonobiBidAdapter', function () { }]; let keyMakerData = { - '30b31c1838de1f': '1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25', - '/7780971/sparks_prebid_LB|30b31c1838de1e': '300x250,300x600', + '30b31c1838de1f': '1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25|gpid=/123123/gpt_publisher/adunit-code-1', + '30b31c1838de1d': '1a2b3c4d5e6f1a2b3c4e|300x250,300x600|gpid=/123123/gpt_publisher/adunit-code-3', + '/7780971/sparks_prebid_LB|30b31c1838de1e': '300x250,300x600|gpid=/7780971/sparks_prebid_LB', }; let bidderRequests = { @@ -629,6 +652,7 @@ describe('SonobiBidAdapter', function () { 'sbi_crid': '1234abcd', 'sbi_aid': '30292e432662bd5f86d90774b944b039', 'sbi_mouse': 1.07, + 'sbi_adomain': 'sonobi.com' }, '30b31c1838de1e': { 'sbi_size': '300x250', @@ -636,7 +660,9 @@ describe('SonobiBidAdapter', function () { 'sbi_aid': '30292e432662bd5f86d90774b944b038', 'sbi_mouse': 1.25, 'sbi_dozer': 'dozerkey', - 'sbi_ct': 'video' + 'sbi_ct': 'video', + 'sbi_adomain': 'sonobi.com' + }, '/7780971/sparks_prebid_LB_OUTSTREAM|30b31c1838de1g': { 'sbi_size': '300x600', @@ -644,6 +670,8 @@ describe('SonobiBidAdapter', function () { 'sbi_crid': '1234abcd', 'sbi_aid': '30292e432662bd5f86d90774b944b038', 'sbi_mouse': 1.07, + 'sbi_adomain': 'sonobi.com' + }, '/7780971/sparks_prebid_LB|30b31c1838de1g': {}, '30b31c1838de1zzzz': { @@ -654,6 +682,7 @@ describe('SonobiBidAdapter', function () { sbi_mouse: 1.25, sbi_size: 'preroll', 'sbi_crid': 'somecrid', + 'sbi_adomain': 'sonobi.com' } @@ -680,7 +709,10 @@ describe('SonobiBidAdapter', function () { 'creativeId': '1234abcd', 'netRevenue': true, 'currency': 'USD', - 'aid': '30292e432662bd5f86d90774b944b039' + 'aid': '30292e432662bd5f86d90774b944b039', + meta: { + advertiserDomains: ['sonobi.com'] + } }, { 'requestId': '30b31c1838de1e', @@ -694,7 +726,10 @@ describe('SonobiBidAdapter', function () { 'currency': 'USD', 'dealId': 'dozerkey', 'aid': '30292e432662bd5f86d90774b944b038', - 'mediaType': 'video' + 'mediaType': 'video', + meta: { + advertiserDomains: ['sonobi.com'] + } }, { 'requestId': '30b31c1838de1g', @@ -706,7 +741,10 @@ describe('SonobiBidAdapter', function () { 'creativeId': '1234abcd', 'netRevenue': true, 'currency': 'USD', - 'aid': '30292e432662bd5f86d90774b944b038' + 'aid': '30292e432662bd5f86d90774b944b038', + meta: { + advertiserDomains: ['sonobi.com'] + } }, { 'requestId': '30b31c1838de1zzzz', @@ -721,7 +759,10 @@ describe('SonobiBidAdapter', function () { 'dealId': 'dozerkey', 'aid': 'force_1550072228_da1c5d030cb49150c5db8a2136175755', 'mediaType': 'video', - renderer: () => {} + renderer: () => {}, + meta: { + advertiserDomains: ['sonobi.com'] + } }, ]; From 0895e4a2d48977855ea7ae872cfa79c91094ed11 Mon Sep 17 00:00:00 2001 From: Seba Perez Date: Wed, 26 May 2021 12:38:56 -0300 Subject: [PATCH 229/303] Eplanning Bid Adapter: verify getUserIds exists and is a function; add adomain support (#6832) --- modules/eplanningBidAdapter.js | 14 +++-- test/spec/modules/eplanningBidAdapter_spec.js | 53 +++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/modules/eplanningBidAdapter.js b/modules/eplanningBidAdapter.js index 98a0e290575..dd96353dea3 100644 --- a/modules/eplanningBidAdapter.js +++ b/modules/eplanningBidAdapter.js @@ -82,9 +82,12 @@ export const spec = { if (bidderRequest && bidderRequest.uspConsent) { params.ccpa = bidderRequest.uspConsent; } - const userIds = (getGlobal()).getUserIds(); - for (var id in userIds) { - params['e_' + id] = (typeof userIds[id] === 'object') ? encodeURIComponent(JSON.stringify(userIds[id])) : encodeURIComponent(userIds[id]); + + if ((getGlobal()).getUserIds && typeof (getGlobal()).getUserIds === 'function') { + const userIds = (getGlobal()).getUserIds(); + for (var id in userIds) { + params['e_' + id] = (typeof userIds[id] === 'object') ? encodeURIComponent(JSON.stringify(userIds[id])) : encodeURIComponent(userIds[id]); + } } } @@ -114,6 +117,11 @@ export const spec = { netRevenue: NET_REVENUE, currency: DOLLARS, }; + if (ad.adom) { + bidResponse.meta = { + advertiserDomains: ad.adom + }; + } bidResponses.push(bidResponse); }); } diff --git a/test/spec/modules/eplanningBidAdapter_spec.js b/test/spec/modules/eplanningBidAdapter_spec.js index 1d3a8344170..6aa191f29a5 100644 --- a/test/spec/modules/eplanningBidAdapter_spec.js +++ b/test/spec/modules/eplanningBidAdapter_spec.js @@ -26,6 +26,7 @@ describe('E-Planning Adapter', function () { const I_ID = '7854abc56248f873'; const CRID = '1234567890'; const TEST_ISV = 'leles.e-planning.net'; + const ADOMAIN = 'adomain.com'; const validBid = { 'bidder': 'eplanning', 'bidId': BID_ID, @@ -237,6 +238,39 @@ describe('E-Planning Adapter', function () { ] } }; + const responseWithAdomain = { + body: { + 'sI': { + 'k': '12345' + }, + 'sec': { + 'k': 'ROS' + }, + 'sp': [{ + 'k': CLEAN_ADUNIT_CODE, + 'a': [{ + 'adm': ADM, + 'id': '7854abc56248f874', + 'i': I_ID, + 'fi': '7854abc56248f872', + 'ip': '45621afd87462104', + 'w': W, + 'h': H, + 'crid': CRID, + 'pr': CPM, + 'adom': ADOMAIN + }], + }], + 'cs': [ + 'http://a-sync-url.com/', + { + 'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east', + 'ifr': true + } + ] + } + }; + const responseWithNoSpace = { body: { 'sI': { @@ -520,6 +554,25 @@ describe('E-Planning Adapter', function () { }; expect(bidResponse).to.deep.equal(expectedResponse); }); + + it('should pass advertiserDomains when present', function () { + const bidResponse = spec.interpretResponse(responseWithAdomain, { adUnitToBidId: { [CLEAN_ADUNIT_CODE]: BID_ID } })[0]; + const expectedResponse = { + requestId: BID_ID, + cpm: CPM, + width: W, + height: H, + ad: ADM, + ttl: 120, + creativeId: CRID, + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ADOMAIN + } + }; + expect(bidResponse).to.deep.equal(expectedResponse); + }); }); describe('getUserSyncs', function () { From e97db76c9288c82f849b9456b017ab010843b1a4 Mon Sep 17 00:00:00 2001 From: mediaconsortium-develop <76139568+mediaconsortium-develop@users.noreply.github.com> Date: Thu, 27 May 2021 02:12:09 +0900 Subject: [PATCH 230/303] Dgkeyword Rtd Provider: add new real-time data submodule (#6410) * add dgkeywordRtdProvider * change access url * we change not to access real url. and one test case delete because of the changing. * update test code. update api access using ajax() * update test code * set keywords using setBidderConfig in ortb2. * change test code for circle CI Co-authored-by: Patrick McCann --- modules/.submodules.json | 1 + modules/dgkeywordRtdProvider.js | 132 +++++++ modules/dgkeywordRtdProvider.md | 35 ++ .../spec/modules/dgkeywordRtdProvider_spec.js | 326 ++++++++++++++++++ 4 files changed, 494 insertions(+) create mode 100644 modules/dgkeywordRtdProvider.js create mode 100644 modules/dgkeywordRtdProvider.md create mode 100644 test/spec/modules/dgkeywordRtdProvider_spec.js diff --git a/modules/.submodules.json b/modules/.submodules.json index 0a10044a78e..74ebc021a6d 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -36,6 +36,7 @@ ], "rtdModule": [ "browsiRtdProvider", + "dgkeywordRtdProvider", "geoedgeRtdProvider", "haloRtdProvider", "jwplayerRtdProvider", diff --git a/modules/dgkeywordRtdProvider.js b/modules/dgkeywordRtdProvider.js new file mode 100644 index 00000000000..52fa9fd70c4 --- /dev/null +++ b/modules/dgkeywordRtdProvider.js @@ -0,0 +1,132 @@ +/** + * This module adds dgkeyword provider to the real time data module + * The {@link module:modules/realTimeData} module is required + * The module will get keywords from 1plux profile api. + * This module can work only with AppNexusBidAdapter. + * @module modules/dgkeywordProvider + * @requires module:modules/realTimeData + */ + +import * as utils from '../src/utils.js'; +import { ajax } from '../src/ajax.js'; +import { submodule } from '../src/hook.js'; +import { getGlobal } from '../src/prebidGlobal.js'; + +/** + * get keywords from api server. and set keywords. + * @param {Object} reqBidsConfigObj + * @param {function} callback + * @param {Object} moduleConfig + * @param {Object} userConsent + */ +export function getDgKeywordsAndSet(reqBidsConfigObj, callback, moduleConfig, userConsent) { + const URL = 'https://mediaconsortium.profiles.tagger.opecloud.com/api/v1?url='; + const PROFILE_TIMEOUT_MS = 1000; + const timeout = (moduleConfig && moduleConfig.params && moduleConfig.params.timeout && Number(moduleConfig.params.timeout) > 0) ? Number(moduleConfig.params.timeout) : PROFILE_TIMEOUT_MS; + const url = (moduleConfig && moduleConfig.params && moduleConfig.params.url) ? moduleConfig.params.url : URL + encodeURIComponent(window.location.href); + const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits; + let isFinish = false; + utils.logMessage('[dgkeyword sub module]', adUnits, timeout); + let setKeywordTargetBidders = getTargetBidderOfDgKeywords(adUnits); + if (setKeywordTargetBidders.length <= 0) { + utils.logMessage('[dgkeyword sub module] no dgkeyword targets.'); + callback(); + } else { + utils.logMessage('[dgkeyword sub module] dgkeyword targets:', setKeywordTargetBidders); + utils.logMessage('[dgkeyword sub module] get targets from profile api start.'); + ajax(url, { + success: function(response) { + const res = JSON.parse(response); + if (!isFinish) { + utils.logMessage('[dgkeyword sub module] get targets from profile api end.'); + if (res) { + let keywords = {}; + if (res['s'] != null && res['s'].length > 0) { + keywords['opeaud'] = res['s']; + } + if (res['t'] != null && res['t'].length > 0) { + keywords['opectx'] = res['t']; + } + if (Object.keys(keywords).length > 0) { + const targetBidKeys = {} + for (let bid of setKeywordTargetBidders) { + // set keywords to params + bid.params.keywords = keywords; + if (!targetBidKeys[bid.bidder]) { + targetBidKeys[bid.bidder] = true; + } + } + + // set keywrods to ortb2 + let addOrtb2 = {}; + utils.deepSetValue(addOrtb2, 'site.keywords', keywords); + utils.deepSetValue(addOrtb2, 'user.keywords', keywords); + const ortb2 = {ortb2: addOrtb2}; + getGlobal().setBidderConfig({ bidders: Object.keys(targetBidKeys), config: ortb2 }); + } + } + isFinish = true; + } + callback(); + }, + error: function(errorStatus) { + // error occur + utils.logError('[dgkeyword sub module] profile api access error.', errorStatus); + callback(); + } + }, null, { + withCredentials: true, + contentType: 'application/json', + }); + setTimeout(function () { + if (!isFinish) { + // profile api timeout + utils.logInfo('[dgkeyword sub module] profile api timeout. [timeout: ' + timeout + 'ms]'); + isFinish = true; + } + callback(); + }, timeout); + } +} + +/** + * get all bidder which hava {dgkeyword: true} in params + * @param {Object} adUnits + */ +export function getTargetBidderOfDgKeywords(adUnits) { + let setKeywordTargetBidders = []; + for (let adUnit of adUnits) { + for (let bid of adUnit.bids) { + if (bid.params && bid.params['dgkeyword'] === true) { + delete bid.params['dgkeyword']; + setKeywordTargetBidders.push(bid); + } + } + } + return setKeywordTargetBidders; +} + +/** @type {RtdSubmodule} */ +export const dgkeywordSubmodule = { + /** + * used to link submodule with realTimeData + * @type {string} + */ + name: 'dgkeyword', + /** + * get data and send back to realTimeData module + * @function + * @param {string[]} adUnitsCodes + */ + getBidRequestData: getDgKeywordsAndSet, + init: init, +}; + +function init(moduleConfig) { + return true; +} + +function registerSubModule() { + submodule('realTimeData', dgkeywordSubmodule); +} +registerSubModule(); diff --git a/modules/dgkeywordRtdProvider.md b/modules/dgkeywordRtdProvider.md new file mode 100644 index 00000000000..7cf532ea650 --- /dev/null +++ b/modules/dgkeywordRtdProvider.md @@ -0,0 +1,35 @@ +## Overview + +Module Name: Digital Garage Keyword Module +Module Type: Rtd Provider +Maintainer: mediaconsortium-develop@bi.garage.co.jp +Remarks: This module can work only with AppNexusBidAdapter. +## Integration + +1) Compile the Digital Garage Keyword Module and Appnexus Bid Adapter into your Prebid build: + +``` +gulp build --modules="dgkeywordRtdProvider,appnexusBidAdapter,..." +``` + +2) Use `setConfig` to instruct Prebid.js to initilize the dgkeyword module, as specified below. + +## Configuration + +This module is configured as part of the `realTimeData.dataProviders` + +```javascript +var DGKEYWORD_TIMEOUT = 1000; +pbjs.setConfig({ + realTimeData: { + auctionDelay: DGKEYWORD_TIMEOUT, + dataProviders: [{ + name: 'dgkeyword', + waitForIt: true, + params: { + timeout: DGKEYWORD_TIMEOUT + } + }] + } +}); +``` diff --git a/test/spec/modules/dgkeywordRtdProvider_spec.js b/test/spec/modules/dgkeywordRtdProvider_spec.js new file mode 100644 index 00000000000..0fac92e5118 --- /dev/null +++ b/test/spec/modules/dgkeywordRtdProvider_spec.js @@ -0,0 +1,326 @@ +import * as dgRtd from 'modules/dgkeywordRtdProvider.js'; +import { cloneDeep } from 'lodash'; +import { server } from 'test/mocks/xhr.js'; +import { getGlobal } from 'src/prebidGlobal.js'; +import { config } from 'src/config.js'; + +const DG_GET_KEYWORDS_TIMEOUT = 1950; +const DEF_CONFIG = { + name: 'dgkeyword', + waitForIt: true, + params: { + timeout: DG_GET_KEYWORDS_TIMEOUT, + }, +}; +const DUMMY_RESPONSE_HEADER = {'Content-Type': 'application/json'}; +const DUMMY_RESPONSE = { s: ['s1', 's2'], t: ['t1', 't2'] }; +const SUCCESS_RESULT = { opeaud: ['s1', 's2'], opectx: ['t1', 't2'] }; +const SUCCESS_ORTB2 = { ortb2: { site: { keywords: SUCCESS_RESULT }, user: { keywords: SUCCESS_RESULT } } }; + +describe('Digital Garage Keyword Module', function () { + it('should init and return always true', function () { + expect(dgRtd.dgkeywordSubmodule.init()).to.equal(true); + }); + + describe('dgkeyword target test', function () { + it('should have no target', function () { + const adUnits_no_target = [ + { + code: 'code1', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999999, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999998, + dgkeyword: false, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999997, + }, + }, + ], + }, + { + code: 'code2', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999996, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999995, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999994, + }, + }, + ], + }, + ]; + expect(dgRtd.getTargetBidderOfDgKeywords(adUnits_no_target)).an('array') + .that.is.empty; + }); + it('should have targets', function () { + const adUnits_targets = [ + { + code: 'code1', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999999, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999998, + dgkeyword: true, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999997, + dgkeyword: false, + }, + }, + ], + }, + { + code: 'code2', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999996, + dgkeyword: true, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999995, + dgkeyword: 'aa', + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999994, + dgkeyword: true, + }, + }, + ], + }, + ]; + const targets = dgRtd.getTargetBidderOfDgKeywords(adUnits_targets); + expect(targets[0].bidder).to.be.equal('dg2'); + expect(targets[0].params.placementId).to.be.equal(99999998); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].bidder).to.be.equal('dg'); + expect(targets[1].params.placementId).to.be.equal(99999996); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + }); + }); + + describe('get profile.', function () { + const AD_UNITS = [ + { + code: 'code1', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999999, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999998, + dgkeyword: true, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999997, + dgkeyword: false, + }, + }, + ], + }, + { + code: 'code2', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999996, + dgkeyword: true, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999995, + dgkeyword: 'aa', + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999994, + }, + }, + ], + }, + ]; + it('should get profiles error(404).', function (done) { + let pdjs = getGlobal(); + pbjs.adUnits = cloneDeep(AD_UNITS); + let moduleConfig = cloneDeep(DEF_CONFIG); + dgRtd.getDgKeywordsAndSet( + pdjs, + () => { + let targets = pbjs.adUnits[0].bids; + expect(targets[1].bidder).to.be.equal('dg2'); + expect(targets[1].params.placementId).to.be.equal(99999998); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].params.keywords).to.be.an('undefined'); + targets = pbjs.adUnits[1].bids; + expect(targets[0].bidder).to.be.equal('dg'); + expect(targets[0].params.placementId).to.be.equal(99999996); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[0].params.keywords).to.be.an('undefined'); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].params.keywords).to.be.an('undefined'); + + expect(config.getBidderConfig()).to.be.deep.equal({}); + + done(); + }, + moduleConfig, + null + ); + const request = server.requests[0]; + request.respond(404); + }); + it('should get profiles timeout.', function (done) { + let pdjs = getGlobal(); + pbjs.adUnits = cloneDeep(AD_UNITS); + let moduleConfig = cloneDeep(DEF_CONFIG); + moduleConfig.params.timeout = 10; + dgRtd.getDgKeywordsAndSet( + pdjs, + () => { + let targets = pbjs.adUnits[0].bids; + expect(targets[1].bidder).to.be.equal('dg2'); + expect(targets[1].params.placementId).to.be.equal(99999998); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].params.keywords).to.be.an('undefined'); + targets = pbjs.adUnits[1].bids; + expect(targets[0].bidder).to.be.equal('dg'); + expect(targets[0].params.placementId).to.be.equal(99999996); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[0].params.keywords).to.be.an('undefined'); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].params.keywords).to.be.an('undefined'); + + expect(config.getBidderConfig()).to.be.deep.equal({}); + + done(); + }, + moduleConfig, + null + ); + setTimeout(() => { + const request = server.requests[0]; + if (request) { + request.respond(200, DUMMY_RESPONSE_HEADER, JSON.stringify(DUMMY_RESPONSE)); + } + }, 1000) + }); + it('should get profiles ok(200).', function (done) { + let pdjs = getGlobal(); + pbjs.adUnits = cloneDeep(AD_UNITS); + let moduleConfig = cloneDeep(DEF_CONFIG); + dgRtd.getDgKeywordsAndSet(pdjs, () => { + let targets = pbjs.adUnits[0].bids; + expect(targets[1].bidder).to.be.equal('dg2'); + expect(targets[1].params.placementId).to.be.equal(99999998); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].params.keywords).to.be.deep.equal(SUCCESS_RESULT); + targets = pbjs.adUnits[1].bids; + expect(targets[0].bidder).to.be.equal('dg'); + expect(targets[0].params.placementId).to.be.equal(99999996); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[0].params.keywords).to.be.deep.equal(SUCCESS_RESULT); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].params.keywords).to.be.an('undefined'); + + // expect(config.getBidderConfig()).to.be.deep.equal({ dg2: SUCCESS_ORTB2, dg: SUCCESS_ORTB2 }); + + done(); + }, moduleConfig, null); + const request = server.requests[0]; + request.respond(200, DUMMY_RESPONSE_HEADER, JSON.stringify(DUMMY_RESPONSE)); + }); + }); +}); From c78238e8d1c0b15c611829d35c38c1b3ab47bf6e Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Wed, 26 May 2021 12:04:27 -0700 Subject: [PATCH 231/303] Revert "Dgkeyword Rtd Provider: add new real-time data submodule (#6410)" (#6837) This reverts commit e97db76c9288c82f849b9456b017ab010843b1a4. Co-authored-by: Olivier --- modules/.submodules.json | 1 - modules/dgkeywordRtdProvider.js | 132 ------- modules/dgkeywordRtdProvider.md | 35 -- .../spec/modules/dgkeywordRtdProvider_spec.js | 326 ------------------ 4 files changed, 494 deletions(-) delete mode 100644 modules/dgkeywordRtdProvider.js delete mode 100644 modules/dgkeywordRtdProvider.md delete mode 100644 test/spec/modules/dgkeywordRtdProvider_spec.js diff --git a/modules/.submodules.json b/modules/.submodules.json index 74ebc021a6d..0a10044a78e 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -36,7 +36,6 @@ ], "rtdModule": [ "browsiRtdProvider", - "dgkeywordRtdProvider", "geoedgeRtdProvider", "haloRtdProvider", "jwplayerRtdProvider", diff --git a/modules/dgkeywordRtdProvider.js b/modules/dgkeywordRtdProvider.js deleted file mode 100644 index 52fa9fd70c4..00000000000 --- a/modules/dgkeywordRtdProvider.js +++ /dev/null @@ -1,132 +0,0 @@ -/** - * This module adds dgkeyword provider to the real time data module - * The {@link module:modules/realTimeData} module is required - * The module will get keywords from 1plux profile api. - * This module can work only with AppNexusBidAdapter. - * @module modules/dgkeywordProvider - * @requires module:modules/realTimeData - */ - -import * as utils from '../src/utils.js'; -import { ajax } from '../src/ajax.js'; -import { submodule } from '../src/hook.js'; -import { getGlobal } from '../src/prebidGlobal.js'; - -/** - * get keywords from api server. and set keywords. - * @param {Object} reqBidsConfigObj - * @param {function} callback - * @param {Object} moduleConfig - * @param {Object} userConsent - */ -export function getDgKeywordsAndSet(reqBidsConfigObj, callback, moduleConfig, userConsent) { - const URL = 'https://mediaconsortium.profiles.tagger.opecloud.com/api/v1?url='; - const PROFILE_TIMEOUT_MS = 1000; - const timeout = (moduleConfig && moduleConfig.params && moduleConfig.params.timeout && Number(moduleConfig.params.timeout) > 0) ? Number(moduleConfig.params.timeout) : PROFILE_TIMEOUT_MS; - const url = (moduleConfig && moduleConfig.params && moduleConfig.params.url) ? moduleConfig.params.url : URL + encodeURIComponent(window.location.href); - const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits; - let isFinish = false; - utils.logMessage('[dgkeyword sub module]', adUnits, timeout); - let setKeywordTargetBidders = getTargetBidderOfDgKeywords(adUnits); - if (setKeywordTargetBidders.length <= 0) { - utils.logMessage('[dgkeyword sub module] no dgkeyword targets.'); - callback(); - } else { - utils.logMessage('[dgkeyword sub module] dgkeyword targets:', setKeywordTargetBidders); - utils.logMessage('[dgkeyword sub module] get targets from profile api start.'); - ajax(url, { - success: function(response) { - const res = JSON.parse(response); - if (!isFinish) { - utils.logMessage('[dgkeyword sub module] get targets from profile api end.'); - if (res) { - let keywords = {}; - if (res['s'] != null && res['s'].length > 0) { - keywords['opeaud'] = res['s']; - } - if (res['t'] != null && res['t'].length > 0) { - keywords['opectx'] = res['t']; - } - if (Object.keys(keywords).length > 0) { - const targetBidKeys = {} - for (let bid of setKeywordTargetBidders) { - // set keywords to params - bid.params.keywords = keywords; - if (!targetBidKeys[bid.bidder]) { - targetBidKeys[bid.bidder] = true; - } - } - - // set keywrods to ortb2 - let addOrtb2 = {}; - utils.deepSetValue(addOrtb2, 'site.keywords', keywords); - utils.deepSetValue(addOrtb2, 'user.keywords', keywords); - const ortb2 = {ortb2: addOrtb2}; - getGlobal().setBidderConfig({ bidders: Object.keys(targetBidKeys), config: ortb2 }); - } - } - isFinish = true; - } - callback(); - }, - error: function(errorStatus) { - // error occur - utils.logError('[dgkeyword sub module] profile api access error.', errorStatus); - callback(); - } - }, null, { - withCredentials: true, - contentType: 'application/json', - }); - setTimeout(function () { - if (!isFinish) { - // profile api timeout - utils.logInfo('[dgkeyword sub module] profile api timeout. [timeout: ' + timeout + 'ms]'); - isFinish = true; - } - callback(); - }, timeout); - } -} - -/** - * get all bidder which hava {dgkeyword: true} in params - * @param {Object} adUnits - */ -export function getTargetBidderOfDgKeywords(adUnits) { - let setKeywordTargetBidders = []; - for (let adUnit of adUnits) { - for (let bid of adUnit.bids) { - if (bid.params && bid.params['dgkeyword'] === true) { - delete bid.params['dgkeyword']; - setKeywordTargetBidders.push(bid); - } - } - } - return setKeywordTargetBidders; -} - -/** @type {RtdSubmodule} */ -export const dgkeywordSubmodule = { - /** - * used to link submodule with realTimeData - * @type {string} - */ - name: 'dgkeyword', - /** - * get data and send back to realTimeData module - * @function - * @param {string[]} adUnitsCodes - */ - getBidRequestData: getDgKeywordsAndSet, - init: init, -}; - -function init(moduleConfig) { - return true; -} - -function registerSubModule() { - submodule('realTimeData', dgkeywordSubmodule); -} -registerSubModule(); diff --git a/modules/dgkeywordRtdProvider.md b/modules/dgkeywordRtdProvider.md deleted file mode 100644 index 7cf532ea650..00000000000 --- a/modules/dgkeywordRtdProvider.md +++ /dev/null @@ -1,35 +0,0 @@ -## Overview - -Module Name: Digital Garage Keyword Module -Module Type: Rtd Provider -Maintainer: mediaconsortium-develop@bi.garage.co.jp -Remarks: This module can work only with AppNexusBidAdapter. -## Integration - -1) Compile the Digital Garage Keyword Module and Appnexus Bid Adapter into your Prebid build: - -``` -gulp build --modules="dgkeywordRtdProvider,appnexusBidAdapter,..." -``` - -2) Use `setConfig` to instruct Prebid.js to initilize the dgkeyword module, as specified below. - -## Configuration - -This module is configured as part of the `realTimeData.dataProviders` - -```javascript -var DGKEYWORD_TIMEOUT = 1000; -pbjs.setConfig({ - realTimeData: { - auctionDelay: DGKEYWORD_TIMEOUT, - dataProviders: [{ - name: 'dgkeyword', - waitForIt: true, - params: { - timeout: DGKEYWORD_TIMEOUT - } - }] - } -}); -``` diff --git a/test/spec/modules/dgkeywordRtdProvider_spec.js b/test/spec/modules/dgkeywordRtdProvider_spec.js deleted file mode 100644 index 0fac92e5118..00000000000 --- a/test/spec/modules/dgkeywordRtdProvider_spec.js +++ /dev/null @@ -1,326 +0,0 @@ -import * as dgRtd from 'modules/dgkeywordRtdProvider.js'; -import { cloneDeep } from 'lodash'; -import { server } from 'test/mocks/xhr.js'; -import { getGlobal } from 'src/prebidGlobal.js'; -import { config } from 'src/config.js'; - -const DG_GET_KEYWORDS_TIMEOUT = 1950; -const DEF_CONFIG = { - name: 'dgkeyword', - waitForIt: true, - params: { - timeout: DG_GET_KEYWORDS_TIMEOUT, - }, -}; -const DUMMY_RESPONSE_HEADER = {'Content-Type': 'application/json'}; -const DUMMY_RESPONSE = { s: ['s1', 's2'], t: ['t1', 't2'] }; -const SUCCESS_RESULT = { opeaud: ['s1', 's2'], opectx: ['t1', 't2'] }; -const SUCCESS_ORTB2 = { ortb2: { site: { keywords: SUCCESS_RESULT }, user: { keywords: SUCCESS_RESULT } } }; - -describe('Digital Garage Keyword Module', function () { - it('should init and return always true', function () { - expect(dgRtd.dgkeywordSubmodule.init()).to.equal(true); - }); - - describe('dgkeyword target test', function () { - it('should have no target', function () { - const adUnits_no_target = [ - { - code: 'code1', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999999, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999998, - dgkeyword: false, - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999997, - }, - }, - ], - }, - { - code: 'code2', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999996, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999995, - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999994, - }, - }, - ], - }, - ]; - expect(dgRtd.getTargetBidderOfDgKeywords(adUnits_no_target)).an('array') - .that.is.empty; - }); - it('should have targets', function () { - const adUnits_targets = [ - { - code: 'code1', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999999, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999998, - dgkeyword: true, - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999997, - dgkeyword: false, - }, - }, - ], - }, - { - code: 'code2', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999996, - dgkeyword: true, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999995, - dgkeyword: 'aa', - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999994, - dgkeyword: true, - }, - }, - ], - }, - ]; - const targets = dgRtd.getTargetBidderOfDgKeywords(adUnits_targets); - expect(targets[0].bidder).to.be.equal('dg2'); - expect(targets[0].params.placementId).to.be.equal(99999998); - expect(targets[0].params.dgkeyword).to.be.an('undefined'); - expect(targets[1].bidder).to.be.equal('dg'); - expect(targets[1].params.placementId).to.be.equal(99999996); - expect(targets[1].params.dgkeyword).to.be.an('undefined'); - expect(targets[2].bidder).to.be.equal('dg3'); - expect(targets[2].params.placementId).to.be.equal(99999994); - expect(targets[2].params.dgkeyword).to.be.an('undefined'); - }); - }); - - describe('get profile.', function () { - const AD_UNITS = [ - { - code: 'code1', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999999, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999998, - dgkeyword: true, - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999997, - dgkeyword: false, - }, - }, - ], - }, - { - code: 'code2', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999996, - dgkeyword: true, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999995, - dgkeyword: 'aa', - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999994, - }, - }, - ], - }, - ]; - it('should get profiles error(404).', function (done) { - let pdjs = getGlobal(); - pbjs.adUnits = cloneDeep(AD_UNITS); - let moduleConfig = cloneDeep(DEF_CONFIG); - dgRtd.getDgKeywordsAndSet( - pdjs, - () => { - let targets = pbjs.adUnits[0].bids; - expect(targets[1].bidder).to.be.equal('dg2'); - expect(targets[1].params.placementId).to.be.equal(99999998); - expect(targets[1].params.dgkeyword).to.be.an('undefined'); - expect(targets[1].params.keywords).to.be.an('undefined'); - targets = pbjs.adUnits[1].bids; - expect(targets[0].bidder).to.be.equal('dg'); - expect(targets[0].params.placementId).to.be.equal(99999996); - expect(targets[0].params.dgkeyword).to.be.an('undefined'); - expect(targets[0].params.keywords).to.be.an('undefined'); - expect(targets[2].bidder).to.be.equal('dg3'); - expect(targets[2].params.placementId).to.be.equal(99999994); - expect(targets[2].params.dgkeyword).to.be.an('undefined'); - expect(targets[2].params.keywords).to.be.an('undefined'); - - expect(config.getBidderConfig()).to.be.deep.equal({}); - - done(); - }, - moduleConfig, - null - ); - const request = server.requests[0]; - request.respond(404); - }); - it('should get profiles timeout.', function (done) { - let pdjs = getGlobal(); - pbjs.adUnits = cloneDeep(AD_UNITS); - let moduleConfig = cloneDeep(DEF_CONFIG); - moduleConfig.params.timeout = 10; - dgRtd.getDgKeywordsAndSet( - pdjs, - () => { - let targets = pbjs.adUnits[0].bids; - expect(targets[1].bidder).to.be.equal('dg2'); - expect(targets[1].params.placementId).to.be.equal(99999998); - expect(targets[1].params.dgkeyword).to.be.an('undefined'); - expect(targets[1].params.keywords).to.be.an('undefined'); - targets = pbjs.adUnits[1].bids; - expect(targets[0].bidder).to.be.equal('dg'); - expect(targets[0].params.placementId).to.be.equal(99999996); - expect(targets[0].params.dgkeyword).to.be.an('undefined'); - expect(targets[0].params.keywords).to.be.an('undefined'); - expect(targets[2].bidder).to.be.equal('dg3'); - expect(targets[2].params.placementId).to.be.equal(99999994); - expect(targets[2].params.dgkeyword).to.be.an('undefined'); - expect(targets[2].params.keywords).to.be.an('undefined'); - - expect(config.getBidderConfig()).to.be.deep.equal({}); - - done(); - }, - moduleConfig, - null - ); - setTimeout(() => { - const request = server.requests[0]; - if (request) { - request.respond(200, DUMMY_RESPONSE_HEADER, JSON.stringify(DUMMY_RESPONSE)); - } - }, 1000) - }); - it('should get profiles ok(200).', function (done) { - let pdjs = getGlobal(); - pbjs.adUnits = cloneDeep(AD_UNITS); - let moduleConfig = cloneDeep(DEF_CONFIG); - dgRtd.getDgKeywordsAndSet(pdjs, () => { - let targets = pbjs.adUnits[0].bids; - expect(targets[1].bidder).to.be.equal('dg2'); - expect(targets[1].params.placementId).to.be.equal(99999998); - expect(targets[1].params.dgkeyword).to.be.an('undefined'); - expect(targets[1].params.keywords).to.be.deep.equal(SUCCESS_RESULT); - targets = pbjs.adUnits[1].bids; - expect(targets[0].bidder).to.be.equal('dg'); - expect(targets[0].params.placementId).to.be.equal(99999996); - expect(targets[0].params.dgkeyword).to.be.an('undefined'); - expect(targets[0].params.keywords).to.be.deep.equal(SUCCESS_RESULT); - expect(targets[2].bidder).to.be.equal('dg3'); - expect(targets[2].params.placementId).to.be.equal(99999994); - expect(targets[2].params.dgkeyword).to.be.an('undefined'); - expect(targets[2].params.keywords).to.be.an('undefined'); - - // expect(config.getBidderConfig()).to.be.deep.equal({ dg2: SUCCESS_ORTB2, dg: SUCCESS_ORTB2 }); - - done(); - }, moduleConfig, null); - const request = server.requests[0]; - request.respond(200, DUMMY_RESPONSE_HEADER, JSON.stringify(DUMMY_RESPONSE)); - }); - }); -}); From 48f73e7b9ffb40b2e06db5e348e495cb3271bb5a Mon Sep 17 00:00:00 2001 From: jsfledd Date: Wed, 26 May 2021 12:29:22 -0700 Subject: [PATCH 232/303] NativoBidAdapter - Added new QS param to the bid request endpoint (#6838) * Initial nativoBidAdapter document creation (js, md and spec) * Fulling working prebid using nativoBidAdapter. Support for GDPR and CCPA in user syncs. * Added defult size settings based on the largest ad unit. Added response body validation. Added consent to request url qs params. * Changed bidder endpoint url * Changed double quotes to single quotes. * Reverted package-json.lock to remove modifications from PR * Added optional bidder param 'url' so the ad server can force- match an existing placement * Lint fix. Added space after if. * Added new QS param to send various adUnit data to adapter endpopint * Updated unit test for new QS param --- modules/nativoBidAdapter.js | 15 +++++++++++++++ test/spec/modules/nativoBidAdapter_spec.js | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/nativoBidAdapter.js b/modules/nativoBidAdapter.js index d396bd4d495..fc0925bf2ca 100644 --- a/modules/nativoBidAdapter.js +++ b/modules/nativoBidAdapter.js @@ -54,9 +54,24 @@ export const spec = { if (!pageUrl) pageUrl = bidderRequest.refererInfo.referer + // Build adUnit data + const adUnitData = { + adUnits: validBidRequests.map((adUnit) => { + return { + adUnitCode: adUnit.adUnitCode, + mediaTypes: adUnit.mediaTypes, + } + }), + } + + // Build QS Params let params = [ { key: 'ntv_ptd', value: placementIds.toString() }, { key: 'ntv_pb_rid', value: bidderRequest.bidderRequestId }, + { + key: 'ntv_ppc', + value: btoa(JSON.stringify(adUnitData)), // Convert to Base 64 + }, { key: 'ntv_url', value: encodeURIComponent(pageUrl), diff --git a/test/spec/modules/nativoBidAdapter_spec.js b/test/spec/modules/nativoBidAdapter_spec.js index e1132bf1b74..6f489a65d3c 100644 --- a/test/spec/modules/nativoBidAdapter_spec.js +++ b/test/spec/modules/nativoBidAdapter_spec.js @@ -65,8 +65,10 @@ describe('nativoBidAdapterTests', function () { expect(request.url).to.be.a('string') expect(request.url).to.include('?') - expect(request.url).to.include('ntv_url') expect(request.url).to.include('ntv_ptd') + expect(request.url).to.include('ntv_pb_rid') + expect(request.url).to.include('ntv_ppc') + expect(request.url).to.include('ntv_url') }) }) }) From 36d0f724a1b45ab321d57c7eb5741b591e6d327e Mon Sep 17 00:00:00 2001 From: hamper Date: Wed, 26 May 2021 23:00:08 +0300 Subject: [PATCH 233/303] Vuukle bid adapter: support for meta advertiserDomains (#6839) * add vuukle adapter * add readme * doc: add email * Vuukle bid adapter: support for meta advertiserDomains --- modules/vuukleBidAdapter.js | 6 +++++- test/spec/modules/vuukleBidAdapter_spec.js | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/vuukleBidAdapter.js b/modules/vuukleBidAdapter.js index e9770b5e62e..7a83bf4e331 100644 --- a/modules/vuukleBidAdapter.js +++ b/modules/vuukleBidAdapter.js @@ -55,8 +55,12 @@ export const spec = { currency: res.currency || 'USD', netRevenue: true, ttl: TIME_TO_LIVE, - ad: res.ad + ad: res.ad, + meta: { + advertiserDomains: Array.isArray(res.adomain) ? res.adomain : [] + } }; + return [bidResponse]; }, } diff --git a/test/spec/modules/vuukleBidAdapter_spec.js b/test/spec/modules/vuukleBidAdapter_spec.js index fdca4085c8e..17353a40b85 100644 --- a/test/spec/modules/vuukleBidAdapter_spec.js +++ b/test/spec/modules/vuukleBidAdapter_spec.js @@ -41,7 +41,8 @@ describe('vuukleBidAdapterTests', function() { 'width': 300, 'height': 250, 'creative_id': '12345', - 'ad': 'test ad' + 'ad': 'test ad', + 'adomain': ['example.com'] } }; @@ -55,5 +56,6 @@ describe('vuukleBidAdapterTests', function() { expect(bid.width).to.equal(300); expect(bid.height).to.equal(250); expect(bid.creativeId).to.equal('12345'); + expect(bid.meta.advertiserDomains).to.deep.equal(['example.com']); }); }); From 8cf4ad9227257b37cd95b8ea2d598198e1ecb679 Mon Sep 17 00:00:00 2001 From: John Salis Date: Wed, 26 May 2021 18:44:39 -0400 Subject: [PATCH 234/303] add support for advertiser domains and other bid meta (#6842) Co-authored-by: John Salis --- modules/beachfrontBidAdapter.js | 6 +- .../spec/modules/beachfrontBidAdapter_spec.js | 73 ++++++++++++++----- 2 files changed, 58 insertions(+), 21 deletions(-) diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index da5f385b0da..43df7eef9ae 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -71,13 +71,15 @@ export const spec = { let firstSize = getFirstSize(sizes); let context = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); let responseType = getVideoBidParam(bidRequest, 'responseType') || 'both'; + let responseMeta = Object.assign({ mediaType: VIDEO, advertiserDomains: [] }, response.meta); let bidResponse = { requestId: bidRequest.bidId, bidderCode: spec.code, cpm: response.bidPrice, width: firstSize.w, height: firstSize.h, - creativeId: response.crid || response.cmpId, + creativeId: response.crid, + meta: responseMeta, renderer: context === OUTSTREAM ? createRenderer(bidRequest) : null, mediaType: VIDEO, currency: CURRENCY, @@ -103,6 +105,7 @@ export const spec = { .filter(bid => bid.adm) .map((bid) => { let request = find(bidRequest, req => req.adUnitCode === bid.slot); + let responseMeta = Object.assign({ mediaType: BANNER, advertiserDomains: [] }, bid.meta); return { requestId: request.bidId, bidderCode: spec.code, @@ -111,6 +114,7 @@ export const spec = { cpm: bid.price, width: bid.w, height: bid.h, + meta: responseMeta, mediaType: BANNER, currency: CURRENCY, netRevenue: true, diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index fc74ec8a2aa..555f2c21262 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -673,6 +673,7 @@ describe('BeachfrontAdapter', function () { width: width, height: height, renderer: null, + meta: { mediaType: 'video', advertiserDomains: [] }, mediaType: 'video', currency: 'USD', netRevenue: true, @@ -680,26 +681,6 @@ describe('BeachfrontAdapter', function () { }); }); - it('should default to the legacy "cmpId" value for the creative ID', () => { - const width = 640; - const height = 480; - const bidRequest = bidRequests[0]; - bidRequest.mediaTypes = { - video: { - playerSize: [ width, height ] - } - }; - const serverResponse = { - bidPrice: 5.00, - url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', - cmpId: '123abc' - }; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - expect(bidResponse).to.deep.contain({ - creativeId: serverResponse.cmpId - }); - }); - it('should return only vast url if the response type is "nurl"', () => { const width = 640; const height = 480; @@ -761,6 +742,31 @@ describe('BeachfrontAdapter', function () { }); expect(bidResponse.renderer.render).to.be.a('function'); }); + + it('should return meta data for the bid response', () => { + const width = 640; + const height = 480; + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { + video: { + playerSize: [ width, height ] + } + }; + const serverResponse = { + bidPrice: 5.00, + url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', + meta: { + advertiserDomains: ['example.com'], + advertiserId: '123' + } + }; + const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); + expect(bidResponse.meta).to.deep.equal({ + mediaType: 'video', + advertiserDomains: ['example.com'], + advertiserId: '123' + }); + }); }); describe('for banner bids', function () { @@ -815,6 +821,7 @@ describe('BeachfrontAdapter', function () { cpm: serverResponse[ i ].price, width: serverResponse[ i ].w, height: serverResponse[ i ].h, + meta: { mediaType: 'banner', advertiserDomains: [] }, mediaType: 'banner', currency: 'USD', netRevenue: true, @@ -822,6 +829,32 @@ describe('BeachfrontAdapter', function () { }); } }); + + it('should return meta data for the bid response', () => { + bidRequests[0].mediaTypes = { + banner: { + sizes: [[ 300, 250 ], [ 728, 90 ]] + } + }; + const serverResponse = [{ + slot: bidRequests[0].adUnitCode, + adm: '
', + crid: 'crid_1', + price: 3.02, + w: 728, + h: 90, + meta: { + advertiserDomains: ['example.com'], + advertiserId: '123' + } + }]; + const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest: bidRequests }); + expect(bidResponse[0].meta).to.deep.equal({ + mediaType: 'banner', + advertiserDomains: ['example.com'], + advertiserId: '123' + }); + }); }); }); From b72e584a024446f1502a74b8c788006ac110f333 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Wed, 26 May 2021 16:26:24 -0700 Subject: [PATCH 235/303] Prebid Core: Check for stale rendering (#6707) * Check for stale rendering * Check for stale rendering - code review changes --- src/auctionManager.js | 6 + src/config.js | 7 +- src/constants.json | 3 +- src/prebid.js | 118 +++++---- src/secureCreatives.js | 14 +- test/spec/config_spec.js | 19 +- test/spec/unit/pbjs_api_spec.js | 121 +++++++++ test/spec/unit/secureCreatives_spec.js | 331 ++++++++++++++++++++++++- 8 files changed, 558 insertions(+), 61 deletions(-) diff --git a/src/auctionManager.js b/src/auctionManager.js index 1aca1277aa8..bbafd7426d5 100644 --- a/src/auctionManager.js +++ b/src/auctionManager.js @@ -15,6 +15,8 @@ * @property {function(): Object} createAuction - creates auction instance and stores it for future reference * @property {function(): Object} findBidByAdId - find bid received by adId. This function will be called by $$PREBID_GLOBAL$$.renderAd * @property {function(): Object} getStandardBidderAdServerTargeting - returns standard bidder targeting for all the adapters. Refer http://prebid.org/dev-docs/publisher-api-reference.html#module_pbjs.bidderSettings for more details + * @property {function(Object): void} addWinningBid - add a winning bid to an auction based on auctionId + * @property {function(): void} clearAllAuctions - clear all auctions for testing */ import { uniques, flatten, logWarn } from './utils.js'; @@ -113,6 +115,10 @@ export function newAuctionManager() { return _auctions.length && _auctions[_auctions.length - 1].getAuctionId() }; + auctionManager.clearAllAuctions = function() { + _auctions.length = 0; + } + function _addAuction(auction) { _auctions.push(auction); } diff --git a/src/config.js b/src/config.js index 7cb1a81955d..00cf1efd854 100644 --- a/src/config.js +++ b/src/config.js @@ -265,7 +265,7 @@ export function newConfig() { } for (let k of Object.keys(val)) { - if (k !== 'secondaryBidders') { + if (k !== 'secondaryBidders' && k !== 'suppressStaleRender') { utils.logWarn(`Auction Options given an incorrect param: ${k}`) return false } @@ -277,6 +277,11 @@ export function newConfig() { utils.logWarn(`Auction Options ${k} must be only string`); return false } + } else if (k === 'suppressStaleRender') { + if (!utils.isBoolean(val[k])) { + utils.logWarn(`Auction Options ${k} must be of type boolean`); + return false; + } } } return true; diff --git a/src/constants.json b/src/constants.json index e6b9687f911..c43e88cf75f 100644 --- a/src/constants.json +++ b/src/constants.json @@ -39,7 +39,8 @@ "AD_RENDER_FAILED": "adRenderFailed", "TCF2_ENFORCEMENT": "tcf2Enforcement", "AUCTION_DEBUG": "auctionDebug", - "BID_VIEWABLE": "bidViewable" + "BID_VIEWABLE": "bidViewable", + "STALE_RENDER": "staleRender" }, "AD_RENDER_FAILED_REASON" : { "PREVENT_WRITING_ON_MAIN_DOCUMENT": "preventWritingOnMainDocument", diff --git a/src/prebid.js b/src/prebid.js index 2211e8ec2b5..f58c97ec581 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -23,7 +23,7 @@ const events = require('./events.js'); const { triggerUserSyncs } = userSync; /* private variables */ -const { ADD_AD_UNITS, BID_WON, REQUEST_BIDS, SET_TARGETING, AD_RENDER_FAILED } = CONSTANTS.EVENTS; +const { ADD_AD_UNITS, BID_WON, REQUEST_BIDS, SET_TARGETING, AD_RENDER_FAILED, STALE_RENDER } = CONSTANTS.EVENTS; const { PREVENT_WRITING_ON_MAIN_DOCUMENT, NO_AD, EXCEPTION, CANNOT_FIND_AD, MISSING_DOC_OR_ADID } = CONSTANTS.AD_RENDER_FAILED_REASON; const eventValidators = { @@ -390,63 +390,75 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id, options) { try { // lookup ad by ad Id const bid = auctionManager.findBidByAdId(id); + if (bid) { - // replace macros according to openRTB with price paid = bid.cpm - bid.ad = utils.replaceAuctionPrice(bid.ad, bid.cpm); - bid.adUrl = utils.replaceAuctionPrice(bid.adUrl, bid.cpm); - - // replacing clickthrough if submitted - if (options && options.clickThrough) { - const { clickThrough } = options; - bid.ad = utils.replaceClickThrough(bid.ad, clickThrough); - bid.adUrl = utils.replaceClickThrough(bid.adUrl, clickThrough); + let shouldRender = true; + if (bid && bid.status === CONSTANTS.BID_STATUS.RENDERED) { + utils.logWarn(`Ad id ${bid.adId} has been rendered before`); + events.emit(STALE_RENDER, bid); + if (utils.deepAccess(config.getConfig('auctionOptions'), 'suppressStaleRender')) { + shouldRender = false; + } } - // save winning bids - auctionManager.addWinningBid(bid); - - // emit 'bid won' event here - events.emit(BID_WON, bid); - - const { height, width, ad, mediaType, adUrl, renderer } = bid; - - const creativeComment = document.createComment(`Creative ${bid.creativeId} served by ${bid.bidder} Prebid.js Header Bidding`); - utils.insertElement(creativeComment, doc, 'body'); - - if (isRendererRequired(renderer)) { - executeRenderer(renderer, bid); - } else if ((doc === document && !utils.inIframe()) || mediaType === 'video') { - const message = `Error trying to write ad. Ad render call ad id ${id} was prevented from writing to the main document.`; - emitAdRenderFail({ reason: PREVENT_WRITING_ON_MAIN_DOCUMENT, message, bid, id }); - } else if (ad) { - // will check if browser is firefox and below version 67, if so execute special doc.open() - // for details see: https://github.com/prebid/Prebid.js/pull/3524 - // TODO remove this browser specific code at later date (when Firefox < 67 usage is mostly gone) - if (navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('firefox/') > -1) { - const firefoxVerRegx = /firefox\/([\d\.]+)/; - let firefoxVer = navigator.userAgent.toLowerCase().match(firefoxVerRegx)[1]; // grabs the text in the 1st matching group - if (firefoxVer && parseInt(firefoxVer, 10) < 67) { - doc.open('text/html', 'replace'); + if (shouldRender) { + // replace macros according to openRTB with price paid = bid.cpm + bid.ad = utils.replaceAuctionPrice(bid.ad, bid.cpm); + bid.adUrl = utils.replaceAuctionPrice(bid.adUrl, bid.cpm); + + // replacing clickthrough if submitted + if (options && options.clickThrough) { + const {clickThrough} = options; + bid.ad = utils.replaceClickThrough(bid.ad, clickThrough); + bid.adUrl = utils.replaceClickThrough(bid.adUrl, clickThrough); + } + + // save winning bids + auctionManager.addWinningBid(bid); + + // emit 'bid won' event here + events.emit(BID_WON, bid); + + const {height, width, ad, mediaType, adUrl, renderer} = bid; + + const creativeComment = document.createComment(`Creative ${bid.creativeId} served by ${bid.bidder} Prebid.js Header Bidding`); + utils.insertElement(creativeComment, doc, 'body'); + + if (isRendererRequired(renderer)) { + executeRenderer(renderer, bid); + } else if ((doc === document && !utils.inIframe()) || mediaType === 'video') { + const message = `Error trying to write ad. Ad render call ad id ${id} was prevented from writing to the main document.`; + emitAdRenderFail({reason: PREVENT_WRITING_ON_MAIN_DOCUMENT, message, bid, id}); + } else if (ad) { + // will check if browser is firefox and below version 67, if so execute special doc.open() + // for details see: https://github.com/prebid/Prebid.js/pull/3524 + // TODO remove this browser specific code at later date (when Firefox < 67 usage is mostly gone) + if (navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('firefox/') > -1) { + const firefoxVerRegx = /firefox\/([\d\.]+)/; + let firefoxVer = navigator.userAgent.toLowerCase().match(firefoxVerRegx)[1]; // grabs the text in the 1st matching group + if (firefoxVer && parseInt(firefoxVer, 10) < 67) { + doc.open('text/html', 'replace'); + } } + doc.write(ad); + doc.close(); + setRenderSize(doc, width, height); + utils.callBurl(bid); + } else if (adUrl) { + const iframe = utils.createInvisibleIframe(); + iframe.height = height; + iframe.width = width; + iframe.style.display = 'inline'; + iframe.style.overflow = 'hidden'; + iframe.src = adUrl; + + utils.insertElement(iframe, doc, 'body'); + setRenderSize(doc, width, height); + utils.callBurl(bid); + } else { + const message = `Error trying to write ad. No ad for bid response id: ${id}`; + emitAdRenderFail({reason: NO_AD, message, bid, id}); } - doc.write(ad); - doc.close(); - setRenderSize(doc, width, height); - utils.callBurl(bid); - } else if (adUrl) { - const iframe = utils.createInvisibleIframe(); - iframe.height = height; - iframe.width = width; - iframe.style.display = 'inline'; - iframe.style.overflow = 'hidden'; - iframe.src = adUrl; - - utils.insertElement(iframe, doc, 'body'); - setRenderSize(doc, width, height); - utils.callBurl(bid); - } else { - const message = `Error trying to write ad. No ad for bid response id: ${id}`; - emitAdRenderFail({ reason: NO_AD, message, bid, id }); } } else { const message = `Error trying to write ad. Cannot find ad by given id : ${id}`; diff --git a/src/secureCreatives.js b/src/secureCreatives.js index def1a9abdbb..a172ec62630 100644 --- a/src/secureCreatives.js +++ b/src/secureCreatives.js @@ -6,19 +6,21 @@ import events from './events.js'; import { fireNativeTrackers, getAssetMessage, getAllAssetsMessage } from './native.js'; import constants from './constants.json'; -import { logWarn, replaceAuctionPrice } from './utils.js'; +import { logWarn, replaceAuctionPrice, deepAccess } from './utils.js'; import { auctionManager } from './auctionManager.js'; import find from 'core-js-pure/features/array/find.js'; import { isRendererRequired, executeRenderer } from './Renderer.js'; import includes from 'core-js-pure/features/array/includes.js'; +import { config } from './config.js'; const BID_WON = constants.EVENTS.BID_WON; +const STALE_RENDER = constants.EVENTS.STALE_RENDER; export function listenMessagesFromCreative() { window.addEventListener('message', receiveMessage, false); } -function receiveMessage(ev) { +export function receiveMessage(ev) { var key = ev.message ? 'message' : 'data'; var data = {}; try { @@ -33,6 +35,14 @@ function receiveMessage(ev) { }); if (adObject && data.message === 'Prebid Request') { + if (adObject.status === constants.BID_STATUS.RENDERED) { + logWarn(`Ad id ${adObject.adId} has been rendered before`); + events.emit(STALE_RENDER, adObject); + if (deepAccess(config.getConfig('auctionOptions'), 'suppressStaleRender')) { + return; + } + } + _sendAdToCreative(adObject, ev); // save winning bids diff --git a/test/spec/config_spec.js b/test/spec/config_spec.js index 8161d9f1827..9492db6e849 100644 --- a/test/spec/config_spec.js +++ b/test/spec/config_spec.js @@ -233,7 +233,7 @@ describe('config API', function () { expect(logWarnSpy.called).to.equal(false); }); - it('sets auctionOptions', function () { + it('sets auctionOptions secondaryBidders', function () { const auctionOptionsConfig = { 'secondaryBidders': ['rubicon', 'appnexus'] } @@ -241,6 +241,14 @@ describe('config API', function () { expect(getConfig('auctionOptions')).to.eql(auctionOptionsConfig); }); + it('sets auctionOptions suppressStaleRender', function () { + const auctionOptionsConfig = { + 'suppressStaleRender': true + } + setConfig({ auctionOptions: auctionOptionsConfig }); + expect(getConfig('auctionOptions')).to.eql(auctionOptionsConfig); + }); + it('should log warning for the wrong value passed to auctionOptions', function () { setConfig({ auctionOptions: '' }); expect(logWarnSpy.calledOnce).to.equal(true); @@ -257,6 +265,15 @@ describe('config API', function () { assert.ok(logWarnSpy.calledWith(warning), 'expected warning was logged'); }); + it('should log warning for invalid auctionOptions suppress stale render', function () { + setConfig({ auctionOptions: { + 'suppressStaleRender': 'test', + }}); + expect(logWarnSpy.calledOnce).to.equal(true); + const warning = 'Auction Options suppressStaleRender must be of type boolean'; + assert.ok(logWarnSpy.calledWith(warning), 'expected warning was logged'); + }); + it('should log warning for invalid properties to auctionOptions', function () { setConfig({ auctionOptions: { 'testing': true diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index 805eae9e3bc..0bd3380f737 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -199,6 +199,10 @@ describe('Unit: Prebid Module', function () { configObj.setConfig({ useBidCache: false }); }); + after(function() { + auctionManager.clearAllAuctions(); + }); + describe('getAdserverTargetingForAdUnitCodeStr', function () { beforeEach(function () { resetAuction(); @@ -1062,6 +1066,8 @@ describe('Unit: Prebid Module', function () { var adResponse = {}; var spyLogError = null; var spyLogMessage = null; + var spyLogWarn = null; + var spyAddWinningBid; var inIframe = true; var triggerPixelStub; @@ -1100,6 +1106,8 @@ describe('Unit: Prebid Module', function () { spyLogError = sinon.spy(utils, 'logError'); spyLogMessage = sinon.spy(utils, 'logMessage'); + spyLogWarn = sinon.spy(utils, 'logWarn'); + spyAddWinningBid = sinon.spy(auctionManager, 'addWinningBid'); inIframe = true; sinon.stub(utils, 'inIframe').callsFake(() => inIframe); @@ -1110,8 +1118,10 @@ describe('Unit: Prebid Module', function () { auction.getBidsReceived = getBidResponses; utils.logError.restore(); utils.logMessage.restore(); + utils.logWarn.restore(); utils.inIframe.restore(); triggerPixelStub.restore(); + spyAddWinningBid.restore(); }); it('should require doc and id params', function () { @@ -1218,6 +1228,117 @@ describe('Unit: Prebid Module', function () { sinon.assert.calledOnce(triggerPixelStub); sinon.assert.calledWith(triggerPixelStub, burl); }); + + it('should call addWinningBid', function () { + pushBidResponseToAuction({ + ad: "" + }); + $$PREBID_GLOBAL$$.renderAd(doc, bidId); + var message = 'Calling renderAd with adId :' + bidId; + sinon.assert.calledWith(spyLogMessage, message); + + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(spyAddWinningBid, adResponse); + }); + + it('should warn stale rendering', function () { + var message = 'Calling renderAd with adId :' + bidId; + var warning = `Ad id ${bidId} has been rendered before`; + var onWonEvent = sinon.stub(); + var onStaleEvent = sinon.stub(); + + $$PREBID_GLOBAL$$.onEvent(CONSTANTS.EVENTS.BID_WON, onWonEvent); + $$PREBID_GLOBAL$$.onEvent(CONSTANTS.EVENTS.STALE_RENDER, onStaleEvent); + + pushBidResponseToAuction({ + ad: "" + }); + + // First render should pass with no warning and added to winning bids + $$PREBID_GLOBAL$$.renderAd(doc, bidId); + sinon.assert.calledWith(spyLogMessage, message); + sinon.assert.neverCalledWith(spyLogWarn, warning); + + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(spyAddWinningBid, adResponse); + + sinon.assert.calledWith(onWonEvent, adResponse); + sinon.assert.notCalled(onStaleEvent); + expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED); + + // Reset call history for spies and stubs + spyLogMessage.resetHistory(); + spyLogWarn.resetHistory(); + spyAddWinningBid.resetHistory(); + onWonEvent.resetHistory(); + onStaleEvent.resetHistory(); + + // Second render should have a warning but still added to winning bids + $$PREBID_GLOBAL$$.renderAd(doc, bidId); + sinon.assert.calledWith(spyLogMessage, message); + sinon.assert.calledWith(spyLogWarn, warning); + + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(spyAddWinningBid, adResponse); + + sinon.assert.calledWith(onWonEvent, adResponse); + sinon.assert.calledWith(onStaleEvent, adResponse); + + // Clean up + $$PREBID_GLOBAL$$.offEvent(CONSTANTS.EVENTS.BID_WON, onWonEvent); + $$PREBID_GLOBAL$$.offEvent(CONSTANTS.EVENTS.STALE_RENDER, onStaleEvent); + }); + + it('should stop stale rendering', function () { + var message = 'Calling renderAd with adId :' + bidId; + var warning = `Ad id ${bidId} has been rendered before`; + var onWonEvent = sinon.stub(); + var onStaleEvent = sinon.stub(); + + // Setting suppressStaleRender to true explicitly + configObj.setConfig({'auctionOptions': {'suppressStaleRender': true}}); + + $$PREBID_GLOBAL$$.onEvent(CONSTANTS.EVENTS.BID_WON, onWonEvent); + $$PREBID_GLOBAL$$.onEvent(CONSTANTS.EVENTS.STALE_RENDER, onStaleEvent); + + pushBidResponseToAuction({ + ad: "" + }); + + // First render should pass with no warning and added to winning bids + $$PREBID_GLOBAL$$.renderAd(doc, bidId); + sinon.assert.calledWith(spyLogMessage, message); + sinon.assert.neverCalledWith(spyLogWarn, warning); + + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(spyAddWinningBid, adResponse); + expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED); + + sinon.assert.calledWith(onWonEvent, adResponse); + sinon.assert.notCalled(onStaleEvent); + + // Reset call history for spies and stubs + spyLogMessage.resetHistory(); + spyLogWarn.resetHistory(); + spyAddWinningBid.resetHistory(); + onWonEvent.resetHistory(); + onStaleEvent.resetHistory(); + + // Second render should have a warning and do not proceed further + $$PREBID_GLOBAL$$.renderAd(doc, bidId); + sinon.assert.calledWith(spyLogMessage, message); + sinon.assert.calledWith(spyLogWarn, warning); + + sinon.assert.notCalled(spyAddWinningBid); + + sinon.assert.notCalled(onWonEvent); + sinon.assert.calledWith(onStaleEvent, adResponse); + + // Clean up + $$PREBID_GLOBAL$$.offEvent(CONSTANTS.EVENTS.BID_WON, onWonEvent); + $$PREBID_GLOBAL$$.offEvent(CONSTANTS.EVENTS.STALE_RENDER, onStaleEvent); + configObj.setConfig({'auctionOptions': {}}); + }); }); describe('requestBids', function () { diff --git a/test/spec/unit/secureCreatives_spec.js b/test/spec/unit/secureCreatives_spec.js index 566154f0003..eca00e8c8fa 100644 --- a/test/spec/unit/secureCreatives_spec.js +++ b/test/spec/unit/secureCreatives_spec.js @@ -1,8 +1,18 @@ import { - _sendAdToCreative -} from '../../../src/secureCreatives.js'; -import { expect } from 'chai'; + _sendAdToCreative, receiveMessage +} from 'src/secureCreatives.js'; import * as utils from 'src/utils.js'; +import {getAdUnits, getBidRequests, getBidResponses} from 'test/fixtures/fixtures.js'; +import {auctionManager} from 'src/auctionManager.js'; +import * as auctionModule from 'src/auction.js'; +import * as native from 'src/native.js'; +import {fireNativeTrackers, getAllAssetsMessage} from 'src/native.js'; +import events from 'src/events.js'; +import { config as configObj } from 'src/config.js'; + +import { expect } from 'chai'; + +var CONSTANTS = require('src/constants.json'); describe('secureCreatives', () => { describe('_sendAdToCreative', () => { @@ -42,4 +52,319 @@ describe('secureCreatives', () => { window.apntag = oldapntag; }); }); + + describe('receiveMessage', function() { + const bidId = 1; + const warning = `Ad id ${bidId} has been rendered before`; + let auction; + let adResponse = {}; + let spyAddWinningBid; + let spyLogWarn; + let stubFireNativeTrackers; + let stubGetAllAssetsMessage; + let stubEmit; + + function pushBidResponseToAuction(obj) { + adResponse = Object.assign({ + auctionId: 1, + adId: bidId, + width: 300, + height: 250, + renderer: null + }, obj); + auction.getBidsReceived = function() { + let bidsReceived = getBidResponses(); + bidsReceived.push(adResponse); + return bidsReceived; + } + auction.getAuctionId = () => 1; + } + + function resetAuction() { + $$PREBID_GLOBAL$$.setConfig({ enableSendAllBids: false }); + auction.getBidRequests = getBidRequests; + auction.getBidsReceived = getBidResponses; + auction.getAdUnits = getAdUnits; + auction.getAuctionStatus = function() { return auctionModule.AUCTION_COMPLETED } + } + + function resetHistories(...others) { + [ + spyAddWinningBid, + spyLogWarn, + stubFireNativeTrackers, + stubGetAllAssetsMessage, + stubEmit + ].forEach(s => s.resetHistory()); + + if (others && others.length > 0) { others.forEach(s => s.resetHistory()); } + } + + before(function() { + const adUnits = getAdUnits(); + const adUnitCodes = getAdUnits().map(unit => unit.code); + const bidsBackHandler = function() {}; + const timeout = 2000; + auction = auctionManager.createAuction({adUnits, adUnitCodes, callback: bidsBackHandler, cbTimeout: timeout}); + resetAuction(); + }); + + after(function() { + auctionManager.clearAllAuctions(); + }); + + beforeEach(function() { + spyAddWinningBid = sinon.spy(auctionManager, 'addWinningBid'); + spyLogWarn = sinon.spy(utils, 'logWarn'); + stubFireNativeTrackers = sinon.stub(native, 'fireNativeTrackers'); + stubGetAllAssetsMessage = sinon.stub(native, 'getAllAssetsMessage'); + stubEmit = sinon.stub(events, 'emit'); + }); + + afterEach(function() { + spyAddWinningBid.restore(); + spyLogWarn.restore(); + stubFireNativeTrackers.restore(); + stubGetAllAssetsMessage.restore(); + stubEmit.restore(); + resetAuction(); + }); + + describe('Prebid Request', function() { + it('should render', function () { + pushBidResponseToAuction({ + renderer: {render: sinon.stub(), url: 'some url'} + }); + + const data = { + adId: bidId, + message: 'Prebid Request' + }; + + const ev = { + data: JSON.stringify(data) + }; + + receiveMessage(ev); + + sinon.assert.neverCalledWith(spyLogWarn, warning); + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(spyAddWinningBid, adResponse); + sinon.assert.calledOnce(adResponse.renderer.render); + sinon.assert.calledWith(adResponse.renderer.render, adResponse); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); + + expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED); + }); + + it('should allow stale rendering without config', function () { + pushBidResponseToAuction({ + renderer: {render: sinon.stub(), url: 'some url'} + }); + + const data = { + adId: bidId, + message: 'Prebid Request' + }; + + const ev = { + data: JSON.stringify(data) + }; + + receiveMessage(ev); + + sinon.assert.neverCalledWith(spyLogWarn, warning); + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(spyAddWinningBid, adResponse); + sinon.assert.calledOnce(adResponse.renderer.render); + sinon.assert.calledWith(adResponse.renderer.render, adResponse); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); + + expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED); + + resetHistories(adResponse.renderer.render); + + receiveMessage(ev); + + sinon.assert.calledWith(spyLogWarn, warning); + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(spyAddWinningBid, adResponse); + sinon.assert.calledOnce(adResponse.renderer.render); + sinon.assert.calledWith(adResponse.renderer.render, adResponse); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER, adResponse); + }); + + it('should stop stale rendering with config', function () { + configObj.setConfig({'auctionOptions': {'suppressStaleRender': true}}); + + pushBidResponseToAuction({ + renderer: {render: sinon.stub(), url: 'some url'} + }); + + const data = { + adId: bidId, + message: 'Prebid Request' + }; + + const ev = { + data: JSON.stringify(data) + }; + + receiveMessage(ev); + + sinon.assert.neverCalledWith(spyLogWarn, warning); + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(spyAddWinningBid, adResponse); + sinon.assert.calledOnce(adResponse.renderer.render); + sinon.assert.calledWith(adResponse.renderer.render, adResponse); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); + + expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED); + + resetHistories(adResponse.renderer.render); + + receiveMessage(ev); + + sinon.assert.calledWith(spyLogWarn, warning); + sinon.assert.notCalled(spyAddWinningBid); + sinon.assert.notCalled(adResponse.renderer.render); + sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER, adResponse); + + configObj.setConfig({'auctionOptions': {}}); + }); + }); + + describe('Prebid Native', function() { + it('Prebid native should render', function () { + pushBidResponseToAuction({}); + + const data = { + adId: bidId, + message: 'Prebid Native', + action: 'allAssetRequest' + }; + + const ev = { + data: JSON.stringify(data), + source: { + postMessage: sinon.stub() + }, + origin: 'any origin' + }; + + receiveMessage(ev); + + sinon.assert.neverCalledWith(spyLogWarn, warning); + sinon.assert.calledOnce(stubGetAllAssetsMessage); + sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse); + sinon.assert.calledOnce(ev.source.postMessage); + sinon.assert.calledOnce(stubFireNativeTrackers); + sinon.assert.calledWith(stubFireNativeTrackers, data, adResponse); + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); + }); + + it('Prebid native should allow stale rendering without config', function () { + pushBidResponseToAuction({}); + + const data = { + adId: bidId, + message: 'Prebid Native', + action: 'allAssetRequest' + }; + + const ev = { + data: JSON.stringify(data), + source: { + postMessage: sinon.stub() + }, + origin: 'any origin' + }; + + receiveMessage(ev); + + sinon.assert.neverCalledWith(spyLogWarn, warning); + sinon.assert.calledOnce(stubGetAllAssetsMessage); + sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse); + sinon.assert.calledOnce(ev.source.postMessage); + sinon.assert.calledOnce(stubFireNativeTrackers); + sinon.assert.calledWith(stubFireNativeTrackers, data, adResponse); + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); + + expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED); + + resetHistories(ev.source.postMessage); + + receiveMessage(ev); + + sinon.assert.neverCalledWith(spyLogWarn, warning); + sinon.assert.calledOnce(stubGetAllAssetsMessage); + sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse); + sinon.assert.calledOnce(ev.source.postMessage); + sinon.assert.calledOnce(stubFireNativeTrackers); + sinon.assert.calledWith(stubFireNativeTrackers, data, adResponse); + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); + }); + + it('Prebid native should allow stale rendering with config', function () { + configObj.setConfig({'auctionOptions': {'suppressStaleRender': true}}); + + pushBidResponseToAuction({}); + + const data = { + adId: bidId, + message: 'Prebid Native', + action: 'allAssetRequest' + }; + + const ev = { + data: JSON.stringify(data), + source: { + postMessage: sinon.stub() + }, + origin: 'any origin' + }; + + receiveMessage(ev); + + sinon.assert.neverCalledWith(spyLogWarn, warning); + sinon.assert.calledOnce(stubGetAllAssetsMessage); + sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse); + sinon.assert.calledOnce(ev.source.postMessage); + sinon.assert.calledOnce(stubFireNativeTrackers); + sinon.assert.calledWith(stubFireNativeTrackers, data, adResponse); + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); + + expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED); + + resetHistories(ev.source.postMessage); + + receiveMessage(ev); + + sinon.assert.neverCalledWith(spyLogWarn, warning); + sinon.assert.calledOnce(stubGetAllAssetsMessage); + sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse); + sinon.assert.calledOnce(ev.source.postMessage); + sinon.assert.calledOnce(stubFireNativeTrackers); + sinon.assert.calledWith(stubFireNativeTrackers, data, adResponse); + sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); + + configObj.setConfig({'auctionOptions': {}}); + }); + }); + }); }); From 9013e5564c5d773adc4f6ad2a51220c9b29307e3 Mon Sep 17 00:00:00 2001 From: prebidtappx <77485538+prebidtappx@users.noreply.github.com> Date: Thu, 27 May 2021 11:30:38 +0200 Subject: [PATCH 236/303] tappx Bid Adapter: fix wrong regex and gdpr bug (#6834) * tappxBidAdapter: hotfix gdpr url param * tappxBidAdapter: update version * tappxBidAdapter: update regex errors --- modules/tappxBidAdapter.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/tappxBidAdapter.js b/modules/tappxBidAdapter.js index 566795a204b..48e0abc5c7f 100644 --- a/modules/tappxBidAdapter.js +++ b/modules/tappxBidAdapter.js @@ -8,7 +8,7 @@ import { config } from '../src/config.js'; const BIDDER_CODE = 'tappx'; const TTL = 360; const CUR = 'USD'; -const TAPPX_BIDDER_VERSION = '0.1.10514'; +const TAPPX_BIDDER_VERSION = '0.1.10526'; const TYPE_CNN = 'prebidjs'; const VIDEO_SUPPORT = ['instream']; @@ -79,7 +79,7 @@ export const spec = { // GDPR & CCPA if (gdprConsent) { - url += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); + url += '&gdpr_optin=' + (gdprConsent.gdprApplies ? 1 : 0); url += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''); } if (uspConsent) { @@ -120,7 +120,7 @@ function validBasic(bid) { } let classicEndpoint = true - if ((new RegExp(`^(vz.*|zz.*)\.*$`, 'i')).test(bid.params.host)) { + if ((new RegExp(`^(vz.*|zz.*)\\.*$`, 'i')).test(bid.params.host)) { classicEndpoint = false } @@ -398,8 +398,8 @@ function getHostInfo(validBidRequests) { domainInfo.domain = hostParam.split('/', 1)[0]; - let regexNewEndpoints = new RegExp(`^(vz.*|zz.*)\.pub\.tappx\.com$`, 'i'); - let regexClassicEndpoints = new RegExp(`^([a-z]{3}|testing)\.[a-z]{3}\.tappx\.com$`, 'i'); + let regexNewEndpoints = new RegExp(`^(vz.*|zz.*)\\.[a-z]{3}\\.tappx\\.com$`, 'i'); + let regexClassicEndpoints = new RegExp(`^([a-z]{3}|testing)\\.[a-z]{3}\\.tappx\\.com$`, 'i'); if (regexNewEndpoints.test(domainInfo.domain)) { domainInfo.newEndpoint = true; From 3cbdf86cb1d729c71f70c13221bfb22dc2c78ac0 Mon Sep 17 00:00:00 2001 From: guiann Date: Thu, 27 May 2021 12:21:34 +0200 Subject: [PATCH 237/303] Adyoulike bid adapter - improvements on Native case (#6831) * add required clickurl in every native adrequest * allows the native response to be given as is to prebid if possible * add unit tests on new Native case --- modules/adyoulikeBidAdapter.js | 101 ++++++++-------- test/spec/modules/adyoulikeBidAdapter_spec.js | 113 ++++++++++++------ 2 files changed, 130 insertions(+), 84 deletions(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 00c7c02dc72..44d8e2e3016 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -78,6 +78,10 @@ export const spec = { if (nativeReq.type === 'image') { nativeReq = Object.assign({}, NATIVE_IMAGE, nativeReq); } + // click url is always mandatory even if not specified by publisher + nativeReq.clickUrl = { + required: true + }; accumulator[bidReq.bidId].Native = nativeReq; } if (mediatype === VIDEO) { @@ -329,6 +333,9 @@ function getVideoAd(response) { } function getNativeAssets(response, nativeConfig) { + if (typeof response.Native === 'object') { + return response.Native; + } const native = {}; var adJson = {}; @@ -362,59 +369,55 @@ function getNativeAssets(response, nativeConfig) { } Object.keys(nativeConfig).map(function(key, index) { - if (typeof response.Native === 'object') { - native[key] = response.Native[key]; - } else { - switch (key) { - case 'title': - native[key] = textsJson.TITLE; - break; - case 'body': - native[key] = textsJson.DESCRIPTION; - break; - case 'cta': - native[key] = textsJson.CALLTOACTION; - break; - case 'sponsoredBy': - native[key] = adJson.Content.Preview.Sponsor.Name; - break; - case 'image': - // main image requested size - const imgSize = nativeConfig.image.sizes || []; - if (!imgSize.length) { - imgSize[0] = response.Width || 300; - imgSize[1] = response.Height || 250; + switch (key) { + case 'title': + native[key] = textsJson.TITLE; + break; + case 'body': + native[key] = textsJson.DESCRIPTION; + break; + case 'cta': + native[key] = textsJson.CALLTOACTION; + break; + case 'sponsoredBy': + native[key] = adJson.Content.Preview.Sponsor.Name; + break; + case 'image': + // main image requested size + const imgSize = nativeConfig.image.sizes || []; + if (!imgSize.length) { + imgSize[0] = response.Width || 300; + imgSize[1] = response.Height || 250; + } + + native[key] = { + url: getImageUrl(adJson, adJson.Content.Preview.Thumbnail.Image, imgSize[0], imgSize[1]), + width: imgSize[0], + height: imgSize[1] + }; + break; + case 'icon': + if (adJson.HasSponsorImage) { + // icon requested size + const iconSize = nativeConfig.icon.sizes || []; + if (!iconSize.length) { + iconSize[0] = 50; + iconSize[1] = 50; } native[key] = { - url: getImageUrl(adJson, adJson.Content.Preview.Thumbnail.Image, imgSize[0], imgSize[1]), - width: imgSize[0], - height: imgSize[1] + url: getImageUrl(adJson, adJson.Content.Preview.Sponsor.Logo.Resource, iconSize[0], iconSize[1]), + width: iconSize[0], + height: iconSize[1] }; - break; - case 'icon': - if (adJson.HasSponsorImage) { - // icon requested size - const iconSize = nativeConfig.icon.sizes || []; - if (!iconSize.length) { - iconSize[0] = 50; - iconSize[1] = 50; - } - - native[key] = { - url: getImageUrl(adJson, adJson.Content.Preview.Sponsor.Logo.Resource, iconSize[0], iconSize[1]), - width: iconSize[0], - height: iconSize[1] - }; - } - break; - case 'privacyIcon': - native[key] = getImageUrl(adJson, adJson.Content.Preview.Credit.Logo.Resource, 25, 25); - break; - case 'privacyLink': - native[key] = adJson.Content.Preview.Credit.Url; - break; - } + } + break; + case 'privacyIcon': + native[key] = getImageUrl(adJson, adJson.Content.Preview.Credit.Logo.Resource, 25, 25); + break; + case 'privacyLink': + native[key] = adJson.Content.Preview.Credit.Url; + break; } }); diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index c432ad1b32d..abf8793865c 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -300,6 +300,74 @@ describe('Adyoulike Adapter', function () { 'Height': 600, } ]; + + const responseWithSingleNative = [{ + 'BidID': 'bid_id_0', + 'Placement': 'placement_0', + 'Native': { + 'body': 'Considérant l\'extrémité conjoncturelle, il serait bon d\'anticiper toutes les voies de bon sens.', + 'cta': 'Click here to learn more', + 'clickUrl': 'https://tracking.omnitagjs.com/tracking/ar?event_kind=CLICK&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991&url=https%3A%2F%2Fwww.w3.org%2FPeople%2Fmimasa%2Ftest%2Fxhtml%2Fentities%2Fentities-11.xhtml%23lat1', + 'image': { + 'height': 600, + 'url': 'https://blobs.omnitagjs.com/blobs/f1/f1c80d4bb5643c22/fd4362d35bb174d6f1c80d4bb5643c22', + 'width': 300 + }, + 'privacyIcon': 'https://fo-static.omnitagjs.com/fo-static/native/images/info-ayl.png', + 'privacyLink': 'https://blobs.omnitagjs.com/adchoice/', + 'sponsoredBy': 'QA Team', + 'title': 'Adserver Traffic Redirect Internal', + 'impressionTrackers': [ + 'https://testPixelIMP.com/fake', + 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=IMPRESSION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991', + 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=INSERTION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991', + ], + 'javascriptTrackers': [ + 'https://testJsIMP.com/fake.js' + ], + 'clickTrackers': [ + 'https://testPixelCLICK.com/fake' + ] + }, + 'Price': 0.5, + 'Height': 600, + }]; + + const nativeResult = [{ + cpm: 0.5, + creativeId: undefined, + currency: 'USD', + netRevenue: true, + requestId: 'bid_id_0', + ttl: 3600, + mediaType: 'native', + native: { + body: 'Considérant l\'extrémité conjoncturelle, il serait bon d\'anticiper toutes les voies de bon sens.', + clickTrackers: [ + 'https://testPixelCLICK.com/fake' + ], + clickUrl: 'https://tracking.omnitagjs.com/tracking/ar?event_kind=CLICK&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991&url=https%3A%2F%2Fwww.w3.org%2FPeople%2Fmimasa%2Ftest%2Fxhtml%2Fentities%2Fentities-11.xhtml%23lat1', + cta: 'Click here to learn more', + image: { + height: 600, + url: 'https://blobs.omnitagjs.com/blobs/f1/f1c80d4bb5643c22/fd4362d35bb174d6f1c80d4bb5643c22', + width: 300, + }, + impressionTrackers: [ + 'https://testPixelIMP.com/fake', + 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=IMPRESSION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991', + 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=INSERTION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991' + ], + javascriptTrackers: [ + 'https://testJsIMP.com/fake.js' + ], + privacyIcon: 'https://fo-static.omnitagjs.com/fo-static/native/images/info-ayl.png', + privacyLink: 'https://blobs.omnitagjs.com/adchoice/', + sponsoredBy: 'QA Team', + title: 'Adserver Traffic Redirect Internal', + } + }]; + const responseWithMultiplePlacements = [ { 'BidID': 'bid_id_0', @@ -569,46 +637,21 @@ describe('Adyoulike Adapter', function () { }); it('receive reponse with Native ad', function () { - serverResponse.body = responseWithSinglePlacement; + serverResponse.body = responseWithSingleNative; let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(sentBidNative) + '}'}); expect(result.length).to.equal(1); - expect(result).to.deep.equal([{ - cpm: 0.5, - creativeId: undefined, - currency: 'USD', - netRevenue: true, - requestId: 'bid_id_0', - ttl: 3600, - mediaType: 'native', - native: { - body: 'Considérant l\'extrémité conjoncturelle, il serait bon d\'anticiper toutes les voies de bon sens.', - clickTrackers: [ - 'https://testPixelCLICK.com/fake' - ], - clickUrl: 'https://tracking.omnitagjs.com/tracking/ar?event_kind=CLICK&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991&url=https%3A%2F%2Fwww.w3.org%2FPeople%2Fmimasa%2Ftest%2Fxhtml%2Fentities%2Fentities-11.xhtml%23lat1', - cta: 'Click here to learn more', - image: { - height: 600, - url: 'https://blobs.omnitagjs.com/blobs/f1/f1c80d4bb5643c22/fd4362d35bb174d6f1c80d4bb5643c22', - width: 300, - }, - impressionTrackers: [ - 'https://testPixelIMP.com/fake', - 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=IMPRESSION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991', - 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=INSERTION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991' - ], - javascriptTrackers: [ - 'https://testJsIMP.com/fake.js' - ], - privacyIcon: 'https://fo-static.omnitagjs.com/fo-static/native/images/info-ayl.png', - privacyLink: 'https://blobs.omnitagjs.com/adchoice/', - sponsoredBy: 'QA Team', - title: 'Adserver Traffic Redirect Internal', - } + expect(result).to.deep.equal(nativeResult); + }); + + it('receive reponse with Native from ad markup', function () { + serverResponse.body = responseWithSinglePlacement; + let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(sentBidNative) + '}'}); + + expect(result.length).to.equal(1); - }]); + expect(result).to.deep.equal(nativeResult); }); }); }); From 438b0e9c8086ebbb06c291c4574136db710ce138 Mon Sep 17 00:00:00 2001 From: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Date: Thu, 27 May 2021 16:23:55 +0600 Subject: [PATCH 238/303] Zeta Ssp Bid Adapter: Improve user sync logic (#6835) --- modules/zetaSspBidAdapter.js | 46 ++++++++++++++------- test/spec/modules/zetaSspBidAdapter_spec.js | 30 ++++++++++++-- 2 files changed, 58 insertions(+), 18 deletions(-) diff --git a/modules/zetaSspBidAdapter.js b/modules/zetaSspBidAdapter.js index 450608a82f4..258478b0886 100644 --- a/modules/zetaSspBidAdapter.js +++ b/modules/zetaSspBidAdapter.js @@ -5,7 +5,8 @@ import {config} from '../src/config.js'; const BIDDER_CODE = 'zeta_global_ssp'; const ENDPOINT_URL = 'https://ssp.disqus.com/bid'; -const USER_SYNC_URL = 'https://ssp.disqus.com/match'; +const USER_SYNC_URL_IFRAME = 'https://ssp.disqus.com/sync?type=iframe'; +const USER_SYNC_URL_IMAGE = 'https://ssp.disqus.com/sync?type=image'; const DEFAULT_CUR = 'USD'; const TTL = 200; const NET_REV = true; @@ -58,7 +59,7 @@ export const spec = { app: params.app ? params.app : {}, ext: { tags: params.tags ? params.tags : {}, - sid: params.sid ? params.sid : {} + sid: params.sid ? params.sid : undefined } }; @@ -123,23 +124,38 @@ export const spec = { }, /** - * Register the user sync pixels which should be dropped after the auction. - * - * @param {SyncOptions} syncOptions Which user syncs are allowed? - * @param {ServerResponse[]} serverResponses List of server's responses. - * @param gdprConsent The GDPR consent parameters - * @param uspConsent The USP consent parameters - * @return {UserSync[]} The user syncs which should be dropped. + * Register User Sync. */ - getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { - const syncs = []; + getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => { + let syncurl = ''; + + // Attaching GDPR Consent Params in UserSync url + if (gdprConsent) { + syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); + syncurl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''); + } + + // CCPA + if (uspConsent) { + syncurl += '&us_privacy=' + encodeURIComponent(uspConsent); + } + + // coppa compliance + if (config.getConfig('coppa') === true) { + syncurl += '&coppa=1'; + } + if (syncOptions.iframeEnabled) { - syncs.push({ + return [{ type: 'iframe', - url: USER_SYNC_URL - }); + url: USER_SYNC_URL_IFRAME + syncurl + }]; + } else { + return [{ + type: 'image', + url: USER_SYNC_URL_IMAGE + syncurl + }]; } - return syncs; } } diff --git a/test/spec/modules/zetaSspBidAdapter_spec.js b/test/spec/modules/zetaSspBidAdapter_spec.js index bdfc64c3234..2766632f707 100644 --- a/test/spec/modules/zetaSspBidAdapter_spec.js +++ b/test/spec/modules/zetaSspBidAdapter_spec.js @@ -1,6 +1,6 @@ -import { spec } from '../../../modules/zetaSspBidAdapter.js' +import {spec} from '../../../modules/zetaSspBidAdapter.js' -describe('Zeta Ssp Bid Adapter', function() { +describe('Zeta Ssp Bid Adapter', function () { const bannerRequest = [{ bidId: 12345, auctionId: 67890, @@ -26,7 +26,7 @@ describe('Zeta Ssp Bid Adapter', function() { } }]; - it('Test the bid validation function', function() { + it('Test the bid validation function', function () { const validBid = spec.isBidRequestValid(bannerRequest[0]); const invalidBid = spec.isBidRequestValid(null); @@ -82,4 +82,28 @@ describe('Zeta Ssp Bid Adapter', function() { expect(bid.requestId).to.equal(receivedBid.impid); expect(bid.meta.advertiserDomains).to.equal(receivedBid.adomain); }); + + it('Different cases for user syncs', function () { + const USER_SYNC_URL_IFRAME = 'https://ssp.disqus.com/sync?type=iframe'; + const USER_SYNC_URL_IMAGE = 'https://ssp.disqus.com/sync?type=image'; + + const sync1 = spec.getUserSyncs({iframeEnabled: true})[0]; + expect(sync1.type).to.equal('iframe'); + expect(sync1.url).to.include(USER_SYNC_URL_IFRAME); + + const sync2 = spec.getUserSyncs({iframeEnabled: false})[0]; + expect(sync2.type).to.equal('image'); + expect(sync2.url).to.include(USER_SYNC_URL_IMAGE); + + const sync3 = spec.getUserSyncs({iframeEnabled: true}, {}, {gdprApplies: true})[0]; + expect(sync3.type).to.equal('iframe'); + expect(sync3.url).to.include(USER_SYNC_URL_IFRAME); + expect(sync3.url).to.include('&gdpr='); + + const sync4 = spec.getUserSyncs({iframeEnabled: true}, {}, {gdprApplies: true}, 'test')[0]; + expect(sync4.type).to.equal('iframe'); + expect(sync4.url).to.include(USER_SYNC_URL_IFRAME); + expect(sync4.url).to.include('&gdpr='); + expect(sync4.url).to.include('&us_privacy='); + }); }); From 77ab4ecf1bfe072ef48193372214de571338bcf3 Mon Sep 17 00:00:00 2001 From: matthieularere-msq <63732822+matthieularere-msq@users.noreply.github.com> Date: Thu, 27 May 2021 13:03:23 +0200 Subject: [PATCH 239/303] Mediasquare Bid Adapter: support advertiserDomains (#6843) * Mediasquare Bid Adapter: support advertiserDomains * Update mediasquareBidAdapter.js * add unit tests * fix unit test * fix string single quote --- modules/mediasquareBidAdapter.js | 3 +++ test/spec/modules/mediasquareBidAdapter_spec.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/modules/mediasquareBidAdapter.js b/modules/mediasquareBidAdapter.js index 84783eb0991..a586157bf20 100644 --- a/modules/mediasquareBidAdapter.js +++ b/modules/mediasquareBidAdapter.js @@ -101,6 +101,9 @@ export const spec = { mediasquare: { 'bidder': value['bidder'], 'code': value['code'] + }, + meta: { + 'advertiserDomains': value['adomain'] } }; if ('native' in value) { diff --git a/test/spec/modules/mediasquareBidAdapter_spec.js b/test/spec/modules/mediasquareBidAdapter_spec.js index 796be3420e8..20e5588a99e 100644 --- a/test/spec/modules/mediasquareBidAdapter_spec.js +++ b/test/spec/modules/mediasquareBidAdapter_spec.js @@ -76,6 +76,7 @@ describe('MediaSquare bid adapter tests', function () { 'bidder': 'msqClassic', 'code': 'test/publishername_atf_desktop_rg_pave', 'bid_id': 'aaaa1234', + 'adomain': ['test.com'], }], }}; @@ -135,6 +136,9 @@ describe('MediaSquare bid adapter tests', function () { expect(bid.mediasquare).to.exist; expect(bid.mediasquare.bidder).to.equal('msqClassic'); expect(bid.mediasquare.code).to.equal([DEFAULT_PARAMS[0].params.owner, DEFAULT_PARAMS[0].params.code].join('/')); + expect(bid.meta).to.exist; + expect(bid.meta.advertiserDomains).to.exist; + expect(bid.meta.advertiserDomains).to.have.lengthOf(1); }); it('Verifies bidder code', function () { From 7baf4b08cc79c5cdeab04bd6e0efb34762e17bea Mon Sep 17 00:00:00 2001 From: thuyhq <61451682+thuyhq@users.noreply.github.com> Date: Thu, 27 May 2021 18:40:41 +0700 Subject: [PATCH 240/303] Apacdex Bid Adapter: add support for meta.advertiserDomains, add and update sample adunit, validate dealId field from server response, add support Price Floors Module (#6711) --- modules/apacdexBidAdapter.js | 44 +++++++++++-- modules/apacdexBidAdapter.md | 56 ++++++++++++++-- test/spec/modules/apacdexBidAdapter_spec.js | 73 +++++++++++++++++---- 3 files changed, 153 insertions(+), 20 deletions(-) diff --git a/modules/apacdexBidAdapter.js b/modules/apacdexBidAdapter.js index 62ae3f54125..c0431ddf923 100644 --- a/modules/apacdexBidAdapter.js +++ b/modules/apacdexBidAdapter.js @@ -55,13 +55,13 @@ export const spec = { let eids; let geo; let test; + let bids = []; - var bids = JSON.parse(JSON.stringify(validBidRequests)) - bidderConfig = CONFIG[bids[0].bidder]; + bidderConfig = CONFIG[validBidRequests[0].bidder]; test = config.getConfig('debug'); - bids.forEach(bidReq => { + validBidRequests.forEach(bidReq => { siteId = siteId || bidReq.params.siteId; if (bidReq.schain) { @@ -95,6 +95,13 @@ export const spec = { } bySlotTargetKey[bidReq.adUnitCode] = targetKey; bidReq.targetKey = targetKey; + + let bidFloor = getBidFloor(bidReq); + if (bidFloor) { + bidReq.bidFloor = bidFloor; + } + + bids.push(JSON.parse(JSON.stringify(bidReq))); }); const payload = {}; @@ -169,23 +176,30 @@ export const spec = { const bidResponses = []; serverBids.forEach(bid => { + const dealId = bid.dealId || ''; const bidResponse = { requestId: bid.requestId, cpm: bid.cpm, width: bid.width, height: bid.height, creativeId: bid.creativeId, - dealId: bid.dealId, currency: bid.currency, netRevenue: bid.netRevenue, ttl: bid.ttl, mediaType: bid.mediaType }; + if (dealId.length > 0) { + bidResponse.dealId = dealId; + } if (bid.vastXml) { bidResponse.vastXml = utils.replaceAuctionPrice(bid.vastXml, bid.cpm); } else { bidResponse.ad = utils.replaceAuctionPrice(bid.ad, bid.cpm); } + bidResponse.meta = {}; + if (bid.meta && bid.meta.advertiserDomains && utils.isArray(bid.meta.advertiserDomains)) { + bidResponse.meta.advertiserDomains = bid.meta.advertiserDomains; + } bidResponses.push(bidResponse); }); return bidResponses; @@ -336,4 +350,26 @@ export function validateGeoObject(geo) { return true; } +/** + * Get bid floor from Price Floors Module + * + * @param {Object} bid + * @returns {float||null} + */ +function getBidFloor(bid) { + if (!utils.isFn(bid.getFloor)) { + return (bid.params.floorPrice) ? bid.params.floorPrice : null; + } + + let floor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*' + }); + if (utils.isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') { + return floor.floor; + } + return null; +} + registerBidder(spec); diff --git a/modules/apacdexBidAdapter.md b/modules/apacdexBidAdapter.md index b88190cda94..fa8c727d709 100644 --- a/modules/apacdexBidAdapter.md +++ b/modules/apacdexBidAdapter.md @@ -11,7 +11,7 @@ Maintainer: ken@apacdex.com Connects to APAC Digital Exchange for bids. Apacdex bid adapter supports Banner and Video (Instream and Outstream) ads. -# Test Parameters +# Sample Banner Ad Unit ``` var adUnits = [ { @@ -26,6 +26,7 @@ var adUnits = [ bidder: 'apacdex', params: { siteId: 'apacdex1234', // siteId provided by Apacdex + floorPrice: 0.01, // default is 0.01 if not declared } } ] @@ -33,7 +34,7 @@ var adUnits = [ ]; ``` -# Video Test Parameters +# Sample Video Ad Unit: Instream ``` var videoAdUnit = { code: 'test-div', @@ -41,7 +42,17 @@ var videoAdUnit = { mediaTypes: { video: { playerSize: [[640, 480]], - context: 'instream' + context: "instream" + api: [2], + placement: 1, + skip: 1, + linearity: 1, + minduration: 1, + maxduration: 120, + mimes: ["video/mp4", "video/x-flv", "video/x-ms-wmv", "application/vnd.apple.mpegurl", "application/x-mpegurl", "video/3gpp", "video/mpeg", "video/ogg", "video/quicktime", "video/webm", "video/x-m4v", "video/ms-asf", video/x-msvideo"], + playbackmethod: [6], + startdelay: 0, + protocols: [1, 2, 3, 4, 5, 6] }, }, bids: [ @@ -49,8 +60,45 @@ var videoAdUnit = { bidder: 'apacdex', params: { siteId: 'apacdex1234', // siteId provided by Apacdex + floorPrice: 0.01, // default is 0.01 if not declared } } ] }; -``` \ No newline at end of file +``` +mediaTypes.video object reference to section 3.2.7 Object: Video in the OpenRTB 2.5 document +You must review all video parameters to ensure validity for your player and DSPs + +# Sample Video Ad Unit: Outstream +``` +var videoAdUnit = { + code: 'test-div', + sizes: [[410, 231]], + mediaTypes: { + video: { + playerSize: [[410, 231]], + context: "outstream" + api: [2], + placement: 5, + linearity: 1, + minduration: 1, + maxduration: 120, + mimes: ["video/mp4", "video/x-flv", "video/x-ms-wmv", "application/vnd.apple.mpegurl", "application/x-mpegurl", "video/3gpp", "video/mpeg", "video/ogg", "video/quicktime", "video/webm", "video/x-m4v", "video/ms-asf", video/x-msvideo"], + playbackmethod: [6], + startdelay: 0, + protocols: [1, 2, 3, 4, 5, 6] + }, + }, + bids: [ + { + bidder: 'apacdex', + params: { + siteId: 'apacdex1234', // siteId provided by Apacdex + floorPrice: 0.01, // default is 0.01 if not declared + } + } + ] +}; +``` +mediaTypes.video object reference to section 3.2.7 Object: Video in the OpenRTB 2.5 document +You must review all video parameters to ensure validity for your player and DSPs \ No newline at end of file diff --git a/test/spec/modules/apacdexBidAdapter_spec.js b/test/spec/modules/apacdexBidAdapter_spec.js index 3a71833bc3e..5f6a935c453 100644 --- a/test/spec/modules/apacdexBidAdapter_spec.js +++ b/test/spec/modules/apacdexBidAdapter_spec.js @@ -3,6 +3,7 @@ import { spec, validateGeoObject, getDomain } from '../../../modules/apacdexBidA import { newBidder } from 'src/adapters/bidderFactory.js' import { userSync } from '../../../src/userSync.js'; import { config } from 'src/config.js'; +import { deepClone } from 'src/utils.js'; describe('ApacdexBidAdapter', function () { const adapter = newBidder(spec) @@ -200,7 +201,7 @@ describe('ApacdexBidAdapter', function () { 'bidder': 'apacdex', 'params': { 'siteId': '1a2b3c4d5e6f1a2b3c4d', - 'geo': {'lat': 123.13123456, 'lon': 54.23467311, 'accuracy': 60} + 'geo': { 'lat': 123.13123456, 'lon': 54.23467311, 'accuracy': 60 } }, 'adUnitCode': 'adunit-code-1', 'sizes': [[300, 250], [300, 600]], @@ -336,12 +337,50 @@ describe('ApacdexBidAdapter', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests); expect(bidRequests.data.us_privacy).to.equal('someCCPAString'); }); - describe('debug test', function() { - beforeEach(function() { - config.setConfig({debug: true}); + it('should attach bidFloor param when either bid param floorPrice or getFloor function exists', function () { + let getFloorResponse = { currency: 'USD', floor: 3 }; + let singleBidRequest, request, payload = null; + + // 1 -> floorPrice not defined, getFloor not defined > empty + singleBidRequest = deepClone(bidRequest[0]); + request = spec.buildRequests([singleBidRequest], bidderRequests); + payload = request.data; + expect(payload.bids[0].bidFloor).to.not.exist; + + // 2 -> floorPrice is defined, getFloor not defined > floorPrice is used + singleBidRequest = deepClone(bidRequest[0]); + singleBidRequest.params = { + 'siteId': '1890909', + 'floorPrice': 0.5 + }; + request = spec.buildRequests([singleBidRequest], bidderRequests); + payload = request.data + expect(payload.bids[0].bidFloor).to.exist.and.to.equal(0.5); + + // 3 -> floorPrice is defined, getFloor is defined > getFloor is used + singleBidRequest = deepClone(bidRequest[0]); + singleBidRequest.params = { + 'siteId': '1890909', + 'floorPrice': 0.5 + }; + singleBidRequest.getFloor = () => getFloorResponse; + request = spec.buildRequests([singleBidRequest], bidderRequests); + payload = request.data + expect(payload.bids[0].bidFloor).to.exist.and.to.equal(3); + + // 4 -> floorPrice not defined, getFloor is defined > getFloor is used + singleBidRequest = deepClone(bidRequest[0]); + singleBidRequest.getFloor = () => getFloorResponse; + request = spec.buildRequests([singleBidRequest], bidderRequests); + payload = request.data + expect(payload.bids[0].bidFloor).to.exist.and.to.equal(3); + }); + describe('debug test', function () { + beforeEach(function () { + config.setConfig({ debug: true }); }); - afterEach(function() { - config.setConfig({debug: false}); + afterEach(function () { + config.setConfig({ debug: false }); }); it('should return a properly formatted request with pbjs_debug is true', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests); @@ -514,7 +553,10 @@ describe('ApacdexBidAdapter', function () { 'netRevenue': true, 'currency': 'USD', 'dealId': 'apacdex', - 'mediaType': 'banner' + 'mediaType': 'banner', + 'meta': { + 'advertiserDomains': ['https://example.com'] + } }, { 'requestId': '30024615be22ef66a', @@ -527,7 +569,10 @@ describe('ApacdexBidAdapter', function () { 'netRevenue': true, 'currency': 'USD', 'dealId': 'apacdex', - 'mediaType': 'banner' + 'mediaType': 'banner', + 'meta': { + 'advertiserDomains': ['https://example.com'] + } }, { 'requestId': '1854b40107d6745c', @@ -540,7 +585,10 @@ describe('ApacdexBidAdapter', function () { 'netRevenue': true, 'currency': 'USD', 'dealId': 'apacdex', - 'mediaType': 'video' + 'mediaType': 'video', + 'meta': { + 'advertiserDomains': ['https://example.com'] + } } ], 'pixel': [{ @@ -610,6 +658,7 @@ describe('ApacdexBidAdapter', function () { if (resp.mediaType === 'banner') { expect(resp.ad.indexOf('Apacdex AD')).to.be.greaterThan(0); } + expect(resp.meta.advertiserDomains).to.deep.equal(['https://example.com']); }); }); }); @@ -693,17 +742,17 @@ describe('ApacdexBidAdapter', function () { describe('getDomain', function () { it('should return valid domain from publisherDomain config', () => { let pageUrl = 'https://www.example.com/page/prebid/exam.html'; - config.setConfig({publisherDomain: pageUrl}); + config.setConfig({ publisherDomain: pageUrl }); expect(getDomain(pageUrl)).to.equal('example.com'); }); it('should return valid domain from pageUrl argument', () => { let pageUrl = 'https://www.example.com/page/prebid/exam.html'; - config.setConfig({publisherDomain: ''}); + config.setConfig({ publisherDomain: '' }); expect(getDomain(pageUrl)).to.equal('example.com'); }); it('should return undefined if pageUrl and publisherDomain not config', () => { let pageUrl; - config.setConfig({publisherDomain: ''}); + config.setConfig({ publisherDomain: '' }); expect(getDomain(pageUrl)).to.equal(pageUrl); }); }); From a5e7d08950f33301372942a64333522474285895 Mon Sep 17 00:00:00 2001 From: rcheptanariu <35690143+rcheptanariu@users.noreply.github.com> Date: Thu, 27 May 2021 16:07:36 +0300 Subject: [PATCH 241/303] Invibes Bid Adapter - support for meta taxonomy (#6849) --- modules/invibesBidAdapter.js | 19 ++++++++++++-- test/spec/modules/invibesBidAdapter_spec.js | 29 ++++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/modules/invibesBidAdapter.js b/modules/invibesBidAdapter.js index 7d2942eea55..18011359a6d 100644 --- a/modules/invibesBidAdapter.js +++ b/modules/invibesBidAdapter.js @@ -11,7 +11,8 @@ const CONSTANTS = { PREBID_VERSION: 6, METHOD: 'GET', INVIBES_VENDOR_ID: 436, - USERID_PROVIDERS: ['pubcid', 'pubProvidedId', 'uid2', 'zeotapIdPlus', 'id5id'] + USERID_PROVIDERS: ['pubcid', 'pubProvidedId', 'uid2', 'zeotapIdPlus', 'id5id'], + META_TAXONOMY: ['networkId', 'networkName', 'agencyId', 'agencyName', 'advertiserId', 'advertiserName', 'advertiserDomains', 'brandId', 'brandName', 'primaryCatId', 'secondaryCatIds', 'mediaType'] }; const storage = getStorageManager(CONSTANTS.INVIBES_VENDOR_ID); @@ -236,10 +237,24 @@ function createBid(bidRequest, requestPlacement) { currency: bidModel.Currency || CONSTANTS.DEFAULT_CURRENCY, netRevenue: true, ttl: CONSTANTS.TIME_TO_LIVE, - ad: renderCreative(bidModel) + ad: renderCreative(bidModel), + meta: addMeta(bidModel.Meta) }; } +function addMeta(bidModelMeta) { + var meta = {}; + if (bidModelMeta != null) { + for (let i = 0; i < CONSTANTS.META_TAXONOMY.length; i++) { + if (bidModelMeta.hasOwnProperty(CONSTANTS.META_TAXONOMY[i])) { + meta[CONSTANTS.META_TAXONOMY[i]] = bidModelMeta[CONSTANTS.META_TAXONOMY[i]]; + } + } + } + + return meta; +} + function generateRandomId() { return (Math.round(Math.random() * 1e12)).toString(36).substring(0, 10); } diff --git a/test/spec/modules/invibesBidAdapter_spec.js b/test/spec/modules/invibesBidAdapter_spec.js index 6a59bf98dad..ea3e1d6611b 100644 --- a/test/spec/modules/invibesBidAdapter_spec.js +++ b/test/spec/modules/invibesBidAdapter_spec.js @@ -733,7 +733,8 @@ describe('invibesBidAdapter:', function () { - ` + `, + meta: {} }]; let multiResponse = { @@ -760,6 +761,23 @@ describe('invibesBidAdapter:', function () { }] }; + let responseWithMeta = { + Ads: [{ + BidPrice: 0.5, + VideoExposedId: 123 + }], + BidModel: { + BidVersion: 1, + PlacementId: '12345', + AuctionStartTime: Date.now(), + CreativeHtml: '', + Meta: { + advertiserDomains: ['theadvertiser.com', 'theadvertiser_2.com'], + advertiserName: 'theadvertiser' + } + } + }; + context('when the response is not valid', function () { it('handles response with no bids requested', function () { let emptyResult = spec.interpretResponse({body: response}); @@ -829,6 +847,15 @@ describe('invibesBidAdapter:', function () { expect(secondResult).to.be.empty; }); }); + + context('when the response has meta', function () { + it('responds with a valid bid, with the meta info', function () { + let result = spec.interpretResponse({body: responseWithMeta}, {bidRequests}); + expect(result[0].meta.advertiserName).to.equal('theadvertiser'); + expect(result[0].meta.advertiserDomains).to.contain('theadvertiser.com'); + expect(result[0].meta.advertiserDomains).to.contain('theadvertiser_2.com'); + }); + }); }); describe('getUserSyncs', function () { From 399292da7f9c7c11531be6cc05efe72b8f7a823f Mon Sep 17 00:00:00 2001 From: nyakove <43004249+nyakove@users.noreply.github.com> Date: Thu, 27 May 2021 16:57:07 +0300 Subject: [PATCH 242/303] adWMG Adapter: add 'adomain' support (#6852) * Support floorCPM parameter, fix some minor bugs * fix space-in-parens circleci error * example fix * clean usersync URL * spaces * spaces * add new unit tests, compatibility with IE11 * remove logInfo * Check for floorCPM value * Check params before sending * New endpoints * code format * new endpoint for cookie sync * update tests * Add meta.advertiserDomains data support * Add meta.advertiserDomains data support Co-authored-by: Mikhail Dykun --- modules/adWMGBidAdapter.js | 4 ++++ test/spec/modules/adWMGBidAdapter_spec.js | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/adWMGBidAdapter.js b/modules/adWMGBidAdapter.js index 689e7d02124..a3d78a69d91 100644 --- a/modules/adWMGBidAdapter.js +++ b/modules/adWMGBidAdapter.js @@ -116,6 +116,10 @@ export const spec = { netRevenue: response.netRevenue, ttl: response.ttl, ad: response.ad, + meta: { + advertiserDomains: response.adomain && response.adomain.length ? response.adomain : [], + mediaType: 'banner' + } }; bidResponses.push(bidResponse); } diff --git a/test/spec/modules/adWMGBidAdapter_spec.js b/test/spec/modules/adWMGBidAdapter_spec.js index 8b927ace84c..db536ca14e2 100644 --- a/test/spec/modules/adWMGBidAdapter_spec.js +++ b/test/spec/modules/adWMGBidAdapter_spec.js @@ -209,7 +209,8 @@ describe('adWMGBidAdapter', function () { 'ttl': 300, 'creativeId': 'creative-id', 'netRevenue': true, - 'currency': 'USD' + 'currency': 'USD', + 'adomain': ['testdomain.com'] } }; }); @@ -219,7 +220,7 @@ describe('adWMGBidAdapter', function () { expect(responses).to.be.an('array').that.is.not.empty; let response = responses[0]; - expect(response).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + expect(response).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'meta', 'ad', 'ttl', 'creativeId', 'netRevenue', 'currency'); expect(response.requestId).to.equal('request-id'); expect(response.cpm).to.equal(100); @@ -230,6 +231,8 @@ describe('adWMGBidAdapter', function () { expect(response.creativeId).to.equal('creative-id'); expect(response.netRevenue).to.be.true; expect(response.currency).to.equal('USD'); + expect(response.meta.advertiserDomains[0]).to.equal('testdomain.com'); + expect(response.meta.mediaType).to.equal('banner'); }); it('should return an empty array when serverResponse is empty', () => { From 0523a1daa9cf66a8a4df513e8a07b1d94428c8a3 Mon Sep 17 00:00:00 2001 From: ardit-baloku <77985953+ardit-baloku@users.noreply.github.com> Date: Thu, 27 May 2021 16:01:34 +0200 Subject: [PATCH 243/303] Added meta.advertiserDomains to bidResponse (#6853) --- modules/gjirafaBidAdapter.js | 5 ++++- test/spec/modules/gjirafaBidAdapter_spec.js | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/gjirafaBidAdapter.js b/modules/gjirafaBidAdapter.js index 77589cd9071..df33369d6ad 100644 --- a/modules/gjirafaBidAdapter.js +++ b/modules/gjirafaBidAdapter.js @@ -95,7 +95,10 @@ export const spec = { referrer: responses[i].Referrer, ad: responses[i].Ad, vastUrl: responses[i].VastUrl, - mediaType: responses[i].MediaType + mediaType: responses[i].MediaType, + meta: { + advertiserDomains: Array.isArray(responses[i].ADomain) ? responses[i].ADomain : [] + } }; bidResponses.push(bidResponse); } diff --git a/test/spec/modules/gjirafaBidAdapter_spec.js b/test/spec/modules/gjirafaBidAdapter_spec.js index f0fb01f4398..96bf319dfd2 100644 --- a/test/spec/modules/gjirafaBidAdapter_spec.js +++ b/test/spec/modules/gjirafaBidAdapter_spec.js @@ -136,7 +136,8 @@ describe('gjirafaAdapterTest', () => { 'CreativeId': '123abc', 'NetRevenue': false, 'Currency': 'EUR', - 'TTL': 360 + 'TTL': 360, + 'ADomain': ['somedomain.com'] }], headers: {} }; @@ -156,7 +157,8 @@ describe('gjirafaAdapterTest', () => { 'referrer', 'ad', 'vastUrl', - 'mediaType' + 'mediaType', + 'meta' ]; let resultKeys = Object.keys(result[0]); @@ -164,5 +166,20 @@ describe('gjirafaAdapterTest', () => { expect(keys.indexOf(key) !== -1).to.equal(true); }); }) + + it('all values correct', () => { + const result = spec.interpretResponse(bidResponse, bidRequest); + + expect(result[0].cpm).to.equal(1); + expect(result[0].width).to.equal(728); + expect(result[0].height).to.equal(90); + expect(result[0].creativeId).to.equal('123abc'); + expect(result[0].currency).to.equal('EUR'); + expect(result[0].netRevenue).to.equal(false); + expect(result[0].ttl).to.equal(360); + expect(result[0].referrer).to.equal('http://localhost:9999/integrationExamples/gpt/hello_world.html?pbjs_debug=true'); + expect(result[0].ad).to.equal('
Test ad
'); + expect(result[0].meta.advertiserDomains).to.deep.equal(['somedomain.com']); + }) }); }); From f02c1fe37c6935dc2b3d9cef292eb8633ffb4679 Mon Sep 17 00:00:00 2001 From: ardit-baloku <77985953+ardit-baloku@users.noreply.github.com> Date: Thu, 27 May 2021 16:21:26 +0200 Subject: [PATCH 244/303] Added meta.advertiserDomains to bidResponse (#6854) --- modules/malltvBidAdapter.js | 5 ++++- test/spec/modules/malltvBidAdapter_spec.js | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/malltvBidAdapter.js b/modules/malltvBidAdapter.js index 7deffe6c07a..4e600135e0b 100644 --- a/modules/malltvBidAdapter.js +++ b/modules/malltvBidAdapter.js @@ -95,7 +95,10 @@ export const spec = { referrer: responses[i].Referrer, ad: responses[i].Ad, vastUrl: responses[i].VastUrl, - mediaType: responses[i].MediaType + mediaType: responses[i].MediaType, + meta: { + advertiserDomains: Array.isArray(responses[i].ADomain) ? responses[i].ADomain : [] + } }; bidResponses.push(bidResponse); } diff --git a/test/spec/modules/malltvBidAdapter_spec.js b/test/spec/modules/malltvBidAdapter_spec.js index ffe08ad1a5e..c31e91992f7 100644 --- a/test/spec/modules/malltvBidAdapter_spec.js +++ b/test/spec/modules/malltvBidAdapter_spec.js @@ -136,7 +136,8 @@ describe('malltvAdapterTest', () => { 'CreativeId': '123abc', 'NetRevenue': false, 'Currency': 'EUR', - 'TTL': 360 + 'TTL': 360, + 'ADomain': ['somedomain.com'] }], headers: {} }; @@ -156,7 +157,8 @@ describe('malltvAdapterTest', () => { 'referrer', 'ad', 'vastUrl', - 'mediaType' + 'mediaType', + 'meta' ]; let resultKeys = Object.keys(result[0]); @@ -164,5 +166,20 @@ describe('malltvAdapterTest', () => { expect(keys.indexOf(key) !== -1).to.equal(true); }); }) + + it('all values correct', () => { + const result = spec.interpretResponse(bidResponse, bidRequest); + + expect(result[0].cpm).to.equal(1); + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(250); + expect(result[0].creativeId).to.equal('123abc'); + expect(result[0].currency).to.equal('EUR'); + expect(result[0].netRevenue).to.equal(false); + expect(result[0].ttl).to.equal(360); + expect(result[0].referrer).to.equal('http://localhost:9999/integrationExamples/gpt/hello_world.html?pbjs_debug=true'); + expect(result[0].ad).to.equal('
Test ad
'); + expect(result[0].meta.advertiserDomains).to.deep.equal(['somedomain.com']); + }) }); }); From d237cbffc88d822a03bd4d23e475aba1960814ac Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Thu, 27 May 2021 07:39:30 -0700 Subject: [PATCH 245/303] LGTM Fixes: fixes for current LGTM issues (#6851) --- integrationExamples/gpt/idImportLibrary_example.html | 1 + modules/aolBidAdapter.js | 2 +- modules/datablocksBidAdapter.js | 6 +++--- modules/gridBidAdapter.js | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/integrationExamples/gpt/idImportLibrary_example.html b/integrationExamples/gpt/idImportLibrary_example.html index a3ef3f168c0..f35b571e8f9 100644 --- a/integrationExamples/gpt/idImportLibrary_example.html +++ b/integrationExamples/gpt/idImportLibrary_example.html @@ -47,6 +47,7 @@ params: { pid: '14', // Set your real identityLink placement ID here // notUse3P: true // true/false - If you do not want to use 3P endpoint to retrieve envelope. If you do not set this property to true, 3p endpoint will be fired. By default this propertt is undefined and 3p request will be fired.}, + }, storage: { type: 'html5', name: 'idl_env', diff --git a/modules/aolBidAdapter.js b/modules/aolBidAdapter.js index 14b529f4973..03e4ac9021a 100644 --- a/modules/aolBidAdapter.js +++ b/modules/aolBidAdapter.js @@ -366,7 +366,7 @@ export const spec = { let tagName = item.match(tagNameRegExp)[0]; let url = item.match(srcRegExp)[2]; - if (tagName && tagName) { + if (tagName && url) { pixelsItems.push({ type: tagName === SYNC_TYPES.IMAGE.TAG ? SYNC_TYPES.IMAGE.TYPE : SYNC_TYPES.IFRAME.TYPE, url: url diff --git a/modules/datablocksBidAdapter.js b/modules/datablocksBidAdapter.js index b00a3eae659..47d2eb2652f 100644 --- a/modules/datablocksBidAdapter.js +++ b/modules/datablocksBidAdapter.js @@ -68,7 +68,7 @@ export const spec = { id: bidRequest.bidId, tagid: bidRequest.adUnitCode, secure: window.location.protocol == 'https:' - } + }; if (utils.deepAccess(bidRequest, `mediaTypes.banner`)) { let sizes = bidRequest.mediaTypes.banner.sizes; @@ -76,7 +76,7 @@ export const spec = { imp.banner = { w: sizes[0][0], h: sizes[0][1] - } + }; } else if (sizes.length > 1) { imp.banner = { format: sizes.map(size => ({ w: size[0], h: size[1] })) @@ -181,7 +181,7 @@ export const spec = { if (VIDEO_PARAMS.indexOf(k) > -1) { imp.video[k] = bidRequest.params.video[k]; } - }) + }); } } let host = bidRequest.params.host; diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js index 955aeff7168..dbeba27d836 100644 --- a/modules/gridBidAdapter.js +++ b/modules/gridBidAdapter.js @@ -350,7 +350,7 @@ function _addBidResponse(serverBid, bidRequest, bidResponses) { netRevenue: false, ttl: TIME_TO_LIVE, meta: { - advertiserDomains: serverBid && serverBid.adomain ? serverBid.adomain : [] + advertiserDomains: serverBid.adomain ? serverBid.adomain : [] }, dealId: serverBid.dealid }; From 54bdd70426fb6ff5c2d4c22b1696a02b7d8ba16e Mon Sep 17 00:00:00 2001 From: wojciech-bialy-wpm <67895844+wojciech-bialy-wpm@users.noreply.github.com> Date: Thu, 27 May 2021 17:14:10 +0200 Subject: [PATCH 246/303] sspBC Bid Adapter: add bidfloor to imp and other updates to bid adapter (#6820) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update tests for sspBC adapter Update tests for sspBC adapter: - change userSync test (due to tcf param appended in v4.6) - add tests for onBidWon and onTimeout * [sspbc-adapter] Update to v4.8 (floorprices, usersync, code cleaning) * [sspbc-adapter] remove bidloor param from md. Remove unused test for old module (sspBCAdapter) Co-authored-by: Wojciech Biały --- modules/sspBCBidAdapter.js | 84 +++++++++++++++++++------------------- modules/sspBCBidAdapter.md | 1 - 2 files changed, 41 insertions(+), 44 deletions(-) diff --git a/modules/sspBCBidAdapter.js b/modules/sspBCBidAdapter.js index 391f3a05721..d166a01a1da 100644 --- a/modules/sspBCBidAdapter.js +++ b/modules/sspBCBidAdapter.js @@ -9,7 +9,7 @@ const BIDDER_URL = 'https://ssp.wp.pl/bidder/'; const SYNC_URL = 'https://ssp.wp.pl/bidder/usersync'; const NOTIFY_URL = 'https://ssp.wp.pl/bidder/notify'; const TMAX = 450; -const BIDDER_VERSION = '4.8'; +const BIDDER_VERSION = '4.9'; const W = window; const { navigator } = W; const oneCodeDetection = {}; @@ -102,25 +102,29 @@ const applyClientHints = ortbRequest => { ortbRequest.user = Object.assign(ortbRequest.user, { data }); }; -function applyGdpr(bidderRequest, ortbRequest) { - if (bidderRequest && bidderRequest.gdprConsent) { - consentApiVersion = bidderRequest.gdprConsent.apiVersion; - ortbRequest.regs = Object.assign(ortbRequest.regs, { '[ortb_extensions.gdpr]': bidderRequest.gdprConsent.gdprApplies ? 1 : 0 }); - ortbRequest.user = Object.assign(ortbRequest.user, { '[ortb_extensions.consent]': bidderRequest.gdprConsent.consentString }); +/** + * Add GDPR data to oRTB request + * Store conset API version (will be required by user sync) + */ +const applyGdpr = (bidderRequest, ortbRequest) => { + const { gdprConsent } = bidderRequest; + if (gdprConsent) { + const { apiVersion, gdprApplies, consentString } = gdprConsent; + consentApiVersion = apiVersion; + ortbRequest.regs = Object.assign(ortbRequest.regs, { '[ortb_extensions.gdpr]': gdprApplies ? 1 : 0 }); + ortbRequest.user = Object.assign(ortbRequest.user, { '[ortb_extensions.consent]': consentString }); } } -function setOnAny(collection, key) { - for (let i = 0, result; i < collection.length; i++) { - result = utils.deepAccess(collection[i], key); - - if (result) { - return result; - } - } -} +/** + * Get value for first occurence of key within the collection + */ +const setOnAny = (collection, key) => collection.reduce((prev, next) => prev || utils.deepAccess(next, key), false); -function sendNotification(payload) { +/** + * Send payload to notification endpoint + */ +const sendNotification = payload => { ajax(NOTIFY_URL, null, JSON.stringify(payload), { withCredentials: false, method: 'POST', @@ -132,7 +136,7 @@ function sendNotification(payload) { * @param {object} slot Ad Unit Params by Prebid * @returns {object} Banner by OpenRTB 2.5 §3.2.6 */ -function mapBanner(slot) { +const mapBanner = slot => { if (slot.mediaType === 'banner' || utils.deepAccess(slot, 'mediaTypes.banner') || (!slot.mediaType && !slot.mediaTypes)) { @@ -141,8 +145,6 @@ function mapBanner(slot) { h: size[1], })); - // override - tylko 1szy wymiar - // format = format.slice(0, 1); return { format, id: slot.bidId, @@ -150,7 +152,7 @@ function mapBanner(slot) { } } -function mapImpression(slot) { +const mapImpression = slot => { const { adUnitCode, bidId, params } = slot; const { id, siteId } = params || {}; const imp = { @@ -160,16 +162,18 @@ function mapImpression(slot) { tagid: adUnitCode, }; - const bidfloor = (slot.params && slot.params.bidFloor) ? parseFloat(slot.params.bidFloor) : undefined; - - if (bidfloor) { - imp.bidfloor = bidfloor; + // Check floorprices for this imp + if (typeof slot.getFloor === 'function') { + // sspBC adapter accepts only floor per imp - check for maximum value for requested ad sizes + imp.bidfloor = slot.sizes.reduce((prev, next) => { + const currentFloor = slot.getFloor({ mediaType: 'banner', size: next }).floor; + return prev > currentFloor ? prev : currentFloor; + }, 0); } - return imp; } -function renderCreative(site, auctionId, bid, seat, request) { +const renderCreative = (site, auctionId, bid, seat, request) => { let gam; const mcad = { @@ -292,7 +296,7 @@ const spec = { return { method: 'POST', - url: BIDDER_URL + '?cs=' + cookieSupport() + '&bdver=' + BIDDER_VERSION + '&pbver=' + pbver + '&inver=0', + url: `${BIDDER_URL}?cs=${cookieSupport()}&bdver=${BIDDER_VERSION}&pbver=${pbver}&inver=0`, data: JSON.stringify(payload), bidderRequest, }; @@ -315,11 +319,11 @@ const spec = { seat = seatbid.seat; seatbid.bid.forEach(serverBid => { // get data from bid response - const { adomain, crid, impid, exp, ext, price, w, h } = serverBid; + const { adomain, crid = `mcad_${bidderRequest.auctionId}_${site.slot}`, impid, exp = 300, ext, price, w, h } = serverBid; const bidRequest = bidderRequest.bids.filter(b => { - const { bidId, params } = b; - const { id, siteId } = params || {}; + const { bidId, params = {} } = b; + const { id, siteId } = params; const currentBidId = id && siteId ? id : 'bidid-' + bidId; return currentBidId === impid; })[0]; @@ -348,10 +352,10 @@ const spec = { const bid = { requestId: bidId, - creativeId: crid || 'mcad_' + bidderRequest.auctionId + '_' + site.slot, + creativeId: crid, cpm: price, currency: response.cur, - ttl: exp || 300, + ttl: exp, width: w, height: h, bidderCode: BIDDER_CODE, @@ -365,14 +369,7 @@ const spec = { }; if (bid.cpm > 0) { - // check bidFloor (if present in params) - const { bidFloor } = params || {}; - - if (!bidFloor || bid.cpm >= bidFloor) { - bids.push(bid); - } else { - utils.logWarn('Discarding bid due to bidFloor setting', bid.cpm, bidFloor); - } + bids.push(bid); } } else { utils.logWarn('Discarding response - no matching request / site id', serverBid.impid); @@ -384,13 +381,14 @@ const spec = { return bids; }, getUserSyncs(syncOptions) { - if (syncOptions.iframeEnabled) { + if (syncOptions.iframeEnabled && consentApiVersion != 1) { return [{ type: 'iframe', - url: SYNC_URL + '?tcf=' + consentApiVersion, + url: `${SYNC_URL}?tcf=${consentApiVersion}`, }]; + } else { + utils.logWarn('sspBC adapter requires iframe based user sync.'); } - utils.logWarn('sspBC adapter requires iframe based user sync.'); }, onTimeout(timeoutData) { diff --git a/modules/sspBCBidAdapter.md b/modules/sspBCBidAdapter.md index f22e8e6c458..1678f3be594 100644 --- a/modules/sspBCBidAdapter.md +++ b/modules/sspBCBidAdapter.md @@ -20,7 +20,6 @@ Optional parameters: - domain - page - tmax -- bidFloor - test # Test Parameters From bcd1ebe079c40354a33b9496aa1edcce8f0f9681 Mon Sep 17 00:00:00 2001 From: Scott Menzer Date: Thu, 27 May 2021 17:19:37 +0200 Subject: [PATCH 247/303] user id module - force calls to getId if there was previously no consent data stored (#6760) --- modules/userId/index.js | 11 ++++++----- test/spec/modules/userId_spec.js | 15 ++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/userId/index.js b/modules/userId/index.js index 199934f4cdb..3f235d15dd1 100644 --- a/modules/userId/index.js +++ b/modules/userId/index.js @@ -277,6 +277,7 @@ function makeStoredConsentDataHash(consentData) { storedConsentData.gdprApplies = consentData.gdprApplies; storedConsentData.apiVersion = consentData.apiVersion; } + return utils.cyrb53Hash(JSON.stringify(storedConsentData)); } @@ -306,17 +307,17 @@ function getStoredConsentData() { } /** - * test if the consent object stored locally matches the current consent data. - * if there is nothing in storage, return true and we'll do an actual comparison next time. - * this way, we don't force a refresh for every user when this code rolls out + * test if the consent object stored locally matches the current consent data. if they + * don't match or there is nothing stored locally, it means a refresh of the user id + * submodule is needed * @param storedConsentData * @param consentData * @returns {boolean} */ function storedConsentDataMatchesConsentData(storedConsentData, consentData) { return ( - typeof storedConsentData === 'undefined' || - storedConsentData === null || + typeof storedConsentData !== 'undefined' && + storedConsentData !== null && storedConsentData === makeStoredConsentDataHash(consentData) ); } diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 95bba079fa2..420d2ddce91 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -234,9 +234,10 @@ describe('User ID', function () { }); }); }); - // Because the cookie exists already, there should be no setCookie call by default; the only setCookie call is - // to store consent data - expect(coreStorage.setCookie.callCount).to.equal(1); + // Because the consent cookie doesn't exist yet, we'll have two setCookie calls: + // 1) for the consent cookie + // 2) from the getId() call that results in a new call to store the results + expect(coreStorage.setCookie.callCount).to.equal(2); }); it('Extend cookie', function () { @@ -2407,7 +2408,7 @@ describe('User ID', function () { }); // check MockId data was copied to bid expect(bid).to.have.deep.nested.property('userId.mid'); - expect(bid.userId.mid).to.equal('123456778'); + expect(bid.userId.mid).to.equal('1234'); // also check that intentIqId id data was copied to bid expect(bid).to.have.deep.nested.property('userId.intentIqId'); expect(bid.userId.intentIqId).to.equal('testintentIqId'); @@ -2785,7 +2786,7 @@ describe('User ID', function () { sharedAfterFunction(); }); - it('does not call getId if no stored consent data and refresh is not needed', function () { + it('calls getId if no stored consent data and refresh is not needed', function () { coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); @@ -2796,9 +2797,9 @@ describe('User ID', function () { innerAdUnits = config.adUnits }, {adUnits}); - sinon.assert.notCalled(mockGetId); + sinon.assert.calledOnce(mockGetId); sinon.assert.calledOnce(mockDecode); - sinon.assert.calledOnce(mockExtendId); + sinon.assert.notCalled(mockExtendId); }); it('calls getId if no stored consent data but refresh is needed', function () { From 649ea9917df275906d10936b1d5e6fa1db53c562 Mon Sep 17 00:00:00 2001 From: Scott Menzer Date: Thu, 27 May 2021 20:58:03 +0200 Subject: [PATCH 248/303] Prebid 4.41.0 Release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 66f1976d4ce..d4c6cd24181 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.41.0-pre", + "version": "4.41.0", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From f2befaab4211240897413082724fe6958984af53 Mon Sep 17 00:00:00 2001 From: Steffen Anders Date: Thu, 27 May 2021 22:06:05 +0200 Subject: [PATCH 249/303] Optimized AdUp Technology bid adapter (#6800) --- modules/aduptechBidAdapter.js | 374 ++++++--- modules/aduptechBidAdapter.md | 87 ++- test/spec/modules/aduptechBidAdapter_spec.js | 780 +++++++++++-------- 3 files changed, 780 insertions(+), 461 deletions(-) diff --git a/modules/aduptechBidAdapter.js b/modules/aduptechBidAdapter.js index d5b348ee29b..b70f7cf3ce6 100644 --- a/modules/aduptechBidAdapter.js +++ b/modules/aduptechBidAdapter.js @@ -1,20 +1,169 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js' +import { config } from '../src/config.js'; +import { BANNER, NATIVE } from '../src/mediaTypes.js' import * as utils from '../src/utils.js'; export const BIDDER_CODE = 'aduptech'; -export const PUBLISHER_PLACEHOLDER = '{PUBLISHER}'; -export const ENDPOINT_URL = 'https://rtb.d.adup-tech.com/prebid/' + PUBLISHER_PLACEHOLDER + '_bid'; +export const ENDPOINT_URL_PUBLISHER_PLACEHOLDER = '{PUBLISHER}'; +export const ENDPOINT_URL = 'https://rtb.d.adup-tech.com/prebid/' + ENDPOINT_URL_PUBLISHER_PLACEHOLDER + '_bid'; export const ENDPOINT_METHOD = 'POST'; +/** + * Internal utitlity functions + */ +export const internal = { + + /** + * Extracts the GDPR information from given bidderRequest + * + * @param {BidderRequest} bidderRequest + * @returns {null|Object.} + */ + extractGdpr: (bidderRequest) => { + if (bidderRequest && bidderRequest.gdprConsent) { + return { + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : true + }; + } + + return null; + }, + + /** + * Extracts the pageUrl from given bidderRequest.refererInfo or gobal "pageUrl" config or from (top) window location + * + * @param {BidderRequest} bidderRequest + * @returns {string} + */ + extractPageUrl: (bidderRequest) => { + if (bidderRequest && utils.deepAccess(bidderRequest, 'refererInfo.canonicalUrl')) { + return bidderRequest.refererInfo.canonicalUrl; + } + + if (config && config.getConfig('pageUrl')) { + return config.getConfig('pageUrl'); + } + + try { + return utils.getWindowTop().location.href; + } catch (e) { + return utils.getWindowSelf().location.href; + } + }, + + /** + * Extracts the referrer based on given bidderRequest.refererInfo or from (top) document referrer + * + * @param {BidderRequest} bidderRequest + * @returns {string} + */ + extractReferrer: (bidderRequest) => { + if (bidderRequest && utils.deepAccess(bidderRequest, 'refererInfo.referer')) { + return bidderRequest.refererInfo.referer; + } + + try { + return utils.getWindowTop().document.referrer; + } catch (e) { + return utils.getWindowSelf().document.referrer; + } + }, + + /** + * Extracts banner config from given bidRequest + * + * @param {BidRequest} bidRequest + * @returns {null|Object.} + */ + extractBannerConfig: (bidRequest) => { + const sizes = utils.getAdUnitSizes(bidRequest); + if (Array.isArray(sizes) && sizes.length > 0) { + return { sizes: sizes }; + } + + return null; + }, + + /** + * Extracts native config from given bidRequest + * + * @param {BidRequest} bidRequest + * @returns {null|Object.} + */ + extractNativeConfig: (bidRequest) => { + if (bidRequest && utils.deepAccess(bidRequest, 'mediaTypes.native')) { + return bidRequest.mediaTypes.native; + } + + return null; + }, + + /** + * Extracts the bidder params from given bidRequest + * + * @param {BidRequest} bidRequest + * @returns {null|Object.} + */ + extractParams: (bidRequest) => { + if (bidRequest && bidRequest.params) { + return bidRequest.params + } + + return null; + }, + + /** + * Group given array of bidRequests by params.publisher + * + * @param {BidRequest[]} bidRequests + * @returns {Object.} + */ + groupBidRequestsByPublisher: (bidRequests) => { + const groupedBidRequests = {}; + + if (!bidRequests || bidRequests.length === 0) { + return groupedBidRequests; + } + + bidRequests.forEach((bidRequest) => { + const publisher = internal.extractParams(bidRequest).publisher; + if (!publisher) { + return; + } + + if (!groupedBidRequests[publisher]) { + groupedBidRequests[publisher] = []; + } + + groupedBidRequests[publisher].push(bidRequest); + }); + + return groupedBidRequests; + }, + + /** + * Build ednpoint url based on given publisher code + * + * @param {string} publisher + * @returns {string} + */ + buildEndpointUrl: (publisher) => { + return ENDPOINT_URL.replace(ENDPOINT_URL_PUBLISHER_PLACEHOLDER, encodeURIComponent(publisher)); + }, +} + +/** + * The bid adapter definition + */ export const spec = { code: BIDDER_CODE, - supportedMediaTypes: [BANNER], + supportedMediaTypes: [BANNER, NATIVE], /** * Validate given bid request * - * @param {*} bidRequest + * @param {BidRequest[]} bidRequest * @returns {boolean} */ isBidRequestValid: (bidRequest) => { @@ -22,12 +171,13 @@ export const spec = { return false; } - const sizes = extractSizesFromBidRequest(bidRequest); - if (!sizes || sizes.length === 0) { + // banner or native config has to be set + if (!internal.extractBannerConfig(bidRequest) && !internal.extractNativeConfig(bidRequest)) { return false; } - const params = extractParamsFromBidRequest(bidRequest); + // publisher and placement param has to be set + const params = internal.extractParams(bidRequest); if (!params || !params.publisher || !params.placement) { return false; } @@ -38,152 +188,124 @@ export const spec = { /** * Build real bid requests * - * @param {*} validBidRequests - * @param {*} bidderRequest - * @returns {*[]} + * @param {BidRequest[]} validBidRequests + * @param {BidderRequest} bidderRequest + * @returns {Object[]} */ buildRequests: (validBidRequests, bidderRequest) => { - const bidRequests = []; - const gdpr = extractGdprFromBidderRequest(bidderRequest); + const requests = []; + + // stop here on invalid or empty data + if (!bidderRequest || !validBidRequests || validBidRequests.length === 0) { + return requests; + } + + // collect required data + const auctionId = bidderRequest.auctionId; + const pageUrl = internal.extractPageUrl(bidderRequest); + const referrer = internal.extractReferrer(bidderRequest); + const gdpr = internal.extractGdpr(bidderRequest); - validBidRequests.forEach((bidRequest) => { - bidRequests.push({ - url: ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, encodeURIComponent(bidRequest.params.publisher)), + // group bid requests by publisher + const groupedBidRequests = internal.groupBidRequestsByPublisher(validBidRequests); + + // build requests + for (const publisher in groupedBidRequests) { + const request = { + url: internal.buildEndpointUrl(publisher), method: ENDPOINT_METHOD, data: { + auctionId: auctionId, + pageUrl: pageUrl, + referrer: referrer, + imp: [] + } + }; + + // add gdpr data + if (gdpr) { + request.data.gdpr = gdpr; + } + + // handle multiple bids per request + groupedBidRequests[publisher].forEach((bidRequest) => { + const bid = { bidId: bidRequest.bidId, - auctionId: bidRequest.auctionId, transactionId: bidRequest.transactionId, adUnitCode: bidRequest.adUnitCode, - pageUrl: extractTopWindowUrlFromBidRequest(bidRequest), - referrer: extractTopWindowReferrerFromBidRequest(bidRequest), - sizes: extractSizesFromBidRequest(bidRequest), - params: extractParamsFromBidRequest(bidRequest), - gdpr: gdpr + params: internal.extractParams(bidRequest) + }; + + // add banner config + const bannerConfig = internal.extractBannerConfig(bidRequest); + if (bannerConfig) { + bid.banner = bannerConfig; + } + + // add native config + const nativeConfig = internal.extractNativeConfig(bidRequest); + if (nativeConfig) { + bid.native = nativeConfig; } + + request.data.imp.push(bid); }); - }); - return bidRequests; + requests.push(request); + } + + return requests; }, /** * Handle bid response * - * @param {*} response - * @returns {*[]} + * @param {Object} response + * @returns {Object[]} */ interpretResponse: (response) => { const bidResponses = []; - if (!response.body || !response.body.bid || !response.body.creative) { + // stop here on invalid or empty data + if (!response || !utils.deepAccess(response, 'body.bids') || response.body.bids.length === 0) { return bidResponses; } - bidResponses.push({ - requestId: response.body.bid.bidId, - cpm: response.body.bid.price, - netRevenue: response.body.bid.net, - currency: response.body.bid.currency, - ttl: response.body.bid.ttl, - creativeId: response.body.creative.id, - width: response.body.creative.width, - height: response.body.creative.height, - ad: response.body.creative.html - }); - - return bidResponses; - } -}; - -/** - * Extracts the possible ad unit sizes from given bid request - * - * @param {*} bidRequest - * @returns {number[]} - */ -export function extractSizesFromBidRequest(bidRequest) { - // since pbjs 3.0 - if (bidRequest && utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes')) { - return bidRequest.mediaTypes.banner.sizes; - - // for backward compatibility - } else if (bidRequest && bidRequest.sizes) { - return bidRequest.sizes; - - // fallback - } else { - return []; - } -} - -/** - * Extracts the custom params from given bid request - * - * @param {*} bidRequest - * @returns {*} - */ -export function extractParamsFromBidRequest(bidRequest) { - if (bidRequest && bidRequest.params) { - return bidRequest.params - } else { - return null; - } -} - -/** - * Extracts the GDPR information from given bidder request - * - * @param {*} bidderRequest - * @returns {*} - */ -export function extractGdprFromBidderRequest(bidderRequest) { - let gdpr = null; - - if (bidderRequest && bidderRequest.gdprConsent) { - gdpr = { - consentString: bidderRequest.gdprConsent.consentString, - consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : true - }; - } + // parse multiple bids per response + response.body.bids.forEach((bid) => { + if (!bid || !bid.bid || !bid.creative) { + return; + } - return gdpr; -} + const bidResponse = { + requestId: bid.bid.bidId, + cpm: bid.bid.price, + netRevenue: bid.bid.net, + currency: bid.bid.currency, + ttl: bid.bid.ttl, + creativeId: bid.creative.id, + meta: { + advertiserDomains: bid.creative.advertiserDomains + } + } -/** - * Extracts the page url from given bid request or use the (top) window location as fallback - * - * @param {*} bidRequest - * @returns {string} - */ -export function extractTopWindowUrlFromBidRequest(bidRequest) { - if (bidRequest && utils.deepAccess(bidRequest, 'refererInfo.canonicalUrl')) { - return bidRequest.refererInfo.canonicalUrl; - } + if (bid.creative.html) { + bidResponse.mediaType = BANNER; + bidResponse.ad = bid.creative.html; + bidResponse.width = bid.creative.width; + bidResponse.height = bid.creative.height; + } - try { - return window.top.location.href; - } catch (e) { - return window.location.href; - } -} + if (bid.creative.native) { + bidResponse.mediaType = NATIVE; + bidResponse.native = bid.creative.native; + } -/** - * Extracts the referrer from given bid request or use the (top) document referrer as fallback - * - * @param {*} bidRequest - * @returns {string} - */ -export function extractTopWindowReferrerFromBidRequest(bidRequest) { - if (bidRequest && utils.deepAccess(bidRequest, 'refererInfo.referer')) { - return bidRequest.refererInfo.referer; - } + bidResponses.push(bidResponse); + }); - try { - return window.top.document.referrer; - } catch (e) { - return window.document.referrer; + return bidResponses; } -} +}; registerBidder(spec); diff --git a/modules/aduptechBidAdapter.md b/modules/aduptechBidAdapter.md index 281fe24cf9d..25034cecbe8 100644 --- a/modules/aduptechBidAdapter.md +++ b/modules/aduptechBidAdapter.md @@ -1,35 +1,86 @@ -# Overview -``` -Module Name: AdUp Technology Bid Adapter -Module Type: Bidder Adapter -Maintainers: - - steffen.anders@adup-tech.com - - sebastian.briesemeister@adup-tech.com - - marten.lietz@adup-tech.com -``` +# AdUp Technology Bid Adapter -# Description +## Description Connects to AdUp Technology demand sources to fetch bids. -Please use ```aduptech``` as bidder code. Only banner formats are supported. -The AdUp Technology bidding adapter requires setup and approval before beginning. -For more information visit [www.adup-tech.com](https://www.adup-tech.com/en) or contact [info@adup-tech.com](mailto:info@adup-tech.com). +**Note:** The bid adapter requires correct setup and approval, including an existing publisher account. For more information visit [www.adup-tech.com](https://www.adup-tech.com/en) or contact [info@adup-tech.com](mailto:info@adup-tech.com). + + +## Overview +- Module Name: AdUp Technology Bid Adapter +- Module Type: Bidder Adapter +- Maintainers: + - [steffen.anders@adup-tech.com](mailto:steffen.anders@adup-tech.com) + - [sebastian.briesemeister@adup-tech.com](mailto:sebastian.briesemeister@adup-tech.com) + - [marten.lietz@adup-tech.com](mailto:marten.lietz@adup-tech.com) +- Bidder code: `aduptech` +- Supported media types: `banner`, `native` + +## Paramters +| Name | Scope | Description | Example | +| :--- | :---- | :---------- | :------ | +| `publisher` | required | Unique publisher identifier | `'prebid'` | +| `placement` | required | Unique placement identifier per publisher | `'1234'` | +| `query` | optional | Semicolon separated list of keywords | `'urlaub;ibiza;mallorca'` | +| `adtest` | optional | Deactivates tracking of impressions and clicks. **Should only be used for testing purposes!** | `true` | + -# Test Parameters +## Examples + +### Banner ```js var adUnits = [ { - code: 'banner', + code: "example1", mediaTypes: { banner: { sizes: [[300, 250], [300, 600]], } }, bids: [{ - bidder: 'aduptech', + bidder: "aduptech", + params: { + publisher: "prebid", + placement: "12345" + } + }] + } +]; +``` + +### Native +```js +var adUnits = [ + { + code: "example2", + mediaTypes: { + native: { + image: { + required: true, + sizes: [150, 150] + }, + title: { + required: true + }, + body: { + required: true + }, + clickUrl: { + required: true + }, + displayUrl: { + required: true + }, + sponsoredBy: { + required: true + } + } + }, + bids: [{ + bidder: "aduptech", params: { - publisher: 'prebid', - placement: '12345' + publisher: "prebid", + placement: "12345" } }] } diff --git a/test/spec/modules/aduptechBidAdapter_spec.js b/test/spec/modules/aduptechBidAdapter_spec.js index 1e39e0cfc8b..362cd3e506a 100644 --- a/test/spec/modules/aduptechBidAdapter_spec.js +++ b/test/spec/modules/aduptechBidAdapter_spec.js @@ -1,180 +1,280 @@ import { expect } from 'chai'; import { BIDDER_CODE, - PUBLISHER_PLACEHOLDER, - ENDPOINT_URL, ENDPOINT_METHOD, - spec, - extractGdprFromBidderRequest, - extractParamsFromBidRequest, - extractSizesFromBidRequest, - extractTopWindowReferrerFromBidRequest, - extractTopWindowUrlFromBidRequest + internal, + spec } from '../../../modules/aduptechBidAdapter.js'; +import { config } from '../../../src/config.js'; +import * as utils from '../../../src/utils.js'; +import { BANNER, NATIVE } from '../../../src/mediaTypes.js' import { newBidder } from '../../../src/adapters/bidderFactory.js'; describe('AduptechBidAdapter', () => { - describe('extractGdprFromBidderRequest', () => { - it('should handle empty bidder request', () => { - const bidderRequest = null; - expect(extractGdprFromBidderRequest(bidderRequest)).to.be.null; - }); + describe('internal', () => { + describe('extractGdpr', () => { + it('should handle empty bidderRequest', () => { + expect(internal.extractGdpr(null)).to.be.null; + expect(internal.extractGdpr({})).to.be.null; + }); - it('should handle missing gdprConsent in bidder request', () => { - const bidderRequest = {}; - expect(extractGdprFromBidderRequest(bidderRequest)).to.be.null; - }); + it('should extract bidderRequest.gdprConsent', () => { + const bidderRequest = { + gdprConsent: { + consentString: 'consentString', + gdprApplies: false + } + }; - it('should handle gdprConsent in bidder request', () => { - const bidderRequest = { - gdprConsent: { - consentString: 'consentString', - gdprApplies: true - } - }; + expect(internal.extractGdpr(bidderRequest)).to.deep.equal({ + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: bidderRequest.gdprConsent.gdprApplies + }); + }); + + it('should handle missing bidderRequest.gdprConsent.gdprApplies', () => { + const bidderRequest = { + gdprConsent: { + consentString: 'consentString' + } + }; - expect(extractGdprFromBidderRequest(bidderRequest)).to.deep.equal({ - consentString: bidderRequest.gdprConsent.consentString, - consentRequired: true + expect(internal.extractGdpr(bidderRequest)).to.deep.equal({ + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: true + }); }); - }); - }); - describe('extractParamsFromBidRequest', () => { - it('should handle empty bid request', () => { - const bidRequest = null; - expect(extractParamsFromBidRequest(bidRequest)).to.be.null; - }); + it('should handle invalid bidderRequest.gdprConsent.gdprApplies', () => { + const bidderRequest = { + gdprConsent: { + consentString: 'consentString', + gdprApplies: 'foobar' + } + }; - it('should handle missing params in bid request', () => { - const bidRequest = {}; - expect(extractParamsFromBidRequest(bidRequest)).to.be.null; + expect(internal.extractGdpr(bidderRequest)).to.deep.equal({ + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: true + }); + }); }); - it('should handle params in bid request', () => { - const bidRequest = { - params: { - foo: '123', - bar: 456 - } - }; - expect(extractParamsFromBidRequest(bidRequest)).to.deep.equal(bidRequest.params); - }); - }); + describe('extractPageUrl', () => { + let origPageUrl; - describe('extractSizesFromBidRequest', () => { - it('should handle empty bid request', () => { - const bidRequest = null; - expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal([]); - }); + beforeEach(() => { + // remember original pageUrl in config + origPageUrl = config.getConfig('pageUrl'); - it('should handle missing sizes in bid request', () => { - const bidRequest = {}; - expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal([]); - }); + // unset pageUrl in config + config.setConfig({ pageUrl: null }); + }); + + afterEach(() => { + // set original pageUrl to config + config.setConfig({ pageUrl: origPageUrl }); + }); + + it('should handle empty or missing data', () => { + expect(internal.extractPageUrl(null)).to.equal(utils.getWindowTop().location.href); + expect(internal.extractPageUrl({})).to.equal(utils.getWindowTop().location.href); + expect(internal.extractPageUrl({ refererInfo: {} })).to.equal(utils.getWindowTop().location.href); + expect(internal.extractPageUrl({ refererInfo: { canonicalUrl: null } })).to.equal(utils.getWindowTop().location.href); + expect(internal.extractPageUrl({ refererInfo: { canonicalUrl: '' } })).to.equal(utils.getWindowTop().location.href); + }); + + it('should use "pageUrl" from config', () => { + config.setConfig({ pageUrl: 'http://page.url' }); - it('should handle sizes in bid request', () => { - const bidRequest = { - mediaTypes: { - banner: { - sizes: [[12, 34], [56, 78]] + expect(internal.extractPageUrl({})).to.equal(config.getConfig('pageUrl')); + }); + + it('should use bidderRequest.refererInfo.canonicalUrl', () => { + const bidderRequest = { + refererInfo: { + canonicalUrl: 'http://canonical.url' } - } - }; - expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal(bidRequest.mediaTypes.banner.sizes); - }); + }; - it('should handle sizes in bid request (backward compatibility)', () => { - const bidRequest = { - sizes: [[12, 34], [56, 78]] - }; - expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal(bidRequest.sizes); - }); + expect(internal.extractPageUrl(bidderRequest)).to.equal(bidderRequest.refererInfo.canonicalUrl); + }); - it('should prefer sizes in mediaTypes.banner', () => { - const bidRequest = { - sizes: [[12, 34]], - mediaTypes: { - banner: { - sizes: [[56, 78]] + it('should prefer bidderRequest.refererInfo.canonicalUrl over "pageUrl" from config', () => { + const bidderRequest = { + refererInfo: { + canonicalUrl: 'http://canonical.url' } - } - }; - expect(extractSizesFromBidRequest(bidRequest)).to.deep.equal(bidRequest.mediaTypes.banner.sizes); - }); - }); + }; - describe('extractTopWindowReferrerFromBidRequest', () => { - it('should use fallback if bid request is empty', () => { - const bidRequest = null; - expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); - }); + config.setConfig({ pageUrl: 'http://page.url' }); - it('should use fallback if refererInfo in bid request is missing', () => { - const bidRequest = {}; - expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); + expect(internal.extractPageUrl(bidderRequest)).to.equal(bidderRequest.refererInfo.canonicalUrl); + }); }); - it('should use fallback if refererInfo.referer in bid request is missing', () => { - const bidRequest = { - refererInfo: {} - }; - expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); - }); + describe('extractReferrer', () => { + it('should handle empty or missing data', () => { + expect(internal.extractReferrer(null)).to.equal(utils.getWindowTop().document.referrer); + expect(internal.extractReferrer({})).to.equal(utils.getWindowTop().document.referrer); + expect(internal.extractReferrer({ refererInfo: {} })).to.equal(utils.getWindowTop().document.referrer); + expect(internal.extractReferrer({ refererInfo: { referer: null } })).to.equal(utils.getWindowTop().document.referrer); + expect(internal.extractReferrer({ refererInfo: { referer: '' } })).to.equal(utils.getWindowTop().document.referrer); + }); - it('should use fallback if refererInfo.referer in bid request is empty', () => { - const bidRequest = { - refererInfo: { - referer: '' - } - }; - expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(window.top.document.referrer); - }); + it('hould use bidderRequest.refererInfo.referer', () => { + const bidderRequest = { + refererInfo: { + referer: 'foobar' + } + }; - it('should use refererInfo.referer from bid request ', () => { - const bidRequest = { - refererInfo: { - referer: 'foobar' - } - }; - expect(extractTopWindowReferrerFromBidRequest(bidRequest)).to.equal(bidRequest.refererInfo.referer); + expect(internal.extractReferrer(bidderRequest)).to.equal(bidderRequest.refererInfo.referer); + }); }); - }); - describe('extractTopWindowUrlFromBidRequest', () => { - it('should use fallback if bid request is empty', () => { - const bidRequest = null; - expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + describe('extractParams', () => { + it('should handle empty bidRequest', () => { + expect(internal.extractParams(null)).to.be.null; + expect(internal.extractParams({})).to.be.null; + }); + + it('should extract bidRequest.params', () => { + const bidRequest = { + params: { + foo: '123', + bar: 456 + } + }; + expect(internal.extractParams(bidRequest)).to.deep.equal(bidRequest.params); + }); }); - it('should use fallback if refererInfo in bid request is missing', () => { - const bidRequest = {}; - expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + describe('extractBannerConfig', () => { + it('should handle empty bidRequest', () => { + expect(internal.extractBannerConfig(null)).to.be.null; + expect(internal.extractBannerConfig({})).to.be.null; + }); + + it('should extract bidRequest.mediaTypes.banner', () => { + const bidRequest = { + mediaTypes: { + banner: { + sizes: [[12, 34], [56, 78]] + } + } + }; + expect(internal.extractBannerConfig(bidRequest)).to.deep.equal(bidRequest.mediaTypes.banner); + }); + + it('should extract bidRequest.sizes (backward compatibility)', () => { + const bidRequest = { + sizes: [[12, 34], [56, 78]] + }; + + expect(internal.extractBannerConfig(bidRequest)).to.deep.equal({sizes: bidRequest.sizes}); + }); }); - it('should use fallback if refererInfo.canonicalUrl in bid request is missing', () => { - const bidRequest = { - refererInfo: {} - }; - expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + describe('extractNativeConfig', () => { + it('should handle empty bidRequest', () => { + expect(internal.extractNativeConfig(null)).to.be.null; + expect(internal.extractNativeConfig({})).to.be.null; + }); + + it('should extract bidRequest.mediaTypes.native', () => { + const bidRequest = { + mediaTypes: { + native: { + image: { + required: true + }, + title: { + required: true + } + } + } + }; + + expect(internal.extractNativeConfig(bidRequest)).to.deep.equal(bidRequest.mediaTypes.native); + }); }); - it('should use fallback if refererInfo.canonicalUrl in bid request is empty', () => { - const bidRequest = { - refererInfo: { - canonicalUrl: '' - } - }; - expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(window.top.location.href); + describe('groupBidRequestsByPublisher', () => { + it('should handle empty bidRequests', () => { + expect(internal.groupBidRequestsByPublisher(null)).to.deep.equal({}); + expect(internal.groupBidRequestsByPublisher([])).to.deep.equal({}) + }); + + it('should group given bidRequests by params.publisher', () => { + const bidRequests = [ + { + mediaTypes: { + banner: { + sizes: [[100, 100]] + } + }, + params: { + publisher: 'publisher1', + placement: '1111' + } + }, + { + mediaTypes: { + banner: { + sizes: [[200, 200]] + } + }, + params: { + publisher: 'publisher2', + placement: '2222' + } + }, + { + mediaTypes: { + banner: { + sizes: [[300, 300]] + } + }, + params: { + publisher: 'publisher3', + placement: '3333' + } + }, + { + mediaTypes: { + banner: { + sizes: [[400, 400]] + } + }, + params: { + publisher: 'publisher1', + placement: '4444' + } + } + ]; + + expect(internal.groupBidRequestsByPublisher(bidRequests)).to.deep.equal({ + publisher1: [ + bidRequests[0], + bidRequests[3] + ], + publisher2: [ + bidRequests[1], + ], + publisher3: [ + bidRequests[2], + ], + }); + }); }); - it('should use refererInfo.canonicalUrl from bid request ', () => { - const bidRequest = { - refererInfo: { - canonicalUrl: 'foobar' - } - }; - expect(extractTopWindowUrlFromBidRequest(bidRequest)).to.equal(bidRequest.refererInfo.canonicalUrl); + describe('buildEndpointUrl', () => { + it('should build endpoint url based on given publisher code', () => { + expect(internal.buildEndpointUrl(1234)).to.be.equal('https://rtb.d.adup-tech.com/prebid/1234_bid'); + expect(internal.buildEndpointUrl('foobar')).to.be.equal('https://rtb.d.adup-tech.com/prebid/foobar_bid'); + expect(internal.buildEndpointUrl('foo bar')).to.be.equal('https://rtb.d.adup-tech.com/prebid/foo%20bar_bid'); + }); }); }); @@ -185,42 +285,31 @@ describe('AduptechBidAdapter', () => { adapter = newBidder(spec); }); - describe('inherited functions', () => { - it('exists and is a function', () => { - expect(adapter.callBids).to.exist.and.to.be.a('function'); + describe('code', () => { + it('should be correct', () => { + expect(adapter.getSpec().code).to.equal(BIDDER_CODE); }); }); - describe('isBidRequestValid', () => { - it('should return true when necessary information is given', () => { - expect(spec.isBidRequestValid({ - mediaTypes: { - banner: { - sizes: [[100, 200]] - } - }, - params: { - publisher: 'test', - placement: '1234' - } - })).to.be.true; + describe('supportedMediaTypes', () => { + it('should be correct', () => { + expect(adapter.getSpec().supportedMediaTypes).to.deep.equal([BANNER, NATIVE]); }); + }); - it('should return true when necessary information is given (backward compatibility)', () => { - expect(spec.isBidRequestValid({ - sizes: [[100, 200]], - params: { - publisher: 'test', - placement: '1234' - } - })).to.be.true; + describe('inherited functions', () => { + it('should exist and be a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); }); + }); - it('should return false on empty bid', () => { + describe('isBidRequestValid', () => { + it('should be false on empty bid', () => { + expect(spec.isBidRequestValid(null)).to.be.false; expect(spec.isBidRequestValid({})).to.be.false; }); - it('should return false on missing sizes', () => { + it('should be false if mediaTypes.banner and mediaTypes.native is missing', () => { expect(spec.isBidRequestValid({ params: { publisher: 'test', @@ -229,63 +318,65 @@ describe('AduptechBidAdapter', () => { })).to.be.false; }); - it('should return false on empty sizes', () => { + it('should be false if params missing', () => { expect(spec.isBidRequestValid({ mediaTypes: { banner: { - sizes: [] + sizes: [[100, 200]] } }, - params: { - publisher: 'test', - placement: '1234' - } })).to.be.false; }); - it('should return false on empty sizes (backward compatibility)', () => { + it('should be false if params is invalid', () => { expect(spec.isBidRequestValid({ - sizes: [], - params: { - publisher: 'test', - placement: '1234' - } + mediaTypes: { + banner: { + sizes: [[100, 200]] + } + }, + params: 'bar' })).to.be.false; }); - it('should return false on missing params', () => { + it('should be false if params is empty', () => { expect(spec.isBidRequestValid({ mediaTypes: { banner: { sizes: [[100, 200]] } }, + params: {} })).to.be.false; }); - it('should return false on invalid params', () => { + it('should be false if params.publisher is missing', () => { expect(spec.isBidRequestValid({ mediaTypes: { banner: { sizes: [[100, 200]] } }, - params: 'bar' + params: { + placement: '1234' + } })).to.be.false; }); - it('should return false on empty params', () => { + it('should be false if params.placement is missing', () => { expect(spec.isBidRequestValid({ mediaTypes: { banner: { sizes: [[100, 200]] } }, - params: {} + params: { + publisher: 'test' + } })).to.be.false; }); - it('should return false on missing publisher', () => { + it('should be true if mediaTypes.banner is given', () => { expect(spec.isBidRequestValid({ mediaTypes: { banner: { @@ -293,34 +384,62 @@ describe('AduptechBidAdapter', () => { } }, params: { + publisher: 'test', placement: '1234' } - })).to.be.false; + })).to.be.true; }); - it('should return false on missing placement', () => { + it('should be true if mediaTypes.native is given', () => { expect(spec.isBidRequestValid({ mediaTypes: { - banner: { - sizes: [[100, 200]] + native: { + image: { + required: true + }, + title: { + required: true + }, + clickUrl: { + required: true + }, + body: { + required: true + } } }, params: { - publisher: 'test' + publisher: 'test', + placement: '1234' } - })).to.be.false; + })).to.be.true; }); }); describe('buildRequests', () => { - it('should send one bid request per ad unit to the endpoint via POST', () => { - const bidRequests = [ + it('should handle empty validBidRequests', () => { + expect(spec.buildRequests(null)).to.deep.equal([]); + expect(spec.buildRequests([])).to.deep.equal([]); + }); + + it('should build one request per publisher', () => { + const bidderRequest = { + auctionId: 'auctionId123', + refererInfo: { + canonicalUrl: 'http://crazy.canonical.url', + referer: 'http://crazy.referer.url' + }, + gdprConsent: { + consentString: 'consentString123', + gdprApplies: true + } + }; + + const validBidRequests = [ { - bidder: BIDDER_CODE, bidId: 'bidId1', adUnitCode: 'adUnitCode1', transactionId: 'transactionId1', - auctionId: 'auctionId1', mediaTypes: { banner: { sizes: [[100, 200], [300, 400]] @@ -332,170 +451,197 @@ describe('AduptechBidAdapter', () => { } }, { - bidder: BIDDER_CODE, bidId: 'bidId2', adUnitCode: 'adUnitCode2', transactionId: 'transactionId2', - auctionId: 'auctionId2', mediaTypes: { banner: { - sizes: [[500, 600]] + sizes: [[100, 200]] } }, params: { - publisher: 'publisher2', + publisher: 'publisher1', placement: 'placement2' } - } - ]; - - const result = spec.buildRequests(bidRequests); - expect(result.length).to.equal(2); - - expect(result[0].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, bidRequests[0].params.publisher)); - expect(result[0].method).to.equal(ENDPOINT_METHOD); - expect(result[0].data).to.deep.equal({ - bidId: bidRequests[0].bidId, - auctionId: bidRequests[0].auctionId, - transactionId: bidRequests[0].transactionId, - adUnitCode: bidRequests[0].adUnitCode, - pageUrl: extractTopWindowUrlFromBidRequest(bidRequests[0]), - referrer: extractTopWindowReferrerFromBidRequest(bidRequests[0]), - sizes: extractSizesFromBidRequest(bidRequests[0]), - params: extractParamsFromBidRequest(bidRequests[0]), - gdpr: null - }); - - expect(result[1].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, bidRequests[1].params.publisher)); - expect(result[1].method).to.equal(ENDPOINT_METHOD); - expect(result[1].data).to.deep.equal({ - bidId: bidRequests[1].bidId, - auctionId: bidRequests[1].auctionId, - transactionId: bidRequests[1].transactionId, - adUnitCode: bidRequests[1].adUnitCode, - pageUrl: extractTopWindowUrlFromBidRequest(bidRequests[1]), - referrer: extractTopWindowReferrerFromBidRequest(bidRequests[1]), - sizes: extractSizesFromBidRequest(bidRequests[1]), - params: extractParamsFromBidRequest(bidRequests[1]), - gdpr: null - }); - }); - - it('should pass gdpr informations', () => { - const bidderRequest = { - gdprConsent: { - consentString: 'consentString', - gdprApplies: true - } - }; - - const bidRequests = [ + }, { - bidder: BIDDER_CODE, bidId: 'bidId3', adUnitCode: 'adUnitCode3', transactionId: 'transactionId3', - auctionId: 'auctionId3', mediaTypes: { - banner: { - sizes: [[100, 200], [300, 400]] + native: { + image: { + required: true + }, + title: { + required: true + }, + clickUrl: { + required: true + }, + body: { + required: true + } } }, params: { - publisher: 'publisher3', + publisher: 'publisher2', placement: 'placement3' } } ]; - const result = spec.buildRequests(bidRequests, bidderRequest); - expect(result.length).to.equal(1); - expect(result[0].data.gdpr).to.deep.equal(extractGdprFromBidderRequest(bidderRequest)); - }); - - it('should encode publisher param in endpoint url', () => { - const bidRequests = [ + expect(spec.buildRequests(validBidRequests, bidderRequest)).to.deep.equal([ { - bidder: BIDDER_CODE, - bidId: 'bidId1', - adUnitCode: 'adUnitCode1', - transactionId: 'transactionId1', - auctionId: 'auctionId1', - mediaTypes: { - banner: { - sizes: [[100, 200]] - } - }, - params: { - publisher: 'crazy publisher key äÖÜ', - placement: 'placement1' + url: internal.buildEndpointUrl(validBidRequests[0].params.publisher), + method: ENDPOINT_METHOD, + data: { + auctionId: bidderRequest.auctionId, + pageUrl: bidderRequest.refererInfo.canonicalUrl, + referrer: bidderRequest.refererInfo.referer, + gdpr: { + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: bidderRequest.gdprConsent.gdprApplies + }, + imp: [ + { + bidId: validBidRequests[0].bidId, + transactionId: validBidRequests[0].transactionId, + adUnitCode: validBidRequests[0].adUnitCode, + params: validBidRequests[0].params, + banner: validBidRequests[0].mediaTypes.banner + }, + { + bidId: validBidRequests[1].bidId, + transactionId: validBidRequests[1].transactionId, + adUnitCode: validBidRequests[1].adUnitCode, + params: validBidRequests[1].params, + banner: validBidRequests[1].mediaTypes.banner + } + ] } }, - ]; - - const result = spec.buildRequests(bidRequests); - expect(result[0].url).to.equal(ENDPOINT_URL.replace(PUBLISHER_PLACEHOLDER, encodeURIComponent(bidRequests[0].params.publisher))); - }); - - it('should handle empty bidRequests', () => { - expect(spec.buildRequests([])).to.deep.equal([]); - }); - }); - - describe('interpretResponse', () => { - it('should correctly interpret the server response', () => { - const serverResponse = { - body: { - bid: { - bidId: 'bidId1', - price: 0.12, - net: true, - currency: 'EUR', - ttl: 123 - }, - creative: { - id: 'creativeId1', - width: 100, - height: 200, - html: '
Hello World
' - } - } - }; - - const result = spec.interpretResponse(serverResponse); - expect(result).to.deep.equal([ { - requestId: serverResponse.body.bid.bidId, - cpm: serverResponse.body.bid.price, - netRevenue: serverResponse.body.bid.net, - currency: serverResponse.body.bid.currency, - ttl: serverResponse.body.bid.ttl, - creativeId: serverResponse.body.creative.id, - width: serverResponse.body.creative.width, - height: serverResponse.body.creative.height, - ad: serverResponse.body.creative.html + url: internal.buildEndpointUrl(validBidRequests[2].params.publisher), + method: ENDPOINT_METHOD, + data: { + auctionId: bidderRequest.auctionId, + pageUrl: bidderRequest.refererInfo.canonicalUrl, + referrer: bidderRequest.refererInfo.referer, + gdpr: { + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: bidderRequest.gdprConsent.gdprApplies + }, + imp: [ + { + bidId: validBidRequests[2].bidId, + transactionId: validBidRequests[2].transactionId, + adUnitCode: validBidRequests[2].adUnitCode, + params: validBidRequests[2].params, + native: validBidRequests[2].mediaTypes.native + } + ] + } } ]); }); + }); + describe('interpretResponse', () => { it('should handle empty serverResponse', () => { + expect(spec.interpretResponse(null)).to.deep.equal([]); expect(spec.interpretResponse({})).to.deep.equal([]); + expect(spec.interpretResponse({ body: {} })).to.deep.equal([]); + expect(spec.interpretResponse({ body: { bids: [] } })).to.deep.equal([]); }); - it('should handle missing bid', () => { - expect(spec.interpretResponse({ + it('should correctly interpret the server response', () => { + const serverResponse = { body: { - creative: {} + bids: [ + { + bid: { + bidId: 'bidId1', + price: 0.12, + net: true, + currency: 'EUR', + ttl: 123 + }, + creative: { + id: 'creativeId1', + advertiserDomains: ['advertiser1.com', 'advertiser2.org'], + width: 100, + height: 200, + html: '
Hello World
' + } + }, + { + bid: { + bidId: 'bidId2', + price: 0.99, + net: false, + currency: 'USD', + ttl: 465 + }, + creative: { + id: 'creativeId2', + advertiserDomains: ['advertiser3.com'], + native: { + title: 'Ad title', + body: 'Ad description', + displayUrl: 'Ad display url', + clickUrl: 'http://click.url/ad.html', + image: { + url: 'https://image.url/ad.png', + width: 123, + height: 456 + }, + sponsoredBy: 'Ad sponsored by', + impressionTrackers: [ + 'https://impression.tracking.url/1', + 'https://impression.tracking.url/2', + ], + privacyLink: 'https://example.com/privacy', + privacyIcon: 'https://example.com/icon.png' + } + } + }, + null, // should be skipped + {} // should be skipped + ] } - })).to.deep.equal([]); - }); + }; - it('should handle missing creative', () => { - expect(spec.interpretResponse({ - body: { - bid: {} + expect(spec.interpretResponse(serverResponse)).to.deep.equal([ + { + requestId: serverResponse.body.bids[0].bid.bidId, + cpm: serverResponse.body.bids[0].bid.price, + netRevenue: serverResponse.body.bids[0].bid.net, + currency: serverResponse.body.bids[0].bid.currency, + ttl: serverResponse.body.bids[0].bid.ttl, + creativeId: serverResponse.body.bids[0].creative.id, + meta: { + advertiserDomains: serverResponse.body.bids[0].creative.advertiserDomains + }, + mediaType: BANNER, + width: serverResponse.body.bids[0].creative.width, + height: serverResponse.body.bids[0].creative.height, + ad: serverResponse.body.bids[0].creative.html + }, + { + requestId: serverResponse.body.bids[1].bid.bidId, + cpm: serverResponse.body.bids[1].bid.price, + netRevenue: serverResponse.body.bids[1].bid.net, + currency: serverResponse.body.bids[1].bid.currency, + ttl: serverResponse.body.bids[1].bid.ttl, + creativeId: serverResponse.body.bids[1].creative.id, + meta: { + advertiserDomains: serverResponse.body.bids[1].creative.advertiserDomains + }, + mediaType: NATIVE, + native: serverResponse.body.bids[1].creative.native } - })).to.deep.equal([]); + ]); }); }); }); From c04b0248e90642588c6e98ba86190aa916f2c101 Mon Sep 17 00:00:00 2001 From: pro-nsk <32703851+pro-nsk@users.noreply.github.com> Date: Fri, 28 May 2021 17:35:50 +0700 Subject: [PATCH 250/303] QwarryBidAdapter: added schain (#6864) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix * gdpr value added * merge master * gdpr value added * qwarry bid adapter: add tests * Qwarry bid adapter: remove gdpr field from request * qwarry bid adapter: add sizes * qwarry bid adapter: add sizes * added schain * added test for schain Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: Ekaterina Legostaeva --- modules/qwarryBidAdapter.js | 3 ++- test/spec/modules/qwarryBidAdapter_spec.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/qwarryBidAdapter.js b/modules/qwarryBidAdapter.js index 7ed5e5c984c..a410c2fe163 100644 --- a/modules/qwarryBidAdapter.js +++ b/modules/qwarryBidAdapter.js @@ -28,7 +28,8 @@ export const spec = { let payload = { requestId: bidderRequest.bidderRequestId, bids, - referer: bidderRequest.refererInfo.referer + referer: bidderRequest.refererInfo.referer, + schain: validBidRequests[0].schain } if (bidderRequest && bidderRequest.gdprConsent) { diff --git a/test/spec/modules/qwarryBidAdapter_spec.js b/test/spec/modules/qwarryBidAdapter_spec.js index 06d4af0756c..6dbb983ea23 100644 --- a/test/spec/modules/qwarryBidAdapter_spec.js +++ b/test/spec/modules/qwarryBidAdapter_spec.js @@ -9,6 +9,15 @@ const REQUEST = { 'params': { zoneToken: 'e64782a4-8e68-4c38-965b-80ccf115d46f', pos: 7 + }, + 'schain': { + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'qwarry.com', + sid: '00001', + hp: 1 + }] } } @@ -86,6 +95,7 @@ describe('qwarryBidAdapter', function () { expect(bidderRequest.method).to.equal('POST') expect(bidderRequest.data.requestId).to.equal('123') expect(bidderRequest.data.referer).to.equal('http://test.com/path.html') + expect(bidderRequest.data.schain).to.deep.contains({ver: '1.0', complete: 1, nodes: [{asi: 'qwarry.com', sid: '00001', hp: 1}]}) expect(bidderRequest.data.bids).to.deep.contains({ bidId: '456', zoneToken: 'e64782a4-8e68-4c38-965b-80ccf115d46f', pos: 7, sizes: [{ width: 100, height: 200 }, { width: 300, height: 400 }] }) expect(bidderRequest.data.gdprConsent).to.deep.contains({ consentRequired: true, consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==' }) expect(bidderRequest.options.customHeaders).to.deep.equal({ 'Rtb-Direct': true }) From 9c484c029a9b899f95d7adddcd0fb5adb494c77c Mon Sep 17 00:00:00 2001 From: Anand Venkatraman Date: Fri, 28 May 2021 08:41:35 -0400 Subject: [PATCH 251/303] PulsePoint Adapter: Fixing issues related to Prebid 5.0 (#6857) --- modules/pulsepointBidAdapter.js | 26 +++++++- modules/pulsepointBidAdapter.md | 35 +++++----- .../spec/modules/pulsepointBidAdapter_spec.js | 64 ++++++++++++++++++- 3 files changed, 100 insertions(+), 25 deletions(-) diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js index f74d79a3dc5..adea33fc3b9 100644 --- a/modules/pulsepointBidAdapter.js +++ b/modules/pulsepointBidAdapter.js @@ -119,7 +119,8 @@ function bidResponseAvailable(request, response) { adId: id, ttl: idToBidMap[id].exp || DEFAULT_BID_TTL, netRevenue: DEFAULT_NET_REVENUE, - currency: bidResponse.cur || DEFAULT_CURRENCY + currency: bidResponse.cur || DEFAULT_CURRENCY, + meta: { advertiserDomains: idToBidMap[id].adomain || [] } }; if (idToImpMap[id].video) { // for outstream, a renderer is specified @@ -154,7 +155,7 @@ function impression(slot) { 'native': nativeImpression(slot), tagid: slot.params.ct.toString(), video: video(slot), - bidfloor: slot.params.bidfloor, + bidfloor: bidFloor(slot), ext: ext(slot), }; } @@ -192,7 +193,11 @@ function parseSizes(slot) { */ function video(slot) { if (slot.params.video) { - return Object.assign({}, slot.params.video, {battr: slot.params.battr}); + return Object.assign({}, + slot.params.video, // previously supported as bidder param + slot.mediaTypes && slot.mediaTypes.video ? slot.mediaTypes.video : {}, // params on mediaTypes.video + {battr: slot.params.battr} + ); } return null; } @@ -519,4 +524,19 @@ function nativeResponse(imp, bid) { return null; } +function bidFloor(slot) { + let floor = slot.params.bidfloor; + if (utils.isFn(slot.getFloor)) { + const floorData = slot.getFloor({ + mediaType: slot.mediaTypes.banner ? 'banner' : slot.mediaTypes.video ? 'video' : 'Native', + size: '*', + currency: DEFAULT_CURRENCY, + }); + if (floorData && floorData.floor) { + floor = floorData.floor; + } + } + return floor; +} + registerBidder(spec); diff --git a/modules/pulsepointBidAdapter.md b/modules/pulsepointBidAdapter.md index 36d4ef6cce5..7f4b7e6b611 100644 --- a/modules/pulsepointBidAdapter.md +++ b/modules/pulsepointBidAdapter.md @@ -45,23 +45,21 @@ Please use ```pulsepoint``` as the bidder code. mediaTypes: { video: { playerSize: [640, 480], - context: 'outstream' + context: 'outstream', + h: 300, + w: 400, + minduration: 1, + maxduration: 210, + linearity: 1, + mimes: ["video/mp4", "video/ogg", "video/webm"], + pos: 3 } }, bids: [{ bidder: 'pulsepoint', params: { cp: 512379, - ct: 505642, - video: { - h: 300, - w: 400, - minduration: 1, - maxduration: 210, - linearity: 1, - mimes: ["video/mp4", "video/ogg", "video/webm"], - pos: 3 - } + ct: 505642 } }], renderer: { @@ -74,7 +72,12 @@ Please use ```pulsepoint``` as the bidder code. mediaTypes: { video: { playerSize: [640, 480], - context: 'instream' + context: 'instream', + h: 300, + w: 400, + minduration: 1, + maxduration: 210, + protocols: [2,3,5] } }, bids: [{ @@ -82,14 +85,6 @@ Please use ```pulsepoint``` as the bidder code. params: { cp: 512379, ct: 694973, - video: { - battr: [1,3], - h: 300, - w: 400, - minduration: 1, - maxduration: 210, - protocols: [2,3,5] - } } }] }]; diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index c3830d5cb46..6630cb0907c 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -254,7 +254,7 @@ describe('PulsePoint Adapter Tests', function () { expect(bid.ttl).to.equal(20); }); - it('Verify ttl/currency applied to bid', function () { + it('Verify ttl/currency/adomain applied to bid', function () { const request = spec.buildRequests(slotConfigs, bidderRequest); const ortbRequest = request.data; const ortbResponse = { @@ -264,7 +264,8 @@ describe('PulsePoint Adapter Tests', function () { price: 1.25, adm: 'This is an Ad#1', crid: 'Creative#123', - exp: 50 + exp: 50, + adomain: ['advertiser.com'] }, { impid: ortbRequest.imp[1].id, price: 1.25, @@ -282,11 +283,15 @@ describe('PulsePoint Adapter Tests', function () { expect(bid.ad).to.equal('This is an Ad#1'); expect(bid.ttl).to.equal(50); expect(bid.currency).to.equal('GBP'); + expect(bid.meta).to.not.be.null; + expect(bid.meta.advertiserDomains).to.eql(['advertiser.com']); const secondBid = bids[1]; expect(secondBid.cpm).to.equal(1.25); expect(secondBid.ad).to.equal('This is an Ad#2'); expect(secondBid.ttl).to.equal(20); expect(secondBid.currency).to.equal('GBP'); + expect(secondBid.meta).to.not.be.null; + expect(secondBid.meta.advertiserDomains).to.eql([]); }); it('Verify full passback', function () { @@ -778,4 +783,59 @@ describe('PulsePoint Adapter Tests', function () { const secondBid = bids[1]; expect(secondBid.vastXml).to.equal(''); }); + it('Verify bid floor', function () { + const bidRequests = deepClone(slotConfigs); + bidRequests[0].params.bidfloor = 1.05; + let request = spec.buildRequests(bidRequests, bidderRequest); + let ortbRequest = request.data; + expect(ortbRequest).to.not.equal(null); + expect(ortbRequest.imp[0].bidfloor).to.equal(1.05); + expect(ortbRequest.imp[1].bidfloor).to.be.undefined; + let floorArg = null; + // publisher uses the floor module + bidRequests[0].getFloor = (arg) => { + floorArg = arg; + return { floor: 1.25 }; + }; + bidRequests[1].getFloor = () => { + return { floor: 2.05 }; + }; + request = spec.buildRequests(bidRequests, bidderRequest); + ortbRequest = request.data; + expect(ortbRequest).to.not.equal(null); + expect(ortbRequest.imp[0].bidfloor).to.equal(1.25); + expect(ortbRequest.imp[1].bidfloor).to.equal(2.05); + expect(floorArg).to.not.be.null; + expect(floorArg.mediaType).to.equal('banner'); + expect(floorArg.currency).to.equal('USD'); + expect(floorArg.size).to.equal('*'); + }); + it('Verify Video params on mediaTypes.video', function () { + const bidRequests = deepClone(videoSlotConfig); + bidRequests[0].mediaTypes = { + video: { + w: 600, + h: 400, + minduration: 15, + maxduration: 20, + startdelay: 10, + skip: 0, + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest).to.not.equal(null); + expect(ortbRequest.imp).to.have.lengthOf(1); + expect(ortbRequest.imp[0].video).to.not.be.null; + expect(ortbRequest.imp[0].native).to.be.null; + expect(ortbRequest.imp[0].banner).to.be.null; + expect(ortbRequest.imp[0].video.w).to.equal(600); + expect(ortbRequest.imp[0].video.h).to.equal(400); + expect(ortbRequest.imp[0].video.minduration).to.equal(15); + expect(ortbRequest.imp[0].video.maxduration).to.equal(20); + expect(ortbRequest.imp[0].video.startdelay).to.equal(10); + expect(ortbRequest.imp[0].video.skip).to.equal(0); + expect(ortbRequest.imp[0].video.minbitrate).to.equal(200); + expect(ortbRequest.imp[0].video.protocols).to.eql([1, 2, 4]); + }); }); From 5b855a614842f6bb52ef676aaf6e326a1cd0a41d Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Fri, 28 May 2021 06:14:08 -0700 Subject: [PATCH 252/303] Bugfix: Parrable Cookie Length in Testing (#6869) --- test/spec/modules/parrableIdSystem_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/parrableIdSystem_spec.js b/test/spec/modules/parrableIdSystem_spec.js index c18574aec7b..256be7340b7 100644 --- a/test/spec/modules/parrableIdSystem_spec.js +++ b/test/spec/modules/parrableIdSystem_spec.js @@ -12,7 +12,7 @@ import { server } from 'test/mocks/xhr.js'; const storage = newStorageManager(); const EXPIRED_COOKIE_DATE = 'Thu, 01 Jan 1970 00:00:01 GMT'; -const EXPIRE_COOKIE_TIME = 20000; +const EXPIRE_COOKIE_TIME = 864000000; const P_COOKIE_NAME = '_parrable_id'; const P_COOKIE_EID = '01.1563917337.test-eid'; const P_XHR_EID = '01.1588030911.test-new-eid' From 7ce7b09d43625499675b8511982e99fab9164502 Mon Sep 17 00:00:00 2001 From: onetag-dev <38786435+onetag-dev@users.noreply.github.com> Date: Fri, 28 May 2021 17:03:11 +0200 Subject: [PATCH 253/303] Add meta.advertiserDomains support (#6870) Co-authored-by: francesco --- modules/onetagBidAdapter.js | 3 ++- test/spec/modules/onetagBidAdapter_spec.js | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 16b8096646f..0974f9db4cf 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -101,7 +101,8 @@ function interpretResponse(serverResponse, bidderRequest) { netRevenue: bid.netRevenue || false, mediaType: bid.mediaType, meta: { - mediaType: bid.mediaType + mediaType: bid.mediaType, + advertiserDomains: bid.adomain }, ttl: bid.ttl || 300 }; diff --git a/test/spec/modules/onetagBidAdapter_spec.js b/test/spec/modules/onetagBidAdapter_spec.js index c1462c3814d..5a1f30a0de8 100644 --- a/test/spec/modules/onetagBidAdapter_spec.js +++ b/test/spec/modules/onetagBidAdapter_spec.js @@ -240,6 +240,7 @@ describe('onetag', function () { expect(dataItem.creativeId).to.be.a('string'); expect(dataItem.netRevenue).to.be.a('boolean'); expect(dataItem.currency).to.be.a('string'); + expect(dataItem.meta.advertiserDomains).to.be.an('array'); } }); it('Returns an empty array if response is not valid', function () { @@ -323,6 +324,7 @@ function getBannerVideoResponse() { currency: 'USD', requestId: 'banner', mediaType: BANNER, + adomain: [] }, { cpm: 13, @@ -334,7 +336,8 @@ function getBannerVideoResponse() { requestId: 'videoInstream', vastUrl: 'https://videoinstream.org', videoCacheKey: 'key', - mediaType: VIDEO + mediaType: VIDEO, + adomain: ['test_domain'] }, { cpm: 13, @@ -347,7 +350,8 @@ function getBannerVideoResponse() { requestId: 'videoOutstream', ad: '', rendererUrl: 'https://testRenderer', - mediaType: VIDEO + mediaType: VIDEO, + adomain: [] } ] } From c73e59f20360c7ccc17835ea2be23c23026008ec Mon Sep 17 00:00:00 2001 From: Kajan Umakanthan Date: Fri, 28 May 2021 08:04:00 -0700 Subject: [PATCH 254/303] adding GAM ad unit code to impression ext object (#6861) Co-authored-by: punkiller --- modules/ixBidAdapter.js | 9 +++++++++ test/spec/modules/ixBidAdapter_spec.js | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/modules/ixBidAdapter.js b/modules/ixBidAdapter.js index 6970eefeac2..4837c9c061f 100644 --- a/modules/ixBidAdapter.js +++ b/modules/ixBidAdapter.js @@ -112,6 +112,11 @@ function bidToVideoImp(bid) { return imp; } +/** + * Converts an incoming PBJS bid to an IX Impression + * @param {object} bid PBJS bid object + * @returns {object} IX impression object + */ function bidToImp(bid) { const imp = {}; @@ -127,6 +132,10 @@ function bidToImp(bid) { imp.ext.sid = `${bid.params.size[0]}x${bid.params.size[1]}`; } + const dfpAdUnitCode = utils.deepAccess(bid, 'ortb2Imp.ext.data.adserver.adslot'); + if (dfpAdUnitCode) { + imp.ext.dfp_ad_unit_code = dfpAdUnitCode; + } return imp; } diff --git a/test/spec/modules/ixBidAdapter_spec.js b/test/spec/modules/ixBidAdapter_spec.js index c026dfd3efc..48c8e48e6af 100644 --- a/test/spec/modules/ixBidAdapter_spec.js +++ b/test/spec/modules/ixBidAdapter_spec.js @@ -1251,6 +1251,32 @@ describe('IndexexchangeAdapter', function () { expect(query.nf).not.to.exist; }); + it('should send dfp_adunit_code in request if ortb2Imp.ext.data.adserver.adslot exists', function () { + const AD_UNIT_CODE = '/19968336/some-adunit-path'; + const validBids = utils.deepClone(DEFAULT_BANNER_VALID_BID); + validBids[0].ortb2Imp = { + ext: { + data: { + adserver: { + name: 'gam', + adslot: AD_UNIT_CODE + } + } + } + }; + const requests = spec.buildRequests(validBids, DEFAULT_OPTION); + const { dfp_ad_unit_code } = JSON.parse(requests[0].data.r).imp[0].ext; + expect(dfp_ad_unit_code).to.equal(AD_UNIT_CODE); + }); + + it('should not send dfp_adunit_code in request if ortb2Imp.ext.data.adserver.adslot does not exists', function () { + const validBids = utils.deepClone(DEFAULT_BANNER_VALID_BID); + const requests = spec.buildRequests(validBids, DEFAULT_OPTION); + const { dfp_ad_unit_code } = JSON.parse(requests[0].data.r).imp[0].ext; + + expect(dfp_ad_unit_code).to.not.exist; + }); + it('payload should have correct format and value', function () { const payload = JSON.parse(query.r); expect(payload.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidderRequestId); From 6f81c1617aaa44ec68670887d8bd0fb032f720b1 Mon Sep 17 00:00:00 2001 From: asurovenko-zeta <80847074+asurovenko-zeta@users.noreply.github.com> Date: Fri, 28 May 2021 21:59:12 +0600 Subject: [PATCH 255/303] Zeta Ssp Bid Adapter: support for eids (#6819) --- modules/zetaSspBidAdapter.js | 9 +++++- test/spec/modules/zetaSspBidAdapter_spec.js | 34 +++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/modules/zetaSspBidAdapter.js b/modules/zetaSspBidAdapter.js index 258478b0886..c956df55a1f 100644 --- a/modules/zetaSspBidAdapter.js +++ b/modules/zetaSspBidAdapter.js @@ -43,7 +43,7 @@ export const spec = { const secure = 1; // treat all requests as secure const request = validBidRequests[0]; const params = request.params; - let impData = { + const impData = { id: request.bidId, secure: secure, banner: buildBanner(request) @@ -84,6 +84,7 @@ export const spec = { } }; } + provideEids(request, payload); return { method: 'POST', url: ENDPOINT_URL, @@ -172,4 +173,10 @@ function buildBanner(request) { }; } +function provideEids(request, payload) { + if (Array.isArray(request.userIdAsEids) && request.userIdAsEids.length > 0) { + utils.deepSetValue(payload, 'user.ext.eids', request.userIdAsEids); + } +} + registerBidder(spec); diff --git a/test/spec/modules/zetaSspBidAdapter_spec.js b/test/spec/modules/zetaSspBidAdapter_spec.js index 2766632f707..4602e2d2b77 100644 --- a/test/spec/modules/zetaSspBidAdapter_spec.js +++ b/test/spec/modules/zetaSspBidAdapter_spec.js @@ -1,6 +1,29 @@ import {spec} from '../../../modules/zetaSspBidAdapter.js' -describe('Zeta Ssp Bid Adapter', function () { +describe('Zeta Ssp Bid Adapter', function() { + const eids = [ + { + 'source': 'example.com', + 'uids': [ + { + 'id': 'someId1', + 'atype': 1 + }, + { + 'id': 'someId2', + 'atype': 1 + }, + { + 'id': 'someId3', + 'atype': 2 + } + ], + 'ext': { + 'foo': 'bar' + } + } + ]; + const bannerRequest = [{ bidId: 12345, auctionId: 67890, @@ -23,7 +46,8 @@ describe('Zeta Ssp Bid Adapter', function () { sid: 'publisherId' }, test: 1 - } + }, + userIdAsEids: eids }]; it('Test the bid validation function', function () { @@ -34,6 +58,12 @@ describe('Zeta Ssp Bid Adapter', function () { expect(invalidBid).to.be.false; }); + it('Test provide eids', function () { + const request = spec.buildRequests(bannerRequest, bannerRequest[0]); + const payload = JSON.parse(request.data); + expect(payload.user.ext.eids).to.eql(eids); + }); + it('Test the request processing function', function () { const request = spec.buildRequests(bannerRequest, bannerRequest[0]); expect(request).to.not.be.empty; From 983d8a9d7aa315b5a4ca01ca5a744375e9b26d14 Mon Sep 17 00:00:00 2001 From: Andrzej Michnowski Date: Fri, 28 May 2021 18:38:11 +0200 Subject: [PATCH 256/303] Adocean Bid Adapter: add meta.advertiserDomains to bid response (#6872) * AdOcean adapter - support for multiple sizes * AdOcean adapter - tests - use normal functions instead of arrow ones for consistency * AdOcean adapter - support for multiple sizes - changed way of sending dimensions * AdOcean adapter - change separator between sizes group * AdOcean adapter - small fix in buildRequest * AdOcean adapter - support advertiserDomains * AdOcean adapter - add advertiserDomains default value Co-authored-by: Marcin Muras Co-authored-by: Andrzej Michnowski --- modules/adoceanBidAdapter.js | 5 ++++- test/spec/modules/adoceanBidAdapter_spec.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/adoceanBidAdapter.js b/modules/adoceanBidAdapter.js index b75d1972f5a..7ce9c7ae8f2 100644 --- a/modules/adoceanBidAdapter.js +++ b/modules/adoceanBidAdapter.js @@ -80,7 +80,10 @@ function interpretResponse(placementResponse, bidRequest, bids) { width: parseInt(placementResponse.width, 10), netRevenue: false, ttl: parseInt(placementResponse.ttl), - creativeId: placementResponse.crid + creativeId: placementResponse.crid, + meta: { + advertiserDomains: placementResponse.adomain || [] + } }; bids.push(bid); diff --git a/test/spec/modules/adoceanBidAdapter_spec.js b/test/spec/modules/adoceanBidAdapter_spec.js index 2b4b7d711e1..43316cd7483 100644 --- a/test/spec/modules/adoceanBidAdapter_spec.js +++ b/test/spec/modules/adoceanBidAdapter_spec.js @@ -150,7 +150,8 @@ describe('AdoceanAdapter', function () { 'width': '300', 'height': '250', 'crid': '0af345b42983cc4bc0', - 'ttl': '300' + 'ttl': '300', + 'adomain': ['adocean.pl'] } ], 'headers': { @@ -186,7 +187,10 @@ describe('AdoceanAdapter', function () { 'ad': '', 'creativeId': '0af345b42983cc4bc0', 'ttl': 300, - 'netRevenue': false + 'netRevenue': false, + 'meta': { + 'advertiserDomains': ['adocean.pl'] + } } ]; @@ -197,6 +201,8 @@ describe('AdoceanAdapter', function () { resultKeys.forEach(function(k) { if (k === 'ad') { expect(result[0][k]).to.match(/$/); + } else if (k === 'meta') { + expect(result[0][k]).to.deep.equal(expectedResponse[0][k]); } else { expect(result[0][k]).to.equal(expectedResponse[0][k]); } From 00b1afac40647fd61d608032d37eaf8ee3160936 Mon Sep 17 00:00:00 2001 From: redaguermas Date: Fri, 28 May 2021 11:58:29 -0700 Subject: [PATCH 257/303] No Bid Adapter: added bidResponse.meta and advertiserDomains (#6862) * Enable supplyChain support * Added support for COPPA * rebuilt * Added support for Extended User IDs. * Added support for the "meta" attribute in bid response. * Removed IDE files. Co-authored-by: Reda Guermas --- modules/nobidBidAdapter.js | 5 ++- test/spec/modules/nobidBidAdapter_spec.js | 53 ++++++++++++++++++++--- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/modules/nobidBidAdapter.js b/modules/nobidBidAdapter.js index 051202cab97..3aabd8f0635 100644 --- a/modules/nobidBidAdapter.js +++ b/modules/nobidBidAdapter.js @@ -6,7 +6,7 @@ import { getStorageManager } from '../src/storageManager.js'; const storage = getStorageManager(); const BIDDER_CODE = 'nobid'; -window.nobidVersion = '1.2.9'; +window.nobidVersion = '1.3.0'; window.nobid = window.nobid || {}; window.nobid.bidResponses = window.nobid.bidResponses || {}; window.nobid.timeoutTotal = 0; @@ -298,6 +298,9 @@ function nobidInterpretResponse(response, bidRequest) { if (bid.videoCacheKey) { bidResponse.videoCacheKey = bid.videoCacheKey; } + if (bid.meta) { + bidResponse.meta = bid.meta; + } bidResponses.push(bidResponse); } diff --git a/test/spec/modules/nobidBidAdapter_spec.js b/test/spec/modules/nobidBidAdapter_spec.js index 8dc15fbc89e..c44b0ce3fc2 100644 --- a/test/spec/modules/nobidBidAdapter_spec.js +++ b/test/spec/modules/nobidBidAdapter_spec.js @@ -257,12 +257,12 @@ describe('Nobid Adapter', function () { 'uids': [ { 'id': 'ID5_ID', - 'atype': 1, - 'ext': { - 'linkType': 0 - } + 'atype': 1 } - ] + ], + 'ext': { + 'linkType': 0 + } }, { 'source': 'adserver.org', @@ -284,7 +284,7 @@ describe('Nobid Adapter', function () { refererInfo: {referer: REFERER} } - it('should get user ids from eids', function () { + it('should criteo eid', function () { const request = spec.buildRequests(bidRequests, bidderRequest); const payload = JSON.parse(request.data); expect(payload.sid).to.exist.and.to.equal(2); @@ -598,6 +598,47 @@ describe('Nobid Adapter', function () { }); }); + describe('interpretResponseWithMeta', function () { + const CREATIVE_ID_300x250 = 'CREATIVE-100'; + const ADUNIT_300x250 = 'ADUNIT-1'; + const ADMARKUP_300x250 = 'ADMARKUP-300x250'; + const PRICE_300x250 = 0.51; + const REQUEST_ID = '3db3773286ee59'; + const DEAL_ID = 'deal123'; + const ADOMAINS = ['adomain1', 'adomain2']; + let response = { + country: 'US', + ip: '68.83.15.75', + device: 'COMPUTER', + site: 2, + bids: [ + {id: 1, + bdrid: 101, + divid: ADUNIT_300x250, + dealid: DEAL_ID, + creativeid: CREATIVE_ID_300x250, + size: {'w': 300, 'h': 250}, + adm: ADMARKUP_300x250, + price: '' + PRICE_300x250, + meta: { + advertiserDomains: ADOMAINS + } + } + ] + }; + + it('should meta.advertiserDomains be respected', function () { + let bidderRequest = { + bids: [{ + bidId: REQUEST_ID, + adUnitCode: ADUNIT_300x250 + }] + } + let result = spec.interpretResponse({ body: response }, {bidderRequest: bidderRequest}); + expect(result[0].meta.advertiserDomains).to.equal(ADOMAINS); + }); + }); + describe('buildRequestsWithSupplyChain', function () { const SITE_ID = 2; let bidRequests = [ From 2bd62fa41d91460ec3734ecc8a07f7a8fb4c6847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandr=20=C5=A0t=C5=A1epelin?= Date: Sat, 29 May 2021 14:26:00 +0300 Subject: [PATCH 258/303] add meta.advertiserDomains and meta.mediaType to bid response (#6875) --- modules/cointrafficBidAdapter.js | 6 ++++- .../modules/cointrafficBidAdapter_spec.js | 24 +++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/modules/cointrafficBidAdapter.js b/modules/cointrafficBidAdapter.js index 43f5cc01ccf..a6241980e06 100644 --- a/modules/cointrafficBidAdapter.js +++ b/modules/cointrafficBidAdapter.js @@ -85,7 +85,11 @@ export const spec = { height: response.height, creativeId: response.creativeId, ttl: response.ttl, - ad: response.ad + ad: response.ad, + meta: { + advertiserDomains: response.adomain && response.adomain.length ? response.adomain : [], + mediaType: response.mediaType + } }; bidResponses.push(bidResponse); diff --git a/test/spec/modules/cointrafficBidAdapter_spec.js b/test/spec/modules/cointrafficBidAdapter_spec.js index a2ce4cedea0..3755ddc4c4a 100644 --- a/test/spec/modules/cointrafficBidAdapter_spec.js +++ b/test/spec/modules/cointrafficBidAdapter_spec.js @@ -142,7 +142,9 @@ describe('cointrafficBidAdapter', function () { height: 250, creativeId: 'creativeId12345', ttl: 90, - ad: '

I am an ad

' + ad: '

I am an ad

', + mediaType: 'banner', + adomain: ['test.com'] } }; @@ -155,7 +157,13 @@ describe('cointrafficBidAdapter', function () { height: 250, creativeId: 'creativeId12345', ttl: 90, - ad: '

I am an ad

' + ad: '

I am an ad

', + meta: { + mediaType: 'banner', + advertiserDomains: [ + 'test.com', + ] + } }]; let result = spec.interpretResponse(serverResponse, bidRequest[0]); @@ -186,7 +194,9 @@ describe('cointrafficBidAdapter', function () { height: 250, creativeId: 'creativeId12345', ttl: 90, - ad: '

I am an ad

' + ad: '

I am an ad

', + mediaType: 'banner', + adomain: ['test.com'] } }; @@ -199,7 +209,13 @@ describe('cointrafficBidAdapter', function () { height: 250, creativeId: 'creativeId12345', ttl: 90, - ad: '

I am an ad

' + ad: '

I am an ad

', + meta: { + mediaType: 'banner', + advertiserDomains: [ + 'test.com', + ] + } }]; const getConfigStub = sinon.stub(config, 'getConfig').returns('USD'); From bf610f6074137a16fa6e1b6131bf9bac1b3f4943 Mon Sep 17 00:00:00 2001 From: Scott Menzer Date: Mon, 31 May 2021 09:17:49 +0200 Subject: [PATCH 259/303] Increment pre version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d4c6cd24181..6df9993806c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.41.0", + "version": "4.42.0-pre", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From e17f231032c31bd5fe1529c1e33e1398ecdf57aa Mon Sep 17 00:00:00 2001 From: arasaki-yuki <35788388+arasaki-yuki@users.noreply.github.com> Date: Mon, 31 May 2021 23:11:59 +0900 Subject: [PATCH 260/303] GMOSSP BidAdapter: add adomain support (#6877) --- modules/gmosspBidAdapter.js | 4 ++++ test/spec/modules/gmosspBidAdapter_spec.js | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/modules/gmosspBidAdapter.js b/modules/gmosspBidAdapter.js index 5eac4069b21..bf57e63d53c 100644 --- a/modules/gmosspBidAdapter.js +++ b/modules/gmosspBidAdapter.js @@ -94,6 +94,10 @@ export const spec = { ttl: res.ttl || 300 }; + if (res.adomains) { + utils.deepSetValue(bid, 'meta.advertiserDomains', Array.isArray(res.adomains) ? res.adomains : [res.adomains]); + } + return [bid]; }, diff --git a/test/spec/modules/gmosspBidAdapter_spec.js b/test/spec/modules/gmosspBidAdapter_spec.js index 52bb8460caa..d29e27554c2 100644 --- a/test/spec/modules/gmosspBidAdapter_spec.js +++ b/test/spec/modules/gmosspBidAdapter_spec.js @@ -106,6 +106,9 @@ describe('GmosspAdapter', function () { price: 20, w: 300, h: 250, + adomains: [ + 'test.com' + ], ad: '
', creativeId: '985ec572b32be309.76973017', cur: 'JPY', @@ -126,6 +129,11 @@ describe('GmosspAdapter', function () { currency: 'JPY', width: 300, height: 250, + meta: { + advertiserDomains: [ + 'test.com' + ] + }, ad: '
', creativeId: '985ec572b32be309.76973017', netRevenue: true, From 262e27c0ba0469ee415d75c2ffa54e81513eb15a Mon Sep 17 00:00:00 2001 From: Junus Date: Mon, 31 May 2021 20:13:58 +0600 Subject: [PATCH 261/303] A4G Bid Adapter: add meta adomain (#6878) * A4G adapter: add meta.advertiserDomains * added another test --- modules/a4gBidAdapter.js | 5 ++++- test/spec/modules/a4gBidAdapter_spec.js | 22 +++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/modules/a4gBidAdapter.js b/modules/a4gBidAdapter.js index 1961dba1f10..01c59616dc0 100644 --- a/modules/a4gBidAdapter.js +++ b/modules/a4gBidAdapter.js @@ -77,7 +77,10 @@ export const spec = { currency: A4G_CURRENCY, netRevenue: true, ttl: A4G_TTL, - ad: response.ad + ad: response.ad, + meta: { + advertiserDomains: response.adomain && response.adomain.length > 0 ? response.adomain : [] + } }; bidResponses.push(bidResponse); } diff --git a/test/spec/modules/a4gBidAdapter_spec.js b/test/spec/modules/a4gBidAdapter_spec.js index cb05fa62ab6..a9ead9fd021 100644 --- a/test/spec/modules/a4gBidAdapter_spec.js +++ b/test/spec/modules/a4gBidAdapter_spec.js @@ -161,7 +161,11 @@ describe('a4gAdapterTests', function () { ad: 'test ad', currency: 'USD', ttl: 120, - netRevenue: true + netRevenue: true, + meta: { + advertiserDomains: [] + } + } ]; const result = spec.interpretResponse(bidResponse, bidRequest); @@ -181,7 +185,10 @@ describe('a4gAdapterTests', function () { ad: 'test ad', currency: 'USD', ttl: 120, - netRevenue: true + netRevenue: true, + meta: { + advertiserDomains: [] + } } ]; const result = spec.interpretResponse(bidResponseWithoutCrid, bidRequest); @@ -201,7 +208,8 @@ describe('a4gAdapterTests', function () { 'currency', 'netRevenue', 'ttl', - 'ad' + 'ad', + 'meta' ]; let resultKeys = Object.keys(result[0]); @@ -215,5 +223,13 @@ describe('a4gAdapterTests', function () { expect(result[0].requestId).to.not.equal(result[0].adId); }) + + it('advertiserDomains is included when sent by server', function () { + bidResponse.body[0].adomain = ['test_adomain']; + let response = spec.interpretResponse(bidResponse, bidRequest); + expect(Object.keys(response[0].meta)).to.include.members(['advertiserDomains']); + expect(response[0].meta.advertiserDomains).to.deep.equal(['test_adomain']); + delete bidResponse.body[0].adomain; + }); }); }); From 8183e8500ee37c8445ae68949326741a4b3eb233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rok=20Su=C5=A1nik?= Date: Mon, 31 May 2021 16:17:38 +0200 Subject: [PATCH 262/303] add pbjs version to bid request (#6879) --- modules/outbrainBidAdapter.js | 8 ++++++++ test/spec/modules/outbrainBidAdapter_spec.js | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/outbrainBidAdapter.js b/modules/outbrainBidAdapter.js index c0af09c2b50..052122e95f1 100644 --- a/modules/outbrainBidAdapter.js +++ b/modules/outbrainBidAdapter.js @@ -79,6 +79,14 @@ export const spec = { imp: imps, bcat: bcat, badv: badv, + ext: { + prebid: { + channel: { + name: 'pbjs', + version: '$prebid.version$' + } + } + } }; if (test) { diff --git a/test/spec/modules/outbrainBidAdapter_spec.js b/test/spec/modules/outbrainBidAdapter_spec.js index 4bdd657f419..a5f23240a7c 100644 --- a/test/spec/modules/outbrainBidAdapter_spec.js +++ b/test/spec/modules/outbrainBidAdapter_spec.js @@ -204,7 +204,14 @@ describe('Outbrain Adapter', function () { request: JSON.stringify(expectedNativeAssets) } } - ] + ], + ext: { + prebid: { + channel: { + name: 'pbjs', version: '$prebid.version$' + } + } + } } const res = spec.buildRequests([bidRequest], commonBidderRequest) expect(res.url).to.equal('https://bidder-url.com') @@ -244,7 +251,14 @@ describe('Outbrain Adapter', function () { ] } } - ] + ], + ext: { + prebid: { + channel: { + name: 'pbjs', version: '$prebid.version$' + } + } + } } const res = spec.buildRequests([bidRequest], commonBidderRequest) expect(res.url).to.equal('https://bidder-url.com') From 10fc2a4be963b63917eb5ccd04ebf96b80a0df74 Mon Sep 17 00:00:00 2001 From: PWyrembak Date: Mon, 31 May 2021 18:56:40 +0300 Subject: [PATCH 263/303] TrustX Bid Adapter: meta.advertiserDomains support (#6891) * Add trustx adapter and tests for it * update integration example * Update trustx adapter * Post-review fixes of Trustx adapter * Code improvement for trustx adapter: changed default price type from gross to net * Update TrustX adapter to support the 1.0 version * Make requested changes for TrustX adapter * Updated markdown file for TrustX adapter * Fix TrustX adapter and spec file * Update TrustX adapter: r parameter was added to ad request as cache buster * Add support of gdpr to Trustx Bid Adapter * Add wtimeout to ad request params for TrustX Bid Adapter * TrustX Bid Adapter: remove last ampersand in the ad request * Update TrustX Bid Adapter to support identical uids in parameters * Update TrustX Bid Adapter to ignore bids that sizes do not match the size of the request * Update TrustX Bid Adapter to support instream and outstream video * Added wrapperType and wrapperVersion parameters in ad request for TrustX Bid Adapter * Update TrustX Bid Adapter to use refererInfo instead depricated function utils.getTopWindowUrl * HOTFIX for referrer encodind in TrustX Bid Adapter * Fix test for TrustX Bid Adapter * TrustX Bid Adapter: added keywords passing support * TrustX Bid Adapter: added us_privacy parameter in bid request * TrustX Bid Adapter: fix us_privacy parameter in bid request * Fix alias error for TrustX Bid Adapter * TrustX Bid Adapter: added new request format * TrustX Bid adapter: fix new format endpoint * TrustX Bid Adapter: update md file to support useNewFormat parameter * TrustX Bid Adapter: added additional sync url * TrustX Bid Adapter: added check for enabled syncs number + added gdpr data to sync urls * TrustX Bid Adapter: added support of meta.advertiserDomains --- modules/trustxBidAdapter.js | 5 ++- test/spec/modules/trustxBidAdapter_spec.js | 44 +++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/modules/trustxBidAdapter.js b/modules/trustxBidAdapter.js index 9f8de30a0d4..247a1f6d048 100644 --- a/modules/trustxBidAdapter.js +++ b/modules/trustxBidAdapter.js @@ -179,7 +179,10 @@ function _addBidResponse(serverBid, bidRequest, bidResponses, RendererConst) { currency: 'USD', netRevenue: newFormat ? false : priceType !== 'gross', ttl: TIME_TO_LIVE, - dealId: serverBid.dealid + dealId: serverBid.dealid, + meta: { + advertiserDomains: serverBid.adomain ? serverBid.adomain : [] + }, }; if (serverBid.content_type === 'video') { bidResponse.vastXml = serverBid.adm; diff --git a/test/spec/modules/trustxBidAdapter_spec.js b/test/spec/modules/trustxBidAdapter_spec.js index c0155f87ab6..f53116f60a4 100644 --- a/test/spec/modules/trustxBidAdapter_spec.js +++ b/test/spec/modules/trustxBidAdapter_spec.js @@ -661,7 +661,7 @@ describe('TrustXAdapter', function () { describe('interpretResponse', function () { const responses = [ - {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 43, 'h': 250, 'w': 300}], 'seat': '1'}, + {'bid': [{'price': 1.15, 'adm': '
test content 1
', 'auid': 43, 'h': 250, 'w': 300, 'adomain': ['somedomain.com']}], 'seat': '1'}, {'bid': [{'price': 0.5, 'adm': '
test content 2
', 'auid': 44, 'h': 600, 'w': 300}], 'seat': '1'}, {'bid': [{'price': 0.15, 'adm': '
test content 3
', 'auid': 43, 'h': 90, 'w': 728}], 'seat': '1'}, {'bid': [{'price': 0, 'auid': 45, 'h': 250, 'w': 300}], 'seat': '1'}, @@ -699,6 +699,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'banner', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': ['somedomain.com'] + }, } ]; @@ -756,6 +759,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'banner', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': ['somedomain.com'] + }, }, { 'requestId': '4dff80cc4ee346', @@ -769,6 +775,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'banner', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, }, { 'requestId': '5703af74d0472a', @@ -782,6 +791,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'banner', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, } ]; @@ -909,6 +921,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'banner', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, }, { 'requestId': '4e111f1b66e4', @@ -922,6 +937,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'banner', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, }, { 'requestId': '26d6f897b516', @@ -935,6 +953,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'banner', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, }, { 'requestId': '326bde7fbf69', @@ -948,6 +969,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'banner', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, } ]; @@ -1009,6 +1033,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'banner', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, }, { 'requestId': '57b2ebe70e16', @@ -1022,6 +1049,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'banner', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, } ]; @@ -1082,6 +1112,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'video', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, 'vastXml': '\n<\/Ad>\n<\/VAST>', 'adResponse': { 'content': '\n<\/Ad>\n<\/VAST>' @@ -1161,6 +1194,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'video', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, 'vastXml': '\n<\/Ad>\n<\/VAST>', 'adResponse': { 'content': '\n<\/Ad>\n<\/VAST>' @@ -1178,6 +1214,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'video', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, 'vastXml': '\n<\/Ad>\n<\/VAST>', 'adResponse': { 'content': '\n<\/Ad>\n<\/VAST>' @@ -1195,6 +1234,9 @@ describe('TrustXAdapter', function () { 'mediaType': 'video', 'netRevenue': true, 'ttl': 360, + 'meta': { + 'advertiserDomains': [] + }, 'vastXml': '\n<\/Ad>\n<\/VAST>', 'adResponse': { 'content': '\n<\/Ad>\n<\/VAST>' From 6be24d483e415dee4bdfd145803d2cb4510273dc Mon Sep 17 00:00:00 2001 From: Denis Logachov Date: Mon, 31 May 2021 19:17:47 +0300 Subject: [PATCH 264/303] Adkernel: denakop alias (#6886) --- modules/adkernelBidAdapter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/adkernelBidAdapter.js b/modules/adkernelBidAdapter.js index e4b04a27d42..b18b2333bac 100644 --- a/modules/adkernelBidAdapter.js +++ b/modules/adkernelBidAdapter.js @@ -68,7 +68,8 @@ export const spec = { {code: 'bcm'}, {code: 'engageadx'}, {code: 'converge_digital', gvlid: 248}, - {code: 'adomega'} + {code: 'adomega'}, + {code: 'denakop'} ], supportedMediaTypes: [BANNER, VIDEO, NATIVE], From 59b0fc9c033a4c97fc01e6859a0d6c2a9d69e77e Mon Sep 17 00:00:00 2001 From: mediaconsortium-develop <76139568+mediaconsortium-develop@users.noreply.github.com> Date: Tue, 1 Jun 2021 01:58:48 +0900 Subject: [PATCH 265/303] Digital Garage RTD module: new rtd submodule #6410 (#6847) * re-open pull request reference #6410 * delete Overview --- modules/.submodules.json | 1 + modules/dgkeywordRtdProvider.js | 132 +++++++ modules/dgkeywordRtdProvider.md | 29 ++ .../spec/modules/dgkeywordRtdProvider_spec.js | 326 ++++++++++++++++++ 4 files changed, 488 insertions(+) create mode 100644 modules/dgkeywordRtdProvider.js create mode 100644 modules/dgkeywordRtdProvider.md create mode 100644 test/spec/modules/dgkeywordRtdProvider_spec.js diff --git a/modules/.submodules.json b/modules/.submodules.json index 0a10044a78e..74ebc021a6d 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -36,6 +36,7 @@ ], "rtdModule": [ "browsiRtdProvider", + "dgkeywordRtdProvider", "geoedgeRtdProvider", "haloRtdProvider", "jwplayerRtdProvider", diff --git a/modules/dgkeywordRtdProvider.js b/modules/dgkeywordRtdProvider.js new file mode 100644 index 00000000000..52fa9fd70c4 --- /dev/null +++ b/modules/dgkeywordRtdProvider.js @@ -0,0 +1,132 @@ +/** + * This module adds dgkeyword provider to the real time data module + * The {@link module:modules/realTimeData} module is required + * The module will get keywords from 1plux profile api. + * This module can work only with AppNexusBidAdapter. + * @module modules/dgkeywordProvider + * @requires module:modules/realTimeData + */ + +import * as utils from '../src/utils.js'; +import { ajax } from '../src/ajax.js'; +import { submodule } from '../src/hook.js'; +import { getGlobal } from '../src/prebidGlobal.js'; + +/** + * get keywords from api server. and set keywords. + * @param {Object} reqBidsConfigObj + * @param {function} callback + * @param {Object} moduleConfig + * @param {Object} userConsent + */ +export function getDgKeywordsAndSet(reqBidsConfigObj, callback, moduleConfig, userConsent) { + const URL = 'https://mediaconsortium.profiles.tagger.opecloud.com/api/v1?url='; + const PROFILE_TIMEOUT_MS = 1000; + const timeout = (moduleConfig && moduleConfig.params && moduleConfig.params.timeout && Number(moduleConfig.params.timeout) > 0) ? Number(moduleConfig.params.timeout) : PROFILE_TIMEOUT_MS; + const url = (moduleConfig && moduleConfig.params && moduleConfig.params.url) ? moduleConfig.params.url : URL + encodeURIComponent(window.location.href); + const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits; + let isFinish = false; + utils.logMessage('[dgkeyword sub module]', adUnits, timeout); + let setKeywordTargetBidders = getTargetBidderOfDgKeywords(adUnits); + if (setKeywordTargetBidders.length <= 0) { + utils.logMessage('[dgkeyword sub module] no dgkeyword targets.'); + callback(); + } else { + utils.logMessage('[dgkeyword sub module] dgkeyword targets:', setKeywordTargetBidders); + utils.logMessage('[dgkeyword sub module] get targets from profile api start.'); + ajax(url, { + success: function(response) { + const res = JSON.parse(response); + if (!isFinish) { + utils.logMessage('[dgkeyword sub module] get targets from profile api end.'); + if (res) { + let keywords = {}; + if (res['s'] != null && res['s'].length > 0) { + keywords['opeaud'] = res['s']; + } + if (res['t'] != null && res['t'].length > 0) { + keywords['opectx'] = res['t']; + } + if (Object.keys(keywords).length > 0) { + const targetBidKeys = {} + for (let bid of setKeywordTargetBidders) { + // set keywords to params + bid.params.keywords = keywords; + if (!targetBidKeys[bid.bidder]) { + targetBidKeys[bid.bidder] = true; + } + } + + // set keywrods to ortb2 + let addOrtb2 = {}; + utils.deepSetValue(addOrtb2, 'site.keywords', keywords); + utils.deepSetValue(addOrtb2, 'user.keywords', keywords); + const ortb2 = {ortb2: addOrtb2}; + getGlobal().setBidderConfig({ bidders: Object.keys(targetBidKeys), config: ortb2 }); + } + } + isFinish = true; + } + callback(); + }, + error: function(errorStatus) { + // error occur + utils.logError('[dgkeyword sub module] profile api access error.', errorStatus); + callback(); + } + }, null, { + withCredentials: true, + contentType: 'application/json', + }); + setTimeout(function () { + if (!isFinish) { + // profile api timeout + utils.logInfo('[dgkeyword sub module] profile api timeout. [timeout: ' + timeout + 'ms]'); + isFinish = true; + } + callback(); + }, timeout); + } +} + +/** + * get all bidder which hava {dgkeyword: true} in params + * @param {Object} adUnits + */ +export function getTargetBidderOfDgKeywords(adUnits) { + let setKeywordTargetBidders = []; + for (let adUnit of adUnits) { + for (let bid of adUnit.bids) { + if (bid.params && bid.params['dgkeyword'] === true) { + delete bid.params['dgkeyword']; + setKeywordTargetBidders.push(bid); + } + } + } + return setKeywordTargetBidders; +} + +/** @type {RtdSubmodule} */ +export const dgkeywordSubmodule = { + /** + * used to link submodule with realTimeData + * @type {string} + */ + name: 'dgkeyword', + /** + * get data and send back to realTimeData module + * @function + * @param {string[]} adUnitsCodes + */ + getBidRequestData: getDgKeywordsAndSet, + init: init, +}; + +function init(moduleConfig) { + return true; +} + +function registerSubModule() { + submodule('realTimeData', dgkeywordSubmodule); +} +registerSubModule(); diff --git a/modules/dgkeywordRtdProvider.md b/modules/dgkeywordRtdProvider.md new file mode 100644 index 00000000000..314475b45a8 --- /dev/null +++ b/modules/dgkeywordRtdProvider.md @@ -0,0 +1,29 @@ + ## Integration + +1) Compile the Digital Garage Keyword Module and Appnexus Bid Adapter into your Prebid build: + +``` +gulp build --modules="dgkeywordRtdProvider,appnexusBidAdapter,..." +``` + +2) Use `setConfig` to instruct Prebid.js to initilize the dgkeyword module, as specified below. + +## Configuration + +This module is configured as part of the `realTimeData.dataProviders` + +```javascript +var DGKEYWORD_TIMEOUT = 1000; +pbjs.setConfig({ + realTimeData: { + auctionDelay: DGKEYWORD_TIMEOUT, + dataProviders: [{ + name: 'dgkeyword', + waitForIt: true, + params: { + timeout: DGKEYWORD_TIMEOUT + } + }] + } +}); +``` diff --git a/test/spec/modules/dgkeywordRtdProvider_spec.js b/test/spec/modules/dgkeywordRtdProvider_spec.js new file mode 100644 index 00000000000..0fac92e5118 --- /dev/null +++ b/test/spec/modules/dgkeywordRtdProvider_spec.js @@ -0,0 +1,326 @@ +import * as dgRtd from 'modules/dgkeywordRtdProvider.js'; +import { cloneDeep } from 'lodash'; +import { server } from 'test/mocks/xhr.js'; +import { getGlobal } from 'src/prebidGlobal.js'; +import { config } from 'src/config.js'; + +const DG_GET_KEYWORDS_TIMEOUT = 1950; +const DEF_CONFIG = { + name: 'dgkeyword', + waitForIt: true, + params: { + timeout: DG_GET_KEYWORDS_TIMEOUT, + }, +}; +const DUMMY_RESPONSE_HEADER = {'Content-Type': 'application/json'}; +const DUMMY_RESPONSE = { s: ['s1', 's2'], t: ['t1', 't2'] }; +const SUCCESS_RESULT = { opeaud: ['s1', 's2'], opectx: ['t1', 't2'] }; +const SUCCESS_ORTB2 = { ortb2: { site: { keywords: SUCCESS_RESULT }, user: { keywords: SUCCESS_RESULT } } }; + +describe('Digital Garage Keyword Module', function () { + it('should init and return always true', function () { + expect(dgRtd.dgkeywordSubmodule.init()).to.equal(true); + }); + + describe('dgkeyword target test', function () { + it('should have no target', function () { + const adUnits_no_target = [ + { + code: 'code1', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999999, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999998, + dgkeyword: false, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999997, + }, + }, + ], + }, + { + code: 'code2', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999996, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999995, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999994, + }, + }, + ], + }, + ]; + expect(dgRtd.getTargetBidderOfDgKeywords(adUnits_no_target)).an('array') + .that.is.empty; + }); + it('should have targets', function () { + const adUnits_targets = [ + { + code: 'code1', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999999, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999998, + dgkeyword: true, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999997, + dgkeyword: false, + }, + }, + ], + }, + { + code: 'code2', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999996, + dgkeyword: true, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999995, + dgkeyword: 'aa', + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999994, + dgkeyword: true, + }, + }, + ], + }, + ]; + const targets = dgRtd.getTargetBidderOfDgKeywords(adUnits_targets); + expect(targets[0].bidder).to.be.equal('dg2'); + expect(targets[0].params.placementId).to.be.equal(99999998); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].bidder).to.be.equal('dg'); + expect(targets[1].params.placementId).to.be.equal(99999996); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + }); + }); + + describe('get profile.', function () { + const AD_UNITS = [ + { + code: 'code1', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999999, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999998, + dgkeyword: true, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999997, + dgkeyword: false, + }, + }, + ], + }, + { + code: 'code2', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999996, + dgkeyword: true, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999995, + dgkeyword: 'aa', + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999994, + }, + }, + ], + }, + ]; + it('should get profiles error(404).', function (done) { + let pdjs = getGlobal(); + pbjs.adUnits = cloneDeep(AD_UNITS); + let moduleConfig = cloneDeep(DEF_CONFIG); + dgRtd.getDgKeywordsAndSet( + pdjs, + () => { + let targets = pbjs.adUnits[0].bids; + expect(targets[1].bidder).to.be.equal('dg2'); + expect(targets[1].params.placementId).to.be.equal(99999998); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].params.keywords).to.be.an('undefined'); + targets = pbjs.adUnits[1].bids; + expect(targets[0].bidder).to.be.equal('dg'); + expect(targets[0].params.placementId).to.be.equal(99999996); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[0].params.keywords).to.be.an('undefined'); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].params.keywords).to.be.an('undefined'); + + expect(config.getBidderConfig()).to.be.deep.equal({}); + + done(); + }, + moduleConfig, + null + ); + const request = server.requests[0]; + request.respond(404); + }); + it('should get profiles timeout.', function (done) { + let pdjs = getGlobal(); + pbjs.adUnits = cloneDeep(AD_UNITS); + let moduleConfig = cloneDeep(DEF_CONFIG); + moduleConfig.params.timeout = 10; + dgRtd.getDgKeywordsAndSet( + pdjs, + () => { + let targets = pbjs.adUnits[0].bids; + expect(targets[1].bidder).to.be.equal('dg2'); + expect(targets[1].params.placementId).to.be.equal(99999998); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].params.keywords).to.be.an('undefined'); + targets = pbjs.adUnits[1].bids; + expect(targets[0].bidder).to.be.equal('dg'); + expect(targets[0].params.placementId).to.be.equal(99999996); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[0].params.keywords).to.be.an('undefined'); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].params.keywords).to.be.an('undefined'); + + expect(config.getBidderConfig()).to.be.deep.equal({}); + + done(); + }, + moduleConfig, + null + ); + setTimeout(() => { + const request = server.requests[0]; + if (request) { + request.respond(200, DUMMY_RESPONSE_HEADER, JSON.stringify(DUMMY_RESPONSE)); + } + }, 1000) + }); + it('should get profiles ok(200).', function (done) { + let pdjs = getGlobal(); + pbjs.adUnits = cloneDeep(AD_UNITS); + let moduleConfig = cloneDeep(DEF_CONFIG); + dgRtd.getDgKeywordsAndSet(pdjs, () => { + let targets = pbjs.adUnits[0].bids; + expect(targets[1].bidder).to.be.equal('dg2'); + expect(targets[1].params.placementId).to.be.equal(99999998); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].params.keywords).to.be.deep.equal(SUCCESS_RESULT); + targets = pbjs.adUnits[1].bids; + expect(targets[0].bidder).to.be.equal('dg'); + expect(targets[0].params.placementId).to.be.equal(99999996); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[0].params.keywords).to.be.deep.equal(SUCCESS_RESULT); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].params.keywords).to.be.an('undefined'); + + // expect(config.getBidderConfig()).to.be.deep.equal({ dg2: SUCCESS_ORTB2, dg: SUCCESS_ORTB2 }); + + done(); + }, moduleConfig, null); + const request = server.requests[0]; + request.respond(200, DUMMY_RESPONSE_HEADER, JSON.stringify(DUMMY_RESPONSE)); + }); + }); +}); From b5f15cf6a4e9e9f12d4b1a58a6a14635e9495755 Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Mon, 31 May 2021 12:26:04 -0700 Subject: [PATCH 266/303] Revert "Digital Garage RTD module: new rtd submodule #6410 (#6847)" (#6895) This reverts commit 59b0fc9c033a4c97fc01e6859a0d6c2a9d69e77e. --- modules/.submodules.json | 1 - modules/dgkeywordRtdProvider.js | 132 ------- modules/dgkeywordRtdProvider.md | 29 -- .../spec/modules/dgkeywordRtdProvider_spec.js | 326 ------------------ 4 files changed, 488 deletions(-) delete mode 100644 modules/dgkeywordRtdProvider.js delete mode 100644 modules/dgkeywordRtdProvider.md delete mode 100644 test/spec/modules/dgkeywordRtdProvider_spec.js diff --git a/modules/.submodules.json b/modules/.submodules.json index 74ebc021a6d..0a10044a78e 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -36,7 +36,6 @@ ], "rtdModule": [ "browsiRtdProvider", - "dgkeywordRtdProvider", "geoedgeRtdProvider", "haloRtdProvider", "jwplayerRtdProvider", diff --git a/modules/dgkeywordRtdProvider.js b/modules/dgkeywordRtdProvider.js deleted file mode 100644 index 52fa9fd70c4..00000000000 --- a/modules/dgkeywordRtdProvider.js +++ /dev/null @@ -1,132 +0,0 @@ -/** - * This module adds dgkeyword provider to the real time data module - * The {@link module:modules/realTimeData} module is required - * The module will get keywords from 1plux profile api. - * This module can work only with AppNexusBidAdapter. - * @module modules/dgkeywordProvider - * @requires module:modules/realTimeData - */ - -import * as utils from '../src/utils.js'; -import { ajax } from '../src/ajax.js'; -import { submodule } from '../src/hook.js'; -import { getGlobal } from '../src/prebidGlobal.js'; - -/** - * get keywords from api server. and set keywords. - * @param {Object} reqBidsConfigObj - * @param {function} callback - * @param {Object} moduleConfig - * @param {Object} userConsent - */ -export function getDgKeywordsAndSet(reqBidsConfigObj, callback, moduleConfig, userConsent) { - const URL = 'https://mediaconsortium.profiles.tagger.opecloud.com/api/v1?url='; - const PROFILE_TIMEOUT_MS = 1000; - const timeout = (moduleConfig && moduleConfig.params && moduleConfig.params.timeout && Number(moduleConfig.params.timeout) > 0) ? Number(moduleConfig.params.timeout) : PROFILE_TIMEOUT_MS; - const url = (moduleConfig && moduleConfig.params && moduleConfig.params.url) ? moduleConfig.params.url : URL + encodeURIComponent(window.location.href); - const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits; - let isFinish = false; - utils.logMessage('[dgkeyword sub module]', adUnits, timeout); - let setKeywordTargetBidders = getTargetBidderOfDgKeywords(adUnits); - if (setKeywordTargetBidders.length <= 0) { - utils.logMessage('[dgkeyword sub module] no dgkeyword targets.'); - callback(); - } else { - utils.logMessage('[dgkeyword sub module] dgkeyword targets:', setKeywordTargetBidders); - utils.logMessage('[dgkeyword sub module] get targets from profile api start.'); - ajax(url, { - success: function(response) { - const res = JSON.parse(response); - if (!isFinish) { - utils.logMessage('[dgkeyword sub module] get targets from profile api end.'); - if (res) { - let keywords = {}; - if (res['s'] != null && res['s'].length > 0) { - keywords['opeaud'] = res['s']; - } - if (res['t'] != null && res['t'].length > 0) { - keywords['opectx'] = res['t']; - } - if (Object.keys(keywords).length > 0) { - const targetBidKeys = {} - for (let bid of setKeywordTargetBidders) { - // set keywords to params - bid.params.keywords = keywords; - if (!targetBidKeys[bid.bidder]) { - targetBidKeys[bid.bidder] = true; - } - } - - // set keywrods to ortb2 - let addOrtb2 = {}; - utils.deepSetValue(addOrtb2, 'site.keywords', keywords); - utils.deepSetValue(addOrtb2, 'user.keywords', keywords); - const ortb2 = {ortb2: addOrtb2}; - getGlobal().setBidderConfig({ bidders: Object.keys(targetBidKeys), config: ortb2 }); - } - } - isFinish = true; - } - callback(); - }, - error: function(errorStatus) { - // error occur - utils.logError('[dgkeyword sub module] profile api access error.', errorStatus); - callback(); - } - }, null, { - withCredentials: true, - contentType: 'application/json', - }); - setTimeout(function () { - if (!isFinish) { - // profile api timeout - utils.logInfo('[dgkeyword sub module] profile api timeout. [timeout: ' + timeout + 'ms]'); - isFinish = true; - } - callback(); - }, timeout); - } -} - -/** - * get all bidder which hava {dgkeyword: true} in params - * @param {Object} adUnits - */ -export function getTargetBidderOfDgKeywords(adUnits) { - let setKeywordTargetBidders = []; - for (let adUnit of adUnits) { - for (let bid of adUnit.bids) { - if (bid.params && bid.params['dgkeyword'] === true) { - delete bid.params['dgkeyword']; - setKeywordTargetBidders.push(bid); - } - } - } - return setKeywordTargetBidders; -} - -/** @type {RtdSubmodule} */ -export const dgkeywordSubmodule = { - /** - * used to link submodule with realTimeData - * @type {string} - */ - name: 'dgkeyword', - /** - * get data and send back to realTimeData module - * @function - * @param {string[]} adUnitsCodes - */ - getBidRequestData: getDgKeywordsAndSet, - init: init, -}; - -function init(moduleConfig) { - return true; -} - -function registerSubModule() { - submodule('realTimeData', dgkeywordSubmodule); -} -registerSubModule(); diff --git a/modules/dgkeywordRtdProvider.md b/modules/dgkeywordRtdProvider.md deleted file mode 100644 index 314475b45a8..00000000000 --- a/modules/dgkeywordRtdProvider.md +++ /dev/null @@ -1,29 +0,0 @@ - ## Integration - -1) Compile the Digital Garage Keyword Module and Appnexus Bid Adapter into your Prebid build: - -``` -gulp build --modules="dgkeywordRtdProvider,appnexusBidAdapter,..." -``` - -2) Use `setConfig` to instruct Prebid.js to initilize the dgkeyword module, as specified below. - -## Configuration - -This module is configured as part of the `realTimeData.dataProviders` - -```javascript -var DGKEYWORD_TIMEOUT = 1000; -pbjs.setConfig({ - realTimeData: { - auctionDelay: DGKEYWORD_TIMEOUT, - dataProviders: [{ - name: 'dgkeyword', - waitForIt: true, - params: { - timeout: DGKEYWORD_TIMEOUT - } - }] - } -}); -``` diff --git a/test/spec/modules/dgkeywordRtdProvider_spec.js b/test/spec/modules/dgkeywordRtdProvider_spec.js deleted file mode 100644 index 0fac92e5118..00000000000 --- a/test/spec/modules/dgkeywordRtdProvider_spec.js +++ /dev/null @@ -1,326 +0,0 @@ -import * as dgRtd from 'modules/dgkeywordRtdProvider.js'; -import { cloneDeep } from 'lodash'; -import { server } from 'test/mocks/xhr.js'; -import { getGlobal } from 'src/prebidGlobal.js'; -import { config } from 'src/config.js'; - -const DG_GET_KEYWORDS_TIMEOUT = 1950; -const DEF_CONFIG = { - name: 'dgkeyword', - waitForIt: true, - params: { - timeout: DG_GET_KEYWORDS_TIMEOUT, - }, -}; -const DUMMY_RESPONSE_HEADER = {'Content-Type': 'application/json'}; -const DUMMY_RESPONSE = { s: ['s1', 's2'], t: ['t1', 't2'] }; -const SUCCESS_RESULT = { opeaud: ['s1', 's2'], opectx: ['t1', 't2'] }; -const SUCCESS_ORTB2 = { ortb2: { site: { keywords: SUCCESS_RESULT }, user: { keywords: SUCCESS_RESULT } } }; - -describe('Digital Garage Keyword Module', function () { - it('should init and return always true', function () { - expect(dgRtd.dgkeywordSubmodule.init()).to.equal(true); - }); - - describe('dgkeyword target test', function () { - it('should have no target', function () { - const adUnits_no_target = [ - { - code: 'code1', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999999, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999998, - dgkeyword: false, - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999997, - }, - }, - ], - }, - { - code: 'code2', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999996, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999995, - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999994, - }, - }, - ], - }, - ]; - expect(dgRtd.getTargetBidderOfDgKeywords(adUnits_no_target)).an('array') - .that.is.empty; - }); - it('should have targets', function () { - const adUnits_targets = [ - { - code: 'code1', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999999, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999998, - dgkeyword: true, - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999997, - dgkeyword: false, - }, - }, - ], - }, - { - code: 'code2', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999996, - dgkeyword: true, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999995, - dgkeyword: 'aa', - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999994, - dgkeyword: true, - }, - }, - ], - }, - ]; - const targets = dgRtd.getTargetBidderOfDgKeywords(adUnits_targets); - expect(targets[0].bidder).to.be.equal('dg2'); - expect(targets[0].params.placementId).to.be.equal(99999998); - expect(targets[0].params.dgkeyword).to.be.an('undefined'); - expect(targets[1].bidder).to.be.equal('dg'); - expect(targets[1].params.placementId).to.be.equal(99999996); - expect(targets[1].params.dgkeyword).to.be.an('undefined'); - expect(targets[2].bidder).to.be.equal('dg3'); - expect(targets[2].params.placementId).to.be.equal(99999994); - expect(targets[2].params.dgkeyword).to.be.an('undefined'); - }); - }); - - describe('get profile.', function () { - const AD_UNITS = [ - { - code: 'code1', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999999, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999998, - dgkeyword: true, - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999997, - dgkeyword: false, - }, - }, - ], - }, - { - code: 'code2', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'dg', - params: { - placementId: 99999996, - dgkeyword: true, - }, - }, - { - bidder: 'dg2', - params: { - placementId: 99999995, - dgkeyword: 'aa', - }, - }, - { - bidder: 'dg3', - params: { - placementId: 99999994, - }, - }, - ], - }, - ]; - it('should get profiles error(404).', function (done) { - let pdjs = getGlobal(); - pbjs.adUnits = cloneDeep(AD_UNITS); - let moduleConfig = cloneDeep(DEF_CONFIG); - dgRtd.getDgKeywordsAndSet( - pdjs, - () => { - let targets = pbjs.adUnits[0].bids; - expect(targets[1].bidder).to.be.equal('dg2'); - expect(targets[1].params.placementId).to.be.equal(99999998); - expect(targets[1].params.dgkeyword).to.be.an('undefined'); - expect(targets[1].params.keywords).to.be.an('undefined'); - targets = pbjs.adUnits[1].bids; - expect(targets[0].bidder).to.be.equal('dg'); - expect(targets[0].params.placementId).to.be.equal(99999996); - expect(targets[0].params.dgkeyword).to.be.an('undefined'); - expect(targets[0].params.keywords).to.be.an('undefined'); - expect(targets[2].bidder).to.be.equal('dg3'); - expect(targets[2].params.placementId).to.be.equal(99999994); - expect(targets[2].params.dgkeyword).to.be.an('undefined'); - expect(targets[2].params.keywords).to.be.an('undefined'); - - expect(config.getBidderConfig()).to.be.deep.equal({}); - - done(); - }, - moduleConfig, - null - ); - const request = server.requests[0]; - request.respond(404); - }); - it('should get profiles timeout.', function (done) { - let pdjs = getGlobal(); - pbjs.adUnits = cloneDeep(AD_UNITS); - let moduleConfig = cloneDeep(DEF_CONFIG); - moduleConfig.params.timeout = 10; - dgRtd.getDgKeywordsAndSet( - pdjs, - () => { - let targets = pbjs.adUnits[0].bids; - expect(targets[1].bidder).to.be.equal('dg2'); - expect(targets[1].params.placementId).to.be.equal(99999998); - expect(targets[1].params.dgkeyword).to.be.an('undefined'); - expect(targets[1].params.keywords).to.be.an('undefined'); - targets = pbjs.adUnits[1].bids; - expect(targets[0].bidder).to.be.equal('dg'); - expect(targets[0].params.placementId).to.be.equal(99999996); - expect(targets[0].params.dgkeyword).to.be.an('undefined'); - expect(targets[0].params.keywords).to.be.an('undefined'); - expect(targets[2].bidder).to.be.equal('dg3'); - expect(targets[2].params.placementId).to.be.equal(99999994); - expect(targets[2].params.dgkeyword).to.be.an('undefined'); - expect(targets[2].params.keywords).to.be.an('undefined'); - - expect(config.getBidderConfig()).to.be.deep.equal({}); - - done(); - }, - moduleConfig, - null - ); - setTimeout(() => { - const request = server.requests[0]; - if (request) { - request.respond(200, DUMMY_RESPONSE_HEADER, JSON.stringify(DUMMY_RESPONSE)); - } - }, 1000) - }); - it('should get profiles ok(200).', function (done) { - let pdjs = getGlobal(); - pbjs.adUnits = cloneDeep(AD_UNITS); - let moduleConfig = cloneDeep(DEF_CONFIG); - dgRtd.getDgKeywordsAndSet(pdjs, () => { - let targets = pbjs.adUnits[0].bids; - expect(targets[1].bidder).to.be.equal('dg2'); - expect(targets[1].params.placementId).to.be.equal(99999998); - expect(targets[1].params.dgkeyword).to.be.an('undefined'); - expect(targets[1].params.keywords).to.be.deep.equal(SUCCESS_RESULT); - targets = pbjs.adUnits[1].bids; - expect(targets[0].bidder).to.be.equal('dg'); - expect(targets[0].params.placementId).to.be.equal(99999996); - expect(targets[0].params.dgkeyword).to.be.an('undefined'); - expect(targets[0].params.keywords).to.be.deep.equal(SUCCESS_RESULT); - expect(targets[2].bidder).to.be.equal('dg3'); - expect(targets[2].params.placementId).to.be.equal(99999994); - expect(targets[2].params.dgkeyword).to.be.an('undefined'); - expect(targets[2].params.keywords).to.be.an('undefined'); - - // expect(config.getBidderConfig()).to.be.deep.equal({ dg2: SUCCESS_ORTB2, dg: SUCCESS_ORTB2 }); - - done(); - }, moduleConfig, null); - const request = server.requests[0]; - request.respond(200, DUMMY_RESPONSE_HEADER, JSON.stringify(DUMMY_RESPONSE)); - }); - }); -}); From 1fe48accb649eb0296c060a647a87b5e260b2b17 Mon Sep 17 00:00:00 2001 From: pro-nsk <32703851+pro-nsk@users.noreply.github.com> Date: Tue, 1 Jun 2021 02:30:44 +0700 Subject: [PATCH 267/303] Qwarry Bid Adapter: meta.advertiserDomains added (#6883) * qwarry bid adapter * formatting fixes * fix tests for qwarry * qwarry bid adapter * add header for qwarry bid adapter * bid requests fix * fix tests * response fix * fix tests for Qwarry bid adapter * add pos parameter to qwarry bid adapter * qwarryBidAdapter onBidWon hotfix * Change bidder endpoint url for Qwarry adapter * add referer JS detection * use bidderRequest.refererInfo * fix tests * GDPR consent string support * NPE fix * gdpr value added * merge master * gdpr value added * qwarry bid adapter: add tests * Qwarry bid adapter: remove gdpr field from request * qwarry bid adapter: add sizes * qwarry bid adapter: add sizes * added schain * added test for schain * added supporting of advertiserDomains * qwarry bid adapter: added meta.advertiserDomains Co-authored-by: Artem Kostritsa Co-authored-by: Alexander Kascheev Co-authored-by: Ekaterina Legostaeva --- modules/qwarryBidAdapter.js | 3 +++ test/spec/modules/qwarryBidAdapter_spec.js | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/qwarryBidAdapter.js b/modules/qwarryBidAdapter.js index a410c2fe163..c9a86f73910 100644 --- a/modules/qwarryBidAdapter.js +++ b/modules/qwarryBidAdapter.js @@ -75,6 +75,9 @@ export const spec = { bid.vastXml = bid.ad; } + bid.meta = {}; + bid.meta.advertiserDomains = bid.adomain || []; + bids.push(bid); }) diff --git a/test/spec/modules/qwarryBidAdapter_spec.js b/test/spec/modules/qwarryBidAdapter_spec.js index 6dbb983ea23..560206681ee 100644 --- a/test/spec/modules/qwarryBidAdapter_spec.js +++ b/test/spec/modules/qwarryBidAdapter_spec.js @@ -33,7 +33,8 @@ const BIDDER_BANNER_RESPONSE = { 'creativeId': 1, 'netRevenue': true, 'winUrl': 'http://test.com', - 'format': 'banner' + 'format': 'banner', + 'adomain': ['test.com'] }] } @@ -49,7 +50,8 @@ const BIDDER_VIDEO_RESPONSE = { 'creativeId': 2, 'netRevenue': true, 'winUrl': 'http://test.com', - 'format': 'video' + 'format': 'video', + 'adomain': ['test.com'] }] } @@ -119,6 +121,8 @@ describe('qwarryBidAdapter', function () { expect(result[0]).to.have.property('netRevenue').equal(true) expect(result[0]).to.have.property('winUrl').equal('http://test.com') expect(result[0]).to.have.property('format').equal('banner') + expect(result[0].meta).to.exist.property('advertiserDomains') + expect(result[0].meta).to.have.property('advertiserDomains').lengthOf(1) }) it('handles video request : should get correct bid response', function () { @@ -136,6 +140,8 @@ describe('qwarryBidAdapter', function () { expect(result[0]).to.have.property('winUrl').equal('http://test.com') expect(result[0]).to.have.property('format').equal('video') expect(result[0]).to.have.property('vastXml').equal('vast') + expect(result[0].meta).to.exist.property('advertiserDomains') + expect(result[0].meta).to.have.property('advertiserDomains').lengthOf(1) }) it('handles no bid response : should get empty array', function () { From 9859d199887501c4fccca1ff3b7d036b02466127 Mon Sep 17 00:00:00 2001 From: Rich Audience Date: Tue, 1 Jun 2021 11:43:17 +0200 Subject: [PATCH 268/303] Richaudience Bid Adapter: add adomain support (#6880) * RichaudienceBidAdapter Add adomine for Prebid 5.0 * new pull * new pull 2 * New Pull 3 * Add unit test * New push 1 * New push 2 Co-authored-by: sgimenez --- modules/richaudienceBidAdapter.js | 3 ++- test/spec/modules/richaudienceBidAdapter_spec.js | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index 5e2a5e1bff5..4b556e83236 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -97,7 +97,8 @@ export const spec = { netRevenue: response.netRevenue, currency: response.currency, ttl: response.ttl, - dealId: response.dealId, + meta: response.adomain, + dealId: response.dealId }; if (response.media_type === 'video') { diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 72410b71fb2..00ae55823b0 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -149,8 +149,8 @@ describe('Richaudience adapter tests', function () { netRevenue: true, currency: 'USD', ttl: 300, - dealId: 'dealId' - + dealId: 'dealId', + adomain: 'richaudience.com' } }; @@ -165,7 +165,8 @@ describe('Richaudience adapter tests', function () { currency: 'USD', ttl: 300, vastXML: '', - dealId: 'dealId' + dealId: 'dealId', + adomain: 'richaudience.com' } }; @@ -600,6 +601,7 @@ describe('Richaudience adapter tests', function () { expect(bid.currency).to.equal('USD'); expect(bid.ttl).to.equal(300); expect(bid.dealId).to.equal('dealId'); + expect(bid.meta).to.equal('richaudience.com'); }); it('no banner media response inestream', function () { @@ -628,6 +630,7 @@ describe('Richaudience adapter tests', function () { expect(bid.currency).to.equal('USD'); expect(bid.ttl).to.equal(300); expect(bid.dealId).to.equal('dealId'); + expect(bid.meta).to.equal('richaudience.com'); }); it('no banner media response outstream', function () { From 7d02e2f7d596fcb26186c4bdf185defbf5589e31 Mon Sep 17 00:00:00 2001 From: hybrid-ai <58724131+hybrid-ai@users.noreply.github.com> Date: Tue, 1 Jun 2021 13:18:13 +0300 Subject: [PATCH 269/303] Hybrid Bid Adapter: add placeholder for advertiserDomains support (#6885) * Add adomains stub. * Hybrid Bid Adapter: add unit test for advertiserDomains. Co-authored-by: Petrov Denis --- modules/hybridBidAdapter.js | 5 ++++- test/spec/modules/hybridBidAdapter_spec.js | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/hybridBidAdapter.js b/modules/hybridBidAdapter.js index e7281086a92..15f8acd824f 100644 --- a/modules/hybridBidAdapter.js +++ b/modules/hybridBidAdapter.js @@ -78,7 +78,10 @@ function buildBid(bidData) { creativeId: bidData.bidId, currency: bidData.currency, netRevenue: true, - ttl: TTL + ttl: TTL, + meta: { + advertiserDomains: bidData.advertiserDomains || [], + } }; if (bidData.placement === PLACEMENT_TYPE_VIDEO) { diff --git a/test/spec/modules/hybridBidAdapter_spec.js b/test/spec/modules/hybridBidAdapter_spec.js index d1899ef3d81..ffbc27293fb 100644 --- a/test/spec/modules/hybridBidAdapter_spec.js +++ b/test/spec/modules/hybridBidAdapter_spec.js @@ -255,7 +255,8 @@ describe('Hybrid.ai Adapter', function() { currency: 'USD', content: 'html', width: 100, - height: 100 + height: 100, + advertiserDomains: ['hybrid.ai'] } ] } @@ -269,6 +270,7 @@ describe('Hybrid.ai Adapter', function() { expect(bids[0].height).to.equal(100) expect(bids[0].currency).to.equal('USD') expect(bids[0].netRevenue).to.equal(true) + expect(bids[0].meta.advertiserDomains).to.deep.equal(['hybrid.ai']) expect(typeof bids[0].ad).to.equal('string') }) it('should return a In-Image bid', function() { From d7d5f62f9e3f14d0bf6aaed31c6f5c549fb30faa Mon Sep 17 00:00:00 2001 From: hybrid-ai <58724131+hybrid-ai@users.noreply.github.com> Date: Tue, 1 Jun 2021 13:27:07 +0300 Subject: [PATCH 270/303] Vox Bid Adapter: Add placeholder to pass advertiser domains (#6884) * Add stub to pass adomains. * Vox Bid Adapter: add unit test for advertiserDomains. Co-authored-by: Petrov Denis --- modules/voxBidAdapter.js | 5 ++++- test/spec/modules/voxBidAdapter_spec.js | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/voxBidAdapter.js b/modules/voxBidAdapter.js index 73df9bb8b9b..ba469c3c7ed 100644 --- a/modules/voxBidAdapter.js +++ b/modules/voxBidAdapter.js @@ -70,7 +70,10 @@ function buildBid(bidData) { netRevenue: true, mediaType: BANNER, ttl: TTL, - content: bidData.content + content: bidData.content, + meta: { + advertiserDomains: bidData.advertiserDomains || [], + } }; if (bidData.placement === 'video') { diff --git a/test/spec/modules/voxBidAdapter_spec.js b/test/spec/modules/voxBidAdapter_spec.js index c6221cba9e5..6906c7dbba4 100644 --- a/test/spec/modules/voxBidAdapter_spec.js +++ b/test/spec/modules/voxBidAdapter_spec.js @@ -243,7 +243,8 @@ describe('VOX Adapter', function() { content: 'html', width: 100, height: 100 - } + }, + advertiserDomains: ['voxexchange.io'] } ] } @@ -257,6 +258,7 @@ describe('VOX Adapter', function() { expect(bids[0].height).to.equal(100) expect(bids[0].currency).to.equal('USD') expect(bids[0].netRevenue).to.equal(true) + expect(bids[0].meta.advertiserDomains).to.deep.equal(['voxexchange.io']) expect(typeof bids[0].ad).to.equal('string') }) it('should return a In-Image bid', function() { From 5c9e149ecc83ccbda53673c0a1e4cf680766e56d Mon Sep 17 00:00:00 2001 From: rtuschkany <35923908+rtuschkany@users.noreply.github.com> Date: Tue, 1 Jun 2021 14:20:06 +0200 Subject: [PATCH 271/303] ConnectAd Bid-Adapter: Add adomain support (#6859) * ConnectAd bid adapter: Add adomain support Add adomain support * ConnectAd Bid-Adapter: Add adomain support fix * ConnectAd Bid-Adapter: Add adomain support * ConnectAd Bid-Adapter: Add adomain support test update --- modules/connectadBidAdapter.js | 1 + test/spec/modules/connectadBidAdapter_spec.js | 39 ++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/modules/connectadBidAdapter.js b/modules/connectadBidAdapter.js index 4fa2a56a004..111b6ac10e8 100644 --- a/modules/connectadBidAdapter.js +++ b/modules/connectadBidAdapter.js @@ -124,6 +124,7 @@ export const spec = { bid.width = decision.width; bid.height = decision.height; bid.dealid = decision.dealid || null; + bid.meta = { advertiserDomains: decision && decision.adomain ? decision.adomain : [] }; bid.ad = retrieveAd(decision); bid.currency = 'USD'; bid.creativeId = decision.adId; diff --git a/test/spec/modules/connectadBidAdapter_spec.js b/test/spec/modules/connectadBidAdapter_spec.js index dbac3c0dc7c..657bc432d06 100644 --- a/test/spec/modules/connectadBidAdapter_spec.js +++ b/test/spec/modules/connectadBidAdapter_spec.js @@ -303,7 +303,43 @@ describe('ConnectAd Adapter', function () { }); describe('bid responses', function () { - it('should return complete bid response', function () { + it('should return complete bid response with adomain', function () { + const ADOMAINS = ['connectad.io']; + + let serverResponse = { + body: { + decisions: { + '2f95c00074b931': { + adId: '0', + adomain: ['connectad.io'], + contents: [ + { + body: '<<<---- Creative --->>>' + } + ], + height: '250', + width: '300', + pricing: { + clearPrice: 11.899999999999999 + } + } + } + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const bids = spec.interpretResponse(serverResponse, request); + + expect(bids).to.be.lengthOf(1); + expect(bids[0].cpm).to.equal(11.899999999999999); + expect(bids[0].width).to.equal('300'); + expect(bids[0].height).to.equal('250'); + expect(bids[0].ad).to.have.length.above(1); + expect(bids[0].meta.advertiserDomains).to.deep.equal(ADOMAINS); + }); + + it('should return complete bid response with empty adomain', function () { + const ADOMAINS = []; + let serverResponse = { body: { decisions: { @@ -331,6 +367,7 @@ describe('ConnectAd Adapter', function () { expect(bids[0].width).to.equal('300'); expect(bids[0].height).to.equal('250'); expect(bids[0].ad).to.have.length.above(1); + expect(bids[0].meta.advertiserDomains).to.deep.equal(ADOMAINS); }); it('should return empty bid response', function () { From 4827f16e224813c338523b2f8e323e57abf28e27 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 1 Jun 2021 15:26:25 +0300 Subject: [PATCH 272/303] Aniview Bid Adapter: added meta.advertiserDomains to bidResponse and extended cookie sync logic (#6858) * Support new aniview bid adapter * Support new aniview bid adapter * Support new aniview bid adapter * Support new aniview bid adapter * Fix Consent parameters * Update aniviewBidAdapter.js V3 support * Update aniviewBidAdapter.js * Update aniviewBidAdapter.js Update refererInfo * Update aniviewBidAdapter.js Fix tabs and spaces * Update aniviewBidAdapter.js fixes * Update aniviewBidAdapter.js * Update aniviewBidAdapter.js Add ccpa support * Update aniviewBidAdapter.js Typo * Update aniviewBidAdapter.js * Update aniviewBidAdapter.js * Fix size and sample Fixed sizes from playerSize Updated md sample * Fix tabs * Fix sizes * Recheck * Add tgt parameter * Update sample * Add support for cookie sync + tests * Add support for cookie sync + tests * Add support for cookie sync + tests * Support aliases Support aliases * Update Update * Fix lint Fix lint * Update spec Update spec * Aniview Bid Adapter: Added the new alias * Aniview Bid Adapter: Added the new configs for the renderer * Aniview Bid Adapter: Added unit tests for the renderer * Aniview Bid Adapter: Have added gvlid * Aniview Bid Adapter: added meta.advertiserDomains to bidResponse and extended cookie sync logic Co-authored-by: Itay Nave Co-authored-by: Itay Nave <38345760+itaynave@users.noreply.github.com> --- modules/aniviewBidAdapter.js | 9 ++++++- test/spec/modules/aniviewBidAdapter_spec.js | 27 ++++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/modules/aniviewBidAdapter.js b/modules/aniviewBidAdapter.js index 6b83c40897e..b37d105da1a 100644 --- a/modules/aniviewBidAdapter.js +++ b/modules/aniviewBidAdapter.js @@ -201,6 +201,10 @@ function interpretResponse(serverResponse, bidRequest) { bidResponse.vastUrl = window.URL.createObjectURL(blob); bidResponse.vastXml = xmlStr; bidResponse.mediaType = VIDEO; + bidResponse.meta = { + advertiserDomains: [] + }; + if (bidRequest.bidRequest && bidRequest.bidRequest.mediaTypes && bidRequest.bidRequest.mediaTypes.video && bidRequest.bidRequest.mediaTypes.video.context === 'outstream') { bidResponse.renderer = newRenderer(bidRequest); } bidResponses.push(bidResponse); @@ -230,7 +234,10 @@ function getSyncData(xml, options) { if (data && data.trackers && data.trackers.length) { data = data.trackers; for (var j = 0; j < data.length; j++) { - if (typeof data[j] === 'object' && typeof data[j].url === 'string' && data[j].e === 'inventory') { + if (typeof data[j] === 'object' && + typeof data[j].url === 'string' && + (data[j].e === 'inventory' || data[j].e === 'sync') + ) { if (data[j].t == 1 && options.pixelEnabled) { ret.push({url: data[j].url, type: 'image'}); } else { diff --git a/test/spec/modules/aniviewBidAdapter_spec.js b/test/spec/modules/aniviewBidAdapter_spec.js index 2e1fdb56201..b6d63fc2a8e 100644 --- a/test/spec/modules/aniviewBidAdapter_spec.js +++ b/test/spec/modules/aniviewBidAdapter_spec.js @@ -160,6 +160,7 @@ describe('ANIVIEW Bid Adapter Test', function () { expect(bidResponse.currency).to.equal('USD'); expect(bidResponse.netRevenue).to.equal(true); expect(bidResponse.mediaType).to.equal('video'); + expect(bidResponse.meta.advertiserDomains).to.be.an('array').that.is.empty; }); it('safely handles XML parsing failure from invalid bid response', function () { @@ -207,12 +208,16 @@ describe('ANIVIEW Bid Adapter Test', function () { }); describe('getUserSyncs', function () { - it('Check get sync pixels from response', function () { - let pixelUrl = 'https://sync.pixel.url/sync'; + let pixelUrl = 'https://sync.pixel.url/sync'; + function createBidResponse (pixelEvent, pixelType) { + let pixelStr = '{"url":"' + pixelUrl + '", "e":"' + pixelEvent + '", "t":' + pixelType + '}'; + return 'FORDFORD00:00:15'; + } + + it('Check get iframe sync pixels from response on inventory', function () { let pixelEvent = 'inventory'; let pixelType = '3'; - let pixelStr = '{"url":"' + pixelUrl + '", "e":"' + pixelEvent + '", "t":' + pixelType + '}'; - let bidResponse = 'FORDFORD00:00:15'; + let bidResponse = createBidResponse(pixelEvent, pixelType); let serverResponse = [ {body: bidResponse} ]; @@ -222,5 +227,19 @@ describe('ANIVIEW Bid Adapter Test', function () { expect(pixel.url).to.equal(pixelUrl); expect(pixel.type).to.equal('iframe'); }); + + it('Check get image sync pixels from response on sync', function () { + let pixelEvent = 'sync'; + let pixelType = '1'; + let bidResponse = createBidResponse(pixelEvent, pixelType); + let serverResponse = [ + {body: bidResponse} + ]; + let syncPixels = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, serverResponse); + expect(syncPixels.length).to.equal(1); + let pixel = syncPixels[0]; + expect(pixel.url).to.equal(pixelUrl); + expect(pixel.type).to.equal('image'); + }); }); }); From d7a1418092fc087ecc8bd9679c257560ed338e4f Mon Sep 17 00:00:00 2001 From: hendrikiseke1979 <53309111+hendrikiseke1979@users.noreply.github.com> Date: Tue, 1 Jun 2021 15:02:02 +0200 Subject: [PATCH 273/303] OR Bid Adapter: add support for advertiserDomains and floors module (#6890) * orbidder adapter: add withCredentials:true header to BidRequest and onBidWon Requests * add blank in order to trigger build again * remove blank to trigger build ... again * adding extra line to trigger build ... again * add prebid version to request * add unit test for version parameter * add version parameter to win requests * fix comment * trigger rebuild * trigger rebuild * remove onBidWon callback from adapter * fix retrieving orbidder endpoint url from local storage * fix unit tests * use getBidFloor function for prebidv5 compatibility * fill meta.advertiserDomains from serverResponse.adomain for prebidv5 compatibility * drop eslint-disable * switch misleading expect and actual in unit test * cr: rename adomain to advertiserDomains * trigger build pipeline * trigger build pipeline Co-authored-by: Volk, Rainer Co-authored-by: RainerVolk4014 <53347752+RainerVolk4014@users.noreply.github.com> Co-authored-by: siggi-otto <57615762+siggi-otto@users.noreply.github.com> Co-authored-by: Hendrik Iseke <39734979+hiseke@users.noreply.github.com> Co-authored-by: Hendrik Iseke Co-authored-by: rvolk <> Co-authored-by: Arne Schulz --- modules/orbidderBidAdapter.js | 31 ++++++++++++++ test/spec/modules/orbidderBidAdapter_spec.js | 43 +++++++++++++++++++- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index e01746af487..4a7d686a7bc 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -1,5 +1,6 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import { getStorageManager } from '../src/storageManager.js'; +import * as utils from '../src/utils.js'; const storageManager = getStorageManager(); @@ -32,6 +33,8 @@ export const spec = { referer = bidderRequest.refererInfo.referer || ''; } + bidRequest.params.bidfloor = getBidFloor(bidRequest); + const ret = { url: `${hostname}/bid`, method: 'POST', @@ -70,6 +73,13 @@ export const spec = { } bidResponse[requiredKey] = bid[requiredKey]; } + + if (Array.isArray(bid.advertiserDomains)) { + bidResponse.meta = { + advertiserDomains: bid.advertiserDomains + } + } + bidResponses.push(bidResponse); }); } @@ -77,4 +87,25 @@ export const spec = { }, }; +/** + * Get bid floor from Price Floors Module + * @param {Object} bid + * @returns {float||undefined} + */ +function getBidFloor(bid) { + if (!utils.isFn(bid.getFloor)) { + return bid.params.bidfloor; + } + + const floor = bid.getFloor({ + currency: 'EUR', + mediaType: '*', + size: '*' + }); + if (utils.isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'EUR') { + return floor.floor; + } + return undefined; +} + registerBidder(spec); diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index df551311c0b..42cc25ae04f 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -104,7 +104,7 @@ describe('orbidderBidAdapter', () => { expect(request.data.pageUrl).to.equal('https://localhost:9876/'); // expect(request.data.referrer).to.equal(''); Object.keys(defaultBidRequest).forEach((key) => { - expect(defaultBidRequest[key]).to.equal(request.data[key]); + expect(request.data[key]).to.deep.equal(defaultBidRequest[key]); }); }); @@ -189,6 +189,47 @@ describe('orbidderBidAdapter', () => { }); }); + it('should get correct bid response with advertiserDomains', () => { + const serverResponse = [ + { + 'width': 300, + 'height': 250, + 'creativeId': '29681110', + 'ad': '', + 'cpm': 0.5, + 'requestId': '30b31c1838de1e', + 'ttl': 60, + 'netRevenue': true, + 'currency': 'EUR', + 'advertiserDomains': ['cm.tavira.pt'] + } + ]; + + const expectedResponse = [ + { + 'requestId': '30b31c1838de1e', + 'cpm': 0.5, + 'creativeId': '29681110', + 'width': 300, + 'height': 250, + 'ttl': 60, + 'currency': 'EUR', + 'ad': '', + 'netRevenue': true, + 'meta': { + 'advertiserDomains': ['cm.tavira.pt'] + } + } + ]; + + const result = spec.interpretResponse({body: serverResponse}); + + expect(result.length).to.equal(expectedResponse.length); + Object.keys(expectedResponse[0]).forEach((key) => { + expect(result[0][key]).to.deep.equal(expectedResponse[0][key]); + }); + }); + it('handles broken server response', () => { const serverResponse = [ { From d779cdc9a6a8baf43b559d740429d5b2da77f992 Mon Sep 17 00:00:00 2001 From: Denis Logachov Date: Tue, 1 Jun 2021 16:11:28 +0300 Subject: [PATCH 274/303] AdkernelAdn: meta fields support (#6899) --- modules/adkernelAdnBidAdapter.js | 30 +++++++++++++++++-- .../modules/adkernelAdnBidAdapter_spec.js | 19 ++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/modules/adkernelAdnBidAdapter.js b/modules/adkernelAdnBidAdapter.js index 0de750c773f..dc56ed6abbb 100644 --- a/modules/adkernelAdnBidAdapter.js +++ b/modules/adkernelAdnBidAdapter.js @@ -103,13 +103,17 @@ function buildBid(tag) { requestId: tag.impid, bidderCode: spec.code, cpm: tag.bid, - width: tag.w, - height: tag.h, creativeId: tag.crid, currency: 'USD', ttl: 720, netRevenue: true }; + if (tag.w) { + bid.width = tag.w; + } + if (tag.h) { + bid.height = tag.h; + } if (tag.tag) { bid.ad = tag.tag; bid.mediaType = BANNER; @@ -117,9 +121,31 @@ function buildBid(tag) { bid.vastUrl = tag.vast_url; bid.mediaType = VIDEO; } + fillBidMeta(bid, tag); return bid; } +function fillBidMeta(bid, tag) { + if (utils.isStr(tag.agencyName)) { + utils.deepSetValue(bid, 'meta.agencyName', tag.agencyName); + } + if (utils.isNumber(tag.advertiserId)) { + utils.deepSetValue(bid, 'meta.advertiserId', tag.advertiserId); + } + if (utils.isStr(tag.advertiserName)) { + utils.deepSetValue(bid, 'meta.advertiserName', tag.advertiserName); + } + if (utils.isArray(tag.advertiserDomains)) { + utils.deepSetValue(bid, 'meta.advertiserDomains', tag.advertiserDomains); + } + if (utils.isStr(tag.primaryCatId)) { + utils.deepSetValue(bid, 'meta.primaryCatId', tag.primaryCatId); + } + if (utils.isArray(tag.secondaryCatIds)) { + utils.deepSetValue(bid, 'meta.secondaryCatIds', tag.secondaryCatIds); + } +} + function getBidFloor(bid, mediaType, sizes) { var floor; var size = sizes.length === 1 ? sizes[0] : '*'; diff --git a/test/spec/modules/adkernelAdnBidAdapter_spec.js b/test/spec/modules/adkernelAdnBidAdapter_spec.js index d3c9a2cf816..c4ad134711a 100644 --- a/test/spec/modules/adkernelAdnBidAdapter_spec.js +++ b/test/spec/modules/adkernelAdnBidAdapter_spec.js @@ -107,7 +107,12 @@ describe('AdkernelAdn adapter', function () { bid: 5.0, tag: '', w: 300, - h: 250 + h: 250, + advertiserId: 777, + advertiserName: 'advertiser', + agencyName: 'agency', + advertiserDomains: ['example.com'], + primaryCatId: 'IAB1-1', }, { id: 'ad-unit-2', impid: '31d798477126c4', @@ -115,7 +120,12 @@ describe('AdkernelAdn adapter', function () { bid: 2.5, tag: '', w: 300, - h: 250 + h: 250, + advertiserId: 777, + advertiserName: 'advertiser', + agencyName: 'agency', + advertiserDomains: ['example.com'], + secondaryCatIds: ['IAB1-4', 'IAB8-16', 'IAB25-5'] }, { id: 'video_wrapper', impid: '57d602ad1c9545', @@ -375,6 +385,11 @@ describe('AdkernelAdn adapter', function () { expect(resp).to.have.property('mediaType', 'banner'); expect(resp).to.have.property('ad'); expect(resp.ad).to.have.string(''); + expect(resp.meta.advertiserId).to.be.eql(777); + expect(resp.meta.advertiserName).to.be.eql('advertiser'); + expect(resp.meta.agencyName).to.be.eql('agency'); + expect(resp.meta.advertiserDomains).to.be.eql(['example.com']); + expect(resp.meta.primaryCatId).to.be.eql('IAB1-1'); }); it('should return fully-initialized video bid-response', function () { From 1bc1427cb62cd3057eeb1e621107f70e148cad51 Mon Sep 17 00:00:00 2001 From: BrightMountainMedia <69471268+BrightMountainMediaInc@users.noreply.github.com> Date: Tue, 1 Jun 2021 18:44:12 +0530 Subject: [PATCH 275/303] BrightMountainMedia Bid Adapter: add floors module support (#6833) * Update BrightMountainMedia cookie sync URL * Bright Mountain Media: Update bidder code * Bright Mountain Media: Add brightmountainmedia as alias * Bright Mountain Media: Update Bid Endpoint * BrightMountainMedia Bid Adapter: add floors module support * BrightMountainMedia Bid Adapter: support advertiserDomains --- modules/brightMountainMediaBidAdapter.js | 36 +++++++++++++- .../brightMountainMediaBidAdapter_spec.js | 49 ++++++++++++++++++- 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/modules/brightMountainMediaBidAdapter.js b/modules/brightMountainMediaBidAdapter.js index 5539004bdcd..531238c7400 100644 --- a/modules/brightMountainMediaBidAdapter.js +++ b/modules/brightMountainMediaBidAdapter.js @@ -58,6 +58,7 @@ export const spec = { let placement = { placementId: bid.params.placement_id, bidId: bid.bidId, + floor: {}, }; if (bid.mediaTypes.hasOwnProperty(BANNER)) { @@ -87,6 +88,23 @@ export const spec = { placement['playbackmethod'] = bid.mediaTypes.video.playbackmethod; } } + + if (typeof bid.getFloor === 'function') { + let floorInfo = {}; + + for (let size of placement['sizes']) { + floorInfo = bid.getFloor({ + currency: 'USD', + mediaType: placement['traffic'], + size: size, + }); + + if (typeof floorInfo === 'object' && floorInfo.currency === 'USD') { + placement.floor[`${size[0]}x${size[1]}`] = parseFloat(floorInfo.floor); + } + } + } + if (bid.schain) { placement.schain = bid.schain; } @@ -105,10 +123,26 @@ export const spec = { if (response && Array.isArray(response) && response.length > 0) { for (let i = 0; i < response.length; i++) { if (response[i].cpm > 0) { + const tempResponse = { + requestId: response[i].requestId, + width: response[i].width, + height: response[i].height, + cpm: response[i].cpm, + mediaType: response[i].mediaType, + creativeId: response[i].creativeId, + currency: response[i].currency, + netRevenue: response[i].netRevenue, + ttl: response[i].ttl, + ad: response[i].ad, + meta: { + advertiserDomains: response[i].adomain && response[i].adomain.length ? response[i].adomain : [], + } + }; + if (response[i].mediaType && response[i].mediaType === 'video') { response[i].vastXml = response[i].ad; } - bidResponse.push(response[i]); + bidResponse.push(tempResponse); } } } diff --git a/test/spec/modules/brightMountainMediaBidAdapter_spec.js b/test/spec/modules/brightMountainMediaBidAdapter_spec.js index 6c7ef816f4f..17f23c5acd3 100644 --- a/test/spec/modules/brightMountainMediaBidAdapter_spec.js +++ b/test/spec/modules/brightMountainMediaBidAdapter_spec.js @@ -103,6 +103,48 @@ describe('brightMountainMediaBidAdapter_spec', function () { let serverRequest = spec.buildRequests([bidBanner], bidderRequest); testServerRequestBody(serverRequest); + it('sends bidfloor param if present', function () { + bidBanner.getFloor = function () { + return { + currency: 'USD', + floor: 0.5, + } + }; + const request = spec.buildRequests([bidBanner], bidderRequest); + expect(request.data.placements[0].floor['300x250']).to.equal(0.5); + }); + + it('sends gdpr info if exists', function () { + const gdprConsent = { + consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==', + gdprApplies: true + }; + + bidderRequest['gdprConsent'] = gdprConsent; + const request = spec.buildRequests([bidBanner], bidderRequest); + + expect(request.data.gdpr_require).to.exist.and.to.be.a('number'); + expect(request.data.gdpr_consent).to.exist.and.to.be.a('string'); + }); + + it('sends schain info if exists', function () { + const schain = { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'directseller.com', + sid: '00001', + rid: 'BidRequest1', + hp: 1 + } + ] + }; + bidBanner.schain = schain; + const request = spec.buildRequests([bidBanner], bidderRequest); + expect(request.data.placements[0].schain).to.be.an('object'); + }); + bidderRequest['bids'] = [bidVideo]; serverRequest = spec.buildRequests([bidVideo], bidderRequest); testServerRequestBody(serverRequest); @@ -129,6 +171,7 @@ describe('brightMountainMediaBidAdapter_spec', function () { expect(dataItem.netRevenue).to.be.a('boolean'); expect(dataItem.currency).to.be.a('string'); expect(dataItem.mediaType).to.be.a('string'); + expect(dataItem.meta.advertiserDomains[0]).to.be.a('string'); } }); } @@ -145,7 +188,8 @@ describe('brightMountainMediaBidAdapter_spec', function () { ttl: 1000, creativeId: '123asd', netRevenue: true, - currency: 'USD' + currency: 'USD', + adomain: ['adomain.com'], }] }; @@ -160,7 +204,8 @@ describe('brightMountainMediaBidAdapter_spec', function () { ttl: 1000, creativeId: '123asd', netRevenue: true, - currency: 'USD' + currency: 'USD', + adomain: ['adomain.com'], }] }; let serverResponses = spec.interpretResponse(resObjectBanner); From 7647b97f7a07412fc49f4cca5572efa741db8462 Mon Sep 17 00:00:00 2001 From: Olivier Date: Tue, 1 Jun 2021 15:18:09 +0200 Subject: [PATCH 276/303] AdagioBidAdapter: support priceFloors module (#6867) --- modules/adagioBidAdapter.js | 57 ++++++++++++++++- test/spec/modules/adagioBidAdapter_spec.js | 71 ++++++++++++++++++++++ 2 files changed, 125 insertions(+), 3 deletions(-) diff --git a/modules/adagioBidAdapter.js b/modules/adagioBidAdapter.js index aed1a1682dc..5598dc5d224 100644 --- a/modules/adagioBidAdapter.js +++ b/modules/adagioBidAdapter.js @@ -24,6 +24,8 @@ export const RENDERER_URL = 'https://script.4dex.io/outstream-player.js'; const MAX_SESS_DURATION = 30 * 60 * 1000; const ADAGIO_PUBKEY = 'AL16XT44Sfp+8SHVF1UdC7hydPSMVLMhsYknKDdwqq+0ToDSJrP0+Qh0ki9JJI2uYm/6VEYo8TJED9WfMkiJ4vf02CW3RvSWwc35bif2SK1L8Nn/GfFYr/2/GG/Rm0vUsv+vBHky6nuuYls20Og0HDhMgaOlXoQ/cxMuiy5QSktp'; const ADAGIO_PUBKEY_E = 65537; +const CURRENCY = 'USD'; +const DEFAULT_FLOOR = 0.1; // This provide a whitelist and a basic validation // of OpenRTB 2.5 options used by the Adagio SSP. @@ -819,6 +821,48 @@ function _parseNativeBidResponse(bid) { bid.native = native } +function _getFloors(bidRequest) { + if (!utils.isFn(bidRequest.getFloor)) { + return false; + } + + const floors = []; + + const getAndPush = (mediaType, size) => { + const info = bidRequest.getFloor({ + currency: CURRENCY, + mediaType, + size: [] + }); + + floors.push(utils.cleanObj({ + mt: mediaType, + s: utils.isArray(size) ? `${size[0]}x${size[1]}` : undefined, + f: (!isNaN(info.floor) && info.currency === CURRENCY) ? info.floor : DEFAULT_FLOOR + })); + } + + Object.keys(bidRequest.mediaTypes).forEach(mediaType => { + if (SUPPORTED_MEDIA_TYPES.indexOf(mediaType) !== -1) { + const sizeProp = mediaType === VIDEO ? 'playerSize' : 'sizes'; + + if (bidRequest.mediaTypes[mediaType][sizeProp] && bidRequest.mediaTypes[mediaType][sizeProp].length) { + if (utils.isArray(bidRequest.mediaTypes[mediaType][sizeProp][0])) { + bidRequest.mediaTypes[mediaType][sizeProp].forEach(size => { + getAndPush(mediaType, [size[0], size[1]]); + }); + } else { + getAndPush(mediaType, [bidRequest.mediaTypes[mediaType][sizeProp][0], bidRequest.mediaTypes[mediaType][sizeProp][1]]); + } + } else { + getAndPush(mediaType, '*'); + } + } + }); + + return floors; +} + export const spec = { code: BIDDER_CODE, gvlid: GVLID, @@ -914,6 +958,9 @@ export const spec = { const adUnits = utils._map(validBidRequests, (bidRequest) => { bidRequest.features = internal.getFeatures(bidRequest, bidderRequest); + // Handle priceFloors module + bidRequest.floors = _getFloors(bidRequest); + if (utils.deepAccess(bidRequest, 'mediaTypes.video')) { _buildVideoBidRequest(bidRequest); } @@ -923,10 +970,14 @@ export const spec = { // Group ad units by organizationId const groupedAdUnits = adUnits.reduce((groupedAdUnits, adUnit) => { - adUnit.params.organizationId = adUnit.params.organizationId.toString(); + const adUnitCopy = utils.deepClone(adUnit); + adUnitCopy.params.organizationId = adUnitCopy.params.organizationId.toString(); + + // remove useless props + delete adUnitCopy.floorData; - groupedAdUnits[adUnit.params.organizationId] = groupedAdUnits[adUnit.params.organizationId] || []; - groupedAdUnits[adUnit.params.organizationId].push(adUnit); + groupedAdUnits[adUnitCopy.params.organizationId] = groupedAdUnits[adUnitCopy.params.organizationId] || []; + groupedAdUnits[adUnitCopy.params.organizationId].push(adUnitCopy); return groupedAdUnits; }, {}); diff --git a/test/spec/modules/adagioBidAdapter_spec.js b/test/spec/modules/adagioBidAdapter_spec.js index 6e0b82cbab8..4b66a96be16 100644 --- a/test/spec/modules/adagioBidAdapter_spec.js +++ b/test/spec/modules/adagioBidAdapter_spec.js @@ -740,6 +740,77 @@ describe('Adagio bid adapter', () => { expect(requests[0].data.user.eids).to.be.empty; }); }); + + describe('with priceFloors module', function() { + it('should get and set floor by mediatype and sizes', function() { + const bid01 = new BidRequestBuilder({ + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + }, + video: { + playerSize: [600, 480] + } + } + }).withParams().build(); + const bidderRequest = new BidderRequestBuilder().build(); + + // delete the computed `sizes` prop as we are based on mediaTypes only. + delete bid01.sizes + + bid01.getFloor = () => { + return { floor: 1, currency: 'USD' } + } + const requests = spec.buildRequests([bid01], bidderRequest); + + expect(requests[0].data.adUnits[0].floors.length).to.equal(3); + expect(requests[0].data.adUnits[0].floors[0]).to.deep.equal({f: 1, mt: 'banner', s: '300x250'}); + expect(requests[0].data.adUnits[0].floors[1]).to.deep.equal({f: 1, mt: 'banner', s: '300x600'}); + expect(requests[0].data.adUnits[0].floors[2]).to.deep.equal({f: 1, mt: 'video', s: '600x480'}); + }); + + it('should get and set floor by mediatype if no size provided (ex native, video)', function() { + const bid01 = new BidRequestBuilder({ + mediaTypes: { + video: { + context: 'outstream', + mimes: ['video/mp4'] + }, + native: { + body: { required: true } + } + } + }).withParams().build(); + const bidderRequest = new BidderRequestBuilder().build(); + bid01.getFloor = () => { + return { floor: 1, currency: 'USD' } + } + const requests = spec.buildRequests([bid01], bidderRequest); + + expect(requests[0].data.adUnits[0].floors.length).to.equal(2); + expect(requests[0].data.adUnits[0].floors[0]).to.deep.equal({f: 1, mt: 'video'}); + expect(requests[0].data.adUnits[0].floors[1]).to.deep.equal({f: 1, mt: 'native'}); + }); + + it('should get and set floor with default value if no floors found', function() { + const bid01 = new BidRequestBuilder({ + mediaTypes: { + video: { + context: 'outstream', + mimes: ['video/mp4'] + } + } + }).withParams().build(); + const bidderRequest = new BidderRequestBuilder().build(); + bid01.getFloor = () => { + return { floor: NaN, currency: 'USD' } + } + const requests = spec.buildRequests([bid01], bidderRequest); + + expect(requests[0].data.adUnits[0].floors.length).to.equal(1); + expect(requests[0].data.adUnits[0].floors[0]).to.deep.equal({f: 0.1, mt: 'video'}); + }); + }); }); describe('interpretResponse()', function() { From 17e446deb5e22efa3898b24e5f37d829af4377cc Mon Sep 17 00:00:00 2001 From: etargetse <40423120+etargetse@users.noreply.github.com> Date: Tue, 1 Jun 2021 16:00:59 +0200 Subject: [PATCH 277/303] eTarget Bid Adapter: add "getMetaData" function to adapter, support for advertiserDomains (#6901) --- modules/etargetBidAdapter.js | 39 +++++++++++++++++++-- test/spec/modules/etargetBidAdapter_spec.js | 5 +++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/modules/etargetBidAdapter.js b/modules/etargetBidAdapter.js index 42c991a17a4..8a1b25cec70 100644 --- a/modules/etargetBidAdapter.js +++ b/modules/etargetBidAdapter.js @@ -1,5 +1,5 @@ -'use strict'; - +import * as utils from '../src/utils.js'; +import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; @@ -57,10 +57,40 @@ export const spec = { data: bidderRequest, bids: validBidRequests, netRevenue: netRevenue, + metaData: getMetaData(), bidder: 'etarget', gdpr: gdprObject }; + function getMetaData() { + var mts = {}; + var hmetas = document.getElementsByTagName('meta'); + var wnames = ['title', 'og:title', 'description', 'og:description', 'og:url', 'base', 'keywords']; + try { + for (var k in hmetas) { + if (typeof hmetas[k] == 'object') { + var mname = hmetas[k].name || hmetas[k].getAttribute('property'); + var mcont = hmetas[k].content; + if (!!mname && mname != 'null' && !!mcont) { + if (wnames.indexOf(mname) >= 0) { + if (!mts[mname]) { + mts[mname] = []; + } + mts[mname].push(mcont); + } + } + } + } + mts['title'] = [(document.getElementsByTagName('title')[0] || []).innerHTML]; + mts['base'] = [(document.getElementsByTagName('base')[0] || {}).href]; + mts['referer'] = [document.location.href]; + mts['ortb2'] = (config.getConfig('ortb2') || {}); + } catch (e) { + mts.error = e; + } + return mts; + } + function formRequestUrl(reqData) { var key; var url = []; @@ -107,9 +137,14 @@ export const spec = { bidObject.gdpr = bidRequest.gdpr.gdpr; bidObject.gdpr_consent = bidRequest.gdpr.gdpr_consent; } + + if (bid.adomain) { + utils.deepSetValue(bidObject, 'meta.advertiserDomains', Array.isArray(bid.adomain) ? bid.adomain : [bid.adomain]); + } bidRespones.push(bidObject); } } + return bidRespones; function verifySize(adItem, validSizes) { diff --git a/test/spec/modules/etargetBidAdapter_spec.js b/test/spec/modules/etargetBidAdapter_spec.js index 2dbf6cd68c5..e2310aee1fb 100644 --- a/test/spec/modules/etargetBidAdapter_spec.js +++ b/test/spec/modules/etargetBidAdapter_spec.js @@ -26,6 +26,11 @@ describe('etarget adapter', function () { assert.lengthOf(parsedUrl.items, 7); }); + it('should be an object', function () { + let request = spec.buildRequests(bids); + assert.isNotNull(request.metaData); + }); + it('should handle global request parameters', function () { let parsedUrl = parseUrl(spec.buildRequests([bids[0]]).url); assert.equal(parsedUrl.path, 'https://sk.search.etargetnet.com/hb'); From 296b926b2c0aa88407716e7bf8793d24f3090d1a Mon Sep 17 00:00:00 2001 From: jackhsiehucf <77815341+jackhsiehucf@users.noreply.github.com> Date: Tue, 1 Jun 2021 23:15:39 +0800 Subject: [PATCH 278/303] ucfunnel Bid Adapter: add support Price Floors Module (#6806) * Add a new ucfunnel Adapter and test page * Add a new ucfunnel Adapter and test page * 1. Use prebid lib in the repo to keep updated 2. Replace var with let 3. Put JSON.parse(JSON.stringify()) into try catch block * utils.getTopWindowLocation is a function * Change to modules from adapters * Migrate to module design * [Dev Fix] Remove width and height which can be got from ad unit id * Update ucfunnelBidAdapter to fit into new spec * Correct the endpoint. Fix the error of query string * Add test case for ucfunnelBidAdapter * Fix lint error * Update version number * Combine all checks on bid request * Add GDPR support for ucfunnel adapter * Add in-stream video and native support for ucfunnel adapter * Remove demo page. Add more test cases. * Change request method from POST to GET * Remove unnecessary comment * Support vastXml and vastUrl for video request * update TTL to 30 mins * Avoid using arrow function which is not discuraged in mocha * ucfunnel tdid support * ucfunnel fix error message in debug mode * ucfunnel adapter add bidfloor parameter * ucfunnel adapter support CCPA * ucfunnel adapter native support clicktrackers * ucfunnel adapter change cookie sync setting * ucfunnel adapter update request parameter * Update ucfunnelBidAdapter * ucfunnel adapter add currency in ad response * ucfunnel adapter support uid2 * ucfunnel Bid Adapter: add support for FLoC and Verizon Media ConnectID * ucfunnel Bid Adapter: add support Price Floors Module Co-authored-by: root Co-authored-by: Ryan Chou Co-authored-by: ucfunnel Co-authored-by: jack.hsieh --- modules/ucfunnelBidAdapter.js | 38 ++++++++++++++++++-- test/spec/modules/ucfunnelBidAdapter_spec.js | 38 ++++++++++++++++++-- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/modules/ucfunnelBidAdapter.js b/modules/ucfunnelBidAdapter.js index 734aba97789..685ffdb42b7 100644 --- a/modules/ucfunnelBidAdapter.js +++ b/modules/ucfunnelBidAdapter.js @@ -8,6 +8,7 @@ const COOKIE_NAME = 'ucf_uid'; const VER = 'ADGENT_PREBID-2018011501'; const BIDDER_CODE = 'ucfunnel'; const GVLID = 607; +const CURRENCY = 'USD'; const VIDEO_CONTEXT = { INSTREAM: 0, OUSTREAM: 2 @@ -210,12 +211,41 @@ function getSupplyChain(schain) { return supplyChain; } +function getMediaType(mediaTypes) { + if (mediaTypes != null && mediaTypes.banner) { + return 'banner'; + } else if (mediaTypes != null && mediaTypes.video) { + return 'video'; + } else if (mediaTypes != null && mediaTypes.native) { + return 'native' + } + return 'banner'; +} + +function getFloor(bid, size, mediaTypes) { + if (bid.params.bidfloor) { + return bid.params.bidfloor; + } + if (typeof bid.getFloor === 'function') { + var bidFloor = bid.getFloor({ + currency: CURRENCY, + mediaType: getMediaType(mediaTypes), + size: (size) ? [ size[0], size[1] ] : '*', + }); + if (bidFloor.currency === CURRENCY) { + return bidFloor.floor; + } + } + return undefined; +} + function getRequestData(bid, bidderRequest) { const size = parseSizes(bid); const language = navigator.language; const dnt = (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0; const userIdTdid = (bid.userId && bid.userId.tdid) ? bid.userId.tdid : ''; const supplyChain = getSupplyChain(bid.schain); + const bidFloor = getFloor(bid, size, bid.mediaTypes); // general bid data let bidData = { ver: VER, @@ -225,9 +255,13 @@ function getRequestData(bid, bidderRequest) { dnt: dnt, adid: bid.params.adid, tdid: userIdTdid, - schain: supplyChain, - fp: bid.params.bidfloor + schain: supplyChain }; + + if (bidFloor) { + bidData.fp = bidFloor; + } + addUserId(bidData, bid.userId); try { bidData.host = window.top.location.hostname; diff --git a/test/spec/modules/ucfunnelBidAdapter_spec.js b/test/spec/modules/ucfunnelBidAdapter_spec.js index bee420f40d4..5899554244b 100644 --- a/test/spec/modules/ucfunnelBidAdapter_spec.js +++ b/test/spec/modules/ucfunnelBidAdapter_spec.js @@ -25,8 +25,7 @@ const userId = { const validBannerBidReq = { bidder: BIDDER_CODE, params: { - adid: 'ad-34BBD2AA24B678BBFD4E7B9EE3B872D', - bidfloor: 1.0 + adid: 'ad-34BBD2AA24B678BBFD4E7B9EE3B872D' }, sizes: [[300, 250]], bidId: '263be71e91dd9d', @@ -175,6 +174,41 @@ describe('ucfunnel Adapter', function () { expect(data.w).to.equal(width); expect(data.h).to.equal(height); }); + + it('should set bidfloor if configured', function() { + let bid = Object.assign({}, validBannerBidReq); + bid.getFloor = function() { + return { + currency: 'USD', + floor: 2.02 + } + }; + const requests = spec.buildRequests([ bid ]); + const data = requests[0].data; + expect(data.fp).to.equal(2.02); + }); + + it('should set bidfloor if configured', function() { + let bid = Object.assign({}, validBannerBidReq); + bid.params.bidfloor = 2.01; + const requests = spec.buildRequests([ bid ]); + const data = requests[0].data; + expect(data.fp).to.equal(2.01); + }); + + it('should set bidfloor if configured', function() { + let bid = Object.assign({}, validBannerBidReq); + bid.getFloor = function() { + return { + currency: 'USD', + floor: 2.02 + } + }; + bid.params.bidfloor = 2.01; + const requests = spec.buildRequests([ bid ]); + const data = requests[0].data; + expect(data.fp).to.equal(2.01); + }); }); describe('interpretResponse', function () { From 667e2683533c546f08b0809b8dd84de9b81d0c3e Mon Sep 17 00:00:00 2001 From: Alexandru Date: Tue, 1 Jun 2021 19:30:11 +0300 Subject: [PATCH 279/303] Brightcom Bid Adapter: handle meta.advertiserDomains (#6905) --- modules/brightcomBidAdapter.js | 5 ++++- test/spec/modules/brightcomBidAdapter_spec.js | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/brightcomBidAdapter.js b/modules/brightcomBidAdapter.js index 2aad211b186..7d6d77356f1 100644 --- a/modules/brightcomBidAdapter.js +++ b/modules/brightcomBidAdapter.js @@ -122,7 +122,10 @@ function interpretResponse(serverResponse) { netRevenue: true, mediaType: BANNER, ad: _getAdMarkup(brightcomBid), - ttl: 60 + ttl: 60, + meta: { + advertiserDomains: brightcomBid && brightcomBid.adomain ? brightcomBid.adomain : [] + } }); }); } diff --git a/test/spec/modules/brightcomBidAdapter_spec.js b/test/spec/modules/brightcomBidAdapter_spec.js index a89391d681e..b7d52c9f7d5 100644 --- a/test/spec/modules/brightcomBidAdapter_spec.js +++ b/test/spec/modules/brightcomBidAdapter_spec.js @@ -247,7 +247,8 @@ describe('brightcomBidAdapter', function() { 'nurl': '', 'adm': '', 'w': 300, - 'h': 250 + 'h': 250, + 'adomain': ['example.com'] }] }] } @@ -265,7 +266,10 @@ describe('brightcomBidAdapter', function() { 'netRevenue': true, 'mediaType': 'banner', 'ad': `
`, - 'ttl': 60 + 'ttl': 60, + 'meta': { + 'advertiserDomains': ['example.com'] + } }]; let result = spec.interpretResponse(response); @@ -283,7 +287,10 @@ describe('brightcomBidAdapter', function() { 'netRevenue': true, 'mediaType': 'banner', 'ad': `
`, - 'ttl': 60 + 'ttl': 60, + 'meta': { + 'advertiserDomains': ['example.com'] + } }]; let result = spec.interpretResponse(response); From 4fe2be1d85b398be2f22912a769beb4a9931d6be Mon Sep 17 00:00:00 2001 From: Alexandru Date: Tue, 1 Jun 2021 19:59:36 +0300 Subject: [PATCH 280/303] Onomagic Bid Adapter: handle meta.advertiserDomains (#6906) * Onomagic Bid Adapter: handle meta.advertiserDomains * Onomagic Bid Adapter: fix lint issues --- modules/onomagicBidAdapter.js | 5 ++++- test/spec/modules/onomagicBidAdapter_spec.js | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/onomagicBidAdapter.js b/modules/onomagicBidAdapter.js index 55fca29fbf3..eba62cfe1d4 100644 --- a/modules/onomagicBidAdapter.js +++ b/modules/onomagicBidAdapter.js @@ -117,7 +117,10 @@ function interpretResponse(serverResponse) { netRevenue: true, mediaType: BANNER, ad: _getAdMarkup(onomagicBid), - ttl: 60 + ttl: 60, + meta: { + advertiserDomains: onomagicBid && onomagicBid.adomain ? onomagicBid.adomain : [] + } }); }); } diff --git a/test/spec/modules/onomagicBidAdapter_spec.js b/test/spec/modules/onomagicBidAdapter_spec.js index 7c71c3e5764..6ddc0edd477 100644 --- a/test/spec/modules/onomagicBidAdapter_spec.js +++ b/test/spec/modules/onomagicBidAdapter_spec.js @@ -222,7 +222,8 @@ describe('onomagicBidAdapter', function() { 'nurl': '', 'adm': '', 'w': 300, - 'h': 250 + 'h': 250, + 'adomain': ['example.com'] }] }] } @@ -240,7 +241,10 @@ describe('onomagicBidAdapter', function() { 'netRevenue': true, 'mediaType': 'banner', 'ad': `
`, - 'ttl': 60 + 'ttl': 60, + 'meta': { + 'advertiserDomains': ['example.com'] + } }]; let result = spec.interpretResponse(response); @@ -258,7 +262,10 @@ describe('onomagicBidAdapter', function() { 'netRevenue': true, 'mediaType': 'banner', 'ad': `
`, - 'ttl': 60 + 'ttl': 60, + 'meta': { + 'advertiserDomains': ['example.com'] + } }]; let result = spec.interpretResponse(response); From 5cca29ed0a744000fa652ed9e91bc1306f0ed965 Mon Sep 17 00:00:00 2001 From: Jake Miller Date: Tue, 1 Jun 2021 10:03:57 -0700 Subject: [PATCH 281/303] add support for advertiser domains (#6908) --- modules/underdogmediaBidAdapter.js | 3 +++ test/spec/modules/underdogmediaBidAdapter_spec.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/modules/underdogmediaBidAdapter.js b/modules/underdogmediaBidAdapter.js index 8368077a627..6268774bc12 100644 --- a/modules/underdogmediaBidAdapter.js +++ b/modules/underdogmediaBidAdapter.js @@ -120,6 +120,9 @@ export const spec = { currency: 'USD', netRevenue: false, ttl: mid.ttl || 60, + meta: { + advertiserDomains: mid.advertiser_domains || [] + } }; if (bidResponse.cpm <= 0) { diff --git a/test/spec/modules/underdogmediaBidAdapter_spec.js b/test/spec/modules/underdogmediaBidAdapter_spec.js index aeb9f56c851..70d09513f27 100644 --- a/test/spec/modules/underdogmediaBidAdapter_spec.js +++ b/test/spec/modules/underdogmediaBidAdapter_spec.js @@ -276,6 +276,7 @@ describe('UnderdogMedia adapter', function () { mids: [ { ad_code_html: 'ad_code_html', + advertiser_domains: ['domain1'], cpm: 2.5, height: '600', mid: '32634', @@ -300,6 +301,7 @@ describe('UnderdogMedia adapter', function () { expect(bids).to.be.lengthOf(2); + expect(bids[0].meta.advertiserDomains).to.deep.equal(['domain1']) expect(bids[0].bidderCode).to.equal('underdogmedia'); expect(bids[0].cpm).to.equal(2.5); expect(bids[0].width).to.equal('160'); From f3302af630ec83260d57ecab02ab32c9215607da Mon Sep 17 00:00:00 2001 From: Skylinar <53079123+Skylinar@users.noreply.github.com> Date: Tue, 1 Jun 2021 19:50:16 +0200 Subject: [PATCH 282/303] smartx Bid Adapter: Add support for Floors Module (#6902) * Add smartclipBidAdapter * smartxBidAdapter.js - removed unused variables, removed debug, added window before the outstream related functions * - made outstream player configurable * remove wrong named files * camelcase * fix * Out-Stream render update to SmartPlay 5.2 * ESlint fix * ESlint fix * ESlint fix * adjust tests, fixes * ESlint * adjusted desired bitrate examples * added bid.meta.advertiserDomains support * bug fix for numeric elementID outstream render * fix renderer url * support for floors module Co-authored-by: smartclip AdTechnology Co-authored-by: Gino Cirlini --- modules/smartxBidAdapter.js | 42 +++++--- test/spec/modules/smartxBidAdapter_spec.js | 108 +++++++++++++++++++-- 2 files changed, 133 insertions(+), 17 deletions(-) diff --git a/modules/smartxBidAdapter.js b/modules/smartxBidAdapter.js index b2c48b58f82..46e2055c8f0 100644 --- a/modules/smartxBidAdapter.js +++ b/modules/smartxBidAdapter.js @@ -46,14 +46,6 @@ export const spec = { utils.logError(BIDDER_CODE + ': siteId is not present in bidder params'); return false; } - if (!utils.getBidIdParameter('bidfloor', bid.params)) { - utils.logError(BIDDER_CODE + ': bidfloor is not present in bidder params'); - return false; - } - if (!utils.getBidIdParameter('bidfloorcur', bid.params)) { - utils.logError(BIDDER_CODE + ': bidfloorcur is not present in bidder params'); - return false; - } if (utils.deepAccess(bid, 'mediaTypes.video.context') === 'outstream') { if (!utils.getBidIdParameter('outstream_options', bid.params)) { utils.logError(BIDDER_CODE + ': outstream_options parameter is not defined'); @@ -85,8 +77,8 @@ export const spec = { const smartxRequests = bidRequests.map(function (bid) { const tagId = utils.getBidIdParameter('tagId', bid.params); const publisherId = utils.getBidIdParameter('publisherId', bid.params); - const bidfloor = utils.getBidIdParameter('bidfloor', bid.params); - const bidfloorcur = utils.getBidIdParameter('bidfloorcur', bid.params); + const bidfloor = getBidFloor(bid) || 0; + const bidfloorcur = utils.getBidIdParameter('bidfloorcur', bid.params) || 'EUR'; const siteId = utils.getBidIdParameter('siteId', bid.params); const domain = utils.getBidIdParameter('domain', bid.params); const cat = utils.getBidIdParameter('cat', bid.params); @@ -161,7 +153,7 @@ export const spec = { const at = utils.getBidIdParameter('at', bid.params) || 2; - const cur = utils.getBidIdParameter('cur', bid.params) || ['EUR']; + const cur = utils.getBidIdParameter('cur', bid.params) || 'EUR'; const requestPayload = { id: utils.generateUUID(), @@ -226,6 +218,8 @@ export const spec = { } } + // Todo: USER ID MODULE + requestPayload.user = { ext: userExt, data: targetingarr @@ -412,4 +406,30 @@ function outstreamRender(bid) { } } } + +/** + * Get the floor price from bid.params for backward compatibility. + * If not found, then check floor module. + * @param bid A valid bid object + * @returns {*|number} floor price + */ +function getBidFloor(bid) { + let floor = utils.getBidIdParameter('bidfloor', bid.params); + let floorcur = utils.getBidIdParameter('bidfloorcur', bid.params) || 'EUR'; + + if (!floor && utils.isFn(bid.getFloor)) { + const floorObj = bid.getFloor({ + currency: floorcur, + mediaType: '*', + size: '*' + }); + + if (utils.isPlainObject(floorObj) && !isNaN(floorObj.floor) && floorObj.currency === floorcur) { + floor = floorObj.floor; + } + } + + return floor; +} + registerBidder(spec); diff --git a/test/spec/modules/smartxBidAdapter_spec.js b/test/spec/modules/smartxBidAdapter_spec.js index 3c871c6f88b..d0659865afa 100644 --- a/test/spec/modules/smartxBidAdapter_spec.js +++ b/test/spec/modules/smartxBidAdapter_spec.js @@ -108,14 +108,13 @@ describe('The smartx adapter', function () { expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should fail without bidfloor', function () { + it('should succeed with floor Module set', function () { delete bid.params.bidfloor; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should fail without bidfloorcur', function () { delete bid.params.bidfloorcur; - expect(spec.isBidRequestValid(bid)).to.equal(false); + bid.floors = { + currency: 'EUR' + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); }); it('should fail with context outstream but no options set for outstream', function () { @@ -514,4 +513,101 @@ describe('The smartx adapter', function () { window.document.getElementById.restore(); }); }); + + describe('price floor module', function () { + var bid, + bidRequestObj; + + beforeEach(function () { + bid = getValidBidObject(); + bidRequestObj = { + refererInfo: { + referer: 'prebid.js' + } + }; + delete bid.params.bidfloor; + }); + + it('obtain floor from getFloor', function () { + bid.getFloor = () => { + return { + currency: 'EUR', + floor: 3.21 + }; + }; + + const payload = spec.buildRequests([bid], bidRequestObj)[0]; + expect(payload.data.imp).to.have.property('bidfloor', 3.21); + }); + + it('obtain floor from params', function() { + bid.getFloor = () => { + return { + currency: 'EUR', + floor: 3.21 + }; + }; + bid.params.bidfloor = 0.64; + + const payload = spec.buildRequests([bid], bidRequestObj)[0]; + expect(payload.data.imp).to.have.property('bidfloor', 0.64); + }); + + it('check currency USD', function() { + bid.getFloor = () => { + return { + currency: 'USD', + floor: 1.23 + }; + }; + bid.params.bidfloorcur = 'USD' + + const payload = spec.buildRequests([bid], bidRequestObj)[0]; + expect(payload.data.imp).to.have.property('bidfloorcur', 'USD'); + expect(payload.data.imp).to.have.property('bidfloor', 1.23); + }); + + it('check defaut currency EUR', function() { + delete bid.params.bidfloorcur; + + bid.getFloor = () => { + return { + currency: 'EUR', + floor: 4.56 + }; + }; + + const payload = spec.buildRequests([bid], bidRequestObj)[0]; + expect(payload.data.imp).to.have.property('bidfloorcur', 'EUR'); + expect(payload.data.imp).to.have.property('bidfloor', 4.56); + }); + + it('bad floor value', function() { + bid.getFloor = () => { + return { + currency: 'EUR', + floor: 'bad' + }; + }; + + const payload = spec.buildRequests([bid], bidRequestObj)[0]; + expect(payload.data.imp).to.have.property('bidfloor', 0); + }); + + it('empty floor object', function() { + bid.getFloor = () => { + return {}; + }; + + const payload = spec.buildRequests([bid], bidRequestObj)[0]; + expect(payload.data.imp).to.have.property('bidfloor', 0); + }); + + it('undefined floor result', function() { + bid.getFloor = () => {}; + + const payload = spec.buildRequests([bid], bidRequestObj)[0]; + expect(payload.data.imp).to.have.property('bidfloor', 0); + }); + }); }) From e414946e31eb6a822ef69edbb27395d0b058d669 Mon Sep 17 00:00:00 2001 From: ym-dlabuzov <81709888+ym-dlabuzov@users.noreply.github.com> Date: Tue, 1 Jun 2021 21:28:06 +0300 Subject: [PATCH 283/303] Yieldmo Bid Adapter: read video parameters from the ad unit (#6873) --- modules/yieldmoBidAdapter.js | 90 +++++++++++++-------- modules/yieldmoBidAdapter.md | 5 ++ test/spec/modules/yieldmoBidAdapter_spec.js | 71 +++++++++++++++- 3 files changed, 130 insertions(+), 36 deletions(-) diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index 36f93f60c9e..fa1ab3a90b3 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -12,8 +12,8 @@ const NET_REVENUE = true; const BANNER_SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; const VIDEO_SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebidvideo'; const OUTSTREAM_VIDEO_PLAYER_URL = 'https://prebid-outstream.yieldmo.com/bundle.js'; -const OPENRTB_VIDEO_BIDPARAMS = ['placement', 'startdelay', 'skipafter', - 'protocols', 'api', 'playbackmethod', 'maxduration', 'minduration', 'pos']; +const OPENRTB_VIDEO_BIDPARAMS = ['mimes', 'startdelay', 'placement', 'startdelay', 'skipafter', 'protocols', 'api', + 'playbackmethod', 'maxduration', 'minduration', 'pos', 'skip', 'skippable']; const OPENRTB_VIDEO_SITEPARAMS = ['name', 'domain', 'cat', 'keywords']; const LOCAL_WINDOW = utils.getWindowTop(); const DEFAULT_PLAYBACK_METHOD = 2; @@ -335,7 +335,6 @@ function openRtbRequest(bidRequests, bidderRequest) { * @return Object OpenRTB's 'imp' (impression) object */ function openRtbImpression(bidRequest) { - const videoReq = utils.deepAccess(bidRequest, 'mediaTypes.video'); const size = extractPlayerSize(bidRequest); const imp = { id: bidRequest.bidId, @@ -347,23 +346,27 @@ function openRtbImpression(bidRequest) { video: { w: size[0], h: size[1], - mimes: videoReq.mimes, linearity: 1 } }; + const mediaTypesParams = utils.deepAccess(bidRequest, 'mediaTypes.video'); + Object.keys(mediaTypesParams) + .filter(param => includes(OPENRTB_VIDEO_BIDPARAMS, param)) + .forEach(param => imp.video[param] = mediaTypesParams[param]); + const videoParams = utils.deepAccess(bidRequest, 'params.video'); Object.keys(videoParams) .filter(param => includes(OPENRTB_VIDEO_BIDPARAMS, param)) .forEach(param => imp.video[param] = videoParams[param]); - if (videoParams.skippable) imp.video.skip = 1; - if (videoParams.placement !== 1) { - imp.video = { - ...imp.video, - startdelay: DEFAULT_START_DELAY, - playbackmethod: [ DEFAULT_PLAYBACK_METHOD ] - } + if (imp.video.skippable) { + imp.video.skip = 1; + delete imp.video.skippable; + } + if (imp.video.placement !== 1) { + imp.video.startdelay = DEFAULT_START_DELAY; + imp.video.playbackmethod = [ DEFAULT_PLAYBACK_METHOD ]; } return imp; } @@ -476,51 +479,68 @@ function validateVideoParams(bid) { const isDefined = val => typeof val !== 'undefined'; const validate = (fieldPath, validateCb, errorCb, errorCbParam) => { - const value = utils.deepAccess(bid, fieldPath); - if (!validateCb(value)) { - errorCb(fieldPath, value, errorCbParam); + if (fieldPath.indexOf('video') === 0) { + const valueFieldPath = 'params.' + fieldPath; + const mediaFieldPath = 'mediaTypes.' + fieldPath; + const valueParams = utils.deepAccess(bid, valueFieldPath); + const mediaTypesParams = utils.deepAccess(bid, mediaFieldPath); + const hasValidValueParams = validateCb(valueParams); + const hasValidMediaTypesParams = validateCb(mediaTypesParams); + + if (hasValidValueParams) return valueParams; + else if (hasValidMediaTypesParams) return hasValidMediaTypesParams; + else { + if (!hasValidValueParams) errorCb(valueFieldPath, valueParams, errorCbParam); + else if (!hasValidMediaTypesParams) errorCb(mediaFieldPath, mediaTypesParams, errorCbParam); + } + return valueParams || mediaTypesParams; + } else { + const value = utils.deepAccess(bid, fieldPath); + if (!validateCb(value)) { + errorCb(fieldPath, value, errorCbParam); + } + return value; } - return value; } try { + validate('video.context', val => !utils.isEmpty(val), paramRequired); + validate('params.placementId', val => !utils.isEmpty(val), paramRequired); - validate('mediaTypes.video.playerSize', val => utils.isArrayOfNums(val, 2) || + validate('video.playerSize', val => utils.isArrayOfNums(val, 2) || (utils.isArray(val) && val.every(v => utils.isArrayOfNums(v, 2))), paramInvalid, 'array of 2 integers, ex: [640,480] or [[640,480]]'); - validate('mediaTypes.video.mimes', val => isDefined(val), paramRequired); - validate('mediaTypes.video.mimes', val => utils.isArray(val) && val.every(v => utils.isStr(v)), paramInvalid, + validate('video.mimes', val => isDefined(val), paramRequired); + validate('video.mimes', val => utils.isArray(val) && val.every(v => utils.isStr(v)), paramInvalid, 'array of strings, ex: ["video/mp4"]'); - validate('params.video', val => !utils.isEmpty(val), paramRequired); - - const placement = validate('params.video.placement', val => isDefined(val), paramRequired); - validate('params.video.placement', val => val >= 1 && val <= 5, paramInvalid); + const placement = validate('video.placement', val => isDefined(val), paramRequired); + validate('video.placement', val => val >= 1 && val <= 5, paramInvalid); if (placement === 1) { - validate('params.video.startdelay', val => isDefined(val), + validate('video.startdelay', val => isDefined(val), (field, v) => paramRequired(field, v, 'placement == 1')); - validate('params.video.startdelay', val => utils.isNumber(val), paramInvalid, 'number, ex: 5'); + validate('video.startdelay', val => utils.isNumber(val), paramInvalid, 'number, ex: 5'); } - validate('params.video.protocols', val => isDefined(val), paramRequired); - validate('params.video.protocols', val => utils.isArrayOfNums(val) && val.every(v => (v >= 1 && v <= 6)), + validate('video.protocols', val => isDefined(val), paramRequired); + validate('video.protocols', val => utils.isArrayOfNums(val) && val.every(v => (v >= 1 && v <= 6)), paramInvalid, 'array of numbers, ex: [2,3]'); - validate('params.video.api', val => isDefined(val), paramRequired); - validate('params.video.api', val => utils.isArrayOfNums(val) && val.every(v => (v >= 1 && v <= 6)), + validate('video.api', val => isDefined(val), paramRequired); + validate('video.api', val => utils.isArrayOfNums(val) && val.every(v => (v >= 1 && v <= 6)), paramInvalid, 'array of numbers, ex: [2,3]'); - validate('params.video.playbackmethod', val => !isDefined(val) || utils.isArrayOfNums(val), paramInvalid, + validate('video.playbackmethod', val => !isDefined(val) || utils.isArrayOfNums(val), paramInvalid, 'array of integers, ex: [2,6]'); - validate('params.video.maxduration', val => isDefined(val), paramRequired); - validate('params.video.maxduration', val => utils.isInteger(val), paramInvalid); - validate('params.video.minduration', val => !isDefined(val) || utils.isNumber(val), paramInvalid); - validate('params.video.skippable', val => !isDefined(val) || utils.isBoolean(val), paramInvalid); - validate('params.video.skipafter', val => !isDefined(val) || utils.isNumber(val), paramInvalid); - validate('params.video.pos', val => !isDefined(val) || utils.isNumber(val), paramInvalid); + validate('video.maxduration', val => isDefined(val), paramRequired); + validate('video.maxduration', val => utils.isInteger(val), paramInvalid); + validate('video.minduration', val => !isDefined(val) || utils.isNumber(val), paramInvalid); + validate('video.skippable', val => !isDefined(val) || utils.isBoolean(val), paramInvalid); + validate('video.skipafter', val => !isDefined(val) || utils.isNumber(val), paramInvalid); + validate('video.pos', val => !isDefined(val) || utils.isNumber(val), paramInvalid); validate('params.badv', val => !isDefined(val) || utils.isArray(val), paramInvalid, 'array of strings, ex: ["ford.com","pepsi.com"]'); validate('params.bcat', val => !isDefined(val) || utils.isArray(val), paramInvalid, diff --git a/modules/yieldmoBidAdapter.md b/modules/yieldmoBidAdapter.md index 54be295a1a1..040fbbec486 100644 --- a/modules/yieldmoBidAdapter.md +++ b/modules/yieldmoBidAdapter.md @@ -96,3 +96,8 @@ var videoAdUnit = [{ }] }]; ``` + +Please also note, that we support the following OpenRTB params: +'mimes', 'startdelay', 'placement', 'startdelay', 'skipafter', 'protocols', 'api', +'playbackmethod', 'maxduration', 'minduration', 'pos', 'skip', 'skippable'. +They can be specified in `mediaTypes.video` or in `bids[].params.video`. diff --git a/test/spec/modules/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js index 3b317f88dc6..77542480c6c 100644 --- a/test/spec/modules/yieldmoBidAdapter_spec.js +++ b/test/spec/modules/yieldmoBidAdapter_spec.js @@ -331,13 +331,82 @@ describe('YieldmoAdapter', function () { }); describe('Instream video:', function () { + let videoBid; + const buildVideoBidAndGetVideoParam = () => build([videoBid])[0].data.imp[0].video; + + beforeEach(() => { + videoBid = mockVideoBid(); + }); + it('should attempt to send video bid requests to the endpoint via POST', function () { - const requests = build([mockVideoBid()]); + const requests = build([videoBid]); expect(requests.length).to.equal(1); expect(requests[0].method).to.equal('POST'); expect(requests[0].url).to.be.equal(VIDEO_ENDPOINT); }); + it('should add mediaTypes.video prop to the imp.video prop', function () { + utils.deepAccess(videoBid, 'mediaTypes.video')['minduration'] = 40; + expect(buildVideoBidAndGetVideoParam().minduration).to.equal(40); + }); + + it('should override mediaTypes.video prop if params.video prop is present', function () { + utils.deepAccess(videoBid, 'mediaTypes.video')['minduration'] = 50; + utils.deepAccess(videoBid, 'params.video')['minduration'] = 40; + expect(buildVideoBidAndGetVideoParam().minduration).to.equal(40); + }); + + it('should add mediaTypes.video.mimes prop to the imp.video', function () { + utils.deepAccess(videoBid, 'mediaTypes.video')['minduration'] = ['video/mp4']; + expect(buildVideoBidAndGetVideoParam().minduration).to.deep.equal(['video/mp4']); + }); + + it('should override mediaTypes.video.mimes prop if params.video.mimes is present', function () { + utils.deepAccess(videoBid, 'mediaTypes.video')['mimes'] = ['video/mp4']; + utils.deepAccess(videoBid, 'params.video')['mimes'] = ['video/mkv']; + expect(buildVideoBidAndGetVideoParam().mimes).to.deep.equal(['video/mkv']); + }); + + describe('video.skip state check', () => { + it('should not set video.skip if neither *.video.skip nor *.video.skippable is present', function () { + utils.deepAccess(videoBid, 'mediaTypes.video')['skippable'] = false; + utils.deepAccess(videoBid, 'params.video')['skippable'] = false; + expect(buildVideoBidAndGetVideoParam().skip).to.undefined; + }); + + it('should set video.skip=1 if mediaTypes.video.skip is present', function () { + utils.deepAccess(videoBid, 'mediaTypes.video')['skip'] = 1; + expect(buildVideoBidAndGetVideoParam().skip).to.equal(1); + }); + + it('should set video.skip=1 if params.video.skip is present', function () { + utils.deepAccess(videoBid, 'params.video')['skip'] = 1; + expect(buildVideoBidAndGetVideoParam().skip).to.equal(1); + }); + + it('should set video.skip=1 if mediaTypes.video.skippable is present', function () { + utils.deepAccess(videoBid, 'mediaTypes.video')['skippable'] = true; + expect(buildVideoBidAndGetVideoParam().skip).to.equal(1); + }); + + it('should set video.skip=1 if mediaTypes.video.skippable is present', function () { + utils.deepAccess(videoBid, 'params.video')['skippable'] = true; + expect(buildVideoBidAndGetVideoParam().skip).to.equal(1); + }); + + it('should set video.skip=1 if mediaTypes.video.skippable is present', function () { + utils.deepAccess(videoBid, 'mediaTypes.video')['skippable'] = false; + utils.deepAccess(videoBid, 'params.video')['skippable'] = true; + expect(buildVideoBidAndGetVideoParam().skip).to.equal(1); + }); + + it('should not set video.skip if params.video.skippable is false', function () { + utils.deepAccess(videoBid, 'mediaTypes.video')['skippable'] = true; + utils.deepAccess(videoBid, 'params.video')['skippable'] = false; + expect(buildVideoBidAndGetVideoParam().skip).to.undefined; + }); + }); + it('should process floors module if available', function () { const requests = build([ mockVideoBid({...mockGetFloor(3.99)}), From 6e203ea6924b196cdcb93aff82416c48dd0978d6 Mon Sep 17 00:00:00 2001 From: hnkhandev <57697206+hnkhandev@users.noreply.github.com> Date: Tue, 1 Jun 2021 12:30:31 -0600 Subject: [PATCH 284/303] Accept outstream renderers defined in mediatype for PBS (#6896) --- modules/prebidServerBidAdapter/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index ec5d05f0fe0..4f13bab05eb 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -594,7 +594,7 @@ const OPEN_RTB_PROTOCOL = { } if (!utils.isEmpty(videoParams)) { - if (videoParams.context === 'outstream' && !adUnit.renderer) { + if (videoParams.context === 'outstream' && (!videoParams.renderer || !adUnit.renderer)) { // Don't push oustream w/o renderer to request object. utils.logError('Outstream bid without renderer cannot be sent to Prebid Server.'); } else { From 1c3247c6beae0119bfabc43a7cee4a61629374b6 Mon Sep 17 00:00:00 2001 From: Mathieu Pheulpin Date: Tue, 1 Jun 2021 13:58:39 -0700 Subject: [PATCH 285/303] Sharethrough Bid Adapter: Use getFloor module for Prebid 5.0 compliance (#6874) * Fix Prebid 5.0 compliance: leverage floors module * Upgrade adapter version --- modules/sharethroughBidAdapter.js | 21 ++++++++++++++++--- .../modules/sharethroughBidAdapter_spec.js | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index 68ccde0da46..59cf2a3a035 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -2,7 +2,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import * as utils from '../src/utils.js'; import { config } from '../src/config.js'; -const VERSION = '3.3.2'; +const VERSION = '3.4.0'; const BIDDER_CODE = 'sharethrough'; const STR_ENDPOINT = 'https://btlr.sharethrough.com/WYu2BXv1/v1'; const DEFAULT_SIZE = [1, 1]; @@ -57,8 +57,9 @@ export const sharethroughAdapterSpec = { query.schain = JSON.stringify(bidRequest.schain); } - if (bidRequest.bidfloor) { - query.bidfloor = parseFloat(bidRequest.bidfloor); + const floor = getFloor(bidRequest); + if (floor) { + query.bidfloor = floor; } if (bidRequest.params.badv) { @@ -292,4 +293,18 @@ function getProtocol() { return document.location.protocol; } +function getFloor(bid) { + if (utils.isFn(bid.getFloor)) { + const floorInfo = bid.getFloor({ + currency: 'USD', + mediaType: 'banner', + size: bid.sizes.map(size => ({ w: size[0], h: size[1] })) + }); + if (utils.isPlainObject(floorInfo) && !isNaN(floorInfo.floor) && floorInfo.currency === 'USD') { + return parseFloat(floorInfo.floor); + } + } + return null; +} + registerBidder(sharethroughAdapterSpec); diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index 5c8e01536dd..b8d91249ec3 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -436,7 +436,7 @@ describe('sharethrough adapter spec', function() { it('should include the bidfloor parameter if it is present in the bid request', function() { const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest['bidfloor'] = 0.50; + bidRequest['getFloor'] = () => ({ currency: 'USD', floor: 0.5 }); const builtBidRequest = spec.buildRequests([bidRequest])[0]; expect(builtBidRequest.data.bidfloor).to.eq(0.5); }); From a259700fc1e152d67672a95170605506fa241939 Mon Sep 17 00:00:00 2001 From: Alexandru Date: Wed, 2 Jun 2021 13:21:09 +0300 Subject: [PATCH 286/303] Onomagic Bid Adapter: use getFloor function (#6907) * Onomagic Bid Adapter: use getFloor function * Onomagic Bid Adapter: fix issues --- modules/onomagicBidAdapter.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/onomagicBidAdapter.js b/modules/onomagicBidAdapter.js index eba62cfe1d4..548c0170c05 100644 --- a/modules/onomagicBidAdapter.js +++ b/modules/onomagicBidAdapter.js @@ -46,7 +46,7 @@ function buildRequests(bidReqs, bidderRequest) { }, tagid: String(bid.adUnitCode) }; - const bidFloor = utils.getBidIdParameter('bidFloor', bid.params); + const bidFloor = _getBidFloor(bid); if (bidFloor) { imp.bidfloor = bidFloor; } @@ -246,4 +246,20 @@ function _getPercentInView(element, topWin, { w, h } = {}) { return 0; } +function _getBidFloor(bid) { + if (!utils.isFn(bid.getFloor)) { + return bid.params.bidFloor ? bid.params.bidFloor : null; + } + + let floor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*' + }); + if (utils.isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') { + return floor.floor; + } + return null; +} + registerBidder(spec); From 481b94f8c27d535d7b9105a69e76d01bad49a64b Mon Sep 17 00:00:00 2001 From: jxdeveloper1 <71084096+jxdeveloper1@users.noreply.github.com> Date: Wed, 2 Jun 2021 19:11:28 +0800 Subject: [PATCH 287/303] Jixie Bid Adapter: add support for advertiserDomains (#6898) * Adapter does not seem capable of supporting advertiserDomains #6650 added response comment and some trivial code. * removed a blank line at the end of file added a space behind the // in comments * in response to comment from reviewer. add the aspect of advertiserdomain in unit tests --- modules/jixieBidAdapter.js | 10 ++++++++++ test/spec/modules/jixieBidAdapter_spec.js | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/jixieBidAdapter.js b/modules/jixieBidAdapter.js index 7c6e0027482..db6c9032e65 100644 --- a/modules/jixieBidAdapter.js +++ b/modules/jixieBidAdapter.js @@ -240,6 +240,16 @@ export const spec = { let rendererScript = (oneBid.osparams.script ? oneBid.osparams.script : JX_OUTSTREAM_RENDERER_URL); bnd.renderer = createRenderer_(oneBid, rendererScript, jxOutstreamRender_); } + // a note on advertiserDomains: our adserver is not responding in + // openRTB-type json. so there is no need to copy from 'adomain' over + // to meta: advertiserDomains + // However, we will just make sure the property is there. + if (!bnd.meta) { + bnd.meta = {}; + } + if (!bnd.meta.advertiserDomains) { + bnd.meta.advertiserDomains = []; + } bidResponses.push(bnd); }); if (response.body.setids) { diff --git a/test/spec/modules/jixieBidAdapter_spec.js b/test/spec/modules/jixieBidAdapter_spec.js index 842f9e0ed30..ae58da30f64 100644 --- a/test/spec/modules/jixieBidAdapter_spec.js +++ b/test/spec/modules/jixieBidAdapter_spec.js @@ -281,7 +281,8 @@ describe('jixie Adapter', function () { }, 'vastUrl': 'https://ad.jixie.io/v1/video?creativeid=522' }, - // display ad returned here: + // display ad returned here: This one there is advertiserDomains + // in the response . Will be checked in the unit tests below { 'trackingUrlBase': 'https://tr.jixie.io/sync/ad?', 'jxBidId': '600c9ae6fda1acb-028d5dee-2c83-44e3-bed1-b75002475cdf', @@ -411,6 +412,9 @@ describe('jixie Adapter', function () { expect(result[0].ttl).to.equal(300) expect(result[0].vastUrl).to.include('https://ad.jixie.io/v1/video?creativeid=') expect(result[0].trackingUrlBase).to.include('sync') + // We will always make sure the meta->advertiserDomains property is there + // If no info it is an empty array. + expect(result[0].meta.advertiserDomains.length).to.equal(0) // display ad expect(result[1].requestId).to.equal('600c9ae6fda1acb') @@ -422,6 +426,7 @@ describe('jixie Adapter', function () { expect(result[1].netRevenue).to.equal(true) expect(result[1].ttl).to.equal(300) expect(result[1].ad).to.include('jxoutstream') + expect(result[1].meta.advertiserDomains.length).to.equal(3) expect(result[1].trackingUrlBase).to.include('sync') // should pick up about using alternative outstream renderer @@ -436,6 +441,7 @@ describe('jixie Adapter', function () { expect(result[2].vastXml).to.include('') expect(result[2].trackingUrlBase).to.include('sync'); expect(result[2].renderer.id).to.equal('demoslot4-div') + expect(result[2].meta.advertiserDomains.length).to.equal(0) expect(result[2].renderer.url).to.equal(JX_OTHER_OUTSTREAM_RENDERER_URL); // should know to use default outstream renderer @@ -450,6 +456,7 @@ describe('jixie Adapter', function () { expect(result[3].vastXml).to.include('') expect(result[3].trackingUrlBase).to.include('sync'); expect(result[3].renderer.id).to.equal('demoslot2-div') + expect(result[3].meta.advertiserDomains.length).to.equal(0) expect(result[3].renderer.url).to.equal(JX_OUTSTREAM_RENDERER_URL) setLocalStorageSpy.restore(); From fbc44aa6c658f3be93f5dbb94e0f549061873902 Mon Sep 17 00:00:00 2001 From: relaido <63339139+relaido@users.noreply.github.com> Date: Wed, 2 Jun 2021 20:20:56 +0900 Subject: [PATCH 288/303] relaido Bid Adapter: Add meta OBJ to BidResponse (#6914) * add relaido adapter * remove event listener * fixed UserSyncs and e.data * fix conflicts * add response meda OBJ update version and test code Co-authored-by: ishigami_shingo Co-authored-by: cmertv-sishigami Co-authored-by: t_bun --- modules/relaidoBidAdapter.js | 6 +++++- test/spec/modules/relaidoBidAdapter_spec.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/relaidoBidAdapter.js b/modules/relaidoBidAdapter.js index 92709b7c047..f69f8c5c6e2 100644 --- a/modules/relaidoBidAdapter.js +++ b/modules/relaidoBidAdapter.js @@ -6,7 +6,7 @@ import { getStorageManager } from '../src/storageManager.js'; const BIDDER_CODE = 'relaido'; const BIDDER_DOMAIN = 'api.relaido.jp'; -const ADAPTER_VERSION = '1.0.3'; +const ADAPTER_VERSION = '1.0.4'; const DEFAULT_TTL = 300; const UUID_KEY = 'relaido_uuid'; @@ -112,6 +112,10 @@ function interpretResponse(serverResponse, bidRequest) { ttl: body.ttl || DEFAULT_TTL, netRevenue: true, mediaType: mediaType, + meta: { + advertiserDomains: body.adomain || [], + mediaType: VIDEO + } }; if (mediaType === VIDEO) { bidResponse.vastXml = body.vast; diff --git a/test/spec/modules/relaidoBidAdapter_spec.js b/test/spec/modules/relaidoBidAdapter_spec.js index 91aa6b05e6e..c2082eb1e91 100644 --- a/test/spec/modules/relaidoBidAdapter_spec.js +++ b/test/spec/modules/relaidoBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { spec } from 'modules/relaidoBidAdapter.js'; import * as utils from 'src/utils.js'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; import { getStorageManager } from '../../../src/storageManager.js'; const UUID_KEY = 'relaido_uuid'; @@ -59,7 +60,8 @@ describe('RelaidoAdapter', function () { uuid: relaido_uuid, vast: '', playerUrl: 'https://relaido/player.js', - syncUrl: 'https://relaido/sync.html' + syncUrl: 'https://relaido/sync.html', + adomain: ['relaido.co.jp', 'www.cmertv.co.jp'] } }; serverRequest = { @@ -276,6 +278,8 @@ describe('RelaidoAdapter', function () { expect(response.currency).to.equal(serverResponse.body.currency); expect(response.creativeId).to.equal(serverResponse.body.creativeId); expect(response.vastXml).to.equal(serverResponse.body.vast); + expect(response.meta.advertiserDomains).to.equal(serverResponse.body.adomain); + expect(response.meta.mediaType).to.equal(VIDEO); expect(response.ad).to.be.undefined; }); From f957aa779be7fbea758932b43644a3d3a95d41c8 Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Wed, 2 Jun 2021 04:28:08 -0700 Subject: [PATCH 289/303] AdYouLike Bidder: Handle advertiser domains (#6916) * AdYouLike Bidder: Handle advertiser domains * fix linting * update tests * fix linting * fix error --- modules/adyoulikeBidAdapter.js | 3 +- test/spec/modules/adyoulikeBidAdapter_spec.js | 34 +++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 44d8e2e3016..74ce62950f8 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -449,7 +449,8 @@ function createBid(response, bidRequests) { creativeId: response.CreativeID, cpm: response.Price, netRevenue: true, - currency: CURRENCY + currency: CURRENCY, + meta: response.Meta || { advertiserDomains: [] } }; if (request && request.Native) { diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index abf8793865c..e6e95ea5423 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -290,6 +290,19 @@ describe('Adyoulike Adapter', function () { 'Placement': 'placement_0' } ]; + + const testMetaObject = { + 'networkId': 123, + 'advertiserId': '3', + 'advertiserName': 'foobar', + 'advertiserDomains': ['foobar.com'], + 'brandId': '345', + 'brandName': 'Foo', + 'primaryCatId': '34', + 'secondaryCatIds': ['IAB-222', 'IAB-333'], + 'mediaType': 'banner' + }; + const admSample = "\u003cscript id=\"ayl-prebid-a11a121205932e75e622af275681965d\"\u003e\n(function(){\n\twindow.isPrebid = true\n\tvar prebidResults = /*PREBID*/{\"OnEvents\":{\"CLICK\":[{\"Kind\":\"PIXEL_URL\",\"Url\":\"https://testPixelCLICK.com/fake\"}],\"IMPRESSION\":[{\"Kind\":\"PIXEL_URL\",\"Url\":\"https://testPixelIMP.com/fake\"},{\"Kind\":\"JAVASCRIPT_URL\",\"Url\":\"https://testJsIMP.com/fake.js\"}]},\"Disabled\":false,\"Attempt\":\"a11a121205932e75e622af275681965d\",\"ApiPrefix\":\"https://fo-api.omnitagjs.com/fo-api\",\"TrackingPrefix\":\"https://tracking.omnitagjs.com/tracking\",\"DynamicPrefix\":\"https://tag-dyn.omnitagjs.com/fo-dyn\",\"StaticPrefix\":\"https://fo-static.omnitagjs.com/fo-static\",\"BlobPrefix\":\"https://fo-api.omnitagjs.com/fo-api/blobs\",\"SspPrefix\":\"https://fo-ssp.omnitagjs.com/fo-ssp\",\"VisitorPrefix\":\"https://visitor.omnitagjs.com/visitor\",\"Trusted\":true,\"Placement\":\"e622af275681965d3095808561a1e510\",\"PlacementAccess\":\"ALL\",\"Site\":\"6e2df7a92203c3c7a25561ed63f25a27\",\"Lang\":\"EN\",\"SiteLogo\":null,\"HasSponsorImage\":false,\"ResizeIframe\":true,\"IntegrationConfig\":{\"Kind\":\"WIDGET\",\"Widget\":{\"ExtraStyleSheet\":\"\",\"Placeholders\":{\"Body\":{\"Color\":{\"R\":77,\"G\":21,\"B\":82,\"A\":100},\"BackgroundColor\":{\"R\":255,\"G\":255,\"B\":255,\"A\":100},\"FontFamily\":\"Lato\",\"Width\":\"100%\",\"Align\":\"\",\"BoxShadow\":true},\"CallToAction\":{\"Color\":{\"R\":26,\"G\":157,\"B\":212,\"A\":100}},\"Description\":{\"Length\":130},\"Image\":{\"Width\":600,\"Height\":600,\"Lowres\":false,\"Raw\":false},\"Size\":{\"Height\":\"250px\",\"Width\":\"300px\"},\"Sponsor\":{\"Color\":{\"R\":35,\"G\":35,\"B\":35,\"A\":100},\"Label\":true,\"WithoutLogo\":false},\"Title\":{\"Color\":{\"R\":219,\"G\":181,\"B\":255,\"A\":100}}},\"Selector\":{\"Kind\":\"CSS\",\"Css\":\"#ayl-prebid-a11a121205932e75e622af275681965d\"},\"Insertion\":\"AFTER\",\"ClickFormat\":true,\"Creative20\":true,\"WidgetKind\":\"CREATIVE_TEMPLATE_4\"}},\"Legal\":\"Sponsored\",\"ForcedCampaign\":\"f1c80d4bb5643c222ae8de75e9b2f991\",\"ForcedTrack\":\"\",\"ForcedCreative\":\"\",\"ForcedSource\":\"\",\"DisplayMode\":\"DEFAULT\",\"Campaign\":\"f1c80d4bb5643c222ae8de75e9b2f991\",\"CampaignAccess\":\"ALL\",\"CampaignKind\":\"AD_TRAFFIC\",\"DataSource\":\"LOCAL\",\"DataSourceUrl\":\"\",\"DataSourceOnEventsIsolated\":false,\"DataSourceWithoutCookie\":false,\"Content\":{\"Preview\":{\"Thumbnail\":{\"Image\":{\"Kind\":\"EXTERNAL\",\"Data\":{\"External\":{\"Url\":\"https://tag-dyn.omnitagjs.com/fo-dyn/native/preview/image?key=fd4362d35bb174d6f1c80d4bb5643c22\\u0026kind=INTERNAL\\u0026ztop=0.000000\\u0026zleft=0.000000\\u0026zwidth=0.333333\\u0026zheight=1.000000\\u0026width=[width]\\u0026height=[height]\"}},\"ZoneTop\":0,\"ZoneLeft\":0,\"ZoneWidth\":1,\"ZoneHeight\":1,\"Smart\":false,\"NoTransform\":false,\"Quality\":\"NORMAL\"}},\"Text\":{\"CALLTOACTION\":\"Click here to learn more\",\"DESCRIPTION\":\"Considérant l'extrémité conjoncturelle, il serait bon d'anticiper toutes les voies de bon sens.\",\"SPONSOR\":\"Tested by\",\"TITLE\":\"Adserver Traffic Redirect Internal\"},\"Sponsor\":{\"Name\":\"QA Team\"},\"Credit\":{\"Logo\":{\"Resource\":{\"Kind\":\"EXTERNAL\",\"Data\":{\"External\":{\"Url\":\"https://fo-static.omnitagjs.com/fo-static/native/images/info-ayl.png\"}},\"ZoneTop\":0,\"ZoneLeft\":0,\"ZoneWidth\":1,\"ZoneHeight\":1,\"Smart\":false,\"NoTransform\":false,\"Quality\":\"NORMAL\"}},\"Url\":\"https://blobs.omnitagjs.com/adchoice/\"}},\"Landing\":{\"Url\":\"https://www.w3.org/People/mimasa/test/xhtml/entities/entities-11.xhtml#lat1\",\"LegacyTracking\":false},\"ViewButtons\":{\"Close\":{\"Skip\":6000}},\"InternalContentFields\":{\"AnimatedImage\":false}},\"AdDomain\":\"adyoulike.com\",\"Opener\":\"REDIRECT\",\"PerformUITriggers\":[\"CLICK\"],\"RedirectionTarget\":\"TAB\"}/*PREBID*/;\n\tvar insertAds = function insertAds() {\insertAds();\n\t}\n})();\n\u003c/script\u003e"; const responseWithSinglePlacement = [ { @@ -298,6 +311,7 @@ describe('Adyoulike Adapter', function () { 'Ad': admSample, 'Price': 0.5, 'Height': 600, + 'Meta': testMetaObject } ]; @@ -365,7 +379,8 @@ describe('Adyoulike Adapter', function () { privacyLink: 'https://blobs.omnitagjs.com/adchoice/', sponsoredBy: 'QA Team', title: 'Adserver Traffic Redirect Internal', - } + }, + meta: testMetaObject }]; const responseWithMultiplePlacements = [ @@ -617,6 +632,7 @@ describe('Adyoulike Adapter', function () { expect(result[0].ad).to.equal(admSample); expect(result[0].width).to.equal(300); expect(result[0].height).to.equal(600); + expect(result[0].meta).to.deep.equal(testMetaObject); }); it('receive reponse with multiple placement', function () { @@ -636,8 +652,8 @@ describe('Adyoulike Adapter', function () { expect(result[1].height).to.equal(250); }); - it('receive reponse with Native ad', function () { - serverResponse.body = responseWithSingleNative; + it('receive reponse with Native from ad markup', function () { + serverResponse.body = responseWithSinglePlacement; let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(sentBidNative) + '}'}); expect(result.length).to.equal(1); @@ -645,13 +661,19 @@ describe('Adyoulike Adapter', function () { expect(result).to.deep.equal(nativeResult); }); - it('receive reponse with Native from ad markup', function () { - serverResponse.body = responseWithSinglePlacement; + it('receive reponse with Native ad', function () { + serverResponse.body = responseWithSingleNative; let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(sentBidNative) + '}'}); expect(result.length).to.equal(1); - expect(result).to.deep.equal(nativeResult); + const noMeta = [...nativeResult]; + const metaBackup = noMeta[0].meta; + + // this test should return default meta object + noMeta[0].meta = { advertiserDomains: [] }; + + expect(result).to.deep.equal(noMeta); }); }); }); From 7e67b4e3b8b89dae7c04bd5cd68041bfd41fa031 Mon Sep 17 00:00:00 2001 From: Alexandru Date: Wed, 2 Jun 2021 16:19:17 +0300 Subject: [PATCH 290/303] Brightcom Bid Adapter: use getFloor function (#6918) --- modules/brightcomBidAdapter.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/brightcomBidAdapter.js b/modules/brightcomBidAdapter.js index 7d6d77356f1..8299a2331cb 100644 --- a/modules/brightcomBidAdapter.js +++ b/modules/brightcomBidAdapter.js @@ -46,7 +46,7 @@ function buildRequests(bidReqs, bidderRequest) { }, tagid: String(bid.adUnitCode) }; - const bidFloor = utils.getBidIdParameter('bidFloor', bid.params); + const bidFloor = _getBidFloor(bid); if (bidFloor) { imp.bidfloor = bidFloor; } @@ -251,4 +251,20 @@ function _getPercentInView(element, topWin, { w, h } = {}) { return 0; } +function _getBidFloor(bid) { + if (!utils.isFn(bid.getFloor)) { + return bid.params.bidFloor ? bid.params.bidFloor : null; + } + + let floor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*' + }); + if (utils.isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') { + return floor.floor; + } + return null; +} + registerBidder(spec); From b105b753472e0b59690ad13289b7169983d9b605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o?= Date: Wed, 2 Jun 2021 15:39:24 +0200 Subject: [PATCH 291/303] Sublime Bid Adapter : Add support for meta.advertiserDomains (#6920) * Add advertiserDomains stub * Use utils from require * Update version * Replace let to const and fix version --- modules/sublimeBidAdapter.js | 8 ++- test/spec/modules/sublimeBidAdapter_spec.js | 77 +++++++++++++-------- 2 files changed, 54 insertions(+), 31 deletions(-) diff --git a/modules/sublimeBidAdapter.js b/modules/sublimeBidAdapter.js index 41fdb72e76e..854f58df8fe 100644 --- a/modules/sublimeBidAdapter.js +++ b/modules/sublimeBidAdapter.js @@ -9,7 +9,7 @@ const DEFAULT_CURRENCY = 'EUR'; const DEFAULT_PROTOCOL = 'https'; const DEFAULT_TTL = 600; const SUBLIME_ANTENNA = 'antenna.ayads.co'; -const SUBLIME_VERSION = '0.7.1'; +const SUBLIME_VERSION = '0.7.2'; /** * Identify the current device type @@ -207,6 +207,12 @@ function interpretResponse(serverResponse, bidRequest) { sspname: response.sspname || null }; + // We don't support advertiserDomains atm + if (response.advertiserDomains) { + // Creating a stub for Prebid.js 5.0 compliance + bidResponse.meta = Object.assign({}, bidResponse.meta, { advertiserDomains: [] }); + } + bidResponses.push(bidResponse); } diff --git a/test/spec/modules/sublimeBidAdapter_spec.js b/test/spec/modules/sublimeBidAdapter_spec.js index 2e1d65f0533..fab487cb65f 100644 --- a/test/spec/modules/sublimeBidAdapter_spec.js +++ b/test/spec/modules/sublimeBidAdapter_spec.js @@ -47,7 +47,7 @@ describe('Sublime Adapter', function() { }); describe('isBidRequestValid', function() { - let bid = { + const bid = { bidder: 'sublime', params: { zoneId: 24549, @@ -60,14 +60,14 @@ describe('Sublime Adapter', function() { }); it('should return false when required params are not passed', function() { - let bid = Object.assign({}, bid); + const bid = Object.assign({}, bid); bid.params = {}; expect(spec.isBidRequestValid(bid)).to.equal(false); }); }); describe('buildRequests', function() { - let bidRequests = [ + const bidRequests = [ { bidder: 'sublime', adUnitCode: 'sublime_code', @@ -90,7 +90,7 @@ describe('Sublime Adapter', function() { } ]; - let bidderRequest = { + const bidderRequest = { gdprConsent: { consentString: 'EOHEIRCOUCOUIEHZIOEIU-TEST', gdprApplies: true @@ -101,7 +101,7 @@ describe('Sublime Adapter', function() { } }; - let request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest); it('should have a post method', function() { expect(request[0].method).to.equal('POST'); @@ -121,7 +121,7 @@ describe('Sublime Adapter', function() { }); describe('buildRequests: default arguments', function() { - let bidRequests = [{ + const bidRequests = [{ bidder: 'sublime', adUnitCode: 'sublime_code', bidId: 'abc1234', @@ -132,7 +132,7 @@ describe('Sublime Adapter', function() { } }]; - let request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests); it('should have an url that match the default endpoint', function() { expect(request[0].url).to.equal('https://pbjs.sskzlabs.com/bid'); @@ -140,7 +140,7 @@ describe('Sublime Adapter', function() { }); describe('interpretResponse', function() { - let serverResponse = { + const serverResponse = { 'request_id': '3db3773286ee59', 'sspname': 'foo', 'cpm': 0.5, @@ -155,7 +155,7 @@ describe('Sublime Adapter', function() { } }; - let expectedResponse = [ + const expectedResponse = [ { requestId: '', cpm: 0.5, @@ -167,23 +167,23 @@ describe('Sublime Adapter', function() { sspname: 'foo', netRevenue: true, ttl: 600, - pbav: '0.7.1', + pbav: '0.7.2', ad: '', }, ]; - let result = spec.interpretResponse({body: serverResponse}); + const result = spec.interpretResponse({body: serverResponse}); expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); }); it('should get correct default size for 1x1', function() { - let serverResponse = { + const serverResponse = { 'requestId': 'xyz654_2', 'sspname': 'sublime', 'cpm': 0.5, 'ad': '', }; - let bidRequest = { + const bidRequest = { bidder: 'sublime', adUnitCode: 'sublime_code_2', bidId: 'abc1234_2', @@ -197,9 +197,9 @@ describe('Sublime Adapter', function() { } }; - let result = spec.interpretResponse({body: serverResponse}, bidRequest); + const result = spec.interpretResponse({body: serverResponse}, bidRequest); - let expectedResponse = { + const expectedResponse = { requestId: 'xyz654_2', cpm: 0.5, width: 1, @@ -210,7 +210,7 @@ describe('Sublime Adapter', function() { netRevenue: true, ttl: 600, ad: '', - pbav: '0.7.1', + pbav: '0.7.2', sspname: 'sublime' }; @@ -218,24 +218,24 @@ describe('Sublime Adapter', function() { }); it('should return bid empty response', function () { - let serverResponse = ''; - let bidRequest = {}; + const serverResponse = ''; + const bidRequest = {}; - let result = spec.interpretResponse({ body: serverResponse }, bidRequest); + const result = spec.interpretResponse({ body: serverResponse }, bidRequest); - let expectedResponse = []; + const expectedResponse = []; expect(result).to.deep.equal(expectedResponse); }); it('should return bid with default value in response', function () { - let serverResponse = { + const serverResponse = { 'requestId': 'xyz654_2', 'sspname': 'sublime', 'ad': '', }; - let bidRequest = { + const bidRequest = { bidder: 'sublime', adUnitCode: 'sublime_code_2', bidId: 'abc1234_2', @@ -249,9 +249,9 @@ describe('Sublime Adapter', function() { } }; - let result = spec.interpretResponse({ body: serverResponse }, bidRequest); + const result = spec.interpretResponse({ body: serverResponse }, bidRequest); - let expectedResponse = { + const expectedResponse = { requestId: 'xyz654_2', cpm: 0, width: 1, @@ -263,20 +263,20 @@ describe('Sublime Adapter', function() { netRevenue: true, ttl: 600, ad: '', - pbav: '0.7.1', + pbav: '0.7.2', }; expect(result[0]).to.deep.equal(expectedResponse); }); it('should return empty bid response because of timeout', function () { - let serverResponse = { + const serverResponse = { 'requestId': 'xyz654_2', 'timeout': true, 'ad': '', }; - let bidRequest = { + const bidRequest = { bidder: 'sublime', adUnitCode: 'sublime_code_2', bidId: 'abc1234_2', @@ -290,9 +290,9 @@ describe('Sublime Adapter', function() { } }; - let result = spec.interpretResponse({ body: serverResponse }, bidRequest); + const result = spec.interpretResponse({ body: serverResponse }, bidRequest); - let expectedResponse = []; + const expectedResponse = []; expect(result).to.deep.equal(expectedResponse); @@ -300,11 +300,28 @@ describe('Sublime Adapter', function() { spec.onTimeout(result); }); }); + + it('should add advertiserDomains', function() { + const responseWithAdvertiserDomains = utils.deepClone(serverResponse); + responseWithAdvertiserDomains.advertiserDomains = ['a_sublime_adomain']; + + const bidRequest = { + bidder: 'sublime', + params: { + zoneId: 456, + } + }; + + const result = spec.interpretResponse({ body: responseWithAdvertiserDomains }, bidRequest); + + expect(Object.keys(result[0].meta)).to.include.members(['advertiserDomains']); + expect(Object.keys(result[0].meta.advertiserDomains)).to.deep.equal([]); + }); }); describe('onBidWon', function() { let sandbox; - let bid = { foo: 'bar' }; + const bid = { foo: 'bar' }; beforeEach(function () { sandbox = sinon.sandbox.create(); From db50c5b49bb7bfdf68f2a36ae7295fac60ff9f37 Mon Sep 17 00:00:00 2001 From: Margaret Liu Date: Wed, 2 Jun 2021 09:27:32 -0500 Subject: [PATCH 292/303] LockerDome Bid Adapter: support for meta.advertiserDomains (#6921) * Add lockerdome adapter advertiserDomains support stub for Prebid 5.0 * Add lockerdome adapter advertiserDomains support stub for Prebid 5.0 * fix linting error Co-authored-by: Chris Huie --- modules/lockerdomeBidAdapter.js | 5 ++++- test/spec/modules/lockerdomeBidAdapter_spec.js | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/lockerdomeBidAdapter.js b/modules/lockerdomeBidAdapter.js index 80c40b39f9a..4e30519c6d3 100644 --- a/modules/lockerdomeBidAdapter.js +++ b/modules/lockerdomeBidAdapter.js @@ -66,7 +66,10 @@ export const spec = { currency: bid.currency, netRevenue: bid.netRevenue, ad: bid.ad, - ttl: bid.ttl + ttl: bid.ttl, + meta: { + advertiserDomains: bid.adomain && Array.isArray(bid.adomain) ? bid.adomain : [] + } }; }); }, diff --git a/test/spec/modules/lockerdomeBidAdapter_spec.js b/test/spec/modules/lockerdomeBidAdapter_spec.js index 42e3f52e533..9e3d7981300 100644 --- a/test/spec/modules/lockerdomeBidAdapter_spec.js +++ b/test/spec/modules/lockerdomeBidAdapter_spec.js @@ -180,7 +180,8 @@ describe('LockerDomeAdapter', function () { currency: 'USD', netRevenue: true, ad: '', - ttl: 300 + ttl: 300, + adomain: ['example.com'] }, { requestId: '4510f2834773ce', @@ -191,7 +192,8 @@ describe('LockerDomeAdapter', function () { currency: 'USD', netRevenue: true, ad: '', - ttl: 300 + ttl: 300, + adomain: ['example.com'] }] } }; @@ -217,6 +219,9 @@ describe('LockerDomeAdapter', function () { expect(interpretedResponse[0].netRevenue).to.equal(serverResponse.body.bids[0].netRevenue); expect(interpretedResponse[0].ad).to.equal(serverResponse.body.bids[0].ad); expect(interpretedResponse[0].ttl).to.equal(serverResponse.body.bids[0].ttl); + expect(interpretedResponse[0]).to.have.property('meta'); + expect(interpretedResponse[0].meta).to.have.property('advertiserDomains'); + expect(interpretedResponse[0].meta.advertiserDomains).to.deep.equal(serverResponse.body.bids[0].adomain); expect(interpretedResponse[1].requestId).to.equal(serverResponse.body.bids[1].requestId); expect(interpretedResponse[1].cpm).to.equal(serverResponse.body.bids[1].cpm); @@ -227,6 +232,9 @@ describe('LockerDomeAdapter', function () { expect(interpretedResponse[1].netRevenue).to.equal(serverResponse.body.bids[1].netRevenue); expect(interpretedResponse[1].ad).to.equal(serverResponse.body.bids[1].ad); expect(interpretedResponse[1].ttl).to.equal(serverResponse.body.bids[1].ttl); + expect(interpretedResponse[1]).to.have.property('meta'); + expect(interpretedResponse[1].meta).to.have.property('advertiserDomains'); + expect(interpretedResponse[1].meta.advertiserDomains).to.deep.equal(serverResponse.body.bids[1].adomain); }); }); }); From b271db1f72258847a27f9e043b7c47e9e8c98991 Mon Sep 17 00:00:00 2001 From: Gena Date: Wed, 2 Jun 2021 17:51:08 +0300 Subject: [PATCH 293/303] Update Adtelligent, Adtarget, ViewDeos adapters to support adomain (#6917) * Update Adtelligent, Adtarget, ViewDeos adapters to support adomain * fix * fix tests --- modules/adtargetBidAdapter.js | 5 ++++- modules/adtelligentBidAdapter.js | 5 ++++- modules/viewdeosDXBidAdapter.js | 5 ++++- test/spec/modules/adtargetBidAdapter_spec.js | 13 ++++++++++--- test/spec/modules/adtelligentBidAdapter_spec.js | 17 ++++++++++++----- test/spec/modules/viewdeosDXBidAdapter_spec.js | 16 +++++++++++----- 6 files changed, 45 insertions(+), 16 deletions(-) diff --git a/modules/adtargetBidAdapter.js b/modules/adtargetBidAdapter.js index b22addec54f..1779ba94371 100644 --- a/modules/adtargetBidAdapter.js +++ b/modules/adtargetBidAdapter.js @@ -173,7 +173,10 @@ function createBid(bidResponse, bidRequest) { cpm: bidResponse.cpm, netRevenue: true, mediaType, - ttl: 300 + ttl: 300, + meta: { + advertiserDomains: bidResponse.adomain || [] + } }; if (mediaType === BANNER) { diff --git a/modules/adtelligentBidAdapter.js b/modules/adtelligentBidAdapter.js index 9ca4b95dfd2..d21931a6dcb 100644 --- a/modules/adtelligentBidAdapter.js +++ b/modules/adtelligentBidAdapter.js @@ -248,7 +248,10 @@ function createBid(bidResponse, bidRequest) { cpm: bidResponse.cpm, netRevenue: true, mediaType, - ttl: 300 + ttl: 300, + meta: { + advertiserDomains: bidResponse.adomain || [] + } }; if (mediaType === BANNER) { diff --git a/modules/viewdeosDXBidAdapter.js b/modules/viewdeosDXBidAdapter.js index 22c16ab5b34..212759642f5 100644 --- a/modules/viewdeosDXBidAdapter.js +++ b/modules/viewdeosDXBidAdapter.js @@ -190,7 +190,10 @@ function createBid(bidResponse, mediaType, bidderParams) { cpm: bidResponse.cpm, netRevenue: true, mediaType, - ttl: 3600 + ttl: 3600, + meta: { + advertiserDomains: bidResponse.adomain || [] + } }; if (mediaType === DISPLAY) { diff --git a/test/spec/modules/adtargetBidAdapter_spec.js b/test/spec/modules/adtargetBidAdapter_spec.js index 5a867e7dd52..d1221d24022 100644 --- a/test/spec/modules/adtargetBidAdapter_spec.js +++ b/test/spec/modules/adtargetBidAdapter_spec.js @@ -45,7 +45,8 @@ const SERVER_VIDEO_RESPONSE = { 'height': 480, 'cur': 'USD', 'width': 640, - 'cpm': 0.9 + 'cpm': 0.9, + 'adomain': ['a.com'] }] }; const SERVER_DISPLAY_RESPONSE = { @@ -107,7 +108,10 @@ const videoEqResponse = [{ height: 480, width: 640, ttl: 300, - cpm: 0.9 + cpm: 0.9, + meta: { + advertiserDomains: ['a.com'] + } }]; const displayEqResponse = [{ @@ -120,7 +124,10 @@ const displayEqResponse = [{ height: 250, width: 300, ttl: 300, - cpm: 0.9 + cpm: 0.9, + meta: { + advertiserDomains: [] + } }]; describe('adtargetBidAdapter', () => { diff --git a/test/spec/modules/adtelligentBidAdapter_spec.js b/test/spec/modules/adtelligentBidAdapter_spec.js index e6916997133..4cfb367efb3 100644 --- a/test/spec/modules/adtelligentBidAdapter_spec.js +++ b/test/spec/modules/adtelligentBidAdapter_spec.js @@ -80,9 +80,9 @@ const SERVER_VIDEO_RESPONSE = { 'height': 480, 'cur': 'USD', 'width': 640, - 'cpm': 0.9 - } - ] + 'cpm': 0.9, + 'adomain': ['a.com'] + }] }; const SERVER_OUSTREAM_VIDEO_RESPONSE = SERVER_VIDEO_RESPONSE; const SERVER_DISPLAY_RESPONSE = { @@ -163,7 +163,10 @@ const videoEqResponse = [{ height: 480, width: 640, ttl: 300, - cpm: 0.9 + cpm: 0.9, + meta: { + advertiserDomains: ['a.com'] + } }]; const displayEqResponse = [{ @@ -177,7 +180,11 @@ const displayEqResponse = [{ height: 250, width: 300, ttl: 300, - cpm: 0.9 + cpm: 0.9, + meta: { + advertiserDomains: [] + } + }]; describe('adtelligentBidAdapter', () => { diff --git a/test/spec/modules/viewdeosDXBidAdapter_spec.js b/test/spec/modules/viewdeosDXBidAdapter_spec.js index f9bee1b0efe..31df9244ada 100644 --- a/test/spec/modules/viewdeosDXBidAdapter_spec.js +++ b/test/spec/modules/viewdeosDXBidAdapter_spec.js @@ -39,9 +39,9 @@ const SERVER_VIDEO_RESPONSE = { 'height': 480, 'cur': 'USD', 'width': 640, - 'cpm': 0.9 - } - ] + 'cpm': 0.9, + 'adomain': ['a.com'] + }] }; const SERVER_OUSTREAM_VIDEO_RESPONSE = SERVER_VIDEO_RESPONSE; @@ -123,7 +123,10 @@ const videoEqResponse = [{ height: 480, width: 640, ttl: 3600, - cpm: 0.9 + cpm: 0.9, + meta: { + advertiserDomains: ['a.com'] + } }]; const displayEqResponse = [{ @@ -136,7 +139,10 @@ const displayEqResponse = [{ height: 250, width: 300, ttl: 3600, - cpm: 0.9 + cpm: 0.9, + meta: { + advertiserDomains: [] + } }]; describe('viewdeosDXBidAdapter', function () { From 42093f41109a9e7e5505243c9cd77d4a2dc932f3 Mon Sep 17 00:00:00 2001 From: Giudici-a <34242194+Giudici-a@users.noreply.github.com> Date: Wed, 2 Jun 2021 17:07:44 +0200 Subject: [PATCH 294/303] Adot Bid Adapter: add the advertising domains support (#6876) --- modules/adotBidAdapter.js | 54 +++++- modules/adotBidAdapter.md | 44 +++-- test/spec/modules/adotBidAdapter_spec.js | 225 +++++++++++++---------- 3 files changed, 191 insertions(+), 132 deletions(-) diff --git a/modules/adotBidAdapter.js b/modules/adotBidAdapter.js index 502ef05b0d5..ddd9531eb43 100644 --- a/modules/adotBidAdapter.js +++ b/modules/adotBidAdapter.js @@ -74,7 +74,7 @@ function isBanner(mediaTypes) { } function isVideo(mediaTypes) { - return isPlainObject(mediaTypes) && isPlainObject(mediaTypes.video); + return isPlainObject(mediaTypes) && 'video' in mediaTypes; } function validateBanner(banner) { @@ -104,13 +104,16 @@ function validateMediaSizes(mediaSize) { function validateParameters(parameters, adUnit) { if (isVideo(adUnit.mediaTypes)) { if (!isPlainObject(parameters)) return false; + if (!isPlainObject(adUnit.mediaTypes.video)) return false; if (!validateVideoParameters(parameters.video, adUnit)) return false; } return true; } -function validateVideoParameters(video, adUnit) { +function validateVideoParameters(videoParams, adUnit) { + const video = adUnit.mediaTypes.video; + if (!video) return false; if (!isArray(video.mimes)) return false; @@ -124,9 +127,9 @@ function validateVideoParameters(video, adUnit) { if (video.protocols.length === 0) return false; if (!video.protocols.every(isNumber)) return false; - if (isInstream(adUnit.mediaTypes.video)) { - if (!video.instreamContext) return false; - if (SUPPORTED_INSTREAM_CONTEXTS.indexOf(video.instreamContext) === -1) return false; + if (isInstream(video)) { + if (!videoParams.instreamContext) return false; + if (SUPPORTED_INSTREAM_CONTEXTS.indexOf(videoParams.instreamContext) === -1) return false; } return true; @@ -203,7 +206,7 @@ function generateImpressionsFromAdUnit(acc, adUnit) { if (mediaType === 'banner') return acc.concat(generateBannerFromAdUnit(impId, data, params)); if (mediaType === 'video') return acc.concat({id: impId, video: generateVideoFromAdUnit(data, params), pmp, ext}); - if (mediaType === 'native') return acc.concat({id: impId, native: generateNativeFromAdUnit(data, params), pmp, ext}); + if (mediaType === 'native') return acc.concat({id: impId, native: generateNativeFromAdUnit(data), pmp, ext}); }, []); return acc.concat(imps); @@ -226,25 +229,52 @@ function generateBannerFromAdUnit(impId, data, params) { function generateVideoFromAdUnit(data, params) { const {playerSize} = data; + const video = data + const hasPlayerSize = isArray(playerSize) && playerSize.length > 0; - const {position, video = {}} = params; const {minDuration, maxDuration, protocols} = video; const size = {width: hasPlayerSize ? playerSize[0][0] : null, height: hasPlayerSize ? playerSize[0][1] : null}; const duration = {min: isNumber(minDuration) ? minDuration : null, max: isNumber(maxDuration) ? maxDuration : null}; + const startdelay = computeStartDelay(data, params); return { mimes: SUPPORTED_VIDEO_MIMES, + skip: video.skippable || 0, w: size.width, h: size.height, - startdelay: computeStartDelay(data, params), + startdelay: startdelay, + linearity: video.linearity || null, minduration: duration.min, maxduration: duration.max, protocols, - pos: position || 0 + api: getApi(protocols), + format: hasPlayerSize ? playerSize.map(s => { + return {w: s[0], h: s[1]}; + }) : null, + pos: video.position || 0 }; } +function getApi(protocols) { + let defaultValue = [2]; + let listProtocols = [ + {key: 'VPAID_1_0', value: 1}, + {key: 'VPAID_2_0', value: 2}, + {key: 'MRAID_1', value: 3}, + {key: 'ORMMA', value: 4}, + {key: 'MRAID_2', value: 5}, + {key: 'MRAID_3', value: 6}, + ]; + if (protocols) { + return listProtocols.filter(p => { + return protocols.indexOf(p.key) !== -1; + }).map(p => p.value) + } else { + return defaultValue; + } +} + function isInstream(video) { return isPlainObject(video) && (video.context === 'instream'); } @@ -263,7 +293,7 @@ function computeStartDelay(data, params) { return null; } -function generateNativeFromAdUnit(data, params) { +function generateNativeFromAdUnit(data) { const {type} = data; const presetFormatter = type && NATIVE_PRESET_FORMATTERS[data.type]; const nativeFields = presetFormatter ? presetFormatter(data) : data; @@ -500,6 +530,10 @@ function generateAdFromBid(bid, bidResponse, serverRequest) { mediaType: bid.ext.adot.media_type, }; + if (bid.adomain) { + base.meta = { advertiserDomains: bid.adomain }; + } + if (isBidANative(bid)) return {...base, native: formatNativeData(bid)}; const size = getSizeFromBid(bid, impressionData); diff --git a/modules/adotBidAdapter.md b/modules/adotBidAdapter.md index 98a4a1a5970..894a592ec18 100644 --- a/modules/adotBidAdapter.md +++ b/modules/adotBidAdapter.md @@ -47,23 +47,22 @@ const adUnit = { context: 'outstream', // Video dimensions supported by the video ad unit. // Each ad unit size is formatted as follows: [width, height]. - playerSize: [[300, 250]] + playerSize: [[300, 250]], + // Content MIME types supported by the ad unit. + mimes: ['video/mp4'], + // Minimum accepted video ad duration (in seconds). + minDuration: 5, + // Maximum accepted video ad duration (in seconds). + maxDuration: 35, + // Video protocols supported by the ad unit (see the OpenRTB 2.5 specifications, + // section 5.8). + protocols: [2, 3] } }, bids: [{ bidder: 'adot', params: { - video: { - // Content MIME types supported by the ad unit. - mimes: ['video/mp4'], - // Minimum accepted video ad duration (in seconds). - minDuration: 5, - // Maximum accepted video ad duration (in seconds). - maxDuration: 35, - // Video protocols supported by the ad unit (see the OpenRTB 2.5 specifications, - // section 5.8). - protocols: [2, 3] - } + video: {} } }] } @@ -82,23 +81,22 @@ const adUnit = { context: 'instream', // Video dimensions supported by the video ad unit. // Each ad unit size is formatted as follows: [width, height]. - playerSize: [[300, 250]] + playerSize: [[300, 250]], + // Content MIME types supported by the ad unit. + mimes: ['video/mp4'], + // Minimum accepted video ad duration (in seconds). + minDuration: 5, + // Maximum accepted video ad duration (in seconds). + maxDuration: 35, + // Video protocols supported by the ad unit (see the OpenRTB 2.5 specifications, + // section 5.8). + protocols: [2, 3] } }, bids: [{ bidder: 'adot', params: { video: { - // Content MIME types supported by the ad unit. - mimes: ['video/mp4'], - // Minimum accepted video ad duration (in seconds). - minDuration: 5, - // Maximum accepted video ad duration (in seconds). - maxDuration: 35, - // Video protocols supported by the ad unit (see the OpenRTB 2.5 specifications, - // section 5.8). - protocols: [2, 3], - // Instream video context. Must be either 'pre-roll', 'mid-roll' or 'post-roll'. instreamContext: 'pre-roll' } } diff --git a/test/spec/modules/adotBidAdapter_spec.js b/test/spec/modules/adotBidAdapter_spec.js index d580cd763a4..40605b17b20 100644 --- a/test/spec/modules/adotBidAdapter_spec.js +++ b/test/spec/modules/adotBidAdapter_spec.js @@ -25,19 +25,16 @@ describe('Adot Adapter', function () { bidder: 'adot', bidderRequestId: 'bid_request_id', bidId: 'bid_id', - params: { + params: {}, + mediaTypes: { video: { + context: 'outstream', + playerSize: [[300, 250]], mimes: ['video/mp4'], minDuration: 5, maxDuration: 30, protocols: [2, 3] } - }, - mediaTypes: { - video: { - context: 'outstream', - playerSize: [[300, 250]] - } } }, @@ -48,17 +45,17 @@ describe('Adot Adapter', function () { bidId: 'bid_id', params: { video: { - instreamContext: 'pre-roll', - mimes: ['video/mp4'], - minDuration: 5, - maxDuration: 30, - protocols: [2, 3] + instreamContext: 'pre-roll' } }, mediaTypes: { video: { context: 'instream', - playerSize: [[300, 250]] + playerSize: [[300, 250]], + mimes: ['video/mp4'], + minDuration: 5, + maxDuration: 30, + protocols: [2, 3] } } }, @@ -557,6 +554,7 @@ describe('Adot Adapter', function () { price: 1.5, h: 350, w: 300, + adomain: ['adot'], ext: { adot: { media_type: 'banner' @@ -568,6 +566,7 @@ describe('Adot Adapter', function () { crid: 'creative_id_2', adm: 'creative_data_2_${AUCTION_PRICE}', nurl: 'win_notice_url_2_${AUCTION_PRICE}', + adomain: ['adot'], price: 2.5, h: 400, w: 350, @@ -913,14 +912,14 @@ describe('Adot Adapter', function () { it('should return true when given an ad unit without minimum duration parameter', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.minDuration = undefined; + adUnit.mediaTypes.video.minDuration = undefined; expect(spec.isBidRequestValid(adUnit)).to.equal(true); }); it('should return true when given an ad unit without maximum duration parameter', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.maxDuration = undefined; + adUnit.mediaTypes.video.maxDuration = undefined; expect(spec.isBidRequestValid(adUnit)).to.equal(true); }); @@ -941,84 +940,84 @@ describe('Adot Adapter', function () { it('should return false when given an ad unit without video parameters', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video = undefined; + adUnit.mediaTypes.video = undefined; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit with invalid video parameters', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video = 'bad_bidder_parameters'; + adUnit.mediaTypes.video = 'bad_bidder_parameters'; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit without mime types parameter', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.mimes = undefined; + adUnit.mediaTypes.video.mimes = undefined; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit with an invalid mime types parameter', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.mimes = 'bad_mime_types'; + adUnit.mediaTypes.video.mimes = 'bad_mime_types'; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit with an empty mime types parameter', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.mimes = []; + adUnit.mediaTypes.video.mimes = []; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit with an invalid mime types parameter value', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.mimes = [200]; + adUnit.mediaTypes.video.mimes = [200]; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit with an invalid minimum duration parameter', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.minDuration = 'bad_min_duration'; + adUnit.mediaTypes.video.minDuration = 'bad_min_duration'; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit with an invalid maximum duration parameter', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.maxDuration = 'bad_max_duration'; + adUnit.mediaTypes.video.maxDuration = 'bad_max_duration'; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit without protocols parameter', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.protocols = undefined; + adUnit.mediaTypes.video.protocols = undefined; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit with an invalid protocols parameter', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.protocols = 'bad_protocols'; + adUnit.mediaTypes.video.protocols = 'bad_protocols'; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit with an empty protocols parameter', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.protocols = []; + adUnit.mediaTypes.video.protocols = []; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); it('should return false when given an ad unit with an invalid protocols parameter value', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.protocols = ['bad_protocols_value']; + adUnit.mediaTypes.video.protocols = ['bad_protocols_value']; expect(spec.isBidRequestValid(adUnit)).to.equal(false); }); @@ -1452,13 +1451,13 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); - expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); - expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.protocols); }); it('should return a server request with one impression when given a valid pre-roll instream ad unit', function () { @@ -1476,13 +1475,13 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.exist.and.to.be.a('number').and.to.equal(0); expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); - expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); - expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.protocols); }); it('should return a server request with one impression when given a valid mid-roll instream ad unit', function () { @@ -1500,13 +1499,13 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.exist.and.to.be.a('number').and.to.equal(-1); expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); - expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); - expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.protocols); }); it('should return a server request with one impression when given a valid post-roll instream ad unit', function () { @@ -1524,13 +1523,13 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.exist.and.to.be.a('number').and.to.equal(-2); expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); - expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); - expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.protocols); }); it('should return a server request with one impression when given a valid ad unit without player size', function () { @@ -1548,13 +1547,13 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); expect(serverRequests[0].data.imp[0].video.w).to.equal(null); expect(serverRequests[0].data.imp[0].video.h).to.equal(null); - expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); - expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.protocols); }); it('should return a server request with one impression when given a valid ad unit with an empty player size', function () { @@ -1572,13 +1571,13 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); expect(serverRequests[0].data.imp[0].video.w).to.equal(null); expect(serverRequests[0].data.imp[0].video.h).to.equal(null); - expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); - expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.protocols); }); it('should return a server request with one impression when given a valid ad unit with multiple player sizes', function () { @@ -1596,18 +1595,18 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); - expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); - expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.protocols); }); it('should return a server request with one impression when given a valid ad unit without minimum duration', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.minDuration = undefined; + adUnit.mediaTypes.video.minDuration = undefined; const adUnits = [adUnit]; @@ -1620,18 +1619,18 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); expect(serverRequests[0].data.imp[0].video.minduration).to.equal(null); - expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.protocols); }); it('should return a server request with one impression when given a valid ad unit without maximum duration', function () { const adUnit = utils.deepClone(examples.adUnit_video_outstream); - adUnit.params.video.maxDuration = undefined; + adUnit.mediaTypes.video.maxDuration = undefined; const adUnits = [adUnit]; @@ -1644,13 +1643,13 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); - expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.minDuration); expect(serverRequests[0].data.imp[0].video.maxduration).to.equal(null); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.protocols); }); it('should return a server request with two impressions when given two valid ad units with different impression identifiers', function () { @@ -1671,31 +1670,31 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); - expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); - expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.protocols); expect(serverRequests[0].data.imp[1]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[1].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0`); expect(serverRequests[0].data.imp[1].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[1].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[1].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[1].video.startdelay).to.equal(null); expect(serverRequests[0].data.imp[1].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][0]); expect(serverRequests[0].data.imp[1].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][1]); - expect(serverRequests[0].data.imp[1].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.minDuration); - expect(serverRequests[0].data.imp[1].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.maxDuration); - expect(serverRequests[0].data.imp[1].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].params.video.protocols); + expect(serverRequests[0].data.imp[1].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.minDuration); + expect(serverRequests[0].data.imp[1].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[1].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].mediaTypes.video.protocols); }); it('should return a server request with one overridden impression when given two valid ad units with identical identifiers', function () { const adUnit_1 = utils.deepClone(examples.adUnit_video_outstream); - adUnit_1.params.video.minDuration = 10; + adUnit_1.mediaTypes.video.minDuration = 10; const adUnit_2 = utils.deepClone(examples.adUnit_video_outstream); - adUnit_2.params.video.minDuration = 15; + adUnit_2.mediaTypes.video.minDuration = 15; const adUnits = [adUnit_1, adUnit_2]; @@ -1708,13 +1707,13 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][0]); expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][1]); - expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.minDuration); - expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.maxDuration); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].mediaTypes.video.protocols); }); it('should return two server requests with one impression when given two valid ad units with different bid request identifiers', function () { @@ -1735,25 +1734,25 @@ describe('Adot Adapter', function () { expect(serverRequests[0].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[0].bidId}_0`); expect(serverRequests[0].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[0].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[0].data.imp[0].video.startdelay).to.equal(null); expect(serverRequests[0].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][0]); expect(serverRequests[0].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.playerSize[0][1]); - expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.minDuration); - expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].params.video.maxDuration); - expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.protocols); + expect(serverRequests[0].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.minDuration); + expect(serverRequests[0].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[0].mediaTypes.video.maxDuration); + expect(serverRequests[0].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.protocols); expect(serverRequests[1].data).to.exist.and.to.be.an('object'); expect(serverRequests[1].data.imp).to.exist.and.to.be.an('array').and.to.have.lengthOf(1); expect(serverRequests[1].data.imp[0]).to.exist.and.to.be.an('object'); expect(serverRequests[1].data.imp[0].id).to.exist.and.to.be.a('string').and.to.equal(`${adUnits[1].bidId}_0`); expect(serverRequests[1].data.imp[0].video).to.exist.and.to.be.an('object'); - expect(serverRequests[1].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].params.video.mimes); + expect(serverRequests[1].data.imp[0].video.mimes).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[0].mediaTypes.video.mimes); expect(serverRequests[1].data.imp[0].video.startdelay).to.equal(null); expect(serverRequests[1].data.imp[0].video.w).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][0]); expect(serverRequests[1].data.imp[0].video.h).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.playerSize[0][1]); - expect(serverRequests[1].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.minDuration); - expect(serverRequests[1].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].params.video.maxDuration); - expect(serverRequests[1].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].params.video.protocols); + expect(serverRequests[1].data.imp[0].video.minduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.minDuration); + expect(serverRequests[1].data.imp[0].video.maxduration).to.exist.and.to.be.a('number').and.to.equal(adUnits[1].mediaTypes.video.maxDuration); + expect(serverRequests[1].data.imp[0].video.protocols).to.exist.and.to.be.an('array').and.to.deep.equal(adUnits[1].mediaTypes.video.protocols); }); }); @@ -2121,6 +2120,48 @@ describe('Adot Adapter', function () { expect(ads[1].renderer).to.equal(null); }); + it('should return two ads when given a valid server response with two bids that contains adomain', function () { + const serverRequest = examples.serverRequest_banner_twoImps; + + const serverResponse = examples.serverResponse_banner_twoBids; + + const ads = spec.interpretResponse(serverResponse, serverRequest); + + const admWithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[0].adm, serverResponse.body.seatbid[0].bid[0].price); + const adm2WithAuctionPriceReplaced = utils.replaceAuctionPrice(serverResponse.body.seatbid[0].bid[1].adm, serverResponse.body.seatbid[0].bid[1].price); + + expect(ads).to.be.an('array').and.to.have.length(2); + + expect(ads[0].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[0].bidId); + expect(ads[0].ad).to.exist.and.to.be.a('string').and.to.have.string(admWithAuctionPriceReplaced); + expect(ads[0].adUrl).to.equal(null); + expect(ads[0].vastXml).to.equal(null); + expect(ads[0].vastUrl).to.equal(null); + expect(ads[0].meta.advertiserDomains[0]).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].adomain[0]) + expect(ads[0].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[0].crid); + expect(ads[0].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].price); + expect(ads[0].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[0].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[0].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[0].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].h); + expect(ads[0].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[0].w); + expect(ads[0].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[0].renderer).to.equal(null); + expect(ads[1].requestId).to.exist.and.to.be.a('string').and.to.equal(serverRequest._adot_internal.impressions[1].bidId); + expect(ads[1].meta.advertiserDomains[0]).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[1].adomain[0]) + expect(ads[1].ad).to.exist.and.to.be.a('string').and.to.have.string(adm2WithAuctionPriceReplaced); + expect(ads[1].adUrl).to.equal(null); + expect(ads[1].creativeId).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.seatbid[0].bid[1].crid); + expect(ads[1].cpm).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].price); + expect(ads[1].currency).to.exist.and.to.be.a('string').and.to.equal(serverResponse.body.cur); + expect(ads[1].netRevenue).to.exist.and.to.be.a('boolean').and.to.equal(true); + expect(ads[1].ttl).to.exist.and.to.be.a('number').and.to.equal(10); + expect(ads[1].height).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].h); + expect(ads[1].width).to.exist.and.to.be.a('number').and.to.equal(serverResponse.body.seatbid[0].bid[1].w); + expect(ads[1].mediaType).to.exist.and.to.be.a('string').and.to.equal('banner'); + expect(ads[1].renderer).to.equal(null); + }); + it('should return no ad when not given a server response', function () { const ads = spec.interpretResponse(null); @@ -3084,20 +3125,6 @@ describe('Adot Adapter', function () { expect(ads).to.be.an('array').and.to.have.length(1); expect(ads[0].renderer).to.be.an('object'); }); - - it('should append a command to the ad rendering queue when executing the renderer', function (done) { - const serverRequest = examples.serverRequest_video_outstream; - const serverResponse = examples.serverResponse_video_outstream; - - const [ad] = spec.interpretResponse(serverResponse, serverRequest); - - this.spyAdRenderingQueue(ad); - - executeAdRenderer(ad, () => { - expect(ad.renderer.push.calledOnce).to.equal(true); - expect(ad.renderer.push.firstCall.args[0]).to.exist.and.to.be.a('function'); - }, done); - }); }); }); From b04d2129d4de0752577fcdf061c1363870cb6db0 Mon Sep 17 00:00:00 2001 From: Jonas Gresens <5290643+jgresens@users.noreply.github.com> Date: Wed, 2 Jun 2021 17:26:56 +0200 Subject: [PATCH 295/303] Smaato bid adapter: Rework multi imp support (#6814) * Smaato bid adapter: Refactor, clean and add tests * Smaato bid adapter: Create individual request to Smaatos server per valid bid request --- modules/smaatoBidAdapter.js | 181 ++-- test/spec/modules/smaatoBidAdapter_spec.js | 968 +++++++++++---------- 2 files changed, 604 insertions(+), 545 deletions(-) diff --git a/modules/smaatoBidAdapter.js b/modules/smaatoBidAdapter.js index fbb4c14e5f8..719d78892ce 100644 --- a/modules/smaatoBidAdapter.js +++ b/modules/smaatoBidAdapter.js @@ -5,75 +5,22 @@ import { BANNER, VIDEO } from '../src/mediaTypes.js'; const BIDDER_CODE = 'smaato'; const SMAATO_ENDPOINT = 'https://prebid.ad.smaato.net/oapi/prebid'; -const CLIENT = 'prebid_js_$prebid.version$_1.1' - -/** -* Transform BidRequest to OpenRTB-formatted BidRequest Object -* @param {Array} validBidRequests -* @param {any} bidderRequest -* @returns {string} -*/ -const buildOpenRtbBidRequestPayload = (validBidRequests, bidderRequest) => { - /** - * Turn incoming prebid sizes into openRtb format mapping. - * @param {*} sizes in format [[10, 10], [20, 20]] - * @returns array of openRtb format mappings [{w: 10, h: 10}, {w: 20, h: 20}] - */ - const parseSizes = (sizes) => { - return sizes.map((size) => { - return {w: size[0], h: size[1]}; - }) - } - - const imp = validBidRequests.map(br => { - const bannerMediaType = utils.deepAccess(br, 'mediaTypes.banner'); - const videoMediaType = utils.deepAccess(br, 'mediaTypes.video'); - let result = { - id: br.bidId, - tagid: utils.deepAccess(br, 'params.adspaceId') - } - - if (bannerMediaType) { - const sizes = parseSizes(utils.getAdUnitSizes(br)); - result.banner = { - w: sizes[0].w, - h: sizes[0].h, - format: sizes - } - } - - if (videoMediaType) { - result.video = { - mimes: videoMediaType.mimes, - minduration: videoMediaType.minduration, - startdelay: videoMediaType.startdelay, - linearity: videoMediaType.linearity, - w: videoMediaType.playerSize[0][0], - h: videoMediaType.playerSize[0][1], - maxduration: videoMediaType.maxduration, - skip: videoMediaType.skip, - protocols: videoMediaType.protocols, - ext: { - rewarded: videoMediaType.ext && videoMediaType.ext.rewarded ? videoMediaType.ext.rewarded : 0 - }, - skipmin: videoMediaType.skipmin, - api: videoMediaType.api - } - } - - return result; - }); +const SMAATO_CLIENT = 'prebid_js_$prebid.version$_1.2' +const buildOpenRtbBidRequest = (bidRequest, bidderRequest) => { const request = { id: bidderRequest.auctionId, at: 1, - imp, + imp: [{ + id: bidRequest.bidId, + tagid: utils.deepAccess(bidRequest, 'params.adspaceId') + }], cur: ['USD'], tmax: bidderRequest.timeout, site: { id: window.location.hostname, publisher: { - id: utils.deepAccess(validBidRequests[0], 'params.publisherId') + id: utils.deepAccess(bidRequest, 'params.publisherId') }, domain: window.location.hostname, page: window.location.href, @@ -94,12 +41,40 @@ const buildOpenRtbBidRequestPayload = (validBidRequests, bidderRequest) => { ext: {} }, ext: { - client: CLIENT + client: SMAATO_CLIENT } }; - let ortb2 = config.getConfig('ortb2') || {}; + if (utils.deepAccess(bidRequest, 'mediaTypes.banner')) { + const sizes = utils.getAdUnitSizes(bidRequest).map((size) => ({w: size[0], h: size[1]})); + request.imp[0].banner = { + w: sizes[0].w, + h: sizes[0].h, + format: sizes + } + } + const videoMediaType = utils.deepAccess(bidRequest, 'mediaTypes.video'); + if (videoMediaType) { + request.imp[0].video = { + mimes: videoMediaType.mimes, + minduration: videoMediaType.minduration, + startdelay: videoMediaType.startdelay, + linearity: videoMediaType.linearity, + w: videoMediaType.playerSize[0][0], + h: videoMediaType.playerSize[0][1], + maxduration: videoMediaType.maxduration, + skip: videoMediaType.skip, + protocols: videoMediaType.protocols, + ext: { + rewarded: videoMediaType.ext && videoMediaType.ext.rewarded ? videoMediaType.ext.rewarded : 0 + }, + skipmin: videoMediaType.skipmin, + api: videoMediaType.api + } + } + + let ortb2 = config.getConfig('ortb2') || {}; Object.assign(request.user, ortb2.user); Object.assign(request.site, ortb2.site); @@ -112,20 +87,19 @@ const buildOpenRtbBidRequestPayload = (validBidRequests, bidderRequest) => { utils.deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent); } - if (utils.deepAccess(validBidRequests[0], 'params.app')) { - const geo = utils.deepAccess(validBidRequests[0], 'params.app.geo'); + if (utils.deepAccess(bidRequest, 'params.app')) { + const geo = utils.deepAccess(bidRequest, 'params.app.geo'); utils.deepSetValue(request, 'device.geo', geo); - const ifa = utils.deepAccess(validBidRequests[0], 'params.app.ifa') + const ifa = utils.deepAccess(bidRequest, 'params.app.ifa') utils.deepSetValue(request, 'device.ifa', ifa); } - const eids = utils.deepAccess(validBidRequests[0], 'userIdAsEids'); + const eids = utils.deepAccess(bidRequest, 'userIdAsEids'); if (eids && eids.length) { utils.deepSetValue(request, 'user.ext.eids', eids); } - utils.logInfo('[SMAATO] OpenRTB Request:', request); - return JSON.stringify(request); + return request } export const spec = { @@ -133,41 +107,41 @@ export const spec = { supportedMediaTypes: [BANNER, VIDEO], /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ isBidRequestValid: (bid) => { return typeof bid.params === 'object' && - typeof bid.params.publisherId === 'string' && - typeof bid.params.adspaceId === 'string'; + typeof bid.params.publisherId === 'string' && + typeof bid.params.adspaceId === 'string'; }, - /** - * Make a server request from the list of BidRequests. - * - * @param {validBidRequests[]} - an array of bids - * @return ServerRequest Info describing the request to the server. - */ buildRequests: (validBidRequests, bidderRequest) => { - utils.logInfo('[SMAATO] Client version:', CLIENT); - return { - method: 'POST', - url: validBidRequests[0].params.endpoint || SMAATO_ENDPOINT, - data: buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest), - options: { - withCredentials: true, - crossOrigin: true, - } - }; + utils.logInfo('[SMAATO] Client version:', SMAATO_CLIENT); + + return validBidRequests.map((validBidRequest) => { + const openRtbBidRequest = buildOpenRtbBidRequest(validBidRequest, bidderRequest); + utils.logInfo('[SMAATO] OpenRTB Request:', openRtbBidRequest); + + return { + method: 'POST', + url: validBidRequest.params.endpoint || SMAATO_ENDPOINT, + data: JSON.stringify(openRtbBidRequest), + options: { + withCredentials: true, + crossOrigin: true, + } + }; + }); }, /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ interpretResponse: (serverResponse, bidRequest) => { // response is empty (HTTP 204) if (utils.isEmpty(serverResponse.body)) { @@ -235,15 +209,14 @@ export const spec = { }, /** - * Register the user sync pixels which should be dropped after the auction. - * - * @param {SyncOptions} syncOptions Which user syncs are allowed? - * @param {ServerResponse[]} serverResponses List of server's responses. - * @return {UserSync[]} The user syncs which should be dropped. - */ + * Register the user sync pixels which should be dropped after the auction. + * + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + */ getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { - const syncs = [] - return syncs; + return []; } } registerBidder(spec); diff --git a/test/spec/modules/smaatoBidAdapter_spec.js b/test/spec/modules/smaatoBidAdapter_spec.js index 1bc77fc9572..0abc8463d28 100644 --- a/test/spec/modules/smaatoBidAdapter_spec.js +++ b/test/spec/modules/smaatoBidAdapter_spec.js @@ -1,200 +1,36 @@ import { spec } from 'modules/smaatoBidAdapter.js'; import * as utils from 'src/utils.js'; -import {config} from 'src/config.js'; -import {createEidsArray} from 'modules/userId/eids.js'; - -const imageAd = { - image: { - img: { - url: 'https://prebid/static/ad.jpg', - w: 320, - h: 50, - ctaurl: 'https://prebid/track/ctaurl' - }, - impressiontrackers: [ - 'https://prebid/track/imp/1', - 'https://prebid/track/imp/2' - ], - clicktrackers: [ - 'https://prebid/track/click/1' - ] - } -}; - -const richmediaAd = { - richmedia: { - mediadata: { - content: '

RICHMEDIA CONTENT

', - w: 800, - h: 600 - }, - impressiontrackers: [ - 'https://prebid/track/imp/1', - 'https://prebid/track/imp/2' - ], - clicktrackers: [ - 'https://prebid/track/click/1' - ] - } -}; +import { config } from 'src/config.js'; +import { createEidsArray } from 'modules/userId/eids.js'; const ADTYPE_IMG = 'Img'; const ADTYPE_RICHMEDIA = 'Richmedia'; const ADTYPE_VIDEO = 'Video'; -const site = { - keywords: 'power tools,drills' -}; - -const user = { - keywords: 'a,b', - gender: 'M', - yob: 1984 -}; - -const openRtbBidResponse = (adType) => { - let adm = ''; - - switch (adType) { - case ADTYPE_IMG: - adm = JSON.stringify(imageAd); - break; - case ADTYPE_RICHMEDIA: - adm = JSON.stringify(richmediaAd); - break; - case ADTYPE_VIDEO: - adm = ''; - break; - default: - throw Error('Invalid AdType'); - } - - let resp = { - body: { - bidid: '04db8629-179d-4bcd-acce-e54722969006', - cur: 'USD', - ext: {}, - id: '5ebea288-f13a-4754-be6d-4ade66c68877', - seatbid: [ - { - bid: [ - { - 'adm': adm, - 'adomain': [ - 'smaato.com' - ], - 'bidderName': 'smaato', - 'cid': 'CM6523', - 'crid': 'CR69381', - 'dealid': '12345', - 'id': '6906aae8-7f74-4edd-9a4f-f49379a3cadd', - 'impid': '226416e6e6bf41', - 'iurl': 'https://prebid/iurl', - 'nurl': 'https://prebid/nurl', - 'price': 0.01, - 'w': 350, - 'h': 50 - } - ], - seat: 'CM6523' - } - ], - }, - headers: { - get: function (header) { - if (header === 'X-SMT-ADTYPE') { - return adType; - } - } - } - }; - return resp; -}; - const request = { method: 'POST', url: 'https://prebid.ad.smaato.net/oapi/prebid', data: '' }; -const interpretedBidsImg = [ - { - requestId: '226416e6e6bf41', - cpm: 0.01, - width: 350, - height: 50, - ad: '
\"\"\"\"
', - ttl: 300, - creativeId: 'CR69381', - dealId: '12345', - netRevenue: true, - currency: 'USD', - meta: { - advertiserDomains: ['smaato.com'], - agencyId: 'CM6523', - networkName: 'smaato', - mediaType: 'banner' - } - } -]; - -const interpretedBidsRichmedia = [ - { - requestId: '226416e6e6bf41', - cpm: 0.01, - width: 350, - height: 50, - ad: '

RICHMEDIA CONTENT

\"\"\"\"
', - ttl: 300, - creativeId: 'CR69381', - dealId: '12345', - netRevenue: true, - currency: 'USD', - meta: { - advertiserDomains: ['smaato.com'], - agencyId: 'CM6523', - networkName: 'smaato', - mediaType: 'banner' - } - } -]; - -const interpretedBidsVideo = [ - { - requestId: '226416e6e6bf41', - cpm: 0.01, - width: 350, - height: 50, - vastXml: '', - ttl: 300, - creativeId: 'CR69381', - dealId: '12345', - netRevenue: true, - currency: 'USD', - meta: { - advertiserDomains: ['smaato.com'], - agencyId: 'CM6523', - networkName: 'smaato', - mediaType: 'video' - } - } -]; +const REFERRER = 'http://example.com/page.html' +const CONSENT_STRING = 'HFIDUYFIUYIUYWIPOI87392DSU' const defaultBidderRequest = { gdprConsent: { - consentString: 'HFIDUYFIUYIUYWIPOI87392DSU', + consentString: CONSENT_STRING, gdprApplies: true }, uspConsent: 'uspConsentString', refererInfo: { - referer: 'http://example.com/page.html', + referer: REFERRER, }, timeout: 1200 }; const minimalBidderRequest = { refererInfo: { - referer: 'http://example.com/page.html', + referer: REFERRER, } }; @@ -221,77 +57,6 @@ const singleBannerBidRequest = { bidderWinsCount: 0 }; -const singleVideoBidRequest = { - bidder: 'smaato', - params: { - publisherId: 'publisherId', - adspaceId: 'adspaceId' - }, - mediaTypes: { - video: { - context: 'outstream', - playerSize: [[768, 1024]], - mimes: ['video\/mp4', 'video\/quicktime', 'video\/3gpp', 'video\/x-m4v'], - minduration: 5, - maxduration: 30, - startdelay: 0, - linearity: 1, - protocols: [7], - skip: 1, - skipmin: 5, - api: [7], - ext: {rewarded: 0} - } - }, - adUnitCode: '/19968336/header-bid-tag-0', - transactionId: 'transactionId', - sizes: [[300, 50]], - bidId: 'bidId', - bidderRequestId: 'bidderRequestId', - auctionId: 'auctionId', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 -}; - -const combinedBannerAndVideoBidRequest = { - bidder: 'smaato', - params: { - publisherId: 'publisherId', - adspaceId: 'adspaceId' - }, - mediaTypes: { - banner: { - sizes: [[300, 50]] - }, - video: { - context: 'outstream', - playerSize: [[768, 1024]], - mimes: ['video\/mp4', 'video\/quicktime', 'video\/3gpp', 'video\/x-m4v'], - minduration: 5, - maxduration: 30, - startdelay: 0, - linearity: 1, - protocols: [7], - skip: 1, - skipmin: 5, - api: [7], - ext: {rewarded: 0} - } - }, - adUnitCode: '/19968336/header-bid-tag-0', - transactionId: 'transactionId', - sizes: [[300, 50]], - bidId: 'bidId', - bidderRequestId: 'bidderRequestId', - auctionId: 'auctionId', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0 -}; - const inAppBidRequest = { bidder: 'smaato', params: { @@ -322,36 +87,10 @@ const inAppBidRequest = { bidderWinsCount: 0 }; -const userIdBidRequest = { - bidder: 'smaato', - params: { - publisherId: 'publisherId', - adspaceId: 'adspaceId' - }, - mediaTypes: { - banner: { - sizes: [[300, 50]] - } - }, - adUnitCode: '/19968336/header-bid-tag-0', - transactionId: 'transactionId', - sizes: [[300, 50]], - bidId: 'bidId', - bidderRequestId: 'bidderRequestId', - auctionId: 'auctionId', - src: 'client', - bidRequestsCount: 1, - bidderRequestsCount: 1, - bidderWinsCount: 0, - userId: { - criteoId: '123456', - tdid: '89145' - }, - userIdAsEids: createEidsArray({ - criteoId: '123456', - tdid: '89145' - }) -}; +const extractPayloadOfFirstAndOnlyRequest = (reqs) => { + expect(reqs).to.have.length(1); + return JSON.parse(reqs[0].data); +} describe('smaatoBidAdapterTest', () => { describe('isBidRequestValid', () => { @@ -368,222 +107,557 @@ describe('smaatoBidAdapterTest', () => { }); describe('buildRequests', () => { - beforeEach(() => { - this.req = JSON.parse(spec.buildRequests([singleBannerBidRequest], defaultBidderRequest).data); - this.sandbox = sinon.sandbox.create(); - }); + describe('common', () => { + it('auction type is 1 (first price auction)', () => { + const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); - afterEach(() => { - this.sandbox.restore(); - }); + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.at).to.be.equal(1); + }) - it('can override endpoint', () => { - const overridenEndpoint = 'https://prebid/bidder'; - let bidRequest = utils.deepClone(singleBannerBidRequest); - utils.deepSetValue(bidRequest, 'params.endpoint', overridenEndpoint); - const actualEndpoint = spec.buildRequests([bidRequest], defaultBidderRequest).url; - expect(actualEndpoint).to.equal(overridenEndpoint); - }); + it('currency is US dollar', () => { + const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); - it('sends correct imps', () => { - expect(this.req.imp).to.deep.equal([ - { - id: 'bidId', - banner: { - w: 300, - h: 50, - format: [ - { - h: 50, - w: 300 + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.cur).to.be.deep.equal(['USD']); + }) + + it('can override endpoint', () => { + const overridenEndpoint = 'https://prebid/bidder'; + const updatedBidRequest = utils.deepClone(singleBannerBidRequest); + utils.deepSetValue(updatedBidRequest, 'params.endpoint', overridenEndpoint); + + const reqs = spec.buildRequests([updatedBidRequest], defaultBidderRequest); + + expect(reqs).to.have.length(1); + expect(reqs[0].url).to.equal(overridenEndpoint); + }); + + it('sends correct imp', () => { + const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.imp).to.deep.equal([ + { + id: 'bidId', + banner: { + w: 300, + h: 50, + format: [ + { + h: 50, + w: 300 + } + ] + }, + tagid: 'adspaceId' + } + ]); + }); + + it('sends correct site', () => { + const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.site.id).to.exist.and.to.be.a('string'); + expect(req.site.domain).to.exist.and.to.be.a('string'); + expect(req.site.page).to.exist.and.to.be.a('string'); + expect(req.site.ref).to.equal(REFERRER); + expect(req.site.publisher.id).to.equal('publisherId'); + }) + + it('sends gdpr applies if exists', () => { + const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.regs.ext.gdpr).to.equal(1); + expect(req.user.ext.consent).to.equal(CONSENT_STRING); + }); + + it('sends no gdpr applies if no gdpr exists', () => { + const reqs = spec.buildRequests([singleBannerBidRequest], minimalBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.regs.ext.gdpr).to.not.exist; + expect(req.user.ext.consent).to.not.exist; + }); + + it('sends us_privacy if exists', () => { + const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.regs.ext.us_privacy).to.equal('uspConsentString'); + }); + + it('sends tmax', () => { + const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.tmax).to.equal(1200); + }); + + it('sends no us_privacy if no us_privacy exists', () => { + const reqs = spec.buildRequests([singleBannerBidRequest], minimalBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.regs.ext.us_privacy).to.not.exist; + }); + + it('sends first party data', () => { + this.sandbox = sinon.sandbox.create() + this.sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + ortb2: { + site: { + keywords: 'power tools,drills' + }, + user: { + keywords: 'a,b', + gender: 'M', + yob: 1984 } - ] - }, - tagid: 'adspaceId' - } - ]) - }); + } + }; + return utils.deepAccess(config, key); + }); + + const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.user.gender).to.equal('M'); + expect(req.user.yob).to.equal(1984); + expect(req.user.keywords).to.eql('a,b'); + expect(req.user.ext.consent).to.equal(CONSENT_STRING); + expect(req.site.keywords).to.eql('power tools,drills'); + expect(req.site.publisher.id).to.equal('publisherId'); + this.sandbox.restore(); + }); - it('sends correct site', () => { - expect(this.req.site.id).to.exist.and.to.be.a('string'); - expect(this.req.site.domain).to.exist.and.to.be.a('string'); - expect(this.req.site.page).to.exist.and.to.be.a('string'); - expect(this.req.site.ref).to.equal('http://example.com/page.html'); - expect(this.req.site.publisher.id).to.equal('publisherId'); - }) + it('has no user ids', () => { + const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); - it('sends gdpr applies if exists', () => { - expect(this.req.regs.ext.gdpr).to.equal(1); - expect(this.req.user.ext.consent).to.equal('HFIDUYFIUYIUYWIPOI87392DSU'); + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.user.ext.eids).to.not.exist; + }); }); - it('sends no gdpr applies if no gdpr exists', () => { - let req_without_gdpr = JSON.parse(spec.buildRequests([singleBannerBidRequest], minimalBidderRequest).data); - expect(req_without_gdpr.regs.ext.gdpr).to.not.exist; - expect(req_without_gdpr.user.ext.consent).to.not.exist; - }); + describe('multiple requests', () => { + it('build individual server request for each bid request', () => { + const bidRequest1 = utils.deepClone(singleBannerBidRequest); + const bidRequest1BidId = '1111'; + utils.deepSetValue(bidRequest1, 'bidId', bidRequest1BidId); + const bidRequest2 = utils.deepClone(singleBannerBidRequest); + const bidRequest2BidId = '2222'; + utils.deepSetValue(bidRequest2, 'bidId', bidRequest2BidId); - it('sends usp if exists', () => { - expect(this.req.regs.ext.us_privacy).to.equal('uspConsentString'); - }); + const reqs = spec.buildRequests([bidRequest1, bidRequest2], defaultBidderRequest); - it('sends tmax', () => { - expect(this.req.tmax).to.equal(1200); + expect(reqs).to.have.length(2); + expect(JSON.parse(reqs[0].data).imp[0].id).to.be.equal(bidRequest1BidId); + expect(JSON.parse(reqs[1].data).imp[0].id).to.be.equal(bidRequest2BidId); + }); }); - it('sends no usp if no usp exists', () => { - let req_without_usp = JSON.parse(spec.buildRequests([singleBannerBidRequest], minimalBidderRequest).data); - expect(req_without_usp.regs.ext.us_privacy).to.not.exist; - }); + describe('buildRequests for video imps', () => { + it('sends correct video imps', () => { + const singleVideoBidRequest = { + bidder: 'smaato', + params: { + publisherId: 'publisherId', + adspaceId: 'adspaceId' + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [[768, 1024]], + mimes: ['video/mp4', 'video/quicktime', 'video/3gpp', 'video/x-m4v'], + minduration: 5, + maxduration: 30, + startdelay: 0, + linearity: 1, + protocols: [7], + skip: 1, + skipmin: 5, + api: [7], + ext: {rewarded: 0} + } + }, + adUnitCode: '/19968336/header-bid-tag-0', + transactionId: 'transactionId', + sizes: [[300, 50]], + bidId: 'bidId', + bidderRequestId: 'bidderRequestId', + auctionId: 'auctionId', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }; - it('sends fp data', () => { - this.sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - ortb2: { - site, - user + const reqs = spec.buildRequests([singleVideoBidRequest], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.imp).to.deep.equal([ + { + id: 'bidId', + video: { + mimes: ['video/mp4', 'video/quicktime', 'video/3gpp', 'video/x-m4v'], + minduration: 5, + startdelay: 0, + linearity: 1, + h: 1024, + maxduration: 30, + skip: 1, + protocols: [7], + ext: { + rewarded: 0 + }, + skipmin: 5, + api: [7], + w: 768 + }, + tagid: 'adspaceId' } + ]); + }); + + it('allows combined banner and video imp in single bid request', () => { + const combinedBannerAndVideoBidRequest = { + bidder: 'smaato', + params: { + publisherId: 'publisherId', + adspaceId: 'adspaceId' + }, + mediaTypes: { + banner: { + sizes: [[300, 50]] + }, + video: { + context: 'outstream', + playerSize: [[768, 1024]], + mimes: ['video/mp4', 'video/quicktime', 'video/3gpp', 'video/x-m4v'], + minduration: 5, + maxduration: 30, + startdelay: 0, + linearity: 1, + protocols: [7], + skip: 1, + skipmin: 5, + api: [7], + ext: {rewarded: 0} + } + }, + adUnitCode: '/19968336/header-bid-tag-0', + transactionId: 'transactionId', + sizes: [[300, 50]], + bidId: 'bidId', + bidderRequestId: 'bidderRequestId', + auctionId: 'auctionId', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 }; - return utils.deepAccess(config, key); + + const reqs = spec.buildRequests([combinedBannerAndVideoBidRequest], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.imp).to.deep.equal([ + { + id: 'bidId', + banner: { + w: 300, + h: 50, + format: [ + { + h: 50, + w: 300 + } + ] + }, + video: { + mimes: ['video/mp4', 'video/quicktime', 'video/3gpp', 'video/x-m4v'], + minduration: 5, + startdelay: 0, + linearity: 1, + h: 1024, + maxduration: 30, + skip: 1, + protocols: [7], + ext: { + rewarded: 0 + }, + skipmin: 5, + api: [7], + w: 768 + }, + tagid: 'adspaceId' + } + ]); }); - let bidRequest = utils.deepClone(singleBannerBidRequest); - let req_fpd = JSON.parse(spec.buildRequests([bidRequest], defaultBidderRequest).data); - expect(req_fpd.user.gender).to.equal('M'); - expect(req_fpd.user.yob).to.equal(1984); - expect(req_fpd.user.keywords).to.eql('a,b'); - expect(req_fpd.user.ext.consent).to.equal('HFIDUYFIUYIUYWIPOI87392DSU'); - expect(req_fpd.site.keywords).to.eql('power tools,drills'); - expect(req_fpd.site.publisher.id).to.equal('publisherId'); }); - it('has no user ids', () => { - expect(this.req.user.ext.eids).to.not.exist; + describe('in-app requests', () => { + it('add geo and ifa info to device object', () => { + const reqs = spec.buildRequests([inAppBidRequest], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.device.geo).to.deep.equal({'lat': 33.3, 'lon': -88.8}); + expect(req.device.ifa).to.equal('aDeviceId'); + }); + + it('when geo is missing, then add only ifa to device object', () => { + const inAppBidRequestWithoutGeo = utils.deepClone(inAppBidRequest); + delete inAppBidRequestWithoutGeo.params.app.geo + + const reqs = spec.buildRequests([inAppBidRequestWithoutGeo], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.device.geo).to.not.exist; + expect(req.device.ifa).to.equal('aDeviceId'); + }); + + it('add no specific device info if param does not exist', () => { + const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.device.geo).to.not.exist; + expect(req.device.ifa).to.not.exist; + }); }); - }); - describe('buildRequests for video imps', () => { - it('sends correct video imps', () => { - let req = JSON.parse(spec.buildRequests([singleVideoBidRequest], defaultBidderRequest).data); - expect(req.imp).to.deep.equal([ - { - id: 'bidId', - video: { - mimes: ['video\/mp4', 'video\/quicktime', 'video\/3gpp', 'video\/x-m4v'], - minduration: 5, - startdelay: 0, - linearity: 1, - h: 1024, - maxduration: 30, - skip: 1, - protocols: [7], - ext: { - rewarded: 0 - }, - skipmin: 5, - api: [7], - w: 768 + describe('user ids in requests', () => { + it('user ids are added to user.ext.eids', () => { + const userIdBidRequest = { + bidder: 'smaato', + params: { + publisherId: 'publisherId', + adspaceId: 'adspaceId' }, - tagid: 'adspaceId' - } - ]) - }); - it('allows combines banner and video imp in single bid request', () => { - let req = JSON.parse(spec.buildRequests([combinedBannerAndVideoBidRequest], defaultBidderRequest).data); - expect(req.imp).to.deep.equal([ - { - id: 'bidId', - banner: { - w: 300, - h: 50, - format: [ - { - h: 50, - w: 300 - } - ] + mediaTypes: { + banner: { + sizes: [[300, 50]] + } }, - video: { - mimes: ['video\/mp4', 'video\/quicktime', 'video\/3gpp', 'video\/x-m4v'], - minduration: 5, - startdelay: 0, - linearity: 1, - h: 1024, - maxduration: 30, - skip: 1, - protocols: [7], - ext: { - rewarded: 0 - }, - skipmin: 5, - api: [7], - w: 768 + adUnitCode: '/19968336/header-bid-tag-0', + transactionId: 'transactionId', + sizes: [[300, 50]], + bidId: 'bidId', + bidderRequestId: 'bidderRequestId', + auctionId: 'auctionId', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0, + userId: { + criteoId: '123456', + tdid: '89145' }, - tagid: 'adspaceId' - } - ]) - }); - it('allows two imps in the same bid request', () => { - let req = JSON.parse(spec.buildRequests([singleBannerBidRequest, singleBannerBidRequest], defaultBidderRequest).data); - expect(req.imp).to.have.length(2); - }); - }); + userIdAsEids: createEidsArray({ + criteoId: '123456', + tdid: '89145' + }) + }; - describe('in-app requests', () => { - it('add geo and ifa info to device object', () => { - let req = JSON.parse(spec.buildRequests([inAppBidRequest], defaultBidderRequest).data); - expect(req.device.geo).to.deep.equal({'lat': 33.3, 'lon': -88.8}); - expect(req.device.ifa).to.equal('aDeviceId'); - }); - it('add only ifa to device object', () => { - let inAppBidRequestWithoutGeo = utils.deepClone(inAppBidRequest); - delete inAppBidRequestWithoutGeo.params.app.geo - let req = JSON.parse(spec.buildRequests([inAppBidRequestWithoutGeo], defaultBidderRequest).data); + const reqs = spec.buildRequests([userIdBidRequest], defaultBidderRequest); - expect(req.device.geo).to.not.exist; - expect(req.device.ifa).to.equal('aDeviceId'); - }); - it('add no specific device info if param does not exist', () => { - let req = JSON.parse(spec.buildRequests([singleBannerBidRequest], defaultBidderRequest).data); - expect(req.device.geo).to.not.exist; - expect(req.device.ifa).to.not.exist; + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.user.ext.eids).to.exist; + expect(req.user.ext.eids).to.have.length(2); + }); }); }); - describe('user ids in requests', () => { - it('user ids are added to user.ext.eids', () => { - let req = JSON.parse(spec.buildRequests([userIdBidRequest], defaultBidderRequest).data); - expect(req.user.ext.eids).to.exist; - expect(req.user.ext.eids).to.have.length(2); + describe('interpretResponse', () => { + const buildOpenRtbBidResponse = (adType) => { + let adm = ''; + + switch (adType) { + case ADTYPE_IMG: + adm = JSON.stringify({ + image: { + img: { + url: 'https://prebid/static/ad.jpg', + w: 320, + h: 50, + ctaurl: 'https://prebid/track/ctaurl' + }, + impressiontrackers: [ + 'https://prebid/track/imp/1', + 'https://prebid/track/imp/2' + ], + clicktrackers: [ + 'https://prebid/track/click/1' + ] + } + }); + break; + case ADTYPE_RICHMEDIA: + adm = JSON.stringify({ + richmedia: { + mediadata: { + content: '

RICHMEDIA CONTENT

', + w: 800, + h: 600 + }, + impressiontrackers: [ + 'https://prebid/track/imp/1', + 'https://prebid/track/imp/2' + ], + clicktrackers: [ + 'https://prebid/track/click/1' + ] + } + }); + break; + case ADTYPE_VIDEO: + adm = ''; + break; + default: + throw Error('Invalid AdType'); + } + + return { + body: { + bidid: '04db8629-179d-4bcd-acce-e54722969006', + cur: 'USD', + ext: {}, + id: '5ebea288-f13a-4754-be6d-4ade66c68877', + seatbid: [ + { + bid: [ + { + 'adm': adm, + 'adomain': [ + 'smaato.com' + ], + 'bidderName': 'smaato', + 'cid': 'CM6523', + 'crid': 'CR69381', + 'dealid': '12345', + 'id': '6906aae8-7f74-4edd-9a4f-f49379a3cadd', + 'impid': '226416e6e6bf41', + 'iurl': 'https://prebid/iurl', + 'nurl': 'https://prebid/nurl', + 'price': 0.01, + 'w': 350, + 'h': 50 + } + ], + seat: 'CM6523' + } + ], + }, + headers: { + get: function (header) { + if (header === 'X-SMT-ADTYPE') { + return adType; + } + } + } + }; + }; + + it('returns empty array on no bid responses', () => { + const response_with_empty_body = {body: {}} + + const bids = spec.interpretResponse(response_with_empty_body, request); + + expect(bids).to.be.empty }); - }); - describe('interpretResponse', () => { it('single image reponse', () => { - const bids = spec.interpretResponse(openRtbBidResponse(ADTYPE_IMG), request); - assert.deepStrictEqual(bids, interpretedBidsImg); + const bids = spec.interpretResponse(buildOpenRtbBidResponse(ADTYPE_IMG), request); + + expect(bids).to.deep.equal([ + { + requestId: '226416e6e6bf41', + cpm: 0.01, + width: 350, + height: 50, + ad: '
', + ttl: 300, + creativeId: 'CR69381', + dealId: '12345', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['smaato.com'], + agencyId: 'CM6523', + networkName: 'smaato', + mediaType: 'banner' + } + } + ]); }); + it('single richmedia reponse', () => { - const bids = spec.interpretResponse(openRtbBidResponse(ADTYPE_RICHMEDIA), request); - assert.deepStrictEqual(bids, interpretedBidsRichmedia); + const bids = spec.interpretResponse(buildOpenRtbBidResponse(ADTYPE_RICHMEDIA), request); + + expect(bids).to.deep.equal([ + { + requestId: '226416e6e6bf41', + cpm: 0.01, + width: 350, + height: 50, + ad: '

RICHMEDIA CONTENT

', + ttl: 300, + creativeId: 'CR69381', + dealId: '12345', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['smaato.com'], + agencyId: 'CM6523', + networkName: 'smaato', + mediaType: 'banner' + } + } + ]); }); + it('single video reponse', () => { - const bids = spec.interpretResponse(openRtbBidResponse(ADTYPE_VIDEO), request); - assert.deepStrictEqual(bids, interpretedBidsVideo); + const bids = spec.interpretResponse(buildOpenRtbBidResponse(ADTYPE_VIDEO), request); + + expect(bids).to.deep.equal([ + { + requestId: '226416e6e6bf41', + cpm: 0.01, + width: 350, + height: 50, + vastXml: '', + ttl: 300, + creativeId: 'CR69381', + dealId: '12345', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['smaato.com'], + agencyId: 'CM6523', + networkName: 'smaato', + mediaType: 'video' + } + } + ]); }); + it('ignores bid response with invalid ad type', () => { - let resp = openRtbBidResponse(ADTYPE_IMG); + const resp = buildOpenRtbBidResponse(ADTYPE_IMG); resp.headers.get = (header) => { if (header === 'X-SMT-ADTYPE') { return undefined; } } + const bids = spec.interpretResponse(resp, request); + expect(bids).to.be.empty }); + it('uses correct TTL when expire header exists', () => { const clock = sinon.useFakeTimers(); clock.tick(2000); - let resp = openRtbBidResponse(ADTYPE_IMG); + const resp = buildOpenRtbBidResponse(ADTYPE_IMG); resp.headers.get = (header) => { if (header === 'X-SMT-ADTYPE') { return ADTYPE_IMG; @@ -592,15 +666,27 @@ describe('smaatoBidAdapterTest', () => { return 2000 + (400 * 1000); } } + const bids = spec.interpretResponse(resp, request); + expect(bids[0].ttl).to.equal(400); + clock.restore(); }); + it('uses net revenue flag send from server', () => { - let resp = openRtbBidResponse(ADTYPE_IMG); + const resp = buildOpenRtbBidResponse(ADTYPE_IMG); resp.body.seatbid[0].bid[0].ext = {net: false}; + const bids = spec.interpretResponse(resp, request); + expect(bids[0].netRevenue).to.equal(false); }) }); + + describe('getUserSyncs', () => { + it('returns no pixels', () => { + expect(spec.getUserSyncs()).to.be.empty + }) + }) }); From 948cb1d04c8e8b740ee1013068b4f32d503fb53e Mon Sep 17 00:00:00 2001 From: mediaconsortium-develop <76139568+mediaconsortium-develop@users.noreply.github.com> Date: Thu, 3 Jun 2021 00:33:24 +0900 Subject: [PATCH 296/303] dgkeyword RTD Provider: add new real time data module (#6912) * re-open pull request reference #6410 * delete Overview * for test , comment out. * for test, comment out. * for test. comment out setConfig. * execute resetConfig aftet test. * execute resetConfig after test. * set emppty bidderConfig after test * fix setBidderConfig and test code * fix test code. * fix * for test resetBidderConfig in config * resetBidderConfig afterEach * setBidderConfig is not executed when ci test --- modules/.submodules.json | 1 + modules/dgkeywordRtdProvider.js | 134 +++++++ modules/dgkeywordRtdProvider.md | 29 ++ .../spec/modules/dgkeywordRtdProvider_spec.js | 351 ++++++++++++++++++ 4 files changed, 515 insertions(+) create mode 100644 modules/dgkeywordRtdProvider.js create mode 100644 modules/dgkeywordRtdProvider.md create mode 100644 test/spec/modules/dgkeywordRtdProvider_spec.js diff --git a/modules/.submodules.json b/modules/.submodules.json index 0a10044a78e..74ebc021a6d 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -36,6 +36,7 @@ ], "rtdModule": [ "browsiRtdProvider", + "dgkeywordRtdProvider", "geoedgeRtdProvider", "haloRtdProvider", "jwplayerRtdProvider", diff --git a/modules/dgkeywordRtdProvider.js b/modules/dgkeywordRtdProvider.js new file mode 100644 index 00000000000..58cec36a6b9 --- /dev/null +++ b/modules/dgkeywordRtdProvider.js @@ -0,0 +1,134 @@ +/** + * This module adds dgkeyword provider to the real time data module + * The {@link module:modules/realTimeData} module is required + * The module will get keywords from 1plux profile api. + * This module can work only with AppNexusBidAdapter. + * @module modules/dgkeywordProvider + * @requires module:modules/realTimeData + */ + +import * as utils from '../src/utils.js'; +import { ajax } from '../src/ajax.js'; +import { submodule } from '../src/hook.js'; +import { getGlobal } from '../src/prebidGlobal.js'; + +/** + * get keywords from api server. and set keywords. + * @param {Object} reqBidsConfigObj + * @param {function} callback + * @param {Object} moduleConfig + * @param {Object} userConsent + */ +export function getDgKeywordsAndSet(reqBidsConfigObj, callback, moduleConfig, userConsent) { + const URL = 'https://mediaconsortium.profiles.tagger.opecloud.com/api/v1?url='; + const PROFILE_TIMEOUT_MS = 1000; + const timeout = (moduleConfig && moduleConfig.params && moduleConfig.params.timeout && Number(moduleConfig.params.timeout) > 0) ? Number(moduleConfig.params.timeout) : PROFILE_TIMEOUT_MS; + const url = (moduleConfig && moduleConfig.params && moduleConfig.params.url) ? moduleConfig.params.url : URL + encodeURIComponent(window.location.href); + const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits; + let isFinish = false; + utils.logMessage('[dgkeyword sub module]', adUnits, timeout); + let setKeywordTargetBidders = getTargetBidderOfDgKeywords(adUnits); + if (setKeywordTargetBidders.length <= 0) { + utils.logMessage('[dgkeyword sub module] no dgkeyword targets.'); + callback(); + } else { + utils.logMessage('[dgkeyword sub module] dgkeyword targets:', setKeywordTargetBidders); + utils.logMessage('[dgkeyword sub module] get targets from profile api start.'); + ajax(url, { + success: function(response) { + const res = JSON.parse(response); + if (!isFinish) { + utils.logMessage('[dgkeyword sub module] get targets from profile api end.'); + if (res) { + let keywords = {}; + if (res['s'] != null && res['s'].length > 0) { + keywords['opeaud'] = res['s']; + } + if (res['t'] != null && res['t'].length > 0) { + keywords['opectx'] = res['t']; + } + if (Object.keys(keywords).length > 0) { + const targetBidKeys = {} + for (let bid of setKeywordTargetBidders) { + // set keywords to params + bid.params.keywords = keywords; + if (!targetBidKeys[bid.bidder]) { + targetBidKeys[bid.bidder] = true; + } + } + + if (!reqBidsConfigObj._ignoreSetOrtb2) { + // set keywrods to ortb2 + let addOrtb2 = {}; + utils.deepSetValue(addOrtb2, 'site.keywords', keywords); + utils.deepSetValue(addOrtb2, 'user.keywords', keywords); + const ortb2 = {ortb2: addOrtb2}; + reqBidsConfigObj.setBidderConfig({ bidders: Object.keys(targetBidKeys), config: ortb2 }); + } + } + } + isFinish = true; + } + callback(); + }, + error: function(errorStatus) { + // error occur + utils.logError('[dgkeyword sub module] profile api access error.', errorStatus); + callback(); + } + }, null, { + withCredentials: true, + contentType: 'application/json', + }); + setTimeout(function () { + if (!isFinish) { + // profile api timeout + utils.logInfo('[dgkeyword sub module] profile api timeout. [timeout: ' + timeout + 'ms]'); + isFinish = true; + } + callback(); + }, timeout); + } +} + +/** + * get all bidder which hava {dgkeyword: true} in params + * @param {Object} adUnits + */ +export function getTargetBidderOfDgKeywords(adUnits) { + let setKeywordTargetBidders = []; + for (let adUnit of adUnits) { + for (let bid of adUnit.bids) { + if (bid.params && bid.params['dgkeyword'] === true) { + delete bid.params['dgkeyword']; + setKeywordTargetBidders.push(bid); + } + } + } + return setKeywordTargetBidders; +} + +/** @type {RtdSubmodule} */ +export const dgkeywordSubmodule = { + /** + * used to link submodule with realTimeData + * @type {string} + */ + name: 'dgkeyword', + /** + * get data and send back to realTimeData module + * @function + * @param {string[]} adUnitsCodes + */ + getBidRequestData: getDgKeywordsAndSet, + init: init, +}; + +function init(moduleConfig) { + return true; +} + +function registerSubModule() { + submodule('realTimeData', dgkeywordSubmodule); +} +registerSubModule(); diff --git a/modules/dgkeywordRtdProvider.md b/modules/dgkeywordRtdProvider.md new file mode 100644 index 00000000000..314475b45a8 --- /dev/null +++ b/modules/dgkeywordRtdProvider.md @@ -0,0 +1,29 @@ + ## Integration + +1) Compile the Digital Garage Keyword Module and Appnexus Bid Adapter into your Prebid build: + +``` +gulp build --modules="dgkeywordRtdProvider,appnexusBidAdapter,..." +``` + +2) Use `setConfig` to instruct Prebid.js to initilize the dgkeyword module, as specified below. + +## Configuration + +This module is configured as part of the `realTimeData.dataProviders` + +```javascript +var DGKEYWORD_TIMEOUT = 1000; +pbjs.setConfig({ + realTimeData: { + auctionDelay: DGKEYWORD_TIMEOUT, + dataProviders: [{ + name: 'dgkeyword', + waitForIt: true, + params: { + timeout: DGKEYWORD_TIMEOUT + } + }] + } +}); +``` diff --git a/test/spec/modules/dgkeywordRtdProvider_spec.js b/test/spec/modules/dgkeywordRtdProvider_spec.js new file mode 100644 index 00000000000..a145f429557 --- /dev/null +++ b/test/spec/modules/dgkeywordRtdProvider_spec.js @@ -0,0 +1,351 @@ +import * as dgRtd from 'modules/dgkeywordRtdProvider.js'; +import { cloneDeep } from 'lodash'; +import { server } from 'test/mocks/xhr.js'; +import { config } from 'src/config.js'; + +const DG_GET_KEYWORDS_TIMEOUT = 1950; +const IGNORE_SET_ORTB2 = true; +const DEF_CONFIG = { + name: 'dgkeyword', + waitForIt: true, + params: { + timeout: DG_GET_KEYWORDS_TIMEOUT, + }, +}; +const DUMMY_RESPONSE_HEADER = { 'Content-Type': 'application/json' }; +const DUMMY_RESPONSE = { s: ['s1', 's2'], t: ['t1', 't2'] }; +const SUCCESS_RESULT = { opeaud: ['s1', 's2'], opectx: ['t1', 't2'] }; +const SUCCESS_ORTB2 = { + ortb2: { + site: { keywords: SUCCESS_RESULT }, + user: { keywords: SUCCESS_RESULT }, + }, +}; + +describe('Digital Garage Keyword Module', function () { + it('should init and return always true', function () { + expect(dgRtd.dgkeywordSubmodule.init()).to.equal(true); + }); + + describe('dgkeyword target test', function () { + it('should have no target', function () { + const adUnits_no_target = [ + { + code: 'code1', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999999, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999998, + dgkeyword: false, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999997, + }, + }, + ], + }, + { + code: 'code2', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999996, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999995, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999994, + }, + }, + ], + }, + ]; + expect(dgRtd.getTargetBidderOfDgKeywords(adUnits_no_target)).an('array') + .that.is.empty; + }); + it('should have targets', function () { + const adUnits_targets = [ + { + code: 'code1', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999999, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999998, + dgkeyword: true, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999997, + dgkeyword: false, + }, + }, + ], + }, + { + code: 'code2', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999996, + dgkeyword: true, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999995, + dgkeyword: 'aa', + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999994, + dgkeyword: true, + }, + }, + ], + }, + ]; + const targets = dgRtd.getTargetBidderOfDgKeywords(adUnits_targets); + expect(targets[0].bidder).to.be.equal('dg2'); + expect(targets[0].params.placementId).to.be.equal(99999998); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].bidder).to.be.equal('dg'); + expect(targets[1].params.placementId).to.be.equal(99999996); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + }); + }); + + describe('get profile.', function () { + const AD_UNITS = [ + { + code: 'code1', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999999, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999998, + dgkeyword: true, + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999997, + dgkeyword: false, + }, + }, + ], + }, + { + code: 'code2', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'dg', + params: { + placementId: 99999996, + dgkeyword: true, + }, + }, + { + bidder: 'dg2', + params: { + placementId: 99999995, + dgkeyword: 'aa', + }, + }, + { + bidder: 'dg3', + params: { + placementId: 99999994, + }, + }, + ], + }, + ]; + it('should get profiles error(404).', function (done) { + let pbjs = cloneDeep(config); + pbjs.adUnits = cloneDeep(AD_UNITS); + let moduleConfig = cloneDeep(DEF_CONFIG); + dgRtd.getDgKeywordsAndSet( + pbjs, + () => { + let targets = pbjs.adUnits[0].bids; + expect(targets[1].bidder).to.be.equal('dg2'); + expect(targets[1].params.placementId).to.be.equal(99999998); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].params.keywords).to.be.an('undefined'); + targets = pbjs.adUnits[1].bids; + expect(targets[0].bidder).to.be.equal('dg'); + expect(targets[0].params.placementId).to.be.equal(99999996); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[0].params.keywords).to.be.an('undefined'); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].params.keywords).to.be.an('undefined'); + + expect(pbjs.getBidderConfig()).to.be.deep.equal({}); + + done(); + }, + moduleConfig, + null + ); + const request = server.requests[0]; + request.respond(404); + }); + it('should get profiles timeout.', function (done) { + let pbjs = cloneDeep(config); + pbjs.adUnits = cloneDeep(AD_UNITS); + let moduleConfig = cloneDeep(DEF_CONFIG); + moduleConfig.params.timeout = 10; + dgRtd.getDgKeywordsAndSet( + pbjs, + () => { + let targets = pbjs.adUnits[0].bids; + expect(targets[1].bidder).to.be.equal('dg2'); + expect(targets[1].params.placementId).to.be.equal(99999998); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].params.keywords).to.be.an('undefined'); + targets = pbjs.adUnits[1].bids; + expect(targets[0].bidder).to.be.equal('dg'); + expect(targets[0].params.placementId).to.be.equal(99999996); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[0].params.keywords).to.be.an('undefined'); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].params.keywords).to.be.an('undefined'); + + expect(pbjs.getBidderConfig()).to.be.deep.equal({}); + + done(); + }, + moduleConfig, + null + ); + setTimeout(() => { + const request = server.requests[0]; + if (request) { + request.respond( + 200, + DUMMY_RESPONSE_HEADER, + JSON.stringify(DUMMY_RESPONSE) + ); + } + }, 1000); + }); + it('should get profiles ok(200).', function (done) { + let pbjs = cloneDeep(config); + pbjs.adUnits = cloneDeep(AD_UNITS); + if (IGNORE_SET_ORTB2) { + pbjs._ignoreSetOrtb2 = true; + } + let moduleConfig = cloneDeep(DEF_CONFIG); + dgRtd.getDgKeywordsAndSet( + pbjs, + () => { + let targets = pbjs.adUnits[0].bids; + expect(targets[1].bidder).to.be.equal('dg2'); + expect(targets[1].params.placementId).to.be.equal(99999998); + expect(targets[1].params.dgkeyword).to.be.an('undefined'); + expect(targets[1].params.keywords).to.be.deep.equal(SUCCESS_RESULT); + targets = pbjs.adUnits[1].bids; + expect(targets[0].bidder).to.be.equal('dg'); + expect(targets[0].params.placementId).to.be.equal(99999996); + expect(targets[0].params.dgkeyword).to.be.an('undefined'); + expect(targets[0].params.keywords).to.be.deep.equal(SUCCESS_RESULT); + expect(targets[2].bidder).to.be.equal('dg3'); + expect(targets[2].params.placementId).to.be.equal(99999994); + expect(targets[2].params.dgkeyword).to.be.an('undefined'); + expect(targets[2].params.keywords).to.be.an('undefined'); + + if (!IGNORE_SET_ORTB2) { + expect(pbjs.getBidderConfig()).to.be.deep.equal({ + dg2: SUCCESS_ORTB2, + dg: SUCCESS_ORTB2, + }); + } + done(); + }, + moduleConfig, + null + ); + const request = server.requests[0]; + request.respond( + 200, + DUMMY_RESPONSE_HEADER, + JSON.stringify(DUMMY_RESPONSE) + ); + }); + }); +}); From 0f267d801ca35b5f9dde797e344a301e6eaf02ee Mon Sep 17 00:00:00 2001 From: Rahul Shandilya <67756716+c3p-0@users.noreply.github.com> Date: Wed, 2 Jun 2021 21:54:28 +0530 Subject: [PATCH 297/303] Medianet bid adapter: MD update for video parameters. (#6922) --- modules/medianetBidAdapter.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/medianetBidAdapter.md b/modules/medianetBidAdapter.md index b465d678fc9..fbe967122e9 100644 --- a/modules/medianetBidAdapter.md +++ b/modules/medianetBidAdapter.md @@ -79,17 +79,16 @@ var videoAdUnit = { mediaTypes: { video: { context: "instream", - playerSize: [640, 480] + playerSize: [640, 480], + mimes: ['video/mp4'], + placement: 1 } }, bids: [{ bidder: 'medianet', params: { cid: '8CUX0H51C', - video: { - mimes: ['video/mp4'], - placement: 1 - }, + crid: '776755783', // Site member is to be used only for testing site: { page: 'http://smoketesting.net/prebidtest/', @@ -111,8 +110,10 @@ var videoAdUnit = { code: 'video1', mediaTypes: { video: { - context: "outstream", - playerSize: [640, 480] + context: "outstream", + playerSize: [640, 480], + mimes: ['video/mp4'], + placement: 1 } }, /** @@ -128,10 +129,7 @@ var videoAdUnit = { bidder: 'medianet', params: { cid: '8CUX0H51C', - video: { - mimes: ['video/mp4'], - placement: 1 - }, + crid: '776755783', // Site member is to be used only for testing site: { page: 'http://smoketesting.net/prebidtest/', From 5698959c5d0de2a527ea55986102329967105e3e Mon Sep 17 00:00:00 2001 From: Yohan Boutin Date: Wed, 2 Jun 2021 18:25:09 +0200 Subject: [PATCH 298/303] Seedtag Bid Adapter: read video params from mediaTypes, and allow override from bidder params, support passing adomain (#6888) * read video params from mediaTypes, and allow override from from bidder * implement meta.advertiserDomain * fix unit tests * allow outstream video --- modules/seedtagBidAdapter.js | 51 ++++++++++++++------- modules/seedtagBidAdapter.md | 21 +++++++-- test/spec/modules/seedtagBidAdapter_spec.js | 29 ++++++++++-- 3 files changed, 76 insertions(+), 25 deletions(-) diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index c25d833a71c..f4e99a2e2a0 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -46,7 +46,7 @@ function mapMediaType(seedtagMediaType) { } function hasVideoMediaType(bid) { - return !!bid.mediaTypes && !!bid.mediaTypes.video + return (!!bid.mediaTypes && !!bid.mediaTypes.video) || (!!bid.params && !!bid.params.video) } function hasMandatoryParams(params) { @@ -58,13 +58,12 @@ function hasMandatoryParams(params) { ); } -function hasMandatoryVideoParams(mediaTypes) { - const isVideoInStream = - !!mediaTypes.video && mediaTypes.video.context === 'instream'; - const isPlayerSize = - !!utils.deepAccess(mediaTypes, 'video.playerSize') && - utils.isArray(utils.deepAccess(mediaTypes, 'video.playerSize')); - return isVideoInStream && isPlayerSize; +function hasMandatoryVideoParams(bid) { + const videoParams = getVideoParams(bid) + + return hasVideoMediaType(bid) && !!videoParams.playerSize && + utils.isArray(videoParams.playerSize) && + videoParams.playerSize.length > 0; } function buildBidRequests(validBidRequests) { @@ -91,18 +90,33 @@ function buildBidRequests(validBidRequests) { } if (hasVideoMediaType(validBidRequest)) { - bidRequest.videoParams = params.video || {}; - bidRequest.videoParams.w = - validBidRequest.mediaTypes.video.playerSize[0][0]; - bidRequest.videoParams.h = - validBidRequest.mediaTypes.video.playerSize[0][1]; + bidRequest.videoParams = getVideoParams(validBidRequest) } return bidRequest; }) } -function buildBid(seedtagBid) { +/** + * return video param (global or overrided per bidder) + */ +function getVideoParams(validBidRequest) { + const videoParams = validBidRequest.mediaTypes.video || {}; + if (videoParams.playerSize) { + videoParams.w = videoParams.playerSize[0][0]; + videoParams.h = videoParams.playerSize[0][1]; + } + + const bidderVideoParams = (validBidRequest.params && validBidRequest.params.video) || {} + // override video params from seedtag bidder params + Object.keys(bidderVideoParams).forEach(key => { + videoParams[key] = validBidRequest.params.video[key] + }) + + return videoParams +} + +function buildBidResponse(seedtagBid) { const mediaType = mapMediaType(seedtagBid.mediaType); const bid = { requestId: seedtagBid.bidId, @@ -114,7 +128,10 @@ function buildBid(seedtagBid) { netRevenue: true, mediaType: mediaType, ttl: seedtagBid.ttl, - nurl: seedtagBid.nurl + nurl: seedtagBid.nurl, + meta: { + advertiserDomains: seedtagBid && seedtagBid.adomain && seedtagBid.adomain.length > 0 ? seedtagBid.adomain : [] + } }; if (mediaType === VIDEO) { @@ -152,7 +169,7 @@ export const spec = { */ isBidRequestValid(bid) { return hasVideoMediaType(bid) - ? hasMandatoryParams(bid.params) && hasMandatoryVideoParams(bid.mediaTypes) + ? hasMandatoryParams(bid.params) && hasMandatoryVideoParams(bid) : hasMandatoryParams(bid.params); }, @@ -197,7 +214,7 @@ export const spec = { const serverBody = serverResponse.body; if (serverBody && serverBody.bids && utils.isArray(serverBody.bids)) { return utils._map(serverBody.bids, function(bid) { - return buildBid(bid); + return buildBidResponse(bid); }); } else { return []; diff --git a/modules/seedtagBidAdapter.md b/modules/seedtagBidAdapter.md index 627ff8333ad..f4249fb2e89 100644 --- a/modules/seedtagBidAdapter.md +++ b/modules/seedtagBidAdapter.md @@ -46,7 +46,19 @@ var adUnits = [{ mediaTypes: { video: { context: 'instream', // required - playerSize: [600, 300] // required + playerSize: [600, 300], // required + mimes: ['video/mp4'], // recommended + minduration: 5, // optional + maxduration: 60, // optional + boxingallowed: 1, // optional + skip: 1, // optional + startdelay: 1, // optional + linearity: 1, // optional + battr: [1, 2], // optional + maxbitrate: 10, // optional + playbackmethod: [1], // optional + delivery: [1], // optional + placement: 1, // optional } }, bids: [ @@ -57,9 +69,10 @@ var adUnits = [{ adUnitId: '0000', // required placement: 'video', // required adPosition: 0, // optional - // Video object as specified in OpenRTB 2.5 - video: { - mimes: ['video/mp4'], // recommended + video: { // optional + context: 'instream', // optional + playerSize: [600, 300], // optional + mimes: ['video/mp4'], // optional minduration: 5, // optional maxduration: 60, // optional boxingallowed: 1, // optional diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index c82c8300d2e..cb04ada59c7 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -55,7 +55,7 @@ describe('Seedtag Adapter', function() { }) }) describe('when video slot has all mandatory params', function() { - it('should return true, when video mediatype object are correct.', function() { + it('should return true, when video context is instream', function () { const slotConfig = getSlotConfigs( { video: { @@ -72,6 +72,24 @@ describe('Seedtag Adapter', function() { const isBidRequestValid = spec.isBidRequestValid(slotConfig) expect(isBidRequestValid).to.equal(true) }) + + it('should return true, when video context is outstream', function () { + const slotConfig = getSlotConfigs( + { + video: { + context: 'outstream', + playerSize: [[600, 200]] + } + }, + { + publisherId: PUBLISHER_ID, + adUnitId: ADUNIT_ID, + placement: 'video' + } + ) + const isBidRequestValid = spec.isBidRequestValid(slotConfig) + expect(isBidRequestValid).to.equal(true) + }) }) }) describe('returns false', function() { @@ -137,7 +155,7 @@ describe('Seedtag Adapter', function() { ) expect(isBidRequestValid).to.equal(false) }) - it('is not instream ', function() { + it('is outstream ', function () { const isBidRequestValid = spec.isBidRequestValid( createVideoSlotConfig({ video: { @@ -146,7 +164,7 @@ describe('Seedtag Adapter', function() { } }) ) - expect(isBidRequestValid).to.equal(false) + expect(isBidRequestValid).to.equal(true) }) describe('order does not matter', function() { it('when video is not the first slot', function() { @@ -326,7 +344,8 @@ describe('Seedtag Adapter', function() { height: 90, mediaType: 'display', ttl: 360, - nurl: 'testurl.com/nurl' + nurl: 'testurl.com/nurl', + adomain: ['advertiserdomain.com'] } ], cookieSync: { url: '' } @@ -342,6 +361,7 @@ describe('Seedtag Adapter', function() { expect(bids[0].netRevenue).to.equal(true) expect(bids[0].ad).to.equal('content') expect(bids[0].nurl).to.equal('testurl.com/nurl') + expect(bids[0].meta.advertiserDomains).to.deep.equal(['advertiserdomain.com']) }) }) describe('the bid is a video', function() { @@ -374,6 +394,7 @@ describe('Seedtag Adapter', function() { expect(bids[0].currency).to.equal('USD') expect(bids[0].netRevenue).to.equal(true) expect(bids[0].vastXml).to.equal('content') + expect(bids[0].meta.advertiserDomains).to.deep.equal([]) }) }) }) From 0cd655d28af6790457f652fa2e06ca3f2be2f6d8 Mon Sep 17 00:00:00 2001 From: Eric Harper Date: Wed, 2 Jun 2021 14:08:17 -0400 Subject: [PATCH 299/303] Prebid 4.42.0 Release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6df9993806c..4515885807c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.42.0-pre", + "version": "4.42.0", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From b099bcc777a0243ce8b4d8c10ffe5a87b53ccecb Mon Sep 17 00:00:00 2001 From: Eric Harper Date: Wed, 2 Jun 2021 14:32:46 -0400 Subject: [PATCH 300/303] Increment pre version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4515885807c..368b49919cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.42.0", + "version": "4.43.0-pre", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From befd64e68a1cba9fd1b0a4094eee5e75c4365d7e Mon Sep 17 00:00:00 2001 From: Harshad Mane Date: Wed, 2 Jun 2021 14:44:19 -0700 Subject: [PATCH 301/303] PubMatic: For Video: bid.mediaTypes.video.mimes OR bid.params.video.mimes should be present and must be a non-empty array (#6926) * bid.mediaTypes.video.mimes OR bid.params.video.mimes should be present and must be a non-empty array --- modules/pubmaticBidAdapter.js | 25 +++- test/spec/modules/pubmaticBidAdapter_spec.js | 132 +++++++++---------- 2 files changed, 84 insertions(+), 73 deletions(-) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 79356415ddf..b78b1fc96ba 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -929,7 +929,16 @@ function _assignRenderer(newBid, request) { newBid.renderer = BB_RENDERER.newRenderer(newBid.rendererCode, adUnitCode); } } -}; +} + +function isNonEmptyArray(test) { + if (utils.isArray(test) === true) { + if (test.length > 0) { + return true; + } + } + return false; +} export const spec = { code: BIDDER_CODE, @@ -949,15 +958,23 @@ export const spec = { } // video ad validation if (bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) { - if (!bid.mediaTypes.video.mimes || (bid.params.video && (!bid.params.video.hasOwnProperty('mimes') || !utils.isArray(bid.params.video.mimes) || bid.params.video.mimes.length === 0))) { - utils.logWarn(LOG_WARN_PREFIX + 'Error: For video ads, mimes is mandatory and must specify atlease 1 mime value. Call to OpenBid will not be sent for ad unit:' + JSON.stringify(bid)); + // bid.mediaTypes.video.mimes OR bid.params.video.mimes should be present and must be a non-empty array + let mediaTypesVideoMimes = utils.deepAccess(bid.mediaTypes, 'video.mimes'); + let paramsVideoMimes = utils.deepAccess(bid, 'params.video.mimes'); + if (isNonEmptyArray(mediaTypesVideoMimes) === false && isNonEmptyArray(paramsVideoMimes) === false) { + utils.logWarn(LOG_WARN_PREFIX + 'Error: For video ads, bid.mediaTypes.video.mimes OR bid.params.video.mimes should be present and must be a non-empty array. Call to OpenBid will not be sent for ad unit:' + JSON.stringify(bid)); return false; } + if (!bid.mediaTypes[VIDEO].hasOwnProperty('context')) { utils.logError(`${LOG_WARN_PREFIX}: no context specified in bid. Rejecting bid: `, bid); return false; } - if (bid.mediaTypes[VIDEO].context === 'outstream' && !utils.isStr(bid.params.outstreamAU) && !bid.hasOwnProperty('renderer') && !bid.mediaTypes[VIDEO].hasOwnProperty('renderer')) { + + if (bid.mediaTypes[VIDEO].context === 'outstream' && + !utils.isStr(bid.params.outstreamAU) && + !bid.hasOwnProperty('renderer') && + !bid.mediaTypes[VIDEO].hasOwnProperty('renderer')) { utils.logError(`${LOG_WARN_PREFIX}: for "outstream" bids either outstreamAU parameter must be provided or ad unit supplied renderer is required. Rejecting bid: `, bid); return false; } diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index ae0b351c367..80ce93858d5 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -864,78 +864,72 @@ describe('PubMatic adapter', function () { expect(isValid).to.equal(false); }) - it('should check for mimes if video is present', function() { + it('bid.mediaTypes.video.mimes OR bid.params.video.mimes should be present and must be a non-empty array', function() { let bid = { - 'bidder': 'pubmatic', - 'params': { - 'adSlot': 'SLOT_NHB1@728x90', - 'publisherId': '5890' - }, - 'mediaTypes': { - 'video': { - 'playerSize': [ - [640, 480] - ], - 'protocols': [1, 2, 5], - 'context': 'instream', - 'mimes': ['video/flv'], - 'skippable': false, - 'skip': 1, - 'linearity': 2 - } - }, - 'adUnitCode': 'video1', - 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', - 'sizes': [ - [640, 480] - ], - 'bidId': '2c95df014cfe97', - 'bidderRequestId': '1fe59391566442', - 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5890', + 'video': {} }, - isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(true); - }) - - it('should return false if mimes is not present in video', function() { - let bid = { - 'bidder': 'pubmatic', - 'params': { - 'adSlot': 'SLOT_NHB1@728x90', - 'publisherId': '5890' - }, - 'mediaTypes': { - 'video': { - 'playerSize': [ - [640, 480] - ], - 'protocols': [1, 2, 5], - 'context': 'instream', - 'skippable': false, - 'skip': 1, - 'linearity': 2 - } - }, - 'adUnitCode': 'video1', - 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', - 'sizes': [ - [640, 480] - ], - 'bidId': '2c95df014cfe97', - 'bidderRequestId': '1fe59391566442', - 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } }, - isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }) + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }; + + delete bid.params.video.mimes; // Undefined + bid.mediaTypes.video.mimes = 'string'; // NOT array + expect(spec.isBidRequestValid(bid)).to.equal(false); + + delete bid.params.video.mimes; // Undefined + delete bid.mediaTypes.video.mimes; // Undefined + expect(spec.isBidRequestValid(bid)).to.equal(false); + + delete bid.params.video.mimes; // Undefined + bid.mediaTypes.video.mimes = ['video/flv']; // Valid + expect(spec.isBidRequestValid(bid)).to.equal(true); + + delete bid.mediaTypes.video.mimes; // mediaTypes.video.mimes undefined + bid.params.video = {mimes: 'string'}; // NOT array + expect(spec.isBidRequestValid(bid)).to.equal(false); + + delete bid.mediaTypes.video.mimes; // mediaTypes.video.mimes undefined + delete bid.params.video.mimes; // Undefined + expect(spec.isBidRequestValid(bid)).to.equal(false); + + delete bid.mediaTypes.video.mimes; // mediaTypes.video.mimes undefined + bid.params.video.mimes = ['video/flv']; // Valid + expect(spec.isBidRequestValid(bid)).to.equal(true); + + delete bid.mediaTypes.video.mimes; // Undefined + bid.params.video.mimes = ['video/flv']; // Valid + expect(spec.isBidRequestValid(bid)).to.equal(true); + + delete bid.mediaTypes.video.mimes; // Undefined + delete bid.params.video.mimes; // Undefined + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); }); describe('Request formation', function () { From 25106daa67962e735e23b00f2efe565fadbef9bd Mon Sep 17 00:00:00 2001 From: TheMediaGrid <44166371+TheMediaGrid@users.noreply.github.com> Date: Thu, 3 Jun 2021 01:16:24 +0300 Subject: [PATCH 302/303] GridNMBidAdapter: Use absent in video params data from mediaTypes (#6817) --- modules/gridBidAdapter.js | 2 +- modules/gridNMBidAdapter.js | 37 ++++++++-- test/spec/modules/gridBidAdapter_spec.js | 20 ++--- test/spec/modules/gridNMBidAdapter_spec.js | 85 +++++++++++++++++++++- 4 files changed, 125 insertions(+), 19 deletions(-) diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js index dbeba27d836..d4aceaea162 100644 --- a/modules/gridBidAdapter.js +++ b/modules/gridBidAdapter.js @@ -347,7 +347,7 @@ function _addBidResponse(serverBid, bidRequest, bidResponses) { height: serverBid.h, creativeId: serverBid.auid, // bid.bidId, currency: 'USD', - netRevenue: false, + netRevenue: true, ttl: TIME_TO_LIVE, meta: { advertiserDomains: serverBid.adomain ? serverBid.adomain : [] diff --git a/modules/gridNMBidAdapter.js b/modules/gridNMBidAdapter.js index af1e9f84f43..4ab8464b115 100644 --- a/modules/gridNMBidAdapter.js +++ b/modules/gridNMBidAdapter.js @@ -24,6 +24,8 @@ const LOG_ERROR_MESS = { hasNoArrayOfBids: 'Seatbid from response has no array of bid objects - ' }; +const VIDEO_KEYS = ['mimes', 'protocols', 'startdelay', 'placement', 'linearity', 'skip', 'skipmin', 'skipafter', 'sequence', 'battr', 'maxextended', 'minbitrate', 'maxbitrate', 'boxingallowed', 'playbackmethod', 'playbackend', 'delivery', 'pos', 'companionad', 'api', 'companiontype']; + export const spec = { code: BIDDER_CODE, supportedMediaTypes: [ VIDEO ], @@ -39,11 +41,12 @@ export const spec = { !bid.params.secid || !utils.isStr(bid.params.secid) || !bid.params.pubid || !utils.isStr(bid.params.pubid); + const video = utils.deepAccess(bid, 'mediaTypes.video') || {}; + const { protocols = video.protocols, mimes = video.mimes } = utils.deepAccess(bid, 'params.video') || {}; if (!invalid) { - invalid = !bid.params.video || !bid.params.video.protocols || !bid.params.video.mimes; + invalid = !protocols || !mimes; } if (!invalid) { - const {protocols, mimes} = bid.params.video; invalid = !utils.isArray(mimes) || !mimes.length || mimes.filter((it) => !(it && utils.isStr(it))).length; if (!invalid) { invalid = !utils.isArray(protocols) || !protocols.length || protocols.filter((it) => !(utils.isNumber(it) && it > 0 && !(it % 1))).length; @@ -63,7 +66,7 @@ export const spec = { const requests = []; bids.forEach(bid => { - const {params, bidderRequestId, sizes} = bid; + const { params, bidderRequestId, sizes } = bid; const payload = { sizes: utils.parseSizesInput(sizes).join(','), r: bidderRequestId, @@ -91,11 +94,32 @@ export const spec = { } } + const video = utils.deepAccess(bid, 'mediaTypes.video') || {}; + const paramsVideo = Object.assign({}, params.video); + VIDEO_KEYS.forEach((key) => { + if (!(key in paramsVideo) && key in video) { + paramsVideo[key] = video[key]; + } + }); + + if (!paramsVideo.size && video.playerSize && video.playerSize.length === 2) { + paramsVideo.size = video.playerSize.join('x'); + } + + if (!('mind' in paramsVideo) && 'minduration' in video) { + paramsVideo.mind = video.minduration; + } + if (!('maxd' in paramsVideo) && 'maxduration' in video) { + paramsVideo.maxd = video.maxduration; + } + + const paramsToSend = Object.assign({}, params, {video: paramsVideo}); + requests.push({ method: 'POST', url: ENDPOINT_URL + '?' + utils.parseQueryStringParameters(payload).replace(/\&$/, ''), bid: bid, - data: params // content + data: paramsToSend // content }); }); @@ -139,11 +163,14 @@ export const spec = { height: serverBid.h, creativeId: serverBid.auid || bid.bidderRequestId, currency: 'USD', - netRevenue: false, + netRevenue: true, ttl: TIME_TO_LIVE, dealId: serverBid.dealid, vastXml: serverBid.adm, mediaType: VIDEO, + meta: { + advertiserDomains: serverBid.adomain ? serverBid.adomain : [] + }, adResponse: { content: serverBid.adm } diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js index e161d82fdd6..4f5f62f2cb8 100644 --- a/test/spec/modules/gridBidAdapter_spec.js +++ b/test/spec/modules/gridBidAdapter_spec.js @@ -555,7 +555,7 @@ describe('TheMediaGrid Adapter', function () { 'ad': '
test content 1
', 'currency': 'USD', 'mediaType': 'banner', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'meta': { advertiserDomains: [] @@ -615,7 +615,7 @@ describe('TheMediaGrid Adapter', function () { 'ad': '
test content 1
', 'currency': 'USD', 'mediaType': 'banner', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'meta': { advertiserDomains: [] @@ -631,7 +631,7 @@ describe('TheMediaGrid Adapter', function () { 'ad': '
test content 2
', 'currency': 'USD', 'mediaType': 'banner', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'meta': { advertiserDomains: [] @@ -647,7 +647,7 @@ describe('TheMediaGrid Adapter', function () { 'ad': '
test content 3
', 'currency': 'USD', 'mediaType': 'banner', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'meta': { advertiserDomains: [] @@ -709,7 +709,7 @@ describe('TheMediaGrid Adapter', function () { 'height': 600, 'currency': 'USD', 'mediaType': 'video', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'meta': { advertiserDomains: [] @@ -728,7 +728,7 @@ describe('TheMediaGrid Adapter', function () { 'height': undefined, 'currency': 'USD', 'mediaType': 'video', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'meta': { advertiserDomains: [] @@ -862,7 +862,7 @@ describe('TheMediaGrid Adapter', function () { 'ad': '
test content 1
', 'currency': 'USD', 'mediaType': 'banner', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'meta': { advertiserDomains: [] @@ -878,7 +878,7 @@ describe('TheMediaGrid Adapter', function () { 'ad': '
test content 2
', 'currency': 'USD', 'mediaType': 'banner', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'meta': { advertiserDomains: [] @@ -894,7 +894,7 @@ describe('TheMediaGrid Adapter', function () { 'ad': '
test content 3
', 'currency': 'USD', 'mediaType': 'banner', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'meta': { advertiserDomains: [] @@ -910,7 +910,7 @@ describe('TheMediaGrid Adapter', function () { 'ad': '
test content 4
', 'currency': 'USD', 'mediaType': 'banner', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'meta': { advertiserDomains: [] diff --git a/test/spec/modules/gridNMBidAdapter_spec.js b/test/spec/modules/gridNMBidAdapter_spec.js index 2aec9713000..6d3a607c0c5 100644 --- a/test/spec/modules/gridNMBidAdapter_spec.js +++ b/test/spec/modules/gridNMBidAdapter_spec.js @@ -132,6 +132,43 @@ describe('TheMediaGridNM Adapter', function () { expect(spec.isBidRequestValid(invalidBid)).to.equal(false); }); }); + + it('should return true when required params is absent, but available in mediaTypes', function () { + const paramsList = [ + { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'protocols': [1, 2, 3, 4, 5, 6] + } + }, + { + 'source': 'jwp', + 'secid': '11', + 'pubid': '22', + 'video': { + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + } + } + ]; + + const mediaTypes = { + video: { + mimes: ['video/mp4', 'video/x-ms-wmv'], + playerSize: [200, 300], + protocols: [1, 2, 3, 4, 5, 6] + } + }; + + paramsList.forEach((params) => { + const validBid = Object.assign({}, bid); + delete validBid.params; + validBid.params = params; + validBid.mediaTypes = mediaTypes; + expect(spec.isBidRequestValid(validBid)).to.equal(true); + }); + }); }); describe('buildRequests', function () { @@ -198,6 +235,39 @@ describe('TheMediaGridNM Adapter', function () { }); }); + it('should attach valid params from mediaTypes', function () { + const mediaTypes = { + video: { + skipafter: 10, + minduration: 10, + maxduration: 100, + protocols: [1, 3, 4], + playerSize: [300, 250] + } + }; + const bidRequest = Object.assign({ mediaTypes }, bidRequests[0]); + const req = spec.buildRequests([bidRequest], bidderRequest)[0]; + const expectedVideo = { + 'skipafter': 10, + 'mind': 10, + 'maxd': 100, + 'mimes': ['video/mp4', 'video/x-ms-wmv'], + 'protocols': [1, 2, 3, 4, 5, 6], + 'size': '300x250' + }; + const expectedParams = Object.assign({}, bidRequest.params); + expectedParams.video = Object.assign(expectedParams.video, expectedVideo); + + expect(req.url).to.be.an('string'); + const payload = parseRequestUrl(req.url); + expect(payload).to.have.property('u', referrer); + expect(payload).to.have.property('r', '22edbae2733bf6'); + expect(payload).to.have.property('wrapperType', 'Prebid_js'); + expect(payload).to.have.property('wrapperVersion', '$prebid.version$'); + expect(payload).to.have.property('sizes', '300x250,300x600'); + expect(req.data).to.deep.equal(expectedParams); + }); + it('if gdprConsent is present payload must have gdpr params', function () { const [request] = spec.buildRequests([bidRequests[0]], {gdprConsent: {consentString: 'AAA', gdprApplies: true}, refererInfo: bidderRequest.refererInfo}); expect(request.url).to.be.an('string'); @@ -235,7 +305,7 @@ describe('TheMediaGridNM Adapter', function () { describe('interpretResponse', function () { const responses = [ {'bid': [{'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'content_type': 'video', 'h': 250, 'w': 300, 'dealid': 11}], 'seat': '2'}, - {'bid': [{'price': 0.5, 'adm': '\n<\/Ad>\n<\/VAST>', 'content_type': 'video', 'h': 600, 'w': 300}], 'seat': '2'}, + {'bid': [{'price': 0.5, 'adm': '\n<\/Ad>\n<\/VAST>', 'content_type': 'video', 'h': 600, 'w': 300, adomain: ['my_domain.ru']}], 'seat': '2'}, {'bid': [{'price': 0, 'h': 250, 'w': 300}], 'seat': '2'}, {'bid': [{'price': 0, 'adm': '\n<\/Ad>\n<\/VAST>', 'h': 250, 'w': 300}], 'seat': '2'}, undefined, @@ -302,9 +372,12 @@ describe('TheMediaGridNM Adapter', function () { 'height': 250, 'currency': 'USD', 'mediaType': 'video', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'meta': { + 'advertiserDomains': [] + }, 'adResponse': { 'content': '\n<\/Ad>\n<\/VAST>' } @@ -318,9 +391,12 @@ describe('TheMediaGridNM Adapter', function () { 'height': 600, 'currency': 'USD', 'mediaType': 'video', - 'netRevenue': false, + 'netRevenue': true, 'ttl': 360, 'vastXml': '\n<\/Ad>\n<\/VAST>', + 'meta': { + 'advertiserDomains': ['my_domain.ru'] + }, 'adResponse': { 'content': '\n<\/Ad>\n<\/VAST>' } @@ -352,6 +428,9 @@ describe('TheMediaGridNM Adapter', function () { 'bidId': '2bc598e42b6a', 'bidderRequestId': '39d74f5b71464', 'auctionId': '1cbd2feafe5e8b', + 'meta': { + 'advertiserDomains': [] + }, 'mediaTypes': { 'video': { 'context': 'instream' From 589bc3f8bc60295210c757cf3e60e1f9d83c5050 Mon Sep 17 00:00:00 2001 From: Rigel Cheng Date: Thu, 3 Jun 2021 06:19:08 +0800 Subject: [PATCH 303/303] BridgewellBidAdapter: modify to include user ids in the bid request object (#6845) --- modules/bridgewellBidAdapter.js | 17 +++++++--- .../spec/modules/bridgewellBidAdapter_spec.js | 33 ++++++++++++++----- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/modules/bridgewellBidAdapter.js b/modules/bridgewellBidAdapter.js index 58c4e907328..2034a59242e 100644 --- a/modules/bridgewellBidAdapter.js +++ b/modules/bridgewellBidAdapter.js @@ -4,8 +4,8 @@ import { BANNER, NATIVE } from '../src/mediaTypes.js'; import find from 'core-js-pure/features/array/find.js'; const BIDDER_CODE = 'bridgewell'; -const REQUEST_ENDPOINT = 'https://prebid.scupio.com/recweb/prebid.aspx?cb=' + Math.random(); -const BIDDER_VERSION = '0.0.3'; +const REQUEST_ENDPOINT = 'https://prebid.scupio.com/recweb/prebid.aspx?cb='; +const BIDDER_VERSION = '1.1.0'; export const spec = { code: BIDDER_CODE, @@ -37,7 +37,12 @@ export const spec = { */ buildRequests: function (validBidRequests, bidderRequest) { const adUnits = []; + var bidderUrl = REQUEST_ENDPOINT + Math.random(); + var userIds; + utils._each(validBidRequests, function (bid) { + userIds = bid.userId; + if (bid.params.cid) { adUnits.push({ cid: bid.params.cid, @@ -47,7 +52,8 @@ export const spec = { banner: { sizes: bid.sizes } - } + }, + userIds: userIds || {} }); } else { adUnits.push({ @@ -58,7 +64,8 @@ export const spec = { banner: { sizes: bid.sizes } - } + }, + userIds: userIds || {} }); } }); @@ -70,7 +77,7 @@ export const spec = { return { method: 'POST', - url: REQUEST_ENDPOINT, + url: bidderUrl, data: { version: { prebid: '$prebid.version$', diff --git a/test/spec/modules/bridgewellBidAdapter_spec.js b/test/spec/modules/bridgewellBidAdapter_spec.js index 0860404355e..8da82c71820 100644 --- a/test/spec/modules/bridgewellBidAdapter_spec.js +++ b/test/spec/modules/bridgewellBidAdapter_spec.js @@ -2,6 +2,14 @@ import { expect } from 'chai'; import { spec } from 'modules/bridgewellBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; +const userId = { + 'criteoId': 'vYlICF9oREZlTHBGRVdrJTJCUUJnc3U2ckNVaXhrV1JWVUZVSUxzZmJlcnJZR0ZxbVhFRnU5bDAlMkJaUWwxWTlNcmdEeHFrJTJGajBWVlV4T3lFQ0FyRVcxNyUyQlIxa0lLSlFhcWJpTm9PSkdPVkx0JTJCbzlQRTQlM0Q', + 'pubcid': '074864cb-3705-430e-9ff7-48ccf3c21b94', + 'sharedid': {'id': '01F61MX53D786DSB2WYD38ZVM7', 'third': '01F61MX53D786DSB2WYD38ZVM7'}, + 'uid2': {'id': 'eb33b0cb-8d35-1234-b9c0-1a31d4064777'}, + 'flocId': {'id': '12345', 'version': 'chrome.1.1'}, +} + describe('bridgewellBidAdapter', function () { const adapter = newBidder(spec); @@ -87,6 +95,7 @@ describe('bridgewellBidAdapter', function () { 'bidId': '3150ccb55da321', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', + 'userId': userId, }, { 'bidder': 'bridgewell', @@ -126,6 +135,7 @@ describe('bridgewellBidAdapter', function () { 'bidId': '3150ccb55da321', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', + 'userId': userId, } ]; @@ -142,10 +152,13 @@ describe('bridgewellBidAdapter', function () { expect(payload.adUnits).to.be.an('array'); expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/'); for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) { - expect(payload.adUnits[i]).to.have.property('ChannelID').that.is.a('string'); - expect(payload.adUnits[i]).to.not.have.property('cid'); - expect(payload.adUnits[i]).to.have.property('adUnitCode').and.to.equal('adunit-code-2'); - expect(payload.adUnits[i]).to.have.property('requestId').and.to.equal('3150ccb55da321'); + let u = payload.adUnits[i]; + expect(u).to.have.property('ChannelID').that.is.a('string'); + expect(u).to.not.have.property('cid'); + expect(u).to.have.property('adUnitCode').and.to.equal('adunit-code-2'); + expect(u).to.have.property('requestId').and.to.equal('3150ccb55da321'); + expect(u).to.have.property('userIds'); + expect(u.userIds).to.deep.equal(userId); } }); @@ -170,6 +183,7 @@ describe('bridgewellBidAdapter', function () { 'bidId': '3150ccb55da321', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', + 'userId': userId }, ]; @@ -180,10 +194,13 @@ describe('bridgewellBidAdapter', function () { expect(payload.adUnits).to.be.an('array'); expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/'); for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) { - expect(payload.adUnits[i]).to.have.property('cid').that.is.a('number'); - expect(payload.adUnits[i]).to.not.have.property('ChannelID'); - expect(payload.adUnits[i]).to.have.property('adUnitCode').and.to.equal('adunit-code-2'); - expect(payload.adUnits[i]).to.have.property('requestId').and.to.equal('3150ccb55da321'); + let u = payload.adUnits[i]; + expect(u).to.have.property('cid').that.is.a('number'); + expect(u).to.not.have.property('ChannelID'); + expect(u).to.have.property('adUnitCode').and.to.equal('adunit-code-2'); + expect(u).to.have.property('requestId').and.to.equal('3150ccb55da321'); + expect(u).to.have.property('userIds'); + expect(u.userIds).to.deep.equal(userId); } });