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

S2s defaults fix in serverbidServerBidAdapter #1986

Merged
merged 2 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 5 additions & 8 deletions modules/serverbidServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ const getConfig = config.getConfig;
const REQUIRED_S2S_CONFIG_KEYS = ['siteId', 'networkId', 'bidders', 'endpoint'];

let _s2sConfig;
config.setDefaults({
's2sConfig': {
enabled: false,
timeout: 1000,
adapter: 'serverbidServer'
}
});

const bidder = 'serverbidServer';

var ServerBidServerAdapter;
ServerBidServerAdapter = function ServerBidServerAdapter() {
Expand Down Expand Up @@ -61,6 +56,8 @@ ServerBidServerAdapter = function ServerBidServerAdapter() {
sizeMap[43] = '300x600';

function setS2sConfig(options) {
if (options.adapter != bidder) return;

let contains = (xs, x) => xs.indexOf(x) > -1;
let userConfig = Object.keys(options);

Expand Down Expand Up @@ -231,6 +228,6 @@ ServerBidServerAdapter.createNew = function() {
return new ServerBidServerAdapter();
};

adaptermanager.registerBidAdapter(new ServerBidServerAdapter(), 'serverbidServer');
adaptermanager.registerBidAdapter(new ServerBidServerAdapter(), bidder);

module.exports = ServerBidServerAdapter;
5 changes: 3 additions & 2 deletions src/adaptermanager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @module adaptermanger */

import { flatten, getBidderCodes, getDefinedParams, shuffle } from './utils';
import { flatten, getBidderCodes, getDefinedParams, shuffle, timestamp } from './utils';
import { resolveStatus } from './sizeMapping';
import { processNativeAdUnitParams, nativeAdapters } from './native';
import { newBidder } from './adapters/bidderFactory';
Expand Down Expand Up @@ -234,6 +234,7 @@ exports.callBids = (adUnits, bidRequests, addBidResponse, doneCb) => {
let s2sBidRequest = {tid, 'ad_units': adUnitsS2SCopy};
if (s2sBidRequest.ad_units.length) {
let doneCbs = serverBidRequests.map(bidRequest => {
bidRequest.start = timestamp();
bidRequest.doneCbCallCount = 0;
return doneCb(bidRequest.bidderRequestId)
});
Expand Down Expand Up @@ -265,7 +266,7 @@ exports.callBids = (adUnits, bidRequests, addBidResponse, doneCb) => {

// handle client adapter requests
clientBidRequests.forEach(bidRequest => {
bidRequest.start = new Date().getTime();
bidRequest.start = timestamp();
// TODO : Do we check for bid in pool from here and skip calling adapter again ?
const adapter = _bidderRegistry[bidRequest.bidderCode];
if (adapter) {
Expand Down