Skip to content

Commit

Permalink
Add GDPR support for ucfunnel adapter (prebid#2619)
Browse files Browse the repository at this point in the history
* Add a new ucfunnel Adapter and test page

* Add a new ucfunnel Adapter and test page

* 1. Use prebid lib in the repo to keep updated
2. Replace var with let
3. Put JSON.parse(JSON.stringify()) into try catch block

* utils.getTopWindowLocation is a function

* Change to modules from adapters

* Migrate to module design

* [Dev Fix] Remove width and height which can be got from ad unit id

* Update ucfunnelBidAdapter to fit into new spec

* Correct the endpoint. Fix the error of query string

* Add test case for ucfunnelBidAdapter

* Fix lint error

* Update version number

* Combine all checks on bid request

* Add GDPR support for ucfunnel adapter
  • Loading branch information
RyanChouTw authored and AdSpacesDevelopers committed Jan 30, 2019
1 parent 5e2f17f commit 45389f0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions modules/ucfunnelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ export const spec = {
},

/**
* Format the bid request object for our endpoint
* @param {BidRequest[]} bidRequests Array of ucfunnel bidders
* @return object of parameters for Prebid AJAX request
* @param {BidRequest[]} bidRequests
* @param {*} bidderRequest
* @return {ServerRequest}
*/
buildRequests: function(validBidRequests) {
buildRequests: function(validBidRequests, bidderRequest) {
var bidRequests = [];
for (var i = 0; i < validBidRequests.length; i++) {
var bid = validBidRequests[i];

var ucfunnelUrlParams = buildUrlParams(bid);
var ucfunnelUrlParams = buildUrlParams(bid, bidderRequest);

bidRequests.push({
method: 'GET',
Expand Down Expand Up @@ -69,7 +69,7 @@ export const spec = {
};
registerBidder(spec);

function buildUrlParams(bid) {
function buildUrlParams(bid, bidderRequest) {
const host = utils.getTopWindowLocation().host;
const page = utils.getTopWindowLocation().pathname;
const refer = document.referrer;
Expand All @@ -88,6 +88,11 @@ function buildUrlParams(bid) {
'ver', VER
];

if (bidderRequest && bidderRequest.gdprConsent) {
queryString.push('gdpr', bidderRequest.gdprConsent.gdprApplies ? 1 : 0);
queryString.push('euconsent', bidderRequest.gdprConsent.consentString);
}

return queryString.reduce(
(memo, curr, index) =>
index % 2 === 0 && queryString[index + 1] !== undefined ? memo + curr + '=' + encodeURIComponent(queryString[index + 1]) + '&' : memo, ''
Expand Down

0 comments on commit 45389f0

Please sign in to comment.