Skip to content

Commit

Permalink
Districtm Dmx adding Coppa support (prebid#4997)
Browse files Browse the repository at this point in the history
* idsync support ccpa & gdpr

* adding support for COPPA

* using proposition to change COPPA setting in dmx adapter

* adding support for liveramp

* update md file
  • Loading branch information
stevealliance authored and iggyfisk committed Jun 22, 2020
1 parent 485829a commit b9c3679
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 4 deletions.
25 changes: 25 additions & 0 deletions modules/districtmDMXBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const spec = {
publisher: { id: String(bidRequest[0].params.memberid) || null }
}
}

try {
let params = config.getConfig('dmx');
dmxRequest.user = params.user || {};
Expand All @@ -80,6 +81,14 @@ export const spec = {
} catch (e) {

}

let eids = [];
if (bidRequest && bidRequest.userId) {
bindUserId(eids, utils.deepAccess(bidRequest, `userId.idl_env`), 'liveramp.com', 1);
dmxRequest.user = dmxRequest.user || {};
dmxRequest.user.ext = dmxRequest.user.ext || {};
dmxRequest.user.ext.eids = eids;
}
if (!dmxRequest.test) {
delete dmxRequest.test;
}
Expand All @@ -91,6 +100,8 @@ export const spec = {
dmxRequest.user.ext = {};
dmxRequest.user.ext.consent = bidderRequest.gdprConsent.consentString;
}
dmxRequest.regs = dmxRequest.regs || {};
dmxRequest.regs.coppa = config.getConfig('coppa') === true ? 1 : 0;
if (bidderRequest && bidderRequest.uspConsent) {
dmxRequest.regs = dmxRequest.regs || {};
dmxRequest.regs.ext = dmxRequest.regs.ext || {};
Expand Down Expand Up @@ -281,4 +292,18 @@ export function defaultSize(thebidObj) {
returnObject.height = checkDeepArray(sizes)[1];
return returnObject;
}

export function bindUserId(eids, value, source, atype) {
if (utils.isStr(value) && Array.isArray(eids)) {
eids.push({
source,
uids: [
{
id: value,
atype
}
]
})
}
}
registerBidder(spec);
9 changes: 7 additions & 2 deletions modules/districtmDmxBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ The `districtmDmxAdapter` module allows publishers to include DMX Exchange deman
* Single Request
* Multi-Size Support
* GDPR Compliant
* CCPA Compliant
* COPPA Compliant
* Bids returned in **NET**

## Media Types
Expand All @@ -23,8 +25,8 @@ The `districtmDmxAdapter` module allows publishers to include DMX Exchange deman

| Key | Scope | Type | Description
| --- | --- | --- | ---
| dmxid | Mandatory | Integer | Unique identifier of the placement, dmxid can be obtained in the district m Boost platform.
| memberid | Mandatory | Integer | Unique identifier for your account, memberid can be obtained in the district m Boost platform.
| `dmxid` | Mandatory | Integer | Unique identifier of the placement, dmxid can be obtained in the district m Boost platform.
| `memberid` | Mandatory | Integer | Unique identifier for your account, memberid can be obtained in the district m Boost platform.

# Ad Unit Configuration Example

Expand All @@ -47,6 +49,9 @@ The `districtmDmxAdapter` module allows publishers to include DMX Exchange deman
```


# Ad Unit Configuration when COPPA is needed


# Quick Start Guide

###### 1. Including the `districtmDmxAdapter` in your build process.
Expand Down
57 changes: 55 additions & 2 deletions test/spec/modules/districtmDmxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const bidRequest = [{
'bidder': 'districtmDMX',
'params': {
'dmxid': 100001,
'memberid': 100003
'memberid': 100003,
},
'adUnitCode': 'div-gpt-ad-12345678-1',
'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2',
Expand All @@ -53,6 +53,22 @@ const bidRequest = [{
'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf'
}];

const bidRequestNoCoppa = [{
'bidder': 'districtmDMX',
'params': {
'dmxid': 100001,
'memberid': 100003
},
'adUnitCode': 'div-gpt-ad-12345678-1',
'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2',
'sizes': [
[300, 250],
[300, 600]
],
'bidId': '29a28a1bbc8a8d',
'bidderRequestId': '124b579a136515',
'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf'
}];
const bidderRequest = {
'bidderCode': 'districtmDMX',
'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf',
Expand All @@ -61,7 +77,7 @@ const bidderRequest = {
'bidder': 'districtmDMX',
'params': {
'dmxid': 100001,
'memberid': 100003
'memberid': 100003,
},
'adUnitCode': 'div-gpt-ad-12345678-1',
'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2',
Expand Down Expand Up @@ -420,6 +436,32 @@ const bidderRequest = {
'doneCbCallCount': 0
};

const bidderRequestNoCoppa = {
'bidderCode': 'districtmDMX',
'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf',
'bidderRequestId': '124b579a136515',
'bids': [{
'bidder': 'districtmDMX',
'params': {
'dmxid': 100001,
'memberid': 100003,
},
'adUnitCode': 'div-gpt-ad-12345678-1',
'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2',
'sizes': [
[300, 250],
[300, 600]
],
'bidId': '29a28a1bbc8a8d',
'bidderRequestId': '124b579a136515',
'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf'
}],
'auctionStart': 1529511035677,
'timeout': 700,
'start': 1529511035686,
'doneCbCallCount': 0
};

const responses = {
'body': {
'id': '1f45b37c-5298-4934-b517-4d911aadabfd',
Expand Down Expand Up @@ -522,6 +564,7 @@ describe('DistrictM Adaptor', function () {

describe(`buildRequests test usage`, function () {
const buildRequestResults = districtm.buildRequests(bidRequest, bidderRequest);
const buildRequestResultsNoCoppa = districtm.buildRequests(bidRequestNoCoppa, bidderRequestNoCoppa);
it(`the function should return an array`, function () {
expect(buildRequestResults).to.be.an('object');
});
Expand All @@ -531,6 +574,16 @@ describe('DistrictM Adaptor', function () {
expect(bidr.regs.ext.us_privacy).to.be.equal('1NY');
expect(bidr.user.ext.consent).to.be.an('string');
});
it(`test contain COPPA`, function() {
const bidr = JSON.parse(buildRequestResults.data)
bidr.regs = bidr.regs || {};
bidr.regs.coppa = 1;
expect(bidr.regs.coppa).to.be.equal(1)
})
it(`test should not contain COPPA`, function() {
const bidr = JSON.parse(buildRequestResultsNoCoppa.data)
expect(bidr.regs.coppa).to.be.equal(0)
})
it(`the function should return array length of 1`, function () {
expect(buildRequestResults.data).to.be.a('string');
});
Expand Down

0 comments on commit b9c3679

Please sign in to comment.