Skip to content

Commit

Permalink
Support for FPD (and ortb2 config) (prebid#7802)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn-lw authored and Chris Pabst committed Jan 10, 2022
1 parent d3c89ed commit 386471a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/livewrappedBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isSafariBrowser, deepAccess, getWindowTop } from '../src/utils.js';
import { isSafariBrowser, deepAccess, getWindowTop, mergeDeep } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import find from 'core-js-pure/features/array/find.js';
Expand Down Expand Up @@ -60,11 +60,17 @@ export const spec = {
const bundle = find(bidRequests, hasBundleParam);
const tid = find(bidRequests, hasTidParam);
const schain = bidRequests[0].schain;
let ortb2 = config.getConfig('ortb2');
const eids = handleEids(bidRequests);
bidUrl = bidUrl ? bidUrl.params.bidUrl : URL;
url = url ? url.params.url : (getAppDomain() || getTopWindowLocation(bidderRequest));
test = test ? test.params.test : undefined;
var adRequests = bidRequests.map(bidToAdRequest);

if (eids) {
ortb2 = mergeDeep(ortb2 || {}, eids);
}

const payload = {
auctionId: auctionId ? auctionId.auctionId : undefined,
publisherId: publisherId ? publisherId.params.publisherId : undefined,
Expand All @@ -86,7 +92,7 @@ export const spec = {
cookieSupport: !isSafariBrowser() && storage.cookiesAreEnabled(),
rcv: getAdblockerRecovered(),
adRequests: [...adRequests],
rtbData: handleEids(bidRequests),
rtbData: ortb2,
schain: schain
};

Expand Down
31 changes: 31 additions & 0 deletions test/spec/modules/livewrappedBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,37 @@ describe('Livewrapped adapter tests', function () {
expect(data.rtbData.user.ext.eids).to.deep.equal(testbidRequest.bids[0].userIdAsEids);
});

it('should merge user ids with existing ortb2', function() {
sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false);
sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => true);

let origGetConfig = config.getConfig;
sandbox.stub(config, 'getConfig').callsFake(function (key) {
if (key === 'ortb2') {
return {user: {ext: {prop: 'value'}}};
}
return origGetConfig.apply(config, arguments);
});

let testbidRequest = clone(bidderRequest);
delete testbidRequest.bids[0].params.userId;
testbidRequest.bids[0].userIdAsEids = [
{
'source': 'pubcid.org',
'uids': [{
'id': 'publisher-common-id',
'atype': 1
}]
}
];

let result = spec.buildRequests(testbidRequest.bids, testbidRequest);
let data = JSON.parse(result.data);
var expected = {user: {ext: {prop: 'value', eids: testbidRequest.bids[0].userIdAsEids}}}

expect(data.rtbData).to.deep.equal(expected);
});

it('should send schain object if available', function() {
sandbox.stub(utils, 'isSafariBrowser').callsFake(() => false);
sandbox.stub(storage, 'cookiesAreEnabled').callsFake(() => true);
Expand Down

0 comments on commit 386471a

Please sign in to comment.