-
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
Yahoo Bid Adapter: Rebrand to Yahoo Advertising #10125
Changes from 2 commits
7178f8c
98ac9eb
f11d726
95cf40d
3ee9438
2f4fc5b
10b6684
d3ec6fd
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 | ||
---|---|---|---|---|
|
@@ -6,9 +6,9 @@ import { Renderer } from '../src/Renderer.js'; | |||
import {hasPurpose1Consent} from '../src/utils/gpdr.js'; | ||||
|
||||
const INTEGRATION_METHOD = 'prebid.js'; | ||||
const BIDDER_CODE = 'yahoossp'; | ||||
const BIDDER_CODE = 'yahooAdvertising'; | ||||
const BIDDER_ALIASES = ['yahoossp'] | ||||
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. maybe yahoo as well? You are welcome to change your bidder code and alias the old adapter, however, changing the filename is breaking because of the build instructions. Line 170 in a35cda0
You'll have to wait for prebid 9 to do that. We just shipped Prebid 8 last week. |
||||
const GVLID = 25; | ||||
const ADAPTER_VERSION = '1.0.2'; | ||||
const PREBID_VERSION = '$prebid.version$'; | ||||
const DEFAULT_BID_TTL = 300; | ||||
const TEST_MODE_DCN = '8a969516017a7a396ec539d97f540011'; | ||||
|
@@ -49,13 +49,17 @@ const SUPPORTED_USER_ID_SOURCES = [ | |||
'quantcast.com', | ||||
'tapad.com', | ||||
'uidapi.com', | ||||
'verizonmedia.com', | ||||
'yahoo.com', | ||||
'zeotap.com' | ||||
]; | ||||
|
||||
/* Utility functions */ | ||||
|
||||
function getConfigValue(bid, key) { | ||||
const bidderCode = bid.bidder || bid.bidderCode; | ||||
return config.getConfig(`${bidderCode}.${key}`); | ||||
} | ||||
|
||||
function getSize(size) { | ||||
return { | ||||
w: parseInt(size[0]), | ||||
|
@@ -155,8 +159,8 @@ function getPubIdMode(bid) { | |||
return pubIdMode; | ||||
}; | ||||
|
||||
function getAdapterMode() { | ||||
let adapterMode = config.getConfig('yahoossp.mode'); | ||||
function getAdapterMode(bid) { | ||||
let adapterMode = getConfigValue(bid, 'mode'); | ||||
adapterMode = adapterMode ? adapterMode.toLowerCase() : undefined; | ||||
if (typeof adapterMode === 'undefined' || adapterMode === BANNER) { | ||||
return BANNER; | ||||
|
@@ -177,7 +181,7 @@ function getResponseFormat(bid) { | |||
}; | ||||
|
||||
function getFloorModuleData(bid) { | ||||
const adapterMode = getAdapterMode(); | ||||
const adapterMode = getAdapterMode(bid); | ||||
const getFloorRequestObject = { | ||||
currency: deepAccess(bid, 'params.bidOverride.cur') || DEFAULT_CURRENCY, | ||||
mediaType: adapterMode, | ||||
|
@@ -187,7 +191,7 @@ function getFloorModuleData(bid) { | |||
}; | ||||
|
||||
function filterBidRequestByMode(validBidRequests) { | ||||
const mediaTypesMode = getAdapterMode(); | ||||
const mediaTypesMode = getAdapterMode(validBidRequests[0]); | ||||
let result = []; | ||||
if (mediaTypesMode === BANNER) { | ||||
result = validBidRequests.filter(bid => { | ||||
|
@@ -244,7 +248,7 @@ function validateAppendObject(validationType, allowedKeys, inputObject, appendTo | |||
}; | ||||
|
||||
function getTtl(bidderRequest) { | ||||
const globalTTL = config.getConfig('yahoossp.ttl'); | ||||
const globalTTL = getConfigValue(bidderRequest, 'ttl'); | ||||
return globalTTL ? validateTTL(globalTTL) : validateTTL(deepAccess(bidderRequest, 'params.ttl')); | ||||
}; | ||||
|
||||
|
@@ -283,7 +287,6 @@ function generateOpenRtbObject(bidderRequest, bid) { | |||
source: { | ||||
ext: { | ||||
hb: 1, | ||||
adapterver: ADAPTER_VERSION, | ||||
prebidver: PREBID_VERSION, | ||||
integration: { | ||||
name: INTEGRATION_METHOD, | ||||
|
@@ -332,7 +335,7 @@ function generateOpenRtbObject(bidderRequest, bid) { | |||
}; | ||||
|
||||
function appendImpObject(bid, openRtbObject) { | ||||
const mediaTypeMode = getAdapterMode(); | ||||
const mediaTypeMode = getAdapterMode(bid); | ||||
|
||||
if (openRtbObject && bid) { | ||||
const impObject = { | ||||
|
@@ -494,20 +497,21 @@ function appendFirstPartyData(outBoundBidRequest, bid) { | |||
|
||||
function generateServerRequest({payload, requestOptions, bidderRequest}) { | ||||
const pubIdMode = getPubIdMode(bidderRequest); | ||||
let sspEndpoint = config.getConfig('yahoossp.endpoint') || SSP_ENDPOINT_DCN_POS; | ||||
const overrideEndpoint = getConfigValue(bidderRequest, 'endpoint'); | ||||
let sspEndpoint = overrideEndpoint || SSP_ENDPOINT_DCN_POS; | ||||
|
||||
if (pubIdMode === true) { | ||||
sspEndpoint = config.getConfig('yahoossp.endpoint') || SSP_ENDPOINT_PUBID; | ||||
sspEndpoint = overrideEndpoint || SSP_ENDPOINT_PUBID; | ||||
}; | ||||
|
||||
if (deepAccess(bidderRequest, 'params.testing.e2etest') === true) { | ||||
logInfo('yahoossp adapter e2etest mode is active'); | ||||
logInfo('Adapter e2etest mode is active'); | ||||
requestOptions.withCredentials = false; | ||||
|
||||
if (pubIdMode === true) { | ||||
payload.site.id = TEST_MODE_PUBID_DCN; | ||||
} else { | ||||
const mediaTypeMode = getAdapterMode(); | ||||
const mediaTypeMode = getAdapterMode(bidderRequest); | ||||
payload.site.id = TEST_MODE_DCN; | ||||
payload.imp.forEach(impObject => { | ||||
impObject.ext.e2eTestMode = true; | ||||
|
@@ -516,8 +520,9 @@ function generateServerRequest({payload, requestOptions, bidderRequest}) { | |||
} else if (mediaTypeMode === VIDEO) { | ||||
impObject.tagid = TEST_MODE_VIDEO_POS; // video passback | ||||
} else { | ||||
logWarn('yahoossp adapter e2etest mode does not support yahoossp.mode="all". \n Please specify either "banner" or "video"'); | ||||
logWarn('yahoossp adapter e2etest mode: Please make sure your adUnit matches the yahoossp.mode video or banner'); | ||||
const bidderCode = bidderRequest.bidderCode; | ||||
logWarn(`e2etest mode does not support ${bidderCode}.mode="all". \n Please specify either "banner" or "video"`); | ||||
logWarn(`Adapter e2etest mode: Please make sure your adUnit matches the ${bidderCode}.mode video or banner`); | ||||
} | ||||
}); | ||||
} | ||||
|
@@ -528,7 +533,7 @@ function generateServerRequest({payload, requestOptions, bidderRequest}) { | |||
method: 'POST', | ||||
data: payload, | ||||
options: requestOptions, | ||||
bidderRequest: bidderRequest | ||||
bidderRequest // Additional data for use in interpretResponse() | ||||
}; | ||||
}; | ||||
|
||||
|
@@ -547,7 +552,7 @@ function createRenderer(bidderRequest, bidResponse) { | |||
}, deepAccess(bidderRequest, 'params.testing.renderer.setTimeout') || DEFAULT_RENDERER_TIMEOUT); | ||||
}); | ||||
} catch (error) { | ||||
logWarn('yahoossp renderer error: setRender() failed', error); | ||||
logWarn('Renderer error: setRender() failed', error); | ||||
} | ||||
return renderer; | ||||
} | ||||
|
@@ -557,7 +562,7 @@ function createRenderer(bidderRequest, bidResponse) { | |||
export const spec = { | ||||
code: BIDDER_CODE, | ||||
gvlid: GVLID, | ||||
aliases: [], | ||||
aliases: BIDDER_ALIASES, | ||||
supportedMediaTypes: [BANNER, VIDEO], | ||||
|
||||
isBidRequestValid: function(bid) { | ||||
|
@@ -570,14 +575,14 @@ export const spec = { | |||
) { | ||||
return true; | ||||
} else { | ||||
logWarn('yahoossp bidder params missing or incorrect, please pass object with either: dcn & pos OR pubId'); | ||||
logWarn('Bidder params missing or incorrect, please pass object with either: dcn & pos OR pubId'); | ||||
return false; | ||||
} | ||||
}, | ||||
|
||||
buildRequests: function(validBidRequests, bidderRequest) { | ||||
if (isEmpty(validBidRequests) || isEmpty(bidderRequest)) { | ||||
logWarn('yahoossp Adapter: buildRequests called with either empty "validBidRequests" or "bidderRequest"'); | ||||
logWarn('buildRequests called with either empty "validBidRequests" or "bidderRequest"'); | ||||
return undefined; | ||||
}; | ||||
|
||||
|
@@ -592,13 +597,12 @@ export const spec = { | |||
|
||||
const filteredBidRequests = filterBidRequestByMode(validBidRequests); | ||||
|
||||
if (config.getConfig('yahoossp.singleRequestMode') === true) { | ||||
if (getConfigValue(bidderRequest, 'singleRequestMode') === true) { | ||||
const payload = generateOpenRtbObject(bidderRequest, filteredBidRequests[0]); | ||||
filteredBidRequests.forEach(bid => { | ||||
appendImpObject(bid, payload); | ||||
}); | ||||
|
||||
return generateServerRequest({payload, requestOptions, bidderRequest}); | ||||
return [generateServerRequest({payload, requestOptions, bidderRequest})]; | ||||
} | ||||
|
||||
return filteredBidRequests.map(bid => { | ||||
|
@@ -608,12 +612,11 @@ export const spec = { | |||
}); | ||||
}, | ||||
|
||||
interpretResponse: function(serverResponse, { data, bidderRequest }) { | ||||
interpretResponse: function(serverResponse, { bidderRequest }) { | ||||
const response = []; | ||||
if (!serverResponse.body || !Array.isArray(serverResponse.body.seatbid)) { | ||||
return response; | ||||
} | ||||
|
||||
let seatbids = serverResponse.body.seatbid; | ||||
seatbids.forEach(seatbid => { | ||||
let bid; | ||||
|
@@ -628,7 +631,6 @@ export const spec = { | |||
|
||||
let bidResponse = { | ||||
adId: deepAccess(bid, 'adId') ? bid.adId : bid.impid || bid.crid, | ||||
adUnitCode: bidderRequest.adUnitCode, | ||||
requestId: bid.impid, | ||||
cpm: cpm, | ||||
width: bid.w, | ||||
|
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.
this will be quite annoying for publishers, as the key names in gam are restricted to 20 characters
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.
Yes, I thought this too. We will go back to product with this issue to get their thoughts on it