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

Resetdigital bid Adapter: add fields and suport for coppa #9400

Merged
merged 9 commits into from
Feb 24, 2023
65 changes: 61 additions & 4 deletions modules/resetdigitalBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

import { timestamp, deepAccess } from '../src/utils.js';
import { timestamp, deepAccess, isStr, deepClone } from '../src/utils.js';
import { getOrigin } from '../libraries/getOrigin/index.js';
import { config } from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER} from '../src/mediaTypes.js';

const BIDDER_CODE = 'resetdigital';
const CURRENCY = 'USD';

export const spec = {
code: BIDDER_CODE,
Expand Down Expand Up @@ -43,16 +45,70 @@ export const spec = {
};
}

if (bidderRequest && bidderRequest.uspConsent) {
payload.ccpa = bidderRequest.uspConsent;
}

function getOrtb2Keywords(ortb2Obj) {
const fields = ['site.keywords', 'site.content.keywords', 'user.keywords', 'app.keywords', 'app.content.keywords'];
let result = [];

fields.forEach(path => {
let keyStr = deepAccess(ortb2Obj, path);
if (isStr(keyStr)) result.push(keyStr);
});
return result;
}

// get the ortb2 keywords data (if it exists)
let ortb2 = deepClone(bidderRequest && bidderRequest.ortb2);
let ortb2KeywordsList = getOrtb2Keywords(ortb2);
// get meta keywords data (if it exists)
let metaKeywords = document.getElementsByTagName('meta')['keywords'];
if (metaKeywords && metaKeywords.content) {
metaKeywords = metaKeywords.content.split(',');
}

for (let x = 0; x < validBidRequests.length; x++) {
let req = validBidRequests[x]
let req = validBidRequests[x];

let bidFloor = req.params.bidFloor ? req.params.bidFloor : null;
let bidFloorCur = req.params.bidFloor ? req.params.bidFloorCur : null;

if (typeof req.getFloor === 'function') {
const floorInfo = req.getFloor({
currency: CURRENCY,
mediaType: BANNER,
size: '*'
});
if (typeof floorInfo === 'object' && floorInfo.currency === CURRENCY && !isNaN(parseFloat(floorInfo.floor))) {
bidFloor = parseFloat(floorInfo.floor);
bidFloorCur = CURRENCY;
}
}

// get param kewords (if it exists)
let paramsKeywords = req.params.keywords ? req.params.keywords.split(',') : [];
// merge all keywords
let keywords = ortb2KeywordsList.concat(paramsKeywords).concat(metaKeywords);

payload.imps.push({
pub_id: req.params.pubId,
site_id: req.params.siteID ? req.params.siteID : null,
placement_id: req.params.placement ? req.params.placement : null,
position: req.params.position ? req.params.position : null,
bid_floor: bidFloor,
bid_floor_cur: bidFloorCur,
lat_long: req.params.latLong ? req.params.latLong : null,
inventory: req.params.inventory ? req.params.inventory : null,
visitor: req.params.visitor ? req.params.visitor : null,
keywords: keywords.join(','),
zone_id: req.params.zoneId,
bid_id: req.bidId,
imp_id: req.transactionId,
sizes: req.sizes,
force_bid: req.params.forceBid,
coppa: config.getConfig('coppa') === true ? 1 : 0,
media_types: deepAccess(req, 'mediaTypes')
});
}
Expand All @@ -62,7 +118,8 @@ export const spec = {
return {
method: 'POST',
url: url,
data: JSON.stringify(payload)
data: JSON.stringify(payload),
bids: validBidRequests
};
},
interpretResponse: function(serverResponse, bidRequest) {
Expand Down
28 changes: 27 additions & 1 deletion modules/resetdigitalBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,43 @@ Video is supported but requires a publisher supplied renderer at this time.
mediaTypes: {
banner: {
sizes: [[300,250]]
},

},
bids: [
{
bidder: "resetdigital",
params: {
pubId: "your-pub-id",
site_id: "your-site-id",
forceBid: true,
}
}
]
}
];


var videoAdUnits = [
{
code: 'your-div',
mediaTypes: {
video: {
playerSize: [640, 480]
},

},
bids: [
{
bidder: "resetdigital",
params: {
pubId: "your-pub-id",
forceBid: true
site_id: "your-site-id",
forceBid: true,
}
}
]
}
];

```