Skip to content

Rubicon adapter GDPR support #2406

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ export const spec = {
'tk_user_key', userId
];

// add GDPR properties if enabled
if (config.getConfig('consentManagement')) {
if (bidRequest.gdprConsent && typeof bidRequest.gdprConsent === 'object') {
if (typeof bidRequest.gdprConsent.consentRequired === 'boolean') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@idettman In the upcoming changes to the consentManagement module, we'll be renaming this field to bidderRequest.gdprConsent.gdprApplies

Can you please make the necessary changes to point to the new field? Please also ensure you're pointing to the bidderRequest object and not the bidRequest object.

As a final request, can you please make the above updates on the earlier set of GDPR code in the adapter file (for the video requests)?

Copy link
Contributor Author

@idettman idettman Apr 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes are committed.

data.push(
'gdpr', bidRequest.gdprConsent.consentRequired ? 1 : 0,
'gdpr_consent', bidRequest.gdprConsent.consentString
);
}
}
}

if (visitor !== null && typeof visitor === 'object') {
utils._each(visitor, (item, key) => data.push(`tg_v.${key}`, item));
}
Expand Down
79 changes: 79 additions & 0 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ describe('the rubicon adapter', () => {
bids: [
{
bidder: 'rubicon',
gdprConsent: {
'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
'consentRequired': true
},
params: {
accountId: '14062',
siteId: '70608',
Expand Down Expand Up @@ -535,6 +539,81 @@ describe('the rubicon adapter', () => {
expect(window.DigiTrust.getUser.calledOnce).to.equal(true);
});
});

it('should send GDPR params when enabled', () => {
sandbox.stub(config, 'getConfig').callsFake((key) => {
var config = {
consentManagement: {
cmp: 'iab',
waitForConsentTimeout: 4000,
lookUpFailureResolution: 'cancel'
}
};
return config[key];
});

let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let data = parseQuery(request.data);
let expectedQuery = {
'gdpr': '1',
'gdpr_consent': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A=='
};

// test that all values above are both present and correct
Object.keys(expectedQuery).forEach(key => {
let value = expectedQuery[key];
expect(data[key]).to.equal(value);
});
});

it('should not send GDPR params if not enabled', () => {
sandbox.stub(config, 'getConfig').callsFake((key) => {
var config = {};
return config[key];
});

let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let data = parseQuery(request.data);
let expectedQuery = {
'gdpr': undefined,
'gdpr_consent': undefined
};

// test that all values above are both present and correct
Object.keys(expectedQuery).forEach(key => {
let value = expectedQuery[key];
expect(data[key]).to.equal(value);
});
});

it('should not send GDPR params if bidRequest does not pass gdprConsent', () => {
sandbox.stub(config, 'getConfig').callsFake((key) => {
var config = {
consentManagement: {
cmp: 'iab',
waitForConsentTimeout: 4000,
lookUpFailureResolution: 'cancel'
}
};
return config[key];
});

// Remove gdprConsent from bidRequest
delete bidderRequest.bids[0].gdprConsent;

let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let data = parseQuery(request.data);
let expectedQuery = {
'gdpr': undefined,
'gdpr_consent': undefined
};

// test that all values above are both present and correct
Object.keys(expectedQuery).forEach(key => {
let value = expectedQuery[key];
expect(data[key]).to.equal(value);
});
});
});

describe('for video requests', () => {
Expand Down