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 support for video bids to use an impression tracking URL #2365

Merged
merged 3 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ function newBid(serverBid, rtbBid, bidderRequest) {
width: rtbBid.rtb.video.player_width,
height: rtbBid.rtb.video.player_height,
vastUrl: rtbBid.rtb.video.asset_url,
vastImpUrl: rtbBid.notify_url,
ttl: 3600
});
// This supports Outstream Video
Expand Down
8 changes: 5 additions & 3 deletions src/videoCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ import { config } from '../src/config';
* Function which wraps a URI that serves VAST XML, so that it can be loaded.
*
* @param {string} uri The URI where the VAST content can be found.
* @param {string} impUrl An impression tracker URL for the delivery of the video ad
* @return A VAST URL which loads XML from the given URI.
*/
function wrapURI(uri) {
function wrapURI(uri, impUrl) {
// Technically, this is vulnerable to cross-script injection by sketchy vastUrl bids.
// We could make sure it's a valid URI... but since we're loading VAST XML from the
// URL they provide anyway, that's probably not a big deal.
let vastImp = (impUrl) ? `<![CDATA[${impUrl}]]>` : ``;
return `<VAST version="3.0">
<Ad>
<Wrapper>
<AdSystem>prebid.org wrapper</AdSystem>
<VASTAdTagURI><![CDATA[${uri}]]></VASTAdTagURI>
<Impression></Impression>
<Impression>${vastImp}</Impression>
<Creatives></Creatives>
</Wrapper>
</Ad>
Expand All @@ -57,7 +59,7 @@ function wrapURI(uri) {
* @param {CacheableBid} bid
*/
function toStorageRequest(bid) {
const vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl);
const vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl, bid.vastImpUrl);
return {
type: 'xml',
value: vastValue
Expand Down
2 changes: 2 additions & 0 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ describe('AppNexusAdapter', () => {
'ads': [{
'ad_type': 'video',
'cpm': 0.500000,
'notify_url': 'imptracker.com',
'rtb': {
'video': {
'content': '<!-- Creative -->'
Expand All @@ -424,6 +425,7 @@ describe('AppNexusAdapter', () => {

let result = spec.interpretResponse({ body: response }, {bidderRequest});
expect(result[0]).to.have.property('vastUrl');
expect(result[0]).to.have.property('vastImpUrl');
expect(result[0]).to.have.property('mediaType', 'video');
});

Expand Down
14 changes: 14 additions & 0 deletions test/spec/videoCache_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ describe('The video cache', () => {
assertRequestMade({ vastUrl: 'my-mock-url.com' }, expectedValue)
});

it('should make the expected request when store() is called on an ad with a vastUrl and vastImpUrl', () => {
const expectedValue = `<VAST version="3.0">
<Ad>
<Wrapper>
<AdSystem>prebid.org wrapper</AdSystem>
<VASTAdTagURI><![CDATA[my-mock-url.com]]></VASTAdTagURI>
<Impression><![CDATA[imptracker.com]]></Impression>
<Creatives></Creatives>
</Wrapper>
</Ad>
</VAST>`;
assertRequestMade({ vastUrl: 'my-mock-url.com', vastImpUrl: 'imptracker.com' }, expectedValue)
});

it('should make the expected request when store() is called on an ad with vastXml', () => {
const vastXml = '<VAST version="3.0"></VAST>';
assertRequestMade({ vastXml: vastXml }, vastXml);
Expand Down