Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kargo Bid Adapter: Support video mediaType #7428

Merged
merged 7 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']
}
}
}]
}];
```