Skip to content

Commit 77254c2

Browse files
sj1815jsadwithjuliangan07njflynn“Nick
authored
Kargo Bid Adapter: floors and CreativeID update (prebid#11153)
* 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 <[email protected]> * 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 <[email protected]> Co-authored-by: Julian Gan <[email protected]> Co-authored-by: Neil Flynn <[email protected]> Co-authored-by: “Nick <“nick.llerandi”@kargo.com> Co-authored-by: Nick Llerandi <[email protected]>
1 parent 1c57789 commit 77254c2

File tree

2 files changed

+54
-24
lines changed

2 files changed

+54
-24
lines changed

modules/kargoBidAdapter.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { _each, isEmpty, buildUrl, deepAccess, pick, triggerPixel } from '../src/utils.js';
1+
import { _each, isEmpty, buildUrl, deepAccess, pick, triggerPixel, logError } from '../src/utils.js';
22
import { config } from '../src/config.js';
33
import { registerBidder } from '../src/adapters/bidderFactory.js';
44
import { getStorageManager } from '../src/storageManager.js';
@@ -221,7 +221,7 @@ function interpretResponse(response, bidRequest) {
221221
width: adUnit.width,
222222
height: adUnit.height,
223223
ttl: 300,
224-
creativeId: adUnit.id,
224+
creativeId: adUnit.creativeID,
225225
dealId: adUnit.targetingCustom,
226226
netRevenue: true,
227227
currency: adUnit.currency || bidRequest.currency,
@@ -459,10 +459,6 @@ function getImpression(bid) {
459459
code: bid.adUnitCode
460460
};
461461

462-
if (bid.floorData != null && bid.floorData.floorMin > 0) {
463-
imp.floor = bid.floorData.floorMin;
464-
}
465-
466462
if (bid.bidRequestsCount > 0) {
467463
imp.bidRequestCount = bid.bidRequestsCount;
468464
}
@@ -482,17 +478,33 @@ function getImpression(bid) {
482478
}
483479
}
484480

485-
if (bid.mediaTypes != null) {
486-
if (bid.mediaTypes.banner != null) {
487-
imp.banner = bid.mediaTypes.banner;
481+
if (bid.mediaTypes) {
482+
const { banner, video, native } = bid.mediaTypes;
483+
484+
if (banner) {
485+
imp.banner = banner;
488486
}
489487

490-
if (bid.mediaTypes.video != null) {
491-
imp.video = bid.mediaTypes.video;
488+
if (video) {
489+
imp.video = video;
492490
}
493491

494-
if (bid.mediaTypes.native != null) {
495-
imp.native = bid.mediaTypes.native;
492+
if (native) {
493+
imp.native = native;
494+
}
495+
496+
if (typeof bid.getFloor === 'function') {
497+
let floorInfo;
498+
try {
499+
floorInfo = bid.getFloor({
500+
currency: 'USD',
501+
mediaType: '*',
502+
size: '*'
503+
});
504+
} catch (e) {
505+
logError('Kargo: getFloor threw an error: ', e);
506+
}
507+
imp.floor = typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseInt(floorInfo.floor)) ? floorInfo.floor : undefined;
496508
}
497509
}
498510

test/spec/modules/kargoBidAdapter_spec.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ describe('kargo adapter tests', function () {
491491
},
492492
fpd: {
493493
gpid: '/22558409563,18834096/dfy_mobile_adhesion'
494-
}
494+
},
495+
floor: 2
495496
},
496497
{
497498
code: '303',
@@ -503,7 +504,8 @@ describe('kargo adapter tests', function () {
503504
},
504505
fpd: {
505506
gpid: '/22558409563,18834096/dfy_mobile_adhesion'
506-
}
507+
},
508+
floor: 3
507509
}
508510
],
509511
socan: {
@@ -605,6 +607,16 @@ describe('kargo adapter tests', function () {
605607
payload['gdprConsent'] = gdpr
606608
}
607609

610+
clonedBids.forEach(bid => {
611+
if (bid.mediaTypes.banner) {
612+
bid.getFloor = () => ({ currency: 'USD', floor: 1 });
613+
} else if (bid.mediaTypes.video) {
614+
bid.getFloor = () => ({ currency: 'USD', floor: 2 });
615+
} else if (bid.mediaTypes.native) {
616+
bid.getFloor = () => ({ currency: 'USD', floor: 3 });
617+
}
618+
});
619+
608620
var request = spec.buildRequests(clonedBids, payload);
609621
var krakenParams = request.data;
610622

@@ -725,7 +737,8 @@ describe('kargo adapter tests', function () {
725737
adm: '<div id="1"></div>',
726738
width: 320,
727739
height: 50,
728-
metadata: {}
740+
metadata: {},
741+
creativeID: 'bar'
729742
},
730743
2: {
731744
id: 'bar',
@@ -736,14 +749,16 @@ describe('kargo adapter tests', function () {
736749
targetingCustom: 'dmpmptest1234',
737750
metadata: {
738751
landingPageDomain: ['https://foobar.com']
739-
}
752+
},
753+
creativeID: 'foo'
740754
},
741755
3: {
742756
id: 'bar',
743757
cpm: 2.5,
744758
adm: '<div id="2"></div>',
745759
width: 300,
746-
height: 250
760+
height: 250,
761+
creativeID: 'foo'
747762
},
748763
4: {
749764
id: 'bar',
@@ -753,6 +768,7 @@ describe('kargo adapter tests', function () {
753768
height: 250,
754769
mediaType: 'banner',
755770
metadata: {},
771+
creativeID: 'foo',
756772
currency: 'EUR'
757773
},
758774
5: {
@@ -763,6 +779,7 @@ describe('kargo adapter tests', function () {
763779
height: 250,
764780
mediaType: 'video',
765781
metadata: {},
782+
creativeID: 'foo',
766783
currency: 'EUR'
767784
},
768785
6: {
@@ -774,6 +791,7 @@ describe('kargo adapter tests', function () {
774791
height: 250,
775792
mediaType: 'video',
776793
metadata: {},
794+
creativeID: 'foo',
777795
currency: 'EUR'
778796
}
779797
}
@@ -818,7 +836,7 @@ describe('kargo adapter tests', function () {
818836
width: 320,
819837
height: 50,
820838
ttl: 300,
821-
creativeId: 'foo',
839+
creativeId: 'bar',
822840
dealId: undefined,
823841
netRevenue: true,
824842
currency: 'USD',
@@ -833,7 +851,7 @@ describe('kargo adapter tests', function () {
833851
width: 300,
834852
height: 250,
835853
ttl: 300,
836-
creativeId: 'bar',
854+
creativeId: 'foo',
837855
dealId: 'dmpmptest1234',
838856
netRevenue: true,
839857
currency: 'USD',
@@ -850,7 +868,7 @@ describe('kargo adapter tests', function () {
850868
width: 300,
851869
height: 250,
852870
ttl: 300,
853-
creativeId: 'bar',
871+
creativeId: 'foo',
854872
dealId: undefined,
855873
netRevenue: true,
856874
currency: 'USD',
@@ -865,7 +883,7 @@ describe('kargo adapter tests', function () {
865883
width: 300,
866884
height: 250,
867885
ttl: 300,
868-
creativeId: 'bar',
886+
creativeId: 'foo',
869887
dealId: undefined,
870888
netRevenue: true,
871889
currency: 'EUR',
@@ -880,7 +898,7 @@ describe('kargo adapter tests', function () {
880898
height: 250,
881899
vastXml: '<VAST></VAST>',
882900
ttl: 300,
883-
creativeId: 'bar',
901+
creativeId: 'foo',
884902
dealId: undefined,
885903
netRevenue: true,
886904
currency: 'EUR',
@@ -895,7 +913,7 @@ describe('kargo adapter tests', function () {
895913
height: 250,
896914
vastUrl: 'https://foobar.com/vast_adm',
897915
ttl: 300,
898-
creativeId: 'bar',
916+
creativeId: 'foo',
899917
dealId: undefined,
900918
netRevenue: true,
901919
currency: 'EUR',

0 commit comments

Comments
 (0)