Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kumma adapter: GDPR support #2799

Merged
merged 1 commit into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion modules/kummaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const spec = {
isBidRequestValid: bid => (
!!(bid && bid.params && bid.params.pubId && bid.params.placementId)
),
buildRequests: bidRequests => {
buildRequests: (bidRequests, bidderRequest) => {
const request = {
id: bidRequests[0].bidderRequestId,
at: 2,
Expand All @@ -32,6 +32,7 @@ export const spec = {
app: app(bidRequests),
device: device(bidRequests),
};
applyGdpr(bidderRequest, request);
return {
method: 'POST',
url: '//hb.kumma.com/',
Expand Down Expand Up @@ -270,6 +271,13 @@ function parse(rawResponse) {
return null;
}

function applyGdpr(bidderRequest, ortbRequest) {
if (bidderRequest && bidderRequest.gdprConsent) {
ortbRequest.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } };
ortbRequest.user = { ext: { consent: bidderRequest.gdprConsent.consentString } };
}
}

function nativeResponse(imp, bid) {
if (imp['native']) {
const nativeAd = parse(bid.adm);
Expand Down
19 changes: 19 additions & 0 deletions test/spec/modules/kummaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,23 @@ describe('Kumma Adapter Tests', () => {
expect(ortbRequest.app.storeurl).to.equal('http://kumma.com/apps');
expect(ortbRequest.app.domain).to.equal('kumma.com');
});

it('Verify GDPR', () => {
const bidderRequest = {
gdprConsent: {
gdprApplies: true,
consentString: 'serialized_gpdr_data'
}
};
const request = spec.buildRequests(slotConfigs, bidderRequest);
expect(request.url).to.equal('//hb.kumma.com/');
expect(request.method).to.equal('POST');
const ortbRequest = JSON.parse(request.data);
expect(ortbRequest.user).to.not.equal(null);
expect(ortbRequest.user.ext).to.not.equal(null);
expect(ortbRequest.user.ext.consent).to.equal('serialized_gpdr_data');
expect(ortbRequest.regs).to.not.equal(null);
expect(ortbRequest.regs.ext).to.not.equal(null);
expect(ortbRequest.regs.ext.gdpr).to.equal(1);
});
});