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

RAS Bid Adapter: fledge support #10477

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions modules/rasBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,36 @@ const getGdprParams = (bidderRequest) => {
return queryString;
};

const parseAuctionConfigs = (serverResponse, bidRequest) => {
if (isEmpty(serverResponse) || isEmpty(bidRequest)) {
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not append fledge if it is empty?

Copy link
Contributor Author

@wsusrasp wsusrasp Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the first iteration of implementation we were planning to return the configs in the serverResponse so if it was empty we would return null, but as you pointed out now there is no reason to do that. I'll correct the code.

}
let auctionConfigs = [];
const bidConfigs = Object.fromEntries(bidRequest.bidIds.map(x => [x.bidId, x]));

serverResponse.ads.filter(bid => bidConfigs.hasOwnProperty(bid.id) && bidConfigs[bid.id].fledgeEnabled).forEach((bid) => {
auctionConfigs.push({
'bidId': bidConfigs[bid.id].bidId,
'config': {
'seller': 'https://csr.onet.pl',
'decisionLogicUrl': `https://csr.onet.pl/${bidConfigs[bid.id].network}/v1/protected-audience-api/decision-logic.js`,
'interestGroupBuyers': ['https://csr.onet.pl'],
'auctionSignals': {
'site': bidConfigs[bid.id].site,
'kvismobile': bidConfigs[bid.id].isMobile,
patmmccann marked this conversation as resolved.
Show resolved Hide resolved
'iusizes': bidConfigs[bid.id].iusizes
}
}
});
});

if (auctionConfigs.length === 0) {
return null;
} else {
return auctionConfigs;
}
}

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER],
Expand All @@ -145,8 +175,18 @@ export const spec = {
const slotsQuery = getSlots(bidRequests);
const contextQuery = getContextParams(bidRequests, bidderRequest);
const gdprQuery = getGdprParams(bidderRequest);
const bidIds = bidRequests.map((bid) => ({ slot: bid.params.slot, bidId: bid.bidId }));
const fledgeEligible = Boolean(bidderRequest && bidderRequest.fledgeEnabled);
const network = bidRequests[0].params.network;
const bidIds = bidRequests.map((bid) => ({
slot: bid.params.slot,
bidId: bid.bidId,
network: network,
site: bid.params.site,
isMobile: Boolean(bid.params.pageContext?.keyValues?.ismobile),
iusizes: getAdUnitSizes(bid),
fledgeEnabled: fledgeEligible
}));

return [{
method: 'GET',
url: getEndpoint(network) + contextQuery + slotsQuery + gdprQuery,
Expand All @@ -159,7 +199,16 @@ export const spec = {
if (!response || !response.ads || response.ads.length === 0) {
return [];
}
return response.ads.map(buildBid).filter((bid) => !isEmpty(bid));

const fledgeAuctionConfigs = parseAuctionConfigs(response, bidRequest);
const bids = response.ads.map(buildBid).filter((bid) => !isEmpty(bid));

if (fledgeAuctionConfigs) {
// Return a tuple of bids and auctionConfigs. It is possible that bids could be null.
return {bids, fledgeAuctionConfigs};
} else {
return bids;
}
}
};

Expand Down