Skip to content
This repository was archived by the owner on Feb 13, 2021. It is now read-only.

Commit 7d32ed1

Browse files
committed
Merge pull request prebid#72 in AOLP_ADS_JS/prebid.js from feature/Prebid-official-0.18.0 to release/1.13.0
* commit 'e145489bc5dd6d292cf16e7fe80adfdf991562ac': (27 commits) Add changelog entry. Prebid 0.18.0 Release Add Criteo adapter (prebid#928) add an event that fires when requestBids is called (prebid#939) Xaxis adapter submitted by Daniel hoffmann (prebid#938) Add flash detection to TripleLift adapter (prebid#855) OpenX Adapter: Fixed bug regarding cross-domain iframe support (prebid#931) Emit event when setTargetingForGPTAsync is called (prebid#873) Maintenance/refactor hb deal (prebid#935) Reset hb_* keys only for registered aduniits (prebid#934) update code style - smartyads adapter Catch errors in bidsBackHandler. Also fix test cleanup in pbjs api spec. (prebid#905) Smartyads Adapter (prebid#895) Appnexus targeting function (prebid#920) There are 2 changes- (prebid#913) Adding support for all AST parameters (prebid#923) GumGum adapter - include the bid timeout as `tmax` (prebid#908) Add pixel size (prebid#892) enable postMessage listener for cross-domain iframe support (prebid#885) Add Sharethrough adapter (prebid#865) ...
2 parents a8df144 + e145489 commit 7d32ed1

38 files changed

+2685
-351
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
Thank you for your pull request. Please make sure this PR is scoped to one change, and that any added or changed code includes tests with greater than 80% code coverage. See http://prebid.org/dev-docs/testing-prebid.html for documentation on testing Prebid.js.
2+
Thank you for your pull request. Please make sure this PR is scoped to one change, and that any added or changed code includes tests with greater than 80% code coverage. See https://github.com/prebid/Prebid.js/blob/master/CONTRIBUTING.md#testing-prebidjs for documentation on testing Prebid.js.
33
-->
44

55
## Type of change

.jshintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"sinon": false,
3434
"beforeEach": false,
3535
"afterEach": false,
36-
"JSON": true
36+
"JSON": true,
37+
"Criteo": true
3738
}
3839
}

CHANGELOG

+6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
AOL Prebid 1.13.0
2+
----------------
3+
Updated to Prebid 0.18.0
4+
5+
16
AOL Prebid 1.12.0
27
----------------
38
Updated to Prebid 0.17.0
49

10+
511
AOL Prebid 1.11.0
612
----------------
713
Added functionality of cookie syncing upon bid response.

CONTRIBUTING.md

+82-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,91 @@
11
# Contributing to Prebid.js
2-
Thank you for taking the time to contribute to Prebid.js!
2+
Contributions are always welcome. To contribute, [fork](https://help.github.com/articles/fork-a-repo/) Prebid.js, commit your changes, and [open a pull request](https://help.github.com/articles/using-pull-requests/).
33

44
## Pull Requests
5-
Please make sure that pull requests are scoped to one change, and that any added or changed code includes tests with greater than 80% code coverage. See [Testing Prebid.js](http://prebid.org/dev-docs/testing-prebid.html) for help on writing tests.
5+
Please make sure that pull requests are scoped to one change, and that any added or changed code includes tests with greater than 80% code coverage. See [Testing Prebid.js](#testing-prebidjs) for help on writing tests.
66

77
## Issues
88
[prebid.org](http://prebid.org/) contains documentation that may help answer questions you have about using Prebid.js. If you can't find the answer there, try searching for a similar issue on the [issues page](https://github.com/prebid/Prebid.js/issues). If you don't find an answer there, [open a new issue](https://github.com/prebid/Prebid.js/issues/new).
99

1010
## Documentation
1111
If you have a documentation issue or pull request, please open a ticket or PR in the [documentation repository](https://github.com/prebid/prebid.github.io).
12+
13+
## Testing Prebid.js
14+
Pull requests to the Prebid.js library will need to include tests with greater than 80% code coverage for any changed/added code before they can be merged into master.
15+
16+
This section describes how to test code in the Prebid.js repository to help prepare your pull request.
17+
18+
### Writing tests
19+
When you are adding code to Prebid.js, or modifying code that isn't covered by an existing test, test the code according to these guidelines:
20+
21+
- If the module you are working on is already partially tested by a file within the `test` directory, add tests to that file
22+
- If the module does not have any tests, create a new test file
23+
- Group tests in a `describe` block
24+
- Test individual units of code within an `it` block
25+
- Within an `it` block, it may be helpful to use the "Arrange-Act-Assert" pattern
26+
- _Arrange_: set up necessary preconditions and inputs
27+
- e.g., creating objects, spies, etc.
28+
- _Act_: call or act on the unit under test
29+
- e.g., call the function you are testing with the parameters you set up
30+
- _Assert_: check that the expected results have occurred
31+
- e.g., use Chai assertions to check that the expected output is equal to the actual output
32+
- Test the public interface, not the internal implementation
33+
- If using global `pbjs` data structures in your test, take care to not completely overwrite them with your own data as that may affect other tests relying on those structures, e.g.:
34+
- **OK**: `pbjs._bidsRequested.push(bidderRequestObject);`
35+
- **NOT OK**: `pbjs._bidsRequested = [bidderRequestObject];`
36+
- If you need to check `adloader.loadScript` in a test, use a `stub` rather than a `spy`. `spy`s trigger a network call which can result in a `script error` and cause unrelated unit tests to fail. `stub`s will let you gather information about the `adloader.loadScript` call without affecting external resources
37+
- When writing tests you may use ES2015 syntax if desired
38+
39+
### Running tests
40+
After checking out the Prebid.js repository and installing dev dependencies with `npm install`, use the following commands to run tests as you are working on code:
41+
42+
- `gulp test` will run the test suite once (`npm test` is aliased to call `gulp test`)
43+
- `gulp serve` will run tests once and stay open, re-running tests whenever a file in the `src` or `test` directory is modified
44+
45+
### Checking results and code coverage
46+
Check the test results using these guidelines:
47+
48+
- Look at the total number of tests run, passed, and failed in the shell window.
49+
- If all tests are passing, great.
50+
- Otherwise look for errors printed in the console for a description of the failing test.
51+
- You may need to iterate on your code or tests until all tests are passing.
52+
- Make sure existing tests still pass.
53+
- There is a table below the testing report that shows code coverage percentage, for each file under the `src` directory.
54+
- Each time you run tests, a code coverage report is generated in `build/coverage/lcov/lcov-report/index.html`.
55+
- This is a static HTML page that you can load in your browser.
56+
- On that page, navigate to the file you are testing to see which lines are being tested.
57+
- Red indicates that a line isn't covered by a test.
58+
- Gray indicates a line that doesn't need coverage, such as a comment or blank line.
59+
- Green indicates a line that is covered by tests.
60+
- The code you have added or modified must have greater than 80% coverage to be accepted.
61+
62+
### Examples
63+
Prebid.js already has lots of tests. Read them to see how Prebid.js is tested, and for inspiration:
64+
65+
- Look in `test/spec` and its subdirectories
66+
- Tests for bidder adaptors are located in `test/spec/adapters`
67+
68+
A test module might have the following general structure:
69+
70+
```JavaScript
71+
// import or require modules necessary for the test, e.g.:
72+
import { expect } from 'chai'; // may prefer 'assert' in place of 'expect'
73+
import adapter from 'src/adapters/<adapter>';
74+
75+
describe('<Adapter>', () => {
76+
it('<description of unit or feature being tested>', () => {
77+
// Arrange - set up preconditions and inputs
78+
// Act - call or act on the code under test
79+
// Assert - use chai to check that expected results have occurred
80+
});
81+
82+
// Add other `describe` or `it` blocks as necessary
83+
});
84+
```
85+
86+
### Resources
87+
The Prebid.js testing stack contains some of the following tools. It may be helpful to consult their documentation during the testing process.
88+
89+
- [Mocha - test framework](http://mochajs.org/)
90+
- [Chai - BDD/TDD assertion library](http://chaijs.com/)
91+
- [Sinon - spy, stub, and mock library](http://sinonjs.org/)

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ If you experience errors after a version update, try a fresh install:
6464

6565
<a name="Build"></a>
6666

67-
## Build
67+
## Build for Dev
6868

6969
To build the project on your local machine, run:
7070

71-
$ gulp build
71+
$ gulp serve
7272

73-
This runs some code quality checks and generates the following files:
73+
This runs some code quality checks, starts a web server at `http://localhost:9999` serving from the project root and generates the following files:
7474

7575
+ `./build/dev/prebid.js` - Full source code for dev and debug
7676
+ `./build/dev/prebid.js.map` - Source map for dev and debug
@@ -124,7 +124,7 @@ Having said that, you are probably safe to check your custom bundle into your pr
124124

125125
<a name="Run"></a>
126126

127-
## Run
127+
## Test locally
128128

129129
To configure Prebid.js to run locally, edit the example file `./integrationExamples/gpt/pbjs_example_gpt.html`:
130130

adapters.json

+11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"pulsepoint",
2525
"rhythmone",
2626
"rubicon",
27+
"smartyads",
28+
"smartadserver",
29+
"sekindoUM",
2730
"sonobi",
2831
"sovrn",
2932
"springserve",
@@ -35,7 +38,10 @@
3538
"jcm",
3639
"underdogmedia",
3740
"memeglobal",
41+
"criteo",
3842
"centro",
43+
"xhb",
44+
"sharethrough",
3945
"roxot",
4046
"vertoz",
4147
"widespace",
@@ -68,6 +74,11 @@
6874
"appnexus": {
6975
"alias": "featureforward"
7076
}
77+
},
78+
{
79+
"adkernel": {
80+
"alias": "headbidding"
81+
}
7182
}
7283

7384
]

integrationExamples/gpt/pbjs_example_gpt.html

+13-8
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,12 @@
192192
impid: 36
193193
}
194194
},
195-
{
196-
bidder: 'sekindo',
197-
params: {
198-
spaceId: 14071, // REQUIRED int. To get one, contact http://www.sekindo.com
199-
bidfloor: 0.2 // OPTIONAL float bid floor in $ CPM
200-
}
201-
},
195+
{
196+
bidder: 'sekindoUM',
197+
params: {
198+
spaceId: 14071 // REQUIRED int. To get one, contact http://www.sekindo.com
199+
}
200+
},
202201
{
203202
bidder: 'memeglobal',
204203
params: {
@@ -226,11 +225,17 @@
226225
}
227226
},
228227
{
229-
bidder: 'widespace',
228+
bidder: 'widespace',
230229
params: {
231230
sid: '7b6589bf-95c8-4656-90b9-af9737bb9ad3',
232231
cur: 'EUR'
233232
}
233+
},
234+
{
235+
bidder: 'smartyads',
236+
params: {
237+
banner_id: 0
238+
}
234239
}
235240
]
236241
}, {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// this script can be returned by an ad server delivering a cross domain iframe, into which the
2+
// creative will be rendered, e.g. DFP delivering a SafeFrame
3+
4+
// set these domains as fits your environment and ensure matching protocols
5+
// alternatively this can be passed as a macro on the query string of the ad server call, for
6+
// example `%%PUBLISHER_DOMAIN%%`.
7+
const publisherDomain = 'http://localhost:9999';
8+
const adServerDomain = 'http://tpc.googlesyndication.com';
9+
10+
function renderAd(ev) {
11+
var key = ev.message ? 'message' : 'data';
12+
var adObject = {};
13+
try {
14+
adObject = JSON.parse(ev[key]);
15+
} catch (e) {
16+
return;
17+
}
18+
19+
if (adObject.ad || adObject.adUrl) {
20+
var doc = window.document;
21+
var ad = adObject.ad;
22+
var url = adObject.adUrl;
23+
var width = adObject.width;
24+
var height = adObject.height;
25+
26+
if (adObject.mediaType === 'video') {
27+
console.log('Error trying to write ad.');
28+
} else
29+
30+
if (ad) {
31+
doc.write(ad);
32+
doc.close();
33+
} else if (url) {
34+
doc.write('<IFRAME SRC="' + url + '" FRAMEBORDER="0" SCROLLING="no" MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" LEFTMARGIN="0" ALLOWTRANSPARENCY="true" WIDTH="' + width + '" HEIGHT="' + height + '"></IFRAME>');
35+
doc.close();
36+
} else {
37+
console.log('Error trying to write ad. No ad for bid response id: ' + id);
38+
}
39+
}
40+
}
41+
42+
function requestAdFromPrebid() {
43+
var message = JSON.stringify({
44+
message: 'Prebid Request',
45+
adId: '%%PATTERN:hb_adid%%',
46+
adServerDomain
47+
});
48+
window.parent.postMessage(message, publisherDomain);
49+
}
50+
51+
function listenAdFromPrebid() {
52+
window.addEventListener('message', renderAd, false);
53+
}
54+
55+
listenAdFromPrebid();
56+
requestAdFromPrebid();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "prebid.js",
3-
"version": "0.17.0",
3+
"version": "0.18.0",
44
"description": "Header Bidding Management Library",
55
"main": "src/prebid.js",
66
"scripts": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import adapter from 'AnalyticsAdapter';
2+
const utils = require('../../utils');
3+
4+
const emptyUrl = '';
5+
const analyticsType = 'endpoint';
6+
const STR_BIDDER_CODE = "sharethrough";
7+
const STR_VERSION = "0.1.0";
8+
9+
export default utils.extend(adapter(
10+
{
11+
emptyUrl,
12+
analyticsType
13+
}
14+
),
15+
{
16+
STR_BEACON_HOST: document.location.protocol + "//b.sharethrough.com/butler?",
17+
placementCodeSet: {},
18+
19+
track({ eventType, args }) {
20+
if(eventType === 'bidRequested' && args.bidderCode === 'sharethrough') {
21+
var bids = args.bids;
22+
var keys = Object.keys(bids);
23+
for(var i = 0; i < keys.length; i++) {
24+
this.placementCodeSet[bids[keys[i]].placementCode] = args.bids[keys[i]];
25+
}
26+
}
27+
28+
if(eventType === 'bidWon') {
29+
this.bidWon(args);
30+
}
31+
},
32+
33+
bidWon(args) {
34+
const curBidderCode = args.bidderCode;
35+
36+
if(curBidderCode !== STR_BIDDER_CODE && (args.adUnitCode in this.placementCodeSet)) {
37+
let strBid = this.placementCodeSet[args.adUnitCode];
38+
this.fireLoseBeacon(curBidderCode, args.cpm, strBid.adserverRequestId, "headerBidLose");
39+
}
40+
},
41+
42+
fireLoseBeacon(winningBidderCode, winningCPM, arid, type) {
43+
let loseBeaconUrl = this.STR_BEACON_HOST;
44+
loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, "winnerBidderCode", winningBidderCode);
45+
loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, "winnerCpm", winningCPM);
46+
loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, "arid", arid);
47+
loseBeaconUrl = utils.tryAppendQueryString(loseBeaconUrl, "type", type);
48+
loseBeaconUrl = this.appendEnvFields(loseBeaconUrl);
49+
50+
this.fireBeacon(loseBeaconUrl);
51+
},
52+
appendEnvFields(url) {
53+
url = utils.tryAppendQueryString(url, 'hbVersion', '$prebid.version$');
54+
url = utils.tryAppendQueryString(url, 'strVersion', STR_VERSION);
55+
url = utils.tryAppendQueryString(url, 'hbSource', 'prebid');
56+
57+
return url;
58+
},
59+
fireBeacon(theUrl) {
60+
const img = new Image();
61+
img.src = theUrl;
62+
}
63+
});

0 commit comments

Comments
 (0)