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

TL-17557: Incorrectly passing FPD KVs #12

Merged
8 commits merged into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 28 additions & 3 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ function _buildPostBody(bidRequests) {
} else if (bidRequest.mediaTypes.banner) {
imp.banner = { format: _sizes(bidRequest.sizes) };
};
if (!utils.isEmpty(bidRequest.fpd)) {
imp.fpd = _getAdUnitFpd(bidRequest.fpd);
}
return imp;
});

Expand Down Expand Up @@ -183,12 +186,34 @@ function _getFloor (bid) {
}

function _getGlobalFpd() {
let fpd = {};
const fpd = {};
const context = {}
const user = {};

const fpdContext = Object.assign({}, config.getConfig('fpd.context'));
const fpdUser = Object.assign({}, config.getConfig('fpd.user'));

_addEntries(fpd, fpdContext);
_addEntries(fpd, fpdUser);
_addEntries(context, fpdContext);
_addEntries(user, fpdUser);
kzhouTL marked this conversation as resolved.
Show resolved Hide resolved

if (!utils.isEmpty(context)) {
fpd.context = context;
}
if (!utils.isEmpty(user)) {
fpd.user = user;
}
return fpd;
}

function _getAdUnitFpd(adUnitFpd) {
const fpd = {};
const context = {};

_addEntries(context, adUnitFpd.context);

if (!utils.isEmpty(context)) {
fpd.context = context;
}

return fpd;
This conversation was marked as resolved.
Show resolved Hide resolved
}
Expand Down
31 changes: 24 additions & 7 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ describe('triplelift adapter', function () {
auctionId: '1d1a030790a475',
userId: {},
schain,
fpd: {
context: {
pbAdSlot: 'homepage-top-rect',
data: {
adUnitSpecificAttribute: 123
}
}
}
},
{
bidder: 'triplelift',
Expand Down Expand Up @@ -597,17 +605,19 @@ describe('triplelift adapter', function () {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[0].floor).to.equal(1.99);
});
it('should send fpd on root level ext if kvps are available', function() {
it('should send global config fpd if kvps are available', function() {
const sens = null;
const category = ['news', 'weather', 'hurricane'];
const pmp_elig = 'true';
const fpd = {
context: {
pmp_elig,
category,
pmp_elig: pmp_elig,
data: {
category: category
}
},
user: {
sens,
sens: sens,
}
}
sandbox.stub(config, 'getConfig').callsFake(key => {
Expand All @@ -618,9 +628,16 @@ describe('triplelift adapter', function () {
});
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
const { data: payload } = request;
expect(payload.ext.fpd).to.not.haveOwnProperty('sens');
expect(payload.ext.fpd).to.haveOwnProperty('category');
expect(payload.ext.fpd).to.haveOwnProperty('pmp_elig');
expect(payload.ext.fpd.user).to.not.exist;
expect(payload.ext.fpd.context.data).to.haveOwnProperty('category');
expect(payload.ext.fpd.context).to.haveOwnProperty('pmp_elig');
});
it('should send ad unit fpd if kvps are available', function() {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[0].fpd.context).to.haveOwnProperty('pbAdSlot');
expect(request.data.imp[0].fpd.context).to.haveOwnProperty('data');
expect(request.data.imp[0].fpd.context.data).to.haveOwnProperty('adUnitSpecificAttribute');
expect(request.data.imp[1].fpd).to.not.exist;
});
});

Expand Down