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

Add gamoshi outstream renderer #2907

Merged
merged 7 commits into from
Jul 31, 2018
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
47 changes: 42 additions & 5 deletions modules/gambidBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as utils from 'src/utils';
import { registerBidder } from 'src/adapters/bidderFactory';
import { config } from 'src/config';
import { Renderer } from '../src/Renderer';

function getTopFrame() {
try {
Expand Down Expand Up @@ -128,7 +129,13 @@ export const spec = {
if (!bidRequest.bidRequest.mediaTypes || bidRequest.bidRequest.mediaTypes.banner) {
outBids.push(Object.assign({}, outBid, { mediaType: 'banner', ad: bid.adm }));
} else if (bidRequest.bidRequest.mediaTypes.video) {
outBids.push(Object.assign({}, outBid, { mediaType: 'video', vastUrl: bid.ext.vast_url, vastXml: bid.adm }));
const context = utils.deepAccess(bidRequest.bidRequest, 'mediaTypes.video.context');
outBids.push(Object.assign({}, outBid, {
mediaType: 'video',
vastUrl: bid.ext.vast_url,
vastXml: bid.adm,
renderer: context === 'outstream' ? newRenderer(bidRequest, bid) : undefined
}));
}
});
return outBids;
Expand Down Expand Up @@ -164,10 +171,40 @@ export const spec = {
}
});
return syncs;
},

onTimeout: function(data) {
utils.logWarn('Gambid request timed out.', data);
}
};

function newRenderer(adUnitCode, bid, rendererOptions = {}) {
const renderer = Renderer.install({
url: '//s.gamoshi.io/video/latest/renderer.js',
config: rendererOptions,
loaded: false,
});
try {
renderer.setRender(renderOutstream);
} catch (err) {
utils.logWarn('Prebid Error calling setRender on renderer', err);
}
return renderer;
}

function renderOutstream(bid) {
bid.renderer.push(() => {
const unitId = bid.adUnitCode + '/' + bid.adId;
window['GamoshiPlayer'].renderAd({
id: unitId,
debug: window.location.href.indexOf('pbjsDebug') >= 0,
placement: document.getElementById(bid.adUnitCode),
width: bid.width,
height: bid.height,
events: {
ALL_ADS_COMPLETED: () => window.setTimeout(() => {
window['GamoshiPlayer'].removeAd(unitId);
}, 300)
},
vastXml: bid.vastXml
});
});
}

registerBidder(spec);
26 changes: 13 additions & 13 deletions modules/gambidBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,61 +19,61 @@ var adUnits = [
// Banner adUnit
{
code: 'banner-div',
sizes: [[300, 250], [300,600]],
sizes: [[300, 250]],
bids: [{
bidder: 'gambid',
params: {

// ID of the supply partner you created in the Gambid dashboard
supplyPartnerId: '12345',
supplyPartnerId: '1253',

// OPTIONAL: if you have a whitelabel account on Gamoshi, specify it here
rtbEndpoint: 'https://my.custom-whitelabel-domain.io',
//rtbEndpoint: 'https://my.custom-whitelabel-domain.io',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason you commented out all these params?


// OPTIONAL: custom bid floor
bidfloor: 0.03,
bidfloor: 0.01,

// OPTIONAL: if you know the ad position on the page, specify it here
// (this corresponds to "Ad Position" in OpenRTB 2.3, section 5.4)
adpos: 1,
//adpos: 1,

// OPTIONAL: whether this is an interstitial placement (0 or 1)
// (see "instl" property in "Imp" object in the OpenRTB 2.3, section 3.2.2)
instl: 0
//instl: 0
}
}]
},

// Video outstream adUnit
{
code: 'video-outstream',
sizes: [[640, 480]],
sizes: [[300, 250]],
mediaTypes: {
video: {
context: 'outstream',
playerSize: [640, 480]
playerSize: [300, 250]
}
},
bids: [ {
bidder: 'gambid',
params: {

// ID of the supply partner you created in the Gambid dashboard
supplyPartnerId: '12345',
supplyPartnerId: '1254',

// OPTIONAL: if you have a whitelabel account on Gamoshi, specify it here
rtbEndpoint: 'https://my.custom-whitelabel-domain.io',
//rtbEndpoint: 'https://my.custom-whitelabel-domain.io',

// OPTIONAL: custom bid floor
bidfloor: 0.03,
bidfloor: 0.01,

// OPTIONAL: if you know the ad position on the page, specify it here
// (this corresponds to "Ad Position" in OpenRTB 2.3, section 5.4)
adpos: 1,
//adpos: 1,

// OPTIONAL: whether this is an interstitial placement (0 or 1)
// (see "instl" property in "Imp" object in the OpenRTB 2.3, section 3.2.2)
instl: 0
//instl: 0
}
}]
}
Expand Down