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

Support Vast Track #4276

Merged
merged 43 commits into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8d635ff
Add microadBidAdapter
Feb 15, 2019
3055b90
Remove unnecessary encodeURIComponent from microadBidAdapter
Feb 26, 2019
67fb91b
Submit Advangelists Prebid Adapter
Feb 26, 2019
3ebb916
Submit Advangelists Prebid Adapter 1.1
Feb 27, 2019
4f5c451
Correct procudtion endpoint for prebid
Feb 28, 2019
2dc6d1d
Merge branch 'microad-bid-adapter' of git://github.com/strong-zero/Pr…
Feb 28, 2019
fa3e081
Merge remote-tracking branch 'origin/master' into master-rubicon-clean
Mar 18, 2019
600a46e
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Mar 18, 2019
7f578b3
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 23, 2019
176a312
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 26, 2019
9abf89c
Merge branch 'master' of https://github.com/prebid/Prebid.js
May 13, 2019
6ce04ab
Merge remote-tracking branch 'upstream/master'
Jun 10, 2019
415e2f6
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jun 27, 2019
61fb82c
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 11, 2019
3cc4c67
analytics update with wrapper name
Jul 11, 2019
cd81e02
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
e2b4e04
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
53b5970
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
5c00ed5
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 16, 2019
28848ad
reverted error merge
Jul 16, 2019
ab635ee
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 19, 2019
93308f5
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 24, 2019
1cfd52d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 25, 2019
d619807
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 27, 2019
9893f0f
Merge branch 'master' of https://github.com/prebid/Prebid.js
Aug 7, 2019
986a251
Merge remote-tracking branch 'upstream/master'
Aug 23, 2019
2cae7c0
Merge branch 'master' of https://github.com/prebid/Prebid.js into ori…
Aug 27, 2019
d7fd252
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 4, 2019
c7c01ba
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 10, 2019
24a28aa
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 10, 2019
7a1a4ec
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Sep 25, 2019
4173d16
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 25, 2019
ca13952
update changed default value of netRevenue to true
Sep 27, 2019
0b6cd48
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 3, 2019
5f0110d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 3, 2019
f930a34
Merge remote-tracking branch 'upstream/master'
Oct 8, 2019
1829c26
Add parameters if config.cache.vasttrack is true
Oct 8, 2019
e7cb303
Merge branch 'master' into hb-6317-support-vast-track
Oct 8, 2019
e7a414d
Use requestId instead of adId
Oct 9, 2019
a296893
Test new vasttrack payload params
Oct 9, 2019
6a6ad50
Removed commented out code
Oct 9, 2019
d54bcf1
Relaxed conditional check per review
Oct 10, 2019
f1d061c
Removed commented out line
Oct 11, 2019
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
10 changes: 8 additions & 2 deletions src/videoCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,18 @@ function wrapURI(uri, impUrl) {
*/
function toStorageRequest(bid) {
const vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl, bid.vastImpUrl);

let payload = {
type: 'xml',
value: vastValue,
ttlseconds: Number(bid.ttl)
};

if (config.getConfig('cache.vasttrack')) {
payload.bidder = bid.bidder;
payload.bidid = bid.requestId;
}

if (typeof bid.customCacheKey === 'string' && bid.customCacheKey !== '') {
payload.key = bid.customCacheKey;
}
Expand Down Expand Up @@ -94,7 +100,7 @@ function toStorageRequest(bid) {
*/
function shimStorageCallback(done) {
return {
success: function(responseBody) {
success: function (responseBody) {
let ids;
try {
ids = JSON.parse(responseBody).responses
Expand All @@ -109,7 +115,7 @@ function shimStorageCallback(done) {
done(new Error("The cache server didn't respond with a responses property."), []);
}
},
error: function(statusText, responseBody) {
error: function (statusText, responseBody) {
done(new Error(`Error storing video ad in the cache: ${statusText}: ${JSON.stringify(responseBody)}`), []);
}
}
Expand Down
59 changes: 56 additions & 3 deletions test/spec/videoCache_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('The video cache', function () {

it('should execute the callback with an error when store() is called', function () {
const callback = sinon.spy();
store([ { vastUrl: 'my-mock-url.com' } ], callback);
store([{ vastUrl: 'my-mock-url.com' }], callback);

requests[0].respond(503, {
'Content-Type': 'plain/text',
Expand Down Expand Up @@ -159,8 +159,61 @@ describe('The video cache', function () {
JSON.parse(request.requestBody).should.deep.equal(payload);
});

it('should include additional params in request payload should config.cache.vasttrack be true', () => {
config.setConfig({
cache: {
url: 'https://prebid.adnxs.com/pbc/v1/cache',
vasttrack: true
}
});

const customKey1 = 'vasttrack_123';
const customKey2 = 'vasttrack_abc';
const vastXml1 = '<VAST version="3.0">testvast1</VAST>';
const vastXml2 = '<VAST version="3.0">testvast2</VAST>';

const bids = [{
vastXml: vastXml1,
ttl: 25,
customCacheKey: customKey1,
requestId: '12345abc',
bidder: 'appnexus'
}, {
vastXml: vastXml2,
ttl: 25,
customCacheKey: customKey2,
requestId: 'cba54321',
bidder: 'rubicon'
}];

store(bids, function () { });
const request = requests[0];
request.method.should.equal('POST');
request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache');
request.requestHeaders['Content-Type'].should.equal('text/plain;charset=utf-8');
let payload = {
puts: [{
type: 'xml',
value: vastXml1,
ttlseconds: 25,
key: customKey1,
bidid: '12345abc',
bidder: 'appnexus'
}, {
type: 'xml',
value: vastXml2,
ttlseconds: 25,
key: customKey2,
bidid: 'cba54321',
bidder: 'rubicon'
}]
};

JSON.parse(request.requestBody).should.deep.equal(payload);
});

function assertRequestMade(bid, expectedValue) {
store([bid], function() { });
store([bid], function () { });

const request = requests[0];
request.method.should.equal('POST');
Expand All @@ -178,7 +231,7 @@ describe('The video cache', function () {

function fakeServerCall(bid, responseBody) {
const callback = sinon.spy();
store([ bid ], callback);
store([bid], callback);
requests[0].respond(
200,
{
Expand Down