Skip to content

Commit

Permalink
update prebid adapter. Add at, ccpa, gdpr and coppa support (prebid#6405
Browse files Browse the repository at this point in the history
)
  • Loading branch information
BizzClick authored and stsepelin committed May 28, 2021
1 parent 9a486c8 commit 46b3d40
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
19 changes: 19 additions & 0 deletions modules/bizzclickBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ export const spec = {
let data = {
id: bidRequest.bidId,
test: config.getConfig('debug') ? 1 : 0,
at: 1,
cur: ['USD'],
device: {
w: winTop.screen.width,
h: winTop.screen.height,
dnt: utils.getDNT() ? 1 : 0,
language: (navigator && navigator.language) ? navigator.language.indexOf('-') != -1 ? navigator.language.split('-')[0] : navigator.language : '',
},
site: {
Expand All @@ -94,9 +96,26 @@ export const spec = {
source: {
tid: bidRequest.transactionId
},
regs: {
coppa: config.getConfig('coppa') === true ? 1 : 0,
ext: {}
},
user: {
ext: {}
},
tmax: bidRequest.timeout,
imp: [impObject],
};
if (bidRequest) {
if (bidRequest.gdprConsent && bidRequest.gdprConsent.gdprApplies) {
utils.deepSetValue(data, 'regs.ext.gdpr', bidRequest.gdprConsent.gdprApplies ? 1 : 0);
utils.deepSetValue(data, 'user.ext.consent', bidRequest.gdprConsent.consentString);
}

if (bidRequest.uspConsent !== undefined) {
utils.deepSetValue(data, 'regs.ext.us_privacy', bidRequest.uspConsent);
}
}
bids.push(data)
}
return {
Expand Down
29 changes: 28 additions & 1 deletion test/spec/modules/bizzclickBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { spec } from 'modules/bizzclickBidAdapter.js';
import {config} from 'src/config.js';

const NATIVE_BID_REQUEST = {
code: 'native_example',
Expand Down Expand Up @@ -53,7 +54,11 @@ const BANNER_BID_REQUEST = {
accountId: 'accountId'
},
timeout: 1000,

gdprConsent: {
consentString: 'BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA',
gdprApplies: 1,
},
uspConsent: 'uspConsent'
}

const bidRequest = {
Expand Down Expand Up @@ -172,6 +177,22 @@ const NATIVE_BID_RESPONSE = {
};

describe('BizzclickAdapter', function() {
describe('with COPPA', function() {
beforeEach(function() {
sinon.stub(config, 'getConfig')
.withArgs('coppa')
.returns(true);
});
afterEach(function() {
config.getConfig.restore();
});

it('should send the Coppa "required" flag set to "1" in the request', function () {
let serverRequest = spec.buildRequests([BANNER_BID_REQUEST]);
expect(serverRequest.data[0].regs.coppa).to.equal(1);
});
});

describe('isBidRequestValid', function() {
it('should return true when required params found', function () {
expect(spec.isBidRequestValid(NATIVE_BID_REQUEST)).to.equal(true);
Expand Down Expand Up @@ -225,6 +246,12 @@ describe('BizzclickAdapter', function() {
expect(request.method).to.equal('POST');
});

it('check consent and ccpa string is set properly', function() {
expect(request.data[0].regs.ext.gdpr).to.equal(1);
expect(request.data[0].user.ext.consent).to.equal(BANNER_BID_REQUEST.gdprConsent.consentString);
expect(request.data[0].regs.ext.us_privacy).to.equal(BANNER_BID_REQUEST.uspConsent);
})

it('Returns valid URL', function () {
expect(request.url).to.equal('https://us-e-node1.bizzclick.com/bid?rtb_seat_id=prebidjs&secret_key=accountId');
});
Expand Down

0 comments on commit 46b3d40

Please sign in to comment.