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

Marsmedia & videofy adapters - Add onTimeout & onSetTargeting #5352

Merged
merged 26 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9a9bf04
Change publisherId to zoneId
vladi-mmg Dec 17, 2019
07f5f49
Remove comments
vladi-mmg Dec 17, 2019
154263e
Merge remote-tracking branch 'upstream/master'
vladi-mmg Dec 17, 2019
e5971a7
Merge remote-tracking branch 'upstream/master'
vladi-mmg Dec 18, 2019
c72847b
Merge remote-tracking branch 'upstream/master'
vladi-mmg Dec 19, 2019
b73b7e4
Fix unit test coverage
vladi-mmg Dec 19, 2019
309e247
Merge remote-tracking branch 'upstream/master'
vladi-mmg Mar 31, 2020
51bb539
fix request id bug
vladi-mmg Apr 2, 2020
cf174a4
Remove bid response default sizes
vladi-mmg Apr 5, 2020
7ab347b
Merge remote-tracking branch 'upstream/master'
vladi-mmg Apr 5, 2020
10ff1f9
Merge remote-tracking branch 'upstream/master'
vladi-mmg Apr 13, 2020
4ef0887
Change endpoint url
vladi-mmg Apr 13, 2020
67f9f58
Add unit test for vastXml
vladi-mmg Apr 13, 2020
e430e9e
Merge remote-tracking branch 'upstream/master'
vladi-mmg Apr 23, 2020
063fafb
Change end point
vladi-mmg Apr 23, 2020
b2b764a
Remove trailing-space
vladi-mmg Apr 23, 2020
b087206
Merge branch 'master' of https://github.com/prebid/Prebid.js
vladi-mmg Apr 27, 2020
ee4c472
Add onBidWon function
vladi-mmg Apr 28, 2020
18bb5af
Merge remote-tracking branch 'upstream/master'
vladi-mmg May 12, 2020
1fd57d2
Merge remote-tracking branch 'upstream/master'
vladi-mmg May 19, 2020
5b8e42c
New adapter - videofy
vladi-mmg May 19, 2020
0852882
Merge remote-tracking branch 'upstream/master'
vladi-mmg Jun 8, 2020
45e4213
Merge remote-tracking branch 'upstream/master'
vladi-mmg Jun 9, 2020
ad7b052
Marsmedia & Videofy - Add onTimeout onSetTargeting
vladi-mmg Jun 9, 2020
55cf4ba
Merge remote-tracking branch 'upstream/master'
vladi-mmg Jun 17, 2020
33ac444
Create sendbeacon function
vladi-mmg Jun 17, 2020
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
16 changes: 14 additions & 2 deletions modules/marsmediaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ 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
Expand All @@ -232,7 +232,19 @@ function MarsmediaAdapter() {
};
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=17&bid=3mhdom&hb_j=' + encodedBuf, null);
};

this.onTimeout = function (bid) {
const bidString = JSON.stringify(bid);
vladi-mmg marked this conversation as resolved.
Show resolved Hide resolved
const encodedBuf = window.btoa(bidString);
utils.triggerPixel('https://ping-hqx-1.go2speed.media/notification/rtb/beacon/?bt=19&bid=3mhdom&hb_j=' + encodedBuf, null);
};

this.onSetTargeting = function (bid) {
const bidString = JSON.stringify(bid);
const encodedBuf = window.btoa(bidString);
utils.triggerPixel('https://ping-hqx-1.go2speed.media/notification/rtb/beacon/?bt=20&bid=3mhdom&hb_j=' + encodedBuf, null);
};

this.interpretResponse = function (serverResponse) {
Expand Down
70 changes: 69 additions & 1 deletion modules/videofyBidAdapter.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -250,13 +251,80 @@ function getUserSyncs(syncOptions, serverResponses) {
}
}

function onBidWon(bid) {
const bidCopy = {
vladi-mmg marked this conversation as resolved.
Show resolved Hide resolved
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,
ttl: bid.ttl
};
const bidString = JSON.stringify(bidCopy);
const encodedBuf = window.btoa(bidString);
utils.triggerPixel('https://beacon.videofy.io/notification/rtb/beacon/?bt=17&bid=hcwqso&hb_j=' + encodedBuf, null);
}

function onTimeout(bid) {
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,
ttl: bid.ttl
};
const bidString = JSON.stringify(bidCopy);
const encodedBuf = window.btoa(bidString);
utils.triggerPixel('https://beacon.videofy.io/notification/rtb/beacon/?bt=19&bid=hcwqso&hb_j=' + encodedBuf, null);
}

function onSetTargeting(bid) {
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=20&bid=hcwqso&hb_j=' + encodedBuf, null);
}

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [VIDEO],
isBidRequestValid,
buildRequests,
interpretResponse,
getUserSyncs
getUserSyncs,
onBidWon,
onTimeout,
onSetTargeting
};

registerBidder(spec);
34 changes: 34 additions & 0 deletions test/spec/modules/marsmediaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
53 changes: 53 additions & 0 deletions test/spec/modules/videofyBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down Expand Up @@ -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);
});
});
});