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

AdkernelAdn: Configurable user-sync types support #5445

Merged
merged 1 commit into from Jul 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);