Skip to content

Commit

Permalink
Livewrapped support for video (#5724)
Browse files Browse the repository at this point in the history
* Livewrapped bid and analytics adapter

* Fixed some tests for browser compatibility

* Fixed some tests for browser compatibility

* Changed analytics adapter code name

* Fix double quote in debug message

* modified how gdpr is being passed

* Added support for Publisher Common ID Module

* Corrections for ttr in analytics

* ANalytics updates

* Auction start time stamp changed

* Detect recovered ad blocked requests
Make it possible to pass dynamic parameters to adapter

* Collect info on ad units receiving any valid bid

* Support for ID5
Pass metadata from adapter

* Typo in test + eids on wrong level

* Fix for Prebid 3.0

* Fix get referer

* http -> https in tests

* Native support

* Read sizes from mediatype.banner

* Revert accidental commit

* Support native data collection + minor refactorings

* Set analytics endpoint

* Support for app parameters

* Fix issue where adunits with bids were not counted on reload

* Send debug info from adapter to external debugger

* SChain support

* Send GDPR data in analytics request

* video support

Video support
  • Loading branch information
bjorn-lw authored Sep 15, 2020
1 parent f61be0c commit cb733da
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 27 deletions.
2 changes: 1 addition & 1 deletion modules/livewrappedAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE
bidResponse.cpm = args.cpm;
bidResponse.ttr = args.timeToRespond;
bidResponse.readyToSend = 1;
bidResponse.mediaType = args.mediaType == 'native' ? 2 : 1;
bidResponse.mediaType = args.mediaType == 'native' ? 2 : (args.mediaType == 'video' ? 4 : 1);
if (!bidResponse.ttr) {
bidResponse.ttr = time - bidResponse.start;
}
Expand Down
17 changes: 12 additions & 5 deletions modules/livewrappedBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import find from 'core-js-pure/features/array/find.js';
import { BANNER, NATIVE } from '../src/mediaTypes.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { getStorageManager } from '../src/storageManager.js';

export const storage = getStorageManager();

const BIDDER_CODE = 'livewrapped';
export const URL = 'https://lwadm.com/ad';
const VERSION = '1.3';
const VERSION = '1.4';

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, NATIVE],
supportedMediaTypes: [BANNER, NATIVE, VIDEO],

/**
* Determines whether or not the given bid request is valid.
Expand Down Expand Up @@ -129,7 +129,12 @@ export const spec = {

if (ad.native) {
bidResponse.native = ad.native;
bidResponse.mediaType = NATIVE
bidResponse.mediaType = NATIVE;
}

if (ad.video) {
bidResponse.mediaType = VIDEO;
bidResponse.vastXml = ad.tag;
}

bidResponses.push(bidResponse);
Expand Down Expand Up @@ -218,7 +223,9 @@ function bidToAdRequest(bid) {

adRequest.native = utils.deepAccess(bid, 'mediaTypes.native');

if (adRequest.native && utils.deepAccess(bid, 'mediaTypes.banner')) {
adRequest.video = utils.deepAccess(bid, 'mediaTypes.video');

if ((adRequest.native || adRequest.video) && utils.deepAccess(bid, 'mediaTypes.banner')) {
adRequest.banner = true;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/livewrappedBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Connects to Livewrapped Header Bidding wrapper for bids.

Livewrapped supports banner.
Livewrapped supports banner, native and video.

# Test Parameters

Expand Down
113 changes: 93 additions & 20 deletions test/spec/modules/livewrappedBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {expect} from 'chai';
import {spec, storage} from 'modules/livewrappedBidAdapter.js';
import {config} from 'src/config.js';
import * as utils from 'src/utils.js';
import { BANNER, NATIVE } from 'src/mediaTypes.js';
import { BANNER, NATIVE, VIDEO } from 'src/mediaTypes.js';

describe('Livewrapped adapter tests', function () {
let sandbox,
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -139,7 +139,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -177,7 +177,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -208,7 +208,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -238,7 +238,7 @@ describe('Livewrapped adapter tests', function () {
let expectedQuery = {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
url: 'https://www.domain.com',
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -270,7 +270,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
version: '1.3',
version: '1.4',
width: 100,
height: 100,
deviceId: 'deviceid',
Expand Down Expand Up @@ -303,7 +303,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
version: '1.3',
version: '1.4',
width: 100,
height: 100,
tid: 'tracking id',
Expand Down Expand Up @@ -335,7 +335,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -366,7 +366,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -397,7 +397,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -428,7 +428,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand All @@ -445,6 +445,37 @@ describe('Livewrapped adapter tests', function () {
expect(data).to.deep.equal(expectedQuery);
});

it('should make a well-formed single request object with video only parameters', function() {
sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false);
sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => true);
let testbidRequest = clone(bidderRequest);
delete testbidRequest.bids[0].params.userId;
delete testbidRequest.bids[0].params.seats;
delete testbidRequest.bids[0].params.adUnitId;
testbidRequest.bids[0].mediaTypes = {'video': {'videodata': 'content parsed serverside only'}};
let result = spec.buildRequests(testbidRequest.bids, testbidRequest);
let data = JSON.parse(result.data);

let expectedQuery = {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
adRequests: [{
callerAdUnitId: 'panorama_d_1',
bidId: '2ffb201a808da7',
transactionId: '3D1C8CF7-D288-4D7F-8ADD-97C553056C3D',
formats: [{width: 980, height: 240}, {width: 980, height: 120}],
video: {'videodata': 'content parsed serverside only'}
}]
};

expect(data).to.deep.equal(expectedQuery);
});

it('should use app objects', function() {
sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false);
sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => true);
Expand Down Expand Up @@ -474,7 +505,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://appdomain.com',
seats: {'dsp': ['seat 1']},
version: '1.3',
version: '1.4',
width: 300,
height: 200,
ifa: 'ifa',
Expand Down Expand Up @@ -507,7 +538,7 @@ describe('Livewrapped adapter tests', function () {
auctionId: 'F7557995-65F5-4682-8782-7D5D34D82A8C',
publisherId: '26947112-2289-405D-88C1-A7340C57E63E',
url: 'https://www.domain.com',
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -541,7 +572,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -577,7 +608,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -608,7 +639,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: false,
Expand Down Expand Up @@ -638,7 +669,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: false,
Expand Down Expand Up @@ -701,7 +732,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'pubcid 123',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -733,7 +764,7 @@ describe('Livewrapped adapter tests', function () {
userId: 'user id',
url: 'https://www.domain.com',
seats: {'dsp': ['seat 1']},
version: '1.3',
version: '1.4',
width: 100,
height: 100,
cookieSupport: true,
Expand Down Expand Up @@ -895,6 +926,48 @@ describe('Livewrapped adapter tests', function () {
expect(bids).to.deep.equal(expectedResponse);
})

it('should handle single video success response', function() {
let lwResponse = {
ads: [
{
id: '28e5ddf4-3c01-11e8-86a7-0a44794250d4',
callerId: 'site_outsider_0',
tag: 'VAST XML',
video: {},
width: 300,
height: 250,
cpmBid: 2.565917,
bidId: '32e50fad901ae89',
auctionId: '13e674db-d4d8-4e19-9d28-ff38177db8bf',
creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077',
ttl: 120,
meta: undefined
}
],
currency: 'USD'
};

let expectedResponse = [{
requestId: '32e50fad901ae89',
bidderCode: 'livewrapped',
cpm: 2.565917,
width: 300,
height: 250,
ad: 'VAST XML',
ttl: 120,
creativeId: '52cbd598-2715-4c43-a06f-229fc170f945:427077',
netRevenue: true,
currency: 'USD',
meta: undefined,
vastXml: 'VAST XML',
mediaType: VIDEO
}];

let bids = spec.interpretResponse({body: lwResponse});

expect(bids).to.deep.equal(expectedResponse);
})

it('should handle multiple success response', function() {
let lwResponse = {
ads: [
Expand Down

0 comments on commit cb733da

Please sign in to comment.