From 2d135d909e0e2bdf93d6ca7a06fe53e99a4b3f6c Mon Sep 17 00:00:00 2001 From: xuanwang Date: Fri, 17 Sep 2021 15:26:18 +0800 Subject: [PATCH 1/4] freewheel add schain in the request --- modules/freewheel-sspBidAdapter.js | 6 ++++++ .../modules/freewheel-sspBidAdapter_spec.js | 21 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/freewheel-sspBidAdapter.js b/modules/freewheel-sspBidAdapter.js index fa2f7b4cd6b..e8a7e5164cf 100644 --- a/modules/freewheel-sspBidAdapter.js +++ b/modules/freewheel-sspBidAdapter.js @@ -312,6 +312,12 @@ export const spec = { requestParams._fw_us_privacy = bidderRequest.uspConsent; } + // Add schain object + var schain = currentBidRequest.schain; + if (schain) { + requestParams.schain = schain; + } + var vastParams = currentBidRequest.params.vastUrlParams; if (typeof vastParams === 'object') { for (var key in vastParams) { diff --git a/test/spec/modules/freewheel-sspBidAdapter_spec.js b/test/spec/modules/freewheel-sspBidAdapter_spec.js index a5b4bd2a03f..931e5dc59e0 100644 --- a/test/spec/modules/freewheel-sspBidAdapter_spec.js +++ b/test/spec/modules/freewheel-sspBidAdapter_spec.js @@ -17,7 +17,8 @@ describe('freewheelSSP BidAdapter Test', () => { let bid = { 'bidder': 'freewheel-ssp', 'params': { - 'zoneId': '277225' + 'zoneId': '277225', + 'schain' }, 'adUnitCode': 'adunit-code', 'mediaTypes': { @@ -31,6 +32,19 @@ describe('freewheelSSP BidAdapter Test', () => { 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', + 'schain': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'example.com', + 'sid': '0', + 'hp': 1, + 'rid': 'bidrequestid', + 'domain': 'example.com' + } + ] + } }; it('should return true when required params found', () => { @@ -45,6 +59,11 @@ describe('freewheelSSP BidAdapter Test', () => { }; expect(spec.isBidRequestValid(bid)).to.equal(false); }); + + it('should return a properly formatted request with schain defined', function () { + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(bidRequests.data.schain).to.deep.equal(bidRequest[0].schain) + }); }); describe('isBidRequestValidForVideo', () => { From 7ac786069ca53bc0e7396858bc94819f39891e13 Mon Sep 17 00:00:00 2001 From: xuanwang Date: Tue, 27 Sep 2022 16:54:00 +0800 Subject: [PATCH 2/4] FreewheelSSP-Update update the bidder name and advertiserDomain --- modules/freewheel-sspBidAdapter.js | 76 +++++++++++++++---- modules/freewheel-sspBidAdapter.md | 2 +- .../modules/freewheel-sspBidAdapter_spec.js | 54 ++++++------- 3 files changed, 91 insertions(+), 41 deletions(-) diff --git a/modules/freewheel-sspBidAdapter.js b/modules/freewheel-sspBidAdapter.js index 38973f915b6..3591595a528 100644 --- a/modules/freewheel-sspBidAdapter.js +++ b/modules/freewheel-sspBidAdapter.js @@ -1,4 +1,4 @@ -import { logWarn, isArray } from '../src/utils.js'; +import * as utils from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; @@ -72,12 +72,52 @@ function getPricing(xmlNode) { price: priceNode.textContent || priceNode.innerText }; } else { - logWarn('PREBID - ' + BIDDER_CODE + ': No bid received or missing pricing extension.'); + utils.logWarn('PREBID - ' + BIDDER_CODE + ': No bid received or missing pricing extension.'); } return princingData; } +/* +* read the StickyBrand extension with this format: +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* @return {object} pricing data in format: {currency: "EUR", price:"1.000"} +*/ +function getAdvertiserDomain(xmlNode) { + var domain = ''; + var brandExtNode; + var extensions = xmlNode.querySelectorAll('Extension'); + // 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') === 'StickyBrand') { + brandExtNode = node; + } + }); + + if (brandExtNode) { + var domainNode = brandExtNode.querySelector('Domain'); + domain = domainNode.textContent || domainNode.innerText + } else { + utils.logWarn('PREBID - ' + BIDDER_CODE + ': No bid received or missing StickyBrand extension.'); + } + + return domain; +} + function hashcode(inputString) { var hash = 0; var char; @@ -189,7 +229,7 @@ function formatAdHTML(bid, size) { var libUrl = ''; if (integrationType && integrationType !== 'inbanner') { libUrl = PRIMETIME_URL + getComponentId(bid.params.format) + '.min.js'; - script = getOutstreamScript(bid); + script = getOutstreamScript(bid, size); } else { libUrl = MUSTANG_URL; script = getInBannerScript(bid, size); @@ -260,7 +300,7 @@ var getOutstreamScript = function(bid) { export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO], - aliases: ['stickyadstv'], // former name for freewheel-ssp + aliases: ['stickyadstv', 'freewheelssp'], // former names for freewheelssp /** * Determines whether or not the given bid request is valid. * @@ -326,8 +366,8 @@ export const spec = { } } } - // TODO: is 'page' the right value here? - var location = bidderRequest?.refererInfo?.page; + + var location = (bidderRequest && bidderRequest.refererInfo) ? bidderRequest.refererInfo.referer : getTopMostWindow().location.href; if (isValidUrl(location)) { requestParams.loc = location; } @@ -335,7 +375,7 @@ export const spec = { var playerSize = []; if (currentBidRequest.mediaTypes.video && currentBidRequest.mediaTypes.video.playerSize) { // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3 - if (isArray(currentBidRequest.mediaTypes.video.playerSize[0])) { + if (utils.isArray(currentBidRequest.mediaTypes.video.playerSize[0])) { playerSize = currentBidRequest.mediaTypes.video.playerSize[0]; } else { playerSize = currentBidRequest.mediaTypes.video.playerSize; @@ -377,7 +417,7 @@ export const spec = { var playerSize = []; if (bidrequest.mediaTypes.video && bidrequest.mediaTypes.video.playerSize) { // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3 - if (isArray(bidrequest.mediaTypes.video.playerSize[0])) { + if (utils.isArray(bidrequest.mediaTypes.video.playerSize[0])) { playerSize = bidrequest.mediaTypes.video.playerSize[0]; } else { playerSize = bidrequest.mediaTypes.video.playerSize; @@ -399,7 +439,7 @@ export const spec = { var parser = new DOMParser(); xmlDoc = parser.parseFromString(serverResponse, 'application/xml'); } catch (err) { - logWarn('Prebid.js - ' + BIDDER_CODE + ' : ' + err); + utils.logWarn('Prebid.js - ' + BIDDER_CODE + ' : ' + err); return; } @@ -409,6 +449,8 @@ export const spec = { const campaignId = getCampaignId(xmlDoc); const bannerId = getBannerId(xmlDoc); const topWin = getTopMostWindow(); + const advertiserDomains = getAdvertiserDomain(xmlDoc); + if (!topWin.freewheelssp_cache) { topWin.freewheelssp_cache = {}; } @@ -426,7 +468,7 @@ export const spec = { currency: princingData.currency, netRevenue: true, ttl: 360, - meta: { advertiserDomains: princingData.adomain && isArray(princingData.adomain) ? princingData.adomain : [] }, + meta: { advertiserDomains: advertiserDomains }, dealId: dealId, campaignId: campaignId, bannerId: bannerId @@ -454,14 +496,20 @@ export const spec = { } } + const syncs = []; if (syncOptions && syncOptions.pixelEnabled) { - return [{ + syncs.push({ type: 'image', url: USER_SYNC_URL + gdprParams - }]; - } else { - return []; + }); + } else if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: USER_SYNC_URL + gdprParams + }); } + + return syncs; }, }; diff --git a/modules/freewheel-sspBidAdapter.md b/modules/freewheel-sspBidAdapter.md index 0086aac6567..a445280f2b0 100644 --- a/modules/freewheel-sspBidAdapter.md +++ b/modules/freewheel-sspBidAdapter.md @@ -22,7 +22,7 @@ Module that connects to Freewheel ssp's demand sources bids: [ { - bidder: "freewheel-ssp", + bidder: "freewheelssp", // or use alias "freewheel-ssp" params: { zoneId : '277225' } diff --git a/test/spec/modules/freewheel-sspBidAdapter_spec.js b/test/spec/modules/freewheel-sspBidAdapter_spec.js index 6dea298762a..2f9f8ec457e 100644 --- a/test/spec/modules/freewheel-sspBidAdapter_spec.js +++ b/test/spec/modules/freewheel-sspBidAdapter_spec.js @@ -17,8 +17,7 @@ describe('freewheelSSP BidAdapter Test', () => { let bid = { 'bidder': 'freewheel-ssp', 'params': { - 'zoneId': '277225', - 'schain' + 'zoneId': '277225' }, 'adUnitCode': 'adunit-code', 'mediaTypes': { @@ -32,19 +31,6 @@ describe('freewheelSSP BidAdapter Test', () => { 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', - 'schain': { - 'ver': '1.0', - 'complete': 1, - 'nodes': [ - { - 'asi': 'example.com', - 'sid': '0', - 'hp': 1, - 'rid': 'bidrequestid', - 'domain': 'example.com' - } - ] - } }; it('should return true when required params found', () => { @@ -59,11 +45,6 @@ describe('freewheelSSP BidAdapter Test', () => { }; expect(spec.isBidRequestValid(bid)).to.equal(false); }); - - it('should return a properly formatted request with schain defined', function () { - const bidRequests = spec.buildRequests(bidRequest, bidderRequests); - expect(bidRequests.data.schain).to.deep.equal(bidRequest[0].schain) - }); }); describe('isBidRequestValidForVideo', () => { @@ -406,7 +387,7 @@ describe('freewheelSSP BidAdapter Test', () => { ]; let result = spec.interpretResponse(response, request[0]); - expect(result[0].meta.advertiserDomains).to.deep.equal([]); + expect(result[0].meta.advertiserDomains).to.deep.equal(''); expect(result[0].dealId).to.equal('NRJ-PRO-00008'); expect(result[0].campaignId).to.equal('SMF-WOW-55555'); expect(result[0].bannerId).to.equal('12345'); @@ -433,7 +414,7 @@ describe('freewheelSSP BidAdapter Test', () => { ]; let result = spec.interpretResponse(response, request[0]); - expect(result[0].meta.advertiserDomains).to.deep.equal([]); + expect(result[0].meta.advertiserDomains).to.deep.equal(''); expect(result[0].dealId).to.equal('NRJ-PRO-00008'); expect(result[0].campaignId).to.equal('SMF-WOW-55555'); expect(result[0].bannerId).to.equal('12345'); @@ -502,6 +483,23 @@ describe('freewheelSSP BidAdapter Test', () => { 'bidId': '2', 'bidderRequestId': '3', 'auctionId': '4', + }, + { + 'bidder': 'freewheelssp', + 'params': { + 'zoneId': '277225', + 'format': 'test' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'video': { + 'playerSize': [300, 600], + } + }, + 'sizes': [[300, 400]], + 'bidId': '2', + 'bidderRequestId': '3', + 'auctionId': '4', } ]; @@ -529,7 +527,8 @@ describe('freewheelSSP BidAdapter Test', () => { ' ' + ' ' + ' 0.2000' + - ' ' + + ' ' + + ' ' + ' ' + ' ' + ''; @@ -555,12 +554,15 @@ describe('freewheelSSP BidAdapter Test', () => { bannerId: '12345', vastXml: response, mediaType: 'video', - ad: ad + ad: ad, + meta: { + advertiserDomains: 'minotaur.com' + } } ]; let result = spec.interpretResponse(response, request[0]); - expect(result[0].meta.advertiserDomains).to.deep.equal([]); + expect(result[0].meta.advertiserDomains).to.deep.equal('minotaur.com'); expect(result[0].dealId).to.equal('NRJ-PRO-00008'); expect(result[0].campaignId).to.equal('SMF-WOW-55555'); expect(result[0].bannerId).to.equal('12345'); @@ -589,7 +591,7 @@ describe('freewheelSSP BidAdapter Test', () => { ]; let result = spec.interpretResponse(response, request[0]); - expect(result[0].meta.advertiserDomains).to.deep.equal([]); + expect(result[0].meta.advertiserDomains).to.deep.equal('minotaur.com'); expect(result[0].dealId).to.equal('NRJ-PRO-00008'); expect(result[0].campaignId).to.equal('SMF-WOW-55555'); expect(result[0].bannerId).to.equal('12345'); From b45d0763e405cfbdb82eb64d1256ea84886592ed Mon Sep 17 00:00:00 2001 From: xuanwang Date: Sun, 9 Oct 2022 15:59:35 +0800 Subject: [PATCH 3/4] FreewheelSSP-Update code update --- modules/freewheel-sspBidAdapter.js | 34 ++++++++++++------------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/modules/freewheel-sspBidAdapter.js b/modules/freewheel-sspBidAdapter.js index 3591595a528..68b67345f15 100644 --- a/modules/freewheel-sspBidAdapter.js +++ b/modules/freewheel-sspBidAdapter.js @@ -1,4 +1,4 @@ -import * as utils from '../src/utils.js'; +import { logWarn, isArray } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; @@ -72,27 +72,19 @@ function getPricing(xmlNode) { price: priceNode.textContent || priceNode.innerText }; } else { - utils.logWarn('PREBID - ' + BIDDER_CODE + ': No bid received or missing pricing extension.'); + logWarn('PREBID - ' + BIDDER_CODE + ': No bid received or missing pricing extension.'); } return princingData; } /* -* read the StickyBrand extension with this format: +* Read the StickyBrand extension with this format: * -* -* -* -* -* -* -* -* -* -* -* -* +* +* +* +* * * @return {object} pricing data in format: {currency: "EUR", price:"1.000"} */ @@ -112,7 +104,7 @@ function getAdvertiserDomain(xmlNode) { var domainNode = brandExtNode.querySelector('Domain'); domain = domainNode.textContent || domainNode.innerText } else { - utils.logWarn('PREBID - ' + BIDDER_CODE + ': No bid received or missing StickyBrand extension.'); + logWarn('PREBID - ' + BIDDER_CODE + ': No bid received or missing StickyBrand extension.'); } return domain; @@ -229,7 +221,7 @@ function formatAdHTML(bid, size) { var libUrl = ''; if (integrationType && integrationType !== 'inbanner') { libUrl = PRIMETIME_URL + getComponentId(bid.params.format) + '.min.js'; - script = getOutstreamScript(bid, size); + script = getOutstreamScript(bid); } else { libUrl = MUSTANG_URL; script = getInBannerScript(bid, size); @@ -300,7 +292,7 @@ var getOutstreamScript = function(bid) { export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO], - aliases: ['stickyadstv', 'freewheelssp'], // former names for freewheelssp + aliases: ['stickyadstv', 'freewheelssp'], // aliases for freewheel-ssp /** * Determines whether or not the given bid request is valid. * @@ -375,7 +367,7 @@ export const spec = { var playerSize = []; if (currentBidRequest.mediaTypes.video && currentBidRequest.mediaTypes.video.playerSize) { // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3 - if (utils.isArray(currentBidRequest.mediaTypes.video.playerSize[0])) { + if (isArray(currentBidRequest.mediaTypes.video.playerSize[0])) { playerSize = currentBidRequest.mediaTypes.video.playerSize[0]; } else { playerSize = currentBidRequest.mediaTypes.video.playerSize; @@ -417,7 +409,7 @@ export const spec = { var playerSize = []; if (bidrequest.mediaTypes.video && bidrequest.mediaTypes.video.playerSize) { // If mediaTypes is video, get size from mediaTypes.video.playerSize per http://prebid.org/blog/pbjs-3 - if (utils.isArray(bidrequest.mediaTypes.video.playerSize[0])) { + if (isArray(bidrequest.mediaTypes.video.playerSize[0])) { playerSize = bidrequest.mediaTypes.video.playerSize[0]; } else { playerSize = bidrequest.mediaTypes.video.playerSize; @@ -439,7 +431,7 @@ export const spec = { var parser = new DOMParser(); xmlDoc = parser.parseFromString(serverResponse, 'application/xml'); } catch (err) { - utils.logWarn('Prebid.js - ' + BIDDER_CODE + ' : ' + err); + logWarn('Prebid.js - ' + BIDDER_CODE + ' : ' + err); return; } From dce3406cbd5cbd5f28d0b3188ab1fa97f1b6edc3 Mon Sep 17 00:00:00 2001 From: xuanwang Date: Mon, 17 Oct 2022 16:59:06 +0800 Subject: [PATCH 4/4] Freewheel-SSP Bid Adapter: code update --- modules/freewheel-sspBidAdapter.js | 7 ++++--- test/spec/modules/freewheel-sspBidAdapter_spec.js | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/freewheel-sspBidAdapter.js b/modules/freewheel-sspBidAdapter.js index 68b67345f15..764e3d6e6c0 100644 --- a/modules/freewheel-sspBidAdapter.js +++ b/modules/freewheel-sspBidAdapter.js @@ -89,7 +89,7 @@ function getPricing(xmlNode) { * @return {object} pricing data in format: {currency: "EUR", price:"1.000"} */ function getAdvertiserDomain(xmlNode) { - var domain = ''; + var domain = []; var brandExtNode; var extensions = xmlNode.querySelectorAll('Extension'); // Nodelist.forEach is not supported in IE and Edge @@ -100,9 +100,10 @@ function getAdvertiserDomain(xmlNode) { } }); + // Currently we only return one Domain if (brandExtNode) { var domainNode = brandExtNode.querySelector('Domain'); - domain = domainNode.textContent || domainNode.innerText + domain.push(domainNode.textContent || domainNode.innerText); } else { logWarn('PREBID - ' + BIDDER_CODE + ': No bid received or missing StickyBrand extension.'); } @@ -359,7 +360,7 @@ export const spec = { } } - var location = (bidderRequest && bidderRequest.refererInfo) ? bidderRequest.refererInfo.referer : getTopMostWindow().location.href; + var location = bidderRequest?.refererInfo?.page; if (isValidUrl(location)) { requestParams.loc = location; } diff --git a/test/spec/modules/freewheel-sspBidAdapter_spec.js b/test/spec/modules/freewheel-sspBidAdapter_spec.js index 2f9f8ec457e..7ef576fc7ec 100644 --- a/test/spec/modules/freewheel-sspBidAdapter_spec.js +++ b/test/spec/modules/freewheel-sspBidAdapter_spec.js @@ -387,7 +387,7 @@ describe('freewheelSSP BidAdapter Test', () => { ]; let result = spec.interpretResponse(response, request[0]); - expect(result[0].meta.advertiserDomains).to.deep.equal(''); + expect(result[0].meta.advertiserDomains).to.deep.equal([]); expect(result[0].dealId).to.equal('NRJ-PRO-00008'); expect(result[0].campaignId).to.equal('SMF-WOW-55555'); expect(result[0].bannerId).to.equal('12345'); @@ -414,7 +414,7 @@ describe('freewheelSSP BidAdapter Test', () => { ]; let result = spec.interpretResponse(response, request[0]); - expect(result[0].meta.advertiserDomains).to.deep.equal(''); + expect(result[0].meta.advertiserDomains).to.deep.equal([]); expect(result[0].dealId).to.equal('NRJ-PRO-00008'); expect(result[0].campaignId).to.equal('SMF-WOW-55555'); expect(result[0].bannerId).to.equal('12345'); @@ -562,7 +562,7 @@ describe('freewheelSSP BidAdapter Test', () => { ]; let result = spec.interpretResponse(response, request[0]); - expect(result[0].meta.advertiserDomains).to.deep.equal('minotaur.com'); + expect(result[0].meta.advertiserDomains).to.deep.equal(['minotaur.com']); expect(result[0].dealId).to.equal('NRJ-PRO-00008'); expect(result[0].campaignId).to.equal('SMF-WOW-55555'); expect(result[0].bannerId).to.equal('12345'); @@ -591,7 +591,7 @@ describe('freewheelSSP BidAdapter Test', () => { ]; let result = spec.interpretResponse(response, request[0]); - expect(result[0].meta.advertiserDomains).to.deep.equal('minotaur.com'); + expect(result[0].meta.advertiserDomains).to.deep.equal(['minotaur.com']); expect(result[0].dealId).to.equal('NRJ-PRO-00008'); expect(result[0].campaignId).to.equal('SMF-WOW-55555'); expect(result[0].bannerId).to.equal('12345');