Skip to content

Commit

Permalink
ucfunnel adapter support supply chain (prebid#4383)
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 adapter support supply chain
  • Loading branch information
ucfunnel authored and sa1omon committed Nov 28, 2019
1 parent 9f4654e commit e152af7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
26 changes: 25 additions & 1 deletion modules/ucfunnelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,28 @@ function parseSizes(bid) {
return transformSizes(bid.sizes);
}

function getSupplyChain(schain) {
var supplyChain = '';
if (schain != null && schain.nodes) {
supplyChain = schain.ver + ',' + schain.complete;
for (let i = 0; i < schain.nodes.length; i++) {
supplyChain += '!';
supplyChain += (schain.nodes[i].asi) ? encodeURIComponent(schain.nodes[i].asi) : '';
supplyChain += ',';
supplyChain += (schain.nodes[i].sid) ? encodeURIComponent(schain.nodes[i].sid) : '';
supplyChain += ',';
supplyChain += (schain.nodes[i].hp) ? encodeURIComponent(schain.nodes[i].hp) : '';
supplyChain += ',';
supplyChain += (schain.nodes[i].rid) ? encodeURIComponent(schain.nodes[i].rid) : '';
supplyChain += ',';
supplyChain += (schain.nodes[i].name) ? encodeURIComponent(schain.nodes[i].name) : '';
supplyChain += ',';
supplyChain += (schain.nodes[i].domain) ? encodeURIComponent(schain.nodes[i].domain) : '';
}
}
return supplyChain;
}

function getRequestData(bid, bidderRequest) {
const size = parseSizes(bid);
const loc = utils.getTopWindowLocation();
Expand All @@ -169,6 +191,7 @@ function getRequestData(bid, bidderRequest) {
const videoContext = utils.deepAccess(bid, 'mediaTypes.video.context');
const videoMediaType = utils.deepAccess(bid, 'mediaTypes.video');
const userIdTdid = (bid.userId && bid.userId.tdid) ? bid.userId.tdid : '';
const supplyChain = getSupplyChain(bid.schain);
// general bid data
let bidData = {
ver: VER,
Expand All @@ -182,7 +205,8 @@ function getRequestData(bid, bidderRequest) {
adid: utils.getBidIdParameter('adid', bid.params),
w: size[0],
h: size[1],
tdid: userIdTdid
tdid: userIdTdid,
schain: supplyChain
};

if (bid.mediaType === 'video' || videoMediaType) {
Expand Down
15 changes: 15 additions & 0 deletions test/spec/modules/ucfunnelBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ const validBannerBidReq = {
sizes: [[300, 250]],
bidId: '263be71e91dd9d',
auctionId: '9ad1fa8d-2297-4660-a018-b39945054746',
'schain': {
'ver': '1.0',
'complete': 1,
'nodes': [
{
'asi': 'exchange1.com',
'sid': '1234',
'hp': 1,
'rid': 'bid-request-1',
'name': 'publisher',
'domain': 'publisher.com'
}
]
}
};

const invalidBannerBidReq = {
Expand Down Expand Up @@ -114,6 +128,7 @@ describe('ucfunnel Adapter', function () {
const [ width, height ] = validBannerBidReq.sizes[0];
expect(data.w).to.equal(width);
expect(data.h).to.equal(height);
expect(data.schain).to.equal('1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com');
});

it('must parse bid size from a nested array', function () {
Expand Down

0 comments on commit e152af7

Please sign in to comment.