From 5fe11053b6b61c0b7fde6d620658ac62eeccb37f Mon Sep 17 00:00:00 2001 From: Rich Loveland Date: Thu, 14 Dec 2017 10:36:46 -0500 Subject: [PATCH 01/20] Add user-facing docs reminder to PR template (#1956) --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 61eb327fd2c..9fdb04ba556 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -11,6 +11,7 @@ Thank you for your pull request. Please make sure this PR is scoped to one chang - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] CI related changes +- [ ] Does this change affect user-facing APIs or examples documented on http://prebid.org? - [ ] Other ## Description of change @@ -32,6 +33,9 @@ Be sure to test the integration with your adserver using the [Hello World](/inte - contact email of the adapter’s maintainer - [ ] official adapter submission +For any changes that affect user-facing APIs or example code documented on http://prebid.org, please provide: + +- A link to a PR on the docs repo at https://github.com/prebid/prebid.github.io/ ## Other information From 91bdce61cd829d6a461576be4feba2a24f947cfd Mon Sep 17 00:00:00 2001 From: Rich Snapp Date: Fri, 15 Dec 2017 11:14:52 -0700 Subject: [PATCH 02/20] allow non-mappable sizes to be passed and used in rubicon adapter (#1893) --- modules/rubiconBidAdapter.js | 50 +++++++++++---------- test/spec/modules/rubiconBidAdapter_spec.js | 24 ++++------ 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index 48fe18677e0..76a9095be72 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -357,14 +357,13 @@ function parseSizes(bid) { } return size; } - return masSizeOrdering(Array.isArray(params.sizes) - ? params.sizes.map(size => (sizeMap[size] || '').split('x')) : bid.sizes - ); -} -export function masSizeOrdering(sizes) { - const MAS_SIZE_PRIORITY = [15, 2, 9]; + let sizes = Array.isArray(params.sizes) ? params.sizes : mapSizes(bid.sizes) + + return masSizeOrdering(sizes); +} +function mapSizes(sizes) { return utils.parseSizesInput(sizes) // map sizes while excluding non-matches .reduce((result, size) => { @@ -373,25 +372,30 @@ export function masSizeOrdering(sizes) { result.push(mappedSize); } return result; - }, []) - .sort((first, second) => { - // sort by MAS_SIZE_PRIORITY priority order - const firstPriority = MAS_SIZE_PRIORITY.indexOf(first); - const secondPriority = MAS_SIZE_PRIORITY.indexOf(second); - - if (firstPriority > -1 || secondPriority > -1) { - if (firstPriority === -1) { - return 1; - } - if (secondPriority === -1) { - return -1; - } - return firstPriority - secondPriority; + }, []); +} + +export function masSizeOrdering(sizes) { + const MAS_SIZE_PRIORITY = [15, 2, 9]; + + return sizes.sort((first, second) => { + // sort by MAS_SIZE_PRIORITY priority order + const firstPriority = MAS_SIZE_PRIORITY.indexOf(first); + const secondPriority = MAS_SIZE_PRIORITY.indexOf(second); + + if (firstPriority > -1 || secondPriority > -1) { + if (firstPriority === -1) { + return 1; + } + if (secondPriority === -1) { + return -1; } + return firstPriority - secondPriority; + } - // and finally ascending order - return first - second; - }); + // and finally ascending order + return first - second; + }); } var hasSynced = false; diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index 49c0dd9011e..8c6a244eb3c 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -98,27 +98,19 @@ describe('the rubicon adapter', () => { }); describe('MAS mapping / ordering', () => { - it('should not include values without a proper mapping', () => { - // two invalid sizes included: [42, 42], [1, 1] - let ordering = masSizeOrdering([[320, 50], [42, 42], [300, 250], [640, 480], [1, 1], [336, 280]]); - - expect(ordering).to.deep.equal([15, 16, 43, 65]); - }); - it('should sort values without any MAS priority sizes in regular ascending order', () => { - let ordering = masSizeOrdering([[320, 50], [640, 480], [336, 280], [200, 600]]); - + let ordering = masSizeOrdering([126, 43, 65, 16]); expect(ordering).to.deep.equal([16, 43, 65, 126]); }); it('should sort MAS priority sizes in the proper order w/ rest ascending', () => { - let ordering = masSizeOrdering([[320, 50], [160, 600], [640, 480], [300, 250], [336, 280], [200, 600]]); + let ordering = masSizeOrdering([43, 9, 65, 15, 16, 126]); expect(ordering).to.deep.equal([15, 9, 16, 43, 65, 126]); - ordering = masSizeOrdering([[320, 50], [300, 250], [160, 600], [640, 480], [336, 280], [200, 600], [728, 90]]); + ordering = masSizeOrdering([43, 15, 9, 65, 16, 126, 2]); expect(ordering).to.deep.equal([15, 2, 9, 16, 43, 65, 126]); - ordering = masSizeOrdering([[120, 600], [320, 50], [160, 600], [640, 480], [336, 280], [200, 600], [728, 90]]); + ordering = masSizeOrdering([8, 43, 9, 65, 16, 126, 2]); expect(ordering).to.deep.equal([2, 9, 8, 16, 43, 65, 126]); }); }); @@ -167,20 +159,20 @@ describe('the rubicon adapter', () => { }); }); - it('should use rubicon sizes if present', () => { + it('should use rubicon sizes if present (including non-mappable sizes)', () => { var sizesBidderRequest = clone(bidderRequest); - sizesBidderRequest.bids[0].params.sizes = [55, 57, 59]; + sizesBidderRequest.bids[0].params.sizes = [55, 57, 59, 801]; let [request] = spec.buildRequests(sizesBidderRequest.bids, sizesBidderRequest); let data = parseQuery(request.data); expect(data['size_id']).to.equal('55'); - expect(data['alt_size_ids']).to.equal('57,59'); + expect(data['alt_size_ids']).to.equal('57,59,801'); }); it('should not validate bid request if no valid sizes', () => { var sizesBidderRequest = clone(bidderRequest); - sizesBidderRequest.bids[0].sizes = [[620, 250], [300, 251]]; + sizesBidderRequest.bids[0].sizes = [[621, 250], [300, 251]]; let result = spec.isBidRequestValid(sizesBidderRequest.bids[0]); From bf3242b88ee7724d4d6bea944fed760b2bfd749a Mon Sep 17 00:00:00 2001 From: takuhou Date: Wed, 20 Dec 2017 00:02:36 +0900 Subject: [PATCH 03/20] Typo correction of YIELDONE md file (#1954) * Added YIELDONE Bid Adapter for Prebid.js 1.0 * Update yieldoneBidAdapter.md change placementId to 44082 * Changed to get size from bid.sizes * fix sizes array * Fix a typo --- modules/yieldoneBidAdapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/yieldoneBidAdapter.md b/modules/yieldoneBidAdapter.md index f1f48637927..b5d96f822b5 100644 --- a/modules/yieldoneBidAdapter.md +++ b/modules/yieldoneBidAdapter.md @@ -10,7 +10,7 @@ Maintainer: y1dev@platform-one.co.jp Connect to YIELDONE for bids. -THE YIELDONE adapter requires setup and approval from the Rubicon Project team. Please reach out to your account team or y1s@platform-one.co.jp for more information. +THE YIELDONE adapter requires setup and approval from the YIELDONE team. Please reach out to your account team or y1s@platform-one.co.jp for more information. # Test Parameters ``` From 6b21369ea6146c365d95c4231d4a9b7693cc1202 Mon Sep 17 00:00:00 2001 From: Justin Grimes Date: Tue, 19 Dec 2017 11:10:49 -0500 Subject: [PATCH 04/20] Serverbid bid adapter: update alias config (#1963) --- modules/serverbidBidAdapter.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/serverbidBidAdapter.js b/modules/serverbidBidAdapter.js index bca1f8a5ac0..e77d7f32a35 100644 --- a/modules/serverbidBidAdapter.js +++ b/modules/serverbidBidAdapter.js @@ -15,6 +15,9 @@ const CONFIG = { }, 'insticator': { 'BASE_URI': 'https://e.serverbid.com/api/v2' + }, + 'adsparc': { + 'BASE_URI': 'https://e.serverbid.com/api/v2' } }; From a936adbc9db94d22d504a0aaae82fc38512c11c2 Mon Sep 17 00:00:00 2001 From: Jaimin Panchal Date: Tue, 19 Dec 2017 11:56:38 -0500 Subject: [PATCH 05/20] use auctionId instead of requestId (#1968) --- modules/adomikAnalyticsAdapter.js | 2 +- test/spec/modules/adomikAnalyticsAdapter_spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/adomikAnalyticsAdapter.js b/modules/adomikAnalyticsAdapter.js index 929a4d5deae..64e3ae14835 100644 --- a/modules/adomikAnalyticsAdapter.js +++ b/modules/adomikAnalyticsAdapter.js @@ -20,7 +20,7 @@ let adomikAdapter = Object.assign(adapter({}), track({ eventType, args }) { switch (eventType) { case auctionInit: - adomikAdapter.currentContext.id = args.requestId + adomikAdapter.currentContext.id = args.auctionId adomikAdapter.currentContext.timeout = args.timeout if (args.config.bidwonTimeout !== undefined && typeof args.config.bidwonTimeout === 'number') { bidwonTimeout = args.config.bidwonTimeout; diff --git a/test/spec/modules/adomikAnalyticsAdapter_spec.js b/test/spec/modules/adomikAnalyticsAdapter_spec.js index a3e0d214e5a..1907cfb14b8 100644 --- a/test/spec/modules/adomikAnalyticsAdapter_spec.js +++ b/test/spec/modules/adomikAnalyticsAdapter_spec.js @@ -33,7 +33,7 @@ describe('Adomik Prebid Analytic', function () { height: 10, statusMessage: 'Bid available', adId: '1234', - requestId: '', + auctionId: '', responseTimestamp: 1496410856397, requestTimestamp: 1496410856295, cpm: 0.1, @@ -58,7 +58,7 @@ describe('Adomik Prebid Analytic', function () { }); // Step 1: Send init auction event - events.emit(constants.EVENTS.AUCTION_INIT, {config: initOptions, requestId: 'test-test-test', timeout: 3000}); + events.emit(constants.EVENTS.AUCTION_INIT, {config: initOptions, auctionId: 'test-test-test', timeout: 3000}); expect(adomikAnalytics.currentContext).to.deep.equal({ uid: '123456', From 4bb4aaa8e91b85a4d612d158283aa12d77ef41f0 Mon Sep 17 00:00:00 2001 From: guillaume-sticky Date: Tue, 19 Dec 2017 18:02:14 +0100 Subject: [PATCH 06/20] Add freewheel ssp bidder adapter for prebid 1.0 (#1793) * add stickyadsTV bidder adapter * init unit test file * ad some unit tests * fix unit test on ad format with parameters * add some unit tests * add unit tests on getBid method * add some test cases in unit tests * minor fix on component id tag. * remove adapters-sticky.json test file * use top most accessible window instead of window.top * Pass in the bid request in the createBid call. * use top most accessible window instead of window.top * add unit tests * update unit tests * fix unit test. * fix CI build * add alias freewheel-ssp * update unit tests on bidderCode value * fix component id values and add unit tests * allws to use any outstream format. * fix ASLoader on futur outstream format versions * minor: fix code format. * update unit tests * minor fix code format * minor: add missing new line at eof * replace StickyAdsTVAdapter by freewheel ssp bd adapter (for prebid 1.0) * remove old stickyadstv unittest spec. * fix server response parsing if sent as object with 'body' field * use the vastXml field for video mediatype * add user sync pixel in freewheel ssp adapter * remove all console log calls (replaced using util helper) * remove useless bidderCode (automatically added by the bidderFactory) * Return the SYNC pixel to be added in the page by Prebid.js * remove instance level properties to enable concurrent bids with the same adapter instance. * fix the request apss through and corresponding unit tests * fix 'freeheelssp' typo --- modules/freewheelSSPBidAdapter.js | 314 ++++++++++++++++++ modules/freewheelSSPBidAdapter.md | 27 ++ .../modules/freewheelSSPBidAdapter_spec.js | 193 +++++++++++ 3 files changed, 534 insertions(+) create mode 100644 modules/freewheelSSPBidAdapter.js create mode 100644 modules/freewheelSSPBidAdapter.md create mode 100644 test/spec/modules/freewheelSSPBidAdapter_spec.js diff --git a/modules/freewheelSSPBidAdapter.js b/modules/freewheelSSPBidAdapter.js new file mode 100644 index 00000000000..7c696c746e6 --- /dev/null +++ b/modules/freewheelSSPBidAdapter.js @@ -0,0 +1,314 @@ +import * as utils from 'src/utils'; +import { registerBidder } from 'src/adapters/bidderFactory'; +// import { config } from 'src/config'; + +const BIDDER_CODE = 'freewheel-ssp'; + +const PROTOCOL = getProtocol(); +const FREEWHEEL_ADSSETUP = PROTOCOL + '://ads.stickyadstv.com/www/delivery/swfIndex.php'; +const MUSTANG_URL = PROTOCOL + '://cdn.stickyadstv.com/mustang/mustang.min.js'; +const PRIMETIME_URL = PROTOCOL + '://cdn.stickyadstv.com/prime-time/'; +const USER_SYNC_URL = PROTOCOL + '://ads.stickyadstv.com/auto-user-sync'; + +function getProtocol() { + if (location.protocol && location.protocol.indexOf('https') === 0) { + return 'https'; + } else { + return 'http'; + } +} + +function isValidUrl(str) { + if (!str) { + return false; + } + + // regExp for url validation + var pattern = /^(https?|ftp|file):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/; + return pattern.test(str); +} + +function getBiggerSize(array) { + var result = [0, 0]; + for (var i = 0; i < array.length; i++) { + if (array[i][0] * array[i][1] > result[0] * result[1]) { + result = array[i]; + } + } + return result; +} + +/* +* read the pricing extension with this format: 1.0000 +* @return {object} pricing data in format: {currency: "EUR", price:"1.000"} +*/ +function getPricing(xmlNode) { + var pricingExtNode; + var princingData = {}; + + var extensions = xmlNode.querySelectorAll('Extension'); + extensions.forEach(function(node) { + if (node.getAttribute('type') === 'StickyPricing') { + pricingExtNode = node; + } + }); + + if (pricingExtNode) { + var priceNode = pricingExtNode.querySelector('Price'); + princingData = { + currency: priceNode.getAttribute('currency'), + price: priceNode.textContent || priceNode.innerText + }; + } else { + utils.logWarn('PREBID - ' + BIDDER_CODE + ': Can\'t get pricing data. Is price awareness enabled?'); + } + + return princingData; +} + +function getCreativeId(xmlNode) { + var creaId = ''; + var adNodes = xmlNode.querySelectorAll('Ad'); + + adNodes.forEach(function(el) { + creaId += '[' + el.getAttribute('id') + ']'; + }); + + return creaId; +} + +/** +* returns the top most accessible window +*/ +function getTopMostWindow() { + var res = window; + + try { + while (top !== res) { + if (res.parent.location.href.length) { res = res.parent; } + } + } catch (e) {} + + return res; +} + +function getComponentId(inputFormat) { + var component = 'mustang'; // default component id + + if (inputFormat && inputFormat !== 'inbanner') { + // format identifiers are equals to their component ids. + component = inputFormat; + } + + return component; +} + +function getAPIName(componentId) { + componentId = componentId || ''; + + // remove dash in componentId to get API name + return componentId.replace('-', ''); +} + +function formatAdHTML(bid, size) { + var integrationType = bid.params.format; + + var divHtml = '
'; + + var script = ''; + var libUrl = ''; + if (integrationType && integrationType !== 'inbanner') { + libUrl = PRIMETIME_URL + getComponentId(bid.params.format) + '.min.js'; + script = getOutstreamScript(bid, size); + } else { + libUrl = MUSTANG_URL; + script = getInBannerScript(bid, size); + } + + return divHtml + + ''; +} + +var getInBannerScript = function(bid, size) { + return 'var config = {' + + ' preloadedVast:vast,' + + ' autoPlay:true' + + ' };' + + ' var ad = new window.com.stickyadstv.vpaid.Ad(document.getElementById("freewheelssp_prebid_target"),config);' + + ' (new window.com.stickyadstv.tools.ASLoader(' + bid.params.zoneId + ', \'' + getComponentId(bid.params.format) + '\')).registerEvents(ad);' + + ' ad.initAd(' + size[0] + ',' + size[1] + ',"",0,"","");'; +}; + +var getOutstreamScript = function(bid) { + var placementCode = bid.adUnitCode; + + var config = bid.params; + + // default placement if no placement is set + if (!config.hasOwnProperty('domId') && !config.hasOwnProperty('auto') && !config.hasOwnProperty('p') && !config.hasOwnProperty('article')) { + config.domId = placementCode; + } + + var script = 'var config = {' + + ' preloadedVast:vast,' + + ' ASLoader:new window.com.stickyadstv.tools.ASLoader(' + bid.params.zoneId + ', \'' + getComponentId(bid.params.format) + '\')'; + + for (var key in config) { + // dont' send format parameter + // neither zone nor vastUrlParams value as Vast is already loaded + if (config.hasOwnProperty(key) && key !== 'format' && key !== 'zone' && key !== 'zoneId' && key !== 'vastUrlParams') { + script += ',' + key + ':"' + config[key] + '"'; + } + } + script += '};' + + + 'window.com.stickyadstv.' + getAPIName(bid.params.format) + '.start(config);'; + + return script; +}; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: ['video'], + aliases: ['stickyadstv'], // former name for freewheel-ssp + /** + * 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.zoneId); + }, + + /** + * 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) { + // var currency = config.getConfig(currency); + + var currentBidRequest = bidRequests[0]; + if (bidRequests.length > 1) { + utils.logMessage('Prebid.JS - freewheel bid adapter: only one ad unit is required.'); + } + + var requestParams = { + reqType: 'AdsSetup', + protocolVersion: '2.0', + zoneId: currentBidRequest.params.zoneId, + componentId: getComponentId(currentBidRequest.params.format) + }; + + var location = utils.getTopWindowUrl(); + if (isValidUrl(location)) { + requestParams.loc = location; + } + + var playerSize = getBiggerSize(currentBidRequest.sizes); + if (playerSize[0] > 0 || playerSize[1] > 0) { + requestParams.playerSize = playerSize[0] + 'x' + playerSize[1]; + } + + return { + method: 'GET', + url: FREEWHEEL_ADSSETUP, + data: requestParams, + bidRequest: currentBidRequest + }; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @param {object} request: the built request object containing the initial bidRequest. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, request) { + var bidrequest = request.bidRequest; + var playerSize = getBiggerSize(bidrequest.sizes); + + if (typeof serverResponse == 'object' && typeof serverResponse.body == 'string') { + serverResponse = serverResponse.body; + } + + var xmlDoc; + try { + var parser = new DOMParser(); + xmlDoc = parser.parseFromString(serverResponse, 'application/xml'); + } catch (err) { + utils.logWarn('Prebid.js - ' + BIDDER_CODE + ' : ' + err); + return; + } + + const princingData = getPricing(xmlDoc); + const creativeId = getCreativeId(xmlDoc); + + const topWin = getTopMostWindow(); + if (!topWin.freewheelssp_cache) { + topWin.freewheelssp_cache = {}; + } + topWin.freewheelssp_cache[bidrequest.adUnitCode] = serverResponse; + + const bidResponses = []; + + if (princingData.price) { + const bidResponse = { + requestId: bidrequest.bidId, + cpm: princingData.price, + width: playerSize[0], + height: playerSize[1], + creativeId: creativeId, + currency: princingData.currency, + netRevenue: true, + ttl: 360 + }; + + var mediaTypes = bidrequest.mediaTypes || {}; + if (mediaTypes.video) { + // bidResponse.vastXml = serverResponse; + bidResponse.mediaType = 'video'; + + var blob = new Blob([serverResponse], {type: 'application/xml'}); + bidResponse.vastUrl = window.URL.createObjectURL(blob); + } else { + bidResponse.ad = formatAdHTML(bidrequest, playerSize); + } + + bidResponses.push(bidResponse); + } + + return bidResponses; + }, + + getUserSyncs: function(syncOptions) { + if (syncOptions.pixelEnabled) { + return [{ + type: 'image', + url: USER_SYNC_URL + }]; + } + } +} +registerBidder(spec); diff --git a/modules/freewheelSSPBidAdapter.md b/modules/freewheelSSPBidAdapter.md new file mode 100644 index 00000000000..ba7915c87e1 --- /dev/null +++ b/modules/freewheelSSPBidAdapter.md @@ -0,0 +1,27 @@ +# Overview + +Module Name: Freewheel SSP Bidder Adapter +Module Type: Bidder Adapter +Maintainer: clientsidesdk@freewheel.tv + +# Description + +Module that connects to Freewheel ssp's demand sources + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div', + sizes: [[300, 250]], // a display size + bids: [ + { + bidder: "freewheel-ssp", + params: { + zoneId : '277225' + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/test/spec/modules/freewheelSSPBidAdapter_spec.js b/test/spec/modules/freewheelSSPBidAdapter_spec.js new file mode 100644 index 00000000000..107259e9805 --- /dev/null +++ b/test/spec/modules/freewheelSSPBidAdapter_spec.js @@ -0,0 +1,193 @@ +import { expect } from 'chai'; +import { spec } from 'modules/freewheelSSPBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory'; + +const ENDPOINT = '//ads.stickyadstv.com/www/delivery/swfIndex.php'; + +describe('freewheelSSP BidAdapter Test', () => { + const adapter = newBidder(spec); + + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', () => { + let bid = { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', () => { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', () => { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + wrong: 'missing zone id' + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', () => { + let bidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + it('should add parameters to the tag', () => { + const request = spec.buildRequests(bidRequests); + console.log(request.data); + + const payload = request.data; + expect(payload.reqType).to.equal('AdsSetup'); + expect(payload.protocolVersion).to.equal('2.0'); + expect(payload.zoneId).to.equal('277225'); + expect(payload.componentId).to.equal('mustang'); + expect(payload.playerSize).to.equal('300x600'); + }); + + it('sends bid request to ENDPOINT via GET', () => { + const request = spec.buildRequests(bidRequests); + expect(request.url).to.contain(ENDPOINT); + expect(request.method).to.equal('GET'); + }); + }) + + describe('interpretResponse', () => { + let bidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + + let formattedBidRequests = [ + { + 'bidder': 'freewheel-ssp', + 'params': { + 'zoneId': '277225', + 'format': 'floorad' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[600, 250], [300, 600]], + 'bidId': '30b3other1c1838de1e', + 'bidderRequestId': '22edbae273other3bf6', + 'auctionId': '1d1a03079test0a475', + }, + { + 'bidder': 'stickyadstv', + 'params': { + 'zoneId': '277225', + 'format': 'test' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 600]], + 'bidId': '2', + 'bidderRequestId': '3', + 'auctionId': '4', + } + ]; + + let response = '' + + '' + + ' ' + + ' Adswizz' + + ' ' + + ' ' + + ' ' + + ' 00:00:09' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' 0.2000' + + ' ' + + ' ' + + ' ' + + ''; + + let ad = '
'; + let formattedAd = '
'; + + it('should get correct bid response', () => { + var request = spec.buildRequests(bidRequests); + + let expectedResponse = [ + { + requestId: '30b31c1838de1e', + cpm: '0.2000', + width: 300, + height: 600, + creativeId: '28517153', + currency: 'EUR', + netRevenue: true, + ttl: 360, + ad: ad + } + ]; + + let result = spec.interpretResponse(response, request); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('should get correct bid response with formated ad', () => { + var request = spec.buildRequests(formattedBidRequests); + + let expectedResponse = [ + { + requestId: '30b31c1838de1e', + cpm: '0.2000', + width: 300, + height: 600, + creativeId: '28517153', + currency: 'EUR', + netRevenue: true, + ttl: 360, + ad: formattedAd + } + ]; + + let result = spec.interpretResponse(response, request); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + }); + + it('handles nobid responses', () => { + var reqest = spec.buildRequests(formattedBidRequests); + let response = ''; + + let result = spec.interpretResponse(response, reqest); + expect(result.length).to.equal(0); + }); + }); +}); From b7385847cbc76e3a2b3b7e104667b86e8c3130a7 Mon Sep 17 00:00:00 2001 From: optimatic58 <33465594+optimatic58@users.noreply.github.com> Date: Tue, 19 Dec 2017 13:13:20 -0500 Subject: [PATCH 07/20] + fixed endpoint request data property names - width to w and height to h (#1955) + updated unit test for the adapter to comply with the property name changes --- modules/optimaticBidAdapter.js | 4 ++-- test/spec/modules/optimaticBidAdapter_spec.js | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/optimaticBidAdapter.js b/modules/optimaticBidAdapter.js index 3130977ea76..2408eb8cefe 100644 --- a/modules/optimaticBidAdapter.js +++ b/modules/optimaticBidAdapter.js @@ -75,8 +75,8 @@ function getData (bid) { bidfloor: bid.params.bidfloor, video: { mimes: ['video/mp4', 'video/ogg', 'video/webm', 'video/x-flv', 'application/javascript', 'application/x-shockwave-flash'], - width: size.width, - height: size.height + w: size.width, + h: size.height } }], site: { diff --git a/test/spec/modules/optimaticBidAdapter_spec.js b/test/spec/modules/optimaticBidAdapter_spec.js index cbea5598627..890c0b78613 100644 --- a/test/spec/modules/optimaticBidAdapter_spec.js +++ b/test/spec/modules/optimaticBidAdapter_spec.js @@ -66,8 +66,8 @@ describe('OptimaticBidAdapter', () => { const requests = spec.buildRequests([ bidRequest ]); const data = requests[0].data; const [ width, height ] = bidRequest.sizes; - expect(data.imp[0].video.width).to.equal(width); - expect(data.imp[0].video.height).to.equal(height); + 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); }); @@ -77,8 +77,8 @@ describe('OptimaticBidAdapter', () => { bidRequest.sizes = [[ width, height ]]; const requests = spec.buildRequests([ bidRequest ]); const data = requests[0].data; - expect(data.imp[0].video.width).to.equal(width); - expect(data.imp[0].video.height).to.equal(height); + expect(data.imp[0].video.w).to.equal(width); + expect(data.imp[0].video.h).to.equal(height); }); it('must parse bid size from a string', () => { @@ -87,16 +87,16 @@ describe('OptimaticBidAdapter', () => { bidRequest.sizes = `${width}x${height}`; const requests = spec.buildRequests([ bidRequest ]); const data = requests[0].data; - expect(data.imp[0].video.width).to.equal(width); - expect(data.imp[0].video.height).to.equal(height); + expect(data.imp[0].video.w).to.equal(width); + expect(data.imp[0].video.h).to.equal(height); }); it('must handle an empty bid size', () => { bidRequest.sizes = []; const requests = spec.buildRequests([ bidRequest ]); const data = requests[0].data; - expect(data.imp[0].video.width).to.equal(undefined); - expect(data.imp[0].video.height).to.equal(undefined); + expect(data.imp[0].video.w).to.equal(undefined); + expect(data.imp[0].video.h).to.equal(undefined); }); }); From f1f18e131946af0214a04e496142ca6d3076a27c Mon Sep 17 00:00:00 2001 From: Pratik Thakkar Date: Tue, 19 Dec 2017 23:58:18 +0530 Subject: [PATCH 08/20] Added iQM Bid Adapter for Prebid.js 1.0 (#1880) * Added iQM Bid Adapter for Prebid.js 1.0 * Modified URL from http to https * Removed geo function which was fetching user location. --- modules/iqmBidAdapter.js | 137 +++++++++++++++ modules/iqmBidAdapter.md | 41 +++++ test/spec/modules/iqmBidAdapter_spec.js | 219 ++++++++++++++++++++++++ 3 files changed, 397 insertions(+) create mode 100644 modules/iqmBidAdapter.js create mode 100644 modules/iqmBidAdapter.md create mode 100644 test/spec/modules/iqmBidAdapter_spec.js diff --git a/modules/iqmBidAdapter.js b/modules/iqmBidAdapter.js new file mode 100644 index 00000000000..6263caeeba0 --- /dev/null +++ b/modules/iqmBidAdapter.js @@ -0,0 +1,137 @@ +import * as utils from 'src/utils'; +// import {config} from 'src/config'; +import {registerBidder} from 'src/adapters/bidderFactory'; +const BIDDER_CODE = 'iqm'; +const ENDPOINT_URL = 'https://pbd.bids.iqm.com'; +const VERSION = 'v.1.0.0'; + +export const spec = { + code: BIDDER_CODE, + aliases: ['iqm'], // short code + /** + * 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 && bid.params && bid.params.publisherId && bid.params.placementId && bid.params.tagId); + }, + /** + * Make a server request from the list of BidRequests. + * + * @return ServerRequest Info describing the request to the server. + * @param validBidRequests - an array of bids + */ + buildRequests: function(validBidRequests) { + let requestId = ''; + let siteId = ''; + let device = getDevice(); + return validBidRequests.map(bid => { + requestId = bid.requestId; + let bidfloor = utils.getBidIdParameter('bidfloor', bid.params); + siteId = utils.getBidIdParameter('tagId', bid.params); + const imp = { + id: bid.bidId, + secure: 1, + bidfloor: bidfloor || 0, + displaymanager: 'Prebid.js', + displaymanagerver: VERSION, + mediatype: 'banner' + }; + imp.banner = getSize(bid.sizes); + let data = { + id: requestId, + publisherId: utils.getBidIdParameter('publisherId', bid.params), + tagId: utils.getBidIdParameter('tagId', bid.params), + placementId: utils.getBidIdParameter('placementId', bid.params), + device: device, + site: { + id: siteId, + page: utils.getTopWindowLocation().href, + domain: utils.getTopWindowLocation().host + }, + imp: imp + }; + return { + method: 'POST', + url: ENDPOINT_URL, + data: data + }; + }); + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @param bidRequest + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, bidRequest) { + // const serverBody = serverResponse.body; + // const headerValue = serverResponse.headers.get('some-response-header') + const bidResponses = []; + serverResponse = serverResponse.body; + if (serverResponse && utils.isArray(serverResponse.seatbid)) { + utils._each(serverResponse.seatbid, function(bidList) { + utils._each(bidList.bid, function(bid) { + const responseCPM = parseFloat(bid.price); + if (responseCPM > 0.0 && bid.impid) { + // const responseNurl = bid.nurl || ''; + const bidResponse = { + requestId: bid.impid, + currency: serverResponse.cur || 'USD', + cpm: responseCPM, + netRevenue: true, + creativeId: bid.crid || '', + ad: bid.adm || '', + width: bid.w || bidRequest.data.imp.banner.w, + height: bid.h || bidRequest.data.imp.banner.h, + ttl: bid.ttl || 300 + }; + + bidResponses.push(bidResponse); + } + }) + }); + } + return bidResponses; + } +}; + +let getDevice = function () { + const language = navigator.language ? 'language' : 'userLanguage'; + return { + h: screen.height, + w: screen.width, + dnt: _getDNT() ? 1 : 0, + language: navigator[language].split('-')[0], + make: navigator.vendor ? navigator.vendor : '', + ua: navigator.userAgent, + devicetype: _isMobile() ? 1 : _isConnectedTV() ? 3 : 2 + }; +}; + +let _getDNT = function () { + return navigator.doNotTrack === '1' || window.doNotTrack === '1' || navigator.msDoNotTrack === '1' || navigator.doNotTrack === 'yes'; +}; + +let getSize = function (sizes) { + let sizeMap; + if (sizes.length === 2 && typeof sizes[0] === 'number' && typeof sizes[1] === 'number') { + sizeMap = {w: sizes[0], h: sizes[1]}; + } else { + sizeMap = {w: sizes[0][0], h: sizes[0][1]}; + } + return sizeMap; +}; + +function _isMobile() { + return (/(ios|ipod|ipad|iphone|android)/i).test(global.navigator.userAgent); +} + +function _isConnectedTV() { + return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(global.navigator.userAgent); +} + +registerBidder(spec); diff --git a/modules/iqmBidAdapter.md b/modules/iqmBidAdapter.md new file mode 100644 index 00000000000..d6d1b4d037d --- /dev/null +++ b/modules/iqmBidAdapter.md @@ -0,0 +1,41 @@ +#Overview + +``` +Module Name: iQM Bidder Adapter +Module Type: Bidder Adapter +Maintainer: hbteam@iqm.com +``` + +# Parameters + +| Name | Scope | Description | Example | +| :------------ | :------- | :------------------------ | :------------------- | +| `publisherId` | required | The Publisher ID from iQM | "df5fd732-c5f3-11e7" | +| `tagId` | required | The tag ID from iQM | "1c5c9ec2-c5f4-11e7" | +| `placementId` | required | The Placement ID from iQM | "50cc36fe-c5f4-11e7" | +| `bidfloor` | optional | Bid Floor | 0.50 | + +# Description + +Module that connects to iQM demand sources + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div1', + sizes: [[320, 50]], // display 320x50 + bids: [ + { + bidder: 'iqm', + params: { + publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', + tagId: '1c5c9ec2-c5f4-11e7-abc4-cec278b6b50a', + placementId: '50cc36fe-c5f4-11e7-abc4-cec278b6b50a', + bidfloor: 0.50, + } + } + ] + } + ]; +``` diff --git a/test/spec/modules/iqmBidAdapter_spec.js b/test/spec/modules/iqmBidAdapter_spec.js new file mode 100644 index 00000000000..8958a4dfc45 --- /dev/null +++ b/test/spec/modules/iqmBidAdapter_spec.js @@ -0,0 +1,219 @@ +import {expect} from 'chai'; +import {spec} from 'modules/iqmBidAdapter' +import * as utils from 'src/utils'; + +describe('iqmBidAdapter', () => { + const ENDPOINT_URL = 'https://pbd.bids.iqm.com'; + const bidRequests = [{ + bidder: 'iqm', + params: { + position: 1, + tagId: 'tagId-1', + placementId: 'placementId-1', + pubId: 'pubId-1', + secure: true, + bidfloor: 0.5 + }, + placementCode: 'pcode000', + transactionId: 'tx000', + sizes: [[300, 250]], + bidId: 'bid000', + bidderRequestId: '117d765b87bed38', + requestId: 'req000' + }]; + + const bidResponses = { + body: { + id: 'req000', + seatbid: [{ + bid: [{ + nurl: 'nurl', + adm: '', + crid: 'cr-65981', + impid: 'bid000', + price: 0.99, + w: 300, + h: 250, + adomain: ['https://example.com'], + id: 'bid000', + ttl: 300 + }] + }] + }, + headers: {}}; + + const bidResponseEmptySeat = { + body: { + id: 'req000', + seatbid: [] + }, + headers: {} + }; + + const bidResponseEmptyBid = { + body: { + id: 'req000', + seatbid: [{ + bid: [] + }] + }, + headers: {} + }; + + const bidResponseNoImpId = { + body: { + id: 'req000', + seatbid: [{ + bid: [{ + nurl: 'nurl', + adm: '', + crid: 'cr-65981', + price: 0.99, + w: 300, + h: 250, + adomain: ['https://example.com'], + id: 'bid000', + ttl: 300 + }] + }] + }, + headers: {} + }; + + describe('Request verification', () => { + it('basic property verification', () => { + expect(spec.code).to.equal('iqm'); + expect(spec.aliases).to.be.an('array'); + // expect(spec.aliases).to.be.ofSize(1); + expect(spec.aliases).to.have.lengthOf(1); + }); + + describe('isBidRequestValid', () => { + let bid = { + 'bidder': 'iqm', + 'params': { + 'placementId': 'placementId', + 'tagId': 'tagId', + 'publisherId': 'pubId' + }, + 'adUnitCode': 'ad-unit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475' + }; + + it('should return false for empty object', () => { + expect(spec.isBidRequestValid({})).to.equal(false); + }); + + it('should return false for request without param', () => { + let bid = Object.assign({}, bid); + delete bid.params; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false for invalid params', () => { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'placementId': 'placementId' + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return true for proper request', () => { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + }); + + describe('buildRequests', () => { + it('sends every bid request to ENDPOINT_URL via POST method', () => { + const requests = spec.buildRequests(bidRequests); + expect(requests[0].method).to.equal('POST'); + expect(requests[0].url).to.equal(ENDPOINT_URL); + // expect(requests[1].method).to.equal('POST'); + // expect(requests[1].url).to.equal(ENDPOINT_URL); + }); + + it('should send request data with every request', () => { + const requests = spec.buildRequests(bidRequests); + const data = requests[0].data; + expect(data.id).to.equal(bidRequests[0].requestId); + + expect(data.imp.id).to.equal(bidRequests[0].bidId); + expect(data.imp.bidfloor).to.equal(bidRequests[0].params.bidfloor); + expect(data.imp.secure).to.equal(1); + expect(data.imp.displaymanager).to.equal('Prebid.js'); + expect(data.imp.displaymanagerver).to.equal('v.1.0.0'); + expect(data.imp.mediatype).to.equal('banner'); + expect(data.imp.banner).to.deep.equal({ + w: 300, + h: 250 + }); + expect(data.publisherId).to.equal(utils.getBidIdParameter('publisherId', bidRequests[0].params)); + expect(data.tagId).to.equal(utils.getBidIdParameter('tagId', bidRequests[0].params)); + expect(data.placementId).to.equal(utils.getBidIdParameter('placementId', bidRequests[0].params)); + expect(data.device.w).to.equal(screen.width); + expect(data.device.h).to.equal(screen.height); + expect(data.device.make).to.equal(navigator.vendor ? navigator.vendor : ''); + expect(data.device.ua).to.equal(navigator.userAgent); + expect(data.device.dnt).to.equal(navigator.doNotTrack === '1' || window.doNotTrack === '1' || navigator.msDoNotTrack === '1' || navigator.doNotTrack === 'yes' ? 1 : 0); + expect(data.site).to.deep.equal({ + id: utils.getBidIdParameter('tagId', bidRequests[0].params), + page: utils.getTopWindowLocation().href, + domain: utils.getTopWindowLocation().host + }); + + expect(data.device.ua).to.equal(navigator.userAgent); + expect(data.device.h).to.equal(screen.height); + expect(data.device.w).to.equal(screen.width); + + expect(data.site.id).to.equal(bidRequests[0].params.tagId); + expect(data.site.page).to.equal(utils.getTopWindowLocation().href); + expect(data.site.domain).to.equal(utils.getTopWindowLocation().host); + }); + }); + + describe('interpretResponse', () => { + it('should handle no bid response', () => { + const response = spec.interpretResponse({ body: null }, { bidRequests }); + expect(response.length).to.equal(0); + }); + + it('should have at least one Seat Object', () => { + const request = spec.buildRequests(bidRequests); + const response = spec.interpretResponse(bidResponseEmptySeat, request); + expect(response.length).to.equal(0); + }); + + it('should have at least one Bid Object', () => { + const request = spec.buildRequests(bidRequests); + const response = spec.interpretResponse(bidResponseEmptyBid, request); + expect(response.length).to.equal(0); + }); + + it('should have impId in Bid Object', () => { + const request = spec.buildRequests(bidRequests); + const response = spec.interpretResponse(bidResponseNoImpId, request); + expect(response.length).to.equal(0); + }); + + it('should handle valid response', () => { + const request = spec.buildRequests(bidRequests); + const response = spec.interpretResponse(bidResponses, request); + expect(response).to.be.an('array').to.have.lengthOf(1); + + let bid = response[0]; + expect(bid).to.have.property('requestId', 'bid000'); + expect(bid).to.have.property('currency', 'USD'); + expect(bid).to.have.property('cpm', 0.99); + expect(bid).to.have.property('creativeId', 'cr-65981'); + expect(bid).to.have.property('width', 300); + expect(bid).to.have.property('height', 250); + expect(bid).to.have.property('ttl', 300); + expect(bid).to.have.property('ad', ''); + }); + }); + }); +}); From 437cb05946b237a810bafdee2b15a9ebaecc6d88 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Tue, 19 Dec 2017 11:47:45 -0800 Subject: [PATCH 09/20] Remove stray console.log (#1975) --- test/spec/modules/freewheelSSPBidAdapter_spec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/spec/modules/freewheelSSPBidAdapter_spec.js b/test/spec/modules/freewheelSSPBidAdapter_spec.js index 107259e9805..33bd647efaa 100644 --- a/test/spec/modules/freewheelSSPBidAdapter_spec.js +++ b/test/spec/modules/freewheelSSPBidAdapter_spec.js @@ -57,8 +57,6 @@ describe('freewheelSSP BidAdapter Test', () => { it('should add parameters to the tag', () => { const request = spec.buildRequests(bidRequests); - console.log(request.data); - const payload = request.data; expect(payload.reqType).to.equal('AdsSetup'); expect(payload.protocolVersion).to.equal('2.0'); From d4e1e9853f0c02e8fd83d05476ab2688b1156315 Mon Sep 17 00:00:00 2001 From: Jaimin Panchal Date: Tue, 19 Dec 2017 14:52:14 -0500 Subject: [PATCH 10/20] Remove duplicate request id and fix empty response from getHighesCpmBids, getAdserverTargeting (#1970) * Removed requestId and added auctionId * Updated module fixtures to use auctionId and not requestId * remove request id from external bid object and fix bug for empty result in public api * use auctionId instead of requestId * fixed lint errors --- modules/conversantBidAdapter.js | 2 +- modules/mobfoxBidAdapter.js | 2 +- src/auction.js | 1 - src/prebid.js | 23 +++-- src/targeting.js | 26 ++--- src/utils.js | 23 ++++- test/fixtures/fixtures.js | 98 +++++++++---------- test/fixtures/video/bidRequest.json | 4 +- test/fixtures/video/vastPayloadResponse.json | 2 +- test/fixtures/video/vastUrlResponse.json | 2 +- test/spec/modules/33acrossBidAdapter_spec.js | 2 +- test/spec/modules/adbutlerBidAdapter_spec.js | 4 +- .../adkernelAdnAnalyticsAdapter_spec.js | 6 +- .../modules/adxcgAnalyticsAdapter_spec.js | 2 +- test/spec/modules/aolBidAdapter_spec.js | 4 +- .../spec/modules/conversantBidAdapter_spec.js | 8 +- test/spec/modules/fidelityBidAdapter_spec.js | 4 +- .../modules/huddledmassesBidAdapter_spec.js | 2 +- test/spec/modules/komoonaBidAdapter_spec.js | 4 +- test/spec/modules/mobfoxBidAdapter_spec.js | 23 +---- .../modules/nanointeractiveBidAdapter_spec.js | 2 +- test/spec/modules/quantcastBidAdapter_spec.js | 4 +- test/spec/modules/readpeakBidAdapter_spec.js | 3 +- test/spec/modules/rtbdemandBidAdapter_spec.js | 6 +- test/spec/modules/rubiconBidAdapter_spec.js | 4 +- test/spec/modules/serverbidBidAdapter_spec.js | 8 +- .../modules/underdogmediaBidAdapter_spec.js | 6 +- test/spec/modules/undertoneBidAdapter_spec.js | 8 +- test/spec/unit/core/adapterManager_spec.js | 26 ++--- test/spec/unit/core/bidderFactory_spec.js | 12 +-- test/spec/unit/pbjs_api_spec.js | 2 +- 31 files changed, 162 insertions(+), 161 deletions(-) diff --git a/modules/conversantBidAdapter.js b/modules/conversantBidAdapter.js index ad0dfc7bcf4..1f6c4f27b77 100644 --- a/modules/conversantBidAdapter.js +++ b/modules/conversantBidAdapter.js @@ -60,7 +60,7 @@ export const spec = { const secure = isPageSecure || (utils.getBidIdParameter('secure', bid.params) ? 1 : 0); siteId = utils.getBidIdParameter('site_id', bid.params); - requestId = bid.requestId; + requestId = bid.auctionId; const format = convertSizes(bid.sizes); diff --git a/modules/mobfoxBidAdapter.js b/modules/mobfoxBidAdapter.js index ff55d330112..3620d8d30e7 100644 --- a/modules/mobfoxBidAdapter.js +++ b/modules/mobfoxBidAdapter.js @@ -9,7 +9,7 @@ export const spec = { code: BIDDER_CODE, aliases: ['mf'], // short code isBidRequestValid: function (bid) { - return bid.params.s !== null && bid.params.s !== undefined && bid.requestId !== null && bid.requestId !== undefined; + return bid.params.s !== null && bid.params.s !== undefined; }, buildRequests: function (validBidRequests) { if (validBidRequests.length > 1) { diff --git a/src/auction.js b/src/auction.js index 82aaa88cf56..45d06c23f59 100644 --- a/src/auction.js +++ b/src/auction.js @@ -268,7 +268,6 @@ function getPreparedBidForAuction({adUnitCode, bid, bidRequests, auctionId}) { let bidObject = Object.assign({}, bid, { auctionId, - requestId: bidRequest.requestId, responseTimestamp: timestamp(), requestTimestamp: start, cpm: parseFloat(bid.cpm) || 0, diff --git a/src/prebid.js b/src/prebid.js index ffecabe05eb..de74f2c4d7b 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -1,7 +1,7 @@ /** @module pbjs */ import { getGlobal } from './prebidGlobal'; -import { flatten, uniques, isGptPubadsDefined, adUnitsFilter } from './utils'; +import { flatten, uniques, isGptPubadsDefined, adUnitsFilter, removeRequestId } from './utils'; import { videoAdUnit, videoBidder, hasNonVideoBidder } from './video'; import { nativeAdUnit, nativeBidder, hasNonNativeBidder } from './native'; import { listenMessagesFromCreative } from './secureCreatives'; @@ -113,7 +113,7 @@ $$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCode = function(adUnitCode) { $$PREBID_GLOBAL$$.getAdserverTargeting = function (adUnitCode) { utils.logInfo('Invoking $$PREBID_GLOBAL$$.getAdserverTargeting', arguments); - return targeting.getAllTargeting(adUnitCode); + return targeting.getAllTargeting(adUnitCode, auctionManager.getBidsReceived()); }; /** @@ -127,16 +127,17 @@ $$PREBID_GLOBAL$$.getBidResponses = function () { const responses = auctionManager.getBidsReceived() .filter(adUnitsFilter.bind(this, auctionManager.getAdUnitCodes())); - // find the last requested id to get responses for most recent auction only - const currentRequestId = responses && responses.length && responses[responses.length - 1].requestId; + // find the last auction id to get responses for most recent auction only + const currentAuctionId = responses && responses.length && responses[responses.length - 1].auctionId; - return responses.map(bid => bid.adUnitCode) + return responses + .map(bid => bid.adUnitCode) .filter(uniques).map(adUnitCode => responses - .filter(bid => bid.requestId === currentRequestId && bid.adUnitCode === adUnitCode)) + .filter(bid => bid.auctionId === currentAuctionId && bid.adUnitCode === adUnitCode)) .filter(bids => bids && bids[0] && bids[0].adUnitCode) .map(bids => { return { - [bids[0].adUnitCode]: { bids: bids } + [bids[0].adUnitCode]: { bids: bids.map(removeRequestId) } }; }) .reduce((a, b) => Object.assign(a, b), {}); @@ -152,7 +153,7 @@ $$PREBID_GLOBAL$$.getBidResponses = function () { $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode = function (adUnitCode) { const bids = auctionManager.getBidsReceived().filter(bid => bid.adUnitCode === adUnitCode); return { - bids: bids + bids: bids.map(removeRequestId) }; }; @@ -528,7 +529,8 @@ $$PREBID_GLOBAL$$.aliasBidder = function (bidderCode, alias) { * @return {Array} A list of bids that have won their respective auctions. */ $$PREBID_GLOBAL$$.getAllWinningBids = function () { - return auctionManager.getAllWinningBids(); + return auctionManager.getAllWinningBids() + .map(removeRequestId); }; /** @@ -539,7 +541,8 @@ $$PREBID_GLOBAL$$.getAllWinningBids = function () { * @return {Array} array containing highest cpm bid object(s) */ $$PREBID_GLOBAL$$.getHighestCpmBids = function (adUnitCode) { - return targeting.getWinningBids(adUnitCode); + return targeting.getWinningBids(adUnitCode, auctionManager.getBidsReceived()) + .map(removeRequestId); }; /** diff --git a/src/targeting.js b/src/targeting.js index 2169af21b2b..54324265a21 100644 --- a/src/targeting.js +++ b/src/targeting.js @@ -54,14 +54,14 @@ export function newTargeting(auctionManager) { * @param {string=} adUnitCode * @return {Object.} targeting */ - targeting.getAllTargeting = function(adUnitCode) { + targeting.getAllTargeting = function(adUnitCode, bidsReceived = getBidsReceived()) { const adUnitCodes = getAdUnitCodes(adUnitCode); // Get targeting for the winning bid. Add targeting for any bids that have // `alwaysUseBid=true`. If sending all bids is enabled, add targeting for losing bids. - var targeting = getWinningBidTargeting(adUnitCodes) - .concat(getCustomBidTargeting(adUnitCodes)) - .concat(config.getConfig('enableSendAllBids') ? getBidLandscapeTargeting(adUnitCodes) : []); + var targeting = getWinningBidTargeting(adUnitCodes, bidsReceived) + .concat(getCustomBidTargeting(adUnitCodes, bidsReceived)) + .concat(config.getConfig('enableSendAllBids') ? getBidLandscapeTargeting(adUnitCodes, bidsReceived) : []); // store a reference of the targeting keys targeting.map(adUnitCode => { @@ -169,15 +169,15 @@ export function newTargeting(auctionManager) { * @param {(string|string[])} adUnitCode adUnitCode or array of adUnitCodes * @return {[type]} [description] */ - targeting.getWinningBids = function(adUnitCode) { + targeting.getWinningBids = function(adUnitCode, bidsReceived = getBidsReceived()) { const adUnitCodes = getAdUnitCodes(adUnitCode); - return getBidsReceived() + return bidsReceived .filter(bid => includes(adUnitCodes, bid.adUnitCode)) .filter(bid => bid.cpm > 0) .map(bid => bid.adUnitCode) .filter(uniques) - .map(adUnitCode => getBidsReceived() + .map(adUnitCode => bidsReceived .filter(bid => bid.adUnitCode === adUnitCode ? bid : null) .reduce(getHighestCpm, getEmptyBid(adUnitCode))); }; @@ -207,8 +207,8 @@ export function newTargeting(auctionManager) { * @param {string[]} AdUnit code array * @return {targetingArray} winning bids targeting */ - function getWinningBidTargeting(adUnitCodes) { - let winners = targeting.getWinningBids(adUnitCodes); + function getWinningBidTargeting(adUnitCodes, bidsReceived) { + let winners = targeting.getWinningBids(adUnitCodes, bidsReceived); winners.forEach((winner) => { winner.status = BID_TARGETING_SET; }); @@ -302,8 +302,8 @@ export function newTargeting(auctionManager) { * @param {string[]} AdUnit code array * @return {targetingArray} bids with custom targeting defined in bidderSettings */ - function getCustomBidTargeting(adUnitCodes) { - return getBidsReceived() + function getCustomBidTargeting(adUnitCodes, bidsReceived) { + return bidsReceived .filter(bid => includes(adUnitCodes, bid.adUnitCode)) .map(bid => Object.assign({}, bid)) .reduce(mergeAdServerTargeting, []) @@ -316,11 +316,11 @@ export function newTargeting(auctionManager) { * @param {string[]} AdUnit code array * @return {targetingArray} all non-winning bids targeting */ - function getBidLandscapeTargeting(adUnitCodes) { + function getBidLandscapeTargeting(adUnitCodes, bidsReceived) { const standardKeys = CONSTANTS.TARGETING_KEYS.concat(NATIVE_TARGETING_KEYS); const bids = []; // bucket by adUnitcode - let buckets = groupBy(getBidsReceived(), 'adUnitCode'); + let buckets = groupBy(bidsReceived, 'adUnitCode'); // filter top bid for each bucket by bidder Object.keys(buckets).forEach(bucketKey => { let bidsByBidder = groupBy(buckets[bucketKey], 'bidderCode'); diff --git a/src/utils.js b/src/utils.js index d5657845492..19014049352 100644 --- a/src/utils.js +++ b/src/utils.js @@ -794,7 +794,7 @@ export function getBidderRequest(bidRequests, bidder, adUnitCode) { return find(bidRequests, request => { return request.bids .filter(bid => bid.bidder === bidder && bid.adUnitCode === adUnitCode).length > 0; - }) || { start: null, requestId: null }; + }) || { start: null, auctionId: null }; } /** @@ -845,3 +845,24 @@ export function unsupportedBidderMessage(adUnit, unSupportedBidders) { ${plural} won't fetch demand. `; } + +/** + * Delete property from object + * @param {Object} object + * @param {string} prop + * @return {Object} object + */ +export function deletePropertyFromObject(object, prop) { + let result = Object.assign({}, object) + delete result[prop]; + return result +} + +/** + * Delete requestId from external bid object. + * @param {Object} bid + * @return {Object} bid + */ +export function removeRequestId(bid) { + return exports.deletePropertyFromObject(bid, 'requestId'); +} diff --git a/test/fixtures/fixtures.js b/test/fixtures/fixtures.js index 8dbbe265cca..b1d94426db0 100644 --- a/test/fixtures/fixtures.js +++ b/test/fixtures/fixtures.js @@ -4,7 +4,7 @@ export function getBidRequests() { return [ { 'bidderCode': 'appnexus', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'bidderRequestId': '2946b569352ef2', 'bids': [ { @@ -26,7 +26,7 @@ export function getBidRequests() { ], 'bidId': '392b5a6b05d648', 'bidderRequestId': '2946b569352ef2', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'startTime': 1462918897462, 'status': 1, 'transactionId': 'fsafsa' @@ -49,7 +49,7 @@ export function getBidRequests() { ], 'bidId': '4dccdc37746135', 'bidderRequestId': '2946b569352ef2', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'startTime': 1462918897463, 'status': 1, 'transactionId': 'fsafsa' @@ -59,7 +59,7 @@ export function getBidRequests() { }, { 'bidderCode': 'pubmatic', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'bidderRequestId': '5e1525bae3eb11', 'bids': [ { @@ -81,7 +81,7 @@ export function getBidRequests() { ], 'bidId': '6d11aa2d5b3659', 'bidderRequestId': '5e1525bae3eb11', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'transactionId': 'fsafsa' } ], @@ -89,7 +89,7 @@ export function getBidRequests() { }, { 'bidderCode': 'rubicon', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'bidderRequestId': '8778750ee15a77', 'bids': [ { @@ -130,7 +130,7 @@ export function getBidRequests() { ], 'bidId': '96aff279720d39', 'bidderRequestId': '8778750ee15a77', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'transactionId': 'fsafsa' } ], @@ -138,7 +138,7 @@ export function getBidRequests() { }, { 'bidderCode': 'triplelift', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'bidderRequestId': '107f5e6e98dcf09', 'bids': [ { @@ -159,7 +159,7 @@ export function getBidRequests() { ], 'bidId': '1144e2f0de84363', 'bidderRequestId': '107f5e6e98dcf09', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'startTime': 1462918897477, 'transactionId': 'fsafsa' } @@ -168,7 +168,7 @@ export function getBidRequests() { }, { 'bidderCode': 'brightcom', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'bidderRequestId': '12eeded736650b4', 'bids': [ { @@ -189,7 +189,7 @@ export function getBidRequests() { ], 'bidId': '135e89c039705da', 'bidderRequestId': '12eeded736650b4', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'status': 1, 'transactionId': 'fsafsa' } @@ -198,7 +198,7 @@ export function getBidRequests() { }, { 'bidderCode': 'brealtime', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'bidderRequestId': '167c4d79b615948', 'bids': [ { @@ -219,7 +219,7 @@ export function getBidRequests() { ], 'bidId': '17dd1d869bed44e', 'bidderRequestId': '167c4d79b615948', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'startTime': 1462918897480, 'status': 1, 'transactionId': 'fsafsa' @@ -229,7 +229,7 @@ export function getBidRequests() { }, { 'bidderCode': 'pagescience', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'bidderRequestId': '18bed198c172a69', 'bids': [ { @@ -250,7 +250,7 @@ export function getBidRequests() { ], 'bidId': '192c8c1df0f5d1d', 'bidderRequestId': '18bed198c172a69', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'startTime': 1462918897481, 'status': 1, 'transactionId': 'fsafsa' @@ -260,7 +260,7 @@ export function getBidRequests() { }, { 'bidderCode': 'amazon', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'bidderRequestId': '20d0d30333715a7', 'bids': [ { @@ -281,7 +281,7 @@ export function getBidRequests() { ], 'bidId': '21ae8131ec04f6e', 'bidderRequestId': '20d0d30333715a7', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'transactionId': 'fsafsa' } ], @@ -310,7 +310,7 @@ export function getBidResponses() { 'pbHg': '0.11', 'pbAg': '0.10', 'size': '0x0', - 'requestId': 123456, + 'auctionId': 123456, 'adserverTargeting': { 'hb_bidder': 'triplelift', 'hb_adid': '222bb26f9e8bd', @@ -342,7 +342,7 @@ export function getBidResponses() { 'pbAg': '10.00', 'size': '300x250', 'alwaysUseBid': true, - 'requestId': 123456, + 'auctionId': 123456, 'adserverTargeting': { 'hb_bidder': 'appnexus', 'hb_adid': '233bcbee889d46d', @@ -374,7 +374,7 @@ export function getBidResponses() { 'pbAg': '10.00', 'size': '728x90', 'alwaysUseBid': true, - 'requestId': 123456, + 'auctionId': 123456, 'adserverTargeting': { 'hb_bidder': 'appnexus', 'hb_adid': '24bd938435ec3fc', @@ -405,7 +405,7 @@ export function getBidResponses() { 'pbHg': '0.50', 'pbAg': '0.50', 'size': '300x250', - 'requestId': 123456, + 'auctionId': 123456, 'adserverTargeting': { 'hb_bidder': 'pagescience', 'hb_adid': '25bedd4813632d7', @@ -435,7 +435,7 @@ export function getBidResponses() { 'pbHg': '0.17', 'pbAg': '0.15', 'size': '300x250', - 'requestId': 654321, + 'auctionId': 654321, 'adserverTargeting': { 'hb_bidder': 'brightcom', 'hb_adid': '26e0795ab963896', @@ -466,7 +466,7 @@ export function getBidResponses() { 'pbHg': '0.50', 'pbAg': '0.50', 'size': '300x250', - 'requestId': 654321, + 'auctionId': 654321, 'adserverTargeting': { 'hb_bidder': 'brealtime', 'hb_adid': '275bd666f5a5a5d', @@ -498,7 +498,7 @@ export function getBidResponses() { 'pbHg': '5.93', 'pbAg': '5.90', 'size': '300x250', - 'requestId': 654321, + 'auctionId': 654321, 'adserverTargeting': { 'hb_bidder': 'pubmatic', 'hb_adid': '28f4039c636b6a7', @@ -528,7 +528,7 @@ export function getBidResponses() { 'pbHg': '2.74', 'pbAg': '2.70', 'size': '300x600', - 'requestId': 654321, + 'auctionId': 654321, 'adserverTargeting': { 'hb_bidder': 'rubicon', 'hb_adid': '29019e2ab586a5a', @@ -609,7 +609,7 @@ export function getAdUnits() { ], 'bidId': '3692954f816efc', 'bidderRequestId': '2b1a75d5e826c4', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'appnexus', @@ -630,7 +630,7 @@ export function getAdUnits() { ], 'bidId': '68136e1c47023d', 'bidderRequestId': '55e24a66bed717', - 'requestId': '1ff753bd4ae5cb', + 'auctionId': '1ff753bd4ae5cb', 'startTime': 1463510220995, 'status': 1 } @@ -667,7 +667,7 @@ export function getAdUnits() { ], 'bidId': '7e5d6af25ed188', 'bidderRequestId': '55e24a66bed717', - 'requestId': '1ff753bd4ae5cb', + 'auctionId': '1ff753bd4ae5cb', 'startTime': 1463510220996 }, { @@ -689,7 +689,7 @@ export function getAdUnits() { ], 'bidId': '4448d80ac1374e', 'bidderRequestId': '2b1a75d5e826c4', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'triplelift', @@ -709,7 +709,7 @@ export function getAdUnits() { ], 'bidId': '9514d586c52abf', 'bidderRequestId': '8c4f03b838d7ee', - 'requestId': '1ff753bd4ae5cb', + 'auctionId': '1ff753bd4ae5cb', 'startTime': 1463510220997 }, { @@ -732,7 +732,7 @@ export function getAdUnits() { ], 'bidId': '113079fed03f58c', 'bidderRequestId': '1048e0df882e965', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'rubicon', @@ -772,7 +772,7 @@ export function getAdUnits() { ], 'bidId': '13c2c2a79d155ea', 'bidderRequestId': '129e383ac549e5d', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'openx', @@ -793,7 +793,7 @@ export function getAdUnits() { ], 'bidId': '154f9cbf82df565', 'bidderRequestId': '1448569c2453b84', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'pubmatic', @@ -814,7 +814,7 @@ export function getAdUnits() { ], 'bidId': '17f8c3a8fb13308', 'bidderRequestId': '16095445eeb05e4', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'pagescience', @@ -834,7 +834,7 @@ export function getAdUnits() { ], 'bidId': '2074d5757675542', 'bidderRequestId': '19883380ef5453a', - 'requestId': '1ff753bd4ae5cb', + 'auctionId': '1ff753bd4ae5cb', 'startTime': 1463510221014 }, { @@ -855,7 +855,7 @@ export function getAdUnits() { ], 'bidId': '222b6ad5a9b835d', 'bidderRequestId': '2163409fdf6f333', - 'requestId': '1ff753bd4ae5cb', + 'auctionId': '1ff753bd4ae5cb', 'startTime': 1463510221015 }, { @@ -878,7 +878,7 @@ export function getAdUnits() { ], 'bidId': '2499961ab3f937a', 'bidderRequestId': '23b57a2de4ae50b', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'adform', @@ -900,7 +900,7 @@ export function getAdUnits() { ], 'bidId': '26605265bf5e9c5', 'bidderRequestId': '25a0902299c17d3', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'amazon', @@ -920,7 +920,7 @@ export function getAdUnits() { ], 'bidId': '2935d8f6764fe45', 'bidderRequestId': '28afa21ca9246c1', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'aol', @@ -941,7 +941,7 @@ export function getAdUnits() { ], 'bidId': '31d1489681dc539', 'bidderRequestId': '30bf32da9080fdd', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'sovrn', @@ -961,7 +961,7 @@ export function getAdUnits() { ], 'bidId': '33c1a8028d91563', 'bidderRequestId': '324bcb47cfcf034', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'pulsepoint', @@ -983,7 +983,7 @@ export function getAdUnits() { ], 'bidId': '379219f0506a26f', 'bidderRequestId': '360ec66bbb0719c', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' }, { 'bidder': 'brightcom', @@ -1003,7 +1003,7 @@ export function getAdUnits() { ], 'bidId': '395cfcf496e7d6d', 'bidderRequestId': '38a776c7f001ea', - 'requestId': '1ff753bd4ae5cb' + 'auctionId': '1ff753bd4ae5cb' } ] } @@ -1032,7 +1032,7 @@ export function getBidResponsesFromAPI() { 'pbHg': '0.17', 'pbAg': '0.15', 'size': '300x250', - 'requestId': 654321, + 'auctionId': 654321, 'adserverTargeting': { 'hb_bidder': 'brightcom', 'hb_adid': '26e0795ab963896', @@ -1063,7 +1063,7 @@ export function getBidResponsesFromAPI() { 'pbHg': '0.50', 'pbAg': '0.50', 'size': '300x250', - 'requestId': 654321, + 'auctionId': 654321, 'adserverTargeting': { 'hb_bidder': 'brealtime', 'hb_adid': '275bd666f5a5a5d', @@ -1095,7 +1095,7 @@ export function getBidResponsesFromAPI() { 'pbHg': '5.93', 'pbAg': '5.90', 'size': '300x250', - 'requestId': 654321, + 'auctionId': 654321, 'adserverTargeting': { 'hb_bidder': 'pubmatic', 'hb_adid': '28f4039c636b6a7', @@ -1125,7 +1125,7 @@ export function getBidResponsesFromAPI() { 'pbHg': '2.74', 'pbAg': '2.70', 'size': '300x600', - 'requestId': 654321, + 'auctionId': 654321, 'adserverTargeting': { 'hb_bidder': 'rubicon', 'hb_adid': '29019e2ab586a5a', @@ -1358,7 +1358,7 @@ export function getTargetingKeysBidLandscape() { export function getBidRequestedPayload() { return { 'bidderCode': 'adequant', - 'requestId': '150f361b202aa8', + 'auctionId': '150f361b202aa8', 'bidderRequestId': '2b193b7a6ff421', 'bids': [ { @@ -1388,7 +1388,7 @@ export function getBidRequestedPayload() { ], 'bidId': '39032dc5c7e834', 'bidderRequestId': '2b193b7a6ff421', - 'requestId': '150f361b202aa8' + 'auctionId': '150f361b202aa8' } ], 'start': 1465426155412 diff --git a/test/fixtures/video/bidRequest.json b/test/fixtures/video/bidRequest.json index f8306e27662..2a598c50183 100644 --- a/test/fixtures/video/bidRequest.json +++ b/test/fixtures/video/bidRequest.json @@ -16,11 +16,11 @@ "sizes": [640,480], "bidId": "392b5a6b05d648", "bidderRequestId": "2946b569352ef2", - "requestId": "6172477f-987f-4523-a967-fa6d7a434ddf", + "auctionId": "6172477f-987f-4523-a967-fa6d7a434ddf", "startTime": 1462918897462 } ], - "requestId": "6172477f-987f-4523-a967-fa6d7a434ddf", + "auctionId": "6172477f-987f-4523-a967-fa6d7a434ddf", "start": 1462918897460, "timeout": 5000 } diff --git a/test/fixtures/video/vastPayloadResponse.json b/test/fixtures/video/vastPayloadResponse.json index 7c388de41ed..2f72907817f 100644 --- a/test/fixtures/video/vastPayloadResponse.json +++ b/test/fixtures/video/vastPayloadResponse.json @@ -7,7 +7,7 @@ "cpm": 0.1, "height": 480, "mediaType": "video", - "requestId": "6172477f-987f-4523-a967-fa6d7a434ddf", + "auctionId": "6172477f-987f-4523-a967-fa6d7a434ddf", "vastXml": "", "width": 640 } diff --git a/test/fixtures/video/vastUrlResponse.json b/test/fixtures/video/vastUrlResponse.json index f3b023dc7bb..a842ed10a71 100644 --- a/test/fixtures/video/vastUrlResponse.json +++ b/test/fixtures/video/vastUrlResponse.json @@ -7,7 +7,7 @@ "cpm": 0.1, "height": 480, "mediaType": "video", - "requestId": "6172477f-987f-4523-a967-fa6d7a434ddf", + "auctionId": "6172477f-987f-4523-a967-fa6d7a434ddf", "vastUrl": "www.myVastUrl.com", "width": 640 } diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 4754e4d1fa5..0b2d65e7db9 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -28,7 +28,7 @@ describe('33acrossBidAdapter:', function () { productId: PRODUCT_ID }, adUnitCode: 'div-id', - requestId: 'r1', + auctionId: 'r1', sizes: [ [ 300, 250 ], [ 728, 90 ] diff --git a/test/spec/modules/adbutlerBidAdapter_spec.js b/test/spec/modules/adbutlerBidAdapter_spec.js index de40f72073b..a46039402e6 100644 --- a/test/spec/modules/adbutlerBidAdapter_spec.js +++ b/test/spec/modules/adbutlerBidAdapter_spec.js @@ -18,7 +18,7 @@ describe('AdButler adapter', () => { placementCode: '/19968336/header-bid-tag-1', sizes: [[300, 250], [300, 600]], bidId: '23acc48ad47af5', - requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', bidderRequestId: '1c56ad30b9b8ca8', transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' } @@ -63,7 +63,7 @@ describe('AdButler adapter', () => { zoneID: '86133', domain: 'servedbyadbutler.com.dan.test' }, - requestId: '10b327aa396609', + auctionId: '10b327aa396609', placementCode: '/123456/header-bid-tag-1' } ], diff --git a/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js b/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js index 1a14660c6af..282bd62403a 100644 --- a/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js +++ b/test/spec/modules/adkernelAdnAnalyticsAdapter_spec.js @@ -147,7 +147,7 @@ describe('', () => { const REQUEST = { bidderCode: 'adapter', - requestId: '5018eb39-f900-4370-b71e-3bb5b48d324f', + auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f', bidderRequestId: '1a6fc81528d0f6', bids: [{ bidder: 'adapter', @@ -157,7 +157,7 @@ describe('', () => { sizes: [[300, 250]], bidId: '208750227436c1', bidderRequestId: '1a6fc81528d0f6', - requestId: '5018eb39-f900-4370-b71e-3bb5b48d324f' + auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f' }], auctionStart: 1509369418387, timeout: 3000, @@ -173,7 +173,7 @@ describe('', () => { mediaType: 'banner', cpm: 0.015, ad: '', - requestId: '5018eb39-f900-4370-b71e-3bb5b48d324f', + auctionId: '5018eb39-f900-4370-b71e-3bb5b48d324f', responseTimestamp: 1509369418832, requestTimestamp: 1509369418389, bidder: 'adapter', diff --git a/test/spec/modules/adxcgAnalyticsAdapter_spec.js b/test/spec/modules/adxcgAnalyticsAdapter_spec.js index 179b806da48..46b50214873 100644 --- a/test/spec/modules/adxcgAnalyticsAdapter_spec.js +++ b/test/spec/modules/adxcgAnalyticsAdapter_spec.js @@ -25,7 +25,7 @@ describe('adxcg analytics adapter', () => { publisherId: '42' }; let bidRequest = { - requestId: 'requestIdData' + auctionId: 'requestIdData' }; let bidResponse = { adId: 'adIdData', diff --git a/test/spec/modules/aolBidAdapter_spec.js b/test/spec/modules/aolBidAdapter_spec.js index efa595ecc64..d05f21a7be4 100644 --- a/test/spec/modules/aolBidAdapter_spec.js +++ b/test/spec/modules/aolBidAdapter_spec.js @@ -54,14 +54,14 @@ let getNexagePostBidParams = () => { let getDefaultBidRequest = () => { return { bidderCode: 'aol', - requestId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', + auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', bidderRequestId: '7101db09af0db2', start: new Date().getTime(), bids: [{ bidder: 'aol', bidId: '84ab500420319d', bidderRequestId: '7101db09af0db2', - requestId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', + auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', placementCode: 'foo', params: getMarketplaceBidParams() }] diff --git a/test/spec/modules/conversantBidAdapter_spec.js b/test/spec/modules/conversantBidAdapter_spec.js index 1d62cba72c1..c99cad473a3 100644 --- a/test/spec/modules/conversantBidAdapter_spec.js +++ b/test/spec/modules/conversantBidAdapter_spec.js @@ -22,7 +22,7 @@ describe('Conversant adapter tests', function() { sizes: [[300, 250]], bidId: 'bid000', bidderRequestId: '117d765b87bed38', - requestId: 'req000' + auctionId: 'req000' }, { bidder: 'conversant', params: { @@ -34,7 +34,7 @@ describe('Conversant adapter tests', function() { sizes: [[468, 60]], bidId: 'bid001', bidderRequestId: '117d765b87bed38', - requestId: 'req000' + auctionId: 'req000' }, { bidder: 'conversant', params: { @@ -48,7 +48,7 @@ describe('Conversant adapter tests', function() { sizes: [[300, 600], [160, 600]], bidId: 'bid002', bidderRequestId: '117d765b87bed38', - requestId: 'req000' + auctionId: 'req000' }, { bidder: 'conversant', params: { @@ -68,7 +68,7 @@ describe('Conversant adapter tests', function() { sizes: [640, 480], bidId: 'bid003', bidderRequestId: '117d765b87bed38', - requestId: 'req000' + auctionId: 'req000' }]; const bidResponses = { diff --git a/test/spec/modules/fidelityBidAdapter_spec.js b/test/spec/modules/fidelityBidAdapter_spec.js index 036a34ee0b0..28ea18aacac 100644 --- a/test/spec/modules/fidelityBidAdapter_spec.js +++ b/test/spec/modules/fidelityBidAdapter_spec.js @@ -52,7 +52,7 @@ describe('FidelityAdapter', () => { describe('buildRequests', () => { let bidderRequest = { bidderCode: 'fidelity', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', bidderRequestId: '178e34bad3658f', bids: [ { @@ -66,7 +66,7 @@ describe('FidelityAdapter', () => { sizes: [[300, 250], [320, 50]], bidId: '2ffb201a808da7', bidderRequestId: '178e34bad3658f', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' } ], diff --git a/test/spec/modules/huddledmassesBidAdapter_spec.js b/test/spec/modules/huddledmassesBidAdapter_spec.js index 71638cef96a..f98bc06d0da 100644 --- a/test/spec/modules/huddledmassesBidAdapter_spec.js +++ b/test/spec/modules/huddledmassesBidAdapter_spec.js @@ -10,7 +10,7 @@ describe('HuddledmassesAdapter', () => { placement_id: 0 }, placementCode: 'placementid_0', - requestId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', + auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', sizes: [[300, 250]], transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62' }; diff --git a/test/spec/modules/komoonaBidAdapter_spec.js b/test/spec/modules/komoonaBidAdapter_spec.js index 82edba28d03..f7038505db3 100644 --- a/test/spec/modules/komoonaBidAdapter_spec.js +++ b/test/spec/modules/komoonaBidAdapter_spec.js @@ -16,7 +16,7 @@ describe('Komoona.com Adapter Tests', () => { ], bidId: '2faedf1095f815', bidderRequestId: '18065867f8ae39', - requestId: '529e1518-b872-45cf-807c-2d41dfa5bcd3' + auctionId: '529e1518-b872-45cf-807c-2d41dfa5bcd3' }, { bidder: 'komoona', @@ -32,7 +32,7 @@ describe('Komoona.com Adapter Tests', () => { ], bidId: '3c34e2367a3f59', bidderRequestId: '18065867f8ae39', - requestId: '529e1518-b872-45cf-807c-2d41dfa5bcd3' + auctionId: '529e1518-b872-45cf-807c-2d41dfa5bcd3' }]; const bidsResponse = { diff --git a/test/spec/modules/mobfoxBidAdapter_spec.js b/test/spec/modules/mobfoxBidAdapter_spec.js index 76bb95430fe..54a057991e3 100644 --- a/test/spec/modules/mobfoxBidAdapter_spec.js +++ b/test/spec/modules/mobfoxBidAdapter_spec.js @@ -14,7 +14,7 @@ describe('mobfox adapter tests', () => { imp_instl: 1 // optional - set to 1 if using interstitial otherwise delete or set to 0 }, placementCode: 'div-gpt-ad-1460505748561-0', - requestId: 'c241c810-18d9-4aa4-a62f-8c1980d8d36b', + auctionId: 'c241c810-18d9-4aa4-a62f-8c1980d8d36b', transactionId: '31f42cba-5920-4e47-adad-69c79d0d4fb4' }]; @@ -29,21 +29,7 @@ describe('mobfox adapter tests', () => { imp_instl: 1 // optional - set to 1 if using interstitial otherwise delete or set to 0 }, placementCode: 'div-gpt-ad-1460505748561-0', - requestId: 'c241c810-18d9-4aa4-a62f-8c1980d8d36b', - transactionId: '31f42cba-5920-4e47-adad-69c79d0d4fb4' - }]; - - let bidRequestInvalid2 = [{ - code: 'div-gpt-ad-1460505748561-0', - sizes: [[320, 480], [300, 250], [300, 600]], - // Replace this object to test a new Adapter! - bidder: 'mobfox', - bidId: '5t5t5t5', - params: { - s: '267d72ac3f77a3f447b32cf7ebf20673', // required - The hash of your inventory to identify which app is making the request, - imp_instl: 1 // optional - set to 1 if using interstitial otherwise delete or set to 0 - }, - placementCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'c241c810-18d9-4aa4-a62f-8c1980d8d36b', transactionId: '31f42cba-5920-4e47-adad-69c79d0d4fb4' }]; @@ -56,11 +42,6 @@ describe('mobfox adapter tests', () => { let isValid = adapter.spec.isBidRequestValid(bidRequestInvalid1[0]); expect(isValid).to.equal(false); }); - - it('test valid MF request failed2', () => { - let isValid = adapter.spec.isBidRequestValid(bidRequestInvalid2[0]); - expect(isValid).to.equal(false); - }); }) describe('buildRequests', () => { diff --git a/test/spec/modules/nanointeractiveBidAdapter_spec.js b/test/spec/modules/nanointeractiveBidAdapter_spec.js index b9b9207aca2..01aa60351e8 100644 --- a/test/spec/modules/nanointeractiveBidAdapter_spec.js +++ b/test/spec/modules/nanointeractiveBidAdapter_spec.js @@ -32,7 +32,7 @@ describe('nanointeractive adapter tests', function () { sizes: SIZES, bidId: '24a1c9ec270973', bidderRequestId: '189135372acd55', - requestId: 'ac15bb68-4ef0-477f-93f4-de91c47f00a9' + auctionId: 'ac15bb68-4ef0-477f-93f4-de91c47f00a9' } } diff --git a/test/spec/modules/quantcastBidAdapter_spec.js b/test/spec/modules/quantcastBidAdapter_spec.js index 14981f198b6..6fd5c3abdf9 100644 --- a/test/spec/modules/quantcastBidAdapter_spec.js +++ b/test/spec/modules/quantcastBidAdapter_spec.js @@ -17,7 +17,7 @@ describe('Quantcast adapter', () => { bidRequest = { bidder: 'quantcast', bidId: '2f7b179d443f14', - requestId: '595ffa73-d78a-46c9-b18e-f99548a5be6b', + auctionId: '595ffa73-d78a-46c9-b18e-f99548a5be6b', bidderRequestId: '1cc026909c24c8', placementCode: 'div-gpt-ad-1438287399331-0', params: { @@ -74,7 +74,7 @@ describe('Quantcast adapter', () => { const bidRequest = { bidder: 'quantcast', bidId: '2f7b179d443f14', - requestId: '595ffa73-d78a-46c9-b18e-f99548a5be6b', + auctionId: '595ffa73-d78a-46c9-b18e-f99548a5be6b', bidderRequestId: '1cc026909c24c8', placementCode: 'div-gpt-ad-1438287399331-0', params: { diff --git a/test/spec/modules/readpeakBidAdapter_spec.js b/test/spec/modules/readpeakBidAdapter_spec.js index 7356cd96a4e..18b52658c4b 100644 --- a/test/spec/modules/readpeakBidAdapter_spec.js +++ b/test/spec/modules/readpeakBidAdapter_spec.js @@ -21,10 +21,9 @@ describe('ReadPeakAdapter', () => { bidfloor: 5.00, publisherId: '11bc5dd5-7421-4dd8-c926-40fa653bec76' }, - auctionId: '1d1a030790a475', bidId: '2ffb201a808da7', bidderRequestId: '178e34bad3658f', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' } serverResponse = { diff --git a/test/spec/modules/rtbdemandBidAdapter_spec.js b/test/spec/modules/rtbdemandBidAdapter_spec.js index a00f1bf62da..20d3e410aee 100644 --- a/test/spec/modules/rtbdemandBidAdapter_spec.js +++ b/test/spec/modules/rtbdemandBidAdapter_spec.js @@ -52,7 +52,7 @@ describe('rtbdemandAdapter', () => { describe('buildRequests', () => { let bidderRequest = { bidderCode: 'rtbdemand', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', bidderRequestId: '178e34bad3658f', bids: [ { @@ -66,7 +66,7 @@ describe('rtbdemandAdapter', () => { sizes: [[300, 250], [320, 50]], bidId: '2ffb201a808da7', bidderRequestId: '178e34bad3658f', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' }, { @@ -80,7 +80,7 @@ describe('rtbdemandAdapter', () => { sizes: [[728, 90], [320, 50]], bidId: '2ffb201a808da7', bidderRequestId: '178e34bad3658f', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' } ], diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index 8c6a244eb3c..b02f01ecd93 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -57,7 +57,7 @@ describe('the rubicon adapter', () => { bidderRequest = { bidderCode: 'rubicon', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', bidderRequestId: '178e34bad3658f', bids: [ { @@ -83,7 +83,7 @@ describe('the rubicon adapter', () => { sizes: [[300, 250], [320, 50]], bidId: '2ffb201a808da7', bidderRequestId: '178e34bad3658f', - requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' } ], diff --git a/test/spec/modules/serverbidBidAdapter_spec.js b/test/spec/modules/serverbidBidAdapter_spec.js index eeb8a6c517c..fb31f925c6e 100644 --- a/test/spec/modules/serverbidBidAdapter_spec.js +++ b/test/spec/modules/serverbidBidAdapter_spec.js @@ -8,7 +8,7 @@ const SMARTSYNC_CALLBACK = 'serverbidCallBids'; const REQUEST = { 'bidderCode': 'serverbid', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d', + 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d', 'bidderRequestId': '109f2a181342a9', 'bidRequest': [{ 'bidder': 'serverbid', @@ -23,7 +23,7 @@ const REQUEST = { ], 'bidId': '2b0f82502298c9', 'bidderRequestId': '109f2a181342a9', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d' + 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d' }, { 'bidder': 'serverbid', @@ -38,7 +38,7 @@ const REQUEST = { ], 'bidId': '123', 'bidderRequestId': '109f2a181342a9', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d' + 'auctionId': 'a4713c32-3762-4798-b342-4ab810ca770d' }], 'start': 1487883186070, 'auctionStart': 1487883186069, @@ -115,7 +115,7 @@ describe('Serverbid BidAdapter', () => { placementCode: 'header-bid-tag-1', sizes: [[300, 250], [300, 600]], bidId: '23acc48ad47af5', - requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', bidderRequestId: '1c56ad30b9b8ca8', transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' } diff --git a/test/spec/modules/underdogmediaBidAdapter_spec.js b/test/spec/modules/underdogmediaBidAdapter_spec.js index 1e7a80aaff8..5dc2a65399f 100644 --- a/test/spec/modules/underdogmediaBidAdapter_spec.js +++ b/test/spec/modules/underdogmediaBidAdapter_spec.js @@ -14,7 +14,7 @@ describe('UnderdogMedia adapter', () => { adUnitCode: '/19968336/header-bid-tag-1', sizes: [[300, 250], [300, 600], [728, 90], [160, 600], [320, 50]], bidId: '23acc48ad47af5', - requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', bidderRequestId: '1c56ad30b9b8ca8', transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' } @@ -68,7 +68,7 @@ describe('UnderdogMedia adapter', () => { params: { siteId: '12143' }, - requestId: '10b327aa396609', + auctionId: '10b327aa396609', adUnitCode: '/123456/header-bid-tag-1' } ]; @@ -86,7 +86,7 @@ describe('UnderdogMedia adapter', () => { params: { siteId: '12143' }, - requestId: '10b327aa396609', + auctionId: '10b327aa396609', adUnitCode: '/123456/header-bid-tag-1' } ]; diff --git a/test/spec/modules/undertoneBidAdapter_spec.js b/test/spec/modules/undertoneBidAdapter_spec.js index dab9cea98bf..d86a1dc5735 100644 --- a/test/spec/modules/undertoneBidAdapter_spec.js +++ b/test/spec/modules/undertoneBidAdapter_spec.js @@ -11,8 +11,7 @@ const validBidReq = { }, sizes: [[300, 250], [300, 600]], bidId: '263be71e91dd9d', - requestId: '9ad1fa8d-2297-4660-a018-b39945054746', - auctionId: '1d1a030790a475' + auctionId: '9ad1fa8d-2297-4660-a018-b39945054746', }; const invalidBidReq = { @@ -22,7 +21,7 @@ const invalidBidReq = { }, sizes: [[300, 250], [300, 600]], bidId: '263be71e91dd9d', - requestId: '9ad1fa8d-2297-4660-a018-b39945054746' + auctionId: '9ad1fa8d-2297-4660-a018-b39945054746' }; const bidReq = [{ @@ -33,8 +32,7 @@ const bidReq = [{ }, sizes: [[300, 250], [300, 600]], bidId: '263be71e91dd9d', - requestId: '9ad1fa8d-2297-4660-a018-b39945054746', - auctionId: '1d1a030790a475' + auctionId: '9ad1fa8d-2297-4660-a018-b39945054746' }]; const validBidRes = { diff --git a/test/spec/unit/core/adapterManager_spec.js b/test/spec/unit/core/adapterManager_spec.js index 95a249263b5..1732716c6a4 100644 --- a/test/spec/unit/core/adapterManager_spec.js +++ b/test/spec/unit/core/adapterManager_spec.js @@ -45,7 +45,7 @@ describe('adapterManager tests', () => { it('should log an error if a bidder is used that does not exist', () => { let bidRequests = [{ 'bidderCode': 'appnexus', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'bidderRequestId': '2946b569352ef2', 'tid': '34566b569352ef2', 'bids': [ @@ -59,7 +59,7 @@ describe('adapterManager tests', () => { 'sizes': [[728, 90], [970, 70]], 'bidId': '392b5a6b05d648', 'bidderRequestId': '2946b569352ef2', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'startTime': 1462918897462, 'status': 1, 'transactionId': 'fsafsa' @@ -73,7 +73,7 @@ describe('adapterManager tests', () => { 'sizes': [[300, 250], [300, 600]], 'bidId': '4dccdc37746135', 'bidderRequestId': '2946b569352ef2', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'startTime': 1462918897463, 'status': 1, 'transactionId': 'fsafsa' @@ -122,7 +122,7 @@ describe('adapterManager tests', () => { it('invokes callBids on the S2S adapter', () => { let bidRequests = [{ 'bidderCode': 'appnexus', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'bidderRequestId': '2946b569352ef2', 'tid': '34566b569352ef2', 'src': 's2s', @@ -159,7 +159,7 @@ describe('adapterManager tests', () => { ], 'bidId': '68136e1c47023d', 'bidderRequestId': '55e24a66bed717', - 'requestId': '1ff753bd4ae5cb', + 'auctionId': '1ff753bd4ae5cb', 'startTime': 1463510220995, 'status': 1, 'bid_id': '378a8914450b334' @@ -197,7 +197,7 @@ describe('adapterManager tests', () => { ], 'bidId': '7e5d6af25ed188', 'bidderRequestId': '55e24a66bed717', - 'requestId': '1ff753bd4ae5cb', + 'auctionId': '1ff753bd4ae5cb', 'startTime': 1463510220996, 'bid_id': '387d9d9c32ca47c' } @@ -224,7 +224,7 @@ describe('adapterManager tests', () => { ], 'bidId': '392b5a6b05d648', 'bidderRequestId': '2946b569352ef2', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'startTime': 1462918897462, 'status': 1, 'transactionId': 'fsafsa' @@ -247,7 +247,7 @@ describe('adapterManager tests', () => { ], 'bidId': '4dccdc37746135', 'bidderRequestId': '2946b569352ef2', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'startTime': 1462918897463, 'status': 1, 'transactionId': 'fsafsa' @@ -285,7 +285,7 @@ describe('adapterManager tests', () => { let bidRequests = [{ 'bidderCode': 'appnexus', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'bidderRequestId': '2946b569352ef2', 'tid': '34566b569352ef2', 'src': 's2s', @@ -322,7 +322,7 @@ describe('adapterManager tests', () => { ], 'bidId': '68136e1c47023d', 'bidderRequestId': '55e24a66bed717', - 'requestId': '1ff753bd4ae5cb', + 'auctionId': '1ff753bd4ae5cb', 'startTime': 1463510220995, 'status': 1, 'bid_id': '378a8914450b334' @@ -360,7 +360,7 @@ describe('adapterManager tests', () => { ], 'bidId': '7e5d6af25ed188', 'bidderRequestId': '55e24a66bed717', - 'requestId': '1ff753bd4ae5cb', + 'auctionId': '1ff753bd4ae5cb', 'startTime': 1463510220996, 'bid_id': '387d9d9c32ca47c' } @@ -387,7 +387,7 @@ describe('adapterManager tests', () => { ], 'bidId': '392b5a6b05d648', 'bidderRequestId': '2946b569352ef2', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'startTime': 1462918897462, 'status': 1, 'transactionId': 'fsafsa' @@ -410,7 +410,7 @@ describe('adapterManager tests', () => { ], 'bidId': '4dccdc37746135', 'bidderRequestId': '2946b569352ef2', - 'requestId': '1863e370099523', + 'auctionId': '1863e370099523', 'startTime': 1462918897463, 'status': 1, 'transactionId': 'fsafsa' diff --git a/test/spec/unit/core/bidderFactory_spec.js b/test/spec/unit/core/bidderFactory_spec.js index 7358017474d..cac3aa85b77 100644 --- a/test/spec/unit/core/bidderFactory_spec.js +++ b/test/spec/unit/core/bidderFactory_spec.js @@ -11,7 +11,7 @@ const MOCK_BIDS_REQUEST = { bids: [ { bidId: 1, - requestId: 'first-bid-id', + auctionId: 'first-bid-id', adUnitCode: 'mock/placement', params: { param: 5 @@ -19,7 +19,7 @@ const MOCK_BIDS_REQUEST = { }, { bidId: 2, - requestId: 'second-bid-id', + auctionId: 'second-bid-id', adUnitCode: 'mock/placement2', params: { badParam: 6 @@ -609,7 +609,7 @@ describe('validate bid response: ', () => { let bidRequest = { bids: [{ bidId: 1, - requestId: 'first-bid-id', + auctionId: 'first-bid-id', adUnitCode: 'mock/placement', params: { param: 5 @@ -646,7 +646,7 @@ describe('validate bid response: ', () => { let bidRequest = { bids: [{ bidId: 1, - requestId: 'first-bid-id', + auctionId: 'first-bid-id', adUnitCode: 'mock/placement', params: { param: 5 @@ -682,7 +682,7 @@ describe('validate bid response: ', () => { let bidRequest = { bids: [{ bidId: 1, - requestId: 'first-bid-id', + auctionId: 'first-bid-id', adUnitCode: 'mock/placement', params: { param: 5 @@ -717,7 +717,7 @@ describe('validate bid response: ', () => { bids: [{ bidder: CODE, bidId: 1, - requestId: 'first-bid-id', + auctionId: 'first-bid-id', adUnitCode: 'mock/placement', params: { param: 5 diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index f0a4f0b8e9a..c1f7fe82252 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -1443,7 +1443,7 @@ describe('Unit: Prebid Module', function () { 'pbAg': '10.00', 'size': '300x250', 'alwaysUseBid': true, - 'requestId': 123456, + 'auctionId': 123456, 'adserverTargeting': { 'hb_bidder': 'appnexus', 'hb_adid': '233bcbee889d46d', From 778c49674616fa258dd93cb3f80bcd8415d7b66b Mon Sep 17 00:00:00 2001 From: rxRTB <34483140+prebidRxRTB@users.noreply.github.com> Date: Wed, 20 Dec 2017 00:48:07 +0300 Subject: [PATCH 11/20] [Add BidAdapter] rxrtb adapter for Perbid.js 1.0 (#1950) * Add: rxrtb prebidAdapter * Update: params for test * Update: code format * Update: code format * Update: code format --- modules/rxrtbBidAdapter.js | 140 ++++++++++++++++++++++ modules/rxrtbBidAdapter.md | 32 +++++ test/spec/modules/rxrtbBidAdapter_spec.js | 120 +++++++++++++++++++ 3 files changed, 292 insertions(+) create mode 100644 modules/rxrtbBidAdapter.js create mode 100644 modules/rxrtbBidAdapter.md create mode 100644 test/spec/modules/rxrtbBidAdapter_spec.js diff --git a/modules/rxrtbBidAdapter.js b/modules/rxrtbBidAdapter.js new file mode 100644 index 00000000000..cf03e41c208 --- /dev/null +++ b/modules/rxrtbBidAdapter.js @@ -0,0 +1,140 @@ +import * as utils from 'src/utils'; +import {BANNER} from 'src/mediaTypes'; +import {registerBidder} from 'src/adapters/bidderFactory'; +import {config} from 'src/config'; + +const BIDDER_CODE = 'rxrtb'; +const DEFAULT_HOST = 'bid.rxrtb.bid'; +const AUCTION_TYPE = 2; +const RESPONSE_TTL = 900; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + isBidRequestValid: function (bidRequest) { + return 'params' in bidRequest && bidRequest.params.source !== undefined && bidRequest.params.id !== undefined && Number.isInteger(bidRequest.params.id) && bidRequest.params.token !== undefined; + }, + buildRequests: function (validBidRequests) { + var requests = []; + for (let i = 0; i < validBidRequests.length; i++) { + let prebidReq = makePrebidRequest(validBidRequests[i]); + if (prebidReq) { + requests.push(prebidReq); + } + } + + return requests; + }, + interpretResponse: function (serverResponse, bidRequest) { + let rtbResp = serverResponse.body; + if ((!rtbResp) || (!rtbResp.seatbid)) { + return []; + } + let bidResponses = []; + for (let i = 0; i < rtbResp.seatbid.length; i++) { + let seatbid = rtbResp.seatbid[i]; + for (let j = 0; j < seatbid.bid.length; j++) { + let bid = seatbid.bid[j]; + let bidResponse = { + requestId: bid.impid, + cpm: bid.price, + width: bid.w, + height: bid.h, + mediaType: BANNER, + creativeId: bid.crid, + currency: rtbResp.cur || 'USD', + netRevenue: true, + ttl: bid.exp || RESPONSE_TTL, + ad: bid.adm + }; + bidResponses.push(bidResponse); + } + } + return bidResponses; + }, + getUserSyncs: function (syncOptions, serverResponses) { + return []; + } +} + +registerBidder(spec); + +function getDomain(url) { + var a = document.createElement('a'); + a.href = url; + + return a.host; +} + +function makePrebidRequest(req) { + let host = req.params.host || DEFAULT_HOST; + let url = window.location.protocol + '//' + host + '/dsp?id=' + req.params.id + '&token=' + req.params.token; + let reqData = makeRtbRequest(req); + return { + method: 'POST', + url: url, + data: JSON.stringify(reqData) + }; +} + +function makeRtbRequest(req) { + let imp = []; + imp.push(makeImp(req)); + return { + 'id': req.auctionId, + 'imp': imp, + 'site': makeSite(req), + 'device': makeDevice(), + 'hb': 1, + 'at': req.params.at || AUCTION_TYPE, + 'cur': ['USD'], + 'badv': req.params.badv || '', + 'bcat': req.params.bcat || '', + }; +} + +function makeImp(req) { + let imp = { + 'id': req.bidId, + 'tagid': req.adUnitCode, + 'banner': makeBanner(req) + }; + + if (req.params.bidfloor && Number.isInteger(req.params.bidfloor)) { + imp.bidfloor = req.params.bidfloor + } + + return imp; +} + +function makeBanner(req) { + let format = []; + let banner = {}; + for (let i = 0; i < req.sizes.length; i++) { + format.push({ + w: req.sizes[i][0], + h: req.sizes[i][1] + }); + } + banner.format = format; + if (req.params.pos && Number.isInteger(req.params.pos)) { + banner.pos = req.params.pos; + } + return banner; +} + +function makeSite(req) { + return { + 'id': req.params.source, + 'domain': getDomain(config.getConfig('publisherDomain')), + 'page': utils.getTopWindowUrl(), + 'ref': utils.getTopWindowReferrer() + }; +} + +function makeDevice() { + return { + 'ua': window.navigator.userAgent || '', + 'ip': 1 + }; +} diff --git a/modules/rxrtbBidAdapter.md b/modules/rxrtbBidAdapter.md new file mode 100644 index 00000000000..e9628bed0dc --- /dev/null +++ b/modules/rxrtbBidAdapter.md @@ -0,0 +1,32 @@ +# Overview + +Module Name: rxrtb Bidder Adapter + +Module Type: Bidder Adapter + +Maintainer: contact@picellaltd.com + + +# Description + +Module that connects to rxrtb's demand source + +# Test Parameters +```javascript + var adUnits = [ + { + code: 'test-ad', + sizes: [[728, 98]], + bids: [ + { + bidder: 'rxrtb', + params: { + id: 89, + token: '658f11a5efbbce2f9be3f1f146fcbc22', + source: 'prebidtest' + } + } + ] + }, + ]; +``` \ No newline at end of file diff --git a/test/spec/modules/rxrtbBidAdapter_spec.js b/test/spec/modules/rxrtbBidAdapter_spec.js new file mode 100644 index 00000000000..0785c6f144b --- /dev/null +++ b/test/spec/modules/rxrtbBidAdapter_spec.js @@ -0,0 +1,120 @@ +import {expect} from 'chai'; +import {spec} from 'modules/rxrtbBidAdapter'; + +describe('rxrtb adapater', () => { + describe('Test validate req', () => { + it('should accept minimum valid bid', () => { + let bid = { + bidder: 'rxrtb', + params: { + id: 89, + token: '658f11a5efbbce2f9be3f1f146fcbc22', + source: 'prebidtest' + } + }; + const isValid = spec.isBidRequestValid(bid); + + expect(isValid).to.equal(true); + }); + + it('should reject missing id', () => { + let bid = { + bidder: 'rxrtb', + params: { + token: '658f11a5efbbce2f9be3f1f146fcbc22', + source: 'prebidtest' + } + }; + const isValid = spec.isBidRequestValid(bid); + + expect(isValid).to.equal(false); + }); + + it('should reject id not Integer', () => { + let bid = { + bidder: 'rxrtb', + params: { + id: '123', + token: '658f11a5efbbce2f9be3f1f146fcbc22', + source: 'prebidtest' + } + }; + const isValid = spec.isBidRequestValid(bid); + + expect(isValid).to.equal(false); + }); + + it('should reject missing source', () => { + let bid = { + bidder: 'rxrtb', + params: { + id: 89, + token: '658f11a5efbbce2f9be3f1f146fcbc22' + } + }; + const isValid = spec.isBidRequestValid(bid); + + expect(isValid).to.equal(false); + }); + }); + + describe('Test build request', () => { + it('minimum request', () => { + let bid = { + bidder: 'rxrtb', + sizes: [[728, 90]], + bidId: '4d0a6829338a07', + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '20882439e3238c', + params: { + id: 89, + token: '658f11a5efbbce2f9be3f1f146fcbc22', + source: 'prebidtest' + }, + }; + const req = JSON.parse(spec.buildRequests([bid])[0].data); + + expect(req).to.have.property('id'); + expect(req).to.have.property('imp'); + expect(req).to.have.property('device'); + expect(req).to.have.property('site'); + expect(req).to.have.property('hb'); + expect(req.imp[0]).to.have.property('id'); + expect(req.imp[0]).to.have.property('banner'); + expect(req.device).to.have.property('ip'); + expect(req.device).to.have.property('ua'); + expect(req.site).to.have.property('id'); + expect(req.site).to.have.property('domain'); + }); + }); + + describe('Test interpret response', () => { + it('General banner response', () => { + let resp = spec.interpretResponse({ + body: { + id: 'abcd', + seatbid: [{ + bid: [{ + id: 'abcd', + impid: 'banner-bid', + price: 0.3, + w: 728, + h: 98, + adm: 'hello', + crid: 'efgh', + exp: 5 + }] + }] + } + }, null)[0]; + + expect(resp).to.have.property('requestId', 'banner-bid'); + expect(resp).to.have.property('cpm', 0.3); + expect(resp).to.have.property('width', 728); + expect(resp).to.have.property('height', 98); + expect(resp).to.have.property('creativeId', 'efgh'); + expect(resp).to.have.property('ttl', 5); + expect(resp).to.have.property('ad', 'hello'); + }); + }); +}); From 68e08b1999b3b6ec06ce6d44f9ec18e85a59f0d1 Mon Sep 17 00:00:00 2001 From: Jarrod Swart Date: Tue, 19 Dec 2017 16:50:53 -0500 Subject: [PATCH 12/20] ServerBid Server BidAdapter (#1819) * ServerBid Server BidAdapter Allow S2S configuration with ServerBid. * Updates to meet 1.0 callBids/config changes. * Fix linting issues. --- modules/serverbidServerBidAdapter.js | 236 ++++++++++++++ .../modules/serverbidServerBidAdapter_spec.js | 299 ++++++++++++++++++ 2 files changed, 535 insertions(+) create mode 100644 modules/serverbidServerBidAdapter.js create mode 100644 test/spec/modules/serverbidServerBidAdapter_spec.js diff --git a/modules/serverbidServerBidAdapter.js b/modules/serverbidServerBidAdapter.js new file mode 100644 index 00000000000..47d4e518222 --- /dev/null +++ b/modules/serverbidServerBidAdapter.js @@ -0,0 +1,236 @@ +import Adapter from 'src/adapter'; +import bidfactory from 'src/bidfactory'; +import * as utils from 'src/utils'; +import adaptermanager from 'src/adaptermanager'; +import { STATUS, S2S } from 'src/constants'; +import { config } from 'src/config'; + +const TYPE = S2S.SRC; +const getConfig = config.getConfig; +const REQUIRED_S2S_CONFIG_KEYS = ['siteId', 'networkId', 'bidders', 'endpoint']; + +let _s2sConfig; +config.setDefaults({ + 's2sConfig': { + enabled: false, + timeout: 1000, + adapter: 'serverbidServer' + } +}); + +var ServerBidServerAdapter; +ServerBidServerAdapter = function ServerBidServerAdapter() { + const baseAdapter = new Adapter('serverbidServer'); + + const BASE_URI = 'https://e.serverbid.com/api/v2'; + + const sizeMap = [ + null, + '120x90', + '120x90', + '468x60', + '728x90', + '300x250', + '160x600', + '120x600', + '300x100', + '180x150', + '336x280', + '240x400', + '234x60', + '88x31', + '120x60', + '120x240', + '125x125', + '220x250', + '250x250', + '250x90', + '0x0', + '200x90', + '300x50', + '320x50', + '320x480', + '185x185', + '620x45', + '300x125', + '800x250' + ]; + + sizeMap[77] = '970x90'; + sizeMap[123] = '970x250'; + sizeMap[43] = '300x600'; + + function setS2sConfig(options) { + let contains = (xs, x) => xs.indexOf(x) > -1; + let userConfig = Object.keys(options); + + REQUIRED_S2S_CONFIG_KEYS.forEach(key => { + if (!contains(userConfig, key)) { + utils.logError(key + ' missing in server to server config'); + return void 0; // void 0 to beat the linter + } + }) + + _s2sConfig = options; + } + getConfig('s2sConfig', ({s2sConfig}) => setS2sConfig(s2sConfig)); + + function getLocalConfig() { + return (_s2sConfig || {}); + } + + function _convertFields(bid) { + let safeBid = bid || {}; + let converted = {}; + let name = safeBid.bidder; + converted[name] = safeBid.params; + return converted; + } + + baseAdapter.callBids = function(s2sBidRequest, bidRequests, addBidResponse, done, ajax) { + let params = s2sBidRequest; + let shouldDoWorkFn = function(bidRequest) { + return bidRequest && + bidRequest.ad_units && + utils.isArray(bidRequest.ad_units) && + bidRequest.ad_units.length; + } + if (shouldDoWorkFn(params)) { + _callBids(s2sBidRequest, bidRequests, addBidResponse, done, ajax); + } + }; + + function _callBids(s2sBidRequest, bidRequests, addBidResponse, done, ajax) { + let bidRequest = s2sBidRequest; + + // one request per ad unit + for (let i = 0; i < bidRequest.ad_units.length; i++) { + let adunit = bidRequest.ad_units[i]; + let siteId = _s2sConfig.siteId; + let networkId = getLocalConfig().networkId; + let sizes = adunit.sizes; + + const data = { + placements: [], + time: Date.now(), + user: {}, + url: utils.getTopWindowUrl(), + referrer: document.referrer, + enableBotFiltering: true, + includePricingData: true, + parallel: true + }; + + const bids = adunit.bids || []; + + // one placement for each of the bids + for (let i = 0; i < bids.length; i++) { + const bid = bids[i]; + bid.code = adunit.code; + + const placement = Object.assign({}, { + divName: bid.bid_id, + networkId: networkId, + siteId: siteId, + adTypes: bid.adTypes || getSize(sizes), + bidders: _convertFields(bid), + skipSelection: true + }); + + if (placement.networkId && placement.siteId) { + data.placements.push(placement); + } + } + if (data.placements.length) { + ajax(BASE_URI, _responseCallback(addBidResponse, bids), JSON.stringify(data), { method: 'POST', withCredentials: true, contentType: 'application/json' }); + } + } + } + + function _responseCallback(addBidResponse, bids) { + return function (resp) { + let bid; + let bidId; + let result; + let bidObj; + let bidCode; + let placementCode; + let skipSelectionRequestsReturnArray = function (decision) { + return (decision || []).length ? decision[0] : {}; + }; + + try { + result = JSON.parse(resp); + } catch (error) { + utils.logError(error); + } + + for (let i = 0; i < bids.length; i++) { + bidObj = bids[i]; + bidId = bidObj.bid_id; + bidObj.bidId = bidObj.bid_id; + bidCode = bidObj.bidder; + placementCode = bidObj.code; + let noBid = function(bidObj) { + bid = bidfactory.createBid(STATUS.NO_BID, bidObj); + bid.bidderCode = bidCode; + return bid; + }; + + if (result) { + const decision = result.decisions && skipSelectionRequestsReturnArray(result.decisions[bidId]); + const price = decision && decision.pricing && decision.pricing.clearPrice; + + if (decision && price) { + bid = bidfactory.createBid(STATUS.GOOD, bidObj); + bid = Object.assign(bid, {bidderCode: bidCode, + cpm: price, + width: decision.width, + height: decision.height, + ad: retrieveAd(decision)}) + } else { + bid = noBid(bidObj); + } + } else { + bid = noBid(bidObj); + } + addBidResponse(placementCode, bid); + } + done() + } + }; + + function retrieveAd(decision) { + return decision.contents && decision.contents[0] && decision.contents[0].body + utils.createTrackPixelHtml(decision.impressionUrl); + } + + function getSize(sizes) { + let width = 'w'; + let height = 'h'; + const result = []; + sizes.forEach(function(size) { + const index = sizeMap.indexOf(size[width] + 'x' + size[height]); + if (index >= 0) { + result.push(index); + } + }); + return result; + } + + // Export the `callBids` function, so that Prebid.js can execute + // this function when the page asks to send out bid requests. + return Object.assign(this, { + queueSync: baseAdapter.queueSync, + callBids: baseAdapter.callBids, + setBidderCode: baseAdapter.setBidderCode, + type: TYPE + }); +}; + +ServerBidServerAdapter.createNew = function() { + return new ServerBidServerAdapter(); +}; + +adaptermanager.registerBidAdapter(new ServerBidServerAdapter(), 'serverbidServer'); + +module.exports = ServerBidServerAdapter; diff --git a/test/spec/modules/serverbidServerBidAdapter_spec.js b/test/spec/modules/serverbidServerBidAdapter_spec.js new file mode 100644 index 00000000000..7745d0e407c --- /dev/null +++ b/test/spec/modules/serverbidServerBidAdapter_spec.js @@ -0,0 +1,299 @@ +import { expect } from 'chai'; +import Adapter from 'modules/serverbidServerBidAdapter'; +import * as utils from 'src/utils'; +import { config } from 'src/config'; +import { ajax } from 'src/ajax'; + +const ENDPOINT = 'https://e.serverbid.com/api/v2'; + +let CONFIG = { + enabled: true, + bidders: ['appnexus'], + timeout: 1000, + adapter: 'serverbidServer', + networkId: 9969, + siteId: 730181, + endpoint: ENDPOINT +}; + +let CONFIG_ARG = { + s2sConfig: CONFIG +} + +const REQUEST = { + 'account_id': '1', + 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', + 'max_bids': 1, + 'timeout_millis': 1000, + 'url': '', + 'prebid_version': '0.21.0-pre', + 'ad_units': [ + { + 'code': 'div-gpt-ad-1460505748561-0', + 'sizes': [ + { + 'w': 300, + 'h': 250 + }, + { + 'w': 300, + 'h': 600 + } + ], + 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', + 'bids': [ + { + 'bid_id': '123', + 'bidder': 'appnexus', + 'params': { + 'placementId': '10433394', + 'member': 123 + } + } + ] + } + ] +}; + +const BID_REQUESTS = [ + { + 'bidderCode': 'appnexus', + 'auctionId': '173afb6d132ba3', + 'bidderRequestId': '3d1063078dfcc8', + 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': '10433394', + 'member': 123 + }, + 'bid_id': '123', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', + 'sizes': [ + { + 'w': 300, + 'h': 250 + } + ], + 'bidId': '259fb43aaa06c1', + 'bidderRequestId': '3d1063078dfcc8', + 'auctionId': '173afb6d132ba3' + } + ], + 'auctionStart': 1510852447530, + 'timeout': 5000, + 'src': 's2s', + 'doneCbCallCount': 0 + } +]; + +const RESPONSE = { + 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, + 'decisions': { + '123': [{ + 'adId': 2364764, + 'creativeId': 1950991, + 'flightId': 2788300, + 'campaignId': 542982, + 'clickUrl': 'https://e.serverbid.com/r', + 'impressionUrl': 'https://e.serverbid.com/i.gif', + 'contents': [{ + 'type': 'html', + 'body': '', + 'data': { + 'height': 300, + 'width': 250, + 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', + 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' + }, + 'template': 'image' + }], + 'height': 250, + 'width': 300, + 'events': [], + 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} + }], + } +}; + +const RESPONSE_NO_BID_NO_UNIT = { + 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, + 'decisions': { + '123': [] + } +}; + +const REQUEST_TWO_UNITS = { + 'account_id': '1', + 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', + 'max_bids': 1, + 'timeout_millis': 1000, + 'url': '', + 'prebid_version': '0.21.0-pre', + 'ad_units': [ + { + 'code': 'div-gpt-ad-1460505748561-0', + 'sizes': [ + { + 'w': 300, + 'h': 250 + }, + { + 'w': 300, + 'h': 600 + } + ], + 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786ab86c', + 'bids': [ + { + 'bid_id': '123', + 'bidder': 'appnexus', + 'params': { + 'placementId': '10433394', + 'member': 123 + } + } + ] + }, + { + 'code': 'div-gpt-ad-1460505748561-1', + 'sizes': [ + { + 'w': 300, + 'h': 250 + }, + { + 'w': 300, + 'h': 600 + } + ], + 'transactionId': '4ef956ad-fd83-406d-bd35-e4bb786bb86d', + 'bids': [ + { + 'bid_id': '101111', + 'bidder': 'appnexus', + 'params': { + 'placementId': '10433394', + 'member': 123 + } + } + ] + } + ] +}; + +describe('ServerBid S2S Adapter', () => { + let adapter, + addBidResponse = sinon.spy(), + done = sinon.spy(); + + beforeEach(() => adapter = new Adapter()); + + afterEach(() => { + addBidResponse.reset(); + done.reset(); + }); + + describe('request function', () => { + let xhr; + let requests; + + beforeEach(() => { + xhr = sinon.useFakeXMLHttpRequest(); + requests = []; + xhr.onCreate = request => requests.push(request); + }); + + afterEach(() => xhr.restore()); + + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('response handler', () => { + let server; + + beforeEach(() => { + server = sinon.fakeServer.create(); + sinon.stub(utils, 'getBidRequest').returns({ + bidId: '123' + }); + }); + + afterEach(() => { + server.restore(); + utils.getBidRequest.restore(); + }); + + it('registers bids', () => { + server.respondWith(JSON.stringify(RESPONSE)); + + config.setConfig(CONFIG_ARG); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.respond(); + sinon.assert.calledOnce(addBidResponse); + + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('statusMessage', 'Bid available'); + expect(response).to.have.property('cpm', 0.5); + expect(response).to.have.property('adId', '123'); + }); + + it('registers no-bid response when ad unit not set', () => { + server.respondWith(JSON.stringify(RESPONSE_NO_BID_NO_UNIT)); + + config.setConfig(CONFIG_ARG); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.respond(); + sinon.assert.calledOnce(addBidResponse); + + const ad_unit_code = addBidResponse.firstCall.args[0]; + expect(ad_unit_code).to.equal('div-gpt-ad-1460505748561-0'); + + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('statusMessage', 'Bid returned empty or error response'); + + const bid_request_passed = addBidResponse.firstCall.args[1]; + expect(bid_request_passed).to.have.property('adId', '123'); + }); + + it('registers no-bid response when ad unit is set', () => { + server.respondWith(JSON.stringify(RESPONSE_NO_BID_NO_UNIT)); + + config.setConfig(CONFIG_ARG); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.respond(); + sinon.assert.calledOnce(addBidResponse); + + const ad_unit_code = addBidResponse.firstCall.args[0]; + expect(ad_unit_code).to.equal('div-gpt-ad-1460505748561-0'); + + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('statusMessage', 'Bid returned empty or error response'); + }); + + it('registers no-bid response when there are less bids than requests', () => { + server.respondWith(JSON.stringify(RESPONSE)); + + config.setConfig(CONFIG_ARG); + adapter.callBids(REQUEST_TWO_UNITS, BID_REQUESTS, addBidResponse, done, ajax); + server.respond(); + + sinon.assert.calledTwice(addBidResponse); + + expect(addBidResponse.firstCall.args[0]).to.equal('div-gpt-ad-1460505748561-0'); + expect(addBidResponse.secondCall.args[0]).to.equal('div-gpt-ad-1460505748561-1'); + + expect(addBidResponse.firstCall.args[1]).to.have.property('adId', '123'); + expect(addBidResponse.secondCall.args[1]).to.have.property('adId', '101111'); + + expect(addBidResponse.firstCall.args[1]) + .to.have.property('statusMessage', 'Bid available'); + expect(addBidResponse.secondCall.args[1]) + .to.have.property('statusMessage', 'Bid returned empty or error response'); + }); + }); +}); From b7d5da33a7cc8162468df77e301dbfb2380a777c Mon Sep 17 00:00:00 2001 From: Matt Kendall Date: Tue, 19 Dec 2017 17:12:05 -0500 Subject: [PATCH 13/20] added hb_source to default keys (#1969) * added hb_source * dropped function to add hb_source since it is now default key * fixed lint error --- modules/s2sTesting.js | 36 -------- src/auction.js | 6 ++ src/bidfactory.js | 2 + src/constants.json | 3 +- test/spec/auctionmanager_spec.js | 23 +++-- test/spec/modules/s2sTesting_spec.js | 127 --------------------------- 6 files changed, 28 insertions(+), 169 deletions(-) diff --git a/modules/s2sTesting.js b/modules/s2sTesting.js index a821383dc2d..60ab150530f 100644 --- a/modules/s2sTesting.js +++ b/modules/s2sTesting.js @@ -1,8 +1,6 @@ import { config } from 'src/config'; import { setS2STestingModule } from 'src/adaptermanager'; -var CONSTANTS = require('src/constants.json'); -const AST = CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING; export const SERVER = 'server'; export const CLIENT = 'client'; @@ -12,43 +10,9 @@ var bidSource = {}; // store bidder sources determined from s2sConfing bidderCon // load s2sConfig config.getConfig('s2sConfig', config => { testing = config.s2sConfig && config.s2sConfig.testing; - addBidderSourceTargeting(config.s2sConfig) calculateBidSources(config.s2sConfig); }); -// function to add hb_source_ adServerTargeting (AST) kvp to bidder settings -function addBidderSourceTargeting(s2sConfig = {}) { - // bail if testing is not turned on - if (!testing) { - return; - } - var bidderSettings = $$PREBID_GLOBAL$$.bidderSettings || {}; - var bidderControl = s2sConfig.bidderControl || {}; - // for each configured bidder - (s2sConfig.bidders || []).forEach((bidder) => { - // remove any existing kvp setting - if (bidderSettings[bidder] && bidderSettings[bidder][AST]) { - bidderSettings[bidder][AST] = bidderSettings[bidder][AST].filter((kvp) => { - return kvp.key !== `hb_source_${bidder}`; - }); - } - // if includeSourceKvp === true add new kvp setting - if (bidderControl[bidder] && bidderControl[bidder].includeSourceKvp) { - bidderSettings[bidder] = bidderSettings[bidder] || {}; - bidderSettings[bidder][AST] = bidderSettings[bidder][AST] || []; - bidderSettings[bidder][AST].push({ - key: `hb_source_${bidder}`, - val: function (bidResponse) { - // default to client (currently only S2S sets this) - return bidResponse.source || CLIENT; - } - }); - // make sure "alwaysUseBid" is true so targeting is set - bidderSettings[bidder].alwaysUseBid = true; - } - }); -} - export function getSourceBidderMap(adUnits = []) { var sourceBidders = {[SERVER]: {}, [CLIENT]: {}}; diff --git a/src/auction.js b/src/auction.js index 45d06c23f59..7c6a752c057 100644 --- a/src/auction.js +++ b/src/auction.js @@ -361,6 +361,12 @@ export function getStandardBidderSettings() { val: function (bidResponse) { return bidResponse.dealId; } + }, + { + key: 'hb_source', + val: function (bidResponse) { + return bidResponse.source; + } } ] } diff --git a/src/bidfactory.js b/src/bidfactory.js index ff57abb8a39..6250969d6df 100644 --- a/src/bidfactory.js +++ b/src/bidfactory.js @@ -16,6 +16,7 @@ var utils = require('./utils.js'); */ function Bid(statusCode, bidRequest) { var _bidId = (bidRequest && bidRequest.bidId) || utils.getUniqueIdentifierStr(); + var _bidSrc = (bidRequest && bidRequest.src) || 'client'; var _statusCode = statusCode || 0; this.bidderCode = (bidRequest && bidRequest.bidder) || ''; @@ -24,6 +25,7 @@ function Bid(statusCode, bidRequest) { this.statusMessage = _getStatus(); this.adId = _bidId; this.mediaType = 'banner'; + this.source = _bidSrc; function _getStatus() { switch (_statusCode) { diff --git a/src/constants.json b/src/constants.json index 3e20d462ac7..e80c118ea83 100644 --- a/src/constants.json +++ b/src/constants.json @@ -51,7 +51,8 @@ "hb_adid", "hb_pb", "hb_size", - "hb_deal" + "hb_deal", + "hb_source" ], "S2S" : { "SRC" : "s2s", diff --git a/test/spec/auctionmanager_spec.js b/test/spec/auctionmanager_spec.js index c773974d177..688afc35d9d 100644 --- a/test/spec/auctionmanager_spec.js +++ b/test/spec/auctionmanager_spec.js @@ -34,6 +34,7 @@ describe('auctionmanager.js', function () { var bidderCode = 'appnexus'; var size = '300x250'; var adId = '1adId'; + var source = 'client'; before(function () { bid.cpm = bidPriceCpm; @@ -50,6 +51,7 @@ describe('auctionmanager.js', function () { }; bid.bidderCode = bidderCode; bid.adId = adId; + bid.source = source; }); it('No bidder level configuration defined - default', function () { @@ -57,7 +59,8 @@ describe('auctionmanager.js', function () { 'hb_bidder': bidderCode, 'hb_adid': adId, 'hb_pb': bidPbMg, - 'hb_size': size + 'hb_size': size, + 'hb_source': source }; var response = getKeyValueTargetingPairs(bidderCode, bid, CONSTANTS.GRANULARITY_OPTIONS.MEDIUM); assert.deepEqual(response, expected); @@ -89,6 +92,12 @@ describe('auctionmanager.js', function () { val: function (bidResponse) { return bidResponse.size; } + }, + { + key: 'hb_source', + val: function (bidResponse) { + return bidResponse.source; + } } ] @@ -99,7 +108,8 @@ describe('auctionmanager.js', function () { 'hb_bidder': bidderCode, 'hb_adid': adId, 'hb_pb': bidPbHg, - 'hb_size': size + 'hb_size': size, + 'hb_source': source }; var response = getKeyValueTargetingPairs(bidderCode, bid, CONSTANTS.GRANULARITY_OPTIONS.MEDIUM); assert.deepEqual(response, expected); @@ -141,7 +151,8 @@ describe('auctionmanager.js', function () { 'hb_bidder': bidderCode, 'hb_adid': adId, 'hb_pb': bidPbHg, - 'hb_size': size + 'hb_size': size, + 'hb_source': source }; var response = getKeyValueTargetingPairs(bidderCode, bid); assert.deepEqual(response, expected); @@ -183,7 +194,8 @@ describe('auctionmanager.js', function () { 'hb_bidder': bidderCode, 'hb_adid': adId, 'hb_pb': bidPbMg, - 'hb_size': size + 'hb_size': size, + 'hb_source': source }; var response = getKeyValueTargetingPairs(bidderCode, bid, CONSTANTS.GRANULARITY_OPTIONS.MEDIUM); assert.deepEqual(response, expected); @@ -347,7 +359,8 @@ describe('auctionmanager.js', function () { 'hb_bidder': bidderCode, 'hb_adid': adId, 'hb_pb': 5.57, - 'hb_size': '300x250' + 'hb_size': '300x250', + 'hb_source': source }; var response = getKeyValueTargetingPairs(bidderCode, bid); assert.deepEqual(response, expected); diff --git a/test/spec/modules/s2sTesting_spec.js b/test/spec/modules/s2sTesting_spec.js index 26d5eb8884b..845947a0b38 100644 --- a/test/spec/modules/s2sTesting_spec.js +++ b/test/spec/modules/s2sTesting_spec.js @@ -308,131 +308,4 @@ describe('s2sTesting', function () { }); }); }); - - describe('addBidderSourceTargeting', () => { - const AST = CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING; - - function checkTargeting(bidder) { - var targeting = window.$$PREBID_GLOBAL$$.bidderSettings[bidder][AST]; - var srcTargeting = targeting[targeting.length - 1]; - expect(srcTargeting.key).to.equal(`hb_source_${bidder}`); - expect(srcTargeting.val).to.be.a('function'); - expect(window.$$PREBID_GLOBAL$$.bidderSettings[bidder].alwaysUseBid).to.be.true; - } - - function checkNoTargeting(bidder) { - var bs = window.$$PREBID_GLOBAL$$.bidderSettings; - var targeting = bs[bidder] && bs[bidder][AST]; - if (!targeting) { - expect(targeting).to.be.undefined; - return; - } - expect(find(targeting, (kvp) => { - return kvp.key === `hb_source_${bidder}`; - })).to.be.undefined; - } - - function checkTargetingVal(bidResponse, expectedVal) { - var targeting = window.$$PREBID_GLOBAL$$.bidderSettings[bidResponse.bidderCode][AST]; - var targetingFunc = targeting[targeting.length - 1].val; - expect(targetingFunc(bidResponse)).to.equal(expectedVal); - } - - beforeEach(() => { - // set bidderSettings - window.$$PREBID_GLOBAL$$.bidderSettings = {}; - }); - - it('should not set hb_source_ unless testing is on and includeSourceKvp is set', () => { - config.setConfig({s2sConfig: {bidders: ['rubicon', 'appnexus']}}); - expect(window.$$PREBID_GLOBAL$$.bidderSettings).to.eql({}); - - config.setConfig({s2sConfig: {bidders: ['rubicon', 'appnexus'], testing: true}}); - expect(window.$$PREBID_GLOBAL$$.bidderSettings).to.eql({}); - - config.setConfig({s2sConfig: { - bidders: ['rubicon', 'appnexus'], - testing: true, - bidderControl: { - rubicon: {bidSource: {server: 2, client: 1}}, - appnexus: {bidSource: {server: 1}} - } - }}); - expect(window.$$PREBID_GLOBAL$$.bidderSettings).to.eql({}); - - config.setConfig({s2sConfig: { - bidders: ['rubicon', 'appnexus'], - testing: false, - bidderControl: { - rubicon: {includeSourceKvp: true}, - appnexus: {includeSourceKvp: true} - } - }}); - expect(window.$$PREBID_GLOBAL$$.bidderSettings).to.eql({}); - }); - - it('should set hb_source_ if includeSourceKvp is set', () => { - config.setConfig({s2sConfig: { - bidders: ['rubicon', 'appnexus'], - testing: true, - bidderControl: { - rubicon: {includeSourceKvp: true}, - appnexus: {includeSourceKvp: true} - } - }}); - checkTargeting('rubicon'); - checkTargeting('appnexus'); - checkTargetingVal({bidderCode: 'rubicon', source: 'server'}, 'server'); - checkTargetingVal({bidderCode: 'appnexus', source: 'client'}, 'client'); - - // turn off appnexus - config.setConfig({s2sConfig: { - bidders: ['rubicon', 'appnexus'], - testing: true, - bidderControl: { - rubicon: {includeSourceKvp: true}, - appnexus: {includeSourceKvp: false} - } - }}); - checkTargeting('rubicon'); - checkNoTargeting('appnexus'); - checkTargetingVal({bidderCode: 'rubicon', source: 'client'}, 'client'); - - // should default to "client" - config.setConfig({s2sConfig: { - bidders: ['rubicon', 'appnexus'], - testing: true, - bidderControl: { - rubicon: {includeSourceKvp: true}, - appnexus: {includeSourceKvp: true} - } - }}); - checkTargeting('rubicon'); - checkTargeting('appnexus'); - checkTargetingVal({bidderCode: 'rubicon'}, 'client'); - checkTargetingVal({bidderCode: 'appnexus'}, 'client'); - }); - - it('should reset adServerTargeting when a new config is set', () => { - // set config with targeting - config.setConfig({s2sConfig: { - bidders: ['rubicon', 'appnexus'], - testing: true, - bidderControl: { - rubicon: {includeSourceKvp: true}, - appnexus: {includeSourceKvp: true} - } - }}); - checkTargeting('rubicon'); - checkTargeting('appnexus'); - - // set config without targeting - config.setConfig({s2sConfig: { - bidders: ['rubicon', 'appnexus'], - testing: true - }}); - checkNoTargeting('rubicon'); - checkNoTargeting('appnexus'); - }); - }); }); From 46cdaa1df297b389967334927334e4808bacce2c Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Tue, 19 Dec 2017 16:20:11 -0800 Subject: [PATCH 14/20] Prebid 1.1.0 Release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 61c9edf2b82..80a44979db6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "1.0.0", + "version": "1.1.0", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From 61f0414cfa3a3b62a01e7fa691c0c2422d1f163e Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Tue, 19 Dec 2017 16:30:23 -0800 Subject: [PATCH 15/20] Increment pre version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 80a44979db6..9d6af175e0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "1.1.0", + "version": "1.2.0-pre", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From d784396245794ca853c244be871dfd71d0dbd22a Mon Sep 17 00:00:00 2001 From: Jaimin Panchal Date: Wed, 20 Dec 2017 11:08:16 -0500 Subject: [PATCH 16/20] S2s defaults fix in serverbidServerBidAdapter (#1986) * removed s2s defaults * start timestamp was missing on s2s requests --- modules/serverbidServerBidAdapter.js | 13 +++++-------- src/adaptermanager.js | 5 +++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/serverbidServerBidAdapter.js b/modules/serverbidServerBidAdapter.js index 47d4e518222..4ff8992772f 100644 --- a/modules/serverbidServerBidAdapter.js +++ b/modules/serverbidServerBidAdapter.js @@ -10,13 +10,8 @@ const getConfig = config.getConfig; const REQUIRED_S2S_CONFIG_KEYS = ['siteId', 'networkId', 'bidders', 'endpoint']; let _s2sConfig; -config.setDefaults({ - 's2sConfig': { - enabled: false, - timeout: 1000, - adapter: 'serverbidServer' - } -}); + +const bidder = 'serverbidServer'; var ServerBidServerAdapter; ServerBidServerAdapter = function ServerBidServerAdapter() { @@ -61,6 +56,8 @@ ServerBidServerAdapter = function ServerBidServerAdapter() { sizeMap[43] = '300x600'; function setS2sConfig(options) { + if (options.adapter != bidder) return; + let contains = (xs, x) => xs.indexOf(x) > -1; let userConfig = Object.keys(options); @@ -231,6 +228,6 @@ ServerBidServerAdapter.createNew = function() { return new ServerBidServerAdapter(); }; -adaptermanager.registerBidAdapter(new ServerBidServerAdapter(), 'serverbidServer'); +adaptermanager.registerBidAdapter(new ServerBidServerAdapter(), bidder); module.exports = ServerBidServerAdapter; diff --git a/src/adaptermanager.js b/src/adaptermanager.js index 670b329ef72..c8dc72e7ddc 100644 --- a/src/adaptermanager.js +++ b/src/adaptermanager.js @@ -1,6 +1,6 @@ /** @module adaptermanger */ -import { flatten, getBidderCodes, getDefinedParams, shuffle } from './utils'; +import { flatten, getBidderCodes, getDefinedParams, shuffle, timestamp } from './utils'; import { resolveStatus } from './sizeMapping'; import { processNativeAdUnitParams, nativeAdapters } from './native'; import { newBidder } from './adapters/bidderFactory'; @@ -234,6 +234,7 @@ exports.callBids = (adUnits, bidRequests, addBidResponse, doneCb) => { let s2sBidRequest = {tid, 'ad_units': adUnitsS2SCopy}; if (s2sBidRequest.ad_units.length) { let doneCbs = serverBidRequests.map(bidRequest => { + bidRequest.start = timestamp(); bidRequest.doneCbCallCount = 0; return doneCb(bidRequest.bidderRequestId) }); @@ -265,7 +266,7 @@ exports.callBids = (adUnits, bidRequests, addBidResponse, doneCb) => { // handle client adapter requests clientBidRequests.forEach(bidRequest => { - bidRequest.start = new Date().getTime(); + bidRequest.start = timestamp(); // TODO : Do we check for bid in pool from here and skip calling adapter again ? const adapter = _bidderRegistry[bidRequest.bidderCode]; if (adapter) { From 94cce25fed9000e9a747129d709935a1a9da4a8f Mon Sep 17 00:00:00 2001 From: Rich Snapp Date: Wed, 20 Dec 2017 11:38:51 -0700 Subject: [PATCH 17/20] remove hardcoded localhost port for tests (#1988) --- test/spec/modules/nanointeractiveBidAdapter_spec.js | 8 +++++++- test/spec/modules/readpeakBidAdapter_spec.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/nanointeractiveBidAdapter_spec.js b/test/spec/modules/nanointeractiveBidAdapter_spec.js index 01aa60351e8..4b498c88982 100644 --- a/test/spec/modules/nanointeractiveBidAdapter_spec.js +++ b/test/spec/modules/nanointeractiveBidAdapter_spec.js @@ -1,4 +1,6 @@ import { expect } from 'chai'; +import * as utils from 'src/utils'; + import { ALG, BIDDER_CODE, CATEGORY, DATA_PARTNER_ID, DATA_PARTNER_PIXEL_ID, ENGINE_BASE_URL, NQ, NQ_NAME, SECURITY, @@ -44,7 +46,7 @@ describe('nanointeractive adapter tests', function () { [NQ]: [SEARCH_QUERY, null], sizes: [WIDTH + 'x' + HEIGHT], bidId: '24a1c9ec270973', - cors: 'http://localhost:9876' + cors: 'http://localhost' }; function getSingleBidResponse(isValid) { @@ -84,10 +86,14 @@ describe('nanointeractive adapter tests', function () { expect(nanoBidAdapter.isBidRequestValid(getBid(false))).to.equal(false); }); it('Test buildRequests()', function () { + let stub = sinon.stub(utils, 'getOrigin', () => 'http://localhost'); + let request = nanoBidAdapter.buildRequests([getBid(true)]); expect(request.method).to.equal('POST'); expect(request.url).to.equal(ENGINE_BASE_URL); expect(request.data).to.equal(JSON.stringify([SINGlE_BID_REQUEST])); + + stub.restore(); }); it('Test interpretResponse() length', function () { let bids = nanoBidAdapter.interpretResponse([getSingleBidResponse(true), getSingleBidResponse(false)]); diff --git a/test/spec/modules/readpeakBidAdapter_spec.js b/test/spec/modules/readpeakBidAdapter_spec.js index 18b52658c4b..7da3450f16c 100644 --- a/test/spec/modules/readpeakBidAdapter_spec.js +++ b/test/spec/modules/readpeakBidAdapter_spec.js @@ -99,7 +99,7 @@ describe('ReadPeakAdapter', () => { }, 'id': '11bc5dd5-7421-4dd8-c926-40fa653bec76', 'ref': '', - 'page': 'http://localhost:9876/?id=48509002', + 'page': 'http://localhost', 'domain': 'localhost' }, 'app': null, From 60b9ac57b41ee615dc0c431a5572879c891ac0d2 Mon Sep 17 00:00:00 2001 From: Jaimin Panchal Date: Wed, 20 Dec 2017 13:39:52 -0500 Subject: [PATCH 18/20] Fixes unit tests in browsers other than chrome (#1987) * Fixes unit tests in browsers other than chrome * fixed lint errors --- modules/freewheelSSPBidAdapter.js | 9 ++++++--- modules/rxrtbBidAdapter.js | 6 +++--- modules/serverbidServerBidAdapter.js | 4 ++-- src/utils.js | 13 +++++++++++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/modules/freewheelSSPBidAdapter.js b/modules/freewheelSSPBidAdapter.js index 7c696c746e6..64ebb36478b 100644 --- a/modules/freewheelSSPBidAdapter.js +++ b/modules/freewheelSSPBidAdapter.js @@ -47,7 +47,9 @@ function getPricing(xmlNode) { var princingData = {}; var extensions = xmlNode.querySelectorAll('Extension'); - extensions.forEach(function(node) { + // Nodelist.forEach is not supported in IE and Edge + // Workaround given here https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10638731/ + Array.prototype.forEach.call(extensions, function(node) { if (node.getAttribute('type') === 'StickyPricing') { pricingExtNode = node; } @@ -69,8 +71,9 @@ function getPricing(xmlNode) { function getCreativeId(xmlNode) { var creaId = ''; var adNodes = xmlNode.querySelectorAll('Ad'); - - adNodes.forEach(function(el) { + // Nodelist.forEach is not supported in IE and Edge + // Workaround given here https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10638731/ + Array.prototype.forEach.call(adNodes, function(el) { creaId += '[' + el.getAttribute('id') + ']'; }); diff --git a/modules/rxrtbBidAdapter.js b/modules/rxrtbBidAdapter.js index cf03e41c208..55b6991667a 100644 --- a/modules/rxrtbBidAdapter.js +++ b/modules/rxrtbBidAdapter.js @@ -12,7 +12,7 @@ export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER], isBidRequestValid: function (bidRequest) { - return 'params' in bidRequest && bidRequest.params.source !== undefined && bidRequest.params.id !== undefined && Number.isInteger(bidRequest.params.id) && bidRequest.params.token !== undefined; + return 'params' in bidRequest && bidRequest.params.source !== undefined && bidRequest.params.id !== undefined && utils.isInteger(bidRequest.params.id) && bidRequest.params.token !== undefined; }, buildRequests: function (validBidRequests) { var requests = []; @@ -100,7 +100,7 @@ function makeImp(req) { 'banner': makeBanner(req) }; - if (req.params.bidfloor && Number.isInteger(req.params.bidfloor)) { + if (req.params.bidfloor && utils.isInteger(req.params.bidfloor)) { imp.bidfloor = req.params.bidfloor } @@ -117,7 +117,7 @@ function makeBanner(req) { }); } banner.format = format; - if (req.params.pos && Number.isInteger(req.params.pos)) { + if (req.params.pos && utils.isInteger(req.params.pos)) { banner.pos = req.params.pos; } return banner; diff --git a/modules/serverbidServerBidAdapter.js b/modules/serverbidServerBidAdapter.js index 4ff8992772f..4be96a09bd6 100644 --- a/modules/serverbidServerBidAdapter.js +++ b/modules/serverbidServerBidAdapter.js @@ -139,12 +139,12 @@ ServerBidServerAdapter = function ServerBidServerAdapter() { } } if (data.placements.length) { - ajax(BASE_URI, _responseCallback(addBidResponse, bids), JSON.stringify(data), { method: 'POST', withCredentials: true, contentType: 'application/json' }); + ajax(BASE_URI, _responseCallback(addBidResponse, bids, done), JSON.stringify(data), { method: 'POST', withCredentials: true, contentType: 'application/json' }); } } } - function _responseCallback(addBidResponse, bids) { + function _responseCallback(addBidResponse, bids, done) { return function (resp) { let bid; let bidId; diff --git a/src/utils.js b/src/utils.js index 19014049352..2d185ebe4c6 100644 --- a/src/utils.js +++ b/src/utils.js @@ -866,3 +866,16 @@ export function deletePropertyFromObject(object, prop) { export function removeRequestId(bid) { return exports.deletePropertyFromObject(bid, 'requestId'); } + +/** + * Checks input is integer or not + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger + * @param {*} value + */ +export function isInteger(value) { + if (Number.isInteger) { + return Number.isInteger(value); + } else { + return typeof value === 'number' && isFinite(value) && Math.floor(value) === value; + } +} From ff8f539dac2fdb03745b252d4f2a89c962bf7eb8 Mon Sep 17 00:00:00 2001 From: Jaimin Panchal Date: Wed, 20 Dec 2017 13:41:09 -0500 Subject: [PATCH 19/20] Prebid 1.1.1 Release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9d6af175e0e..661cbfc3495 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "1.2.0-pre", + "version": "1.1.1", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From 2b1b1fe1f67ebacafd5bb4dc0906dbbaf499e78c Mon Sep 17 00:00:00 2001 From: Matt Kendall Date: Tue, 2 Jan 2018 15:58:54 -0500 Subject: [PATCH 20/20] Add note about docs needed before merge (#1959) * Add note about docs needed before merge * Update pr_review.md * Update pr_review.md * Update pr_review.md --- pr_review.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pr_review.md b/pr_review.md index 558b1c8bcb9..1d8cf0c360c 100644 --- a/pr_review.md +++ b/pr_review.md @@ -6,9 +6,10 @@ We take PR review seriously. Please read https://medium.com/@mrjoelkemp/giving-b - Verify PR is a single change type. Example, refactor OR bugfix. If more than 1 type, ask submitter to break out requests. - Verify code under review has at least 80% unit test coverage. If legacy code has no unit test coverage, ask for unit tests to be included in the PR. - Verify tests are green in Travis-ci + local build by running `gulp serve` | `gulp test` -- Verify no code quality violations are present from jscs (should be reported in terminal) +- Verify no code quality violations are present from linting (should be reported in terminal) - Review for obvious errors or bad coding practice / use best judgement here. - If the change is a new feature / change to core prebid.js - review the change with a Tech Lead on the project and make sure they agree with the nature of change. +- If the change results in needing updates to docs (such as public API change, module interface etc), add a label for "needs docs" and inform the submitter they must submit a docs PR to update the appropriate area of Prebid.org **before the PR can merge**. Help them with finding where the docs are located on prebid.org if needed. - If all above is good, add a `LGTM` comment and request 1 additional core member to review. - Once there is 2 `LGTM` on the PR, merge to master - Ask the submitter to add a PR for documentation if applicable.