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 supporting top level app/site/device FPD config #11522

Merged
merged 2 commits 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: 0 additions & 12 deletions src/fpd/enrichment.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const enrichFPD = hook('sync', (fpd) => {
return GreedyPromise.all(promArr)
.then(([ortb2, sua, cdep]) => {
const ri = dep.getRefererInfo();
mergeLegacySetConfigs(ortb2);
Object.entries(ENRICHMENTS).forEach(([section, getEnrichments]) => {
const data = getEnrichments(ortb2, ri);
if (data && Object.keys(data).length > 0) {
Expand Down Expand Up @@ -64,17 +63,6 @@ export const enrichFPD = hook('sync', (fpd) => {
});
});

function mergeLegacySetConfigs(ortb2) {
// merge in values from "legacy" setConfig({app, site, device})
// TODO: deprecate these eventually
['app', 'site', 'device'].forEach(prop => {
const cfg = config.getConfig(prop);
if (cfg != null) {
ortb2[prop] = mergeDeep({}, cfg, ortb2[prop]);
}
})
}

function winFallback(fn) {
try {
return fn(dep.getWindowTop());
Expand Down
55 changes: 0 additions & 55 deletions test/spec/fpd/enrichment_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,26 +147,6 @@ describe('FPD enrichment', () => {
expect(ortb2.site.publisher.domain).to.eql('pub.com');
});
});

it('respects config set through setConfig({site})', () => {
sandbox.stub(dep, 'getRefererInfo').callsFake(() => ({
page: 'www.example.com',
ref: 'referrer.com',
}));
config.setConfig({
site: {
ref: 'override.com',
priority: 'lower'
}
});
return fpd({site: {priority: 'highest'}}).then(ortb2 => {
sinon.assert.match(ortb2.site, {
page: 'www.example.com',
ref: 'override.com',
priority: 'highest'
})
})
})
});

describe('device', () => {
Expand Down Expand Up @@ -214,44 +194,9 @@ describe('FPD enrichment', () => {
expect(ortb2.device.language).to.eql('lang');
})
});

it('respects setConfig({device})', () => {
win.navigator.userAgent = 'ua';
win.navigator.language = 'lang';
config.setConfig({
device: {
language: 'override',
priority: 'lower'
}
});
return fpd({device: {priority: 'highest'}}).then(ortb2 => {
sinon.assert.match(ortb2.device, {
language: 'override',
priority: 'highest',
ua: 'ua'
})
})
});
});
});

describe('app', () => {
it('respects setConfig({app})', () => {
config.setConfig({
app: {
priority: 'lower',
prop: 'value'
}
});
return fpd({app: {priority: 'highest'}}).then(ortb2 => {
sinon.assert.match(ortb2.app, {
priority: 'highest',
prop: 'value'
})
})
})
})

describe('regs', () => {
describe('gpc', () => {
let win;
Expand Down
File renamed without changes.
33 changes: 0 additions & 33 deletions test/spec/modules/improvedigitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,32 +682,9 @@ describe('Improve Digital Adapter Tests', function () {
expect(payload.app.content).does.exist.and.equal('XYZ');
});

it('should not set site when app is defined in CONFIG', function () {
getConfigStub = sinon.stub(config, 'getConfig');
getConfigStub.withArgs('app').returns({ content: 'XYZ' });
let request = spec.buildRequests([simpleBidRequest], syncAddFPDToBidderRequest(bidderRequest))[0];
let payload = JSON.parse(request.data);
expect(payload.site).does.not.exist;
expect(payload.app).does.exist;
expect(payload.app.content).does.exist.and.equal('XYZ');
});

it('should set correct site params', function () {
getConfigStub = sinon.stub(config, 'getConfig');
getConfigStub.withArgs('site').returns({
content: 'XYZ',
page: 'https://improveditigal.com/',
domain: 'improveditigal.com'
});
let request = spec.buildRequests([simpleBidRequest], syncAddFPDToBidderRequest(bidderRequestReferrer))[0];
let payload = JSON.parse(request.data);
expect(payload.site.content).does.exist.and.equal('XYZ');
expect(payload.site.page).does.exist.and.equal('https://improveditigal.com/');
expect(payload.site.domain).does.exist.and.equal('improveditigal.com');
getConfigStub.reset();

request = spec.buildRequests([simpleBidRequest], syncAddFPDToBidderRequest(bidderRequestReferrer))[0];
payload = JSON.parse(request.data);
expect(payload.site.content).does.not.exist;
expect(payload.site.page).does.exist.and.equal('https://blah.com/test.html');
expect(payload.site.domain).does.exist.and.equal('blah.com');
Expand All @@ -720,16 +697,6 @@ describe('Improve Digital Adapter Tests', function () {
expect(payload.site.domain).does.exist.and.equal('blah.com');
});

it('should set site when app not available', function () {
getConfigStub = sinon.stub(config, 'getConfig');
getConfigStub.withArgs('app').returns(undefined);
getConfigStub.withArgs('site').returns({});
let request = spec.buildRequests([simpleBidRequest], syncAddFPDToBidderRequest(bidderRequest))[0];
let payload = JSON.parse(request.data);
expect(payload.site).does.exist;
expect(payload.app).does.not.exist;
});

it('should call basic ads endpoint when no consent for purpose 1', function () {
const consent = deepClone(gdprConsent);
deepSetValue(consent, 'vendorData.purpose.consents.1', false);
Expand Down
134 changes: 83 additions & 51 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1021,12 +1021,18 @@ describe('S2S Adapter', function () {
it('adds device and app objects to request', function () {
const _config = {
s2sConfig: CONFIG,
device: { ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC' },
app: { bundle: 'com.test.app' },
};

config.setConfig(_config);
adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax);
const s2sreq = addFpdEnrichmentsToS2SRequest({
...REQUEST,
ortb2Fragments: {
global: {
device: { ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC' },
app: { bundle: 'com.test.app' },
}
}
}, BID_REQUESTS)
adapter.callBids(s2sreq, BID_REQUESTS, addBidResponse, done, ajax);
const requestBid = JSON.parse(server.requests[0].requestBody);
sinon.assert.match(requestBid.device, {
ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC',
Expand All @@ -1045,15 +1051,20 @@ describe('S2S Adapter', function () {
p1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'
}
});

const _config = {
s2sConfig: s2sConfig,
device: { ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC' },
app: { bundle: 'com.test.app' },
};

config.setConfig(_config);
adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax);
const s2sReq = addFpdEnrichmentsToS2SRequest({
...REQUEST,
ortb2Fragments: {
global: {
device: { ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC' },
app: { bundle: 'com.test.app' },
}
}
}, BID_REQUESTS)
adapter.callBids(s2sReq, BID_REQUESTS, addBidResponse, done, ajax);
const requestBid = JSON.parse(server.requests[0].requestBody);
sinon.assert.match(requestBid.device, {
ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC',
Expand Down Expand Up @@ -1412,20 +1423,14 @@ describe('S2S Adapter', function () {
it('adds device.w and device.h even if the config lacks a device object', function () {
const _config = {
s2sConfig: CONFIG,
app: { bundle: 'com.test.app' },
};

config.setConfig(_config);
adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax);
const requestBid = JSON.parse(server.requests[0].requestBody);
sinon.assert.match(requestBid.device, {
w: window.innerWidth,
h: window.innerHeight
})
sinon.assert.match(requestBid.app, {
bundle: 'com.test.app',
publisher: { 'id': '1' }
});
expect(requestBid.imp[0].native.ver).to.equal('1.2');
});

Expand Down Expand Up @@ -1509,19 +1514,26 @@ describe('S2S Adapter', function () {
it('adds site if app is not present', function () {
const _config = {
s2sConfig: CONFIG,
site: {
publisher: {
id: '1234',
domain: 'test.com'
},
content: {
language: 'en'
}
}
};

config.setConfig(_config);
adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax);
const s2sReq = addFpdEnrichmentsToS2SRequest({
...REQUEST,
ortb2Fragments: {
global: {
site: {
publisher: {
id: '1234',
domain: 'test.com'
},
content: {
language: 'en'
}
}
}
}
}, BID_REQUESTS);
adapter.callBids(s2sReq, BID_REQUESTS, addBidResponse, done, ajax);
const requestBid = JSON.parse(server.requests[0].requestBody);
expect(requestBid.site).to.exist.and.to.be.a('object');
expect(requestBid.site.publisher).to.exist.and.to.be.a('object');
Expand All @@ -1546,23 +1558,31 @@ describe('S2S Adapter', function () {
it('site should not be present when app is present', function () {
osazos marked this conversation as resolved.
Show resolved Hide resolved
const _config = {
s2sConfig: CONFIG,
app: { bundle: 'com.test.app' },
site: {
publisher: {
id: '1234',
domain: 'test.com'
},
content: {
language: 'en'
}
}
};

config.setConfig(_config);
adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax);

const s2sReq = addFpdEnrichmentsToS2SRequest({
...REQUEST,
ortb2Fragments: {
global: {
app: { bundle: 'com.test.app' },
site: {
publisher: {
id: '1234',
domain: 'test.com'
},
content: {
language: 'en'
}
}
}
}
}, BID_REQUESTS)
adapter.callBids(s2sReq, BID_REQUESTS, addBidResponse, done, ajax);
const requestBid = JSON.parse(server.requests[0].requestBody);
expect(requestBid.site).to.not.exist;
expect(requestBid.app).to.exist.and.to.be.a('object');
expect(requestBid.app.bundle).to.eql('com.test.app');
});

it('adds appnexus aliases to request', function () {
Expand Down Expand Up @@ -1976,15 +1996,21 @@ describe('S2S Adapter', function () {
it('and overrides publisher and page', function () {
config.setConfig({
s2sConfig: s2sConfig,
site: {
domain: 'nytimes.com',
page: 'http://www.nytimes.com',
publisher: { id: '2' }
},
device: device
});

adapter.callBids(addFpdEnrichmentsToS2SRequest(s2sBidRequest, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax);
const s2sReq = addFpdEnrichmentsToS2SRequest({
...s2sBidRequest,
ortb2Fragments: {
global: {
site: {
domain: 'nytimes.com',
page: 'http://www.nytimes.com',
publisher: { id: '2' }
},
device,
}
}
}, BID_REQUESTS);
adapter.callBids(s2sReq, BID_REQUESTS, addBidResponse, done, ajax);
const requestBid = JSON.parse(server.requests[0].requestBody);

expect(requestBid.site).to.exist.and.to.be.a('object');
Expand All @@ -1997,13 +2023,19 @@ describe('S2S Adapter', function () {
it('and merges domain and page with the config site value', function () {
config.setConfig({
s2sConfig: s2sConfig,
site: {
foo: 'bar'
},
device: device
});

adapter.callBids(addFpdEnrichmentsToS2SRequest(s2sBidRequest, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax);
const s2sReq = addFpdEnrichmentsToS2SRequest({
...s2sBidRequest,
ortb2Fragments: {
global: {
site: {
foo: 'bar'
},
device: device
}
}
}, BID_REQUESTS);
adapter.callBids(s2sReq, BID_REQUESTS, addBidResponse, done, ajax);

const requestBid = JSON.parse(server.requests[0].requestBody);
expect(requestBid.site).to.exist.and.to.be.a('object');
Expand Down