Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 0325151

Browse files
Big-Richmedia Bid Adapter: initial release (prebid#8033)
* feature: add Hubvisor richmedia adapter * feature(hubvisor-bid-adapter): fix lint error * feature: Replay support for Hubvisor richmedia adapter * feature: do not need size 1800x1000 for skin * feature: rename hbvRichmediaAdapter to bigRichmediaAdapter (#7) * feature: add tests and documentation (#8) * Richmedia adapter : rename files (#9) Co-authored-by: Julie <[email protected]> Co-authored-by: JulieLorin <[email protected]>
1 parent 7fd9569 commit 0325151

File tree

3 files changed

+509
-0
lines changed

3 files changed

+509
-0
lines changed

modules/big-richmediaBidAdapter.js

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import {BANNER, VIDEO} from '../src/mediaTypes.js';
2+
import {config} from '../src/config.js';
3+
import {registerBidder} from '../src/adapters/bidderFactory.js';
4+
import {spec as baseAdapter} from './appnexusBidAdapter.js'; // eslint-disable-line prebid/validate-imports
5+
6+
const BIDDER_CODE = 'big-richmedia';
7+
8+
const metadataByRequestId = {};
9+
10+
export const spec = {
11+
version: '1.4.0',
12+
code: BIDDER_CODE,
13+
gvlid: baseAdapter.GVLID, // use base adapter gvlid
14+
supportedMediaTypes: [ BANNER, VIDEO ],
15+
16+
/**
17+
* Determines whether or not the given bid request is valid.
18+
*
19+
* @param {object} bid The bid to validate.
20+
* @return boolean True if this is a valid bid, and false otherwise.
21+
*/
22+
isBidRequestValid: function (bid) {
23+
if (!baseAdapter.isBidRequestValid) { return true; }
24+
return baseAdapter.isBidRequestValid(bid);
25+
},
26+
27+
/**
28+
* Make a server request from the list of BidRequests.
29+
*
30+
* @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server.
31+
* @return ServerRequest Info describing the request to the server.
32+
*/
33+
buildRequests: function (bidRequests, bidderRequest) {
34+
if (!baseAdapter.buildRequests) { return []; }
35+
36+
const publisherId = config.getConfig('bigRichmedia.publisherId');
37+
if (typeof publisherId !== 'string') { return []; }
38+
39+
bidRequests.forEach(bidRequest => {
40+
if (bidRequest.params.format === 'skin' && bidRequest.mediaTypes.banner) {
41+
bidRequest.mediaTypes.banner.sizes.push([1800, 1000]);
42+
}
43+
metadataByRequestId[bidRequest.bidId] = { placementId: bidRequest.adUnitCode, bidder: bidRequest.bidder };
44+
});
45+
return baseAdapter.buildRequests(bidRequests, bidderRequest);
46+
},
47+
48+
/**
49+
* Unpack the response from the server into a list of bids.
50+
*
51+
* @param {*} serverResponse A successful response from the server.
52+
* @return {Bid[]} An array of bids which were nested inside the server.
53+
*/
54+
interpretResponse: function (serverResponse, params) {
55+
const publisherId = config.getConfig('bigRichmedia.publisherId');
56+
if (typeof publisherId !== 'string') { return []; }
57+
58+
const bids = baseAdapter.interpretResponse(serverResponse, params);
59+
bids.forEach(bid => {
60+
const { placementId, bidder } = metadataByRequestId[bid.requestId] || {};
61+
const { width = 1, height = 1, ad, creativeId = '', cpm, vastXml, vastUrl } = bid;
62+
const bidRequest = params.bidderRequest.bids.find(({ bidId }) => bidId === bid.requestId);
63+
const format = (bidRequest && bidRequest.params && bidRequest.params.format) || 'video-sticky-footer';
64+
const isReplayable = bidRequest && bidRequest.params && bidRequest.params.isReplayable;
65+
const customSelector = bidRequest && bidRequest.params && bidRequest.params.customSelector;
66+
const renderParams = {
67+
adm: ad,
68+
vastXml,
69+
vastUrl,
70+
width,
71+
height,
72+
placementId,
73+
bidId: bid.requestId,
74+
creativeId: `${creativeId}`,
75+
bidder,
76+
cpm,
77+
format,
78+
customSelector,
79+
isReplayable
80+
};
81+
const encoded = window.btoa(JSON.stringify(renderParams));
82+
bid.ad = `<script src="//cdn.hubvisor.io/wrapper/${publisherId}/richmedia-renderer.js" async="true"></script>
83+
<script>var hbvrm = hbvrm || {}; hbvrm.cmd = hbvrm.cmd || []; hbvrm.cmd.push(function() { hbvrm.render('${encoded}'); });</script>`;
84+
85+
if (bid.mediaType !== 'banner') { // in case this is a video
86+
bid.mediaType = 'banner';
87+
delete bid.renderer;
88+
delete bid.vastUrl;
89+
delete bid.vastXml;
90+
bid.width = 1;
91+
bid.height = 1;
92+
}
93+
});
94+
return bids;
95+
},
96+
97+
getUserSyncs: function (syncOptions, responses, gdprConsent) {
98+
if (!baseAdapter.getUserSyncs) { return []; }
99+
return baseAdapter.getUserSyncs(syncOptions, responses, gdprConsent);
100+
},
101+
102+
transformBidParams: function (params, isOpenRtb) {
103+
if (!baseAdapter.transformBidParams) { return params; }
104+
return baseAdapter.transformBidParams(params, isOpenRtb);
105+
},
106+
107+
/**
108+
* Add element selector to javascript tracker to improve native viewability
109+
* @param {Bid} bid
110+
*/
111+
onBidWon: function (bid) {
112+
if (!baseAdapter.onBidWon) { return; }
113+
baseAdapter.onBidWon(bid);
114+
}
115+
}
116+
117+
registerBidder(spec);

modules/big-richmediaBidAdapter.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Overview
2+
3+
```
4+
Module Name: BI.Garage Rich Media
5+
Module Type: Bidder Adapter
6+
Maintainer: [email protected]
7+
```
8+
9+
# Description
10+
11+
Module which renders richmedia demand from a Xandr seat
12+
13+
### Global configuration
14+
15+
```javascript
16+
pbjs.setConfig({
17+
debug: false,
18+
// …,
19+
bigRichmedia: {
20+
publisherId: 'A7FN99NZ98F5ZD4G', // Required
21+
},
22+
});
23+
```
24+
25+
# AdUnit Configuration
26+
```javascript
27+
var adUnits = [
28+
// Skin adUnit
29+
{
30+
code: 'banner-div',
31+
mediaTypes: {
32+
banner: {
33+
sizes: [[300, 250], [300,600]]
34+
}
35+
},
36+
bids: [{
37+
bidder: 'big-richmedia',
38+
params: {
39+
placementId: 12345,
40+
format: 'skin' // This will automatically add 1800x1000 size to banner mediaType
41+
}
42+
}]
43+
},
44+
// Video outstream adUnit
45+
{
46+
code: 'video-outstream',
47+
sizes: [[300, 250]],
48+
mediaTypes: {
49+
video: {
50+
playerSize: [[300, 250]],
51+
context: 'outstream',
52+
// Certain ORTB 2.5 video values can be read from the mediatypes object; below are examples of supported params.
53+
// To note - appnexus supports additional values for our system that are not part of the ORTB spec. If you want
54+
// to use these values, they will have to be declared in the bids[].params.video object instead using the appnexus syntax.
55+
// Between the corresponding values of the mediaTypes.video and params.video objects, the properties in params.video will
56+
// take precedence if declared; eg in the example below, the `skippable: true` setting will be used instead of the `skip: 0`.
57+
minduration: 1,
58+
maxduration: 60,
59+
skip: 0, // 1 - true, 0 - false
60+
skipafter: 5,
61+
playbackmethod: [2], // note - we only support options 1-4 at this time
62+
api: [1,2,3] // note - option 6 is not supported at this time
63+
}
64+
},
65+
bids: [
66+
{
67+
bidder: 'big-richmedia',
68+
params: {
69+
placementId: 12345,
70+
video: {
71+
skippable: true,
72+
playback_method: 'auto_play_sound_off'
73+
},
74+
format: 'video-sticky-footer', // or 'video-sticky-top'
75+
isReplayable: true // Default to false - choose if the video should be replayable or not.
76+
customSelector: '#nav-bar' // custom selector for navbar
77+
}
78+
}
79+
]
80+
}
81+
];
82+
```

0 commit comments

Comments
 (0)