Skip to content

Commit

Permalink
Revert "fledgeForGpt: consolidate publisher configuration (prebid#10136
Browse files Browse the repository at this point in the history
…)" (prebid#10352)

This reverts commit 52996a6.
  • Loading branch information
patmmccann authored Aug 11, 2023
1 parent e1acefe commit 934f5a9
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 144 deletions.
18 changes: 5 additions & 13 deletions modules/fledgeForGpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,18 @@ function isFledgeSupported() {

export function markForFledge(next, bidderRequests) {
if (isFledgeSupported()) {
const globalFledgeConfig = config.getConfig('fledgeForGpt');
const bidders = globalFledgeConfig?.bidders ?? [];
bidderRequests.forEach((req) => {
const useGlobalConfig = globalFledgeConfig?.enabled && (bidders.length == 0 || bidders.includes(req.bidderCode));
Object.assign(req, config.runWithBidder(req.bidderCode, () => {
return {
fledgeEnabled: config.getConfig('fledgeEnabled') ?? (useGlobalConfig ? globalFledgeConfig.enabled : undefined),
defaultForSlots: config.getConfig('defaultForSlots') ?? (useGlobalConfig ? globalFledgeConfig?.defaultForSlots : undefined)
}
}));
});
req.fledgeEnabled = config.runWithBidder(req.bidderCode, () => config.getConfig('fledgeEnabled'))
})
}
next(bidderRequests);
}
getHook('makeBidRequests').after(markForFledge);

export function setImpExtAe(imp, bidRequest, context) {
const impExt = imp.ext ?? {};
impExt.ae = context.bidderRequest.fledgeEnabled ? (impExt.ae ?? context.bidderRequest.defaultForSlots) : undefined;
imp.ext = impExt;
if (!context.bidderRequest.fledgeEnabled) {
delete imp.ext?.ae;
}
}
registerOrtbProcessor({type: IMP, name: 'impExtAe', fn: setImpExtAe});

Expand Down
27 changes: 10 additions & 17 deletions modules/fledgeForGpt.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,24 @@ This is accomplished by adding the `fledgeForGpt` module to the list of modules
gulp build --modules=fledgeForGpt,...
```

Second, they must enable FLEDGE in their Prebid.js configuration.
This is done through module level configuration, but to provide a high degree of flexiblity for testing, FLEDGE settings also exist at the bidder level and slot level.
Second, they must enable FLEDGE in their Prebid.js configuration. To provide a high degree of flexiblity for testing, FLEDGE
settings exist at the module level, the bidder level, and the slot level.

### Module Configuration
This module exposes the following settings:

|Name |Type |Description |Notes |
| :------------ | :------------ | :------------ |:------------ |
|enabled | Boolean |Enable/disable the module |Defaults to `false` |
|bidders | Array[String] |Optional list of bidders |Defaults to all bidders |
|defaultForSlots | Number |Default value for `imp.ext.ae` in requests for specified bidders |Should be 1 |

As noted above, FLEDGE support is disabled by default. To enable it, set the `enabled` value to `true` for this module and configure `defaultForSlots` to be `1` (meaning _Client-side auction_).
using the `setConfig` method of Prebid.js. Optionally, a list of
bidders to apply these settings to may be provided:
As noted above, FLEDGE support is disabled by default. To enable it, set the `enabled` value to `true` for this module
using the `setConfig` method of Prebid.js:

```js
pbjs.que.push(function() {
pbjs.setConfig({
fledgeForGpt: {
enabled: true,
bidders: ['openx', 'rtbhouse'],
defaultForSlots: 1
enabled: true
}
});
});
Expand All @@ -49,25 +44,23 @@ This module adds the following setting for bidders:
|Name |Type |Description |Notes |
| :------------ | :------------ | :------------ |:------------ |
| fledgeEnabled | Boolean | Enable/disable a bidder to participate in FLEDGE | Defaults to `false` |
|defaultForSlots | Number |Default value for `imp.ext.ae` in requests for specified bidders |Should be 1|

Individual bidders may be further included or excluded here using the `setBidderConfig` method
In addition to enabling FLEDGE at the module level, individual bidders must also be enabled. This allows publishers to
selectively test with one or more bidders as they desire. To enable one or more bidders, use the `setBidderConfig` method
of Prebid.js:

```js
pbjs.setBidderConfig({
bidders: ["openx"],
config: {
fledgeEnabled: true,
defaultForSlots: 1
fledgeEnabled: true
}
});
```

### AdUnit Configuration
All adunits can be opted-in to FLEDGE in the global config via the `defaultForSlots` parameter.
If needed, adunits can be configured individually by setting an attribute of the `ortb2Imp` object for that
adunit. This attribute will take precedence over `defaultForSlots` setting.
Enabling an adunit for FLEDGE eligibility is accomplished by setting an attribute of the `ortb2Imp` object for that
adunit.

|Name |Type |Description |Notes |
| :------------ | :------------ | :------------ |:------------ |
Expand Down
156 changes: 42 additions & 114 deletions test/spec/modules/fledge_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,131 +61,59 @@ describe('fledgeEnabled', function () {
config.resetConfig();
});

const adUnits = [{
'code': '/19968336/header-bid-tag1',
'mediaTypes': {
'banner': {
'sizes': [[728, 90]]
},
},
'bids': [
{
'bidder': 'appnexus',
},
{
'bidder': 'rubicon',
},
]
}];

describe('with setBidderConfig()', () => {
it('should set fledgeEnabled correctly per bidder', function () {
config.setConfig({bidderSequence: 'fixed'})
config.setBidderConfig({
bidders: ['appnexus'],
config: {
fledgeEnabled: true,
defaultForSlots: 1,
}
});

const bidRequests = adapterManager.makeBidRequests(
adUnits,
Date.now(),
utils.getUniqueIdentifierStr(),
function callback() {},
[]
);

expect(bidRequests[0].bids[0].bidder).equals('appnexus');
expect(bidRequests[0].fledgeEnabled).to.be.true;
expect(bidRequests[0].defaultForSlots).to.equal(1);

expect(bidRequests[1].bids[0].bidder).equals('rubicon');
expect(bidRequests[1].fledgeEnabled).to.be.undefined;
expect(bidRequests[1].defaultForSlots).to.be.undefined;
});
});

describe('with setConfig()', () => {
it('should set fledgeEnabled correctly per bidder', function () {
config.setConfig({
bidderSequence: 'fixed',
fledgeForGpt: {
enabled: true,
bidders: ['appnexus'],
defaultForSlots: 1,
}
});

const bidRequests = adapterManager.makeBidRequests(
adUnits,
Date.now(),
utils.getUniqueIdentifierStr(),
function callback() {},
[]
);

expect(bidRequests[0].bids[0].bidder).equals('appnexus');
expect(bidRequests[0].fledgeEnabled).to.be.true;
expect(bidRequests[0].defaultForSlots).to.equal(1);

expect(bidRequests[1].bids[0].bidder).equals('rubicon');
expect(bidRequests[1].fledgeEnabled).to.be.undefined;
expect(bidRequests[1].defaultForSlots).to.be.undefined;
it('should set fledgeEnabled correctly per bidder', function () {
config.setConfig({bidderSequence: 'fixed'})
config.setBidderConfig({
bidders: ['appnexus'],
config: {
fledgeEnabled: true,
}
});

it('should set fledgeEnabled correctly for all bidders', function () {
config.setConfig({
bidderSequence: 'fixed',
fledgeForGpt: {
enabled: true,
defaultForSlots: 1,
}
});

const bidRequests = adapterManager.makeBidRequests(
adUnits,
Date.now(),
utils.getUniqueIdentifierStr(),
function callback() {},
[]
);

expect(bidRequests[0].bids[0].bidder).equals('appnexus');
expect(bidRequests[0].fledgeEnabled).to.be.true;
expect(bidRequests[0].defaultForSlots).to.equal(1);

expect(bidRequests[1].bids[0].bidder).equals('rubicon');
expect(bidRequests[0].fledgeEnabled).to.be.true;
expect(bidRequests[0].defaultForSlots).to.equal(1);
});
const adUnits = [{
'code': '/19968336/header-bid-tag1',
'mediaTypes': {
'banner': {
'sizes': [[728, 90]]
},
},
'bids': [
{
'bidder': 'appnexus',
},
{
'bidder': 'rubicon',
},
]
}];

const bidRequests = adapterManager.makeBidRequests(
adUnits,
Date.now(),
utils.getUniqueIdentifierStr(),
function callback() {},
[]
);

expect(bidRequests[0].bids[0].bidder).equals('appnexus');
expect(bidRequests[0].fledgeEnabled).to.be.true;

expect(bidRequests[1].bids[0].bidder).equals('rubicon');
expect(bidRequests[1].fledgeEnabled).to.be.undefined;
});
});

describe('ortb processors for fledge', () => {
describe('when defaultForSlots is set', () => {
it('imp.ext.ae should be set if fledge is enabled', () => {
const imp = {};
setImpExtAe(imp, {}, {bidderRequest: {fledgeEnabled: true, defaultForSlots: 1}});
expect(imp.ext.ae).to.equal(1);
});
it('imp.ext.ae should be left intact if set on adunit and fledge is enabled', () => {
const imp = {ext: {ae: 2}};
setImpExtAe(imp, {}, {bidderRequest: {fledgeEnabled: true, defaultForSlots: 1}});
expect(imp.ext.ae).to.equal(2);
});
});
describe('when defaultForSlots is not defined', () => {
it('imp.ext.ae should be removed if fledge is not enabled', () => {
describe('imp.ext.ae', () => {
it('should be removed if fledge is not enabled', () => {
const imp = {ext: {ae: 1}};
setImpExtAe(imp, {}, {bidderRequest: {}});
expect(imp.ext.ae).to.not.exist;
})
it('imp.ext.ae should be left intact if fledge is enabled', () => {
const imp = {ext: {ae: 2}};
it('should be left intact if fledge is enabled', () => {
const imp = {ext: {ae: false}};
setImpExtAe(imp, {}, {bidderRequest: {fledgeEnabled: true}});
expect(imp.ext.ae).to.equal(2);
expect(imp.ext.ae).to.equal(false);
});
});
describe('parseExtPrebidFledge', () => {
Expand Down

0 comments on commit 934f5a9

Please sign in to comment.