From 77254c2954d61c9156735a2fb30611fd7bbde6e4 Mon Sep 17 00:00:00 2001 From: Saurabh Joshi <43156540+sj1815@users.noreply.github.com> Date: Thu, 14 Mar 2024 04:49:56 -0400 Subject: [PATCH] Kargo Bid Adapter: floors and CreativeID update (#11153) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * KargoBidAdapter: GPP Support * kargo adapter to forward schain object (#21) * wrap in if statement (#22) * KRKPD-572: Add spec for schain (#23) * wrap in if statement * update test for schain, file formatting * Adding site to Kargo adapter. * KRKPD-619 Updating Site object. * KRKPD-619 Adding null check for Site object. * Update modules/kargoBidAdapter.js Co-authored-by: Julian Gan * Reducing the size of Site object. * remove white space that is causing linting error * Kargo Bid Adapter: Updates to gpid retrieval * Support for sending ortb2.user.data * update bid Response to use actual creativeID * update spec * fix nomencalature based on Kargo's service * Prebid.js - Update bid Response to use actual creativeID (#25) * update bid Response to use actual creativeID * update spec * fix nomencalature based on Kargo's service * utilize floors mod * fixes tests * mediatype specific floors * simpler implementation leveraging Prebid's smart rule selection * revert nomenclature change * fix * removes comment --------- Co-authored-by: Jeremy Sadwith Co-authored-by: Julian Gan Co-authored-by: Neil Flynn Co-authored-by: “Nick <“nick.llerandi”@kargo.com> Co-authored-by: Nick Llerandi --- modules/kargoBidAdapter.js | 38 +++++++++++++-------- test/spec/modules/kargoBidAdapter_spec.js | 40 ++++++++++++++++------- 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/modules/kargoBidAdapter.js b/modules/kargoBidAdapter.js index 9d8c7bc06a1..b72601e5ebb 100644 --- a/modules/kargoBidAdapter.js +++ b/modules/kargoBidAdapter.js @@ -1,4 +1,4 @@ -import { _each, isEmpty, buildUrl, deepAccess, pick, triggerPixel } from '../src/utils.js'; +import { _each, isEmpty, buildUrl, deepAccess, pick, triggerPixel, logError } from '../src/utils.js'; import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { getStorageManager } from '../src/storageManager.js'; @@ -221,7 +221,7 @@ function interpretResponse(response, bidRequest) { width: adUnit.width, height: adUnit.height, ttl: 300, - creativeId: adUnit.id, + creativeId: adUnit.creativeID, dealId: adUnit.targetingCustom, netRevenue: true, currency: adUnit.currency || bidRequest.currency, @@ -459,10 +459,6 @@ function getImpression(bid) { code: bid.adUnitCode }; - if (bid.floorData != null && bid.floorData.floorMin > 0) { - imp.floor = bid.floorData.floorMin; - } - if (bid.bidRequestsCount > 0) { imp.bidRequestCount = bid.bidRequestsCount; } @@ -482,17 +478,33 @@ function getImpression(bid) { } } - if (bid.mediaTypes != null) { - if (bid.mediaTypes.banner != null) { - imp.banner = bid.mediaTypes.banner; + if (bid.mediaTypes) { + const { banner, video, native } = bid.mediaTypes; + + if (banner) { + imp.banner = banner; } - if (bid.mediaTypes.video != null) { - imp.video = bid.mediaTypes.video; + if (video) { + imp.video = video; } - if (bid.mediaTypes.native != null) { - imp.native = bid.mediaTypes.native; + if (native) { + imp.native = native; + } + + if (typeof bid.getFloor === 'function') { + let floorInfo; + try { + floorInfo = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*' + }); + } catch (e) { + logError('Kargo: getFloor threw an error: ', e); + } + imp.floor = typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseInt(floorInfo.floor)) ? floorInfo.floor : undefined; } } diff --git a/test/spec/modules/kargoBidAdapter_spec.js b/test/spec/modules/kargoBidAdapter_spec.js index f43c3b11aac..40f8833c6ec 100644 --- a/test/spec/modules/kargoBidAdapter_spec.js +++ b/test/spec/modules/kargoBidAdapter_spec.js @@ -491,7 +491,8 @@ describe('kargo adapter tests', function () { }, fpd: { gpid: '/22558409563,18834096/dfy_mobile_adhesion' - } + }, + floor: 2 }, { code: '303', @@ -503,7 +504,8 @@ describe('kargo adapter tests', function () { }, fpd: { gpid: '/22558409563,18834096/dfy_mobile_adhesion' - } + }, + floor: 3 } ], socan: { @@ -605,6 +607,16 @@ describe('kargo adapter tests', function () { payload['gdprConsent'] = gdpr } + clonedBids.forEach(bid => { + if (bid.mediaTypes.banner) { + bid.getFloor = () => ({ currency: 'USD', floor: 1 }); + } else if (bid.mediaTypes.video) { + bid.getFloor = () => ({ currency: 'USD', floor: 2 }); + } else if (bid.mediaTypes.native) { + bid.getFloor = () => ({ currency: 'USD', floor: 3 }); + } + }); + var request = spec.buildRequests(clonedBids, payload); var krakenParams = request.data; @@ -725,7 +737,8 @@ describe('kargo adapter tests', function () { adm: '
', width: 320, height: 50, - metadata: {} + metadata: {}, + creativeID: 'bar' }, 2: { id: 'bar', @@ -736,14 +749,16 @@ describe('kargo adapter tests', function () { targetingCustom: 'dmpmptest1234', metadata: { landingPageDomain: ['https://foobar.com'] - } + }, + creativeID: 'foo' }, 3: { id: 'bar', cpm: 2.5, adm: '
', width: 300, - height: 250 + height: 250, + creativeID: 'foo' }, 4: { id: 'bar', @@ -753,6 +768,7 @@ describe('kargo adapter tests', function () { height: 250, mediaType: 'banner', metadata: {}, + creativeID: 'foo', currency: 'EUR' }, 5: { @@ -763,6 +779,7 @@ describe('kargo adapter tests', function () { height: 250, mediaType: 'video', metadata: {}, + creativeID: 'foo', currency: 'EUR' }, 6: { @@ -774,6 +791,7 @@ describe('kargo adapter tests', function () { height: 250, mediaType: 'video', metadata: {}, + creativeID: 'foo', currency: 'EUR' } } @@ -818,7 +836,7 @@ describe('kargo adapter tests', function () { width: 320, height: 50, ttl: 300, - creativeId: 'foo', + creativeId: 'bar', dealId: undefined, netRevenue: true, currency: 'USD', @@ -833,7 +851,7 @@ describe('kargo adapter tests', function () { width: 300, height: 250, ttl: 300, - creativeId: 'bar', + creativeId: 'foo', dealId: 'dmpmptest1234', netRevenue: true, currency: 'USD', @@ -850,7 +868,7 @@ describe('kargo adapter tests', function () { width: 300, height: 250, ttl: 300, - creativeId: 'bar', + creativeId: 'foo', dealId: undefined, netRevenue: true, currency: 'USD', @@ -865,7 +883,7 @@ describe('kargo adapter tests', function () { width: 300, height: 250, ttl: 300, - creativeId: 'bar', + creativeId: 'foo', dealId: undefined, netRevenue: true, currency: 'EUR', @@ -880,7 +898,7 @@ describe('kargo adapter tests', function () { height: 250, vastXml: '', ttl: 300, - creativeId: 'bar', + creativeId: 'foo', dealId: undefined, netRevenue: true, currency: 'EUR', @@ -895,7 +913,7 @@ describe('kargo adapter tests', function () { height: 250, vastUrl: 'https://foobar.com/vast_adm', ttl: 300, - creativeId: 'bar', + creativeId: 'foo', dealId: undefined, netRevenue: true, currency: 'EUR',