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

Prebid 9: stop using transformBidParams #11499

Merged
merged 1 commit into from
May 23, 2024
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
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 @@ -1726,39 +1726,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);
})
});
});