Skip to content

Commit

Permalink
VIS.X: change tracking win & pending url's (#6815)
Browse files Browse the repository at this point in the history
  • Loading branch information
mk0x9 authored May 24, 2021
1 parent a073213 commit 8335d67
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 12 deletions.
16 changes: 11 additions & 5 deletions modules/visxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const ENDPOINT_URL = BASE_URL + '/hb';
const TIME_TO_LIVE = 360;
const DEFAULT_CUR = 'EUR';
const ADAPTER_SYNC_URL = BASE_URL + '/push_sync';
const TRACK_WIN_URL = BASE_URL + '/track/win';
const TRACK_PENDING_URL = BASE_URL + '/track/pending';
const TRACK_TIMEOUT_URL = BASE_URL + '/track/bid_timeout';
const LOG_ERROR_MESS = {
noAuid: 'Bid from response has no auid parameter - ',
Expand Down Expand Up @@ -191,11 +189,15 @@ export const spec = {
},
onSetTargeting: function(bid) {
// Call '/track/pending' with the corresponding bid.requestId
utils.triggerPixel(TRACK_PENDING_URL + '?requestId=' + bid.requestId);
if (bid.ext && bid.ext.events && bid.ext.events.pending) {
utils.triggerPixel(bid.ext.events.pending);
}
},
onBidWon: function(bid) {
// Call '/track/win' with the corresponding bid.requestId
utils.triggerPixel(TRACK_WIN_URL + '?requestId=' + bid.requestId);
if (bid.ext && bid.ext.events && bid.ext.events.win) {
utils.triggerPixel(bid.ext.events.win);
}
},
onTimeout: function(timeoutData) {
// Call '/track/bid_timeout' with timeout data
Expand Down Expand Up @@ -240,9 +242,13 @@ function _addBidResponse(serverBid, bidsMap, currency, bidResponses, bidsWithout
currency: reqCurrency,
netRevenue: true,
ttl: TIME_TO_LIVE,
dealId: serverBid.dealid
dealId: serverBid.dealid,
};

if (serverBid.ext && serverBid.ext.prebid) {
bidResponse.ext = serverBid.ext.prebid;
}

if (!_isVideoBid(bid)) {
bidResponse.ad = serverBid.adm;
} else {
Expand Down
66 changes: 59 additions & 7 deletions test/spec/modules/visxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ describe('VisxAdapter', function () {
];

const response = Object.assign({}, responses[0]);
Object.assign(response.bid[0], {'cur': 'PLN'});
response.bid = [Object.assign({}, response.bid[0], {'cur': 'PLN'})];
const result = spec.interpretResponse({'body': {'seatbid': [response]}}, request);
expect(result).to.deep.equal(expectedResponse);
getConfigStub.restore();
Expand Down Expand Up @@ -756,6 +756,56 @@ describe('VisxAdapter', function () {
const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request);
expect(result).to.deep.equal(expectedResponse);
});

it('should get right ext data in bid response', function () {
const bidRequests = [
{
'bidder': 'visx',
'params': {
'uid': '903535'
},
'adUnitCode': 'adunit-code-1',
'sizes': [[300, 250], [300, 600]],
'bidId': '659423fff799cb',
'bidderRequestId': '5f2009617a7c0a',
'auctionId': '1cbd2feafe5e8b',
}
];
const request = spec.buildRequests(bidRequests);
const pendingUrl = 'https://t.visx.net/track/pending/123123123';
const winUrl = 'https://t.visx.net/track/win/53245341';
const expectedResponse = [
{
'requestId': '659423fff799cb',
'cpm': 1.15,
'creativeId': 903535,
'dealId': undefined,
'width': 300,
'height': 250,
'ad': '<div>test content 1</div>',
'currency': 'EUR',
'netRevenue': true,
'ttl': 360,
'ext': {
'events': {
'pending': pendingUrl,
'win': winUrl
}
}
}
];
const serverResponse = Object.assign({}, responses[0]);
serverResponse.bid = [Object.assign({}, {ext: {
prebid: {
events: {
'pending': pendingUrl,
'win': winUrl
}
}
}}, serverResponse.bid[0])];
const result = spec.interpretResponse({'body': {'seatbid': [serverResponse]}}, request);
expect(result).to.deep.equal(expectedResponse);
});
});
describe('check trackers', function () {
beforeEach(function () {
Expand All @@ -767,15 +817,17 @@ describe('VisxAdapter', function () {
});

it('onSetTargeting', function () {
const requestId = '111';
spec.onSetTargeting({ requestId });
expect(utils.triggerPixel.calledOnceWith('https://t.visx.net/track/pending?requestId=' + requestId)).to.equal(true);
const trackUrl = 'https://t.visx.net/track/pending/123123123';
const bid = { ext: { events: { pending: trackUrl } } };
spec.onSetTargeting(bid);
expect(utils.triggerPixel.calledOnceWith(trackUrl)).to.equal(true);
});

it('onBidWon', function () {
const requestId = '111';
spec.onBidWon({ requestId });
expect(utils.triggerPixel.calledOnceWith('https://t.visx.net/track/win?requestId=' + requestId)).to.equal(true);
const trackUrl = 'https://t.visx.net/track/win/123123123';
const bid = { ext: { events: { win: trackUrl } } };
spec.onBidWon(bid);
expect(utils.triggerPixel.calledOnceWith(trackUrl)).to.equal(true);
});

it('onTimeout', function () {
Expand Down

0 comments on commit 8335d67

Please sign in to comment.