Skip to content

Commit

Permalink
Merge pull request #21 from yieldmo/feature/FS-10299-stage-bid-service
Browse files Browse the repository at this point in the history
Feature/fs 10299 stage bid service
  • Loading branch information
ym-elber authored Jul 19, 2022
2 parents 99e3877 + 7c4658f commit 970e2ae
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ const BIDDER_CODE = 'yieldmo';
const CURRENCY = 'USD';
const TIME_TO_LIVE = 300;
const NET_REVENUE = true;
const BANNER_SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid';
const VIDEO_SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebidvideo';
const PB_COOKIE_ASSIST_SYNC_ENDPOINT = `https://ads.yieldmo.com/pbcas`;
const BANNER_PATH = '/exchange/prebid';
const VIDEO_PATH = '/exchange/prebidvideo';
const STAGE_DOMAIN = 'https://ads-stg.yieldmo.com';
const PROD_DOMAIN = 'https://ads.yieldmo.com';
const OUTSTREAM_VIDEO_PLAYER_URL = 'https://prebid-outstream.yieldmo.com/bundle.js';
const OPENRTB_VIDEO_BIDPARAMS = ['mimes', 'startdelay', 'placement', 'startdelay', 'skipafter', 'protocols', 'api',
'playbackmethod', 'maxduration', 'minduration', 'pos', 'skip', 'skippable'];
Expand Down Expand Up @@ -59,6 +61,9 @@ export const spec = {
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (bidRequests, bidderRequest) {
const stage = isStage(bidderRequest);
const bannerUrl = getAdserverUrl(BANNER_PATH, stage);
const videoUrl = getAdserverUrl(VIDEO_PATH, stage);
const bannerBidRequests = bidRequests.filter(request => hasBannerMediaType(request));
const videoBidRequests = bidRequests.filter(request => hasVideoMediaType(request));
let serverRequests = [];
Expand Down Expand Up @@ -122,8 +127,8 @@ export const spec = {
serverRequest.eids = JSON.stringify(eids);
};
// check if url exceeded max length
const url = `${BANNER_SERVER_ENDPOINT}?${parseQueryStringParameters(serverRequest)}`;
let extraCharacters = url.length - MAX_BANNER_REQUEST_URL_LENGTH;
const fullUrl = `${bannerUrl}?${parseQueryStringParameters(serverRequest)}`;
let extraCharacters = fullUrl.length - MAX_BANNER_REQUEST_URL_LENGTH;
if (extraCharacters > 0) {
for (let i = 0; i < BANNER_REQUEST_PROPERTIES_TO_REDUCE.length; i++) {
extraCharacters = shortcutProperty(extraCharacters, serverRequest, BANNER_REQUEST_PROPERTIES_TO_REDUCE[i]);
Expand All @@ -136,7 +141,7 @@ export const spec = {

serverRequests.push({
method: 'GET',
url: BANNER_SERVER_ENDPOINT,
url: bannerUrl,
data: serverRequest
});
}
Expand All @@ -148,7 +153,7 @@ export const spec = {
};
serverRequests.push({
method: 'POST',
url: VIDEO_SERVER_ENDPOINT,
url: videoUrl,
data: serverRequest
});
}
Expand Down Expand Up @@ -661,3 +666,12 @@ function canAccessTopWindow() {
return false;
}
}

function isStage(bidderRequest) {
return !!bidderRequest.refererInfo?.referer?.includes('pb_force_a');
}

function getAdserverUrl(path, stage) {
const domain = stage ? STAGE_DOMAIN : PROD_DOMAIN;
return `${domain}${path}`;
}

0 comments on commit 970e2ae

Please sign in to comment.