Skip to content

Commit

Permalink
Prebid 9: stop using transformBidParams (#11499)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi authored May 23, 2024
1 parent 16d1ea6 commit f9139d1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 102 deletions.
12 changes: 1 addition & 11 deletions libraries/pbsExtensions/processors/params.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import {auctionManager} from '../../../src/auctionManager.js';
import adapterManager from '../../../src/adapterManager.js';
import {deepSetValue} from '../../../src/utils.js';

export function setImpBidParams(
imp, bidRequest, context,
{adUnit, bidderRequests, index = auctionManager.index, bidderRegistry = adapterManager.bidderRegistry} = {}) {
export function setImpBidParams(imp, bidRequest) {
let params = bidRequest.params;
const adapter = bidderRegistry[bidRequest.bidder];
if (adapter && adapter.getSpec().transformBidParams) {
adUnit = adUnit || index.getAdUnit(bidRequest);
bidderRequests = bidderRequests || [context.bidderRequest];
params = adapter.getSpec().transformBidParams(params, true, adUnit, bidderRequests);
}
if (params) {
deepSetValue(
imp,
Expand Down
33 changes: 0 additions & 33 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1746,39 +1746,6 @@ describe('S2S Adapter', function () {
});
});

it('converts appnexus params to expected format for PBS', function () {
const s2sConfig = Object.assign({}, CONFIG, {
endpoint: {
p1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'
}
});
config.setConfig({ s2sConfig: s2sConfig });

Object.assign(BID_REQUESTS[0].bids[0].params, {
usePaymentRule: true,
keywords: {
foo: ['bar', 'baz'],
fizz: ['buzz']
}
})

adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
const requestBid = JSON.parse(server.requests[0].requestBody);

const requestParams = requestBid.imp[0].ext.prebid.bidder;
expect(requestParams.appnexus).to.exist;
expect(requestParams.appnexus.placement_id).to.exist.and.to.equal(10433394);
expect(requestParams.appnexus.use_pmt_rule).to.exist.and.to.be.true;
expect(requestParams.appnexus.member).to.exist;
expect(requestParams.appnexus.keywords).to.exist.and.to.deep.equal([{
key: 'foo',
value: ['bar', 'baz']
}, {
key: 'fizz',
value: ['buzz']
}]);
});

describe('cookie sync', () => {
let s2sConfig, bidderReqs;

Expand Down
58 changes: 0 additions & 58 deletions test/spec/ortbConverter/pbsExtensions/params_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,63 +34,5 @@ describe('pbjs -> ortb bid params to imp[].ext.prebid.BIDDER', () => {

it('has no effect if bidRequest has no params', () => {
expect(setParams({bidder: 'mockBidder'})).to.eql({});
})

describe('when adapter provides transformBidParams', () => {
let transform, bidderRequest;
beforeEach(() => {
bidderRequest = {bidderCode: 'mockBidder'};
transform = sinon.stub().callsFake((p) => Object.assign({transformed: true}, p));
bidderRegistry.mockBidder = {
getSpec() {
return {
transformBidParams: transform
}
}
}
})

it('runs params through transform', () => {
expect(setParams({bidder: 'mockBidder', params: {a: 'param'}}, {bidderRequest})).to.eql({
ext: {
prebid: {
bidder: {
mockBidder: {
a: 'param',
transformed: true
}
}
}
}
});
});

it('runs through transform even if bid has no params', () => {
expect(setParams({bidder: 'mockBidder'}, {bidderRequest})).to.eql({
ext: {
prebid: {
bidder: {
mockBidder: {
transformed: true
}
}
}
}
})
})

it('by default, passes adUnit from index, bidderRequest from context', () => {
const params = {a: 'param'};
setParams({bidder: 'mockBidder', params}, {bidderRequest});
sinon.assert.calledWith(transform, params, true, adUnit, [bidderRequest])
});

it('uses provided adUnit, bidderRequests', () => {
const adUnit = {code: 'other-ad-unit'};
const bidderRequests = [{bidderCode: 'one'}, {bidderCode: 'two'}];
const params = {a: 'param'};
setParams({bidder: 'mockBidder', params}, {}, {adUnit, bidderRequests});
sinon.assert.calledWith(transform, params, true, adUnit, bidderRequests);
})
});
});

0 comments on commit f9139d1

Please sign in to comment.