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

LiveWrapped Bid Adapter: support for FPD (and ortb2 config) #7802

Merged
merged 1 commit into from
Dec 7, 2021
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
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