From cda0b6b9278da2ec416c0cae65921ff5df2bcfdc Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Tue, 25 May 2021 14:14:32 -0400 Subject: [PATCH 1/2] added gpid to sonobi bidder adapter. It tries to get the gpt ad unit code --- modules/sonobiBidAdapter.js | 15 +++++++++--- test/spec/modules/sonobiBidAdapter_spec.js | 27 ++++++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index e5bd76eba9f..1bdeb7fffb6 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -1,5 +1,5 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { parseSizesInput, logError, generateUUID, isEmpty, deepAccess, logWarn, logMessage, deepClone } from '../src/utils.js'; +import { parseSizesInput, logError, generateUUID, isEmpty, deepAccess, logWarn, logMessage, deepClone, getGptSlotInfoForAdUnitCode } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; import { Renderer } from '../src/Renderer.js'; @@ -60,11 +60,11 @@ export const spec = { if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)) { slotIdentifier = slotIdentifier.charAt(0) === '/' ? slotIdentifier : '/' + slotIdentifier; return { - [`${slotIdentifier}|${bid.bidId}`]: `${_validateSize(bid)}${_validateFloor(bid)}` + [`${slotIdentifier}|${bid.bidId}`]: `${_validateSize(bid)}${_validateFloor(bid)}${_validateGPID(bid)}` } } else if (/^[0-9a-fA-F]{20}$/.test(slotIdentifier) && slotIdentifier.length === 20) { return { - [bid.bidId]: `${slotIdentifier}|${_validateSize(bid)}${_validateFloor(bid)}` + [bid.bidId]: `${slotIdentifier}|${_validateSize(bid)}${_validateFloor(bid)}${_validateGPID(bid)}` } } else { logError(`The ad unit code or Sonobi Placement id for slot ${bid.bidId} is invalid`); @@ -302,6 +302,15 @@ function _validateFloor (bid) { return ''; } +function _validateGPID(bid) { + const gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot') || deepAccess(getGptSlotInfoForAdUnitCode(bid.adUnitCode), 'gptSlot') || bid.params.ad_unit; + + if (gpid) { + return `|gpid=${gpid}` + } + return '' +} + const _creative = (mediaType, referer) => (sbiDc, sbiAid) => { if (mediaType === 'video' || mediaType === 'outstream') { return _videoCreative(sbiDc, sbiAid, referer) diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 0314ffb71c1..6c7d62e7413 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -3,6 +3,7 @@ import { spec, _getPlatform } from 'modules/sonobiBidAdapter.js' import { newBidder } from 'src/adapters/bidderFactory.js' import {userSync} from '../../../src/userSync.js'; import { config } from 'src/config.js'; +import * as utils from '../../../src/utils.js'; describe('SonobiBidAdapter', function () { const adapter = newBidder(spec) @@ -239,9 +240,12 @@ describe('SonobiBidAdapter', function () { describe('.buildRequests', function () { 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'}) }); afterEach(function() { userSync.canBidderRegisterSync.restore(); + utils.getGptSlotInfoForAdUnitCode.restore(); }); let bidRequest = [{ 'schain': { @@ -271,6 +275,24 @@ describe('SonobiBidAdapter', function () { 'adUnitCode': 'adunit-code-1', 'sizes': [[300, 250], [300, 600]], 'bidId': '30b31c1838de1f', + ortb2Imp: { + ext: { + data: { + pbadslot: '/123123/gpt_publisher/adunit-code-1' + } + } + } + }, + { + 'bidder': 'sonobi', + 'params': { + 'placement_id': '1a2b3c4d5e6f1a2b3c4e', + 'sizes': [[300, 250], [300, 600]], + 'referrer': 'overrides_top_window_location' + }, + 'adUnitCode': 'adunit-code-3', + 'sizes': [[120, 600], [300, 600], [160, 600]], + 'bidId': '30b31c1838de1d', }, { 'bidder': 'sonobi', @@ -285,8 +307,9 @@ describe('SonobiBidAdapter', function () { }]; let keyMakerData = { - '30b31c1838de1f': '1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25', - '/7780971/sparks_prebid_LB|30b31c1838de1e': '300x250,300x600', + '30b31c1838de1f': '1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25|gpid=/123123/gpt_publisher/adunit-code-1', + '30b31c1838de1d': '1a2b3c4d5e6f1a2b3c4e|300x250,300x600|gpid=/123123/gpt_publisher/adunit-code-3', + '/7780971/sparks_prebid_LB|30b31c1838de1e': '300x250,300x600|gpid=/7780971/sparks_prebid_LB', }; let bidderRequests = { From 9c0a3714b6f2fea727a132c7370305b7be9177ae Mon Sep 17 00:00:00 2001 From: Jonathan Go Date: Wed, 26 May 2021 09:53:36 -0400 Subject: [PATCH 2/2] added advertiser domain to bid meta --- modules/sonobiBidAdapter.js | 9 ++++++- test/spec/modules/sonobiBidAdapter_spec.js | 28 ++++++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 1bdeb7fffb6..eb6009079ac 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -199,6 +199,10 @@ export const spec = { width = 1, height = 1 ] = bid.sbi_size.split('x'); + let aDomains = []; + if (bid.sbi_adomain) { + aDomains = [bid.sbi_adomain] + } const bids = { requestId: bidId, cpm: Number(bid.sbi_mouse), @@ -209,7 +213,10 @@ export const spec = { creativeId: bid.sbi_crid || bid.sbi_aid, aid: bid.sbi_aid, netRevenue: true, - currency: 'USD' + currency: 'USD', + meta: { + advertiserDomains: aDomains + } }; if (bid.sbi_dozer) { diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index 6c7d62e7413..79bfa86b216 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -652,6 +652,7 @@ describe('SonobiBidAdapter', function () { 'sbi_crid': '1234abcd', 'sbi_aid': '30292e432662bd5f86d90774b944b039', 'sbi_mouse': 1.07, + 'sbi_adomain': 'sonobi.com' }, '30b31c1838de1e': { 'sbi_size': '300x250', @@ -659,7 +660,9 @@ describe('SonobiBidAdapter', function () { 'sbi_aid': '30292e432662bd5f86d90774b944b038', 'sbi_mouse': 1.25, 'sbi_dozer': 'dozerkey', - 'sbi_ct': 'video' + 'sbi_ct': 'video', + 'sbi_adomain': 'sonobi.com' + }, '/7780971/sparks_prebid_LB_OUTSTREAM|30b31c1838de1g': { 'sbi_size': '300x600', @@ -667,6 +670,8 @@ describe('SonobiBidAdapter', function () { 'sbi_crid': '1234abcd', 'sbi_aid': '30292e432662bd5f86d90774b944b038', 'sbi_mouse': 1.07, + 'sbi_adomain': 'sonobi.com' + }, '/7780971/sparks_prebid_LB|30b31c1838de1g': {}, '30b31c1838de1zzzz': { @@ -677,6 +682,7 @@ describe('SonobiBidAdapter', function () { sbi_mouse: 1.25, sbi_size: 'preroll', 'sbi_crid': 'somecrid', + 'sbi_adomain': 'sonobi.com' } @@ -703,7 +709,10 @@ describe('SonobiBidAdapter', function () { 'creativeId': '1234abcd', 'netRevenue': true, 'currency': 'USD', - 'aid': '30292e432662bd5f86d90774b944b039' + 'aid': '30292e432662bd5f86d90774b944b039', + meta: { + advertiserDomains: ['sonobi.com'] + } }, { 'requestId': '30b31c1838de1e', @@ -717,7 +726,10 @@ describe('SonobiBidAdapter', function () { 'currency': 'USD', 'dealId': 'dozerkey', 'aid': '30292e432662bd5f86d90774b944b038', - 'mediaType': 'video' + 'mediaType': 'video', + meta: { + advertiserDomains: ['sonobi.com'] + } }, { 'requestId': '30b31c1838de1g', @@ -729,7 +741,10 @@ describe('SonobiBidAdapter', function () { 'creativeId': '1234abcd', 'netRevenue': true, 'currency': 'USD', - 'aid': '30292e432662bd5f86d90774b944b038' + 'aid': '30292e432662bd5f86d90774b944b038', + meta: { + advertiserDomains: ['sonobi.com'] + } }, { 'requestId': '30b31c1838de1zzzz', @@ -744,7 +759,10 @@ describe('SonobiBidAdapter', function () { 'dealId': 'dozerkey', 'aid': 'force_1550072228_da1c5d030cb49150c5db8a2136175755', 'mediaType': 'video', - renderer: () => {} + renderer: () => {}, + meta: { + advertiserDomains: ['sonobi.com'] + } }, ];