diff --git a/modules/justpremiumBidAdapter.js b/modules/justpremiumBidAdapter.js index f336d44671b..a7aebae0fd9 100644 --- a/modules/justpremiumBidAdapter.js +++ b/modules/justpremiumBidAdapter.js @@ -3,11 +3,8 @@ import { deepAccess } from '../src/utils'; const BIDDER_CODE = 'justpremium' const ENDPOINT_URL = 'https://pre.ads.justpremium.com/v/2.0/t/xhr' -const JP_ADAPTER_VERSION = '1.5' +const JP_ADAPTER_VERSION = '1.6' const pixels = [] -const TRACK_START_TIME = Date.now() -let LAST_PAYLOAD = {} -let AD_UNIT_IDS = [] export const spec = { code: BIDDER_CODE, @@ -20,11 +17,6 @@ export const spec = { buildRequests: (validBidRequests, bidderRequest) => { const c = preparePubCond(validBidRequests) const dim = getWebsiteDim() - AD_UNIT_IDS = validBidRequests.map(b => { - return b.adUnitCode - }).filter((value, index, self) => { - return self.indexOf(value) === index - }) const payload = { zone: validBidRequests.map(b => { return parseInt(b.params.zone) @@ -69,8 +61,6 @@ export const spec = { const payloadString = JSON.stringify(payload) - LAST_PAYLOAD = payload - return { method: 'POST', url: ENDPOINT_URL + '?i=' + (+new Date()), @@ -117,53 +107,6 @@ export const spec = { } return pixels }, - - onTimeout: (timeoutData) => { - timeoutData.forEach((data) => { - if (AD_UNIT_IDS.indexOf(data.adUnitCode) != -1) { - track(data, LAST_PAYLOAD, 'btm') - } - }) - }, - -} - -export let pixel = { - fire(url) { - let img = document.createElement('img') - img.src = url - img.id = 'jp-pixel-track' - img.style.cssText = 'display:none !important;' - document.body.appendChild(img) - } -}; - -function track (data, payload, type) { - let pubUrl = '' - - let jp = { - auc: data.adUnitCode, - to: data.timeout - } - - if (window.top == window) { - pubUrl = window.location.href - } else { - try { - pubUrl = window.top.location.href - } catch (e) { - pubUrl = document.referrer - } - } - - let duration = Date.now() - TRACK_START_TIME - - const pixelUrl = `https://emea-v3.tracking.justpremium.com/tracking.gif?rid=&sid=&uid=&vr=& -ru=${encodeURIComponent(pubUrl)}&tt=&siw=&sh=${payload.sh}&sw=${payload.sw}&wh=${payload.wh}&ww=${payload.ww}&an=&vn=& -sd=&_c=&et=&aid=&said=&ei=&fc=&sp=&at=bidder&cid=&ist=&mg=&dl=&dlt=&ev=&vt=&zid=${payload.id}&dr=${duration}&di=&pr=& -cw=&ch=&nt=&st=&jp=${encodeURIComponent(JSON.stringify(jp))}&ty=${type}` - - pixel.fire(pixelUrl); } function findBid (params, bids) { diff --git a/test/spec/modules/justpremiumBidAdapter_spec.js b/test/spec/modules/justpremiumBidAdapter_spec.js index 503ca1e3d81..b16586d0e14 100644 --- a/test/spec/modules/justpremiumBidAdapter_spec.js +++ b/test/spec/modules/justpremiumBidAdapter_spec.js @@ -1,13 +1,11 @@ import { expect } from 'chai' -import { spec, pixel } from 'modules/justpremiumBidAdapter' +import { spec } from 'modules/justpremiumBidAdapter' describe('justpremium adapter', function () { let sandbox; - let pixelStub; beforeEach(function() { sandbox = sinon.sandbox.create(); - pixelStub = sandbox.stub(pixel, 'fire'); }); afterEach(function() { @@ -82,7 +80,7 @@ describe('justpremium adapter', function () { expect(jpxRequest.id).to.equal(adUnits[0].params.zone) expect(jpxRequest.mediaTypes && jpxRequest.mediaTypes.banner && jpxRequest.mediaTypes.banner.sizes).to.not.equal('undefined') expect(jpxRequest.version.prebid).to.equal('$prebid.version$') - expect(jpxRequest.version.jp_adapter).to.equal('1.5') + expect(jpxRequest.version.jp_adapter).to.equal('1.6') expect(jpxRequest.pubcid).to.equal('0000000') expect(jpxRequest.uids.tdid).to.equal('1111111') expect(jpxRequest.uids.id5id).to.equal('2222222') @@ -163,34 +161,4 @@ describe('justpremium adapter', function () { expect(options[0].url).to.match(/\/\/pre.ads.justpremium.com\/v\/1.0\/t\/sync/) }) }) - - describe('onTimeout', function () { - it('onTimeout', function(done) { - spec.onTimeout([{ - 'bidId': '25cd3ec3fd6ed7', - 'bidder': 'justpremium', - 'adUnitCode': 'div-gpt-ad-1471513102552-1', - 'auctionId': '6fbd0562-f613-4151-a6df-6cb446fc717b', - 'params': [{ - 'adType': 'iab', - 'zone': 21521 - }], - 'timeout': 1 - }, { - 'bidId': '3b51df1f254e32', - 'bidder': 'justpremium', - 'adUnitCode': 'div-gpt-ad-1471513102552-3', - 'auctionId': '6fbd0562-f613-4151-a6df-6cb446fc717b', - 'params': [{ - 'adType': 'iab', - 'zone': 21521 - }], - 'timeout': 1 - }]); - - expect(pixelStub.calledOnce).to.equal(true); - - done() - }) - }) })