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
Show file tree
Hide file tree
Changes from 11 commits
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
77 changes: 77 additions & 0 deletions modules/a4gBidAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import {registerBidder} from 'src/adapters/bidderFactory';
import * as utils from 'src/utils';

const A4G_BIDDER_CODE = 'a4g';
const A4G_CURRENCY = 'USD';
const A4G_DEFAULT_BID_URL = '//ads.ad4game.com/v1/bid';
const A4G_TTL = 120;

const LOCATION_PARAM_NAME = 'siteurl';
const ID_PARAM_NAME = 'id';
const ZONE_ID_PARAM_NAME = 'zoneId';
const SIZE_PARAM_NAME = 'size';

const ARRAY_PARAM_SEPARATOR = ';';
const ARRAY_SIZE_SEPARATOR = ',';
const SIZE_SEPARATOR = 'x';

export const spec = {
code: A4G_BIDDER_CODE,
isBidRequestValid: function(bid) {
return bid.params && !!bid.params.zoneId;
},

buildRequests: function(validBidRequests) {
let deliveryUrl = '';
const idParams = [];
const sizeParams = [];
const zoneIds = [];

utils._each(validBidRequests, function(bid) {
if (!deliveryUrl && typeof bid.params.deliveryUrl === 'string') {
deliveryUrl = bid.params.deliveryUrl;
}
idParams.push(bid.adUnitCode);
sizeParams.push(bid.sizes.map(size => size.join(SIZE_SEPARATOR)).join(ARRAY_SIZE_SEPARATOR));
zoneIds.push(bid.params.zoneId);
});

if (!deliveryUrl) {
deliveryUrl = A4G_DEFAULT_BID_URL;
}

return {
method: 'GET',
url: deliveryUrl,
data: {
[LOCATION_PARAM_NAME]: utils.getTopWindowUrl(),
[SIZE_PARAM_NAME]: sizeParams.join(ARRAY_PARAM_SEPARATOR),
[ID_PARAM_NAME]: idParams.join(ARRAY_PARAM_SEPARATOR),
[ZONE_ID_PARAM_NAME]: zoneIds.join(ARRAY_PARAM_SEPARATOR)
}
};
},

interpretResponse: function(serverResponses, request) {
const bidResponses = [];
utils._each(serverResponses, function(response) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1748 changed the first argument of interpretResponse to:

{
  body: responseBody,
  headers: {
    get: function(header) { /* returns a header from the HTTP response */ }
  }
}

so updating serverResponses to serverResponses.body (and in corresponding tests if needed) should do the trick. May need to rebase off of master first

const bidResponse = {
requestId: request.bidId,
bidderCode: spec.code,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bidderCode can be dropped from the bid response object, it'll be set automatically by bidderFactory. Docs just updated, sorry for the confusion

cpm: response.cpm,
width: response.width,
height: response.height,
creativeId: response.zoneid,
currency: A4G_CURRENCY,
netRevenue: true,
ttl: A4G_TTL,
ad: response.ad
};
bidResponses.push(bidResponse);
});

return bidResponses;
}
};

registerBidder(spec);
40 changes: 40 additions & 0 deletions modules/a4gBidAdapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Overview

Module Name: Ad4Game Bidder Adapter
Module Type: Bidder Adapter
Maintainer: [email protected]

# Description

Ad4Game Bidder Adapter for Prebid.js

# Test Parameters
```
var adUnits = [
{
code: 'test-div',
sizes: [[300, 250]], // a display size
bids: [
{
bidder: 'a4g',
params: {
zoneId: 59304,
deliveryUrl: 'http://dev01.ad4game.com/v1/bid'
}
}
]
},{
code: 'test-div',
sizes: [[300, 50]], // a mobile size
bids: [
{
bidder: 'a4g',
params: {
zoneId: 59354,
deliveryUrl: 'http://dev01.ad4game.com/v1/bid'
}
}
]
}
];
```
126 changes: 126 additions & 0 deletions test/spec/modules/a4gBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import { expect} from 'chai';
import { spec } from 'modules/a4gBidAdapter';

describe('a4gAdapterTests', () => {
describe('bidRequestValidity', () => {
it('bidRequest with zoneId and deliveryUrl params', () => {
expect(spec.isBidRequestValid({
bidder: 'a4g',
params: {
zoneId: 59304,
deliveryUrl: 'http://dev01.ad4game.com/v1/bid'
}
})).to.equal(true);
});

it('bidRequest with only zoneId', () => {
expect(spec.isBidRequestValid({
bidder: 'a4g',
params: {
zoneId: 59304
}
})).to.equal(true);
});

it('bidRequest with only deliveryUrl', () => {
expect(spec.isBidRequestValid({
bidder: 'a4g',
params: {
deliveryUrl: 'http://dev01.ad4game.com/v1/bid'
}
})).to.equal(false);
});
});

describe('bidRequest', () => {
const bidRequests = [{
'bidder': 'a4g',
'bidId': '51ef8751f9aead',
'params': {
'zoneId': 59304,
},
'adUnitCode': 'div-gpt-ad-1460505748561-0',
'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec',
'sizes': [[320, 50], [300, 250], [300, 600]],
'bidderRequestId': '418b37f85e772c',
'auctionId': '18fd8b8b0bd757'
}, {
'bidder': 'a4g',
'bidId': '51ef8751f9aead',
'params': {
'zoneId': 59354,
'deliveryUrl': '//dev01.ad4game.com/v1/bid'
},
'adUnitCode': 'div-gpt-ad-1460505748561-0',
'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec',
'sizes': [[320, 50], [300, 250], [300, 600]],
'bidderRequestId': '418b37f85e772c',
'auctionId': '18fd8b8b0bd757'
}];

it('bidRequest method', () => {
const request = spec.buildRequests(bidRequests);
expect(request.method).to.equal('GET');
});

it('bidRequest url', () => {
const request = spec.buildRequests(bidRequests);
expect(request.url).to.match(new RegExp(`${bidRequests[1].params.deliveryUrl}`));
});

it('bidRequest data', () => {
const request = spec.buildRequests(bidRequests);
expect(request.data).to.exists;
});

it('bidRequest zoneIds', () => {
const request = spec.buildRequests(bidRequests);
expect(request.data.zoneId).to.equal('59304;59354');
});
});

describe('interpretResponse', () => {
const bidRequest = [{
'bidder': 'a4g',
'bidId': '51ef8751f9aead',
'params': {
'zoneId': 59304,
},
'adUnitCode': 'div-gpt-ad-1460505748561-0',
'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec',
'sizes': [[320, 50], [300, 250], [300, 600]],
'bidderRequestId': '418b37f85e772c',
'auctionId': '18fd8b8b0bd757'
}];

const bidResponse = [{
'id': 'div-gpt-ad-1460505748561-0',
'ad': 'test ad',
'width': 320,
'height': 250,
'cpm': 5.2
}];

it('required keys', () => {
const result = spec.interpretResponse(bidResponse, bidRequest);

let requiredKeys = [
'requestId',
'bidderCode',
'cpm',
'width',
'height',
'ad',
'ttl',
'creativeId',
'netRevenue',
'currency'
];

let resultKeys = Object.keys(result[0]);
resultKeys.forEach(function(key) {
expect(requiredKeys.indexOf(key) !== -1).to.equal(true);
});
})
});
});
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ d@1:
dependencies:
es5-ext "^0.10.9"

"dargs@github:christian-bromann/dargs":
dargs@christian-bromann/dargs:
version "4.0.1"
resolved "https://codeload.github.com/christian-bromann/dargs/tar.gz/7d6d4164a7c4106dbd14ef39ed8d95b7b5e9b770"
dependencies:
Expand Down