Skip to content

Commit 7904b4f

Browse files
Salomon Radaharpere
Salomon Rada
authored andcommitted
Update gambid aliases (#3410)
* Update the Gamoshi Gambid adapter to simply the Gamoshi adapter This is a minor branding change to highlight the Gamoshi brand name. The biddercode "gambid" is still retained in the adapter aliases array. * update whitelabel * Add test that checks support for outstream renderers * Update testing and page ref * Modify bidder's url resolving * Fix lint issue with bidder's url resolving
1 parent c07e60d commit 7904b4f

File tree

4 files changed

+476
-403
lines changed

4 files changed

+476
-403
lines changed

modules/gambidBidAdapter.js renamed to modules/gamoshiBidAdapter.js

Lines changed: 62 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,70 @@
11
import * as utils from 'src/utils';
2-
import { registerBidder } from 'src/adapters/bidderFactory';
3-
import { config } from 'src/config';
4-
import { Renderer } from '../src/Renderer';
2+
import {registerBidder} from 'src/adapters/bidderFactory';
3+
import {config} from 'src/config';
4+
import {Renderer} from '../src/Renderer';
55

6-
function getTopFrame() {
7-
try {
8-
return window.top === window ? 1 : 0;
9-
} catch (e) {
6+
export const helper = {
7+
8+
getTopFrame: function () {
9+
try {
10+
return window.top === window ? 1 : 0;
11+
} catch (e) {
12+
}
1013
return 0;
11-
}
12-
}
14+
},
1315

14-
function startsWith(str, search) {
15-
return str.substr(0, search.length) === search;
16-
}
16+
startsWith: function (str, search) {
17+
return str.substr(0, search.length) === search;
18+
},
1719

18-
function getTopWindowDomain() {
19-
const url = utils.getTopWindowUrl();
20-
const domainStart = url.indexOf('://') + '://'.length;
21-
return url.substring(domainStart, url.indexOf('/', domainStart) < 0 ? url.length : url.indexOf('/', domainStart));
22-
}
20+
getTopWindowDomain: function (url) {
21+
const domainStart = url.indexOf('://') + '://'.length;
22+
return url.substring(domainStart, url.indexOf('/', domainStart) < 0 ? url.length : url.indexOf('/', domainStart));
23+
},
2324

24-
function getTopWindowReferer() {
25-
try {
26-
return window.top.document.referrer;
27-
} catch (e) {
28-
utils.logMessage('Failed obtaining top window\'s referrer: ', e);
25+
getTopWindowReferer: function () {
2926
try {
30-
return window.document.referrer;
27+
return window.top.document.referrer;
3128
} catch (e) {
32-
utils.logMessage('Failed obtaining current window\'s referrer: ', e);
33-
return '';
29+
utils.logMessage('Failed obtaining top window\'s referrer: ', e);
30+
try {
31+
return window.document.referrer;
32+
} catch (e) {
33+
utils.logMessage('Failed obtaining current window\'s referrer: ', e);
34+
}
3435
}
36+
return '';
3537
}
3638
}
3739

3840
export const spec = {
39-
code: 'gambid',
40-
aliases: [],
41-
supportedMediaTypes: [ 'banner', 'video' ],
41+
code: 'gamoshi',
42+
aliases: ['gambid', 'cleanmedia'],
43+
supportedMediaTypes: ['banner', 'video'],
4244

43-
isBidRequestValid: function(bid) {
45+
isBidRequestValid: function (bid) {
4446
return !!bid.params.supplyPartnerId && typeof bid.params.supplyPartnerId === 'string' &&
45-
(typeof bid.params[ 'rtbEndpoint' ] === 'undefined' || typeof bid.params[ 'rtbEndpoint' ] === 'string') &&
46-
(typeof bid.params.bidfloor === 'undefined' || typeof bid.params.bidfloor === 'number') &&
47-
(typeof bid.params[ 'adpos' ] === 'undefined' || typeof bid.params[ 'adpos' ] === 'number') &&
48-
(typeof bid.params[ 'protocols' ] === 'undefined' || Array.isArray(bid.params[ 'protocols' ])) &&
49-
(typeof bid.params.instl === 'undefined' || bid.params.instl === 0 || bid.params.instl === 1);
47+
(typeof bid.params['rtbEndpoint'] === 'undefined' || typeof bid.params['rtbEndpoint'] === 'string') &&
48+
(typeof bid.params.bidfloor === 'undefined' || typeof bid.params.bidfloor === 'number') &&
49+
(typeof bid.params['adpos'] === 'undefined' || typeof bid.params['adpos'] === 'number') &&
50+
(typeof bid.params['protocols'] === 'undefined' || Array.isArray(bid.params['protocols'])) &&
51+
(typeof bid.params.instl === 'undefined' || bid.params.instl === 0 || bid.params.instl === 1);
5052
},
5153

52-
buildRequests: function(validBidRequests, bidderRequest) {
54+
buildRequests: function (validBidRequests, bidderRequest) {
5355
return validBidRequests.map(bidRequest => {
54-
const { adUnitCode, auctionId, mediaTypes, params, sizes, transactionId } = bidRequest;
55-
const baseEndpoint = params[ 'rtbEndpoint' ] || 'https://rtb.gambid.io';
56+
const {adUnitCode, auctionId, mediaTypes, params, sizes, transactionId} = bidRequest;
57+
const baseEndpoint = params['rtbEndpoint'] || 'https://rtb.gamoshi.io';
5658
const rtbEndpoint = `${baseEndpoint}/r/${params.supplyPartnerId}/bidr?rformat=open_rtb&reqformat=rtb_json&bidder=prebid` + (params.query ? '&' + params.query : '');
59+
let referer = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer;
60+
let url = config.getConfig('pageUrl') || referer || utils.getTopWindowUrl();
61+
5762
const rtbBidRequest = {
5863
'id': auctionId,
5964
'site': {
60-
'domain': getTopWindowDomain(),
61-
'page': config.getConfig('pageUrl') || utils.getTopWindowUrl(),
62-
'ref': getTopWindowReferer()
65+
'domain': helper.getTopWindowDomain(url),
66+
'page': url,
67+
'ref': helper.getTopWindowReferer()
6368
},
6469
'device': {
6570
'ua': navigator.userAgent
@@ -80,33 +85,33 @@ export const spec = {
8085
'tagid': adUnitCode,
8186
'bidfloor': params.bidfloor || 0,
8287
'bidfloorcur': 'USD',
83-
'secure': startsWith(utils.getTopWindowUrl().toLowerCase(), 'http://') ? 0 : 1
88+
'secure': helper.startsWith(utils.getTopWindowUrl().toLowerCase(), 'http://') ? 0 : 1
8489
};
8590

8691
if (!mediaTypes || mediaTypes.banner) {
8792
imp.banner = {
88-
w: sizes.length ? sizes[ 0 ][ 0 ] : 300,
89-
h: sizes.length ? sizes[ 0 ][ 1 ] : 250,
93+
w: sizes.length ? sizes[0][0] : 300,
94+
h: sizes.length ? sizes[0][1] : 250,
9095
pos: params.pos || 0,
91-
topframe: getTopFrame()
96+
topframe: helper.getTopFrame()
9297
};
9398
} else if (mediaTypes.video) {
9499
imp.video = {
95-
w: sizes.length ? sizes[ 0 ][ 0 ] : 300,
96-
h: sizes.length ? sizes[ 0 ][ 1 ] : 250,
100+
w: sizes.length ? sizes[0][0] : 300,
101+
h: sizes.length ? sizes[0][1] : 250,
97102
protocols: params.protocols || [1, 2, 3, 4, 5, 6],
98103
pos: params.pos || 0,
99-
topframe: getTopFrame()
104+
topframe: helper.getTopFrame()
100105
};
101106
} else {
102107
return;
103108
}
104109
rtbBidRequest.imp.push(imp);
105-
return { method: 'POST', url: rtbEndpoint, data: rtbBidRequest, bidRequest };
110+
return {method: 'POST', url: rtbEndpoint, data: rtbBidRequest, bidRequest};
106111
});
107112
},
108113

109-
interpretResponse: function(serverResponse, bidRequest) {
114+
interpretResponse: function (serverResponse, bidRequest) {
110115
const response = serverResponse && serverResponse.body;
111116
if (!response) {
112117
utils.logError('empty response');
@@ -127,7 +132,7 @@ export const spec = {
127132
currency: bid.cur || response.cur
128133
};
129134
if (!bidRequest.bidRequest.mediaTypes || bidRequest.bidRequest.mediaTypes.banner) {
130-
outBids.push(Object.assign({}, outBid, { mediaType: 'banner', ad: bid.adm }));
135+
outBids.push(Object.assign({}, outBid, {mediaType: 'banner', ad: bid.adm}));
131136
} else if (bidRequest.bidRequest.mediaTypes.video) {
132137
const context = utils.deepAccess(bidRequest.bidRequest, 'mediaTypes.video.context');
133138
outBids.push(Object.assign({}, outBid, {
@@ -141,27 +146,27 @@ export const spec = {
141146
return outBids;
142147
},
143148

144-
getUserSyncs: function(syncOptions, serverResponses, gdprConsent) {
149+
getUserSyncs: function (syncOptions, serverResponses, gdprConsent) {
145150
const syncs = [];
146151
const gdprApplies = gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean') ? gdprConsent.gdprApplies : false;
147152
const suffix = gdprApplies ? 'gc=' + encodeURIComponent(gdprConsent.consentString) : 'gc=missing';
148153
serverResponses.forEach(resp => {
149154
if (resp.body) {
150155
const bidResponse = resp.body;
151-
if (bidResponse.ext && Array.isArray(bidResponse.ext[ 'utrk' ])) {
152-
bidResponse.ext[ 'utrk' ].forEach(pixel => {
156+
if (bidResponse.ext && Array.isArray(bidResponse.ext['utrk'])) {
157+
bidResponse.ext['utrk'].forEach(pixel => {
153158
const url = pixel.url + (pixel.url.indexOf('?') > 0 ? '&' + suffix : '?' + suffix);
154-
return syncs.push({ type: pixel.type, url });
159+
return syncs.push({type: pixel.type, url});
155160
});
156161
}
157162
if (Array.isArray(bidResponse.seatbid)) {
158163
bidResponse.seatbid.forEach(seatBid => {
159164
if (Array.isArray(seatBid.bid)) {
160165
seatBid.bid.forEach(bid => {
161-
if (bid.ext && Array.isArray(bid.ext[ 'utrk' ])) {
162-
bid.ext[ 'utrk' ].forEach(pixel => {
166+
if (bid.ext && Array.isArray(bid.ext['utrk'])) {
167+
bid.ext['utrk'].forEach(pixel => {
163168
const url = pixel.url + (pixel.url.indexOf('?') > 0 ? '&' + suffix : '?' + suffix);
164-
return syncs.push({ type: pixel.type, url });
169+
return syncs.push({type: pixel.type, url});
165170
});
166171
}
167172
});

modules/gambidBidAdapter.md renamed to modules/gamoshiBidAdapter.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Overview
22

33
```
4-
Module Name: Gamoshi's Gambid Bid Adapter
4+
Module Name: Gamoshi Bid Adapter
55
Module Type: Bidder Adapter
6-
Maintainer: arik@gamoshi.com
6+
Maintainer: moses@gamoshi.com
77
```
88

99
# Description
1010

11-
Connects to Gamoshi's Gambid platform & exchange for bids.
11+
Connects to Gamoshi's Programmatic advertising platform as a service.
1212

13-
Gambid bid adapter supports Banner & Outstream Video. The *only* required parameter (in the `params` section) is the `supplyPartnerId` parameter.
13+
Gamoshi bid adapter supports Banner & Outstream Video. The *only* required parameter (in the `params` section) is the `supplyPartnerId` parameter.
1414

1515
# Test Parameters
1616
```
@@ -21,10 +21,10 @@ var adUnits = [
2121
code: 'banner-div',
2222
sizes: [[300, 250]],
2323
bids: [{
24-
bidder: 'gambid',
24+
bidder: 'gamoshi',
2525
params: {
2626
27-
// ID of the supply partner you created in the Gambid dashboard
27+
// ID of the supply partner you created in the Gamoshi dashboard
2828
supplyPartnerId: '1253',
2929
3030
// OPTIONAL: if you have a whitelabel account on Gamoshi, specify it here
@@ -55,10 +55,10 @@ var adUnits = [
5555
}
5656
},
5757
bids: [ {
58-
bidder: 'gambid',
58+
bidder: 'gamoshi',
5959
params: {
6060
61-
// ID of the supply partner you created in the Gambid dashboard
61+
// ID of the supply partner you created in the dashboard
6262
supplyPartnerId: '1254',
6363
6464
// OPTIONAL: if you have a whitelabel account on Gamoshi, specify it here

0 commit comments

Comments
 (0)