Skip to content

Commit

Permalink
Playground xyz - GDPR integration. (prebid#2699)
Browse files Browse the repository at this point in the history
* add playground adapters

* clean up

* update with upstream master

* add test file clean up adapter by removing native referecnes

* test file

* replace appnexus with playground reference in error logs

* remove commented code

* change key in response object from appnexus to playgroundxyz

* change tests so we test for ordering by cpm as well

* dont drop other bids, just set cpm to 0 and send it through

* clean up

* restore glulp file

* fix documentation

* remove cpm logic from adapter

* change application type to application\json for playground adapter

* update adaptor to use openRtb

* add device and site to bid

* add extra space on error msg

* remove package-lock

* update pg details

* Update playgroundxyzBidAdapter.md

* add GDPR
remove video sample config form .md file
  • Loading branch information
teranchristian authored and florevallatmrf committed Sep 6, 2018
1 parent fc72152 commit c0b3e9a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 45 deletions.
12 changes: 9 additions & 3 deletions modules/playgroundxyzBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const spec = {
*/
buildRequests: function (bidRequests, bidderRequest) {
const topLocation = utils.getTopWindowLocation();
const payload = JSON.stringify({
const payload = {
id: bidRequests[0].auctionId,
site: {
domain: window.location.protocol + '//' + topLocation.hostname,
Expand All @@ -41,17 +41,23 @@ export const spec = {
devicetype: isMobile() ? 1 : isConnectedTV() ? 3 : 2,
},
imp: bidRequests.map(mapImpression)
});
};

const options = {
contentType: 'application/json',
withCredentials: false
};

if (bidderRequest && bidderRequest.gdprConsent) {
payload.user = {ext: {consent: bidderRequest.gdprConsent.consentString}};
const gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0;
payload.regs = {ext: {gdpr: gdpr}};
}

return {
method: 'POST',
url: URL,
data: payload,
data: JSON.stringify(payload),
options,
bidderRequest
};
Expand Down
42 changes: 0 additions & 42 deletions modules/playgroundxyzBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,48 +25,6 @@ var adUnits = [
placementId: '10433394'
}
}]
},
// Video instream adUnit
{
code: 'video-instream',
sizes: [640, 480],
mediaTypes: {
video: {
context: 'instream'
},
},
bids: [{
bidder: 'playgroundxyz',
params: {
placementId: '9333431',
video: {
skippable: true,
playback_methods: ['auto_play_sound_off']
}
}
}]
},
// Video outstream adUnit
{
code: 'video-outstream',
sizes: [[640, 480]],
mediaTypes: {
video: {
context: 'outstream'
}
},
bids: [
{
bidder: 'playgroundxyz',
params: {
placementId: '5768085',
video: {
skippable: true,
playback_method: ['auto_play_sound_off']
}
}
}
]
}
];
```
49 changes: 49 additions & 0 deletions test/spec/modules/playgroundxyzBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { newBidder } from 'src/adapters/bidderFactory';
import { deepClone } from 'src/utils';

const URL = 'https://ads.playground.xyz/host-config/prebid';
const GDPR_CONSENT = 'XYZ-CONSENT';

describe('playgroundxyzBidAdapter', () => {
const adapter = newBidder(spec);
Expand Down Expand Up @@ -133,4 +134,52 @@ describe('playgroundxyzBidAdapter', () => {
expect(result.length).to.equal(0);
});
});

describe('buildRequests', () => {
let bidRequests = [
{
'bidder': 'playgroundxyz',
'params': {
'publisherId': 'PUB_FAKE'
},
'adUnitCode': 'adunit-code',
'sizes': [[300, 250]],
'bidId': '321db112312as',
'bidderRequestId': '23edabce2731sd6',
'auctionId': '12as040790a475'
}
];

it('should not populate GDPR', () => {
let bidRequest = Object.assign([], bidRequests);
const request = spec.buildRequests(bidRequest);
let data = JSON.parse(request.data);
expect(data).to.not.have.property('user');
expect(data).to.not.have.property('regs');
});

it('should populate GDPR and consent string when consetString is presented but not gdpApplies', () => {
let bidRequest = Object.assign([], bidRequests);
const request = spec.buildRequests(bidRequest, {gdprConsent: {consentString: GDPR_CONSENT}});
let data = JSON.parse(request.data);
expect(data.regs.ext.gdpr).to.equal(0);
expect(data.user.ext.consent).to.equal('XYZ-CONSENT');
});

it('should populate GDPR and consent string when gdpr is set to true', () => {
let bidRequest = Object.assign([], bidRequests);
const request = spec.buildRequests(bidRequest, {gdprConsent: {gdprApplies: true, consentString: GDPR_CONSENT}});
let data = JSON.parse(request.data);
expect(data.regs.ext.gdpr).to.equal(1);
expect(data.user.ext.consent).to.equal('XYZ-CONSENT');
});

it('should populate GDPR and consent string when gdpr is set to false', () => {
let bidRequest = Object.assign([], bidRequests);
const request = spec.buildRequests(bidRequest, {gdprConsent: {gdprApplies: false, consentString: GDPR_CONSENT}});
let data = JSON.parse(request.data);
expect(data.regs.ext.gdpr).to.equal(0);
expect(data.user.ext.consent).to.equal('XYZ-CONSENT');
});
});
});

0 comments on commit c0b3e9a

Please sign in to comment.