Skip to content

Commit

Permalink
Criteo Bid Adapter: Add Coppa support (prebid#8781)
Browse files Browse the repository at this point in the history
* Criteo Bid Adapter: Add support of the COPPA flag

* Criteo Bid Adapter: Add support of the COPPA flag
  • Loading branch information
Pgb-Criteo authored and jorgeluisrocha committed May 18, 2023
1 parent 17a6c02 commit 703be84
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export const spec = {
Object.assign(bidderRequest, {
publisherExt: fpd.site?.ext,
userExt: fpd.user?.ext,
ceh: config.getConfig('criteo.ceh')
ceh: config.getConfig('criteo.ceh'),
coppa: config.getConfig('coppa')
});

// If publisher tag not already loaded try to get it from fast bid
Expand Down Expand Up @@ -446,6 +447,9 @@ function buildCdbRequest(context, bidRequests, bidderRequest) {
url: context.url,
ext: bidderRequest.publisherExt,
},
regs: {
coppa: bidderRequest.coppa === true ? 1 : (bidderRequest.coppa === false ? 0 : undefined)
},
slots: bidRequests.map(bidRequest => {
networkId = bidRequest.params.networkId || networkId;
schain = bidRequest.schain || schain;
Expand Down
25 changes: 25 additions & 0 deletions test/spec/modules/criteoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,31 @@ describe('The Criteo bidding adapter', function () {
}
});
});

it('should properly build a request when coppa flag is true', function () {
const bidRequests = [];
const bidderRequest = {};
config.setConfig({ coppa: true });
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.regs.coppa).to.not.be.undefined;
expect(request.data.regs.coppa).to.equal(1);
});

it('should properly build a request when coppa flag is false', function () {
const bidRequests = [];
const bidderRequest = {};
config.setConfig({ coppa: false });
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.regs.coppa).to.not.be.undefined;
expect(request.data.regs.coppa).to.equal(0);
});

it('should properly build a request when coppa flag is not defined', function () {
const bidRequests = [];
const bidderRequest = {};
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data.regs.coppa).to.be.undefined;
});
});

describe('interpretResponse', function () {
Expand Down

0 comments on commit 703be84

Please sign in to comment.