Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JustPremium: Disable 'btm' requests #4511

Merged
merged 1 commit into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 1 addition & 58 deletions modules/justpremiumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -69,8 +61,6 @@ export const spec = {

const payloadString = JSON.stringify(payload)

LAST_PAYLOAD = payload

return {
method: 'POST',
url: ENDPOINT_URL + '?i=' + (+new Date()),
Expand Down Expand Up @@ -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) {
Expand Down
36 changes: 2 additions & 34 deletions test/spec/modules/justpremiumBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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()
})
})
})