Skip to content

Commit

Permalink
Merge pull request #47 from triplelift-internal/TL-19850-floors-modul…
Browse files Browse the repository at this point in the history
…e-update

TL-19850 Finished log error logic around floors functionality
  • Loading branch information
nllerandi3lift authored Apr 21, 2022
2 parents 9072383 + 0ebf51c commit da47d96
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
22 changes: 13 additions & 9 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tryAppendQueryString, logMessage, isEmpty, isStr, isPlainObject, isArray, logWarn } from '../src/utils.js';
import { tryAppendQueryString, logMessage, logError, isEmpty, isStr, isPlainObject, isArray, logWarn } from '../src/utils.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
Expand Down Expand Up @@ -175,14 +175,18 @@ function _getORTBVideo(bidRequest) {
function _getFloor (bid) {
let floor = null;
if (typeof bid.getFloor === 'function') {
const floorInfo = bid.getFloor({
currency: 'USD',
mediaType: _isInstreamBidRequest(bid) ? 'video' : 'banner',
size: '*'
});
if (typeof floorInfo === 'object' &&
floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) {
floor = parseFloat(floorInfo.floor);
try {
const floorInfo = bid.getFloor({
currency: 'USD',
mediaType: _isInstreamBidRequest(bid) ? 'video' : 'banner',
size: '*'
});
if (typeof floorInfo === 'object' &&
floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) {
floor = parseFloat(floorInfo.floor);
}
} catch (err) {
logError('Triplelift: getFloor threw an error: ', err);
}
}
return floor !== null ? floor : bid.params.floor;
Expand Down
11 changes: 11 additions & 0 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,17 @@ describe('triplelift adapter', function () {
size: '*'
})).to.be.true;
});
it('should catch error if getFloor throws error', function() {
let logErrorSpy = sinon.spy(utils, 'logError');

bidRequests[0].getFloor = () => {
throw new Error('An exception!');
};

tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);

expect(logErrorSpy.calledOnce).to.equal(true);
});
it('should send global config fpd if kvps are available', function() {
const sens = null;
const category = ['news', 'weather', 'hurricane'];
Expand Down

0 comments on commit da47d96

Please sign in to comment.