-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
update AdGeneration adapter #3228
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import * as utils from 'src/utils'; | ||
// import {config} from 'src/config'; | ||
import {registerBidder} from 'src/adapters/bidderFactory'; | ||
import {BANNER, NATIVE} from 'src/mediaTypes'; | ||
const ADG_BIDDER_CODE = 'adgeneration'; | ||
|
@@ -15,7 +14,7 @@ export const spec = { | |
* @return boolean True if this is a valid bid, and false otherwise. | ||
*/ | ||
isBidRequestValid: function (bid) { | ||
return !!(bid.params.id); | ||
return !!(bid.params.id) && (isValidCurrency(bid.params.currency)); | ||
}, | ||
/** | ||
* Make a server request from the list of BidRequests. | ||
|
@@ -24,6 +23,7 @@ export const spec = { | |
* @return ServerRequest Info describing the request to the server. | ||
*/ | ||
buildRequests: function (validBidRequests) { | ||
const ADGENE_PREBID_VERSION = '1.0.1'; | ||
let serverRequests = []; | ||
for (let i = 0, len = validBidRequests.length; i < len; i++) { | ||
const validReq = validBidRequests[i]; | ||
|
@@ -38,12 +38,16 @@ export const spec = { | |
data = utils.tryAppendQueryString(data, 'hb', 'true'); | ||
data = utils.tryAppendQueryString(data, 't', 'json3'); | ||
data = utils.tryAppendQueryString(data, 'transactionid', validReq.transactionId); | ||
|
||
data = utils.tryAppendQueryString(data, 'sizes', getSizes(validReq)); | ||
data = utils.tryAppendQueryString(data, 'currency', validReq.params.currency.toUpperCase()); | ||
data = utils.tryAppendQueryString(data, 'pbver', '$prebid.version$'); | ||
data = utils.tryAppendQueryString(data, 'sdkname', 'prebidjs'); | ||
data = utils.tryAppendQueryString(data, 'adapterver', ADGENE_PREBID_VERSION); | ||
// native以外にvideo等の対応が入った場合は要修正 | ||
if (!validReq.mediaTypes || !validReq.mediaTypes.native) { | ||
data = utils.tryAppendQueryString(data, 'imark', '1'); | ||
} | ||
|
||
data = utils.tryAppendQueryString(data, 'tp', utils.getTopWindowUrl()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a deprecated function. Please pull the referrer out of bidRequest.refererInfo. See http://prebid.org/dev-docs/bidder-adaptor.html#referrers |
||
// remove the trailing "&" | ||
if (data.lastIndexOf('&') === data.length - 1) { | ||
data = data.substring(0, data.length - 1); | ||
|
@@ -198,4 +202,34 @@ function removeWrapper(ad) { | |
return ad.substr(bodyIndex, lastBodyIndex).replace('<body>', '').replace('</body>', ''); | ||
} | ||
|
||
/** | ||
* request | ||
* @param validReq request | ||
* @returns {?string} 300x250,320x50... | ||
*/ | ||
function getSizes(validReq) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function assumes valid formatting of the sizes input and will crash on invalid size formatting. Since there are try/catch blocks around the adapter, this isn't necessarily something that needs to get fixed, just pointing it out. |
||
const sizes = validReq.sizes; | ||
if (!sizes || sizes.length < 1) return null; | ||
let sizesStr = null; | ||
for (const i in sizes) { | ||
const size = sizes[i]; | ||
if (sizesStr == null) { | ||
sizesStr = size[0] + 'x' + size[1]; | ||
} else { | ||
sizesStr += ',' + size[0] + 'x' + size[1]; | ||
} | ||
} | ||
return sizesStr; | ||
} | ||
|
||
/** | ||
* @param {?string} currency | ||
* @return {!boolean} | ||
*/ | ||
function isValidCurrency(currency) { | ||
if (!currency) return false; | ||
const upperCurrency = currency.toUpperCase(); | ||
return (upperCurrency === 'JPY' || upperCurrency === 'USD') | ||
} | ||
|
||
registerBidder(spec); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ var adUnits = [ | |
bidder: 'adg', | ||
params: { | ||
id: '58278', // banner | ||
currency: 'JPY', | ||
} | ||
}, | ||
] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend against adding this adapter-specific
bids.params.currency
. The standard way that the publisher is supposed to specify currency is by callingsetConfig
with currency.adServerCurrency. All modules should be reading this value rather than making the publisher specify the currency in each adapter's params.For the full picture see http://prebid.org/dev-docs/modules/currency.html