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

Update sspbc 4.9 branch #10

Merged
merged 13 commits into from
May 24, 2021
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
2 changes: 2 additions & 0 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,12 @@ export const spec = {
if (bidRequests[0].userId) {
let eids = [];

addUserId(eids, utils.deepAccess(bidRequests[0], `userId.flocId.id`), 'chrome.com', null);
addUserId(eids, utils.deepAccess(bidRequests[0], `userId.criteoId`), 'criteo.com', null);
addUserId(eids, utils.deepAccess(bidRequests[0], `userId.netId`), 'netid.de', null);
addUserId(eids, utils.deepAccess(bidRequests[0], `userId.idl_env`), 'liveramp.com', null);
addUserId(eids, utils.deepAccess(bidRequests[0], `userId.tdid`), 'adserver.org', 'TDID');
addUserId(eids, utils.deepAccess(bidRequests[0], `userId.uid2.id`), 'uidapi.com', 'UID2');

if (eids.length) {
payload.eids = eids;
Expand Down
26 changes: 25 additions & 1 deletion modules/conversantBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const spec = {
let bidurl = URL;

const conversantImps = validBidRequests.map(function(bid) {
const bidfloor = utils.getBidIdParameter('bidfloor', bid.params);
const bidfloor = getBidFloor(bid);

siteId = utils.getBidIdParameter('site_id', bid.params) || siteId;
pubcidName = utils.getBidIdParameter('pubcid_name', bid.params) || pubcidName;
Expand Down Expand Up @@ -378,4 +378,28 @@ function readStoredValue(key) {
return storedValue;
}

/**
* Get the floor price from bid.params for backward compatibility.
* If not found, then check floor module.
* @param bid A valid bid object
* @returns {*|number} floor price
*/
function getBidFloor(bid) {
let floor = utils.getBidIdParameter('bidfloor', bid.params);

if (!floor && utils.isFn(bid.getFloor)) {
const floorObj = bid.getFloor({
currency: 'USD',
mediaType: '*',
size: '*'
});

if (utils.isPlainObject(floorObj) && !isNaN(floorObj.floor) && floorObj.currency === 'USD') {
floor = floorObj.floor;
}
}

return floor
}

registerBidder(spec);
28 changes: 27 additions & 1 deletion modules/emx_digitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export const spec = {

utils._each(validBidRequests, function (bid) {
let tagid = utils.getBidIdParameter('tagid', bid.params);
let bidfloor = parseFloat(utils.getBidIdParameter('bidfloor', bid.params)) || 0;
let bidfloor = parseFloat(getBidFloor(bid)) || 0;
let isVideo = !!bid.mediaTypes.video;
let data = {
id: bid.bidId,
Expand Down Expand Up @@ -287,6 +287,14 @@ export const spec = {
bidResponse = emxAdapter.formatVideoResponse(bidResponse, Object.assign({}, emxBid), bidRequest);
}
bidResponse.mediaType = (isVideo ? VIDEO : BANNER);

// support for adomain in prebid 5.0
if (emxBid.adomain && emxBid.adomain.length) {
bidResponse.meta = {
advertiserDomains: emxBid.adomain
};
}

emxBidResponses.push(bidResponse);
});
}
Expand All @@ -312,4 +320,22 @@ export const spec = {
return syncs;
}
};

// support floors module in prebid 5.0
function getBidFloor(bid) {
if (!utils.isFn(bid.getFloor)) {
return parseFloat(utils.getBidIdParameter('bidfloor', bid.params));
}

let floor = bid.getFloor({
currency: DEFAULT_CUR,
mediaType: '*',
size: '*'
});
if (utils.isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') {
return floor.floor;
}
return null;
}

registerBidder(spec);
119 changes: 62 additions & 57 deletions modules/invibesBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const CONSTANTS = {
SYNC_ENDPOINT: 'https://k.r66net.com/GetUserSync',
TIME_TO_LIVE: 300,
DEFAULT_CURRENCY: 'EUR',
PREBID_VERSION: 5,
PREBID_VERSION: 6,
METHOD: 'GET',
INVIBES_VENDOR_ID: 436,
USERID_PROVIDERS: ['pubcid', 'pubProvidedId']
USERID_PROVIDERS: ['pubcid', 'pubProvidedId', 'uid2', 'zeotapIdPlus', 'id5id']
};

const storage = getStorageManager(CONSTANTS.INVIBES_VENDOR_ID);
Expand Down Expand Up @@ -168,64 +168,76 @@ function handleResponse(responseObj, bidRequests) {
responseObj = responseObj.body || responseObj;
responseObj = responseObj.videoAdContentResult || responseObj;

let bidModel = responseObj.BidModel;
if (typeof bidModel !== 'object') {
utils.logInfo('Invibes Adapter - Bidding is not configured');
return [];
}

if (typeof invibes.bidResponse === 'object') {
utils.logInfo('Invibes Adapter - Bid response already received. Invibes only responds to one bid request per user visit');
return [];
}

invibes.bidResponse = responseObj;

let ads = responseObj.Ads;
const bidResponses = [];
for (let i = 0; i < bidRequests.length; i++) {
let bidRequest = bidRequests[i];

if (!Array.isArray(ads) || ads.length < 1) {
if (responseObj.AdReason != null) {
utils.logInfo('Invibes Adapter - ' + responseObj.AdReason);
let requestPlacement = null;
if (responseObj.AdPlacements != null) {
for (let j = 0; j < responseObj.AdPlacements.length; j++) {
let bidModel = responseObj.AdPlacements[j].BidModel;
if (bidModel != null && bidModel.PlacementId == bidRequest.params.placementId) {
requestPlacement = responseObj.AdPlacements[j];
break;
}
}
} else {
let bidModel = responseObj.BidModel;
if (bidModel != null && bidModel.PlacementId == bidRequest.params.placementId) {
requestPlacement = responseObj;
}
}

utils.logInfo('Invibes Adapter - No ads available');
return [];
let bid = createBid(bidRequest, requestPlacement);
if (bid !== null) {
bidResponses.push(bid);
}
}

let ad = ads[0];
return bidResponses;
}

if (bidModel.PlacementId == null) {
utils.logInfo('Invibes Adapter - No Placement Id in response');
return [];
function createBid(bidRequest, requestPlacement) {
if (requestPlacement === null || requestPlacement.BidModel === null) {
utils.logInfo('Invibes Adapter - Placement not configured for bidding ' + bidRequest.params.placementId);
return null;
}

const bidResponses = [];
for (let i = 0; i < bidRequests.length; i++) {
let bidRequest = bidRequests[i];

if (bidModel.PlacementId == bidRequest.params.placementId) {
let size = getBiggerSize(bidRequest.sizes);

bidResponses.push({
requestId: bidRequest.bidId,
cpm: ad.BidPrice,
width: bidModel.Width || size[0],
height: bidModel.Height || size[1],
creativeId: ad.VideoExposedId,
currency: bidModel.Currency || CONSTANTS.DEFAULT_CURRENCY,
netRevenue: true,
ttl: CONSTANTS.TIME_TO_LIVE,
ad: renderCreative(bidModel)
});

const now = Date.now();
ivLogger.info('Bid auction started at ' + bidModel.AuctionStartTime + ' . Invibes registered the bid at ' + now + ' ; bid request took a total of ' + (now - bidModel.AuctionStartTime) + ' ms.');
} else {
utils.logInfo('Invibes Adapter - Incorrect Placement Id: ' + bidRequest.params.placementId);
let bidModel = requestPlacement.BidModel;
let ads = requestPlacement.Ads;
if (!Array.isArray(ads) || ads.length < 1) {
if (requestPlacement.AdReason != null) {
utils.logInfo('Invibes Adapter - No ads ' + requestPlacement.AdReason);
}

utils.logInfo('Invibes Adapter - No ads available');
return null;
}

return bidResponses;
let ad = ads[0];
let size = getBiggerSize(bidRequest.sizes);

const now = Date.now();
utils.logInfo('Bid auction started at ' + bidModel.AuctionStartTime + ' . Invibes registered the bid at ' + now + ' ; bid request took a total of ' + (now - bidModel.AuctionStartTime) + ' ms.');

return {
requestId: bidRequest.bidId,
cpm: ad.BidPrice,
width: bidModel.Width || size[0],
height: bidModel.Height || size[1],
creativeId: ad.VideoExposedId,
currency: bidModel.Currency || CONSTANTS.DEFAULT_CURRENCY,
netRevenue: true,
ttl: CONSTANTS.TIME_TO_LIVE,
ad: renderCreative(bidModel)
};
}

function generateRandomId() {
Expand Down Expand Up @@ -357,17 +369,6 @@ function getCappedCampaignsAsString() {
.join(',');
}

const noop = function () {
};

function initLogger() {
if (storage.hasLocalStorage() && localStorage.InvibesDEBUG) {
return window.console;
}

return {info: noop, error: noop, log: noop, warn: noop, debug: noop};
}

function buildSyncUrl() {
let syncUrl = _customUserSync || CONSTANTS.SYNC_ENDPOINT;
syncUrl += '?visitId=' + invibes.visitId;
Expand All @@ -392,7 +393,7 @@ function readGdprConsent(gdprConsent) {

if (!gdprConsent.vendorData.gdprApplies || gdprConsent.vendorData.hasGlobalConsent) {
var index;
for (index = 0; index < invibes.purposes; ++index) {
for (index = 0; index < invibes.purposes.length; ++index) {
invibes.purposes[index] = true;
}

Expand Down Expand Up @@ -448,7 +449,13 @@ function tryCopyValueToArray(value, target, length) {
}

if (value.hasOwnProperty(prop)) {
target[i] = !((value[prop] === false || value[prop] === 'false' || value[prop] == null));
let parsedProp = parseInt(prop);
if (isNaN(parsedProp)) {
target[i] = !((value[prop] === false || value[prop] === 'false' || value[prop] == null));
} else {
target[parsedProp - 1] = !((value[prop] === false || value[prop] === 'false' || value[prop] == null));
}

i++;
}
}
Expand Down Expand Up @@ -515,8 +522,6 @@ function getVendorLegitimateInterest(vendorData) {
return {};
}

const ivLogger = initLogger();

/// Local domain cookie management =====================
invibes.Uid = {
generate: function () {
Expand Down
Loading