diff --git a/modules/ixBidAdapter.js b/modules/ixBidAdapter.js index 4efed90d147..a8ffc4be721 100644 --- a/modules/ixBidAdapter.js +++ b/modules/ixBidAdapter.js @@ -38,7 +38,6 @@ const BANNER_TIME_TO_LIVE = 300; const VIDEO_TIME_TO_LIVE = 3600; // 1hr const NATIVE_TIME_TO_LIVE = 3600; // Since native can have video, use ttl same as video const NET_REVENUE = true; -const MAX_REQUEST_SIZE = 8000; const MAX_REQUEST_LIMIT = 4; const OUTSTREAM_MINIMUM_PLAYER_SIZE = [144, 144]; const PRICE_TO_DOLLAR_FACTOR = { @@ -586,6 +585,12 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { let userEids = eidInfo.toSend; const pageUrl = deepAccess(bidderRequest, 'refererInfo.page'); + let MAX_REQUEST_SIZE = 8000; + // Modify request size limit if its FT is enabeld. + if (FEATURE_TOGGLES.isFeatureEnabled('pbjs_use_32kb_size_limit')) { + MAX_REQUEST_SIZE = 32000 + } + // RTI ids will be included in the bid request if the function getIdentityInfo() is loaded // and if the data for the partner exist if (window.headertag && typeof window.headertag.getIdentityInfo === 'function') { @@ -642,6 +647,9 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) { r.ext.ixdiag.err = cachedErrors; } + // Add number of available imps to ixDiag. + r.ext.ixdiag.imps = Object.keys(impressions).length; + // set source.tid to auctionId for outgoing request to Exchange. r.source = { tid: validBidRequests[0].auctionId, diff --git a/test/spec/modules/ixBidAdapter_spec.js b/test/spec/modules/ixBidAdapter_spec.js index a2698fa2cdc..ec749398019 100644 --- a/test/spec/modules/ixBidAdapter_spec.js +++ b/test/spec/modules/ixBidAdapter_spec.js @@ -1563,6 +1563,13 @@ describe('IndexexchangeAdapter', function () { expect(r.ext.ixdiag.tmax).to.be.undefined }); + it('should set ixdiag.imps to number of impressions', function () { + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0]; + const r = extractPayload(request); + + expect(r.ext.ixdiag.imps).to.equal(1); + }); + it('should not send information that is not part of openRTB spec v2.5 using ortb2', function () { const ortb2 = { site: { @@ -3388,6 +3395,99 @@ describe('IndexexchangeAdapter', function () { expect(FEATURE_TOGGLES.isFeatureEnabled('test')).to.be.undefined; expect(FEATURE_TOGGLES.featureToggles).to.deep.equal({}); }); + + it('should set request size limit to 32KB when its feature enabled', () => { + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + serverResponse.body.ext.features.pbjs_use_32kb_size_limit = { + activated: true + }; + FEATURE_TOGGLES.setFeatureToggles(serverResponse); + const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]); + bid.bidderRequestId = Array(10000).join('#'); + + expect(spec.isBidRequestValid(bid)).to.be.true; + spec.buildRequests([bid], {}); + const lsData = JSON.parse(storage.getDataFromLocalStorage(LOCAL_STORAGE_FEATURE_TOGGLES_KEY)); + expect(lsData.features.pbjs_use_32kb_size_limit.activated).to.be.true; + }); + + it('6 ad units should generate only 2 requests if 32kb size limit FT is enabled', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + serverResponse.body.ext.features.pbjs_use_32kb_size_limit = { + activated: true + }; + serverResponse.body.ext.features.pbjs_enable_post = { + activated: true + }; + FEATURE_TOGGLES.setFeatureToggles(serverResponse); + + const bid1 = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + bid1.mediaTypes.banner.sizes = LARGE_SET_OF_SIZES; + bid1.params.siteId = '121'; + bid1.adUnitCode = 'div-gpt-1' + bid1.transactionId = 'tr1'; + bid1.bidId = '2f6g5s5e'; + + const bid2 = utils.deepClone(bid1); + bid2.transactionId = 'tr2'; + + const bid3 = utils.deepClone(bid1); + bid3.transactionId = 'tr3'; + + const bid4 = utils.deepClone(bid1); + bid4.transactionId = 'tr4'; + + const bid5 = utils.deepClone(bid1); + bid5.transactionId = 'tr5'; + + const bid6 = utils.deepClone(bid1); + bid6.transactionId = 'tr6'; + + const requests = spec.buildRequests([bid1, bid2, bid3, bid4, bid5, bid6], DEFAULT_OPTION); + + expect(requests).to.be.an('array'); + // 32KB size limit causes only 2 requests to get generated. + expect(requests).to.have.lengthOf(2); + for (let request of requests) { + expect(request.method).to.equal('POST'); + } + }); + + it('4 ad units should generate only 1 requests if 32kb size limit FT is enabled', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + serverResponse.body.ext.features.pbjs_use_32kb_size_limit = { + activated: true + }; + serverResponse.body.ext.features.pbjs_enable_post = { + activated: true + }; + FEATURE_TOGGLES.setFeatureToggles(serverResponse); + + const bid1 = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + bid1.mediaTypes.banner.sizes = LARGE_SET_OF_SIZES; + bid1.params.siteId = '121'; + bid1.adUnitCode = 'div-gpt-1' + bid1.transactionId = 'tr1'; + bid1.bidId = '2f6g5s5e'; + + const bid2 = utils.deepClone(bid1); + bid2.transactionId = 'tr2'; + + const bid3 = utils.deepClone(bid1); + bid3.transactionId = 'tr3'; + + const bid4 = utils.deepClone(bid1); + bid4.transactionId = 'tr4'; + + const requests = spec.buildRequests([bid1, bid2, bid3, bid4], DEFAULT_OPTION); + + expect(requests).to.be.an('array'); + // 32KB size limit causes only 1 requests to get generated. + expect(requests).to.have.lengthOf(1); + for (let request of requests) { + expect(request.method).to.equal('POST'); + } + }); }); describe('LocalStorage error codes', () => {