diff --git a/modules/tappxBidAdapter.js b/modules/tappxBidAdapter.js index 1e502274fc0..337779d1d53 100644 --- a/modules/tappxBidAdapter.js +++ b/modules/tappxBidAdapter.js @@ -9,7 +9,7 @@ import { Renderer } from '../src/Renderer.js'; const BIDDER_CODE = 'tappx'; const TTL = 360; const CUR = 'USD'; -const TAPPX_BIDDER_VERSION = '0.1.0818'; +const TAPPX_BIDDER_VERSION = '0.1.0921'; const TYPE_CNN = 'prebidjs'; const LOG_PREFIX = '[TAPPX]: '; const VIDEO_SUPPORT = ['instream', 'outstream']; @@ -195,6 +195,9 @@ function interpretBid(serverBid, request) { } if (typeof serverBid.dealId !== 'undefined') { bidReturned.dealId = serverBid.dealId } + if (typeof serverBid.lurl != 'undefined') { bidReturned.lurl = serverBid.lurl } + if (typeof serverBid.nurl != 'undefined') { bidReturned.nurl = serverBid.nurl } + if (typeof serverBid.burl != 'undefined') { bidReturned.burl = serverBid.burl } if (typeof request.bids.mediaTypes !== 'undefined' && typeof request.bids.mediaTypes.video !== 'undefined') { bidReturned.vastXml = serverBid.adm; @@ -324,6 +327,12 @@ function buildOneRequest(validBidRequests, bidderRequest) { video.mimes = videoMediaType.mimes; + let videoExt = {}; + if ((typeof videoMediaType.rewarded !== 'undefined') && videoMediaType.rewarded == 1) { + videoExt.rewarded = videoMediaType.rewarded; + } + video.ext = videoExt; + imp.video = video; } @@ -492,7 +501,8 @@ function outstreamRender(bid, request) { targetId: bid.adUnitCode, adResponse: bid.adResponse, rendererOptions: { - content: bid.vastXml + content: bid.vastXml, + skip: (typeof bid.params[0].video.skip != 'undefined' && bid.params[0].video.skip > 0) ? bid.params[0].video.skip : 0 } }); }); @@ -539,19 +549,11 @@ export function _checkParamDataType(key, value, datatype) { } export function _extractPageUrl(validBidRequests, bidderRequest) { - let domainUrl = deepAccess(validBidRequests, 'params.domainUrl'); + let referrer = deepAccess(bidderRequest, 'refererInfo.referer'); + let page = deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || deepAccess(window, 'location.href'); + let paramUrl = deepAccess(validBidRequests, 'params.domainUrl') || config.getConfig('pageUrl'); - if (typeof domainUrl == 'undefined' || domainUrl == null) { - domainUrl = config.getConfig('pageUrl') || deepAccess(bidderRequest, 'refererInfo.canonicalUrl'); - } - - if (typeof domainUrl == 'undefined' || domainUrl == null) { - try { - domainUrl = window.top.document.head.querySelector('link[rel="canonical"][href]').getAttribute('href'); - } catch (error) { - domainUrl = undefined; - } - } + let domainUrl = referrer || page || paramUrl; try { domainUrl = domainUrl.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)/img)[0].replace(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?/img, ''); @@ -559,10 +561,6 @@ export function _extractPageUrl(validBidRequests, bidderRequest) { domainUrl = undefined; } - if (typeof domainUrl == 'undefined' || domainUrl == null) { - domainUrl = window.location.hostname; - } - return domainUrl; } diff --git a/test/spec/modules/tappxBidAdapter_spec.js b/test/spec/modules/tappxBidAdapter_spec.js index 123379eb29e..3fe691847b6 100644 --- a/test/spec/modules/tappxBidAdapter_spec.js +++ b/test/spec/modules/tappxBidAdapter_spec.js @@ -1,6 +1,6 @@ import { assert } from 'chai'; import { spec } from 'modules/tappxBidAdapter.js'; -import { _checkParamDataType, _getHostInfo } from '../../../modules/tappxBidAdapter.js'; +import { _checkParamDataType, _getHostInfo, _extractPageUrl } from '../../../modules/tappxBidAdapter.js'; const c_BIDREQUEST = { data: { @@ -70,7 +70,10 @@ const c_SERVERRESPONSE_B = { adm: "\t", w: 320, h: 480, - lurl: 'http://testing.ssp.tappx.com/rtb/RTBv2Loss?id=3811165568213389257&ep=ZZ1234PBJS&au=test&bu=localhost&sz=320x480&pu=0.005&pt=0.01&cid=&crid=&adv=&aid=${AUCTION_ID}&bidid=${AUCTION_BID_ID}&impid=${AUCTION_IMP_ID}&sid=${AUCTION_SEAT_ID}&adid=${AUCTION_AD_ID}&ap=${AUCTION_PRICE}&cur=${AUCTION_CURRENCY}&mbr=${AUCTION_MBR}&l=${AUCTION_LOSS}', + lurl: 'https:\/\/ssp.api.tappx.com\/burlURL', + burl: 'https:\/\/ssp.api.tappx.com\/burlURL', + nurl: 'https:\/\/ssp.api.tappx.com\/nurllURL', + dealId: 'b21d0704-9688-4e46-81d9-41de1050fef7', cid: '01744fbb521e9fb10ffea926190effea', crid: 'a13cf884e66e7c660afec059c89d98b6', adomain: [ @@ -98,7 +101,10 @@ const c_SERVERRESPONSE_V = { impid: 1, price: 0.05, adm: "Tappx<\/AdSystem>Tappx<\/AdTitle><\/Impression><\/Error>00:00:22<\/Duration><\/Tracking><\/Tracking><\/Tracking><\/Tracking><\/Tracking><\/Tracking><\/Tracking><\/TrackingEvents><\/ClickThrough><\/ClickTracking><\/VideoClicks><\/MediaFile><\/MediaFiles><\/Linear><\/Creative><\/Creatives><\/InLine><\/Ad><\/VAST>", - 'lurl': 'https:\/\/ssp.api.tappx.com\/rtb\/RTBv2Loss?id=5001829913749291152&ep=VZ12TESTCTV&au=test&bu=localhost&sz=6x6&pu=0.005&pt=0.01&cid=&crid=&adv=&aid=${AUCTION_ID}&bidid=${AUCTION_BID_ID}&impid=${AUCTION_IMP_ID}&sid=${AUCTION_SEAT_ID}&adid=${AUCTION_AD_ID}&ap=${AUCTION_PRICE}&cur=${AUCTION_CURRENCY}&mbr=${AUCTION_MBR}&l=${AUCTION_LOSS}', + lurl: 'https:\/\/ssp.api.tappx.com\/lurlURL', + burl: 'https:\/\/ssp.api.tappx.com\/burlURL', + nurl: 'https:\/\/ssp.api.tappx.com\/nurllURL', + dealId: 'b21d0704-9688-4e46-81d9-41de1050fef7', cid: '01744fbb521e9fb10ffea926190effea', crid: 'a13cf884e66e7c660afec059c89d98b6', adomain: [ @@ -257,6 +263,27 @@ describe('Tappx bid adapter', function () { expect(data.imp[0].video).to.not.equal(null); }); + it('should properly create video rewarded request', function () { + delete validBidRequests_Voutstream[0].mediaTypes.banner + validBidRequests_Voutstream[0].mediaTypes.video = {}; + validBidRequests_Voutstream[0].mediaTypes.video.rewarded = 1; + validBidRequests_Voutstream[0].mediaTypes.video.playerSize = [640, 480]; + validBidRequests_Voutstream[0].mediaTypes.video.context = 'outstream'; + validBidRequests_Voutstream[0].mediaTypes.video.mimes = [ 'video/mp4', 'application/javascript' ]; + + bidderRequest_VOutstream.bids.mediaTypes.context = 'outstream'; + + const request = spec.buildRequests(validBidRequests_Voutstream, bidderRequest_VOutstream); + expect(request[0].url).to.match(/^(http|https):\/\/(.*)\.tappx\.com\/.+/); + expect(request[0].method).to.equal('POST'); + + const data = JSON.parse(request[0].data); + expect(data.site).to.not.equal(null); + expect(data.imp).to.have.lengthOf(1); + expect(data.imp[0].bidfloor, data).to.not.be.null; + expect(data.imp[0].video).to.not.equal(null); + }); + it('should set user eids array', function () { const request = spec.buildRequests(validBidRequests, bidderRequest); @@ -443,4 +470,13 @@ describe('Tappx bid adapter', function () { expect(_checkParamDataType('Wrong array', false, 'array')).to.be.undefined; }); }) + + describe('_extractPageUrl tests', function() { + let validBidRequests = c_VALIDBIDREQUESTS; + let bidderRequest = c_BIDDERREQUEST_B; + it('should return the Domain of the site', function () { + validBidRequests[0].params.domainUrl = 'testUrl.com'; + assert.isString(_extractPageUrl(validBidRequests, bidderRequest)); + }); + }) });