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

Sonobi Adapter GDPR Support #2582

Merged
merged 3 commits into from
May 23, 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: 8 additions & 2 deletions modules/sonobiBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const spec = {
* @param {BidRequest[]} validBidRequests - an array of bids
* @return {object} ServerRequest - Info describing the request to the server.
*/
buildRequests: (validBidRequests) => {
buildRequests: (validBidRequests, bidderRequest) => {
const bids = validBidRequests.map(bid => {
let slotIdentifier = _validateSlot(bid);
if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)) {
Expand Down Expand Up @@ -61,7 +61,13 @@ export const spec = {
payload.ref = validBidRequests[0].params.referrer;
}

// If there is no key_maker data, then dont make the request.
// Apply GDPR parameters to request.
if (bidderRequest && bidderRequest.gdprConsent) {
payload.gdpr = bidderRequest.gdprConsent.gdprApplies ? 'true' : 'false';
payload.consent_string = bidderRequest.gdprConsent.consentString;
}

// If there is no key_maker data, then don't make the request.
if (isEmpty(data)) {
return null;
}
Expand Down
26 changes: 26 additions & 0 deletions test/spec/modules/sonobiBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ describe('SonobiBidAdapter', () => {
'/7780971/sparks_prebid_LB|30b31c1838de1e': '300x250,300x600',
};

let bidderRequests = {
'gdprConsent': {
'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==',
'vendorData': {},
'gdprApplies': true
},
};

it('should return a properly formatted request', () => {
const bidRequests = spec.buildRequests(bidRequest)
const bidRequestsPageViewID = spec.buildRequests(bidRequest)
Expand All @@ -145,6 +153,23 @@ describe('SonobiBidAdapter', () => {
expect(['mobile', 'tablet', 'desktop']).to.contain(bidRequests.data.vp);
})

it('should return a properly formatted request with GDPR applies set to true', () => {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json')
expect(bidRequests.method).to.equal('GET')
expect(bidRequests.data.gdpr).to.equal('true')
expect(bidRequests.data.consent_string).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==')
})

it('should return a properly formatted request with GDPR applies set to false', () => {
bidderRequests.gdprConsent.gdprApplies = false;
const bidRequests = spec.buildRequests(bidRequest, bidderRequests)
expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json')
expect(bidRequests.method).to.equal('GET')
expect(bidRequests.data.gdpr).to.equal('false')
expect(bidRequests.data.consent_string).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==')
})

it('should return a properly formatted request with hfa', () => {
bidRequest[0].params.hfa = 'hfakey'
bidRequest[1].params.hfa = 'hfakey'
Expand All @@ -155,6 +180,7 @@ describe('SonobiBidAdapter', () => {
expect(bidRequests.data.s).not.to.be.empty
expect(bidRequests.data.hfa).to.equal('hfakey')
})

it('should return null if there is nothing to bid on', () => {
const bidRequests = spec.buildRequests([{params: {}}])
expect(bidRequests).to.equal(null);
Expand Down