Skip to content

Commit feb2973

Browse files
Resetdigital bid Adapter: add fields and suport for coppa (#9400)
* Resetdigital Bid Adapter: Add custom fields to bid request and GDRP support * fixing comments * fix bidfloor settings * get kewords from request and site meta tag" * fix bild errors --------- Co-authored-by: nicolas taglienti <[email protected]>
1 parent fb675de commit feb2973

File tree

2 files changed

+88
-5
lines changed

2 files changed

+88
-5
lines changed

modules/resetdigitalBidAdapter.js

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
2-
import { timestamp, deepAccess } from '../src/utils.js';
1+
import { timestamp, deepAccess, isStr, deepClone } from '../src/utils.js';
32
import { getOrigin } from '../libraries/getOrigin/index.js';
43
import { config } from '../src/config.js';
54
import {registerBidder} from '../src/adapters/bidderFactory.js';
5+
import {BANNER} from '../src/mediaTypes.js';
6+
67
const BIDDER_CODE = 'resetdigital';
8+
const CURRENCY = 'USD';
79

810
export const spec = {
911
code: BIDDER_CODE,
@@ -43,16 +45,70 @@ export const spec = {
4345
};
4446
}
4547

48+
if (bidderRequest && bidderRequest.uspConsent) {
49+
payload.ccpa = bidderRequest.uspConsent;
50+
}
51+
52+
function getOrtb2Keywords(ortb2Obj) {
53+
const fields = ['site.keywords', 'site.content.keywords', 'user.keywords', 'app.keywords', 'app.content.keywords'];
54+
let result = [];
55+
56+
fields.forEach(path => {
57+
let keyStr = deepAccess(ortb2Obj, path);
58+
if (isStr(keyStr)) result.push(keyStr);
59+
});
60+
return result;
61+
}
62+
63+
// get the ortb2 keywords data (if it exists)
64+
let ortb2 = deepClone(bidderRequest && bidderRequest.ortb2);
65+
let ortb2KeywordsList = getOrtb2Keywords(ortb2);
66+
// get meta keywords data (if it exists)
67+
let metaKeywords = document.getElementsByTagName('meta')['keywords'];
68+
if (metaKeywords && metaKeywords.content) {
69+
metaKeywords = metaKeywords.content.split(',');
70+
}
71+
4672
for (let x = 0; x < validBidRequests.length; x++) {
47-
let req = validBidRequests[x]
73+
let req = validBidRequests[x];
74+
75+
let bidFloor = req.params.bidFloor ? req.params.bidFloor : null;
76+
let bidFloorCur = req.params.bidFloor ? req.params.bidFloorCur : null;
77+
78+
if (typeof req.getFloor === 'function') {
79+
const floorInfo = req.getFloor({
80+
currency: CURRENCY,
81+
mediaType: BANNER,
82+
size: '*'
83+
});
84+
if (typeof floorInfo === 'object' && floorInfo.currency === CURRENCY && !isNaN(parseFloat(floorInfo.floor))) {
85+
bidFloor = parseFloat(floorInfo.floor);
86+
bidFloorCur = CURRENCY;
87+
}
88+
}
89+
90+
// get param kewords (if it exists)
91+
let paramsKeywords = req.params.keywords ? req.params.keywords.split(',') : [];
92+
// merge all keywords
93+
let keywords = ortb2KeywordsList.concat(paramsKeywords).concat(metaKeywords);
4894

4995
payload.imps.push({
5096
pub_id: req.params.pubId,
97+
site_id: req.params.siteID ? req.params.siteID : null,
98+
placement_id: req.params.placement ? req.params.placement : null,
99+
position: req.params.position ? req.params.position : null,
100+
bid_floor: bidFloor,
101+
bid_floor_cur: bidFloorCur,
102+
lat_long: req.params.latLong ? req.params.latLong : null,
103+
inventory: req.params.inventory ? req.params.inventory : null,
104+
visitor: req.params.visitor ? req.params.visitor : null,
105+
keywords: keywords.join(','),
51106
zone_id: req.params.zoneId,
52107
bid_id: req.bidId,
53108
imp_id: req.transactionId,
54109
sizes: req.sizes,
55110
force_bid: req.params.forceBid,
111+
coppa: config.getConfig('coppa') === true ? 1 : 0,
56112
media_types: deepAccess(req, 'mediaTypes')
57113
});
58114
}
@@ -62,7 +118,8 @@ export const spec = {
62118
return {
63119
method: 'POST',
64120
url: url,
65-
data: JSON.stringify(payload)
121+
data: JSON.stringify(payload),
122+
bids: validBidRequests
66123
};
67124
},
68125
interpretResponse: function(serverResponse, bidRequest) {

modules/resetdigitalBidAdapter.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,43 @@ Video is supported but requires a publisher supplied renderer at this time.
2121
mediaTypes: {
2222
banner: {
2323
sizes: [[300,250]]
24+
},
25+
26+
},
27+
bids: [
28+
{
29+
bidder: "resetdigital",
30+
params: {
31+
pubId: "your-pub-id",
32+
site_id: "your-site-id",
33+
forceBid: true,
34+
}
2435
}
36+
]
37+
}
38+
];
39+
40+
41+
var videoAdUnits = [
42+
{
43+
code: 'your-div',
44+
mediaTypes: {
45+
video: {
46+
playerSize: [640, 480]
47+
},
48+
2549
},
2650
bids: [
2751
{
2852
bidder: "resetdigital",
2953
params: {
3054
pubId: "your-pub-id",
31-
forceBid: true
55+
site_id: "your-site-id",
56+
forceBid: true,
3257
}
3358
}
3459
]
3560
}
3661
];
62+
3763
```

0 commit comments

Comments
 (0)