Skip to content

Commit

Permalink
Add GDPR parameters in ad request (#2522)
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
  • Loading branch information
guillaume-sticky authored and jsnellbaker committed Jun 18, 2018
1 parent c739338 commit 2c19032
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
20 changes: 19 additions & 1 deletion modules/freewheelSSPBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export const spec = {
* @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) {
buildRequests: function(bidRequests, bidderRequest) {
// var currency = config.getConfig(currency);

var currentBidRequest = bidRequests[0];
Expand All @@ -223,6 +223,24 @@ export const spec = {
componentId: getComponentId(currentBidRequest.params.format)
};

// Add GDPR flag and consent string
if (bidderRequest.gdprConsent) {
requestParams._fw_gdpr_consent = bidderRequest.gdprConsent.consentString;

if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') {
requestParams._fw_gdpr = bidderRequest.gdprConsent.gdprApplies;
}
}

var vastParams = currentBidRequest.params.vastUrlParams;
if (typeof vastParams === 'object') {
for (var key in vastParams) {
if (vastParams.hasOwnProperty(key)) {
requestParams[key] = vastParams[key];
}
}
}

var location = utils.getTopWindowUrl();
if (isValidUrl(location)) {
requestParams.loc = location;
Expand Down
16 changes: 11 additions & 5 deletions test/spec/modules/freewheelSSPBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,27 @@ describe('freewheelSSP BidAdapter Test', () => {
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'gdprConsent': {
'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
'gdprApplies': true
}
}
];

it('should add parameters to the tag', () => {
const request = spec.buildRequests(bidRequests);
const request = spec.buildRequests(bidRequests, bidRequests[0]);
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');
expect(payload._fw_gdpr).to.equal(true);
expect(payload._fw_gdpr_consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==');
});

it('sends bid request to ENDPOINT via GET', () => {
const request = spec.buildRequests(bidRequests);
const request = spec.buildRequests(bidRequests, bidRequests[0]);
expect(request.url).to.contain(ENDPOINT);
expect(request.method).to.equal('GET');
});
Expand Down Expand Up @@ -139,7 +145,7 @@ describe('freewheelSSP BidAdapter Test', () => {
let formattedAd = '<div id="freewheelssp_prebid_target"></div><script type=\'text/javascript\'>(function() { var st = document.createElement(\'script\'); st.type = \'text/javascript\'; st.async = true; st.src = \'http://cdn.stickyadstv.com/prime-time/floorad.min.js\'; st.onload = function(){ var vastLoader = new window.com.stickyadstv.vast.VastLoader(); var vast = vastLoader.getVast(); var topWindow = (function(){var res=window; try{while(top != res){if(res.parent.location.href.length)res=res.parent;}}catch(e){}return res;})(); vast.setXmlString(topWindow.freeheelssp_cache["adunit-code"]); vastLoader.parseAds(vast, { onSuccess: function() {var config = { preloadedVast:vast, ASLoader:new window.com.stickyadstv.tools.ASLoader(277225, \'floorad\'),domId:"adunit-code"};window.com.stickyadstv.floorad.start(config); } }); }; document.head.appendChild(st);})();</script>';

it('should get correct bid response', () => {
var request = spec.buildRequests(bidRequests);
var request = spec.buildRequests(formattedBidRequests, formattedBidRequests[0]);

let expectedResponse = [
{
Expand All @@ -160,7 +166,7 @@ describe('freewheelSSP BidAdapter Test', () => {
});

it('should get correct bid response with formated ad', () => {
var request = spec.buildRequests(formattedBidRequests);
var request = spec.buildRequests(formattedBidRequests, formattedBidRequests[0]);

let expectedResponse = [
{
Expand All @@ -181,7 +187,7 @@ describe('freewheelSSP BidAdapter Test', () => {
});

it('handles nobid responses', () => {
var reqest = spec.buildRequests(formattedBidRequests);
var reqest = spec.buildRequests(formattedBidRequests, formattedBidRequests[0]);
let response = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><VAST version=\'2.0\'></VAST>';

let result = spec.interpretResponse(response, reqest);
Expand Down

0 comments on commit 2c19032

Please sign in to comment.