Skip to content

Commit

Permalink
Dctr fixes (prebid#3337)
Browse files Browse the repository at this point in the history
* changes to not show dctr message when none of the adunits have dctr set

* added usage description for dctr and currency params
  • Loading branch information
pm-manasi-moghe authored and Pedro López Jiménez committed Mar 18, 2019
1 parent 31c789f commit 2adadcf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ export const spec = {
payload.site.domain = _getDomainFromURL(payload.site.page);

// set dctr value in site.ext, if present in validBidRequests[0], else ignore
<<<<<<< HEAD
if (validBidRequests[0].params.hasOwnProperty('dctr')) {
dctr = validBidRequests[0].params.dctr;
if (utils.isStr(dctr) && dctr.length > 0) {
Expand Down Expand Up @@ -561,6 +562,33 @@ export const spec = {
BIDDER_CODE +
': dctr value not found in 1st adunit, ignoring values from subsequent adunits'
);
=======
if (dctrArr.length > 0) {
if (validBidRequests[0].params.hasOwnProperty('dctr')) {
dctr = validBidRequests[0].params.dctr;
if (utils.isStr(dctr) && dctr.length > 0) {
var arr = dctr.split('|');
dctr = '';
arr.forEach(val => {
dctr += (val.length > 0) ? (val.trim() + '|') : '';
});
dctrLen = dctr.length;
if (dctr.substring(dctrLen, dctrLen - 1) === '|') {
dctr = dctr.substring(0, dctrLen - 1);
}
payload.site.ext = {
key_val: dctr.trim()
}
} else {
utils.logWarn(BIDDER_CODE + ': Ignoring param : dctr with value : ' + dctr + ', expects string-value, found empty or non-string value');
}
if (dctrArr.length > 1) {
utils.logWarn(BIDDER_CODE + ': dctr value found in more than 1 adunits. Value from 1st adunit will be picked. Ignoring values from subsequent adunits');
}
} else {
utils.logWarn(BIDDER_CODE + ': dctr value not found in 1st adunit, ignoring values from subsequent adunits');
}
>>>>>>> Dctr fixes (#3337)
}

_handleEids(payload);
Expand Down
4 changes: 2 additions & 2 deletions modules/pubmaticBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ var adUnits = [
kadpageurl: 'www.test.com', // optional
gender: 'M', // optional
kadfloor: '0.50', // optional
currency: 'AUD' // optional
dctr: 'key1=123|key2=345' // optional
currency: 'AUD' // optional (Value configured only in the 1st adunit will be passed on. < br/> Values if present in subsequent adunits, will be ignored.)
dctr: 'key1=123|key2=345' // optional (Value configured only in the 1st adunit will be passed on. < br/> Values if present in subsequent adunits, will be ignored.)
}
}]
}];
Expand Down

0 comments on commit 2adadcf

Please sign in to comment.