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

Yieldmo Bid Adapteer : add iab gvlid and update path #9189

Merged
merged 14 commits into from
Nov 8, 2022
Merged
30 changes: 22 additions & 8 deletions modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ import {find, includes} from '../src/polyfill.js';
import {createEidsArray} from './userId/eids.js';

const BIDDER_CODE = 'yieldmo';
const GVLID = 173;
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 All @@ -40,7 +43,7 @@ const BANNER_REQUEST_PROPERTIES_TO_REDUCE = ['description', 'title', 'pr', 'page
export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, VIDEO],

gvlid: GVLID,
/**
* Determines whether or not the given bid request is valid.
* @param {object} bid, bid to validate
Expand All @@ -59,6 +62,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 +128,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 +142,7 @@ export const spec = {

serverRequests.push({
method: 'GET',
url: BANNER_SERVER_ENDPOINT,
url: bannerUrl,
data: serverRequest
});
}
Expand All @@ -148,7 +154,7 @@ export const spec = {
};
serverRequests.push({
method: 'POST',
url: VIDEO_SERVER_ENDPOINT,
url: videoUrl,
data: serverRequest
});
}
Expand Down Expand Up @@ -249,7 +255,6 @@ function addPlacement(request) {
if (transactionId) {
placementInfo.tid = transactionId;
}

if (request.auctionId) {
placementInfo.auctionId = request.auctionId;
}
Expand Down Expand Up @@ -676,3 +681,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}`;
}
7 changes: 3 additions & 4 deletions test/spec/modules/yieldmoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('YieldmoAdapter', function () {
userId: {
tdid: '8d146286-91d4-4958-aff4-7e489dd1abd6'
},
transactionId: '54a58774-7a41-494e-9aaf-fa7b79164f0c',
...rootParams
});

Expand Down Expand Up @@ -63,6 +64,7 @@ describe('YieldmoAdapter', function () {
...videoParams
}
},
transactionId: '54a58774-7a41-494e-8cbc-fa7b79164f0c',
...rootParams
});

Expand Down Expand Up @@ -178,10 +180,9 @@ describe('YieldmoAdapter', function () {
expect(buildAndGetPlacementInfo(bidArray)).to.equal(
'[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1,"auctionId":"1d1a030790a475"}]'
);

// multiple placements
bidArray.push(mockBannerBid(
{adUnitCode: 'adunit-2', bidId: '123a', bidderRequestId: '321', auctionId: '222'}, {bidFloor: 0.2}));
{adUnitCode: 'adunit-2', bidId: '123a', bidderRequestId: '321', auctionId: '222', transactionId: '444'}, {bidFloor: 0.2}));
expect(buildAndGetPlacementInfo(bidArray)).to.equal(
'[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1,"auctionId":"1d1a030790a475"},' +
'{"placement_id":"adunit-2","callback_id":"123a","sizes":[[300,250],[300,600]],"bidFloor":0.2,"auctionId":"222"}]'
Expand All @@ -193,7 +194,6 @@ describe('YieldmoAdapter', function () {
let placementInfo = buildAndGetPlacementInfo(bidArray);
expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"');
expect(placementInfo).not.to.include('"ym_placement_id":"ym_0987654321"');

bidArray.push(mockBannerBid({}, {placementId: 'ym_0987654321'}));
placementInfo = buildAndGetPlacementInfo(bidArray);
expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"');
Expand Down Expand Up @@ -507,7 +507,6 @@ describe('YieldmoAdapter', function () {

it('should add auction id to video bid request', function() {
const auctionId = '1d1a03073455';

expect(buildAndGetData([mockVideoBid({})]).auctionId).to.deep.equal(auctionId);
});

Expand Down