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

Latest #4

Merged
merged 41 commits into from
Dec 21, 2018
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
96fef93
Added 980x150 size (#3334)
hdeodhar Nov 29, 2018
e9bd097
replaced deprecated getWindowTopLocation with refererInfo.referer (#3…
bansawbanchee Nov 30, 2018
7aef26e
new TapHype bidder adapter (#3319)
aeliox Dec 3, 2018
6f1d23b
fix(adyoulike): use bidderRequest referer info (#3339)
j343my Dec 3, 2018
b215559
Fix for Quantum Adapter empty size detection (#3329)
benjaminclot Dec 4, 2018
5e3f144
update gulp packages to address vulnerability (#3343)
jsnellbaker Dec 4, 2018
96df52f
initial version of ozone adapter for review (#3307)
afsheenb Dec 4, 2018
f7473c7
update AdGenetation adapter (+1 squashed commit) (#3327)
banakemi Dec 4, 2018
d933a96
adding additional bid request validity checks. updating how we grab …
EMXDigital Dec 4, 2018
9e752d8
Update TTL to 30 mins (#3345)
Dec 4, 2018
9271d36
Set the OpenRTB device dimensions (#3336)
dbemiller Dec 4, 2018
00c955a
removing out console.log statements in ozoneBidAdapter test file (#3349)
jsnellbaker Dec 4, 2018
e8d9b1a
Prebid 1.35.0 Release
jsnellbaker Dec 4, 2018
650aa3a
increment pre version
jsnellbaker Dec 4, 2018
f80f2d5
Bidfluence Adapter update - Single call (#3347)
francescocristallo Dec 7, 2018
3b7f462
conditionally adds another param to browserParams (#3355)
susyt Dec 7, 2018
ca69912
enable ozone to support multiple bid responses (#3354)
afsheenb Dec 7, 2018
efc28ad
increment to correct pre version
jsnellbaker Dec 7, 2018
8fa2a84
update unit test example to mocha recommendations (#3361)
jsnellbaker Dec 7, 2018
522a0ce
Supply2 Bid Adapter (#3335)
Vishalrkanse Dec 7, 2018
13182f7
Dctr fixes (#3337)
pm-manasi-moghe Dec 7, 2018
5a2282e
Added publisher common ID support to sonobi adapter. (#3363)
edahood-sonobi Dec 10, 2018
239f180
adding native parameters: body2, rating, privacyLink (#3348)
aneuway2 Dec 10, 2018
f424cd2
Add user sync pixel logic in Adtelligent adapter (#3359)
GeneGenie Dec 10, 2018
88156e7
AppNexus debug auction via cookie (#3314)
aneuway2 Dec 10, 2018
4c1f690
fix bug when syncsPerBidder was set to 0 (#3360)
jsnellbaker Dec 13, 2018
ba49c0d
update conversant bid adapter to use video playerSize instead of size…
sohlhausen Dec 13, 2018
5253d29
Remove application json from bid request header (#3346)
ankur-modi Dec 13, 2018
bbc6316
feat(video-platform-ids): BID-3468: video support for platform IDs (#…
rjvelicaria Dec 14, 2018
32a611d
Add a new adapter for Appier bidder. (#3370)
PCMan-Appier Dec 14, 2018
65afce6
new no bid event and no bids available from auction (#3286)
snapwich Dec 17, 2018
14bf872
New bidder adapter for collectcent (#3365)
devcollectcent Dec 18, 2018
514fc5f
Added 640x360 size (#3388)
hdeodhar Dec 18, 2018
05df581
Added 250x800 size (#3390)
hdeodhar Dec 18, 2018
9277365
update AJA adapter: support user sync by iframe (#3382)
naoto0822 Dec 18, 2018
7224e78
Prebid 1.36.0 Release
Dec 18, 2018
691dcf6
Increment pre version
Dec 18, 2018
f2e5f17
add support for userSyncLimit field in s2sConfig (#3375)
jsnellbaker Dec 18, 2018
49ea705
Rivr thin adapter (#3351)
Dec 19, 2018
e5f4255
Fix multi-bid adId in Criteo bid adapter (#3340)
Spark-NF Dec 19, 2018
e476021
Modified the Telaria Bid Adapter to use bid.mediaTypes.video.playerSi…
telariaEng Dec 20, 2018
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
Prev Previous commit
Modified the Telaria Bid Adapter to use bid.mediaTypes.video.playerSi…
…ze instead of bid.sizes (prebid#3377)

* Added telaria bid adapter

* more documentation

* Added more test cases. And improved some code in the adapter

* Removed the check for optional params, they are handled in the server. Also updated certain param names used in  the test spec.

* added some spaces to fix CircleCI tests

* added some spaces to fix CircleCI tests

* fixed code indentation in /spec/AnalyticsAdapter_spec.js which causing the CircleCI tests to fail.

* Reverted the changes

* merged with prebid master.

* creative Id is required when we build a response but our server doesn't always have the crid, so using a sentinel value when we don't have the crid.

* - removed an un used method
- Removed the package-lock file.

* merging to master

* updated telaria bid adapter to use player size provided by the bid.mediaTypes.video.playerSize instead of bid.sizes.

prebid#3331

* - removed the requirement for having player size
- updated the test spec to reflect the above change
- removed changes to the package-lock.json file.

* added a param to the ad call url to let us know that the request is coming via hb.

* to lower casing the bidder code.
  • Loading branch information
telariaEng authored and bretg committed Dec 20, 2018
commit e47602142febf3469672fdcfa6f1f1574ec29a46
50 changes: 29 additions & 21 deletions modules/telariaBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as utils from 'src/utils';
import * as bidfactory from 'src/bidfactory';
import {registerBidder} from 'src/adapters/bidderFactory';
import {config} from 'src/config';
import {VIDEO} from '../src/mediaTypes';
import {STATUS} from 'src/constants';

@@ -24,17 +23,18 @@ export const spec = {
/**
* Make a server request from the list of BidRequests.
* @param validBidRequests list of valid bid requests that have passed isBidRequestValid check
* @param bidderRequest
* @returns {Array} of url objects
*/
buildRequests: function (validBidRequests) {
buildRequests: function (validBidRequests, bidderRequest) {
let requests = [];

validBidRequests.forEach(bid => {
let url = generateUrl(bid);
let url = generateUrl(bid, bidderRequest);
if (url) {
requests.push({
method: 'GET',
url: generateUrl(bid),
url: generateUrl(bid, bidderRequest),
bidId: bid.bidId,
vastUrl: url.split('&fmt=json')[0]
});
@@ -84,7 +84,7 @@ export const spec = {
utils.logError(errorMessage);
} else if (bidResult.seatbid && bidResult.seatbid.length > 0) {
bidResult.seatbid[0].bid.forEach(tag => {
bids.push(createBid(STATUS.GOOD, bidderRequest, tag, width, height, bidResult.seatbid[0].seat));
bids.push(createBid(STATUS.GOOD, bidderRequest, tag, width, height, bidResult.seatbid[0].seat.toLowerCase()));
});
}

@@ -112,28 +112,36 @@ export const spec = {
* Generates the url based on the parameters given. Sizes, supplyCode & adCode are required.
* The format is: [L,W] or [[L1,W1],...]
* @param bid
* @param bidderRequest
* @returns {string}
*/
function generateUrl(bid) {
let width, height;
if (!bid.sizes) {
return '';
function generateUrl(bid, bidderRequest) {
let playerSize = (bid.mediaTypes && bid.mediaTypes.video && bid.mediaTypes.video.playerSize);
if (!playerSize) {
utils.logWarn('Although player size isn\'t required it is highly recommended');
}

if (utils.isArray(bid.sizes) && (bid.sizes.length === 2) && (!isNaN(bid.sizes[0]) && !isNaN(bid.sizes[1]))) {
width = bid.sizes[0];
height = bid.sizes[1];
} else if (typeof bid.sizes === 'object') {
// take the primary (first) size from the array
width = bid.sizes[0][0];
height = bid.sizes[0][1];
let width, height;
if (playerSize) {
if (utils.isArray(playerSize) && (playerSize.length === 2) && (!isNaN(playerSize[0]) && !isNaN(playerSize[1]))) {
width = playerSize[0];
height = playerSize[1];
} else if (typeof playerSize === 'object') {
width = playerSize[0][0];
height = playerSize[0][1];
}
}
if (width && height && bid.params.supplyCode && bid.params.adCode) {

if (bid.params.supplyCode && bid.params.adCode) {
let scheme = ((document.location.protocol === 'https:') ? 'https' : 'http') + '://';
let url = scheme + bid.params.supplyCode + ENDPOINT + '?adCode=' + bid.params.adCode;

url += ('&playerWidth=' + width);
url += ('&playerHeight=' + height);
if (width) {
url += ('&playerWidth=' + width);
}
if (height) {
url += ('&playerHeight=' + height);
}

for (let key in bid.params) {
if (bid.params.hasOwnProperty(key) && bid.params[key]) {
@@ -145,8 +153,8 @@ function generateUrl(bid) {
url += ('&srcPageUrl=' + encodeURIComponent(document.location.href));
}

url += ('&transactionId=' + bid.transactionId);
url += ('&referrer=' + config.getConfig('pageUrl') || utils.getTopWindowUrl());
url += ('&transactionId=' + bid.transactionId + '&hb=1');
url += ('&referrer=' + encodeURIComponent(bidderRequest.refererInfo.referer));

return (url + '&fmt=json');
}
92 changes: 58 additions & 34 deletions test/spec/modules/telariaBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,12 @@ const SUPPLY_CODE = 'ssp-demo-rm6rh';
const SIZES = [640, 480];
const REQUEST = {
'code': 'video1',
'sizes': [640, 480],
'mediaTypes': {
'video': {
'playerSize': [[640, 480]],
'context': 'instream'
}
},
'mediaType': 'video',
'bids': [{
'bidder': 'tremor',
@@ -19,6 +24,12 @@ const REQUEST = {
}]
};

const BIDDER_REQUEST = {
'refererInfo': {
'referer': 'www.test.com'
}
};

const RESPONSE = {
'cur': 'USD',
'id': '3dba13e35f3d42f998bc7e65fd871889',
@@ -34,26 +45,26 @@ const RESPONSE = {
}]
};

describe('TelariaAdapter', function () {
describe('TelariaAdapter', () => {
const adapter = newBidder(spec);

describe('inherited functions', function () {
it('exists and is a function', function () {
describe('inherited functions', () => {
it('exists and is a function', () => {
expect(adapter.callBids).to.exist.and.to.be.a('function');
});
});

describe('isBidRequestValid', function () {
describe('isBidRequestValid', () => {
let bid = REQUEST.bids[0];

it('should return true when required params found', function () {
it('should return true when required params found', () => {
let tempBid = bid;
tempBid.params.adCode = 'ssp-!demo!-lufip';
tempBid.params.supplyCode = 'ssp-demo-rm6rh';
expect(spec.isBidRequestValid(bid)).to.equal(true);
});

it('should return true when required params found', function () {
it('should return true when required params found', () => {
let tempBid = bid;
delete tempBid.params;
tempBid.params = {
@@ -64,35 +75,40 @@ describe('TelariaAdapter', function () {
expect(spec.isBidRequestValid(tempBid)).to.equal(true);
});

it('should return false when required params are not passed', function () {
it('should return false when required params are not passed', () => {
let tempBid = bid;
tempBid.params = {};
expect(spec.isBidRequestValid(tempBid)).to.equal(false);
});
});

describe('buildRequests', function () {
describe('buildRequests', () => {
const stub = [{
mediaTypes: {
video: {
playerSize: [[640, 480]],
context: 'instream'
}
},
bidder: 'tremor',
sizes: [[300, 250], [300, 600]],
params: {
supplyCode: 'ssp-demo-rm6rh',
adCode: 'ssp-!demo!-lufip',
videoId: 'MyCoolVideo'
}
}];

it('exists and is a function', function () {
it('exists and is a function', () => {
expect(spec.buildRequests).to.exist.and.to.be.a('function');
});

it('requires supply code, ad code and sizes to make a request', function () {
const tempRequest = spec.buildRequests(stub);
it('requires supply code & ad code to make a request', () => {
const tempRequest = spec.buildRequests(stub, BIDDER_REQUEST);
expect(tempRequest.length).to.equal(1);
});

it('generates an array of requests with 4 params, method, url, bidId and vastUrl', function () {
const tempRequest = spec.buildRequests(stub);
it('generates an array of requests with 4 params, method, url, bidId and vastUrl', () => {
const tempRequest = spec.buildRequests(stub, BIDDER_REQUEST);

expect(tempRequest.length).to.equal(1);
expect(tempRequest[0].method).to.equal('GET');
@@ -101,77 +117,85 @@ describe('TelariaAdapter', function () {
expect(tempRequest[0].vastUrl).to.exist;
});

it('requires sizes to make a request', function () {
it('doesn\'t require player size but is highly recommended', () => {
let tempBid = stub;
tempBid[0].sizes = null;
const tempRequest = spec.buildRequests(tempBid);
tempBid[0].mediaTypes.video.playerSize = null;
const tempRequest = spec.buildRequests(tempBid, BIDDER_REQUEST);

expect(tempRequest.length).to.equal(0);
expect(tempRequest.length).to.equal(1);
});

it('generates a valid request with sizes as an array of two elements', function () {
it('generates a valid request with sizes as an array of two elements', () => {
let tempBid = stub;
tempBid[0].sizes = [640, 480];
expect(spec.buildRequests(tempBid).length).to.equal(1);
tempBid[0].mediaTypes.video.playerSize = [640, 480];
tempBid[0].params.adCode = 'ssp-!demo!-lufip';
tempBid[0].params.supplyCode = 'ssp-demo-rm6rh';
let builtRequests = spec.buildRequests(tempBid, BIDDER_REQUEST);
expect(builtRequests.length).to.equal(1);
});

it('requires ad code and supply code to make a request', function () {
it('requires ad code and supply code to make a request', () => {
let tempBid = stub;
tempBid[0].params.adCode = null;
tempBid[0].params.supplyCode = null;

const tempRequest = spec.buildRequests(tempBid);
const tempRequest = spec.buildRequests(tempBid, BIDDER_REQUEST);

expect(tempRequest.length).to.equal(0);
});
});

describe('interpretResponse', function () {
describe('interpretResponse', () => {
const responseStub = RESPONSE;
const stub = [{
mediaTypes: {
video: {
playerSize: [[640, 480]],
context: 'instream'
}
},
bidder: 'tremor',
sizes: [[300, 250], [300, 600]],
params: {
supplyCode: 'ssp-demo-rm6rh',
adCode: 'ssp-!demo!-lufip',
videoId: 'MyCoolVideo'
}
}];

it('should get correct bid response', function () {
it('should get correct bid response', () => {
let expectedResponseKeys = ['bidderCode', 'width', 'height', 'statusMessage', 'adId', 'mediaType', 'source',
'getStatusCode', 'getSize', 'requestId', 'cpm', 'creativeId', 'vastXml',
'vastUrl', 'currency', 'netRevenue', 'ttl', 'ad'];

let bidRequest = spec.buildRequests(stub)[0];
let bidRequest = spec.buildRequests(stub, BIDDER_REQUEST)[0];
bidRequest.bidId = '1234';
let result = spec.interpretResponse({body: responseStub}, bidRequest);
expect(Object.keys(result[0])).to.have.members(expectedResponseKeys);
});

it('handles nobid responses', function () {
it('handles nobid responses', () => {
let tempResponse = responseStub;
tempResponse.seatbid = [];

let bidRequest = spec.buildRequests(stub)[0];
let bidRequest = spec.buildRequests(stub, BIDDER_REQUEST)[0];
bidRequest.bidId = '1234';

let result = spec.interpretResponse({body: tempResponse}, bidRequest);
expect(result.length).to.equal(0);
});

it('handles invalid responses', function () {
it('handles invalid responses', () => {
let result = spec.interpretResponse(null, {bbidderCode: 'telaria'});
expect(result.length).to.equal(0);
});

it('handles error responses', function () {
it('handles error responses', () => {
let result = spec.interpretResponse({body: {error: 'Invalid request'}}, {bbidderCode: 'telaria'});
expect(result.length).to.equal(0);
});
});

describe('getUserSyncs', function () {
describe('getUserSyncs', () => {
const responses = [{body: RESPONSE}];
responses[0].body.ext = {
telaria: {
@@ -182,7 +206,7 @@ describe('TelariaAdapter', function () {
}
};

it('should get the correct number of sync urls', function () {
it('should get the correct number of sync urls', () => {
let urls = spec.getUserSyncs({pixelEnabled: true}, responses);
expect(urls.length).to.equal(2);
});