Skip to content

Commit

Permalink
33Across Bid Adapter: add support for User ID modules (#6554)
Browse files Browse the repository at this point in the history
  • Loading branch information
curlyblueeagle authored and idettman committed May 21, 2021
1 parent 159e13d commit 9e67aa8
Show file tree
Hide file tree
Showing 2 changed files with 242 additions and 79 deletions.
61 changes: 44 additions & 17 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,36 @@ function _createServerRequest({bidRequest, gdprConsent = {}, uspConsent, pageUrl
// therefore in ad targetting process
ttxRequest.id = bidRequest.bidId;

// Set GDPR related fields
ttxRequest.user = {
ext: {
consent: gdprConsent.consentString
}
};
ttxRequest.regs = {
ext: {
gdpr: (gdprConsent.gdprApplies === true) ? 1 : 0,
us_privacy: uspConsent || null
}
};
if (gdprConsent.consentString) {
ttxRequest.user = setExtension(
ttxRequest.user,
'consent',
gdprConsent.consentString
)
}

if (Array.isArray(bidRequest.userIdAsEids) && bidRequest.userIdAsEids.length > 0) {
ttxRequest.user = setExtension(
ttxRequest.user,
'eids',
bidRequest.userIdAsEids
)
}

ttxRequest.regs = setExtension(
ttxRequest.regs,
'gdpr',
Number(gdprConsent.gdprApplies)
);

if (uspConsent) {
ttxRequest.regs = setExtension(
ttxRequest.regs,
'us_privacy',
uspConsent
)
}

ttxRequest.ext = {
ttx: {
prebidStartedAt: Date.now(),
Expand All @@ -217,11 +235,11 @@ function _createServerRequest({bidRequest, gdprConsent = {}, uspConsent, pageUrl
};

if (bidRequest.schain) {
ttxRequest.source = {
ext: {
schain: bidRequest.schain
}
}
ttxRequest.source = setExtension(
ttxRequest.source,
'schain',
bidRequest.schain
)
}

// Finally, set the openRTB 'test' param if this is to be a test bid
Expand Down Expand Up @@ -250,6 +268,15 @@ function _createServerRequest({bidRequest, gdprConsent = {}, uspConsent, pageUrl
}
}

// BUILD REQUESTS: SET EXTENSIONS
function setExtension(obj = {}, key, value) {
return Object.assign({}, obj, {
ext: Object.assign({}, obj.ext, {
[key]: value
})
});
}

// BUILD REQUESTS: SIZE INFERENCE
function _transformSizes(sizes) {
if (utils.isArray(sizes) && sizes.length === 2 && !utils.isArray(sizes[0])) {
Expand Down
Loading

0 comments on commit 9e67aa8

Please sign in to comment.