Skip to content

Commit

Permalink
Colossus Bid Adapter: add advertiserDomains and video params support (#…
Browse files Browse the repository at this point in the history
…7245)

* add video&native traffic colossus ssp

* Native obj validation

* Native obj validation #2

* Added size field in requests

* fixed test

* fix merge conflicts

* move to 3.0

* move to 3.0

* fix IE11 new URL issue

* fix IE11 new URL issue

* fix IE11 new URL issue

* https for 3.0

* add https test

* add ccp and schain features

* fix test

* sync with upstream, fix conflicts

* Update colossussspBidAdapter.js

remove commented code

* Update colossussspBidAdapter.js

lint fix

* identity extensions

* identity extensions

* fix

* fix

* fix

* fix

* fix

* add tests for user ids

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* add gdpr support

* add gdpr support

* id5id support

* Update colossussspBidAdapter.js

add bidfloor parameter

* Update colossussspBidAdapter.js

check bidfloor

* Update colossussspBidAdapter.js

* Update colossussspBidAdapter.js

* Update colossussspBidAdapter.js

* Update colossussspBidAdapter_spec.js

* use floor module

* Revert "use floor module"

This reverts commit f0c5c24.

* use floor module

* update to 5v

* fix

Co-authored-by: Vladislav Isaiko <[email protected]>
Co-authored-by: Aiholkin <[email protected]>
Co-authored-by: Mykhailo Yaremchuk <[email protected]>
  • Loading branch information
4 people authored Aug 3, 2021
1 parent 72eacfa commit 9eed220
Show file tree
Hide file tree
Showing 3 changed files with 380 additions and 15 deletions.
176 changes: 176 additions & 0 deletions modules/colossussspBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import * as utils from '../src/utils.js';

const BIDDER_CODE = 'colossusssp';
const G_URL = 'https://colossusssp.com/?c=o&m=multi';
const G_URL_SYNC = 'https://colossusssp.com/?c=o&m=cookie';

function isBidResponseValid(bid) {
if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) {
return false;
}

switch (bid.mediaType) {
case BANNER:
return Boolean(bid.width && bid.height && bid.ad);
case VIDEO:
return Boolean(bid.vastUrl);
case NATIVE:
return Boolean(bid.native);
default:
return false;
}
}

function getUserId(eids, id, source, uidExt) {
if (id) {
var uid = { id };
if (uidExt) {
uid.ext = uidExt;
}
eids.push({
source,
uids: [ uid ]
});
}
}

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
/**
* Determines whether or not the given bid request is valid.
*
* @param {object} bid The bid to validate.
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: (bid) => {
return Boolean(bid.bidId && bid.params && !isNaN(bid.params.placement_id));
},

/**
* Make a server request from the list of BidRequests.
*
* @param {BidRequest[]} validBidRequests A non-empty list of valid bid requests that should be sent to the Server.
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: (validBidRequests, bidderRequest) => {
const winTop = utils.getWindowTop();
const location = winTop.location;
let placements = [];
let request = {
'deviceWidth': winTop.screen.width,
'deviceHeight': winTop.screen.height,
'language': (navigator && navigator.language) ? navigator.language : '',
'secure': location.protocol === 'https:' ? 1 : 0,
'host': location.host,
'page': location.pathname,
'placements': placements,
};

if (bidderRequest) {
if (bidderRequest.uspConsent) {
request.ccpa = bidderRequest.uspConsent;
}
if (bidderRequest.gdprConsent) {
request.gdpr_consent = bidderRequest.gdprConsent.consentString || 'ALL'
request.gdpr_require = bidderRequest.gdprConsent.gdprApplies ? 1 : 0
}
}

for (let i = 0; i < validBidRequests.length; i++) {
let bid = validBidRequests[i];
let traff = bid.params.traffic || BANNER
let placement = {
placementId: bid.params.placement_id,
bidId: bid.bidId,
sizes: bid.mediaTypes[traff].sizes,
traffic: traff,
eids: [],
floor: {}
};
if (typeof bid.getFloor === 'function') {
let tmpFloor = {};
for (let size of placement.sizes) {
tmpFloor = bid.getFloor({
currency: 'USD',
mediaType: traff,
size: size
});
if (tmpFloor) {
placement.floor[`${size[0]}x${size[1]}`] = tmpFloor.floor;
}
}
}
if (bid.schain) {
placement.schain = bid.schain;
}
if (bid.userId) {
getUserId(placement.eids, bid.userId.britepoolid, 'britepool.com');
getUserId(placement.eids, bid.userId.idl_env, 'identityLink');
getUserId(placement.eids, bid.userId.id5id, 'id5-sync.com')
getUserId(placement.eids, bid.userId.tdid, 'adserver.org', {
rtiPartner: 'TDID'
});
}
if (traff === VIDEO) {
placement.playerSize = bid.mediaTypes[VIDEO].playerSize;
placement.minduration = bid.mediaTypes[VIDEO].minduration;
placement.maxduration = bid.mediaTypes[VIDEO].maxduration;
placement.mimes = bid.mediaTypes[VIDEO].mimes;
placement.protocols = bid.mediaTypes[VIDEO].protocols;
placement.startdelay = bid.mediaTypes[VIDEO].startdelay;
placement.placement = bid.mediaTypes[VIDEO].placement;
placement.skip = bid.mediaTypes[VIDEO].skip;
placement.skipafter = bid.mediaTypes[VIDEO].skipafter;
placement.minbitrate = bid.mediaTypes[VIDEO].minbitrate;
placement.maxbitrate = bid.mediaTypes[VIDEO].maxbitrate;
placement.delivery = bid.mediaTypes[VIDEO].delivery;
placement.playbackmethod = bid.mediaTypes[VIDEO].playbackmethod;
placement.api = bid.mediaTypes[VIDEO].api;
placement.linearity = bid.mediaTypes[VIDEO].linearity;
}
placements.push(placement);
}
return {
method: 'POST',
url: G_URL,
data: request
};
},

/**
* Unpack the response from the server into a list of bids.
*
* @param {*} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: (serverResponse) => {
let response = [];
try {
serverResponse = serverResponse.body;
for (let i = 0; i < serverResponse.length; i++) {
let resItem = serverResponse[i];
if (isBidResponseValid(resItem)) {
const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : [];
resItem.meta = { ...resItem.meta, advertiserDomains };

response.push(resItem);
}
}
} catch (e) {
utils.logMessage(e);
};
return response;
},

getUserSyncs: () => {
return [{
type: 'image',
url: G_URL_SYNC
}];
}
};

registerBidder(spec);
29 changes: 14 additions & 15 deletions modules/colossussspBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ Module that connects to Colossus SSP demand sources
# Test Parameters
```
var adUnits = [{
code: 'placementid_0',
mediaTypes: {
banner: {
sizes: [[300, 250], [300,600]]
}
},
bids: [{
bidder: 'colossusssp',
params: {
placement_id: 0,
traffic: 'banner'
}
}]
}
];
code: 'placementid_0',
mediaTypes: {
banner: {
sizes: [[300, 250], [300,600]]
}
},
bids: [{
bidder: 'colossusssp',
params: {
placement_id: 0,
traffic: 'banner'
}
}]
];
```
Loading

0 comments on commit 9eed220

Please sign in to comment.