Skip to content

Commit

Permalink
Logicad Bid Adapter: Add paapi support (prebid#11123)
Browse files Browse the repository at this point in the history
* Logicad Bid Adapter: Add paapi support

* Logicad Bid Adapter: fix

* Logicad Bid Adapter: fix test
  • Loading branch information
naru-tsujine authored Feb 24, 2024
1 parent 2e40035 commit 98162dc
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 15 deletions.
50 changes: 36 additions & 14 deletions modules/logicadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,25 @@ export const spec = {
},
interpretResponse: function (serverResponse, bidderRequest) {
serverResponse = serverResponse.body;

const bids = [];

if (!serverResponse || serverResponse.error) {
return bids;
}

serverResponse.seatbid.forEach(function (seatbid) {
bids.push(seatbid.bid);
})

const fledgeAuctionConfigs = deepAccess(serverResponse, 'ext.fledgeAuctionConfigs') || [];
if (fledgeAuctionConfigs.length) {
return {
bids,
fledgeAuctionConfigs,
};
}

return bids;
},
getUserSyncs: function (syncOptions, serverResponses) {
Expand All @@ -52,32 +64,42 @@ export const spec = {
},
};

function newBidRequest(bid, bidderRequest) {
function newBidRequest(bidRequest, bidderRequest) {
const bid = {
adUnitCode: bidRequest.adUnitCode,
bidId: bidRequest.bidId,
transactionId: bidRequest.ortb2Imp?.ext?.tid,
sizes: bidRequest.sizes,
params: bidRequest.params,
mediaTypes: bidRequest.mediaTypes,
}

const fledgeEnabled = deepAccess(bidderRequest, 'fledgeEnabled')
if (fledgeEnabled) {
const ae = deepAccess(bidRequest, 'ortb2Imp.ext.ae');
if (ae) {
bid.ae = ae;
}
}

const data = {
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
auctionId: bid.auctionId,
bidderRequestId: bid.bidderRequestId,
bids: [{
adUnitCode: bid.adUnitCode,
bidId: bid.bidId,
transactionId: bid.ortb2Imp?.ext?.tid,
sizes: bid.sizes,
params: bid.params,
mediaTypes: bid.mediaTypes
}],
auctionId: bidRequest.auctionId,
bidderRequestId: bidRequest.bidderRequestId,
bids: [bid],
prebidJsVersion: '$prebid.version$',
// TODO: is 'page' the right value here?
referrer: bidderRequest.refererInfo.page,
auctionStartTime: bidderRequest.auctionStart,
eids: bid.userIdAsEids,
eids: bidRequest.userIdAsEids,
};

const sua = deepAccess(bid, 'ortb2.device.sua');
const sua = deepAccess(bidRequest, 'ortb2.device.sua');
if (sua) {
data.sua = sua;
}

const userData = deepAccess(bid, 'ortb2.user.data');
const userData = deepAccess(bidRequest, 'ortb2.user.data');
if (userData) {
data.userData = userData;
}
Expand Down
63 changes: 62 additions & 1 deletion test/spec/modules/logicadBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ describe('LogicadAdapter', function () {
}
}]
}],
ortb2Imp: {
ext: {
ae: 1
}
},
ortb2: {
device: {
sua: {
Expand Down Expand Up @@ -176,7 +181,8 @@ describe('LogicadAdapter', function () {
numIframes: 1,
stack: []
},
auctionStart: 1563337198010
auctionStart: 1563337198010,
fledgeEnabled: true
};
const serverResponse = {
body: {
Expand All @@ -203,6 +209,49 @@ describe('LogicadAdapter', function () {
}
}
};

const paapiServerResponse = {
body: {
seatbid:
[{
bid: {
requestId: '51ef8751f9aead',
cpm: 101.0234,
width: 300,
height: 250,
creativeId: '2019',
currency: 'JPY',
netRevenue: true,
ttl: 60,
ad: '<div>TEST</div>',
meta: {
advertiserDomains: ['logicad.com']
}
}
}],
ext: {
fledgeAuctionConfigs: [{
bidId: '51ef8751f9aead',
config: {
seller: 'https://fledge.ladsp.com',
decisionLogicUrl: 'https://fledge.ladsp.com/decision_logic.js',
interestGroupBuyers: ['https://fledge.ladsp.com'],
requestedSize: {width: '300', height: '250'},
allSlotsRequestedSizes: [{width: '300', height: '250'}],
sellerSignals: {signal: 'signal'},
sellerTimeout: '500',
perBuyerSignals: {'https://fledge.ladsp.com': {signal: 'signal'}},
perBuyerCurrencies: {'https://fledge.ladsp.com': 'USD'}
}
}]
},
userSync: {
type: 'image',
url: 'https://cr-p31.ladsp.jp/cookiesender/31'
}
}
};

const nativeServerResponse = {
body: {
seatbid:
Expand Down Expand Up @@ -272,6 +321,11 @@ describe('LogicadAdapter', function () {

const data = JSON.parse(request.data);
expect(data.auctionId).to.equal('18fd8b8b0bd757');

// Protected Audience API flag
expect(data.bids[0]).to.have.property('ae');
expect(data.bids[0].ae).to.equal(1);

expect(data.eids[0].source).to.equal('sharedid.org');
expect(data.eids[0].uids[0].id).to.equal('fakesharedid');

Expand Down Expand Up @@ -330,6 +384,13 @@ describe('LogicadAdapter', function () {
expect(interpretedResponse[0].ttl).to.equal(serverResponse.body.seatbid[0].bid.ttl);
expect(interpretedResponse[0].meta.advertiserDomains).to.equal(serverResponse.body.seatbid[0].bid.meta.advertiserDomains);

// Protected Audience API
const paapiRequest = spec.buildRequests(bidRequests, bidderRequest)[0];
const paapiInterpretedResponse = spec.interpretResponse(paapiServerResponse, paapiRequest);
expect(paapiInterpretedResponse).to.have.property('bids');
expect(paapiInterpretedResponse).to.have.property('fledgeAuctionConfigs');
expect(paapiInterpretedResponse.fledgeAuctionConfigs[0]).to.deep.equal(paapiServerResponse.body.ext.fledgeAuctionConfigs[0]);

// native
const nativeRequest = spec.buildRequests(nativeBidRequests, bidderRequest)[0];
const interpretedResponseForNative = spec.interpretResponse(nativeServerResponse, nativeRequest);
Expand Down

0 comments on commit 98162dc

Please sign in to comment.