From eb3ee0bc3f21e088e9a7607f79ab40c831de4557 Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Thu, 21 Oct 2021 16:01:40 -0400 Subject: [PATCH] Send ortb2 object to sonobi bidding endpoint as fpd param --- modules/sonobiBidAdapter.js | 7 +++++ test/spec/modules/sonobiBidAdapter_spec.js | 35 +++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 01966f3d6b1..c5fc07320d8 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -83,8 +83,15 @@ export const spec = { 'lib_name': 'prebid', 'lib_v': '$prebid.version$', 'us': 0, + }; + const fpd = config.getConfig('ortb2'); + + if (fpd) { + payload.fpd = JSON.stringify(fpd); + } + if (config.getConfig('userSync') && config.getConfig('userSync').syncsPerBidder) { payload.us = config.getConfig('userSync').syncsPerBidder; } diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 05ba3f0897b..f56f4e0c12b 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -238,14 +238,17 @@ describe('SonobiBidAdapter', function () { }); describe('.buildRequests', function () { + let sandbox; beforeEach(function() { sinon.stub(userSync, 'canBidderRegisterSync'); sinon.stub(utils, 'getGptSlotInfoForAdUnitCode') - .onFirstCall().returns({gptSlot: '/123123/gpt_publisher/adunit-code-3', divId: 'adunit-code-3-div-id'}) + .onFirstCall().returns({gptSlot: '/123123/gpt_publisher/adunit-code-3', divId: 'adunit-code-3-div-id'}); + sandbox = sinon.createSandbox(); }); afterEach(function() { userSync.canBidderRegisterSync.restore(); utils.getGptSlotInfoForAdUnitCode.restore(); + sandbox.restore(); }); let bidRequest = [{ 'schain': { @@ -333,6 +336,36 @@ describe('SonobiBidAdapter', function () { uspConsent: 'someCCPAString' }; + it('should set fpd if there is any data in ortb2', function() { + const ortb2 = { + site: { + ext: { + data: { + pageType: 'article', + category: 'tools' + } + } + }, + user: { + ext: { + data: { + registered: true, + interests: ['cars'] + } + } + } + }; + + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + ortb2: ortb2 + }; + return utils.deepAccess(config, key); + }); + const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + expect(bidRequests.data.fpd).to.equal(JSON.stringify(ortb2)); + }); + it('should populate coppa as 1 if set in config', function () { config.setConfig({coppa: true}); const bidRequests = spec.buildRequests(bidRequest, bidderRequests);