Skip to content

Commit

Permalink
Added trackers in ZEDO adapter (prebid#3240)
Browse files Browse the repository at this point in the history
* initial commit

* updated contact and tag details

* changes ti support the renderers

* changes to pass dimId

* fixed names of internal mapping

* added comment

* added gdpr param to request and other fixes

* modified api url

* fix

* fixed the secure api call

* rolled back video event callback till we support it

* updated doc with video details

* added bid won and timeout pixel

* added testcase for bid events

* modified testcase

* fixed the url logged
  • Loading branch information
skazedo authored and AdSpacesDevelopers committed Jan 30, 2019
1 parent 7761ad1 commit 94d3899
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 1 deletion.
56 changes: 55 additions & 1 deletion modules/zedoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { registerBidder } from 'src/adapters/bidderFactory';
import { BANNER, VIDEO } from 'src/mediaTypes';
import find from 'core-js/library/fn/array/find';
import { Renderer } from 'src/Renderer';
import * as url from 'src/url';

const BIDDER_CODE = 'zedo';
const URL = '//z2.zedo.com/asw/fmh.json';
Expand All @@ -22,6 +23,8 @@ const DIM_TYPE = {
'103': 'display'
// '85': 'pre-mid-post-roll',
};
const EVENT_PIXEL_URL = 'm1.zedo.com/log/p.gif';
const SECURE_EVENT_PIXEL_URL = 'tt1.zedo.com/log/p.gif';

export const spec = {
code: BIDDER_CODE,
Expand Down Expand Up @@ -137,7 +140,23 @@ export const spec = {
url: url
}];
}
}
},

onTimeout: function (timeoutData) {
try {
logEvent('117', timeoutData);
} catch (e) {
utils.logError(e);
}
},

onBidWon: function (bid) {
try {
logEvent('116', [bid]);
} catch (e) {
utils.logError(e);
}
},
};

function getCreative(ad) {
Expand Down Expand Up @@ -251,4 +270,39 @@ function parseMediaType(creativeBid) {
}
}

function logEvent(eid, data) {
let getParams = {
protocol: utils.getTopWindowLocation().protocol === 'http:' ? 'http' : 'https',
hostname: utils.getTopWindowLocation().protocol === 'http:' ? EVENT_PIXEL_URL : SECURE_EVENT_PIXEL_URL,
search: getLoggingData(eid, data)
};
utils.triggerPixel(url.format(getParams).replace(/&/g, ';'));
}

function getLoggingData(eid, data) {
data = (utils.isArray(data) && data) || [];

let params = {};
let channel, network, dim, adunitCode, timeToRespond, cpm;
data.map((adunit) => {
adunitCode = adunit.adUnitCode;
channel = utils.deepAccess(adunit, 'params.0.channelCode') || 0;
network = channel > 0 ? parseInt(channel / 1000000) : 0;
dim = utils.deepAccess(adunit, 'params.0.dimId') * 256 || 0;
timeToRespond = adunit.timeout ? adunit.timeout : adunit.timeToRespond;
cpm = adunit.cpm;
});
params.n = network;
params.c = channel;
params.s = '0';
params.x = dim;
params.ai = encodeURI('Prebid^zedo^' + adunitCode + '^' + cpm + '^' + timeToRespond);
params.pu = encodeURI(utils.getTopWindowUrl()) || '';
params.eid = eid;
params.e = 'e';
params.z = Math.random();

return params;
}

registerBidder(spec);
82 changes: 82 additions & 0 deletions test/spec/modules/zedoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,86 @@ describe('The ZEDO bidding adapter', function () {
expect(syncs[0].url).to.contains('gdpr=0');
});
});

describe('bid events', function () {
it('should trigger a win pixel', function () {
const bid = {
'bidderCode': 'zedo',
'width': '300',
'height': '250',
'statusMessage': 'Bid available',
'adId': '148018fe5e',
'cpm': 0.5,
'ad': 'dummy data',
'ad_id': '12345',
'sizeId': '15',
'adResponse':
{
'creatives': [
{
'adId': '12345',
'height': '480',
'width': '640',
'isFoc': true,
'creativeDetails': {
'type': 'VAST',
'adContent': '<VAST></VAST>'
},
'seeder': {
'network': 1234,
'servedChan': 1234567,
},
'cpm': '1200000',
'servedChan': 1234,
}]
},
'params': [{
'channelCode': '123456',
'dimId': '85'
}],
'requestTimestamp': 1540401686,
'responseTimestamp': 1540401687,
'timeToRespond': 6253,
'pbLg': '0.50',
'pbMg': '0.50',
'pbHg': '0.53',
'adUnitCode': '/123456/header-bid-tag-0',
'bidder': 'zedo',
'size': '300x250',
'adserverTargeting': {
'hb_bidder': 'zedo',
'hb_adid': '148018fe5e',
'hb_pb': '10.00',
}
};
spec.onBidWon(bid);
spec.onTimeout(bid);
});
it('should trigger a timeout pixel', function () {
const bid = {
'bidderCode': 'zedo',
'width': '300',
'height': '250',
'statusMessage': 'Bid available',
'adId': '148018fe5e',
'cpm': 0.5,
'ad': 'dummy data',
'ad_id': '12345',
'sizeId': '15',
'params': [{
'channelCode': '123456',
'dimId': '85'
}],
'timeout': 1,
'requestTimestamp': 1540401686,
'responseTimestamp': 1540401687,
'timeToRespond': 6253,
'adUnitCode': '/123456/header-bid-tag-0',
'bidder': 'zedo',
'size': '300x250',
};
spec.onBidWon(bid);
spec.onTimeout(bid);
});
});
});

0 comments on commit 94d3899

Please sign in to comment.