Skip to content

Commit 9eed220

Browse files
Bill Newmanvladis-teqblazeAiholkinMykhailo Yaremchuk
authored
Colossus Bid Adapter: add advertiserDomains and video params support (prebid#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]>
1 parent 72eacfa commit 9eed220

File tree

3 files changed

+380
-15
lines changed

3 files changed

+380
-15
lines changed

modules/colossussspBidAdapter.js

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
import { registerBidder } from '../src/adapters/bidderFactory.js';
2+
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
3+
import * as utils from '../src/utils.js';
4+
5+
const BIDDER_CODE = 'colossusssp';
6+
const G_URL = 'https://colossusssp.com/?c=o&m=multi';
7+
const G_URL_SYNC = 'https://colossusssp.com/?c=o&m=cookie';
8+
9+
function isBidResponseValid(bid) {
10+
if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) {
11+
return false;
12+
}
13+
14+
switch (bid.mediaType) {
15+
case BANNER:
16+
return Boolean(bid.width && bid.height && bid.ad);
17+
case VIDEO:
18+
return Boolean(bid.vastUrl);
19+
case NATIVE:
20+
return Boolean(bid.native);
21+
default:
22+
return false;
23+
}
24+
}
25+
26+
function getUserId(eids, id, source, uidExt) {
27+
if (id) {
28+
var uid = { id };
29+
if (uidExt) {
30+
uid.ext = uidExt;
31+
}
32+
eids.push({
33+
source,
34+
uids: [ uid ]
35+
});
36+
}
37+
}
38+
39+
export const spec = {
40+
code: BIDDER_CODE,
41+
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
42+
/**
43+
* Determines whether or not the given bid request is valid.
44+
*
45+
* @param {object} bid The bid to validate.
46+
* @return boolean True if this is a valid bid, and false otherwise.
47+
*/
48+
isBidRequestValid: (bid) => {
49+
return Boolean(bid.bidId && bid.params && !isNaN(bid.params.placement_id));
50+
},
51+
52+
/**
53+
* Make a server request from the list of BidRequests.
54+
*
55+
* @param {BidRequest[]} validBidRequests A non-empty list of valid bid requests that should be sent to the Server.
56+
* @return ServerRequest Info describing the request to the server.
57+
*/
58+
buildRequests: (validBidRequests, bidderRequest) => {
59+
const winTop = utils.getWindowTop();
60+
const location = winTop.location;
61+
let placements = [];
62+
let request = {
63+
'deviceWidth': winTop.screen.width,
64+
'deviceHeight': winTop.screen.height,
65+
'language': (navigator && navigator.language) ? navigator.language : '',
66+
'secure': location.protocol === 'https:' ? 1 : 0,
67+
'host': location.host,
68+
'page': location.pathname,
69+
'placements': placements,
70+
};
71+
72+
if (bidderRequest) {
73+
if (bidderRequest.uspConsent) {
74+
request.ccpa = bidderRequest.uspConsent;
75+
}
76+
if (bidderRequest.gdprConsent) {
77+
request.gdpr_consent = bidderRequest.gdprConsent.consentString || 'ALL'
78+
request.gdpr_require = bidderRequest.gdprConsent.gdprApplies ? 1 : 0
79+
}
80+
}
81+
82+
for (let i = 0; i < validBidRequests.length; i++) {
83+
let bid = validBidRequests[i];
84+
let traff = bid.params.traffic || BANNER
85+
let placement = {
86+
placementId: bid.params.placement_id,
87+
bidId: bid.bidId,
88+
sizes: bid.mediaTypes[traff].sizes,
89+
traffic: traff,
90+
eids: [],
91+
floor: {}
92+
};
93+
if (typeof bid.getFloor === 'function') {
94+
let tmpFloor = {};
95+
for (let size of placement.sizes) {
96+
tmpFloor = bid.getFloor({
97+
currency: 'USD',
98+
mediaType: traff,
99+
size: size
100+
});
101+
if (tmpFloor) {
102+
placement.floor[`${size[0]}x${size[1]}`] = tmpFloor.floor;
103+
}
104+
}
105+
}
106+
if (bid.schain) {
107+
placement.schain = bid.schain;
108+
}
109+
if (bid.userId) {
110+
getUserId(placement.eids, bid.userId.britepoolid, 'britepool.com');
111+
getUserId(placement.eids, bid.userId.idl_env, 'identityLink');
112+
getUserId(placement.eids, bid.userId.id5id, 'id5-sync.com')
113+
getUserId(placement.eids, bid.userId.tdid, 'adserver.org', {
114+
rtiPartner: 'TDID'
115+
});
116+
}
117+
if (traff === VIDEO) {
118+
placement.playerSize = bid.mediaTypes[VIDEO].playerSize;
119+
placement.minduration = bid.mediaTypes[VIDEO].minduration;
120+
placement.maxduration = bid.mediaTypes[VIDEO].maxduration;
121+
placement.mimes = bid.mediaTypes[VIDEO].mimes;
122+
placement.protocols = bid.mediaTypes[VIDEO].protocols;
123+
placement.startdelay = bid.mediaTypes[VIDEO].startdelay;
124+
placement.placement = bid.mediaTypes[VIDEO].placement;
125+
placement.skip = bid.mediaTypes[VIDEO].skip;
126+
placement.skipafter = bid.mediaTypes[VIDEO].skipafter;
127+
placement.minbitrate = bid.mediaTypes[VIDEO].minbitrate;
128+
placement.maxbitrate = bid.mediaTypes[VIDEO].maxbitrate;
129+
placement.delivery = bid.mediaTypes[VIDEO].delivery;
130+
placement.playbackmethod = bid.mediaTypes[VIDEO].playbackmethod;
131+
placement.api = bid.mediaTypes[VIDEO].api;
132+
placement.linearity = bid.mediaTypes[VIDEO].linearity;
133+
}
134+
placements.push(placement);
135+
}
136+
return {
137+
method: 'POST',
138+
url: G_URL,
139+
data: request
140+
};
141+
},
142+
143+
/**
144+
* Unpack the response from the server into a list of bids.
145+
*
146+
* @param {*} serverResponse A successful response from the server.
147+
* @return {Bid[]} An array of bids which were nested inside the server.
148+
*/
149+
interpretResponse: (serverResponse) => {
150+
let response = [];
151+
try {
152+
serverResponse = serverResponse.body;
153+
for (let i = 0; i < serverResponse.length; i++) {
154+
let resItem = serverResponse[i];
155+
if (isBidResponseValid(resItem)) {
156+
const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : [];
157+
resItem.meta = { ...resItem.meta, advertiserDomains };
158+
159+
response.push(resItem);
160+
}
161+
}
162+
} catch (e) {
163+
utils.logMessage(e);
164+
};
165+
return response;
166+
},
167+
168+
getUserSyncs: () => {
169+
return [{
170+
type: 'image',
171+
url: G_URL_SYNC
172+
}];
173+
}
174+
};
175+
176+
registerBidder(spec);

modules/colossussspBidAdapter.md

+14-15
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@ Module that connects to Colossus SSP demand sources
1313
# Test Parameters
1414
```
1515
var adUnits = [{
16-
code: 'placementid_0',
17-
mediaTypes: {
18-
banner: {
19-
sizes: [[300, 250], [300,600]]
20-
}
21-
},
22-
bids: [{
23-
bidder: 'colossusssp',
24-
params: {
25-
placement_id: 0,
26-
traffic: 'banner'
27-
}
28-
}]
29-
}
30-
];
16+
code: 'placementid_0',
17+
mediaTypes: {
18+
banner: {
19+
sizes: [[300, 250], [300,600]]
20+
}
21+
},
22+
bids: [{
23+
bidder: 'colossusssp',
24+
params: {
25+
placement_id: 0,
26+
traffic: 'banner'
27+
}
28+
}]
29+
];
3130
```

0 commit comments

Comments
 (0)