-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Sekindo Prebid Adapter : #355
Changes from 5 commits
56b515f
27e58d0
4572e9f
1c85c86
0ee9bb4
b64e51d
e8e36fa
88744ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { getBidRequest } from '../utils.js'; | ||
var CONSTANTS = require('../constants.json'); | ||
var utils = require('../utils.js'); | ||
var bidfactory = require('../bidfactory.js'); | ||
var bidmanager = require('../bidmanager.js'); | ||
|
||
var SekindoAdapter; | ||
SekindoAdapter = function SekindoAdapter() { | ||
|
||
function _callBids(params) { | ||
var bids = params.bids; | ||
var bidsCount = bids.length; | ||
|
||
var pubUrl = null; | ||
if (parent !== window) | ||
pubUrl = document.referrer; | ||
else | ||
pubUrl = window.location.href; | ||
|
||
for (var i = 0; i < bidsCount; i++) { | ||
var bidReqeust = bids[i]; | ||
var callbackId = bidReqeust.bidId; | ||
_requestBids(bidReqeust, callbackId, pubUrl); | ||
//store a reference to the bidRequest from the callback id | ||
//bidmanager.pbCallbackMap[callbackId] = bidReqeust; | ||
} | ||
} | ||
|
||
pbjs.sekindoCB = function(callbackId, response) | ||
{ | ||
if (typeof (response) != 'undefined' && typeof (response.cpm) != 'undefined') | ||
{ | ||
var bidObj = getBidRequest(callbackId); | ||
var bid = []; | ||
if (bidObj) | ||
{ | ||
var bidCode = bidObj.bidder; | ||
var placementCode = bidObj.placementCode; | ||
|
||
if (response.cpm !== undefined && response.cpm > 0) | ||
{ | ||
|
||
bid = bidfactory.createBid(CONSTANTS.STATUS.GOOD); | ||
bid.adId = response.adId; | ||
bid.callback_uid = callbackId; | ||
bid.bidderCode = bidCode; | ||
bid.creative_id = response.adId; | ||
bid.cpm = parseFloat(response.cpm); | ||
bid.ad = response.ad; | ||
bid.width = response.width; | ||
bid.height = response.height; | ||
|
||
bidmanager.addBidResponse(placementCode, bid); | ||
} | ||
else | ||
{ | ||
bid = bidfactory.createBid(CONSTANTS.STATUS.NO_BID); | ||
bid.callback_uid = callbackId; | ||
bid.bidderCode = bidCode; | ||
bidmanager.addBidResponse(placementCode, bid); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
utils.logMessage('No prebid response for placement %%PLACEMENT%%'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sekindo |
||
} | ||
}; | ||
|
||
function _requestBids(bid, callbackId, pubUrl) | ||
{ | ||
//determine tag params | ||
var spaceId = utils.getBidIdParamater('spaceId', bid.params); | ||
var bidfloor = utils.getBidIdParamater('bidfloor', bid.params); | ||
var protocol = ('https:' === document.location.protocol ? 's' : ''); | ||
var scriptSrc = 'https://live.sekindo.com/live/liveView.php?'; | ||
|
||
scriptSrc = utils.tryAppendQueryString(scriptSrc, 's', spaceId); | ||
scriptSrc = utils.tryAppendQueryString(scriptSrc, 'pubUrl', pubUrl); | ||
scriptSrc = utils.tryAppendQueryString(scriptSrc, 'hbcb', callbackId); | ||
scriptSrc = utils.tryAppendQueryString(scriptSrc, 'dcpmflr', bidfloor); | ||
scriptSrc = utils.tryAppendQueryString(scriptSrc, 'hbto', pbjs.bidderTimeout); | ||
scriptSrc = utils.tryAppendQueryString(scriptSrc, 'protocol', protocol); | ||
|
||
var html = '<scr'+'ipt type="text/javascript" src="'+scriptSrc+'"></scr'+'ipt>'; | ||
|
||
var iframe = utils.createInvisibleIframe(); | ||
iframe.id = 'skIfr_'+callbackId; | ||
|
||
var elToAppend = document.getElementsByTagName('head')[0]; | ||
//insert the iframe into document | ||
elToAppend.insertBefore(iframe, elToAppend.firstChild); | ||
|
||
var iframeDoc = utils.getIframeDocument(iframe); | ||
iframeDoc.write(html); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this script be loaded asynchronously? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It cannot, we use the iframe for async. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep. added |
||
iframeDoc.close(); | ||
} | ||
|
||
return { | ||
callBids: _callBids | ||
}; | ||
}; | ||
|
||
|
||
module.exports = SekindoAdapter; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use triple equality.