Ejemplo n.º 1
0
  isBidRequestValid: function (bid) {
    if (!bid || !bid.params) {
      utils.logWarn(BIDDER_CODE + ': Missing bid parameters')
      return false
    }

    if (!utils.isStr(bid.params.adzoneid)) {
      utils.logWarn(BIDDER_CODE + ': adzoneid must be specified as a string')
      return false
    }

    if (isVideoRequest(bid)) {
      if (!bid.params.video.mimes) {
        // Give a warning but let it pass
        utils.logWarn(BIDDER_CODE + ': mimes should be specified for videos')
      } else if (!utils.isArray(bid.params.video.mimes) || !bid.params.video.mimes.every(s => utils.isStr(s))) {
        utils.logWarn(BIDDER_CODE + ': mimes must be an array of strings')
        return false
      }

      const context = utils.deepAccess(bid, 'mediaTypes.video.context')
      if (context !== 'instream') {
        utils.logWarn(BIDDER_CODE + ': video context must be valid - instream')
        return false
      }
    }

    return true
  },
Ejemplo n.º 2
0
  isBidRequestValid: function (bid) {
    if (typeof bid.params !== 'object') {
      return false;
    }

    if (!/^\d+$/.test(bid.params.accountId)) {
      return false;
    }

    if (hasVideoMediaType(bid)) {
      // Log warning if mediaTypes contains both 'banner' and 'video'
      if (utils.deepAccess(bid, `mediaTypes.${VIDEO}.context`) === 'instream' || bid.mediaType === VIDEO) {
        if (typeof utils.deepAccess(bid, 'params.video.size_id') === 'undefined') {
          utils.logError('Rubicon bid adapter Error: size id is missing for instream video request.');
          return false;
        }
      } else if (utils.deepAccess(bid, `mediaTypes.${VIDEO}.context`) === 'outstream') {
        if (utils.deepAccess(bid, 'params.video.size_id') !== 203) {
          utils.logWarn('Rubicon bid adapter Warning: outstream video is sending invalid size id, converting size id to 203.');
        }
      } else {
        utils.logError('Rubicon bid adapter Error: no instream or outstream context defined in mediaTypes.');
        return false;
      }
      if (typeof utils.deepAccess(bid, `mediaTypes.${BANNER}`) !== 'undefined') {
        utils.logWarn('Rubicon bid adapter Warning: video and banner requested for same ad unit, continuing with video request, multi-format request is not supported by rubicon yet.');
      }
    }
    return parseSizes(bid).length > 0;
  },
Ejemplo n.º 3
0
  return function(adUnitCode, bid) {
    if (!bid) {
      return fn.apply(this, arguments); // if no bid, call original and let it display warnings
    }

    let bidder = bid.bidderCode || bid.bidder;
    if (bidderCurrencyDefault[bidder]) {
      let currencyDefault = bidderCurrencyDefault[bidder];
      if (bid.currency && currencyDefault !== bid.currency) {
        utils.logWarn(`Currency default '${bidder}: ${currencyDefault}' ignored. adapter specified '${bid.currency}'`);
      } else {
        bid.currency = currencyDefault;
      }
    }

    // default to USD if currency not set
    if (!bid.currency) {
      utils.logWarn('Currency not specified on bid.  Defaulted to "USD"');
      bid.currency = 'USD';
    }

    // execute immediately if the bid is already in the desired currency
    if (bid.currency === adServerCurrency) {
      return fn.apply(this, arguments);
    }

    bidResponseQueue.push(wrapFunction(fn, this, arguments));
    if (!currencySupportEnabled || currencyRatesLoaded) {
      processBidResponseQueue();
    }
  }
Ejemplo n.º 4
0
    utils._each(bids, bidRequest => {
      const { bidId
        , params = {}
        , placementCode
      } = bidRequest;
      const timestamp = _getTimeStamp();
      const trackingId = params.inScreen;
      const nativeId = params['native'];
      const slotId = params.inSlot;
      const bid = { tmax: $$PREBID_GLOBAL$$.cbTimeout };

      /* slot/native ads need the placement id */
      switch (true) {
        case !!(params.inImage): bid.pi = 1; break;
        case !!(params.inScreen): bid.pi = 2; break;
        case !!(params.inSlot): bid.pi = 3; break;
        case !!(params['native']): bid.pi = 5; break;
        default: return utils.logWarn(
          `[GumGum] No product selected for the placement ${placementCode}` +
          ', please check your implementation.'
        );
      }

      /* throttle based on the latest request for this product */
      const productId = bid.pi;
      const requestKey = productId + '|' + placementCode;
      const throttle = throttleTable[productId];
      const latestRequest = requestCache[requestKey];
      if (latestRequest && throttle && (timestamp - latestRequest) < throttle) {
        return utils.logWarn(
          `[GumGum] The refreshes for "${placementCode}" with the params ` +
          `${JSON.stringify(params)} should be at least ${throttle / 1e3}s apart.`
        );
      }
      /* update the last request */
      requestCache[requestKey] = timestamp;

      /* tracking id is required for in-image and in-screen */
      if (trackingId) bid.t = trackingId;
      /* native ads require a native placement id */
      if (nativeId) bid.ni = nativeId;
      /* slot ads require a slot id */
      if (slotId) bid.si = slotId;

      /* include the pageViewId, if any */
      if (pageViewId) bid.pv = pageViewId;

      const cachedBid = Object.assign({
        placementCode,
        id: bidId
      }, bid);

      const callback = { jsonp: `$$PREBID_GLOBAL$$.handleGumGumCB['${bidId}']` };
      CALLBACKS[bidId] = _handleGumGumResponse(cachedBid);
      const query = Object.assign(callback, browserParams, bid, _getDigiTrustQueryParams());
      const bidCall = `${bidEndpoint}?${utils.parseQueryStringParameters(query)}`;
      adloader.loadScript(bidCall);
    });
  interpretResponse: (serverResponse, bidRequest) => {
    const bidObj = bidRequest.bidRequest;
    const bidResponses = [];
    const bidResponse = {};
    let isCorrectSize = false;
    let isCorrectCPM = true;
    let cpm;
    let minCPM;
    let maxCPM;
    let width;
    let height;

    serverResponse = serverResponse.body;
    if (serverResponse && serverResponse.status === 'SUCCESS' && bidObj) {
      cpm = serverResponse.cpm;
      minCPM = utils.getBidIdParameter('minCPM', bidObj.params);
      maxCPM = utils.getBidIdParameter('maxCPM', bidObj.params);
      width = parseInt(serverResponse.width);
      height = parseInt(serverResponse.height);

      // Ensure response CPM is within the given bounds
      if (minCPM !== '' && cpm < parseFloat(minCPM)) {
        isCorrectCPM = false;
        utils.logWarn('ContentIgnite: CPM did not meet minCPM requirements.');
      } else if (maxCPM !== '' && cpm > parseFloat(maxCPM)) {
        isCorrectCPM = false;
        utils.logWarn('ContentIgnite: CPM did not meet maxCPM requirements.');
      }

      // Ensure that response ad matches one of the placement sizes.
      utils._each(bidObj.sizes, (size) => {
        if (width === size[0] && height === size[1]) {
          isCorrectSize = true;
        } else {
          utils.logWarn(
            'ContentIgnite: Returned ad is of a different size to that requested.'
          );
        }
      });
      if (isCorrectCPM && isCorrectSize) {
        bidResponse.requestId = bidObj.bidId;
        bidResponse.creativeId = serverResponse.placement_id;
        bidResponse.cpm = cpm;
        bidResponse.width = width;
        bidResponse.height = height;
        bidResponse.ad = serverResponse.ad_code;
        bidResponse.currency = 'USD';
        bidResponse.netRevenue = true;
        bidResponse.ttl = config.getConfig('_bidderTimeout');
        bidResponse.referrer = utils.getTopWindowUrl();
        bidResponses.push(bidResponse);
      }
    }
    return bidResponses;
  }
Ejemplo n.º 6
0
/**
 * This function handles the exit logic for the module.
 * There are several paths in the module's logic to call this function and we only allow 1 of the 3 potential exits to happen before suppressing others.
 *
 * We prevent multiple exits to avoid conflicting messages in the console depending on certain scenarios.
 * One scenario could be auction was canceled due to timeout with CMP being reached.
 * While the timeout is the accepted exit and runs first, the CMP's callback still tries to process the user's data (which normally leads to a good exit).
 * In this case, the good exit will be suppressed since we already decided to cancel the auction.
 *
 * Three exit paths are:
 * 1. good exit where auction runs (CMP data is processed normally).
 * 2. bad exit but auction still continues (warning message is logged, CMP data is undefined and still passed along).
 * 3. bad exit with auction canceled (error message is logged).
 * @param {string} errMsg optional; only to be used when there was a 'bad' exit.  String is a descriptive message for the failure/issue encountered.
 * @param {object} hookConfig contains module related variables (see comment in requestBidsHook function)
 * @param {object} extraArgs contains additional data that's passed along in the error/warning messages for easier debugging
 */
function exitModule(errMsg, hookConfig, extraArgs) {
  if (hookConfig.haveExited === false) {
    hookConfig.haveExited = true;

    let context = hookConfig.context;
    let args = hookConfig.args;
    let nextFn = hookConfig.nextFn;

    if (errMsg) {
      if (allowAuction) {
        utils.logWarn(errMsg + ' Resuming auction without consent data as per consentManagement config.', extraArgs);
        nextFn.apply(context, args);
      } else {
        utils.logError(errMsg + ' Canceling auction as per consentManagement config.', extraArgs);
        if (typeof hookConfig.bidsBackHandler === 'function') {
          hookConfig.bidsBackHandler();
        } else {
          utils.logError('Error executing bidsBackHandler');
        }
      }
    } else {
      nextFn.apply(context, args);
    }
  }
}
Ejemplo n.º 7
0
export function requestBidsHook(reqBidsConfigObj, fn) {
  // preserves all module related variables for the current auction instance (used primiarily for concurrent auctions)
  const hookConfig = {
    context: this,
    args: arguments,
    nextFn: fn,
    adUnits: reqBidsConfigObj.adUnits || $$PREBID_GLOBAL$$.adUnits,
    bidsBackHandler: reqBidsConfigObj.bidsBackHandler,
    haveExited: false,
    timer: null
  };

  // in case we already have consent (eg during bid refresh)
  if (consentData) {
    return exitModule(null, hookConfig);
  }

  if (!includes(Object.keys(cmpCallMap), userCMP)) {
    utils.logWarn(`CMP framework (${userCMP}) is not a supported framework.  Aborting consentManagement module and resuming auction.`);
    return hookConfig.nextFn.apply(hookConfig.context, hookConfig.args);
  }

  cmpCallMap[userCMP].call(this, processCmpData, cmpFailed, hookConfig);

  // only let this code run if module is still active (ie if the callbacks used by CMPs haven't already finished)
  if (!hookConfig.haveExited) {
    if (consentTimeout === 0) {
      processCmpData(undefined, hookConfig);
    } else {
      hookConfig.timer = setTimeout(cmpTimedOut.bind(null, hookConfig), consentTimeout);
    }
  }
}
Ejemplo n.º 8
0
function _buildMarketplaceUrl(bid) {
  const params = bid.params;
  const serverParam = params.server;
  let regionParam = params.region || 'us';
  let server;

  if (!MP_SERVER_MAP.hasOwnProperty(regionParam)) {
    utils.logWarn(`Unknown region '${regionParam}' for AOL bidder.`);
    regionParam = 'us'; // Default region.
  }

  if (serverParam) {
    server = serverParam;
  } else {
    server = MP_SERVER_MAP[regionParam];
  }

  // Set region param, used by AOL analytics.
  params.region = regionParam;

  return pubapiTemplate({
    host: server,
    network: params.network,
    placement: parseInt(params.placement),
    pageid: params.pageId || 0,
    sizeid: params.sizeId || 0,
    alias: params.alias || utils.getUniqueIdentifierStr(),
    bidfloor: formatMarketplaceBidFloor(params.bidFloor),
    keyValues: formatMarketplaceKeyValues(params.keyValues),
    misc: new Date().getTime() // cache busting
  });
}
Ejemplo n.º 9
0
/*
* read the pricing extension with this format: <Extension type='StickyPricing'><Price currency="EUR">1.0000</Price></Extension>
* @return {object} pricing data in format: {currency: "EUR", price:"1.000"}
*/
function getPricing(xmlNode) {
  var pricingExtNode;
  var princingData = {};

  var extensions = xmlNode.querySelectorAll('Extension');
  // Nodelist.forEach is not supported in IE and Edge
  // Workaround given here https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10638731/
  Array.prototype.forEach.call(extensions, function(node) {
    if (node.getAttribute('type') === 'StickyPricing') {
      pricingExtNode = node;
    }
  });

  if (pricingExtNode) {
    var priceNode = pricingExtNode.querySelector('Price');
    princingData = {
      currency: priceNode.getAttribute('currency'),
      price: priceNode.textContent || priceNode.innerText
    };
  } else {
    utils.logWarn('PREBID - ' + BIDDER_CODE + ': Can\'t get pricing data. Is price awareness enabled?');
  }

  return princingData;
}
Ejemplo n.º 10
0
 function filterAndWarn(bid) {
   if (!spec.isBidRequestValid(bid)) {
     logWarn(`Invalid bid sent to bidder ${spec.code}: ${JSON.stringify(bid)}`);
     return false;
   }
   return true;
 }
Ejemplo n.º 11
0
function parseSizes(bid) {
  let params = bid.params;
  if (hasVideoMediaType(bid)) {
    let size = [];
    if (typeof utils.deepAccess(bid, 'mediaTypes.video.playerSize') !== 'undefined') {
      size = bid.mediaTypes.video.playerSize;
    } else if (params.video && params.video.playerWidth && params.video.playerHeight) {
      size = [
        params.video.playerWidth,
        params.video.playerHeight
      ];
    } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0 && Array.isArray(bid.sizes[0]) && bid.sizes[0].length > 1) {
      size = bid.sizes[0];
    }
    return size;
  }

  // deprecated: temp legacy support
  let sizes = [];
  if (Array.isArray(params.sizes)) {
    sizes = params.sizes;
  } else if (typeof utils.deepAccess(bid, 'mediaTypes.banner.sizes') !== 'undefined') {
    sizes = mapSizes(bid.mediaTypes.banner.sizes);
  } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0) {
    sizes = mapSizes(bid.sizes)
  } else {
    utils.logWarn('Warning: no sizes are setup or found');
  }

  return masSizeOrdering(sizes);
}
Ejemplo n.º 12
0
 interpretResponse: function(response, { bidRequest }) {
   let bid;
   let size;
   let bidResponse;
   try {
     response = response.body;
     bid = response.seatbid[0].bid[0];
   } catch (e) {
     response = null;
   }
   if (!response || !bid || (!bid.adm && !bid.nurl) || !bid.price) {
     utils.logWarn(`No valid bids from ${spec.code} bidder`);
     return [];
   }
   size = getSize(bidRequest.sizes);
   bidResponse = {
     requestId: bidRequest.bidId,
     bidderCode: spec.code,
     cpm: bid.price,
     creativeId: bid.id,
     width: size.width,
     height: size.height,
     mediaType: 'video',
     currency: response.cur,
     ttl: 100,
     netRevenue: true
   };
   if (bid.nurl) {
     bidResponse.vastUrl = bid.nurl;
   } else if (bid.adm) {
     bidResponse.vastXml = bid.adm;
   }
   return bidResponse;
 },
Ejemplo n.º 13
0
function newRenderer(adUnitCode, rtbBid, rendererOptions = {}) {
  const renderer = Renderer.install({
    id: rtbBid.renderer_id,
    url: rtbBid.renderer_url,
    config: rendererOptions,
    loaded: false,
    adUnitCode
  });

  try {
    renderer.setRender(outstreamRender);
  } catch (err) {
    utils.logWarn('Prebid Error calling setRender on renderer', err);
  }

  renderer.setEventHandlers({
    impression: () => utils.logMessage('AppNexus outstream video impression event'),
    loaded: () => utils.logMessage('AppNexus outstream video loaded event'),
    ended: () => {
      utils.logMessage('AppNexus outstream renderer video event');
      document.querySelector(`#${adUnitCode}`).style.display = 'none';
    }
  });
  return renderer;
}
Ejemplo n.º 14
0
 utils._each(bidObj.sizes, (size) => {
   if (width === size[0] && height === size[1]) {
     isCorrectSize = true;
   } else {
     utils.logWarn(
       'ContentIgnite: Returned ad is of a different size to that requested.'
     );
   }
 });
Ejemplo n.º 15
0
 function addBidUsingRequestMap(bid) {
   const bidRequest = bidRequestMap[bid.requestId];
   if (bidRequest) {
     const prebidBid = Object.assign(bidfactory.createBid(CONSTANTS.STATUS.GOOD, bidRequest), bid);
     addBidWithCode(bidRequest.adUnitCode, prebidBid);
   } else {
     logWarn(`Bidder ${spec.code} made bid for unknown request ID: ${bid.requestId}. Ignoring.`);
   }
 }
Ejemplo n.º 16
0
  interpretResponse: function(serverResponse, request) {
    var bidrequest = request.bidRequest;
    var playerSize = getBiggerSize(bidrequest.sizes);

    if (typeof serverResponse == 'object' && typeof serverResponse.body == 'string') {
      serverResponse = serverResponse.body;
    }

    var xmlDoc;
    try {
      var parser = new DOMParser();
      xmlDoc = parser.parseFromString(serverResponse, 'application/xml');
    } catch (err) {
      utils.logWarn('Prebid.js - ' + BIDDER_CODE + ' : ' + err);
      return;
    }

    const princingData = getPricing(xmlDoc);
    const creativeId = getCreativeId(xmlDoc);

    const topWin = getTopMostWindow();
    if (!topWin.freewheelssp_cache) {
      topWin.freewheelssp_cache = {};
    }
    topWin.freewheelssp_cache[bidrequest.adUnitCode] = serverResponse;

    const bidResponses = [];

    if (princingData.price) {
      const bidResponse = {
        requestId: bidrequest.bidId,
        cpm: princingData.price,
        width: playerSize[0],
        height: playerSize[1],
        creativeId: creativeId,
        currency: princingData.currency,
        netRevenue: true,
        ttl: 360
      };

      var mediaTypes = bidrequest.mediaTypes || {};
      if (mediaTypes.video) {
        // bidResponse.vastXml = serverResponse;
        bidResponse.mediaType = 'video';

        var blob = new Blob([serverResponse], {type: 'application/xml'});
        bidResponse.vastUrl = window.URL.createObjectURL(blob);
      } else {
        bidResponse.ad = formatAdHTML(bidrequest, playerSize);
      }

      bidResponses.push(bidResponse);
    }

    return bidResponses;
  },
Ejemplo n.º 17
0
 // function to convert google tag slot sizes to [[w,h],...]
 function mapGptSlotSizes(aGPTSlotSizes) {
   var aSlotSizes = [];
   for (var i = 0; i < aGPTSlotSizes.length; i++) {
     try {
       aSlotSizes.push([aGPTSlotSizes[i].getWidth(), aGPTSlotSizes[i].getHeight()]);
     } catch (e) {
       utils.logWarn('slot size ' + aGPTSlotSizes[i].toString() + ' not supported by' + MODULE_NAME);
     }
   }
   return aSlotSizes;
 }
Ejemplo n.º 18
0
 return function() {
   let bidderSettings = $$PREBID_GLOBAL$$.bidderSettings;
   if (showCpmWarning && bidderSettings && bidderSettings.aol &&
     typeof bidderSettings.aol.bidCpmAdjustment === 'function') {
     utils.logWarn(
       'bidCpmAdjustment is active for the AOL adapter. ' +
       'As of Prebid 0.14, AOL can bid in net – please contact your accounts team to enable.'
     );
     showCpmWarning = false; // warning is shown at most once
   }
 };
Ejemplo n.º 19
0
        result.bidder_status.forEach(bidder => {
          if (bidder.error) {
            utils.logWarn(`Prebid Server returned error: '${bidder.error}' for ${bidder.bidder}`);
          }

          bidderRequests.filter(bidderRequest => bidderRequest.bidderCode === bidder.bidder)
            .forEach(bidderRequest =>
              (bidderRequest.bids || []).forEach(bid =>
                bid.serverResponseTimeMs = bidder.response_time_ms
              )
            )
        });
Ejemplo n.º 20
0
/**
 * Determine bidRequest mediaType
 * @param bid the bid to test
 * @param log whether we should log errors/warnings for invalid bids
 * @returns {string|undefined} Returns 'video' or 'banner' if resolves to a type, or undefined otherwise (invalid).
 */
function bidType(bid, log = false) {
  // Is it considered video ad unit by rubicon
  if (hasVideoMediaType(bid)) {
    // legacy mediaType or the new mediaTypes
    // this is the preffered "new" way to define mediaTypes
    if (typeof utils.deepAccess(bid, `mediaTypes.${VIDEO}`) !== 'undefined') {
      // We require either context as instream or outstream
      if (['outstream', 'instream'].indexOf(utils.deepAccess(bid, `mediaTypes.${VIDEO}.context`)) === -1) {
        if (log) {
          utils.logError('Rubicon bid adapter requires mediaTypes.video.context to be one of outstream or instream');
        }
        return;
      }
    } else { // Otherwise its the legacy way where mediaType == 'video'
      if (log) {
        utils.logWarn('Rubicon video bid requested using legacy `adUnit.mediaType = `video``\nThis is deprecated\nPlease move towards the PBJS standard using mediaTypes object!');
      }
      if (isNaN(parseInt(utils.deepAccess(bid, 'params.video.size_id')))) {
        if (log) {
          utils.logError('Rubicon bid adapter needs params.video.size_id to be declared and an integer in order to process a legacy video request using mediaType == video');
        }
        return;
      }
    }
    // we require playerWidth and playerHeight to come from one of params.playerWidth/playerHeight or mediaTypes.video.playerSize or adUnit.sizes
    if (parseSizes(bid, 'video').length < 2) {
      if (log) {
        utils.logError('Rubicon bid adapter could not determine the playerSize of the video\nplayerWidth and playerHeight are inferred from one of params.playerWidth/playerHeight or mediaTypes.video.playerSize or adUnit.sizes, in that order');
      }
      return;
    }

    if (log) {
      utils.logMessage('Rubicon bid adapter making video request for adUnit', bid.adUnitCode);
    }
    return 'video';
  } else {
    // we require banner sizes to come from one of params.sizes or mediaTypes.banner.sizes or adUnit.sizes, in that order
    // if we cannot determine them, we reject it!
    if (parseSizes(bid, 'banner').length === 0) {
      if (log) {
        utils.logError('Rubicon bid adapter could not determine the sizes for a banner request\nThey are inferred from one of params.sizes or mediaTypes.banner.sizes or adUnit.sizes, in that order');
      }
      return;
    }

    // everything looks good for banner so lets do it
    if (log) {
      utils.logMessage('Rubicon bid adapter making banner request for adUnit', bid.adUnitCode);
    }
    return 'banner';
  }
}
Ejemplo n.º 21
0
export function isValid(adUnitCode, bid, bidRequests) {
  function hasValidKeys() {
    let bidKeys = Object.keys(bid);
    return COMMON_BID_RESPONSE_KEYS.every(key => includes(bidKeys, key) && !includes([undefined, null], bid[key]));
  }

  function errorMessage(msg) {
    return `Invalid bid from ${bid.bidderCode}. Ignoring bid: ${msg}`;
  }

  if (!adUnitCode) {
    logWarn('No adUnitCode was supplied to addBidResponse.');
    return false;
  }

  if (!bid) {
    logWarn(`Some adapter tried to add an undefined bid for ${adUnitCode}.`);
    return false;
  }

  if (!hasValidKeys()) {
    logError(errorMessage(`Bidder ${bid.bidderCode} is missing required params. Check http://prebid.org/dev-docs/bidder-adapter-1.html for list of params.`));
    return false;
  }

  if (bid.mediaType === 'native' && !nativeBidIsValid(bid, bidRequests)) {
    logError(errorMessage('Native bid missing some required properties.'));
    return false;
  }
  if (bid.mediaType === 'video' && !isValidVideoBid(bid, bidRequests)) {
    logError(errorMessage(`Video bid does not have required vastUrl or renderer property`));
    return false;
  }
  if (bid.mediaType === 'banner' && !validBidSize(adUnitCode, bid, bidRequests)) {
    logError(errorMessage(`Banner bids require a width and height`));
    return false;
  }

  return true;
}
Ejemplo n.º 22
0
 function bidCallback(responseText) {
   try {
     utils.logMessage('XHR callback function called for ad ID: ' + bid.bidId);
     handleRpCB(responseText, bid);
   } catch (err) {
     if (typeof err === 'string') {
       utils.logWarn(`${err} when processing rubicon response for placement code ${bid.placementCode}`);
     } else {
       utils.logError('Error processing rubicon response for placement code ' + bid.placementCode, null, err);
     }
     addErrorBid();
   }
 }
Ejemplo n.º 23
0
function newRenderer(bidRequest, bid, rendererOptions = {}) {
  const renderer = Renderer.install({
    url: (bidRequest.params && bidRequest.params.rendererUrl) || (bid.ext && bid.ext.renderer_url) || '//s.gamoshi.io/video/latest/renderer.js',
    config: rendererOptions,
    loaded: false,
  });
  try {
    renderer.setRender(renderOutstream);
  } catch (err) {
    utils.logWarn('Prebid Error calling setRender on renderer', err);
  }
  return renderer;
}
Ejemplo n.º 24
0
 function addBidUsingRequestMap(bid) {
   // In Prebid 1.0 all the validation logic from bidmanager will move here, as of now we are only validating new params so that adapters dont miss adding them.
   if (hasValidKeys(bid)) {
     const bidRequest = bidRequestMap[bid.requestId];
     if (bidRequest) {
       const prebidBid = Object.assign(bidfactory.createBid(STATUS.GOOD, bidRequest), bid);
       addBidWithCode(bidRequest.placementCode, prebidBid);
     } else {
       logWarn(`Bidder ${spec.code} made bid for unknown request ID: ${bid.requestId}. Ignoring.`);
     }
   } else {
     logError(`Bidder ${spec.code} is missing required params. Check http://prebid.org/dev-docs/bidder-adapter-1.html for list of params.`);
   }
 }
Ejemplo n.º 25
0
  isBidRequestValid: function(bid) {
    if (!bid || !bid.params) {
      utils.logWarn(BIDDER_CODE + ': Missing bid parameters');
      return false;
    }

    if (!utils.isStr(bid.params.site_id)) {
      utils.logWarn(BIDDER_CODE + ': site_id must be specified as a string')
      return false;
    }

    if (isVideoRequest(bid)) {
      if (!bid.params.mimes) {
        // Give a warning but let it pass
        utils.logWarn(BIDDER_CODE + ': mimes should be specified for videos');
      } else if (!utils.isArray(bid.params.mimes) || !bid.params.mimes.every(s => utils.isStr(s))) {
        utils.logWarn(BIDDER_CODE + ': mimes must be an array of strings');
        return false;
      }
    }

    return true;
  },
Ejemplo n.º 26
0
const createRenderer = (bid, serverResponse) => {
  const renderer = Renderer.install({
    id: serverResponse.renderer_id,
    url: serverResponse.renderer_url,
    loaded: false,
  });

  try {
    renderer.setRender(outstreamRender);
  } catch (err) {
    utils.logWarn('Prebid Error calling setRender on renderer', err);
  }

  return renderer;
}
Ejemplo n.º 27
0
function newRenderer(bidderResponse) {
  const renderer = Renderer.install({
    id: bidderResponse.ad.prebid_id,
    url: bidderResponse.ad.video.purl,
    loaded: false,
  });

  try {
    renderer.setRender(outstreamRender);
  } catch (err) {
    utils.logWarn('Prebid Error calling setRender on newRenderer', err);
  }

  return renderer;
}
Ejemplo n.º 28
0
  isBidRequestValid: function(bid) {
    const isVideoMediaType = utils.deepAccess(bid, 'mediaTypes.video');
    const videoContext = utils.deepAccess(bid, 'mediaTypes.video.context');

    if (typeof bid.params !== 'object' || typeof bid.params.adid != 'string') {
      return false;
    }

    if (isVideoMediaType && videoContext === 'outstream') {
      utils.logWarn('Warning: outstream video is not supported yet');
      return false;
    }

    return true;
  },
Ejemplo n.º 29
0
 function bidCallback(responseText) {
   try {
     utils.logMessage('XHR callback function called for ad ID: ' + bid.bidId);
     handleRpCB(responseText, bid);
   } catch (err) {
     if (typeof err === 'string') {
       utils.logWarn(`${err} when processing huddledmasses response for placement code ${bid.placementCode}`);
     } else {
       utils.logError('Error processing huddledmasses response for placement code ' + bid.placementCode, null, err);
     }
     var badBid = bidfactory.createBid(STATUS.NO_BID, bid);
     badBid.bidderCode = bid.bidder;
     badBid.error = err;
     bidmanager.addBidResponse(bid.placementCode, badBid);
   }
 }
/**
 * Determines whether or not the given bid request is valid.
 *
 * @param {BidRequest} bid The bid params to validate.
 * @return boolean True if this is a valid bid, and false otherwise.
 */
function isBidRequestValid (bid) {
  const {
    params,
    adUnitCode
  } = bid;

  switch (true) {
    case !!(params.inScreen): break;
    case !!(params.inSlot): break;
    case !!(params.ICV): break;
    default:
      utils.logWarn(`[GumGum] No product selected for the placement ${adUnitCode}, please check your implementation.`);
      return false;
  }
  return true;
}