Skip to content

Commit

Permalink
AdkernelAdn: Configurable user-sync types support (#5445)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckbo3hrk committed Jul 23, 2020
1 parent bf5c7c7 commit 215bc0e
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions modules/adkernelAdnBidAdapter.js
Expand Up @@ -48,11 +48,12 @@ function canonicalizeSizesArray(sizes) {
return sizes;
}

function buildRequestParams(tags, auctionId, transactionId, gdprConsent, uspConsent, refInfo) {
function buildRequestParams(tags, bidderRequest) {
let {auctionId, gdprConsent, uspConsent, transactionId, refererInfo} = bidderRequest;
let req = {
id: auctionId,
tid: transactionId,
site: buildSite(refInfo),
site: buildSite(refererInfo),
imp: tags
};
if (gdprConsent) {
Expand Down Expand Up @@ -132,14 +133,13 @@ export const spec = {
return acc;
}, {});

let {auctionId, gdprConsent, uspConsent, transactionId, refererInfo} = bidderRequest;
let requests = [];
Object.keys(dispatch).forEach(host => {
Object.keys(dispatch[host]).forEach(pubId => {
let request = buildRequestParams(dispatch[host][pubId], auctionId, transactionId, gdprConsent, uspConsent, refererInfo);
let request = buildRequestParams(dispatch[host][pubId], bidderRequest);
requests.push({
method: 'POST',
url: `https://${host}/tag?account=${pubId}&pb=1${isRtbDebugEnabled(refererInfo) ? '&debug=1' : ''}`,
url: `https://${host}/tag?account=${pubId}&pb=1${isRtbDebugEnabled(bidderRequest.refererInfo) ? '&debug=1' : ''}`,
data: JSON.stringify(request)
})
});
Expand All @@ -159,14 +159,24 @@ export const spec = {
},

getUserSyncs: function(syncOptions, serverResponses) {
if (!syncOptions.iframeEnabled || !serverResponses || serverResponses.length === 0) {
if (!serverResponses || serverResponses.length === 0) {
return [];
}
if (syncOptions.iframeEnabled) {
return buildSyncs(serverResponses, 'syncpages', 'iframe');
} else if (syncOptions.pixelEnabled) {
return buildSyncs(serverResponses, 'syncpixels', 'image');
} else {
return [];
}
return serverResponses.filter(rps => rps.body && rps.body.syncpages)
.map(rsp => rsp.body.syncpages)
.reduce((a, b) => a.concat(b), [])
.map(syncUrl => ({type: 'iframe', url: syncUrl}));
}
};

function buildSyncs(serverResponses, propName, type) {
return serverResponses.filter(rps => rps.body && rps.body[propName])
.map(rsp => rsp.body[propName])
.reduce((a, b) => a.concat(b), [])
.map(syncUrl => ({type: type, url: syncUrl}));
}

registerBidder(spec);

0 comments on commit 215bc0e

Please sign in to comment.