diff --git a/modules/oguryBidAdapter.js b/modules/oguryBidAdapter.js index 513f9ed384e..fcbb89c5188 100644 --- a/modules/oguryBidAdapter.js +++ b/modules/oguryBidAdapter.js @@ -8,6 +8,7 @@ import { ajax } from '../src/ajax.js' const BIDDER_CODE = 'ogury'; const DEFAULT_TIMEOUT = 1000; const BID_HOST = 'https://mweb-hb.presage.io/api/header-bidding-request'; +const TIMEOUT_MONITORING_HOST = 'https://ms-ads-monitoring-events.presage.io'; const MS_COOKIE_SYNC_DOMAIN = 'https://ms-cookie-sync.presage.io'; function isBidRequestValid(bid) { @@ -141,6 +142,13 @@ function onBidWon(bid) { if (bid && bid.hasOwnProperty('nurl') && bid.nurl.length > 0) ajax(bid['nurl'], null); } +function onTimeout(timeoutData) { + ajax(`${TIMEOUT_MONITORING_HOST}/bid_timeout`, null, JSON.stringify(timeoutData[0]), { + method: 'POST', + contentType: 'application/json' + }); +} + export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER], @@ -149,7 +157,8 @@ export const spec = { buildRequests, interpretResponse, getFloor, - onBidWon + onBidWon, + onTimeout } registerBidder(spec); diff --git a/test/spec/modules/oguryBidAdapter_spec.js b/test/spec/modules/oguryBidAdapter_spec.js index d693e8fd3cc..d3a154b3989 100644 --- a/test/spec/modules/oguryBidAdapter_spec.js +++ b/test/spec/modules/oguryBidAdapter_spec.js @@ -2,7 +2,8 @@ import { expect } from 'chai'; import { spec } from 'modules/oguryBidAdapter'; import { deepClone } from 'src/utils.js'; -const BID_HOST = 'https://mweb-hb.presage.io/api/header-bidding-request'; +const BID_URL = 'https://mweb-hb.presage.io/api/header-bidding-request'; +const TIMEOUT_URL = 'https://ms-ads-monitoring-events.presage.io/bid_timeout' describe('OguryBidAdapter', function () { let bidRequests; @@ -150,7 +151,7 @@ describe('OguryBidAdapter', function () { const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); expect(userSyncs).to.have.lengthOf(1); expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') }); it('should return syncs array with an element of type image when consentString is null', () => { @@ -162,7 +163,7 @@ describe('OguryBidAdapter', function () { const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); expect(userSyncs).to.have.lengthOf(1); expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') }); it('should return syncs array with an element of type image when gdprConsent is undefined', () => { @@ -171,7 +172,7 @@ describe('OguryBidAdapter', function () { const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); expect(userSyncs).to.have.lengthOf(1); expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') }); it('should return syncs array with an element of type image when gdprConsent is null', () => { @@ -180,7 +181,7 @@ describe('OguryBidAdapter', function () { const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); expect(userSyncs).to.have.lengthOf(1); expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') }); it('should return syncs array with an element of type image when gdprConsent is null and gdprApplies is false', () => { @@ -192,7 +193,7 @@ describe('OguryBidAdapter', function () { const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); expect(userSyncs).to.have.lengthOf(1); expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') }); it('should return syncs array with an element of type image when gdprConsent is empty string and gdprApplies is false', () => { @@ -204,7 +205,7 @@ describe('OguryBidAdapter', function () { const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); expect(userSyncs).to.have.lengthOf(1); expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') }); }); @@ -255,7 +256,7 @@ describe('OguryBidAdapter', function () { const validBidRequests = deepClone(bidRequests) const request = spec.buildRequests(validBidRequests, bidderRequest); - expect(request.url).to.equal(BID_HOST); + expect(request.url).to.equal(BID_URL); expect(request.method).to.equal('POST'); }); @@ -453,11 +454,11 @@ describe('OguryBidAdapter', function () { }) afterEach(function() { - xhr.restore(); + xhr.restore() }) it('Should not create nurl request if bid is undefined', function() { - spec.onBidWon(); + spec.onBidWon() expect(requests.length).to.equal(0); }) @@ -473,4 +474,33 @@ describe('OguryBidAdapter', function () { expect(requests[0].method).to.equal('GET') }) }) + + describe('onTimeout', function () { + let xhr; + let requests; + + beforeEach(function() { + xhr = sinon.useFakeXMLHttpRequest(); + requests = []; + xhr.onCreate = (xhr) => { + requests.push(xhr); + }; + }) + + afterEach(function() { + xhr.restore() + }) + + it('should send notification on bid timeout', function() { + const bid = { + ad: 'cookies', + cpm: 3 + } + spec.onTimeout(bid); + expect(requests).to.not.be.undefined; + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal(TIMEOUT_URL); + expect(requests[0].method).to.equal('POST'); + }) + }); });