Skip to content

Commit

Permalink
Ccx bid adapter: Protected Audence, add request param imp.ext.ae (#12055
Browse files Browse the repository at this point in the history
)

* adomain support

* adomain support

* adomain support

* adomain support

* adomain support

* video params

* docs changes

* Clickonometrics adapter update

* Revert "Revert "Clickonometrics Bid Adapter : add gvlid (#9198)" (#9216)"

This reverts commit 6d114e8.

* Test fix

* tests

* fledge

* fledge

---------

Co-authored-by: Michal Jaworski <[email protected]>
  • Loading branch information
mjaworskiccx and mkjsoft authored Jul 31, 2024
1 parent 62e6d89 commit 39fa308
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 2 deletions.
8 changes: 6 additions & 2 deletions modules/ccxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function _validateSizes (sizeObj, type) {
return true
}

function _buildBid (bid) {
function _buildBid (bid, bidderRequest) {
let placement = {}
placement.id = bid.bidId
placement.secure = 1
Expand Down Expand Up @@ -105,6 +105,10 @@ function _buildBid (bid) {

placement.ext = {'pid': bid.params.placementId}

if (bidderRequest.paapi?.enabled) {
placement.ext.ae = bid?.ortb2Imp?.ext?.ae
}

return placement
}

Expand Down Expand Up @@ -197,7 +201,7 @@ export const spec = {
}

_each(validBidRequests, function (bid) {
requestBody.imp.push(_buildBid(bid))
requestBody.imp.push(_buildBid(bid, bidderRequest))
})
// Return the server request
return {
Expand Down
81 changes: 81 additions & 0 deletions test/spec/modules/ccxBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from 'chai';
import {syncAddFPDToBidderRequest} from '../../helpers/fpd';
import { spec } from 'modules/ccxBidAdapter.js';
import * as utils from 'src/utils.js';

Expand Down Expand Up @@ -39,6 +40,7 @@ describe('ccxAdapter', function () {
transactionId: 'aefddd38-cfa0-48ab-8bdd-325de4bab5f9'
}
];

describe('isBidRequestValid', function () {
it('Valid bid requests', function () {
expect(spec.isBidRequestValid(bids[0])).to.be.true;
Expand Down Expand Up @@ -75,6 +77,7 @@ describe('ccxAdapter', function () {
expect(spec.isBidRequestValid(bidsClone[0])).to.be.true;
});
});

describe('buildRequests', function () {
it('No valid bids', function () {
expect(spec.buildRequests([])).to.be.undefined;
Expand Down Expand Up @@ -173,6 +176,7 @@ describe('ccxAdapter', function () {

expect(data.imp).to.deep.have.same.members(imps);
});

it('Valid bid request - sizes old style', function () {
let bidsClone = utils.deepClone(bids);
delete (bidsClone[0].mediaTypes);
Expand Down Expand Up @@ -218,6 +222,7 @@ describe('ccxAdapter', function () {

expect(data.imp).to.deep.have.same.members(imps);
});

it('Valid bid request - sizes old style - no media type', function () {
let bidsClone = utils.deepClone(bids);
delete (bidsClone[0].mediaTypes);
Expand Down Expand Up @@ -385,6 +390,7 @@ describe('ccxAdapter', function () {
expect(spec.interpretResponse({})).to.be.empty;
});
});

describe('getUserSyncs', function () {
it('Valid syncs - all', function () {
let syncOptions = {
Expand Down Expand Up @@ -434,6 +440,7 @@ describe('ccxAdapter', function () {
expect(spec.getUserSyncs(syncOptions, [{body: response}])).to.be.empty;
});
});

describe('mediaTypesVideoParams', function () {
it('Valid video mediaTypes', function () {
let bids = [
Expand Down Expand Up @@ -488,4 +495,78 @@ describe('ccxAdapter', function () {
expect(data.imp).to.deep.have.same.members(imps);
});
});

describe('FLEDGE', function () {
it('should properly build a request when FLEDGE is enabled', function () {
let bidderRequest = {
paapi: {
enabled: true
}
};
let bids = [
{
adUnitCode: 'banner',
auctionId: '0b9de793-8eda-481e-a548-aaaaaaaaaaa1',
bidId: '2e56e1af51ccc1',
bidder: 'ccx',
bidderRequestId: '17e7b9f58accc1',
mediaTypes: {
banner: {
sizes: [[300, 250]]
}
},
params: {
placementId: 609
},
sizes: [[300, 250]],
transactionId: 'befddd38-cfa0-48ab-8bdd-bbbbbbbbbbb1',
ortb2Imp: {
ext: {
ae: 1
}
}
}
];

let ortbRequest = spec.buildRequests(bids, syncAddFPDToBidderRequest(bidderRequest));
let data = JSON.parse(ortbRequest.data);
expect(data.imp[0].ext.ae).to.equal(1);
});

it('should properly build a request when FLEDGE is disabled', function () {
let bidderRequest = {
paapi: {
enabled: false
}
};
let bids = [
{
adUnitCode: 'banner',
auctionId: '0b9de793-8eda-481e-a548-aaaaaaaaaaa2',
bidId: '2e56e1af51ccc2',
bidder: 'ccx',
bidderRequestId: '17e7b9f58accc2',
mediaTypes: {
banner: {
sizes: [[300, 250]]
}
},
params: {
placementId: 610
},
sizes: [[300, 250]],
transactionId: 'befddd38-cfa0-48ab-8bdd-bbbbbbbbbbb2',
ortb2Imp: {
ext: {
ae: 1
}
}
}
];

let ortbRequest = spec.buildRequests(bids, syncAddFPDToBidderRequest(bidderRequest));
let data = JSON.parse(ortbRequest.data);
expect(data.imp[0].ext.ae).to.be.undefined;
});
});
});

0 comments on commit 39fa308

Please sign in to comment.