Skip to content

Commit

Permalink
Merge pull request #1 from rtbh-lotani/piotrj
Browse files Browse the repository at this point in the history
structured user agent - browsers.brands
  • Loading branch information
piotrj-rtbh authored Jul 29, 2022
2 parents b59ea92 + 541f33f commit 21ee5a8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions modules/rtbhouseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export const spec = {
}
}

const clientHints = getClientHints();
if (clientHints) {
const { device = {} } = request;
const { sua = {} } = device;
device.sua = { ...sua, ...clientHints };
request.device = device;
}

return {
method: 'POST',
url: 'https://' + validBidRequests[0].params.region + '.' + ENDPOINT_URL,
Expand Down Expand Up @@ -420,3 +428,19 @@ function interpretNativeAd(adm) {
});
return result;
}

function getClientHints() {
let clientHints = {};
const { userAgentData = {} } = navigator;

const { brands = [] } = userAgentData;
if (brands.length > 0) {
clientHints.browsers = brands;
}

if(Object.keys(clientHints).length === 0) {
clientHints = null;
}

return clientHints;
}

0 comments on commit 21ee5a8

Please sign in to comment.