Skip to content

Commit

Permalink
Yahoo Bid Adapter: Rebrand from to Yahoo Advertising (#10125)
Browse files Browse the repository at this point in the history
* Yahoo bid adapter rebrand

* Add deleted modules

* Addressing PR feedback

* Updated docs

* Renamed spec file

* Ensure consent data is pulled and sent correctly

---------

Co-authored-by: slimkrazy <sam@slimkrazy.com>
  • Loading branch information
slimkrazy and slimkrazy authored Jul 10, 2023
1 parent dcbebef commit 38aacce
Showing 3 changed files with 536 additions and 442 deletions.
71 changes: 38 additions & 33 deletions modules/yahoosspBidAdapter.js
Original file line number Diff line number Diff line change
@@ -6,9 +6,10 @@ 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 = 'yahooAds';
const BIDDER_ALIASES = ['yahoossp', 'yahooAdvertising']
const GVLID = 25;
const ADAPTER_VERSION = '1.0.2';
const ADAPTER_VERSION = '1.1.0';
const PREBID_VERSION = '$prebid.version$';
const DEFAULT_BID_TTL = 300;
const TEST_MODE_DCN = '8a969516017a7a396ec539d97f540011';
@@ -49,13 +50,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]),
@@ -114,11 +119,12 @@ function extractUserSyncUrls(syncOptions, pixels) {
*/
function updateConsentQueryParams(url, consentData) {
const parameterMap = {
'gdpr_consent': consentData.gdpr.consentString,
'gdpr': consentData.gdpr.gdprApplies ? '1' : '0',
'us_privacy': consentData.uspConsent,
'gpp': consentData.gpp.gppString,
'gpp_sid': consentData.gpp.applicableSections ? consentData.gpp.applicableSections.join(',') : ''
'gdpr_consent': consentData.gdpr ? consentData.gdpr.consentString : '',
'gdpr': consentData.gdpr && consentData.gdpr.gdprApplies ? '1' : '0',
'us_privacy': consentData.uspConsent ? consentData.uspConsent : '',
'gpp': consentData.gpp ? consentData.gpp.gppString : '',
'gpp_sid': consentData.gpp && Array.isArray(consentData.gpp.applicableSections)
? consentData.gpp.applicableSections.join(',') : ''
}

const existingUrl = new URL(url);
@@ -155,8 +161,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 +183,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 +193,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 +250,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'));
};

@@ -276,8 +282,8 @@ function generateOpenRtbObject(bidderRequest, bid) {
ext: {
'us_privacy': bidderRequest.uspConsent ? bidderRequest.uspConsent : '',
gdpr: bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies ? 1 : 0,
gpp: bidderRequest.gppConsent.gppString,
gpp_sid: bidderRequest.gppConsent.applicableSections
gpp: bidderRequest.gppConsent ? bidderRequest.gppConsent.gppString : '',
gpp_sid: bidderRequest.gppConsent ? bidderRequest.gppConsent.applicableSections : []
}
},
source: {
@@ -332,7 +338,7 @@ function generateOpenRtbObject(bidderRequest, bid) {
};

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

if (openRtbObject && bid) {
const impObject = {
@@ -494,20 +500,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 +523,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 +536,7 @@ function generateServerRequest({payload, requestOptions, bidderRequest}) {
method: 'POST',
data: payload,
options: requestOptions,
bidderRequest: bidderRequest
bidderRequest // Additional data for use in interpretResponse()
};
};

@@ -547,7 +555,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 +565,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 +578,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 +600,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 +615,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 +634,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,
Loading
Oops, something went wrong.

0 comments on commit 38aacce

Please sign in to comment.