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

Standardizing First Party Data #4472

Merged
merged 52 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 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
8e81409
Support user and context first party data in rubicon and prebid serve…
Nov 15, 2019
1d0acf1
Place user and context within fpd object
Nov 15, 2019
5d58dae
Merge branch 'master' of https://github.com/prebid/Prebid.js into sta…
Dec 13, 2019
9ee631b
Separate global and bidder-specific first party data
Dec 13, 2019
2234c5e
Merge branch 'master' of https://github.com/prebid/Prebid.js into sta…
Dec 16, 2019
cbb5ba5
Merge branch 'master' of https://github.com/prebid/Prebid.js into sta…
Dec 16, 2019
86bb432
Merge branch 'master' of https://github.com/prebid/Prebid.js into sta…
Jan 22, 2020
724c5ad
Merge branch 'master' of https://github.com/prebid/Prebid.js into sta…
Jan 30, 2020
0bc3661
Repeat FPD for each bidder when sending to PBS
Feb 13, 2020
cc98dac
Merge branch 'master' of https://github.com/prebid/Prebid.js into sta…
Feb 13, 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
35 changes: 35 additions & 0 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,32 @@ function _appendSiteAppDevice(request, pageUrl) {
}
}

function addBidderFirstPartyDataToRequest(request) {
const bidderConfig = config.getBidderConfig();
const fpdConfigs = Object.keys(bidderConfig).reduce((acc, bidder) => {
const currBidderConfig = bidderConfig[bidder];
if (currBidderConfig.fpd) {
const fpd = {};
if (currBidderConfig.fpd.context) {
fpd.site = currBidderConfig.fpd.context;
}
if (currBidderConfig.fpd.user) {
fpd.user = currBidderConfig.fpd.user;
}

acc.push({
bidders: [ bidder ],
config: { fpd }
});
}
return acc;
}, []);

if (fpdConfigs.length) {
utils.deepSetValue(request, 'ext.prebid.bidderconfig', fpdConfigs);
}
}

// https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=40
let nativeDataIdMap = {
sponsoredBy: 1, // sponsored
Expand Down Expand Up @@ -661,6 +687,15 @@ const OPEN_RTB_PROTOCOL = {
utils.deepSetValue(request, 'regs.coppa', 1);
}

const commonFpd = getConfig('fpd') || {};
if (commonFpd.context) {
utils.deepSetValue(request, 'site.ext.data', commonFpd.context);
}
if (commonFpd.user) {
utils.deepSetValue(request, 'user.ext.data', commonFpd.user);
}
addBidderFirstPartyDataToRequest(request);

return request;
},

Expand Down
58 changes: 43 additions & 15 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,27 @@ export const spec = {
utils.deepSetValue(data, 'source.ext.schain', bidRequest.schain);
}

const siteData = Object.assign({}, bidRequest.params.inventory, config.getConfig('fpd.context'));
const userData = Object.assign({}, bidRequest.params.visitor, config.getConfig('fpd.user'));
if (!utils.isEmpty(siteData) || !utils.isEmpty(userData)) {
const bidderData = {
bidders: [ bidderRequest.bidderCode ],
config: {
fpd: {}
}
};

if (!utils.isEmpty(siteData)) {
bidderData.config.fpd.site = siteData;
}

if (!utils.isEmpty(userData)) {
bidderData.config.fpd.user = userData;
}

utils.deepSetValue(data, 'ext.prebid.bidderconfig.0', bidderData);
}

/**
* Prebid AdSlot
* @type {(string|undefined)}
Expand Down Expand Up @@ -448,7 +469,6 @@ export const spec = {
'x_source.tid': bidRequest.transactionId,
'x_source.pchain': params.pchain,
'p_screen_res': _getScreenResolution(),
'kw': Array.isArray(params.keywords) ? params.keywords.join(',') : '',
'tk_user_key': params.userId,
'p_geo.latitude': isNaN(parseFloat(latitude)) ? undefined : parseFloat(latitude).toFixed(4),
'p_geo.longitude': isNaN(parseFloat(longitude)) ? undefined : parseFloat(longitude).toFixed(4),
Expand Down Expand Up @@ -487,22 +507,30 @@ export const spec = {
}

// visitor properties
if (params.visitor !== null && typeof params.visitor === 'object') {
Object.keys(params.visitor).forEach((key) => {
bretg marked this conversation as resolved.
Show resolved Hide resolved
if (params.visitor[key] != null) {
data[`tg_v.${key}`] = params.visitor[key].toString(); // initialize array;
}
});
}
const visitorData = Object.assign({}, params.visitor, config.getConfig('fpd.user'));
Object.keys(visitorData).forEach((key) => {
if (visitorData[key] != null && key !== 'keywords') {
data[`tg_v.${key}`] = typeof visitorData[key] === 'object' && !Array.isArray(visitorData[key])
? JSON.stringify(visitorData[key])
: visitorData[key].toString(); // initialize array;
}
});

// inventory properties
if (params.inventory !== null && typeof params.inventory === 'object') {
Object.keys(params.inventory).forEach((key) => {
if (params.inventory[key] != null) {
data[`tg_i.${key}`] = params.inventory[key].toString();
}
});
}
const inventoryData = Object.assign({}, params.inventory, config.getConfig('fpd.context'));
Object.keys(inventoryData).forEach((key) => {
if (inventoryData[key] != null && key !== 'keywords') {
data[`tg_i.${key}`] = typeof inventoryData[key] === 'object' && !Array.isArray(inventoryData[key])
? JSON.stringify(inventoryData[key])
: inventoryData[key].toString();
}
});

// keywords
const keywords = (params.keywords || []).concat(
utils.deepAccess(config.getConfig('fpd.user'), 'keywords') || [],
utils.deepAccess(config.getConfig('fpd.context'), 'keywords') || []);
data.kw = keywords.length ? keywords.join(',') : '';

/**
* Prebid AdSlot
Expand Down
46 changes: 45 additions & 1 deletion test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,51 @@ describe('S2S Adapter', function () {
adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax);
const parsedRequestBody = JSON.parse(server.requests[0].requestBody);
expect(parsedRequestBody.source.ext.schain).to.deep.equal(schainObject);
})
});

it('passes first party data in request', () => {
const s2sBidRequest = utils.deepClone(REQUEST);
const bidRequests = utils.deepClone(BID_REQUESTS);

const commonContext = {
keywords: ['power tools'],
search: 'drill'
};
const commonUser = {
keywords: ['a', 'b'],
gender: 'M'
};

const context = {
content: { userrating: 4 },
data: {
pageType: 'article',
category: 'tools'
}
};
const user = {
yob: '1984',
geo: { country: 'ca' },
data: {
registered: true,
interests: ['cars']
}
};
const allowedBidders = [ 'rubicon', 'appnexus' ];

const expected = allowedBidders.map(bidder => ({
bidders: [ bidder ],
config: { fpd: { site: context, user } }
}));

config.setConfig({ fpd: { context: commonContext, user: commonUser } });
config.setBidderConfig({ bidders: allowedBidders, config: { fpd: { context, user } } });
adapter.callBids(s2sBidRequest, bidRequests, addBidResponse, done, ajax);
const parsedRequestBody = JSON.parse(server.requests[0].requestBody);
expect(parsedRequestBody.ext.prebid.bidderconfig).to.deep.equal(expected);
expect(parsedRequestBody.site.ext.data).to.deep.equal(commonContext);
expect(parsedRequestBody.user.ext.data).to.deep.equal(commonUser);
});

describe('pbAdSlot config', function () {
it('should not send \"imp.ext.context.data.adslot\" if \"fpd.context\" is undefined', function () {
Expand Down
83 changes: 83 additions & 0 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,51 @@ describe('the rubicon adapter', function () {
expect(data[key]).to.equal(value);
});
});

it('should use first party data from getConfig over the bid params, if present', () => {
const context = {
keywords: ['e', 'f'],
rating: '4-star'
};
const user = {
keywords: ['d'],
gender: 'M',
yob: '1984',
geo: { country: 'ca' }
};

sandbox.stub(config, 'getConfig').callsFake(key => {
const config = {
fpd: {
context,
user
}
};
return utils.deepAccess(config, key);
});

const expectedQuery = {
'kw': 'a,b,c,d,e,f',
'tg_v.ucat': 'new',
'tg_v.lastsearch': 'iphone',
'tg_v.likes': 'sports,video games',
'tg_v.gender': 'M',
'tg_v.yob': '1984',
'tg_v.geo': '{"country":"ca"}',
'tg_i.rating': '4-star',
'tg_i.prodtype': 'tech,mobile',
};

// get the built request
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let data = parseQuery(request.data);

// make sure that tg_v, tg_i, and kw values are correct
Object.keys(expectedQuery).forEach(key => {
let value = expectedQuery[key];
expect(data[key]).to.deep.equal(value);
});
});
});

describe('singleRequest config', function () {
Expand Down Expand Up @@ -1641,6 +1686,44 @@ describe('the rubicon adapter', function () {
expect(request.data.regs.coppa).to.equal(1);
});

it('should include first party data', () => {
createVideoBidderRequest();

const context = {
keywords: ['e', 'f'],
rating: '4-star'
};
const user = {
keywords: ['d'],
gender: 'M',
yob: '1984',
geo: { country: 'ca' }
};

sandbox.stub(config, 'getConfig').callsFake(key => {
const config = {
fpd: {
context,
user
}
};
return utils.deepAccess(config, key);
});

const expected = [{
bidders: [ 'rubicon' ],
config: {
fpd: {
site: Object.assign({}, bidderRequest.bids[0].params.inventory, context),
user: Object.assign({}, bidderRequest.bids[0].params.visitor, user)
}
}
}];

const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
expect(request.data.ext.prebid.bidderconfig).to.deep.equal(expected);
});

it('should include storedAuctionResponse in video bid request', function () {
createVideoBidderRequest();

Expand Down