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

Pre-auction filters and pbAdslot support #4539

Merged
merged 68 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
8d635ff
Add microadBidAdapter
Feb 15, 2019
3055b90
Remove unnecessary encodeURIComponent from microadBidAdapter
Feb 26, 2019
67fb91b
Submit Advangelists Prebid Adapter
Feb 26, 2019
3ebb916
Submit Advangelists Prebid Adapter 1.1
Feb 27, 2019
4f5c451
Correct procudtion endpoint for prebid
Feb 28, 2019
2dc6d1d
Merge branch 'microad-bid-adapter' of git://github.com/strong-zero/Pr…
Feb 28, 2019
fa3e081
Merge remote-tracking branch 'origin/master' into master-rubicon-clean
Mar 18, 2019
600a46e
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Mar 18, 2019
7f578b3
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 23, 2019
176a312
Merge branch 'master' of https://github.com/prebid/Prebid.js
Mar 26, 2019
9abf89c
Merge branch 'master' of https://github.com/prebid/Prebid.js
May 13, 2019
6ce04ab
Merge remote-tracking branch 'upstream/master'
Jun 10, 2019
415e2f6
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jun 27, 2019
61fb82c
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 11, 2019
3cc4c67
analytics update with wrapper name
Jul 11, 2019
cd81e02
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
e2b4e04
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
53b5970
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 15, 2019
5c00ed5
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 16, 2019
28848ad
reverted error merge
Jul 16, 2019
ab635ee
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 19, 2019
93308f5
Merge branch 'master' of https://github.com/prebid/Prebid.js into mas…
Jul 24, 2019
1cfd52d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 25, 2019
d619807
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jul 27, 2019
9893f0f
Merge branch 'master' of https://github.com/prebid/Prebid.js
Aug 7, 2019
986a251
Merge remote-tracking branch 'upstream/master'
Aug 23, 2019
2cae7c0
Merge branch 'master' of https://github.com/prebid/Prebid.js into ori…
Aug 27, 2019
d7fd252
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 4, 2019
c7c01ba
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 10, 2019
24a28aa
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 10, 2019
7a1a4ec
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js
Sep 25, 2019
4173d16
Merge branch 'master' of https://github.com/prebid/Prebid.js
Sep 25, 2019
ca13952
update changed default value of netRevenue to true
Sep 27, 2019
0b6cd48
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 3, 2019
5f0110d
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 3, 2019
f930a34
Merge remote-tracking branch 'upstream/master'
Oct 8, 2019
9bff282
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 14, 2019
712ec9e
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 29, 2019
f192f65
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 29, 2019
006f53c
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 29, 2019
0341150
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 31, 2019
fa59897
Merge branch 'master' of https://github.com/prebid/Prebid.js
Nov 15, 2019
dcff2cf
Merge branch 'master' of https://github.com/prebid/Prebid.js
Nov 20, 2019
e4b0344
add beforeRequestBids event
Nov 20, 2019
e52714d
add pbAdSlot support to pbs adapter
Nov 22, 2019
887971a
update jsdoc comment for on before request bids event
Nov 22, 2019
ff646df
add pbAdSlot support to rubicon adapter
Nov 22, 2019
5e4c078
added more tests
Nov 22, 2019
6ca2d59
update code comment
Nov 22, 2019
b97e2b9
add api test, update event to emit from adapterManager
Nov 24, 2019
8a89f4d
add multi-bid api test
Nov 24, 2019
0222ce2
Merge branch 'master' of https://github.com/prebid/Prebid.js
Nov 24, 2019
9e79b0e
Merge branch 'master' of https://github.com/rubicon-project/Prebid.js…
Nov 24, 2019
a6d83ab
Merge branch 'master' of https://github.com/prebid/Prebid.js into add…
Dec 5, 2019
5375b6f
added pbAdSlot to rubicon bid adapter video bid request
Dec 13, 2019
727f517
added ext to server video path in rp adapter pbAdSlot
Dec 13, 2019
3abfe1a
fix for pb video ortb path
Dec 13, 2019
0c1b352
fix for consistency with pb server
Dec 14, 2019
d4e7f21
Merge branch 'master' of https://github.com/prebid/Prebid.js into add…
Jan 6, 2020
c526a58
update obj path to fpd.context.pbAdSlot
Jan 6, 2020
431a8b8
add leading slash removal to all outputs of pbAslot
Jan 13, 2020
eea65d5
Merge branch 'master' of https://github.com/prebid/Prebid.js into add…
Jan 13, 2020
55d6e90
revert to previous branch reviewed
Jan 14, 2020
fe3fa59
revert to previous branch reviewed
Jan 14, 2020
728b7e5
Merge branch 'master' of https://github.com/prebid/Prebid.js into add…
Jan 14, 2020
db6fff9
Merge remote-tracking branch 'origin/add-pbadslot' into add-pbadslot
Jan 14, 2020
65dfb11
Merge branch 'master' of https://github.com/prebid/Prebid.js into add…
Jan 14, 2020
240e621
fix merge errors
Jan 14, 2020
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
9 changes: 9 additions & 0 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,15 @@ const OPEN_RTB_PROTOCOL = {

const imp = { id: adUnit.code, ext, secure: _s2sConfig.secure };

/**
* Prebid AdSlot
* @type {(string|undefined)}
*/
const pbAdSlot = utils.deepAccess(adUnit, 'fpd.context.pbAdSlot');
if (typeof pbAdSlot === 'string' && pbAdSlot) {
utils.deepSetValue(imp, 'ext.context.data.adslot', pbAdSlot);
}

Object.assign(imp, mediaTypes);

if (imp.banner || imp.video || imp.native) {
Expand Down
18 changes: 18 additions & 0 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ export const spec = {
utils.deepSetValue(data, 'source.ext.schain', bidRequest.schain);
}

/**
* Prebid AdSlot
* @type {(string|undefined)}
*/
const pbAdSlot = utils.deepAccess(bidRequest, 'fpd.context.pbAdSlot');
if (typeof pbAdSlot === 'string' && pbAdSlot) {
utils.deepSetValue(data.imp[0].ext, 'context.data.adslot', pbAdSlot);
}

return {
method: 'POST',
url: VIDEO_ENDPOINT,
Expand Down Expand Up @@ -489,6 +498,15 @@ export const spec = {
});
}

/**
* Prebid AdSlot
* @type {(string|undefined)}
*/
const pbAdSlot = utils.deepAccess(bidRequest, 'fpd.context.pbAdSlot');
if (typeof pbAdSlot === 'string' && pbAdSlot) {
data['tg_i.dfp_ad_unit_code'] = pbAdSlot.replace(/^\/+/, '');
idettman marked this conversation as resolved.
Show resolved Hide resolved
}

// digitrust properties
const digitrustParams = _getDigiTrustQueryParams(bidRequest, 'FASTLANE');
Object.assign(data, digitrustParams);
Expand Down
7 changes: 7 additions & 0 deletions src/adapterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function getBids({bidderCode, auctionId, bidderRequestId, adUnits, labels, src})
}

bid = Object.assign({}, bid, getDefinedParams(adUnit, [
'fpd',
'mediaType',
'renderer'
]));
Expand Down Expand Up @@ -174,6 +175,12 @@ export let uspDataHandler = {
};

adapterManager.makeBidRequests = hook('sync', function (adUnits, auctionStart, auctionId, cbTimeout, labels) {
/**
* emit and pass adunits for external modification
* @see {@link https://github.com/prebid/Prebid.js/issues/4149|Issue}
*/
events.emit(CONSTANTS.EVENTS.BEFORE_REQUEST_BIDS, adUnits);

let bidRequests = [];

let bidderCodes = getBidderCodes(adUnits);
Expand Down
1 change: 1 addition & 0 deletions src/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"BID_WON": "bidWon",
"BIDDER_DONE": "bidderDone",
"SET_TARGETING": "setTargeting",
"BEFORE_REQUEST_BIDS": "beforeRequestBids",
idettman marked this conversation as resolved.
Show resolved Hide resolved
"REQUEST_BIDS": "requestBids",
"ADD_AD_UNITS": "addAdUnits",
"AD_RENDER_FAILED" : "adRenderFailed"
Expand Down
74 changes: 74 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,80 @@ describe('S2S Adapter', function () {
const parsedRequestBody = JSON.parse(server.requests[0].requestBody);
expect(parsedRequestBody.source.ext.schain).to.deep.equal(schainObject);
})

describe('pbAdSlot config', function () {
it('should not send \"imp.ext.context.data.adslot\" if \"fpd.context\" is undefined', function () {
const ortb2Config = utils.deepClone(CONFIG);
ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction';
const consentConfig = { s2sConfig: ortb2Config };
config.setConfig(consentConfig);
const bidRequest = utils.deepClone(REQUEST);

adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax);
const parsedRequestBody = JSON.parse(server.requests[0].requestBody);

expect(parsedRequestBody.imp).to.be.a('array');
expect(parsedRequestBody.imp[0]).to.be.a('object');
expect(parsedRequestBody.imp[0]).to.not.have.deep.nested.property('ext.context.data.adslot');
});

it('should not send \"imp.ext.context.data.adslot\" if \"fpd.context.pbAdSlot\" is undefined', function () {
const ortb2Config = utils.deepClone(CONFIG);
ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction';
const consentConfig = { s2sConfig: ortb2Config };
config.setConfig(consentConfig);
const bidRequest = utils.deepClone(REQUEST);
bidRequest.ad_units[0].fpd = {};

adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax);
const parsedRequestBody = JSON.parse(server.requests[0].requestBody);

expect(parsedRequestBody.imp).to.be.a('array');
expect(parsedRequestBody.imp[0]).to.be.a('object');
expect(parsedRequestBody.imp[0]).to.not.have.deep.nested.property('ext.context.data.adslot');
});

it('should not send \"imp.ext.context.data.adslot\" if \"fpd.context.pbAdSlot\" is empty string', function () {
const ortb2Config = utils.deepClone(CONFIG);
ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction';
const consentConfig = { s2sConfig: ortb2Config };
config.setConfig(consentConfig);
const bidRequest = utils.deepClone(REQUEST);
bidRequest.ad_units[0].fpd = {
context: {
pbAdSlot: ''
}
};

adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax);
const parsedRequestBody = JSON.parse(server.requests[0].requestBody);

expect(parsedRequestBody.imp).to.be.a('array');
expect(parsedRequestBody.imp[0]).to.be.a('object');
expect(parsedRequestBody.imp[0]).to.not.have.deep.nested.property('ext.context.data.adslot');
});

it('should send \"imp.ext.context.data.adslot\" if \"fpd.context.pbAdSlot\" value is a non-empty string', function () {
const ortb2Config = utils.deepClone(CONFIG);
ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction';
const consentConfig = { s2sConfig: ortb2Config };
config.setConfig(consentConfig);
const bidRequest = utils.deepClone(REQUEST);
bidRequest.ad_units[0].fpd = {
context: {
pbAdSlot: '/a/b/c'
}
};

adapter.callBids(bidRequest, BID_REQUESTS, addBidResponse, done, ajax);
const parsedRequestBody = JSON.parse(server.requests[0].requestBody);

expect(parsedRequestBody.imp).to.be.a('array');
expect(parsedRequestBody.imp[0]).to.be.a('object');
expect(parsedRequestBody.imp[0]).to.have.deep.nested.property('ext.context.data.adslot');
expect(parsedRequestBody.imp[0].ext.context.data.adslot).to.equal('/a/b/c');
});
});
});

describe('response handler', function () {
Expand Down
103 changes: 103 additions & 0 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,77 @@ describe('the rubicon adapter', function () {
});
});
})

describe('Prebid AdSlot', function () {
beforeEach(function () {
// enforce that the bid at 0 does not have a 'context' property
if (bidderRequest.bids[0].hasOwnProperty('fpd')) {
delete bidderRequest.bids[0].fpd;
}
});

it('should not send \"tg_i.dfp_ad_unit_code\" if \"fpd.context\" object is not valid', function () {
const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
const data = parseQuery(request.data);

expect(data).to.be.an('Object');
expect(data).to.not.have.property('tg_i.dfp_ad_unit_code');
});

it('should not send \"tg_i.dfp_ad_unit_code\" if \"fpd.context.pbAdSlot\" is undefined', function () {
bidderRequest.bids[0].fpd = {};

const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
const data = parseQuery(request.data);

expect(data).to.be.an('Object');
expect(data).to.not.have.property('tg_i.dfp_ad_unit_code');
});

it('should not send \"tg_i.dfp_ad_unit_code\" if \"fpd.context.pbAdSlot\" value is an empty string', function () {
bidderRequest.bids[0].fpd = {
context: {
pbAdSlot: ''
}
};

const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
const data = parseQuery(request.data);

expect(data).to.be.an('Object');
expect(data).to.not.have.property('tg_i.dfp_ad_unit_code');
});

it('should send \"tg_i.dfp_ad_unit_code\" if \"fpd.context.pbAdSlot\" value is a valid string', function () {
bidderRequest.bids[0].fpd = {
context: {
pbAdSlot: 'abc'
}
}

const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
const data = parseQuery(request.data);

expect(data).to.be.an('Object');
expect(data).to.have.property('tg_i.dfp_ad_unit_code');
expect(data['tg_i.dfp_ad_unit_code']).to.equal('abc');
});

it('should send \"tg_i.dfp_ad_unit_code\" if \"fpd.context.pbAdSlot\" value is a valid string, but all leading slash characters should be removed', function () {
bidderRequest.bids[0].fpd = {
context: {
pbAdSlot: '/a/b/c'
}
};

const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
const data = parseQuery(request.data);

expect(data).to.be.an('Object');
expect(data).to.have.property('tg_i.dfp_ad_unit_code');
expect(data['tg_i.dfp_ad_unit_code']).to.equal('a/b/c');
});
});
});

describe('for video requests', function () {
Expand Down Expand Up @@ -1568,6 +1639,38 @@ describe('the rubicon adapter', function () {
const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(request.data.regs.coppa).to.equal(1);
});

it('should include pbAdSlot in bid request', function () {
createVideoBidderRequest();
bidderRequest.bids[0].fpd = {
context: {
pbAdSlot: '1234567890'
}
};

sandbox.stub(Date, 'now').callsFake(() =>
bidderRequest.auctionStart + 100
);

const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(request.data.imp[0].ext.context.data.adslot).to.equal('1234567890');
});
});

it('should include pbAdSlot in bid request', function () {
createVideoBidderRequest();
bidderRequest.bids[0].fpd = {
context: {
pbAdSlot: '1234567890'
}
};

sandbox.stub(Date, 'now').callsFake(() =>
bidderRequest.auctionStart + 100
);

const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(request.data.imp[0].ext.context.data.adslot).to.equal('1234567890');
});

describe('combineSlotUrlParams', function () {
Expand Down
Loading