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

Yahoo Bid Adapter: Rebrand to Yahoo Advertising #10125

Merged
merged 8 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Collaborator

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

image

Copy link
Contributor Author

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

const BIDDER_ALIASES = ['yahoossp']
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

With `modules.json` containing the following

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';
Expand Down Expand Up @@ -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]),
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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 => {
Expand Down Expand Up @@ -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'));
};

Expand Down Expand Up @@ -283,7 +287,6 @@ function generateOpenRtbObject(bidderRequest, bid) {
source: {
ext: {
hb: 1,
adapterver: ADAPTER_VERSION,
prebidver: PREBID_VERSION,
integration: {
name: INTEGRATION_METHOD,
Expand Down Expand Up @@ -332,7 +335,7 @@ function generateOpenRtbObject(bidderRequest, bid) {
};

function appendImpObject(bid, openRtbObject) {
const mediaTypeMode = getAdapterMode();
const mediaTypeMode = getAdapterMode(bid);

if (openRtbObject && bid) {
const impObject = {
Expand Down Expand Up @@ -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;
Expand All @@ -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`);
}
});
}
Expand All @@ -528,7 +533,7 @@ function generateServerRequest({payload, requestOptions, bidderRequest}) {
method: 'POST',
data: payload,
options: requestOptions,
bidderRequest: bidderRequest
bidderRequest // Additional data for use in interpretResponse()
};
};

Expand All @@ -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;
}
Expand All @@ -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) {
Expand All @@ -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;
};

Expand All @@ -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 => {
Expand All @@ -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;
Expand All @@ -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,
Expand Down
Loading