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

Rise Bid Adapter: support onbid won #7958

Merged
merged 34 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3cfdf9d
add Rise adapter
noamtzuberi Jan 3, 2021
923e646
fixes
noamtzuberi Jan 3, 2021
499f36f
change param isOrg to org
noamtzuberi Jan 5, 2021
d33a8af
Rise adapter
noamtzuberi Jan 5, 2021
b2cdd97
change email for rise
noamtzuberi Jan 5, 2021
b8a140c
change email for rise
noamtzuberi Jan 5, 2021
3ce6a3b
fix circle failed
noamtzuberi Jan 5, 2021
dd10c25
bump
noamtzuberi Jan 5, 2021
464d2b7
bump
noamtzuberi Jan 5, 2021
1c52066
bump
noamtzuberi Jan 5, 2021
2b1fad5
remove space
noamtzuberi Jan 6, 2021
b08dd59
Merge branch 'master' of https://github.com/streamrail/Prebid.js
noamtzu Jul 6, 2021
924bb15
Upgrade Rise adapter to 5.0
noamtzu Jul 6, 2021
0f9e730
Merge branch 'prebid:master' into master
noamtzu Jul 13, 2021
87c6a56
Merge branch 'prebid:master' into master
noamtzu Jul 20, 2021
e8e613b
Merge branch 'master' of https://github.com/streamrail/Prebid.js
noamtzu Aug 18, 2021
1ba7048
Merge branch 'master' of github.com:prebid/Prebid.js
Aug 23, 2021
a032702
Merge branch 'prebid:master' into master
noamtzu Aug 27, 2021
a5e5954
Merge branch 'prebid:master' into master
noamtzu Sep 5, 2021
bc2dafd
Merge branch 'prebid:master' into master
noamtzu Sep 12, 2021
75344c1
Merge branch 'prebid:master' into master
noamtzu Sep 19, 2021
2e17e14
Merge branch 'prebid:master' into master
noamtzu Nov 21, 2021
03099f3
Merge branch 'prebid:master' into master
noamtzu Jan 13, 2022
c87f05e
add onBidWon event
noamtzu Jan 13, 2022
42ff678
nurl
noamtzu Jan 17, 2022
5c30696
Merge branch 'prebid:master' into master
noamtzu Jan 17, 2022
80d35d1
Merge branch 'master' into rise-bid-won
noamtzu Jan 17, 2022
5103d93
add test
noamtzu Jan 17, 2022
bc1d897
Merge branch 'prebid:master' into master
noamtzu Jan 23, 2022
448cc8b
Merge branch 'master' into rise-bid-won
noamtzu Jan 23, 2022
5216018
eslint
noamtzu Jan 23, 2022
21e6304
fix corcle
noamtzu Jan 23, 2022
5d7fdc1
fix circle
noamtzu Jan 23, 2022
d645557
fix
noamtzu Jan 23, 2022
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
23 changes: 17 additions & 6 deletions modules/riseBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logWarn, isArray, isFn, deepAccess, isEmpty, contains, timestamp, getBidIdParameter } from '../src/utils.js';
import { logWarn, logInfo, isArray, isFn, deepAccess, isEmpty, contains, timestamp, getBidIdParameter, triggerPixel } from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {VIDEO} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
Expand All @@ -23,7 +23,7 @@ export const spec = {
gvlid: 1043,
version: ADAPTER_VERSION,
supportedMediaTypes: SUPPORTED_AD_TYPES,
isBidRequestValid: function(bidRequest) {
isBidRequestValid: function (bidRequest) {
if (!bidRequest.params) {
logWarn('no params have been set to Rise adapter');
return false;
Expand All @@ -49,7 +49,7 @@ export const spec = {

return requests;
},
interpretResponse: function({body}) {
interpretResponse: function ({body}) {
const bidResponses = [];

const bidResponse = {
Expand All @@ -62,6 +62,7 @@ export const spec = {
netRevenue: body.netRevenue,
ttl: body.ttl || TTL,
vastXml: body.vastXml,
nurl: body.nurl,
mediaType: VIDEO
};

Expand All @@ -73,7 +74,7 @@ export const spec = {

return bidResponses;
},
getUserSyncs: function(syncOptions, serverResponses) {
getUserSyncs: function (syncOptions, serverResponses) {
const syncs = [];
for (const response of serverResponses) {
if (syncOptions.iframeEnabled && response.body.userSyncURL) {
Expand All @@ -93,8 +94,18 @@ export const spec = {
}
}
return syncs;
}
};
},
onBidWon: function (bid) {
if (bid == null) {
return;
}

logInfo('onBidWon:', bid);
if (bid.hasOwnProperty('nurl') && bid.nurl.length > 0) {
triggerPixel(bid.nurl);
}
},
}

registerBidder(spec);

Expand Down
34 changes: 30 additions & 4 deletions test/spec/modules/riseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { spec } from 'modules/riseBidAdapter.js';
import { newBidder } from 'src/adapters/bidderFactory.js';
import { config } from 'src/config.js';
import { VIDEO } from '../../../src/mediaTypes.js';
import { deepClone } from 'src/utils.js';
import * as utils from 'src/utils.js';

const ENDPOINT = 'https://hb.yellowblue.io/hb';
const TEST_ENDPOINT = 'https://hb.yellowblue.io/hb-test';
Expand Down Expand Up @@ -262,7 +262,7 @@ describe('riseAdapter', function () {
});

it('should set floor_price to getFloor.floor value if it is greater than params.floorPrice', function() {
const bid = deepClone(bidRequests[0]);
const bid = utils.deepClone(bidRequests[0]);
bid.getFloor = () => {
return {
currency: 'USD',
Expand All @@ -276,7 +276,7 @@ describe('riseAdapter', function () {
});

it('should set floor_price to params.floorPrice value if it is greater than getFloor.floor', function() {
const bid = deepClone(bidRequests[0]);
const bid = utils.deepClone(bidRequests[0]);
bid.getFloor = () => {
return {
currency: 'USD',
Expand All @@ -299,7 +299,8 @@ describe('riseAdapter', function () {
requestId: '21e12606d47ba7',
netRevenue: true,
currency: 'USD',
adomain: ['abc.com']
adomain: ['abc.com'],
nurl: 'http://example.com/win/1234',
};

it('should get correct bid response', function () {
Expand All @@ -315,6 +316,7 @@ describe('riseAdapter', function () {
ttl: TTL,
vastXml: '<VAST version="3.0"></VAST>',
mediaType: VIDEO,
nurl: 'http://example.com/win/1234',
meta: {
advertiserDomains: ['abc.com']
}
Expand Down Expand Up @@ -402,4 +404,28 @@ describe('riseAdapter', function () {
expect(syncs).to.deep.equal([]);
});
})

describe('onBidWon', function() {
beforeEach(function() {
sinon.stub(utils, 'triggerPixel');
});
afterEach(function() {
utils.triggerPixel.restore();
});

it('Should trigger pixel if bid nurl', function() {
const bid = {
'bidder': spec.code,
'adUnitCode': 'adunit-code',
'sizes': [['640', '480']],
'nurl': 'http://example.com/win/1234',
'params': {
'org': 'jdye8weeyirk00000001'
}
};

spec.onBidWon(bid);
expect(utils.triggerPixel.callCount).to.equal(1)
})
})
});