Skip to content

Commit

Permalink
Kargo Bid Adapter: Support video mediaType (prebid#7428)
Browse files Browse the repository at this point in the history
* KRAK-3001 adding video support to prebid adapter

* Simplified video implementation

* Linting

* Removed video context validation

* Revert merge bidIDs->bidIds

* Updated placement ID for video test

Co-authored-by: fionasequeira <[email protected]>
  • Loading branch information
2 people authored and Chris Pabst committed Jan 10, 2022
1 parent a2242ce commit 5eec47c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
21 changes: 14 additions & 7 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { _each } from '../src/utils.js';
import {config} from '../src/config.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { getStorageManager } from '../src/storageManager.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';

const BIDDER_CODE = 'kargo';
const HOST = 'https://krk.kargo.com';
const SYNC = 'https://crb.kargo.com/api/v1/initsyncrnd/{UUID}?seed={SEED}&idx={INDEX}&gdpr={GDPR}&gdpr_consent={GDPR_CONSENT}&us_privacy={US_PRIVACY}';
const SYNC_COUNT = 5;
const GVLID = 972;
const SUPPORTED_MEDIA_TYPES = [BANNER, VIDEO]
const storage = getStorageManager(GVLID, BIDDER_CODE);

let sessionId,
Expand All @@ -21,34 +23,38 @@ export const spec = {
if (!bid || !bid.params) {
return false;
}

return !!bid.params.placementId;
},
buildRequests: function(validBidRequests, bidderRequest) {
const currencyObj = config.getConfig('currency');
const currency = (currencyObj && currencyObj.adServerCurrency) || 'USD';
const bidIds = {};
const bidIDs = {};
const bidSizes = {};

_each(validBidRequests, bid => {
bidIds[bid.bidId] = bid.params.placementId;
bidIDs[bid.bidId] = bid.params.placementId;
bidSizes[bid.bidId] = bid.sizes;
});

let tdid;
if (validBidRequests.length > 0 && validBidRequests[0].userId && validBidRequests[0].userId.tdid) {
tdid = validBidRequests[0].userId.tdid;
}

const transformedParams = Object.assign({}, {
sessionId: spec._getSessionId(),
requestCount: spec._getRequestCount(),
timeout: bidderRequest.timeout,
currency: currency,
currency,
cpmGranularity: 1,
timestamp: (new Date()).getTime(),
cpmRange: {
floor: 0,
ceil: 20
},
bidIDs: bidIds,
bidSizes: bidSizes,
bidIDs,
bidSizes,
prebidRawBidRequests: validBidRequests
}, spec._getAllMetadata(tdid, bidderRequest.uspConsent, bidderRequest.gdprConsent));
const encodedParams = encodeURIComponent(JSON.stringify(transformedParams));
Expand Down Expand Up @@ -111,6 +117,7 @@ export const spec = {
}
return syncs;
},
supportedMediaTypes: SUPPORTED_MEDIA_TYPES,

// PRIVATE
_readCookie(name) {
Expand Down
20 changes: 20 additions & 0 deletions modules/kargoBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,25 @@ Please use `kargo` as the bidder code. Also, you *must* test on a mobile device,
placementId: '_m1Xt2E5dez'
}
}]
},{
code: 'div-gpt-ad-video-1',
sizes: [[640,480]],
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
}
},
bids: [{
bidder: 'kargo',
params: {
placementId: '_bLIt2QMYee',
video: {
skipppable: true,
playback_method: ['auto_play_sound_off'],
mimes: ['video/mp4']
}
}
}]
}];
```

0 comments on commit 5eec47c

Please sign in to comment.