Skip to content

Commit

Permalink
Merge pull request #3 from rtbh-lotani/feature/added-sda
Browse files Browse the repository at this point in the history
RTB House Bid Adapter: Add SUA and SDA support based on ortb2 object
  • Loading branch information
rtbh-lotani authored Aug 29, 2022
2 parents 1c69c76 + e7adb7d commit 04de645
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions modules/rtbhouseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,28 @@ export const spec = {
}
}

const clientHints = getClientHints();
if (clientHints) {
const { device = {} } = request;
const { sua = {} } = device;
device.sua = { ...sua, ...clientHints };
request.device = device;
const ortb2Params = bidderRequest && bidderRequest.ortb2;
if (ortb2Params?.user) {
request.user = {
...request.user,
...(ortb2Params.user.data && {
data: { ...request.user?.data, ...ortb2Params.user.data },
}),
...(ortb2Params.user.ext && {
ext: { ...request.user?.ext, ...ortb2Params.user.ext },
}),
};
}
if (ortb2Params?.site) {
request.site = {
...request.site,
...(ortb2Params.site.content && {
content: { ...request.site?.content, ...ortb2Params.site.content },
}),
...(ortb2Params.site.ext && {
ext: { ...request.site?.ext, ...ortb2Params.site.ext },
}),
};
}

return {
Expand Down Expand Up @@ -428,19 +444,3 @@ 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 04de645

Please sign in to comment.