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

Yieldmo Adapter: Add support for structured user agent #9380

Merged
Show file tree
Hide file tree
Changes from 5 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: 11 additions & 1 deletion modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
isStr,
logError,
parseQueryStringParameters,
parseUrl
parseUrl,
pick
} from '../src/utils.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
Expand Down Expand Up @@ -515,6 +516,15 @@ function openRtbDevice(bidRequest) {
ua: navigator.userAgent,
language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage),
};
// Add User Agent Client hints.
const uaClientHints = deepAccess(bidRequest, 'ortb2Imp.device.sua');
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is under bidderRequest.ortb2.device.sua. Also, why not just merge in everything from bidderRequest.ortb2.device, or even just the whole ortb2 object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't want to include extra fields which are not going to be used.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The tradeoff is some unused fields - or extra code (and slower page loads) for the pub, and extra work for you on every new feature.

But beside that, device is not under bidRequest.ortb2Imp - it's under bidderRequest.ortb2. (Sorry for repeating myself, I'm not sure I made it clear enough).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are trying to figure out if there is any downside in passing entire ortb2 object but now I have made changes to pass entire device object. Sorry for not understanding it earlier, Thank you.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you find a roadblock (beside not wanting to change things until you need to, which I do think is a legitimate reason), please let us know - since currently that's the direction we are recommending.

I am aware of one case of an exchange that would not accept fields it didn't know about (#9250) - the ORTB 2.6 spec requires endpoints to ignore such fields, so in the long term that should not be a problem (but it may be for you at the moment, so beware).

You would also give up the opportunity to do validation on publisher inputs, but I don't think each adapter doing independent validation is desirable - it's code duplication in the best case scenario, and in practice I think it would be a major source of confusion if the same configuration is interpreted differently by different exchanges.

let sua = null;
if (uaClientHints) {
sua = pick(uaClientHints, ['browsers', 'platform', 'mobile', 'model']);
}
if (sua) {
deepSetValue(deviceObj, 'sua', sua);
}
return deviceObj;
}

Expand Down
57 changes: 57 additions & 0 deletions test/spec/modules/yieldmoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,63 @@ describe('YieldmoAdapter', function () {
};
expect(buildAndGetData([mockVideoBid({...params})]).user.eids).to.eql(params.fakeUserIdAsEids);
});
it('should add device sua info to payload if available', function () {
let videoBid = mockVideoBid({ ortb2Imp: {
device: {
sua: {
platform: {
brand: 'macOS',
version: [ '12', '4', '0' ]
},
browsers: [
{
brand: 'Chromium',
version: [ '106', '0', '5249', '119' ]
},
{
brand: 'Google Chrome',
version: [ '106', '0', '5249', '119' ]
},
{
brand: 'Not;A=Brand',
version: [ '99', '0', '0', '0' ]
}
],
mobile: 0,
model: '',
bitness: '64',
architecture: 'x86'
}
}
}});
const payload = buildAndGetData([videoBid]);
expect(payload.device.sua).to.exist;
expect(payload.device.sua).to.deep.equal({
platform: {
brand: 'macOS',
version: [ '12', '4', '0' ]
},
browsers: [
{
brand: 'Chromium',
version: [ '106', '0', '5249', '119' ]
},
{
brand: 'Google Chrome',
version: [ '106', '0', '5249', '119' ]
},
{
brand: 'Not;A=Brand',
version: [ '99', '0', '0', '0' ]
}
],
mobile: 0,
model: ''
}
);
videoBid = buildAndGetData([mockVideoBid()]);
expect(videoBid.device.sua).to.not.exist;
});
});
});

Expand Down