-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Preciso : Added new library to remove code duplication in bid adapter #11868
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
17451f8
Preciso : Added new library to remove code duplication in bid adapter
NikhilGopalChennissery c8f17b7
Merge branch 'prebid:master' into master_jun_24
NikhilGopalChennissery 23731e6
modified bidfloor mapping logic
NikhilGopalChennissery 3db9592
Merge branch 'master_jun_24' of https://github.com/PrecisoSRL/Prebid.…
NikhilGopalChennissery ec467a9
Merge branch 'prebid:master' into master_jun_24
NikhilGopalChennissery b60e3d6
Merge branch 'prebid:master' into master_jun_24
NikhilGopalChennissery 1e51330
error fix
NikhilGopalChennissery 702eba7
error fix
NikhilGopalChennissery e0ee391
Merge branch 'prebid:master' into master_jun_24
NikhilGopalChennissery c174c9e
import bidUtils.js in IdxBidadapter to reduce the code duplicataion
NikhilGopalChennissery 65af09e
import bidUtils.js in IdxBidadapter to reduce the code duplicataion
NikhilGopalChennissery d4c4bd7
Error fix
NikhilGopalChennissery c291e6d
Imported bidUtils library into redtram bid adapter
NikhilGopalChennissery 510053a
import common library in mediabramaBidAdapter
NikhilGopalChennissery 6324822
Merge branch 'master' into master_jun_24
NikhilGopalChennissery e9c773e
import common library in loganBidAdapter to remove code duplication
NikhilGopalChennissery dcb586f
Merge branch 'master_jun_24' of https://github.com/PrecisoSRL/Prebid.…
NikhilGopalChennissery 8659a3a
removed storageManaser from library
NikhilGopalChennissery c2b8c27
renderer.js changes reverted
NikhilGopalChennissery 0ccda46
Merge branch 'prebid:master' into master_jun_24
NikhilGopalChennissery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,168 @@ | ||
<html> | ||
|
||
<head> | ||
<link rel="icon" type="image/png" href="/favicon.png"> | ||
|
||
<!--script async src="//cdn.preciso.net/Preciso_Prebid/prebid.js"></script--> | ||
<script async src="../../build/dev/prebid.js"></script> | ||
<script> | ||
var div_1_sizes = [ | ||
[300, 250], | ||
[300, 600] | ||
]; | ||
var div_2_sizes = [ | ||
[300, 250], | ||
[970, 250] | ||
]; | ||
var PREBID_TIMEOUT = 1000; | ||
var FAILSAFE_TIMEOUT = 3000; | ||
var adslot1 = 'preciso-adslot-1'; | ||
var adslot2 = 'preciso-adslot-2'; | ||
|
||
// define Ad units | ||
var adUnits = [ | ||
{ | ||
code: adslot1, | ||
mediaTypes: { | ||
banner: { | ||
sizes: div_1_sizes | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'preciso', | ||
params: { | ||
publisherId: 'PRECISO_TEST00001', | ||
traffic: 'banner', | ||
bidFloor: 0.12, | ||
currency: 'USD' | ||
} | ||
}] | ||
}, | ||
{ | ||
code: adslot2, | ||
mediaTypes: { | ||
banner: { | ||
sizes: div_2_sizes | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'preciso', | ||
params: { | ||
publisherId: 'PRECISO_TEST00001', | ||
host: 'prebid', | ||
traffic: 'banner', | ||
bidFloor: 0.28, | ||
currency: 'INR' | ||
} | ||
}] | ||
} | ||
]; | ||
|
||
|
||
|
||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
pbjs.que.push(function () { | ||
pbjs.addAdUnits(adUnits); | ||
// Pbjs configurations | ||
pbjs.setConfig({ | ||
userSync: { | ||
userIds: [{ | ||
name: 'sharedId', | ||
storage: { | ||
name: '_sharedid', | ||
type: 'cookie', | ||
expires: 365 | ||
} | ||
}], | ||
filterSettings: { | ||
iframe: { | ||
bidders: ['preciso'], | ||
filter: 'include' | ||
}, | ||
image: { | ||
bidders: ['preciso'], | ||
filter: 'include' | ||
} | ||
} | ||
}, | ||
realTimeData: { | ||
dataProviders: [{ | ||
"name": "geolocation", | ||
"waitForIt": true, | ||
"params": { | ||
"requestPermission": true | ||
} | ||
}] | ||
}, | ||
floors: { | ||
floorMin: 0.32, | ||
currency: ['USD'] | ||
}, | ||
ortb2: { | ||
bcat: ['IAB1-1'], | ||
badv: ['example.com'], | ||
wlang: ['fr', 'en'] | ||
}, | ||
enableTIDs: true | ||
}); | ||
pbjs.setTargetingForGPTAsync(); | ||
pbjs.requestBids({ | ||
bidsBackHandler: function () { | ||
// call for the bid response which have the high bid price | ||
let ad1 = pbjs.getHighestCpmBids(adslot1) | ||
let ad2 = pbjs.getHighestCpmBids(adslot2) | ||
if (ad1 && ad1.length > 0) { | ||
var iframe1 = document.getElementById('preciso-iframe-1'); | ||
var iframe1Doc = iframe1.contentWindow.document; | ||
try { | ||
pbjs.renderAd(iframe1Doc, ad1[0]['adId']); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} else { | ||
console.log("No bids for the adslot : " + adslot1); | ||
}; | ||
if (ad2 && ad2.length > 0) { | ||
var iframe2 = document.getElementById('preciso-iframe-2'); | ||
var iframe2Doc = iframe2.contentWindow.document; | ||
try { | ||
pbjs.renderAd(iframe2Doc, ad2[0]['adId']); | ||
} catch (e) { | ||
console.log(e) | ||
} | ||
} else { | ||
console.log("No bids for the adslot : " + adslot2); | ||
}; | ||
|
||
var bids = pbjs.getBidResponses(); | ||
console.log('Bids received Test test:', bids); | ||
pbjs.setTargetingForAst(); | ||
console.log('Rendering ads...'); | ||
}, | ||
timeout: PREBID_TIMEOUT | ||
}); | ||
|
||
}); | ||
|
||
</script> | ||
|
||
</head> | ||
|
||
<body> | ||
<!-- Ad slot Creation --> | ||
<h2>Basic Prebid.js Example with Preciso Bidder</h2> | ||
<h3>Adslot-1</h3> | ||
<div id='div-1' style="display: inline-block;"> | ||
<iframe id='preciso-iframe-1' style="min-width: 350px; min-height: 600px; padding: 0%;" scrolling="no"></iframe> | ||
</div> | ||
|
||
<div id='div-2' style="margin-left: 30; vertical-align: top; display: inline-block;"> | ||
<h3>Adslot-2</h3> | ||
<iframe id='preciso-iframe-2' style="min-width: 970px; min-height: 250px; " scrolling="no"></iframe> | ||
</div> | ||
|
||
</body> | ||
|
||
</html> |
This file contains hidden or 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,104 @@ | ||
import { convertOrtbRequestToProprietaryNative } from '../../src/native.js'; | ||
import { replaceAuctionPrice } from '../../src/utils.js'; | ||
import { getStorageManager } from '../../src/storageManager.js'; | ||
import { ajax } from '../../src/ajax.js'; | ||
import { MODULE_TYPE_UID } from '../../src/activities/modules.js'; | ||
import { consentCheck } from './bidUtilsCommon.js'; | ||
|
||
export const storage = getStorageManager({ moduleType: MODULE_TYPE_UID, moduleName: 'sharedId' }); | ||
|
||
export const buildRequests = (endpoint) => (validBidRequests = [], bidderRequest) => { | ||
// convert Native ORTB definition to old-style prebid native definition | ||
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); | ||
var city = Intl.DateTimeFormat().resolvedOptions().timeZone; | ||
let req = { | ||
// bidRequest: bidderRequest, | ||
id: validBidRequests[0].auctionId, | ||
cur: validBidRequests[0].params.currency || ['USD'], | ||
imp: validBidRequests.map(req => { | ||
const { bidId, sizes } = req | ||
const impValue = { | ||
id: bidId, | ||
bidfloor: req.params.bidFloor, | ||
bidfloorcur: req.params.currency | ||
} | ||
if (req.mediaTypes.banner) { | ||
impValue.banner = { | ||
format: (req.mediaTypes.banner.sizes || sizes).map(size => { | ||
return { w: size[0], h: size[1] } | ||
}), | ||
|
||
} | ||
} | ||
return impValue | ||
}), | ||
user: { | ||
id: validBidRequests[0].userId.pubcid || '', | ||
buyeruid: validBidRequests[0].buyerUid || '', | ||
geo: { | ||
country: validBidRequests[0].params.region || city, | ||
}, | ||
|
||
}, | ||
device: validBidRequests[0].ortb2.device, | ||
site: validBidRequests[0].ortb2.site, | ||
source: validBidRequests[0].ortb2.source, | ||
bcat: validBidRequests[0].ortb2.bcat || validBidRequests[0].params.bcat, | ||
badv: validBidRequests[0].ortb2.badv || validBidRequests[0].params.badv, | ||
wlang: validBidRequests[0].ortb2.wlang || validBidRequests[0].params.wlang, | ||
}; | ||
if (req.device && req.device != 'undefined') { | ||
req.device.geo = { | ||
country: req.user.geo.country | ||
}; | ||
}; | ||
req.site.publisher = { | ||
publisherId: validBidRequests[0].params.publisherId | ||
}; | ||
|
||
// req.language.indexOf('-') != -1 && (req.language = req.language.split('-')[0]) | ||
consentCheck(bidderRequest, req); | ||
return { | ||
method: 'POST', | ||
url: endpoint, | ||
data: req, | ||
|
||
}; | ||
} | ||
|
||
export function interpretResponse(serverResponse) { | ||
const bidsValue = [] | ||
const bidResponse = serverResponse.body | ||
bidResponse.seatbid.forEach(seat => { | ||
seat.bid.forEach(bid => { | ||
bidsValue.push({ | ||
requestId: bid.impid, | ||
cpm: bid.price, | ||
width: bid.w, | ||
height: bid.h, | ||
creativeId: bid.crid, | ||
ad: macroReplace(bid.adm, bid.price), | ||
currency: 'USD', | ||
netRevenue: true, | ||
ttl: 300, | ||
meta: { | ||
advertiserDomains: bid.adomain || '', | ||
}, | ||
}) | ||
}) | ||
}) | ||
return bidsValue | ||
} | ||
|
||
export function onBidWon(bid) { | ||
if (bid.nurl) { | ||
const resolvedNurl = replaceAuctionPrice(bid.nurl, bid.price); | ||
ajax(resolvedNurl); | ||
} | ||
} | ||
|
||
/* replacing auction_price macro from adm */ | ||
function macroReplace(adm, cpm) { | ||
let replacedadm = replaceAuctionPrice(adm, cpm); | ||
return replacedadm; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.