From b7df202a49436c3094cc6e6c3101b2c4938d41f6 Mon Sep 17 00:00:00 2001 From: EMX Digital Date: Wed, 19 Jun 2019 11:46:11 -0400 Subject: [PATCH 1/5] EMX Digital - device info and video parameter updates --- modules/emx_digitalBidAdapter.js | 81 +++++++++++++------ .../modules/emx_digitalBidAdapter_spec.js | 7 +- 2 files changed, 58 insertions(+), 30 deletions(-) diff --git a/modules/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js index 69e02d5c860..da62eab2826 100644 --- a/modules/emx_digitalBidAdapter.js +++ b/modules/emx_digitalBidAdapter.js @@ -8,6 +8,8 @@ import includes from 'core-js/library/fn/array/includes'; const BIDDER_CODE = 'emx_digital'; const ENDPOINT = 'hb.emxdgt.com'; const RENDERER_URL = '//js.brealtime.com/outstream/1.30.0/bundle.js'; +const ADAPTER_VERSION = '1.40.1'; +const DEFAULT_CUR = 'USD'; export const emxAdapter = { validateSizes: (sizes) => { @@ -48,6 +50,23 @@ export const emxAdapter = { } return bidResponse; }, + isMobile: () => { + return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); + }, + isConnectedTV: () => { + return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); + }, + getDevice: () => { + return { + ua: navigator.userAgent, + js: 1, + dnt: (navigator.doNotTrack === 'yes' || navigator.doNotTrack === '1' || navigator.msDoNotTrack === '1') ? 1 : 0, + h: screen.height, + w: screen.width, + devicetype: emxAdapter.isMobile() ? 1 : emxAdapter.isConnectedTV() ? 3 : 2, + language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), + }; + }, cleanProtocols: (video) => { if (video.protocols && includes(video.protocols, 7)) { // not supporting VAST protocol 7 (VAST 4.0); @@ -85,10 +104,22 @@ export const emxAdapter = { return renderer; }, buildVideo: (bid) => { - bid.params.video = bid.params.video || {}; - bid.params.video.h = bid.mediaTypes.video.playerSize[0][0]; - bid.params.video.w = bid.mediaTypes.video.playerSize[0][1]; - return emxAdapter.cleanProtocols(bid.params.video); + let videoObj = Object.assign(bid.mediaTypes.video, bid.params.video) + return emxAdapter.cleanProtocols(videoObj); + }, + parseResponse: (bidResponseAdm) => { + try { + return decodeURIComponent(bidResponseAdm); + } catch (err) { + utils.logError('emx_digitalBidAdapter', 'error', err); + } + }, + getReferrer: () => { + try { + return window.top.document.referrer; + } catch (err) { + return document.referrer; + } }, getGdpr: (bidRequests, emxData) => { if (bidRequests.gdprConsent) { @@ -151,40 +182,45 @@ export const spec = { return true; }, buildRequests: function (validBidRequests, bidderRequest) { - const page = bidderRequest.refererInfo.referer; - let emxImps = []; + const emxImps = []; const timeout = config.getConfig('bidderTimeout'); const timestamp = Date.now(); - const url = location.protocol + '//' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp); - const networkProtocol = location.protocol.indexOf('https') > -1 ? 1 : 0; + const url = location.protocol + '//' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs'); + const secure = location.protocol.indexOf('https') > -1 ? 1 : 0; + const domain = utils.getTopWindowLocation().hostname; + const page = bidderRequest.refererInfo.referer; + const device = emxAdapter.getDevice(); + const ref = emxAdapter.getReferrer(); utils._each(validBidRequests, function (bid) { - let tagId = utils.getBidIdParameter('tagid', bid.params); - let bidFloor = parseFloat(utils.getBidIdParameter('bidfloor', bid.params)) || 0; + let tagid = utils.getBidIdParameter('tagid', bid.params); + let bidfloor = parseFloat(utils.getBidIdParameter('bidfloor', bid.params)) || 0; let isVideo = !!bid.mediaTypes.video; let data = { id: bid.bidId, tid: bid.transactionId, - tagid: tagId, - secure: networkProtocol + tagid, + secure, + ...(bidfloor > 0 && { bidfloor, bidfloorcur: DEFAULT_CUR }) + }; let typeSpecifics = isVideo ? { video: emxAdapter.buildVideo(bid) } : { banner: emxAdapter.buildBanner(bid) }; let emxBid = Object.assign(data, typeSpecifics); - if (bidFloor > 0) { - emxBid.bidfloor = bidFloor - } emxImps.push(emxBid); }); let emxData = { id: bidderRequest.auctionId, imp: emxImps, + device, site: { - domain: window.top.document.location.host, - page: page + domain, + page, + ref }, - version: '1.30.0' + cur: DEFAULT_CUR, + version: ADAPTER_VERSION }; emxData = emxAdapter.getGdpr(bidderRequest, Object.assign({}, emxData)); @@ -204,6 +240,7 @@ export const spec = { response.seatbid.forEach(function (emxBid) { emxBid = emxBid.bid[0]; let isVideo = false; + let adm = emxAdapter.parseResponse(emxBid.adm) || ''; let bidResponse = { requestId: emxBid.id, cpm: emxBid.price, @@ -214,7 +251,7 @@ export const spec = { currency: 'USD', netRevenue: true, ttl: emxBid.ttl, - ad: decodeURIComponent(emxBid.adm) + ad: adm }; if (emxBid.adm && emxBid.adm.indexOf(' -1) { isVideo = true; @@ -234,12 +271,6 @@ export const spec = { url: '//biddr.brealtime.com/check.html' }); } - if (syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: '//edba.brealtime.com/' - }); - } return syncs; } }; diff --git a/test/spec/modules/emx_digitalBidAdapter_spec.js b/test/spec/modules/emx_digitalBidAdapter_spec.js index 170e5676f43..10d0d74c49c 100644 --- a/test/spec/modules/emx_digitalBidAdapter_spec.js +++ b/test/spec/modules/emx_digitalBidAdapter_spec.js @@ -276,8 +276,9 @@ describe('emx_digital Adapter', function () { it('properly sends site information and protocol', function () { request = spec.buildRequests(bidderRequest.bids, bidderRequest); request = JSON.parse(request.data); - expect(request.site.domain).to.equal(window.top.document.location.host); + expect(request.site.domain).to.equal(utils.getTopWindowLocation().hostname); expect(decodeURIComponent(request.site.page)).to.equal(bidderRequest.refererInfo.referer); + expect(request.site.ref).to.equal(window.top.document.referrer); }); it('builds correctly formatted request banner object', function () { @@ -511,10 +512,6 @@ describe('emx_digital Adapter', function () { let iframeSync = spec.getUserSyncs(syncOptionsIframe); expect(iframeSync.length).to.equal(1); expect(iframeSync[0].type).to.equal('iframe'); - - let pixelSync = spec.getUserSyncs(syncOptionsPixel); - expect(pixelSync.length).to.equal(1); - expect(pixelSync[0].type).to.equal('image'); }); }); }); From 6e86a03631a28fbfe829364a63324ffb293b1695 Mon Sep 17 00:00:00 2001 From: Nick Colletti Date: Thu, 20 Jun 2019 12:28:43 -0400 Subject: [PATCH 2/5] update timeout value to grab from bidderRequest arg --- modules/emx_digitalBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js index da62eab2826..b00106e4144 100644 --- a/modules/emx_digitalBidAdapter.js +++ b/modules/emx_digitalBidAdapter.js @@ -8,7 +8,7 @@ import includes from 'core-js/library/fn/array/includes'; const BIDDER_CODE = 'emx_digital'; const ENDPOINT = 'hb.emxdgt.com'; const RENDERER_URL = '//js.brealtime.com/outstream/1.30.0/bundle.js'; -const ADAPTER_VERSION = '1.40.1'; +const ADAPTER_VERSION = '1.40.2'; const DEFAULT_CUR = 'USD'; export const emxAdapter = { @@ -183,7 +183,7 @@ export const spec = { }, buildRequests: function (validBidRequests, bidderRequest) { const emxImps = []; - const timeout = config.getConfig('bidderTimeout'); + const timeout = bidderRequest.timeout || ""; const timestamp = Date.now(); const url = location.protocol + '//' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs'); const secure = location.protocol.indexOf('https') > -1 ? 1 : 0; From 7f001f7708502de53f4c92df6c674b97af01a7fe Mon Sep 17 00:00:00 2001 From: Nick Colletti Date: Thu, 20 Jun 2019 13:08:59 -0400 Subject: [PATCH 3/5] removing unused import --- modules/emx_digitalBidAdapter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js index b00106e4144..e5a6d7db89b 100644 --- a/modules/emx_digitalBidAdapter.js +++ b/modules/emx_digitalBidAdapter.js @@ -1,7 +1,6 @@ import * as utils from '../src/utils'; import { registerBidder } from '../src/adapters/bidderFactory'; import { BANNER, VIDEO } from '../src/mediaTypes'; -import { config } from '../src/config'; import { Renderer } from '../src/Renderer'; import includes from 'core-js/library/fn/array/includes'; From d17af25dff0dc54702338d9f6d67dc6829c5e0eb Mon Sep 17 00:00:00 2001 From: Nick Colletti Date: Thu, 20 Jun 2019 15:15:04 -0400 Subject: [PATCH 4/5] removing object spread use. quote fix for lint --- modules/emx_digitalBidAdapter.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js index e5a6d7db89b..9750e1d5630 100644 --- a/modules/emx_digitalBidAdapter.js +++ b/modules/emx_digitalBidAdapter.js @@ -182,7 +182,7 @@ export const spec = { }, buildRequests: function (validBidRequests, bidderRequest) { const emxImps = []; - const timeout = bidderRequest.timeout || ""; + const timeout = bidderRequest.timeout || ''; const timestamp = Date.now(); const url = location.protocol + '//' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs'); const secure = location.protocol.indexOf('https') > -1 ? 1 : 0; @@ -191,6 +191,7 @@ export const spec = { const device = emxAdapter.getDevice(); const ref = emxAdapter.getReferrer(); + utils._each(validBidRequests, function (bid) { let tagid = utils.getBidIdParameter('tagid', bid.params); let bidfloor = parseFloat(utils.getBidIdParameter('bidfloor', bid.params)) || 0; @@ -199,12 +200,11 @@ export const spec = { id: bid.bidId, tid: bid.transactionId, tagid, - secure, - ...(bidfloor > 0 && { bidfloor, bidfloorcur: DEFAULT_CUR }) - + secure }; let typeSpecifics = isVideo ? { video: emxAdapter.buildVideo(bid) } : { banner: emxAdapter.buildBanner(bid) }; - let emxBid = Object.assign(data, typeSpecifics); + let bidfloorObj = bidfloor > 0 ? { bidfloor, bidfloorcur: DEFAULT_CUR } : {}; + let emxBid = Object.assign(data, typeSpecifics, bidfloorObj); emxImps.push(emxBid); }); From e1d56eb77cb1b32be86bbd0276eeb2ffa9a12eab Mon Sep 17 00:00:00 2001 From: Nick Colletti Date: Thu, 20 Jun 2019 17:28:12 -0400 Subject: [PATCH 5/5] remove space --- modules/emx_digitalBidAdapter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/emx_digitalBidAdapter.js b/modules/emx_digitalBidAdapter.js index 9750e1d5630..2ca595151f9 100644 --- a/modules/emx_digitalBidAdapter.js +++ b/modules/emx_digitalBidAdapter.js @@ -191,7 +191,6 @@ export const spec = { const device = emxAdapter.getDevice(); const ref = emxAdapter.getReferrer(); - utils._each(validBidRequests, function (bid) { let tagid = utils.getBidIdParameter('tagid', bid.params); let bidfloor = parseFloat(utils.getBidIdParameter('bidfloor', bid.params)) || 0;