Skip to content

Commit

Permalink
PubMatic Adapter: add support for FloCID (#6749)
Browse files Browse the repository at this point in the history
* changes to support native in pubmaticbid adapter

* Removed port from endpoint

* Removed protocol from endpoint

* Formatting

* Fix request payload

* Updated test case

* Changed request and response as per ortb spec

* Change in request and response

* Removed comments and extra code

* Code Review comments

* Code Review Comments and Test cases for request and response

* Removed data type as all data asset types are handled

* Code Review Changes

* Code Review Comments

* Supporting both banner and native and sending 0x0 in case of native

* Bug Fixes

* Bug response not processed by prebid

* Change warning message

* Fixed typo

* Do not send request in case of invalid native bid

* Do not send request in case of invalid native requests

* objects converted to strings in log for debug purposes

* Fixed logic to check for required parmas

* Fixed typo for stringify

* documentation for native

* Review comments from Prebid

* Typo

* Typo

* Updated pub id for native

* Code Review

* Support for pubid

* Test Cases for PubCommonId in PubMatic adapter

* Delete yarn.lock

* Rename adaptermanager.js to adapterManager.js

* Rename yieldNexusBidAdapter.js to yieldnexusBidAdapter.js

* Rename yieldNexusBidAdapter.md to yieldnexusBidAdapter.md

* Rename yieldNexusBidAdapter_spec.js to yieldnexusBidAdapter_spec.yieldnexusBidAdaptera

* Rename yieldnexusBidAdapter_spec.yieldnexusBidAdaptera to yieldnexusBidAdapter_spec.js

* bluebillywig outstream player support in pubmatic adapter

* removed pubcommon id test cases

* BBW Renderer

* Pubmatic should work with provided renderer

* Review Comments

* changes for flocId

* code review comments

* fixed for eids

* code review comments

* unit test cases for floc

* updated md file

* code review comment
  • Loading branch information
pm-shashank-jain authored May 18, 2021
1 parent e92009d commit 3b6442e
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 2 deletions.
68 changes: 66 additions & 2 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ const dealChannelValues = {
5: 'PREF',
6: 'PMPG'
};

const FLOC_FORMAT = {
'EID': 1,
'SEGMENT': 2
}
// BB stands for Blue BillyWig
const BB_RENDERER = {
bootstrapPlayer: function(bid) {
Expand Down Expand Up @@ -708,8 +713,67 @@ function _addFloorFromFloorModule(impObj, bid) {
impObj.bidfloor = ((!isNaN(bidFloor) && bidFloor > 0) ? bidFloor : UNDEFINED);
}

function _getFlocId(validBidRequests, flocFormat) {
var flocIdObject = null;
var flocId = utils.deepAccess(validBidRequests, '0.userId.flocId');
if (flocId && flocId.id) {
switch (flocFormat) {
case FLOC_FORMAT.SEGMENT:
flocIdObject = {
id: 'FLOC',
name: 'FLOC',
ext: {
ver: flocId.version
},
segment: [{
id: flocId.id,
name: 'chrome.com',
value: flocId.id.toString()
}]
}
break;
case FLOC_FORMAT.EID:
default:
flocIdObject = {
source: 'chrome.com',
uids: [
{
atype: 1,
id: flocId.id,
ext: {
ver: flocId.version
}
},
]
}
break;
}
}
return flocIdObject;
}

function _handleFlocId(payload, validBidRequests) {
var flocObject = _getFlocId(validBidRequests, FLOC_FORMAT.SEGMENT);
if (flocObject) {
if (!payload.user) {
payload.user = {};
}
if (!payload.user.data) {
payload.user.data = [];
}
payload.user.data.push(flocObject);
}
}

function _handleEids(payload, validBidRequests) {
const bidUserIdAsEids = utils.deepAccess(validBidRequests, '0.userIdAsEids');
let bidUserIdAsEids = utils.deepAccess(validBidRequests, '0.userIdAsEids');
let flocObject = _getFlocId(validBidRequests, FLOC_FORMAT.EID);
if (flocObject) {
if (!bidUserIdAsEids) {
bidUserIdAsEids = [];
}
bidUserIdAsEids.push(flocObject);
}
if (utils.isArray(bidUserIdAsEids) && bidUserIdAsEids.length > 0) {
utils.deepSetValue(payload, 'user.eids', bidUserIdAsEids);
}
Expand Down Expand Up @@ -1029,7 +1093,7 @@ export const spec = {
_handleDealCustomTargetings(payload, dctrArr, validBidRequests);
_handleEids(payload, validBidRequests);
_blockedIabCategoriesValidation(payload, blockedIabCategories);

_handleFlocId(payload, validBidRequests);
// First Party Data
const commonFpd = config.getConfig('ortb2') || {};
if (commonFpd.site) {
Expand Down
62 changes: 62 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,68 @@ describe('PubMatic adapter', function () {
expect(data.user.eids).to.equal(undefined);
});
});

describe('FlocId', function() {
it('send the FlocId if it is present', function() {
bidRequests[0].userId = {};
bidRequests[0].userId.flocId = {
id: '1234',
version: 'chrome1.1'
}
let request = spec.buildRequests(bidRequests, {});
let data = JSON.parse(request.data);
expect(data.user.eids).to.deep.equal([{
'source': 'chrome.com',
'uids': [{
'id': '1234',
'atype': 1,
'ext': {
'ver': 'chrome1.1'
}
}]
}]);
expect(data.user.data).to.deep.equal([{
id: 'FLOC',
name: 'FLOC',
ext: {
ver: 'chrome1.1'
},
segment: [{
id: '1234',
name: 'chrome.com',
value: '1234'
}]
}]);
});

it('appnend the flocId if userIds are present', function() {
bidRequests[0].userId = {};
bidRequests[0].userId.netId = 'netid-user-id';
bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId);
bidRequests[0].userId.flocId = {
id: '1234',
version: 'chrome1.1'
}
let request = spec.buildRequests(bidRequests, {});
let data = JSON.parse(request.data);
expect(data.user.eids).to.deep.equal([{
'source': 'netid.de',
'uids': [{
'id': 'netid-user-id',
'atype': 1
}]
}, {
'source': 'chrome.com',
'uids': [{
'id': '1234',
'atype': 1,
'ext': {
'ver': 'chrome1.1'
}
}]
}]);
});
});
});

it('Request params check for video ad', function () {
Expand Down

0 comments on commit 3b6442e

Please sign in to comment.