forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request prebid#17 from pm-manasi-moghe/master
merge prebid master into MFR branch
- Loading branch information
Showing
24 changed files
with
1,290 additions
and
510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
}); | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.