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

PS bid adapter update to copy site object from config #5083

Merged
merged 3 commits into from
Apr 21, 2020
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
8 changes: 5 additions & 3 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,12 @@ function _appendSiteAppDevice(request, pageUrl) {
request.app = config.getConfig('app');
request.app.publisher = {id: _s2sConfig.accountId}
} else {
request.site = {
publisher: { id: _s2sConfig.accountId },
page: pageUrl
request.site = {};
if (typeof config.getConfig('site') === 'object') {
request.site = config.getConfig('site');
}
utils.deepSetValue(request.site, 'publisher.id', _s2sConfig.accountId);
request.site.page = pageUrl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if someone sets site in setConfig, we want to use it.

But we want to overwrite publisher and page no matter what?

Here is what the publisher object specifies in openRTB protocol:

image

So if we did:

pbjs.setConfig({
   site: {
      ...
      publisher: {
         id: 'some id'
         domain: 'prebid.org'
         ...
      }
});

Then we would basically not include the other keys in the user defined publisher object.

Maybe it makes more sense to use utils.deepSet in order to set the id of publisher, so that if publisher already exists we do not overwrite the entire thing but just the id key?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for this as well

}
if (typeof config.getConfig('device') === 'object') {
request.device = config.getConfig('device');
Expand Down
23 changes: 23 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -899,14 +899,37 @@ describe('S2S Adapter', function () {

const _config = {
s2sConfig: s2sConfig,
site: {
publisher: {
id: '1234',
domain: 'test.com'
},
content: {
language: 'en'
}
}
};

config.setConfig(_config);
adapter.callBids(REQUEST, 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');
expect(requestBid.site.publisher.id).to.exist.and.to.be.a('string');
expect(requestBid.site.publisher.domain).to.exist.and.to.be.a('string');
expect(requestBid.site.page).to.exist.and.to.be.a('string');
expect(requestBid.site.content).to.exist.and.to.be.a('object');
expect(requestBid.site.content.language).to.exist.and.to.be.a('string');
expect(requestBid.site).to.deep.equal({
publisher: {
id: '1',
domain: 'test.com'
},
content: {
language: 'en'
},
page: 'http://mytestpage.com'
});
});

it('adds appnexus aliases to request', function () {
Expand Down