Skip to content

Commit

Permalink
Merge pull request prebid#17 from pm-manasi-moghe/master
Browse files Browse the repository at this point in the history
merge prebid master into MFR branch
  • Loading branch information
pm-manasi-moghe authored Mar 27, 2019
2 parents ec67b85 + 04ebe44 commit a583147
Show file tree
Hide file tree
Showing 24 changed files with 1,290 additions and 510 deletions.
1 change: 1 addition & 0 deletions modules/ajaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const spec = {
sponsoredBy: assets.sponsor,
clickUrl: assets.lp_link,
impressionTrackers: nativeAd.imps,
privacyLink: assets.adchoice_url,
};

if (assets.img_main !== undefined) {
Expand Down
6 changes: 5 additions & 1 deletion modules/ajaBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ var adUnits = [
icon: {
required: false,
sendId: false
}
},
privacyLink: {
required: true,
sendId: true
},
}
},
bids: [{
Expand Down
154 changes: 154 additions & 0 deletions modules/cedatoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
import * as utils from 'src/utils';
import { registerBidder } from 'src/adapters/bidderFactory';
import { BANNER } from 'src/mediaTypes';

const BIDDER_CODE = 'cedato';
const BID_URL = '//h.cedatoplayer.com/hb';
const SYNC_URL = '//h.cedatoplayer.com/hb_usync?uid={UUID}';
const COOKIE_NAME = 'hb-cedato-id';
const UUID_LEN = 36;
const TTL = 10000;
const CURRENCY = 'USD';
const FIRST_PRICE = 1;
const NET_REVENUE = true;

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER],

isBidRequestValid: function(bid) {
return !!(
bid &&
bid.params &&
bid.params.player_id &&
utils.checkCookieSupport() &&
utils.cookiesAreEnabled()
);
},

buildRequests: function(bidRequests, bidderRequest) {
const req = bidRequests[Math.floor(Math.random() * bidRequests.length)];
const params = req.params;
const at = FIRST_PRICE;
const site = { id: params.player_id, domain: document.domain };
const device = { ua: navigator.userAgent, ip: '' };
const user = { id: getUserID() }
const cur = [ CURRENCY ];
const tmax = bidderRequest.timeout;

const imp = bidRequests.map(req => {
const banner = { 'format': getFormats(utils.deepAccess(req, 'mediaTypes.banner.sizes')) };
const bidfloor = params.bidfloor !== undefined
? Number(params.bidfloor) : 1;
const bidfloorcur = CURRENCY;
const bidId = req.bidId;

return {
bidId,
banner,
bidfloor,
bidfloorcur,
};
});

const payload = {
at,
site,
device,
user,
imp,
cur,
tmax,
};

if (bidderRequest && bidderRequest.gdprConsent) {
payload.gdpr_consent = {
consent_string: bidderRequest.gdprConsent.consentString,
consent_required: bidderRequest.gdprConsent.gdprApplies
};
}

return {
method: 'POST',
url: BID_URL,
data: JSON.stringify(payload),
};
},

interpretResponse: function(resp) {
if (resp.body === '') return [];

const bids = resp.body.seatbid[0].bid.map(bid => {
const cpm = bid.price;
const requestId = bid.uuid;
const width = bid.w;
const height = bid.h;
const creativeId = bid.crid;
const dealId = bid.dealid;
const currency = resp.body.cur;
const netRevenue = NET_REVENUE;
const ttl = TTL;
const ad = bid.adm;

return {
cpm,
requestId,
width,
height,
creativeId,
dealId,
currency,
netRevenue,
ttl,
ad,
};
});

return bids;
},

getUserSyncs: function(syncOptions, resps, gdprConsent) {
const syncs = [];
if (syncOptions.pixelEnabled) {
resps.forEach(() => {
const uuid = getUserID();
const syncUrl = SYNC_URL;
let params = '';
if (gdprConsent && typeof gdprConsent.consentString === 'string') {
if (typeof gdprConsent.gdprApplies === 'boolean') {
params += `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
} else {
params += `?gdpr_consent=${gdprConsent.consentString}`;
}
}
syncs.push({
type: 'image',
url: syncUrl.replace('{UUID}', uuid) + params,
});
});
}
return syncs;
}
}

const getUserID = () => {
const cookieName = COOKIE_NAME;
const uuidLen = UUID_LEN;

const i = document.cookie.indexOf(cookieName);

if (i === -1) {
const uuid = utils.generateUUID();
document.cookie = `${cookieName}=${uuid}; path=/`;
return uuid;
}

const j = i + cookieName.length + 1;
return document.cookie.substring(j, j + uuidLen);
};

const getFormats = arr => arr.map((s) => {
return { w: s[0], h: s[1] };
});

registerBidder(spec);
53 changes: 53 additions & 0 deletions modules/cedatoBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Overview

```
Module Name: Cedato Bidder Adapter
Module Type: Bidder Adapter
Maintainer: [email protected]
```

# Description

Connects to Cedato bidder.
Cedato adapter supports only Banner at the moment.

# Test Parameters
```
var adUnits = [
// Banner
{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
// You can choose one of them
sizes: [
[300, 250],
[300, 600],
[240, 400],
[728, 90],
]
}
},
bids: [
{
bidder: "cedato",
params: {
player_id: 1450133326,
}
}
]
}
];
pbjs.que.push(() => {
pbjs.setConfig({
userSync: {
syncEnabled: true,
enabledBidders: ['cedato'],
pixelEnabled: true,
syncsPerBidder: 200,
syncDelay: 100,
},
});
});
```
4 changes: 4 additions & 0 deletions modules/dfpAdServerVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ function getCustParams(bid, options) {

const optCustParams = deepAccess(options, 'params.cust_params');
let customParams = Object.assign({},
// Why are we adding standard keys here ? Refer https://github.com/prebid/Prebid.js/issues/3664
{ hb_uuid: bid && bid.videoCacheKey },
// hb_uuid will be deprecated and replaced by hb_cache_id
{ hb_cache_id: bid && bid.videoCacheKey },
allTargetingData,
adserverTargeting,
optCustParams,
Expand Down
6 changes: 3 additions & 3 deletions modules/etargetBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ export const spec = {
var i, l, bid, reqParams, netRevenue, gdprObject;
var request = [];
var bids = JSON.parse(JSON.stringify(validBidRequests));
var lastContry = 'sk';
var lastCountry = 'sk';
for (i = 0, l = bids.length; i < l; i++) {
bid = bids[i];
if (countryMap[bid.params.country]) {
lastContry = countryMap[bid.params.country];
lastCountry = countryMap[bid.params.country];
}
reqParams = bid.params;
reqParams.transactionId = bid.transactionId;
request.push(formRequestUrl(reqParams));
}

request.unshift('//' + lastContry + '.search.etargetnet.com/hb/?hbget=1');
request.unshift('//' + lastCountry + '.search.etargetnet.com/hb/?hbget=1');
netRevenue = 'net';

if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) {
Expand Down
5 changes: 5 additions & 0 deletions modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ function parseBid(rawBid, currency) {
bid.currency = currency;
bid.creativeId = rawBid.hasOwnProperty('crid') ? rawBid.crid : '-';

bid.meta = {};
bid.meta.networkId = utils.deepAccess(rawBid, 'ext.dspid');
bid.meta.brandId = utils.deepAccess(rawBid, 'ext.advbrandid');
bid.meta.brandName = utils.deepAccess(rawBid, 'ext.advbrand');

return bid;
}

Expand Down
50 changes: 23 additions & 27 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,40 +91,37 @@ export const spec = {
return null;
},

_getCrbIds() {
_getCrbFromCookie() {
try {
const crb = JSON.parse(decodeURIComponent(spec._readCookie('krg_crb')));
let syncIds = {};

if (crb && crb.v) {
let vParsed = JSON.parse(atob(crb.v));

if (vParsed && vParsed.syncIds) {
syncIds = vParsed.syncIds;
if (vParsed) {
return vParsed;
}
}

return syncIds;
return {};
} catch (e) {
return {};
}
},

_getUid() {
_getCrbFromLocalStorage() {
try {
const uid = JSON.parse(decodeURIComponent(spec._readCookie('krg_uid')));
let vData = {};

if (uid && uid.v) {
vData = uid.v;
}

return vData;
return JSON.parse(atob(spec._getLocalStorageSafely('krg_crb')));
} catch (e) {
return {};
}
},

_getCrb() {
let localStorageCrb = spec._getCrbFromLocalStorage();
if (Object.keys(localStorageCrb).length) {
return localStorageCrb;
}
return spec._getCrbFromCookie();
},

_getKruxUserId() {
return spec._getLocalStorageSafely('kxkar_user');
},
Expand Down Expand Up @@ -156,28 +153,27 @@ export const spec = {
},

_getUserIds() {
const uid = spec._getUid();
const crbIds = spec._getCrbIds();

const crb = spec._getCrb();
return {
kargoID: uid.userId,
clientID: uid.clientId,
crbIDs: crbIds,
optOut: uid.optOut
kargoID: crb.userId,
clientID: crb.clientId,
crbIDs: crb.syncIds || {},
optOut: crb.optOut
};
},

_getClientId() {
const uid = spec._getUid();
return uid.clientId;
const crb = spec._getCrb();
return crb.clientId;
},

_getAllMetadata() {
return {
userIDs: spec._getUserIds(),
krux: spec._getKrux(),
pageURL: window.location.href,
rawCRB: spec._readCookie('krg_crb')
rawCRB: spec._readCookie('krg_crb'),
rawCRBLocalStorage: spec._getLocalStorageSafely('krg_crb')
};
},

Expand Down
2 changes: 1 addition & 1 deletion modules/orbitsoftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let styleParamsMap = {
};
export const spec = {
code: BIDDER_CODE,
aliases: ['oas', '152media'], // short code and customer aliases
aliases: ['oas', 'mediafuseLift'], // short code and customer aliases
isBidRequestValid: function (bid) {
switch (true) {
case !('params' in bid):
Expand Down
Loading

0 comments on commit a583147

Please sign in to comment.