Skip to content

Commit

Permalink
Kargo Bid Adapter: floors and CreativeID update (prebid#11153)
Browse files Browse the repository at this point in the history
* 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  <juliangan07@gmail.com>

* 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 <jeremy@kargo.com>
Co-authored-by: Julian Gan <juliangan07@gmail.com>
Co-authored-by: Neil Flynn <nflynn@kargo.com>
Co-authored-by: “Nick <“nick.llerandi”@kargo.com>
Co-authored-by: Nick Llerandi <nick.llerandi@kargo.com>
  • Loading branch information
6 people authored Mar 14, 2024
1 parent 1c57789 commit 77254c2
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 24 deletions.
38 changes: 25 additions & 13 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
}

Expand Down
40 changes: 29 additions & 11 deletions test/spec/modules/kargoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ describe('kargo adapter tests', function () {
},
fpd: {
gpid: '/22558409563,18834096/dfy_mobile_adhesion'
}
},
floor: 2
},
{
code: '303',
Expand All @@ -503,7 +504,8 @@ describe('kargo adapter tests', function () {
},
fpd: {
gpid: '/22558409563,18834096/dfy_mobile_adhesion'
}
},
floor: 3
}
],
socan: {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -725,7 +737,8 @@ describe('kargo adapter tests', function () {
adm: '<div id="1"></div>',
width: 320,
height: 50,
metadata: {}
metadata: {},
creativeID: 'bar'
},
2: {
id: 'bar',
Expand All @@ -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: '<div id="2"></div>',
width: 300,
height: 250
height: 250,
creativeID: 'foo'
},
4: {
id: 'bar',
Expand All @@ -753,6 +768,7 @@ describe('kargo adapter tests', function () {
height: 250,
mediaType: 'banner',
metadata: {},
creativeID: 'foo',
currency: 'EUR'
},
5: {
Expand All @@ -763,6 +779,7 @@ describe('kargo adapter tests', function () {
height: 250,
mediaType: 'video',
metadata: {},
creativeID: 'foo',
currency: 'EUR'
},
6: {
Expand All @@ -774,6 +791,7 @@ describe('kargo adapter tests', function () {
height: 250,
mediaType: 'video',
metadata: {},
creativeID: 'foo',
currency: 'EUR'
}
}
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -880,7 +898,7 @@ describe('kargo adapter tests', function () {
height: 250,
vastXml: '<VAST></VAST>',
ttl: 300,
creativeId: 'bar',
creativeId: 'foo',
dealId: undefined,
netRevenue: true,
currency: 'EUR',
Expand All @@ -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',
Expand Down

0 comments on commit 77254c2

Please sign in to comment.