Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A4G prebid adapter #1650

Closed
wants to merge 96 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
58ff158
Add A4G prebid adapter
kononenko-a-m May 23, 2017
36da477
Changed a4gBidFactory
adilets Oct 2, 2017
a32ac6c
Code refactoring
adilets Oct 3, 2017
5e6705a
Code refactoring
adilets Oct 3, 2017
6eff99d
Code refactoring to Prebid.js 1.0
adilets Oct 3, 2017
b2da81d
http -> https (#1651)
Yann-Pravo Oct 3, 2017
2fd1fd7
Add publisher sub-id support to the Criteo adapter (#1629)
Spark-NF Oct 3, 2017
e508a64
Adxcg analytics adapter (#1599)
adxcgcom Oct 3, 2017
3ef99d0
Add placementId request param to Yieldmo bid adapter (#1632)
cdoher01 Oct 3, 2017
6b6a1fb
fixed PBS cookie syncs (#1637)
harpere Oct 3, 2017
c0a608d
Add ignore-loader to handle .md files (#1646)
thewizarodofoz Oct 3, 2017
684ddf3
Add JSDoc for `pbjs.getAllWinningBids` (#1566)
rmloveland Oct 3, 2017
fed1688
rubicon converted to bidderFactory (#1624)
snapwich Oct 3, 2017
d566700
Revert changes for switch between client side and server side. (#1653)
Oct 3, 2017
aef474d
Support aspect ratio specification for native images (#1634)
matthewlane Oct 3, 2017
219f5f9
Appnexus ast unittest updates (#1654)
jaiminpanchal27 Oct 3, 2017
36f4ba7
PulsePoint Lite adpater changes (#1630)
anand-venkatraman Oct 3, 2017
abb7d45
Add native param support to mediaTypes (#1625)
matthewlane Oct 3, 2017
0ab545e
Prebid 0.30.0 Release
jaiminpanchal27 Oct 3, 2017
0bc0b29
Increment pre version
jaiminpanchal27 Oct 3, 2017
a69ec25
Code refactoring to Prebid.js 1.0
adilets Oct 5, 2017
42282f5
prebidAdapter secure support (#1655)
bretg Oct 6, 2017
6186a2c
Aliasbidder fix (#1652)
jaiminpanchal27 Oct 6, 2017
a9dda35
fixes bug for IE when invalid value passed to parse (#1657)
jaiminpanchal27 Oct 6, 2017
a2db7c4
Remove undefined variable usage (#1662)
matthewlane Oct 6, 2017
731c7e4
Prebid 0.30.1 Release
jaiminpanchal27 Oct 6, 2017
a907a4a
remove bidmanager from rubicon tests (#1671)
snapwich Oct 11, 2017
f40f0e3
no longer attaching gpt slots to adUnits, which breaks utils.cloneJso…
harpere Oct 12, 2017
2988065
Fix adapter tests that hardcoded pbjs. (#1666)
mattpr Oct 13, 2017
2f58bb0
Fix broken AOL mobile endpoint secure bid requests (#1684)
kizzard Oct 13, 2017
fc9cbfb
Update spotx video adapter to set the spotx_ad_key used in DFP (#1614)
npeceniak Oct 13, 2017
4eff79f
PulsePoint Lite adapter - Enabling Sync pixel (#1686)
anand-venkatraman Oct 16, 2017
e1f2d08
Code improvement for trustx adapter (#1673)
PWyrembak Oct 16, 2017
a20c3f8
Change Default Content-Type for POST Requests to 'application/json' (…
Oct 16, 2017
3f8021c
AppnexusAst bidadapter markdown file (#1696)
jaiminpanchal27 Oct 16, 2017
209921c
AppnexusAst adapter: logging error message from endpoint (#1697)
jaiminpanchal27 Oct 16, 2017
5bfcdc4
Add ad units event (#1702)
hhhjort Oct 17, 2017
1ed7fb5
Update JSDoc for `pbjs.enableAnalytics` (#1565)
rmloveland Oct 17, 2017
c89e911
Don't set non-object configurations (#1704)
matthewlane Oct 17, 2017
54edd80
Renaming of "huddledmasses" adapter into colossusssp (#1701)
Oct 17, 2017
9b5b211
Rubicon feature/s2s test module (#1678)
harpere Oct 17, 2017
ac40506
Fixes: Immediate adapter response may end auction (#1690)
jaiminpanchal27 Oct 17, 2017
17115fc
Initial commit for video support for pbs (#1706)
Oct 17, 2017
819f8fc
Support native click tracking (#1691)
matthewlane Oct 17, 2017
d0140eb
Prebid 0.31.0 Release
jaiminpanchal27 Oct 17, 2017
e74ea2a
Fix for #1628 (allowing standard bidCpmAdjustment) (#1645)
dugwood Oct 17, 2017
75f6dc5
Increment pre version
jaiminpanchal27 Oct 17, 2017
89a8ed6
Update AdButler adapter for Prebid v1.0 (#1664)
dharton Oct 18, 2017
bd88352
Update Beachfront adapter for v1.0 (#1675)
jsalis Oct 18, 2017
b721d6f
Update JSDoc to call the module `pbjs` (#1572)
rmloveland Oct 19, 2017
37b218a
realvuBidAdapter (#1571)
tchibirev Oct 20, 2017
a7a73fd
Updating license (#1717)
pdezwart Oct 20, 2017
be21952
Justpremium Adapter bugfix (#1716)
mkalafior Oct 20, 2017
a45387d
Allow more than one placement from one page (#1692)
FeatureForwardDev Oct 23, 2017
505f7f3
fix log message not displaying when referencing missing bidder (#1737)
snapwich Oct 23, 2017
f8bf197
Fix window.top.host cross origin issue when in nested iframes. (#1730)
bansawbanchee Oct 23, 2017
409fbc5
Platform.io Bidder Adapter update. Prebid v1.0. (#1705)
varashellov Oct 23, 2017
755f193
Finished an unfinished comment. (#1749)
dbemiller Oct 23, 2017
8aecd9a
UPDATE to Prebid.js 1.0
adilets Oct 24, 2017
1375602
commit for test
adilets Oct 24, 2017
80c9577
commit for test
adilets Oct 24, 2017
d547e51
Updated to Prebid version 1.0
adilets Oct 24, 2017
450d4ab
Updated to Prebid version 1.0
adilets Oct 24, 2017
923adfb
Update JCM Adapter to 1.0 (#1715)
JCarterGw Oct 24, 2017
19deb8e
add option to run tests in a specific file (#1727)
thewizarodofoz Oct 24, 2017
88af47b
Make response headers available to the specs (#1748)
dbemiller Oct 24, 2017
403a991
Upgrade Audience Network adapter for Prebid 1.0 (#1750)
lovell Oct 26, 2017
32196ae
Fix TypeError condition when bid is empty (#1769)
matthewlane Oct 26, 2017
1b0439f
Validating bid response params (#1738)
jaiminpanchal27 Oct 26, 2017
698c330
nanointeractive bid adapter (#1627)
rade-popovic Oct 26, 2017
15b2798
Fixed the argument type on getUserSyncs. (#1767)
dbemiller Oct 26, 2017
c730f95
Update Improve Digital adapter for Prebid 1.0 (#1728)
jbartek25 Oct 26, 2017
6a0c5ca
Migrating TrustX adapter to 1.0 (#1709)
PWyrembak Oct 26, 2017
caec5c0
Fix test-coverage bug (#1765)
dbemiller Oct 26, 2017
9a6ddc2
Update Conversant adapter to Prebid 1.0 (#1711)
pycnvr Oct 26, 2017
edc2274
Add AdOcean adapter (#1735)
jdrobiecki Oct 26, 2017
d4a1423
updated for prebid 1.0 api (#1722)
ckbo3hrk Oct 26, 2017
ebaec7a
Kargo Adapter for Prebid 1.0 (#1729)
samuelhorwitz Oct 26, 2017
c5d1ecf
Fidelity Media Adapter update. Prebid v1.0 (#1719)
onaydenov Oct 26, 2017
51ffb4e
Upgrade Quantcast adapter for Prebid 1.0 (#1753)
Oct 26, 2017
90c66f2
Update yieldmoBid adapter request url (#1771)
cdoher01 Oct 26, 2017
d5f1cd1
Update adxcg adapter for prebid 1.0 (#1741)
adxcgcom Oct 26, 2017
8e5dedf
Add A4G prebid adapter
kononenko-a-m May 23, 2017
e96a7e5
Changed a4gBidFactory
adilets Oct 2, 2017
2db8f61
Code refactoring
adilets Oct 3, 2017
3dcb12e
Code refactoring
adilets Oct 3, 2017
73e1814
Code refactoring to Prebid.js 1.0
adilets Oct 3, 2017
3937408
Code refactoring to Prebid.js 1.0
adilets Oct 5, 2017
3f47e77
UPDATE to Prebid.js 1.0
adilets Oct 24, 2017
4e36e3a
commit for test
adilets Oct 24, 2017
09b30fe
commit for test
adilets Oct 24, 2017
2b1b1a0
Updated to Prebid version 1.0
adilets Oct 24, 2017
ddca775
Updated to Prebid version 1.0
adilets Oct 24, 2017
67c6733
Updated to Prebid version 1.0
adilets Oct 31, 2017
61f9811
Merge remote-tracking branch 'origin/master'
adilets Oct 31, 2017
638a95d
Updated to Prebid version 1.0
adilets Oct 31, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Upgrade Quantcast adapter for Prebid 1.0 (#1753)
* Add v1.0 adapter skeleton

* Fix a typo in variable name declaration

* Change spec dependencies

* Add new describes for test

* Move URL detechtion inside buildRequests method

* Add necessary cases

* Clean test cases

* Export Quantcast adapter constants

* Implemenent test cases

* Fix wrong ports number

* Correct test cases

* Make string with single quote

* Remove unused statements

* Revert "Remove unused statements"

This reverts commit 459ca31.

* Remove unused statements

* Change string to single quote

* Fix sizes type

* Fix the sizes propty name typo in the spec

* Remove unused method, key value and comments

* Update the spec

* Change code using single quote

* Update the first argument for interpretResponse method and its spec

* Handle undefined Server Response

* Add required params from the server response
  • Loading branch information
Xinyang Li authored and matthewlane committed Oct 26, 2017
commit 51ffb4eaa96a2c82641a9c8f47c3356e3d70dd1e
255 changes: 146 additions & 109 deletions modules/quantcastBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,128 +1,165 @@
const utils = require('src/utils.js');
const bidfactory = require('src/bidfactory.js');
const bidmanager = require('src/bidmanager.js');
const ajax = require('src/ajax.js');
const CONSTANTS = require('src/constants.json');
const adaptermanager = require('src/adaptermanager');
const QUANTCAST_CALLBACK_URL = 'http://global.qc.rtb.quantserve.com:8080/qchb';

var QuantcastAdapter = function QuantcastAdapter() {
const BIDDER_CODE = 'quantcast';

const DEFAULT_BID_FLOOR = 0.0000000001;
let bidRequests = {};

let returnEmptyBid = function(bidId) {
var bidRequested = utils.getBidRequest(bidId);
if (!utils.isEmpty(bidRequested)) {
let bid = bidfactory.createBid(CONSTANTS.STATUS.NO_BID, bidRequested);
bid.bidderCode = BIDDER_CODE;
bidmanager.addBidResponse(bidRequested.placementCode, bid);
import * as utils from 'src/utils';
import { registerBidder } from 'src/adapters/bidderFactory';

const BIDDER_CODE = 'quantcast';
const DEFAULT_BID_FLOOR = 0.0000000001;

export const QUANTCAST_CALLBACK_URL = 'global.qc.rtb.quantserve.com';
export const QUANTCAST_CALLBACK_URL_TEST = 's2s-canary.quantserve.com';
export const QUANTCAST_NET_REVENUE = true;
export const QUANTCAST_TEST_PUBLISHER = 'test-publisher';
export const QUANTCAST_TTL = 4;

/**
* The documentation for Prebid.js Adapter 1.0 can be found at link below,
* http://prebid.org/dev-docs/bidder-adapter-1.html
*/
export const spec = {
code: BIDDER_CODE,

/**
* Verify the `AdUnits.bids` response with `true` for valid request and `false`
* for invalid request.
*
* @param {object} bid
* @return boolean `true` is this is a valid bid, and `false` otherwise
*/
isBidRequestValid(bid) {
if (!bid) {
return false;
}
};

// expose the callback to the global object:
$$PREBID_GLOBAL$$.handleQuantcastCB = function (responseText) {
if (utils.isEmpty(responseText)) {
return;
}
let response = null;
try {
response = JSON.parse(responseText);
} catch (e) {
// Malformed JSON
utils.logError("Malformed JSON received from server - can't do anything here");
return;
}

if (response === null || !response.hasOwnProperty('bids') || utils.isEmpty(response.bids)) {
utils.logError("Sub-optimal JSON received from server - can't do anything here");
return;
if (bid.mediaType === 'video') {
return false;
}

for (let i = 0; i < response.bids.length; i++) {
let seatbid = response.bids[i];
let key = seatbid.placementCode;
var request = bidRequests[key];
if (request === null || request === undefined) {
return returnEmptyBid(seatbid.placementCode);
}
// This line is required since this is the field
// that bidfactory.createBid looks for
request.bidId = request.imp[0].placementCode;
let responseBid = bidfactory.createBid(CONSTANTS.STATUS.GOOD, request);

responseBid.cpm = seatbid.cpm;
responseBid.ad = seatbid.ad;
responseBid.height = seatbid.height;
responseBid.width = seatbid.width;
responseBid.bidderCode = response.bidderCode;
responseBid.requestId = request.requestId;
responseBid.bidderCode = BIDDER_CODE;

bidmanager.addBidResponse(request.bidId, responseBid);
return true;
},

/**
* Make a server request when the page asks Prebid.js for bids from a list of
* `BidRequests`.
*
* @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be send to Quantcast server
* @return ServerRequest information describing the request to the server.
*/
buildRequests(bidRequests) {
const bids = bidRequests || [];

const referrer = utils.getTopWindowUrl();
const loc = utils.getTopWindowLocation();
const domain = loc.hostname;

let publisherTagURL;
let publisherTagURLTest;

// Switch the callback URL to Quantcast Canary Endpoint for testing purpose
// `//` is not used because we have different port setting at our end
switch (window.location.protocol) {
case 'https:':
publisherTagURL = `https://${QUANTCAST_CALLBACK_URL}:8443/qchb`;
publisherTagURLTest = `https://${QUANTCAST_CALLBACK_URL_TEST}:8443/qchb`;
break;
default:
publisherTagURL = `http://${QUANTCAST_CALLBACK_URL}:8080/qchb`;
publisherTagURLTest = `http://${QUANTCAST_CALLBACK_URL_TEST}:8080/qchb`;
}
};

function callBids(params) {
let bids = params.bids || [];
if (bids.length === 0) {
return;
}

let referrer = utils.getTopWindowUrl();
let loc = utils.getTopWindowLocation();
let domain = loc.hostname;
let publisherId = 0;
const bidRequestsList = bids.map(bid => {
const bidSizes = [];

publisherId = '' + bids[0].params.publisherId;
utils._each(bids, function(bid) {
let key = bid.placementCode;
var bidSizes = [];
utils._each(bid.sizes, function (size) {
bid.sizes.forEach(size => {
bidSizes.push({
'width': size[0],
'height': size[1]
width: size[0],
height: size[1]
});
});

bidRequests[key] = bidRequests[key] || {
'publisherId': publisherId,
'requestId': bid.bidId,
'bidId': bid.bidId,
'site': {
'page': loc.href,
'referrer': referrer,
'domain': domain,
// Request Data Format can be found at https://wiki.corp.qc/display/adinf/QCX
const requestData = {
publisherId: bid.params.publisherId,
requestId: bid.bidId,
imp: [
{
banner: {
battr: bid.params.battr,
sizes: bidSizes
},
placementCode: bid.placementCode,
bidFloor: bid.params.bidFloor || DEFAULT_BID_FLOOR
}
],
site: {
page: loc.href,
referrer,
domain
},
'imp': [{

'banner': {
'battr': bid.params.battr,
'sizes': bidSizes,
},
'placementCode': bid.placementCode,
'bidFloor': bid.params.bidFloor || DEFAULT_BID_FLOOR,
}]
bidId: bid.bidId
};
});

utils._each(bidRequests, function (bidRequest) {
ajax.ajax(QUANTCAST_CALLBACK_URL, $$PREBID_GLOBAL$$.handleQuantcastCB, JSON.stringify(bidRequest), {
const data = JSON.stringify(requestData);

const url =
bid.params.publisherId === QUANTCAST_TEST_PUBLISHER
? publisherTagURLTest
: publisherTagURL;

return {
data,
method: 'POST',
withCredentials: true
});
url
};
});
}

// Export the `callBids` function, so that Prebid.js can execute
// this function when the page asks to send out bid requests.
return {
callBids: callBids,
QUANTCAST_CALLBACK_URL: QUANTCAST_CALLBACK_URL
};
};
return bidRequestsList;
},

/**
* Function get called when the browser has received the response from Quantcast server.
* The function parse the response and create a `bidResponse` object containing one/more bids.
* Returns an empty array if no valid bids
*
* Response Data Format can be found at https://wiki.corp.qc/display/adinf/QCX
*
* @param {*} serverResponse A successful response from Quantcast server.
* @return {Bid[]} An array of bids which were nested inside the server.
*
*/
interpretResponse(serverResponse) {
if (serverResponse === undefined) {
utils.logError('Server Response is undefined');
return [];
}

const response = serverResponse['body'];

if (
response === undefined ||
!response.hasOwnProperty('bids') ||
utils.isEmpty(response.bids)
) {
utils.logError('Sub-optimal JSON received from Quantcast server');
return [];
}

adaptermanager.registerBidAdapter(new QuantcastAdapter(), 'quantcast');
const bidResponsesList = response.bids.map(bid => {
const { ad, cpm, width, height, creativeId, currency } = bid;

return {
requestId: response.requestId,
cpm,
width,
height,
ad,
ttl: QUANTCAST_TTL,
creativeId,
netRevenue: QUANTCAST_NET_REVENUE,
currency
};
});

return bidResponsesList;
}
};

module.exports = QuantcastAdapter;
registerBidder(spec);
31 changes: 31 additions & 0 deletions modules/quantcastBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Overview

```
Module Name: Quantcast Bidder Adapter
Module Type: Bidder Adapter
Maintainer: [email protected]
```

# Description

Module that connects to Quantcast demand sources to fetch bids.

# Test Parameters

```js
const adUnits = [{
code: 'banner',
sizes: [
[300, 250]
],
bids: [
{
bidder: 'quantcast',
params: {
publisherId: 'test-publisher', // REQUIRED - Publisher ID provided by Quantcast
battr: [1, 2] // OPTIONAL - Array of blocked creative attributes as per OpenRTB Spec List 5.3
}
}
]
}];
```
Loading
Oops, something went wrong.