Skip to content

Commit

Permalink
ucfunnel adapter add bidfloor parameter (prebid#4495)
Browse files Browse the repository at this point in the history
* Add a new ucfunnel Adapter and test page

* Add a new ucfunnel Adapter and test page

* 1. Use prebid lib in the repo to keep updated
2. Replace var with let
3. Put JSON.parse(JSON.stringify()) into try catch block

* utils.getTopWindowLocation is a function

* Change to modules from adapters

* Migrate to module design

* [Dev Fix] Remove width and height which can be got from ad unit id

* Update ucfunnelBidAdapter to fit into new spec

* Correct the endpoint. Fix the error of query string

* Add test case for ucfunnelBidAdapter

* Fix lint error

* Update version number

* Combine all checks on bid request

* Add GDPR support for ucfunnel adapter

* Add in-stream video and native support for ucfunnel adapter

* Remove demo page. Add more test cases.

* Change request method from POST to GET

* Remove unnecessary comment

* Support vastXml and vastUrl for video request

* update TTL to 30 mins

* Avoid using arrow function which is not discuraged in mocha

* ucfunnel tdid support

* ucfunnel fix error message in debug mode

* ucfunnel adapter add bidfloor parameter
  • Loading branch information
ucfunnel authored and tadam75 committed Jan 9, 2020
1 parent 7e237c6 commit 776621b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
6 changes: 5 additions & 1 deletion modules/ucfunnelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export const spec = {
ttl: 1800
};

if (bidRequest.params && bidRequest.params.bidfloor && ad.cpm && ad.cpm < bidRequest.params.bidfloor) {
bid.cpm = 0;
}
if (ad.creative_type) {
bid.mediaType = ad.creative_type;
}
Expand Down Expand Up @@ -207,7 +210,8 @@ function getRequestData(bid, bidderRequest) {
w: size[0],
h: size[1],
tdid: userIdTdid,
schain: supplyChain
schain: supplyChain,
fp: utils.getBidIdParameter('bidfloor', bid.params)
};

if (bid.mediaType === 'video' || videoMediaType) {
Expand Down
33 changes: 26 additions & 7 deletions test/spec/modules/ucfunnelBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const BIDDER_CODE = 'ucfunnel';
const validBannerBidReq = {
bidder: BIDDER_CODE,
params: {
adid: 'ad-34BBD2AA24B678BBFD4E7B9EE3B872D'
adid: 'ad-34BBD2AA24B678BBFD4E7B9EE3B872D',
bidfloor: 1.0
},
sizes: [[300, 250]],
bidId: '263be71e91dd9d',
Expand Down Expand Up @@ -42,7 +43,7 @@ const validBannerBidRes = {
creative_type: BANNER,
ad_id: 'ad-34BBD2AA24B678BBFD4E7B9EE3B872D',
adm: '<html style="height:100%"><body style="width:300px;height: 100%;padding:0;margin:0 auto;"><div style="width:100%;height:100%;display:table;"><div style="width:100%;height:100%;display:table-cell;text-align:center;vertical-align:middle;"><a href="//www.ucfunnel.com/" target="_blank"><img src="//cdn.aralego.net/ucfad/house/ucf/AdGent-300x250.jpg" width="300px" height="250px" align="middle" style="border:none"></a></div></div></body></html>',
cpm: 0.01,
cpm: 1.01,
height: 250,
width: 300
};
Expand All @@ -64,7 +65,7 @@ const validVideoBidRes = {
ad_id: 'ad-9A22D466494297EAC443D967B2622DA9',
vastUrl: 'https://ads.aralego.com/ads/58f9749f-0553-4993-8d9a-013a38b29e55',
vastXml: '<VAST version="3.0"><Ad id="preroll-1"><InLine><AdSystem>ucX</AdSystem><AdTitle> I-Primo </AdTitle><Creatives><Creative><Linear><Duration>00:00:30</Duration><TrackingEvents><Tracking event="start"><![CDATA[https://dev-ads.aralego.com/c/ucfunnel-test-vad-campaign/start]]></Tracking><Tracking event="complete"><![CDATA[https://dev-ads.aralego.com/c/ucfunnel-test-vad-campaign/complete]]></Tracking><Tracking event="unmute"><![CDATA[https://dev-ads.aralego.com/c/ucfunnel-test-vad-campaign/umute]]></Tracking><Tracking event="rewind"><![CDATA[https://dev-ads.aralego.com/c/ucfunnel-test-vad-campaign/rewind]]></Tracking></TrackingEvents><VideoClicks><ClickThrough><![CDATA[https://www.iprimo.tw/]]></ClickThrough><ClickTracking><![CDATA[https://dev-ads.aralego.com/c/ucfunnel-test-vad-campaign/clk]]></ClickTracking></VideoClicks><MediaFiles><MediaFile width="1920" height="1080" type="video/mp4" delivery="progressive"><![CDATA[https://cdn.aralego.net/ucfad/house/ucf/i-primo.mp4]]</MediaFile></MediaFiles></Linear></Creative></Creatives></InLine></Ad></VAST>',
cpm: 0.01,
cpm: 1.01,
width: 640,
height: 360
};
Expand Down Expand Up @@ -100,7 +101,7 @@ const validNativeBidRes = {
clickUrl: 'https://www.ucfunnel.com',
impressionTrackers: ['https://www.aralego.net/imp?mf=native&adid=ad-9A22D466494297EAC443D967B2622DA9&auc=9ad1fa8d-2297-4660-a018-b39945054746'],
},
cpm: 0.01,
cpm: 1.01,
height: 1,
width: 1
};
Expand Down Expand Up @@ -158,7 +159,7 @@ describe('ucfunnel Adapter', function () {
expect(bid.mediaType).to.equal(BANNER);
expect(bid.ad).to.exist;
expect(bid.requestId).to.equal('263be71e91dd9d');
expect(bid.cpm).to.equal(0.01);
expect(bid.cpm).to.equal(1.01);
expect(bid.width).to.equal(300);
expect(bid.height).to.equal(250);
});
Expand All @@ -182,6 +183,24 @@ describe('ucfunnel Adapter', function () {
});
});

describe('handle banner cpm under bidfloor', function () {
const request = spec.buildRequests([ validBannerBidReq ]);
const result = spec.interpretResponse({body: invalidBannerBidRes}, request[0]);
it('should build bid array for banner', function () {
expect(result.length).to.equal(1);
});

it('should have all relevant fields', function () {
const bid = result[0];

expect(bid.ad).to.exist;
expect(bid.requestId).to.equal('263be71e91dd9d');
expect(bid.cpm).to.equal(0);
expect(bid.width).to.equal(300);
expect(bid.height).to.equal(250);
});
});

describe('should support video', function () {
const request = spec.buildRequests([ validVideoBidReq ]);
const result = spec.interpretResponse({body: validVideoBidRes}, request[0]);
Expand All @@ -196,7 +215,7 @@ describe('ucfunnel Adapter', function () {
expect(bid.vastUrl).to.exist;
expect(bid.vastXml).to.exist;
expect(bid.requestId).to.equal('263be71e91dd9f');
expect(bid.cpm).to.equal(0.01);
expect(bid.cpm).to.equal(1.01);
expect(bid.width).to.equal(640);
expect(bid.height).to.equal(360);
});
Expand All @@ -215,7 +234,7 @@ describe('ucfunnel Adapter', function () {
expect(bid.mediaType).to.equal(NATIVE);
expect(bid.native).to.exist;
expect(bid.requestId).to.equal('263be71e91dda0');
expect(bid.cpm).to.equal(0.01);
expect(bid.cpm).to.equal(1.01);
expect(bid.width).to.equal(1);
expect(bid.height).to.equal(1);
});
Expand Down

0 comments on commit 776621b

Please sign in to comment.