diff --git a/modules/logicadBidAdapter.js b/modules/logicadBidAdapter.js index 07f9b893887..fe4dd83c9e2 100644 --- a/modules/logicadBidAdapter.js +++ b/modules/logicadBidAdapter.js @@ -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) { @@ -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; } diff --git a/test/spec/modules/logicadBidAdapter_spec.js b/test/spec/modules/logicadBidAdapter_spec.js index 3c1383781b9..12e8ca31cbb 100644 --- a/test/spec/modules/logicadBidAdapter_spec.js +++ b/test/spec/modules/logicadBidAdapter_spec.js @@ -36,6 +36,11 @@ describe('LogicadAdapter', function () { } }] }], + ortb2Imp: { + ext: { + ae: 1 + } + }, ortb2: { device: { sua: { @@ -176,7 +181,8 @@ describe('LogicadAdapter', function () { numIframes: 1, stack: [] }, - auctionStart: 1563337198010 + auctionStart: 1563337198010, + fledgeEnabled: true }; const serverResponse = { body: { @@ -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: '
TEST
', + 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: @@ -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'); @@ -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);