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

Add GDPR support to GumGum Adapter #2595

Merged
merged 1 commit into from
May 24, 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
7 changes: 6 additions & 1 deletion modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ function isBidRequestValid (bid) {
* @param {validBidRequests[]} - an array of bids
* @return ServerRequest Info describing the request to the server.
*/
function buildRequests (validBidRequests) {
function buildRequests (validBidRequests, bidderRequest) {
const bids = [];
const gdprConsent = Object.assign({ consentString: null, gdprApplies: true }, bidderRequest && bidderRequest.gdprConsent)
Copy link
Collaborator

Choose a reason for hiding this comment

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

In case when gdpr module does not exist in the build, this will always send gdprApplies and gdprConsent to your request payload.

https://github.com/prebid/Prebid.js/blob/master/modules/appnexusBidAdapter.js#L77

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will only send gdprApplies and, at least for us, thats ok. gdprConsent url param is conditional to gdprApplies. Check lines 127-129

data.gdprApplies = gdprConsent.gdprApplies;
if (gdprConsent.gdprApplies) {
  data.gdprConsent = gdprConsent.consentString;
}

Do you need us to change this?

utils._each(validBidRequests, bidRequest => {
const timeout = config.getConfig('bidderTimeout');
const {
Expand All @@ -123,6 +124,10 @@ function buildRequests (validBidRequests) {
data.ni = parseInt(params.ICV, 10);
data.pi = 5;
}
data.gdprApplies = gdprConsent.gdprApplies;
if (gdprConsent.gdprApplies) {
data.gdprConsent = gdprConsent.consentString;
}

bids.push({
id: bidId,
Expand Down
16 changes: 14 additions & 2 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,24 @@ describe('gumgumAdapter', () => {
];

it('sends bid request to ENDPOINT via GET', () => {
const requests = spec.buildRequests(bidRequests);
const request = requests[0];
const request = spec.buildRequests(bidRequests)[0];
expect(request.url).to.equal(ENDPOINT);
expect(request.method).to.equal('GET');
expect(request.id).to.equal('30b31c1838de1e');
});
it('should add consent parameters if gdprConsent is present', () => {
const gdprConsent = { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', gdprApplies: true };
const fakeBidRequest = { gdprConsent: gdprConsent };
const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0];
expect(bidRequest.data.gdprApplies).to.eq(true);
expect(bidRequest.data.gdprConsent).to.eq('BOJ/P2HOJ/P2HABABMAAAAAZ+A==');
});
it('should handle gdprConsent is present but values are undefined case', () => {
const gdprConsent = { consent_string: undefined, gdprApplies: undefined };
const fakeBidRequest = { gdprConsent: gdprConsent };
const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0];
expect(bidRequest.data).to.not.include.any.keys('gdprConsent')
});
})

describe('interpretResponse', () => {
Expand Down