Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freewheel-SSP Bid Adapter: add alias, update local param, and other additions #9093

Merged
merged 9 commits into from
Oct 19, 2022
55 changes: 48 additions & 7 deletions modules/freewheel-sspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,39 @@ function getPricing(xmlNode) {
return princingData;
}

/*
* Read the StickyBrand extension with this format:
* <Extension type='StickyBrand'>
* <Domain><![CDATA[minotaur.com]]></Domain>
* <Sector><![CDATA[BEAUTY & HYGIENE]]></Sector>
* <Advertiser><![CDATA[James Bond Trademarks]]></Advertiser>
* <Brand><![CDATA[007 Seven]]></Brand>
* </Extension>
* @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;
}
});

// Currently we only return one Domain
if (brandExtNode) {
var domainNode = brandExtNode.querySelector('Domain');
domain.push(domainNode.textContent || domainNode.innerText);
} else {
logWarn('PREBID - ' + BIDDER_CODE + ': No bid received or missing StickyBrand extension.');
}

return domain;
}

function hashcode(inputString) {
var hash = 0;
var char;
Expand Down Expand Up @@ -260,7 +293,7 @@ var getOutstreamScript = function(bid) {
export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, VIDEO],
aliases: ['stickyadstv'], // former name for freewheel-ssp
aliases: ['stickyadstv', 'freewheelssp'], // aliases for freewheel-ssp
/**
* Determines whether or not the given bid request is valid.
*
Expand Down Expand Up @@ -326,7 +359,7 @@ export const spec = {
}
}
}
// TODO: is 'page' the right value here?

var location = bidderRequest?.refererInfo?.page;
if (isValidUrl(location)) {
requestParams.loc = location;
Expand Down Expand Up @@ -409,6 +442,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 = {};
}
Expand All @@ -426,7 +461,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
Expand Down Expand Up @@ -454,14 +489,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;
},
};

Expand Down
2 changes: 1 addition & 1 deletion modules/freewheel-sspBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
29 changes: 25 additions & 4 deletions test/spec/modules/freewheel-sspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,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',
}
];

Expand Down Expand Up @@ -510,7 +527,8 @@ describe('freewheelSSP BidAdapter Test', () => {
' </Creatives>' +
' <Extensions>' +
' <Extension type=\'StickyPricing\'><Price currency="EUR">0.2000</Price></Extension>' +
' </Extensions>' +
' <Extension type=\'StickyBrand\'><Domain><![CDATA[minotaur.com]]></Domain><Sector><![CDATA[BEAUTY & HYGIENE]]></Sector><Advertiser><![CDATA[James Bond Trademarks]]></Advertiser><Brand><![CDATA[007 Seven]]></Brand></Extension>' +
' </Extensions>' +
' </InLine>' +
' </Ad>' +
'</VAST>';
Expand All @@ -536,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');
Expand Down Expand Up @@ -570,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');
Expand Down