diff --git a/modules/marsmediaBidAdapter.js b/modules/marsmediaBidAdapter.js index 2a2017c4b5c..1ce2558b8de 100644 --- a/modules/marsmediaBidAdapter.js +++ b/modules/marsmediaBidAdapter.js @@ -222,18 +222,30 @@ function MarsmediaAdapter() { }; this.onBidWon = function (bid) { - const cpm = bid.pbMg; if (typeof bid.nurl !== 'undefined') { + const cpm = bid.pbMg; bid.nurl = bid.nurl.replace( /\$\{AUCTION_PRICE\}/, cpm ); utils.triggerPixel(bid.nurl, null); }; + sendbeacon(bid, 17) + }; + + this.onTimeout = function (bid) { + sendbeacon(bid, 19) + }; + + this.onSetTargeting = function (bid) { + sendbeacon(bid, 20) + }; + + function sendbeacon(bid, type) { const bidString = JSON.stringify(bid); const encodedBuf = window.btoa(bidString); - utils.triggerPixel('https://ping-hqx-1.go2speed.media/notification/rtb/beacon/?bt=17&hb_j=' + encodedBuf, null); - }; + utils.triggerPixel('https://ping-hqx-1.go2speed.media/notification/rtb/beacon/?bt=' + type + '&bid=3mhdom&hb_j=' + encodedBuf, null); + } this.interpretResponse = function (serverResponse) { let responses = serverResponse.body || []; diff --git a/modules/videofyBidAdapter.js b/modules/videofyBidAdapter.js index 07e95689ab4..11bc21303fd 100644 --- a/modules/videofyBidAdapter.js +++ b/modules/videofyBidAdapter.js @@ -1,6 +1,7 @@ import { VIDEO } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { Renderer } from '../src/Renderer.js'; +import * as utils from '../src/utils.js'; const BIDDER_CODE = 'videofy'; const TTL = 600; @@ -250,13 +251,50 @@ function getUserSyncs(syncOptions, serverResponses) { } } +function onBidWon(bid) { + sendbeacon(bid, 17); +} + +function onTimeout(bid) { + sendbeacon(bid, 19); +} + +function onSetTargeting(bid) { + sendbeacon(bid, 20); +} + +function sendbeacon(bid, type) { + const bidCopy = { + bidder: bid.bidder, + cpm: bid.cpm, + originalCpm: bid.originalCpm, + currency: bid.currency, + originalCurrency: bid.originalCurrency, + timeToRespond: bid.timeToRespond, + statusMessage: bid.statusMessage, + width: bid.width, + height: bid.height, + size: bid.size, + params: bid.params, + status: bid.status, + adserverTargeting: bid.adserverTargeting, + ttl: bid.ttl + }; + const bidString = JSON.stringify(bidCopy); + const encodedBuf = window.btoa(bidString); + utils.triggerPixel('https://beacon.videofy.io/notification/rtb/beacon/?bt=' + type + '&bid=hcwqso&hb_j=' + encodedBuf, null); +} + export const spec = { code: BIDDER_CODE, supportedMediaTypes: [VIDEO], isBidRequestValid, buildRequests, interpretResponse, - getUserSyncs + getUserSyncs, + onBidWon, + onTimeout, + onSetTargeting }; registerBidder(spec); diff --git a/test/spec/modules/marsmediaBidAdapter_spec.js b/test/spec/modules/marsmediaBidAdapter_spec.js index e02870d9890..b4c2fe68f34 100644 --- a/test/spec/modules/marsmediaBidAdapter_spec.js +++ b/test/spec/modules/marsmediaBidAdapter_spec.js @@ -624,4 +624,38 @@ describe('marsmedia adapter tests', function () { expect(utils.triggerPixel.called).to.equal(true); }); }); + + describe('on Timeout', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + it('exists and is a function', () => { + expect(spec.onTimeout).to.exist.and.to.be.a('function'); + }); + it('should return nothing', function () { + var response = spec.onTimeout({}); + expect(response).to.be.an('undefined') + expect(utils.triggerPixel.called).to.equal(true); + }); + }); + + describe('on Set Targeting', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + it('exists and is a function', () => { + expect(spec.onSetTargeting).to.exist.and.to.be.a('function'); + }); + it('should return nothing', function () { + var response = spec.onSetTargeting({}); + expect(response).to.be.an('undefined') + expect(utils.triggerPixel.called).to.equal(true); + }); + }); }); diff --git a/test/spec/modules/videofyBidAdapter_spec.js b/test/spec/modules/videofyBidAdapter_spec.js index e221ece45b8..270eefd1efc 100644 --- a/test/spec/modules/videofyBidAdapter_spec.js +++ b/test/spec/modules/videofyBidAdapter_spec.js @@ -1,5 +1,7 @@ import { spec } from 'modules/videofyBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; +import * as utils from '../../../src/utils.js'; + const { expect } = require('chai'); describe('Videofy Bid Adapter Test', function () { @@ -197,4 +199,55 @@ describe('Videofy Bid Adapter Test', function () { expect(pixel.type).to.equal('iframe'); }); }); + + describe('on bidWon', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + it('exists and is a function', () => { + expect(spec.onBidWon).to.exist.and.to.be.a('function'); + }); + it('should return nothing', function () { + var response = spec.onBidWon({}); + expect(response).to.be.an('undefined') + expect(utils.triggerPixel.called).to.equal(true); + }); + }); + + describe('on Timeout', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + it('exists and is a function', () => { + expect(spec.onTimeout).to.exist.and.to.be.a('function'); + }); + it('should return nothing', function () { + var response = spec.onTimeout({}); + expect(response).to.be.an('undefined') + expect(utils.triggerPixel.called).to.equal(true); + }); + }); + + describe('on Set Targeting', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + it('exists and is a function', () => { + expect(spec.onSetTargeting).to.exist.and.to.be.a('function'); + }); + it('should return nothing', function () { + var response = spec.onSetTargeting({}); + expect(response).to.be.an('undefined') + expect(utils.triggerPixel.called).to.equal(true); + }); + }); });