Skip to content

Commit

Permalink
Merge branch 'prebid:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Wazabit authored Jul 17, 2024
2 parents 12942d0 + 40b906d commit f24297c
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 106 deletions.
3 changes: 2 additions & 1 deletion modules/adkernelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export const spec = {
{code: 'digiad'},
{code: 'monetix'},
{code: 'hyperbrainz'},
{code: 'voisetech'}
{code: 'voisetech'},
{code: 'global_sun'}
],
supportedMediaTypes: [BANNER, VIDEO, NATIVE],

Expand Down
66 changes: 35 additions & 31 deletions modules/insticatorBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,8 @@ function buildVideo(bidRequest) {
const playerSize = deepAccess(bidRequest, 'mediaTypes.video.playerSize');
const context = deepAccess(bidRequest, 'mediaTypes.video.context');

if (!w && playerSize) {
if (Array.isArray(playerSize[0])) {
w = parseInt(playerSize[0][0], 10);
} else if (typeof playerSize[0] === 'number' && !isNaN(playerSize[0])) {
w = parseInt(playerSize[0], 10);
}
}
if (!h && playerSize) {
if (Array.isArray(playerSize[0])) {
h = parseInt(playerSize[0][1], 10);
} else if (typeof playerSize[1] === 'number' && !isNaN(playerSize[1])) {
h = parseInt(playerSize[1], 10);
}
if (!h && !w && playerSize) {
({w, h} = parsePlayerSizeToWidthHeight(playerSize, w, h));
}

const bidRequestVideo = deepAccess(bidRequest, 'mediaTypes.video');
Expand Down Expand Up @@ -173,6 +162,14 @@ function buildImpression(bidRequest) {
},
}

if (bidRequest?.params?.adUnitId) {
deepSetValue(imp, 'ext.prebid.bidder.insticator.adUnitId', bidRequest.params.adUnitId);
}

if (bidRequest?.params?.publisherId) {
deepSetValue(imp, 'ext.prebid.bidder.insticator.publisherId', bidRequest.params.publisherId);
}

let bidFloor = parseFloat(deepAccess(bidRequest, 'params.floor'));

if (!isNaN(bidFloor)) {
Expand Down Expand Up @@ -247,7 +244,7 @@ function buildDevice(bidRequest) {
const device = {
w: window.innerWidth,
h: window.innerHeight,
js: true,
js: 1,
ext: {
localStorage: storage.localStorageIsEnabled(),
cookies: storage.cookiesAreEnabled(),
Expand Down Expand Up @@ -569,24 +566,12 @@ function validateVideo(bid) {
let w = deepAccess(bid, 'mediaTypes.video.w');
let h = deepAccess(bid, 'mediaTypes.video.h');
const playerSize = deepAccess(bid, 'mediaTypes.video.playerSize');
if (!w && playerSize) {
if (Array.isArray(playerSize[0])) {
w = parseInt(playerSize[0][0], 10);
} else if (typeof playerSize[0] === 'number' && !isNaN(playerSize[0])) {
w = parseInt(playerSize[0], 10);
}
}
if (!h && playerSize) {
if (Array.isArray(playerSize[0])) {
h = parseInt(playerSize[0][1], 10);
} else if (typeof playerSize[1] === 'number' && !isNaN(playerSize[1])) {
h = parseInt(playerSize[1], 10);
}

if (!h && !w && playerSize) {
({w, h} = parsePlayerSizeToWidthHeight(playerSize, w, h));
}
const videoSize = [
w,
h,
];

const videoSize = [w, h];

if (
!validateSize(videoSize)
Expand Down Expand Up @@ -625,6 +610,25 @@ function validateVideo(bid) {
return true;
}

function parsePlayerSizeToWidthHeight(playerSize, w, h) {
if (!w && playerSize) {
if (Array.isArray(playerSize[0])) {
w = parseInt(playerSize[0][0], 10);
} else if (typeof playerSize[0] === 'number' && !isNaN(playerSize[0])) {
w = parseInt(playerSize[0], 10);
}
}
if (!h && playerSize) {
if (Array.isArray(playerSize[0])) {
h = parseInt(playerSize[0][1], 10);
} else if (typeof playerSize[1] === 'number' && !isNaN(playerSize[1])) {
h = parseInt(playerSize[1], 10);
}
}

return { w, h };
}

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
Expand Down
31 changes: 24 additions & 7 deletions modules/kimberliteBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { ortbConverter } from '../libraries/ortbConverter/converter.js'
import { deepSetValue } from '../src/utils.js';
import {ORTB_MTYPES} from '../libraries/ortbConverter/processors/mediaType.js';

const VERSION = '1.0.0';
const VERSION = '1.1.0';

const BIDDER_CODE = 'kimberlite';
const METHOD = 'POST';
const ENDPOINT_URL = 'https://kimberlite.io/rtb/bid/pbjs';
export const ENDPOINT_URL = 'https://kimberlite.io/rtb/bid/pbjs';

const VERSION_INFO = {
ver: '$prebid.version$',
Expand All @@ -16,7 +17,6 @@ const VERSION_INFO = {

const converter = ortbConverter({
context: {
mediaType: BANNER,
netRevenue: true,
ttl: 300
},
Expand All @@ -35,18 +35,32 @@ const converter = ortbConverter({
const imp = buildImp(bidRequest, context);
imp.tagid = bidRequest.params.placementId;
return imp;
}
},

bidResponse: function (buildBidResponse, bid, context) {
if (!bid.price) return;

const [type] = Object.keys(context.bidRequest.mediaTypes);
if (Object.values(ORTB_MTYPES).includes(type)) {
context.mediaType = type;
}

const bidResponse = buildBidResponse(bid, context);
return bidResponse;
},
});

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER],
supportedMediaTypes: [BANNER, VIDEO],

isBidRequestValid: (bidRequest = {}) => {
const { params, mediaTypes } = bidRequest;
let isValid = Boolean(params && params.placementId);
if (mediaTypes && mediaTypes[BANNER]) {
isValid = isValid && Boolean(mediaTypes[BANNER].sizes);
} else if (mediaTypes && mediaTypes[VIDEO]) {
isValid = isValid && Boolean(mediaTypes[VIDEO].mimes);
} else {
isValid = false;
}
Expand All @@ -58,7 +72,10 @@ export const spec = {
return {
method: METHOD,
url: ENDPOINT_URL,
data: converter.toORTB({ bidderRequest, bidRequests })
data: converter.toORTB({
bidRequests,
bidderRequest
})
}
},

Expand Down
31 changes: 30 additions & 1 deletion modules/kimberliteBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var adUnits = [
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[320, 250], [640, 480]],
sizes: [[320, 250], [640, 480]], // Required.
}
},
bids: [
Expand All @@ -34,3 +34,32 @@ var adUnits = [
}
]
```

## Video AdUnit

```javascript
var adUnits = [
{
code: 'test-div',
mediaTypes: {
video: {
// ORTB 2.5 options.
mimes: ['video/mp4'], // Required.
// Other options are optional.
placement: 1,
protocols: [3, 6],
linearity: 1,
startdelay: 0
}
},
bids: [
{
bidder: "kimberlite",
params: {
placementId: 'testVideo'
}
}
]
}
]
```
9 changes: 8 additions & 1 deletion test/spec/modules/insticatorBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ describe('InsticatorBidAdapter', function () {
expect(data.device).to.be.an('object');
expect(data.device.w).to.equal(window.innerWidth);
expect(data.device.h).to.equal(window.innerHeight);
expect(data.device.js).to.equal(true);
expect(data.device.js).to.equal(1);
expect(data.device.ext).to.be.an('object');
expect(data.device.ext.localStorage).to.equal(true);
expect(data.device.ext.cookies).to.equal(false);
Expand Down Expand Up @@ -439,6 +439,13 @@ describe('InsticatorBidAdapter', function () {
insticator: {
adUnitId: bidRequest.params.adUnitId,
},
prebid: {
bidder: {
insticator: {
adUnitId: bidRequest.params.adUnitId,
}
}
}
}
}]);
expect(data.ext).to.be.an('object');
Expand Down
Loading

0 comments on commit f24297c

Please sign in to comment.