Skip to content

Commit

Permalink
spreading ortb2: user & site props
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrj-rtbh committed Aug 25, 2022
1 parent 257b37e commit e0db59f
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions modules/rtbhouseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ export const spec = {
? bidderRequest.gdprConsent.consentString.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '') : '';
const gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0;
request.regs = {ext: {gdpr: gdpr}};
request.user = {ext: {consent: consentStr, data: bidderRequest.ortb2}};
request.user = {ext: {consent: consentStr}};
}
if (validBidRequests[0].schain) {
const schain = mapSchain(validBidRequests[0].schain);
if (schain) {
request.ext = {
schain: schain,
}
};
}
}

if (validBidRequests[0].userIdAsEids) {
const eids = { eids: validBidRequests[0].userIdAsEids };
if (request.user && request.user.ext) {
Expand All @@ -80,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 @@ -427,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 e0db59f

Please sign in to comment.