Skip to content

Commit

Permalink
Freewheel-ssp BidAdapter improvements (prebid#3097)
Browse files Browse the repository at this point in the history
* 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

* add vast parameters feature and GDPR params in VAST request

* fix lint issues

* add gdpr parameter support on freewheelSSPBidAdapter

* use bidderrequest to read gdpr parameters and update unit tests

* fix lint errors

* fix lint errors

* fix typo and bidderRequest reference.

* fix bidderRequest reference.

* add missing declaration for 'key' variable

* rename frewheel ssp bid adapter files to match the bidder code (fix custom download issues)

* update unit tests using the new name freewheel-ssp

* update documented test zone to a more recent one

* target created div insitead of original placement (avoid some misplaced ad)

* fix target div size

* add key and timestamp parameters for a better request identification.

* Remove the arrow function call so the style  is consistent throughout the file
  • Loading branch information
guillaume-sticky authored and Pedro López Jiménez committed Mar 18, 2019
1 parent 2cdff2e commit faccbaa
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 205 deletions.
31 changes: 24 additions & 7 deletions modules/freewheel-sspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ function getPricing(xmlNode) {
return princingData;
}

function hashcode(inputString) {
var hash = 0;
var char;
if (inputString.length == 0) return hash;
for (var i = 0; i < inputString.length; i++) {
char = inputString.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}

function getCreativeId(xmlNode) {
var creaId = '';
var adNodes = xmlNode.querySelectorAll('Ad');
Expand Down Expand Up @@ -116,7 +128,7 @@ function getAPIName(componentId) {
function formatAdHTML(bid, size) {
var integrationType = bid.params.format;

var divHtml = '<div id="freewheelssp_prebid_target"></div>';
var divHtml = '<div id="freewheelssp_prebid_target" style="width:' + size[0] + 'px;height:' + size[1] + 'px;"></div>';

var script = '';
var libUrl = '';
Expand Down Expand Up @@ -161,13 +173,11 @@ var getInBannerScript = function(bid, size) {
};

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;
config.domId = 'freewheelssp_prebid_target';
}

var script = 'var config = {' +
Expand Down Expand Up @@ -216,11 +226,17 @@ export const spec = {
utils.logMessage('Prebid.JS - freewheel bid adapter: only one ad unit is required.');
}

var zone = currentBidRequest.params.zoneId;
var timeInMillis = new Date().getTime();
var keyCode = hashcode(zone + '' + timeInMillis);

var requestParams = {
reqType: 'AdsSetup',
protocolVersion: '2.0',
zoneId: currentBidRequest.params.zoneId,
componentId: getComponentId(currentBidRequest.params.format)
zoneId: zone,
componentId: getComponentId(currentBidRequest.params.format),
timestamp: timeInMillis,
pKey: keyCode
};

// Add GDPR flag and consent string
Expand Down Expand Up @@ -330,6 +346,7 @@ export const spec = {
url: USER_SYNC_URL
}];
}
}
},

}
registerBidder(spec);
2 changes: 1 addition & 1 deletion modules/freewheel-sspBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Module that connects to Freewheel ssp's demand sources
{
bidder: "freewheel-ssp",
params: {
zoneId : '277225'
zoneId : '41852'
}
}
]
Expand Down
Loading

0 comments on commit faccbaa

Please sign in to comment.