diff --git a/modules/tappxBidAdapter.js b/modules/tappxBidAdapter.js index d8f6654a567..566795a204b 100644 --- a/modules/tappxBidAdapter.js +++ b/modules/tappxBidAdapter.js @@ -8,11 +8,10 @@ import { config } from '../src/config.js'; const BIDDER_CODE = 'tappx'; const TTL = 360; const CUR = 'USD'; -const TAPPX_BIDDER_VERSION = '0.1.10420'; +const TAPPX_BIDDER_VERSION = '0.1.10514'; const TYPE_CNN = 'prebidjs'; const VIDEO_SUPPORT = ['instream']; -var HOST; var hostDomain; export const spec = { @@ -105,13 +104,31 @@ export const spec = { } function validBasic(bid) { - if ( - (bid.params == null) || - (bid.params.endpoint == null) || - (bid.params.tappxkey == null)) { + if (bid.params == null) { utils.logWarn(`[TAPPX]: Please review the mandatory Tappx parameters.`); return false; } + + if (bid.params.tappxkey == null) { + utils.logWarn(`[TAPPX]: Please review the mandatory Tappxkey parameter.`); + return false; + } + + if (bid.params.host == null) { + utils.logWarn(`[TAPPX]: Please review the mandatory Host parameter.`); + return false; + } + + let classicEndpoint = true + if ((new RegExp(`^(vz.*|zz.*)\.*$`, 'i')).test(bid.params.host)) { + classicEndpoint = false + } + + if (classicEndpoint && bid.params.endpoint == null) { + utils.logWarn(`[TAPPX]: Please review the mandatory endpoint Tappx parameters.`); + return false; + } + return true; } @@ -174,11 +191,10 @@ function interpretBid(serverBid, request) { * @return response ad */ function buildOneRequest(validBidRequests, bidderRequest) { - HOST = utils.deepAccess(validBidRequests, 'params.host'); - let hostInfo = getHostInfo(HOST); + let hostInfo = getHostInfo(validBidRequests); + const ENDPOINT = hostInfo.endpoint; hostDomain = hostInfo.domain; - const ENDPOINT = utils.deepAccess(validBidRequests, 'params.endpoint'); const TAPPXKEY = utils.deepAccess(validBidRequests, 'params.tappxkey'); const BIDFLOOR = utils.deepAccess(validBidRequests, 'params.bidfloor'); const BIDEXTRA = utils.deepAccess(validBidRequests, 'params.ext'); @@ -359,7 +375,7 @@ function buildOneRequest(validBidRequests, bidderRequest) { return { method: 'POST', - url: `https://${HOST}/${ENDPOINT}?type_cnn=${TYPE_CNN}&v=${TAPPX_BIDDER_VERSION}`, + url: `${hostInfo.url}?type_cnn=${TYPE_CNN}&v=${TAPPX_BIDDER_VERSION}`, data: JSON.stringify(payload), bids: validBidRequests }; @@ -375,23 +391,24 @@ function getOs() { if (ua == null) { return 'unknown'; } else if (ua.match(/(iPhone|iPod|iPad)/)) { return 'ios'; } else if (ua.match(/Android/)) { return 'android'; } else if (ua.match(/Window/)) { return 'windows'; } else { return 'unknown'; } } -function getHostInfo(hostParam) { +function getHostInfo(validBidRequests) { let domainInfo = {}; + let endpoint = utils.deepAccess(validBidRequests, 'params.endpoint'); + let hostParam = utils.deepAccess(validBidRequests, 'params.host'); domainInfo.domain = hostParam.split('/', 1)[0]; - domainInfo.url = hostParam; - let regexNewEndpoints = new RegExp(`^(vz.*|zz.*|testing)\.ssp\.tappx\.com$`, 'i'); - let regexClassicEndpoints = new RegExp(`^[a-z]{3}\.[a-z]{3}\.tappx\.com$`, 'i'); + let regexNewEndpoints = new RegExp(`^(vz.*|zz.*)\.pub\.tappx\.com$`, 'i'); + let regexClassicEndpoints = new RegExp(`^([a-z]{3}|testing)\.[a-z]{3}\.tappx\.com$`, 'i'); if (regexNewEndpoints.test(domainInfo.domain)) { - let endpoint = domainInfo.domain.split('.', 1)[0] - if (endpoint.toUpperCase().indexOf('TESTING') === -1) { - domainInfo.endpoint = endpoint - domainInfo.new_endpoint = true; - } + domainInfo.newEndpoint = true; + domainInfo.endpoint = domainInfo.domain.split('.', 1)[0] + domainInfo.url = `https://${hostParam}` } else if (regexClassicEndpoints.test(domainInfo.domain)) { - domainInfo.new_endpoint = false; + domainInfo.newEndpoint = false; + domainInfo.endpoint = endpoint + domainInfo.url = `https://${hostParam}${endpoint}` } return domainInfo; diff --git a/modules/tappxBidAdapter.md b/modules/tappxBidAdapter.md index a07bb2d88d1..776b24bb07c 100644 --- a/modules/tappxBidAdapter.md +++ b/modules/tappxBidAdapter.md @@ -9,7 +9,7 @@ Maintainer: prebid@tappx.com Module that connects to :tappx demand sources. Suppots Banner and Instream Video. Please use ```tappx``` as the bidder code. -Ads sizes available: [320,50], [300,250], [320,480], [1024,768], [728,90] +Ads sizes available: [300,250], [320,50], [320,480], [480,320], [728,90], [768,1024], [1024,768] # Banner Test Parameters ``` diff --git a/test/spec/modules/tappxBidAdapter_spec.js b/test/spec/modules/tappxBidAdapter_spec.js index 54c4f8c9dca..9fab7d858e1 100644 --- a/test/spec/modules/tappxBidAdapter_spec.js +++ b/test/spec/modules/tappxBidAdapter_spec.js @@ -126,11 +126,35 @@ describe('Tappx bid adapter', function () { assert.isTrue(spec.isBidRequestValid(c_BIDREQUEST.bids[0]), JSON.stringify(c_BIDREQUEST)); }); - it('should return false when required params are missing', function () { - let badBidRequest = c_BIDREQUEST; - delete badBidRequest.bids[0].params.tappxkey; - delete badBidRequest.bids[0].params.endpoint; - assert.isFalse(spec.isBidRequestValid(badBidRequest.bids[0])); + it('should return false when params are missing', function () { + let badBidRequestParam = JSON.parse(JSON.stringify(c_BIDREQUEST)); + delete badBidRequestParam.bids[0].params; + assert.isFalse(spec.isBidRequestValid(badBidRequestParam.bids[0])); + }); + + it('should return false when tappxkey is missing', function () { + let badBidRequestTpxkey = JSON.parse(JSON.stringify(c_BIDREQUEST)); ; + delete badBidRequestTpxkey.bids[0].params.tappxkey; + assert.isFalse(spec.isBidRequestValid(badBidRequestTpxkey.bids[0])); + }); + + it('should return false when host is missing', function () { + let badBidRequestHost = JSON.parse(JSON.stringify(c_BIDREQUEST)); ; + delete badBidRequestHost.bids[0].params.host; + assert.isFalse(spec.isBidRequestValid(badBidRequestHost.bids[0])); + }); + + it('should return false when classic endpoint is missing', function () { + let badBidRequestClEp = JSON.parse(JSON.stringify(c_BIDREQUEST)); ; + delete badBidRequestClEp.bids[0].params.endpoint; + assert.isFalse(spec.isBidRequestValid(badBidRequestClEp.bids[0])); + }); + + it('should return true when endpoint is not set for new endpoints', function () { + let badBidRequestNwEp = JSON.parse(JSON.stringify(c_BIDREQUEST)); ; + delete badBidRequestNwEp.bids[0].params.endpoint; + badBidRequestNwEp.bids[0].params.host = 'zztesting.ssp.tappx.com/rtb/v2/'; + assert.isTrue(spec.isBidRequestValid(badBidRequestNwEp.bids[0])); }); it('should return false for not instream requests', function () {