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

Feature/smart video #4367

Merged
merged 11 commits into from
Nov 20, 2019
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
52 changes: 42 additions & 10 deletions modules/smartadserverBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import * as utils from '../src/utils';
import {
BANNER,
VIDEO
} from '../src/mediaTypes';
import {
config
} from '../src/config';
Expand All @@ -9,6 +13,7 @@ const BIDDER_CODE = 'smartadserver';
export const spec = {
code: BIDDER_CODE,
aliases: ['smart'], // short code
supportedMediaTypes: [BANNER, VIDEO],
/**
* Determines whether or not the given bid request is valid.
*
Expand All @@ -33,6 +38,7 @@ export const spec = {

// pull requested transaction ID from bidderRequest.bids[].transactionId
return validBidRequests.map(bid => {
// Common bid request attributes for banner, outstream and instream.
var payload = {
siteid: bid.params.siteId,
pageid: bid.params.pageId,
Expand All @@ -44,17 +50,33 @@ export const spec = {
appname: bid.params.appName && bid.params.appName != '' ? bid.params.appName : undefined,
ckid: bid.params.ckId || 0,
tagId: bid.adUnitCode,
sizes: bid.sizes.map(size => ({
w: size[0],
h: size[1]
})),
pageDomain: utils.getTopWindowUrl(),
transactionId: bid.transactionId,
timeout: config.getConfig('bidderTimeout'),
bidId: bid.bidId,
prebidVersion: '$prebid.version$'
};

const videoMediaType = utils.deepAccess(bid, 'mediaTypes.video');
if (!videoMediaType) {
payload.sizes = bid.sizes.map(size => ({
w: size[0],
h: size[1]
}));
} else if (videoMediaType && videoMediaType.context === 'instream') {
// Specific attributes for instream.
var playerSize = videoMediaType.playerSize[0];
payload.isVideo = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This variable is causing the returned outstream bid from your adserver to be setup as a banner creative (see line 126 below). The outstream bid should be treated as a video mediaType and ideally have an associated renderer.

payload.videoData = {
videoProtocol: bid.params.video.protocol,
playerWidth: playerSize[0],
playerHeight: playerSize[1],
adBreak: bid.params.video.startDelay || 0
};
} else {
return {};
}

if (bidderRequest && bidderRequest.gdprConsent) {
payload.gdpr_consent = bidderRequest.gdprConsent.consentString;
payload.gdpr = bidderRequest.gdprConsent.gdprApplies; // we're handling the undefined case server side
Expand All @@ -74,13 +96,15 @@ export const spec = {
* @param {*} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: function (serverResponse, bidRequest) {
interpretResponse: function (serverResponse, bidRequestString) {
const bidResponses = [];
var response = serverResponse.body;
try {
if (response) {
const bidResponse = {
requestId: JSON.parse(bidRequest.data).bidId,
const bidRequest = JSON.parse(bidRequestString.data);

var bidResponse = {
requestId: bidRequest.bidId,
cpm: response.cpm,
width: response.width,
height: response.height,
Expand All @@ -89,10 +113,18 @@ export const spec = {
currency: response.currency,
netRevenue: response.isNetCpm,
ttl: response.ttl,
referrer: utils.getTopWindowUrl(),
adUrl: response.adUrl,
ad: response.ad
referrer: utils.getTopWindowUrl()
};

if (bidRequest.isVideo) {
bidResponse.mediaType = VIDEO;
bidResponse.vastUrl = response.adUrl;
bidResponse.vastXml = response.ad;
} else {
bidResponse.adUrl = response.adUrl;
bidResponse.ad = response.ad;
}

bidResponses.push(bidResponse);
}
} catch (error) {
Expand Down
101 changes: 64 additions & 37 deletions modules/smartadserverBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
```
Module Name: Smart Ad Server Bidder Adapter
Module Type: Bidder Adapter
Maintainer: gcarnec@smartadserver.com
Maintainer: support@smartadserver.com
```

# Description
Expand All @@ -18,45 +18,72 @@ Please reach out to your Technical account manager for more information.
## Web
```
var adUnits = [
{
code: 'test-div',
sizes: [[300, 250]], // a display size
bids: [
{
bidder: "smart",
params: {
domain: 'http://ww251.smartadserver.com',
siteId: 207435,
pageId: 896536,
formatId: 62913,
ckId: 1122334455 // optional
}
}
]
}
];
{
code: 'test-div',
sizes: [[300, 250]], // a display size
bids: [
{
bidder: "smart",
params: {
domain: 'http://ww251.smartadserver.com',
siteId: 207435,
pageId: 896536,
formatId: 62913,
ckId: 1122334455 // optional
}
}
]
}
];
```

## In-app
```
var adUnits = [
{
code: 'test-div',
sizes: [[300, 250]], // a display size
bids: [
{
bidder: "smart",
params: {
domain: 'http://ww251.smartadserver.com',
siteId: 207435,
pageId: 896536,
formatId: 65906,
buId: "com.smartadserver.android.dashboard", // in-app only
appName: "Smart AdServer Preview", // in-app only
ckId: 1122334455 // optional
}
}
]
}
];
{
code: 'test-div',
sizes: [[300, 250]], // a display size
bids: [
{
bidder: "smart",
params: {
domain: 'http://ww251.smartadserver.com',
siteId: 207435,
pageId: 896536,
formatId: 65906,
buId: "com.smartadserver.android.dashboard", // in-app only
appName: "Smart AdServer Preview", // in-app only
ckId: 1122334455 // optional
}
}
]
}
];
```

## Instream Video
```
var videoAdUnit = {
code: 'test-div',
mediaTypes: {
video: {
context: 'instream',
playerSize: [640, 480]
}
},
bids: [{
bidder: "smart",
params: {
domain: 'http://ww251.smartadserver.com',
siteId: 326147,
pageId: 1153895,
formatId: 55710
bidfloor: 5,
video: {
protocol: 6,
startDelay: 0
}
}
}]
};
```
Loading