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

Added GDPR consent management to YOC VIS.X Bid Adapter #2737

Merged
merged 1 commit into from
Jun 19, 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
24 changes: 21 additions & 3 deletions modules/visxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const spec = {
isBidRequestValid: function(bid) {
return !!bid.params.uid;
},
buildRequests: function(validBidRequests) {
buildRequests: function(validBidRequests, bidderRequest) {
const auids = [];
const bidsMap = {};
const bids = validBidRequests || [];
Expand Down Expand Up @@ -55,6 +55,15 @@ export const spec = {
cur: currency,
};

if (bidderRequest && bidderRequest.gdprConsent) {
if (bidderRequest.gdprConsent.consentString) {
payload.gdpr_consent = bidderRequest.gdprConsent.consentString;
}
payload.gdpr_applies =
(typeof bidderRequest.gdprConsent.gdprApplies === 'boolean')
? Number(bidderRequest.gdprConsent.gdprApplies) : 1;
}

return {
method: 'GET',
url: ENDPOINT_URL,
Expand Down Expand Up @@ -84,11 +93,20 @@ export const spec = {
if (errorMessage) utils.logError(errorMessage);
return bidResponses;
},
getUserSyncs: function(syncOptions) {
getUserSyncs: function(syncOptions, serverResponses, gdprConsent) {
if (syncOptions.pixelEnabled) {
var query = [];
if (gdprConsent) {
if (gdprConsent.consentString) {
query.push('gdpr_consent=' + encodeURIComponent(gdprConsent.consentString));
}
query.push('gdpr_applies=' + encodeURIComponent(
(typeof gdprConsent.gdprApplies === 'boolean')
? Number(gdprConsent.gdprApplies) : 1));
}
return [{
type: 'image',
url: ADAPTER_SYNC_URL
url: ADAPTER_SYNC_URL + (query.length ? '?' + query.join('&') : '')
}];
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/visxBidAdapter.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Overview

```
Module Name: VIS.X Bidder Adapter
Module Name: YOC VIS.X Bidder Adapter
Module Type: Bidder Adapter
Maintainer: service@yoc.com
```

# Description

Module that connects to VIS.X demand source to fetch bids.
Module that connects to YOC VIS.X® demand source to fetch bids.

# Test Parameters
```
Expand Down
23 changes: 23 additions & 0 deletions test/spec/modules/visxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,29 @@ describe('VisxAdapter', function () {
expect(payload).to.have.property('cur', 'USD');
getConfigStub.restore();
});
it('if gdprConsent is present payload must have gdpr params', () => {
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}});
const payload = request.data;
expect(payload).to.be.an('object');
expect(payload).to.have.property('gdpr_consent', 'AAA');
expect(payload).to.have.property('gdpr_applies', 1);
});

it('if gdprApplies is false gdpr_applies must be 0', () => {
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: false}});
const payload = request.data;
expect(payload).to.be.an('object');
expect(payload).to.have.property('gdpr_consent', 'AAA');
expect(payload).to.have.property('gdpr_applies', 0);
});

it('if gdprApplies is undefined gdpr_applies must be 1', () => {
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA'}});
const payload = request.data;
expect(payload).to.be.an('object');
expect(payload).to.have.property('gdpr_consent', 'AAA');
expect(payload).to.have.property('gdpr_applies', 1);
});
});

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