Skip to content

Commit 9e67aa8

Browse files
curlyblueeagleidettman
authored and
idettman
committed
33Across Bid Adapter: add support for User ID modules (#6554)
1 parent 159e13d commit 9e67aa8

File tree

2 files changed

+242
-79
lines changed

2 files changed

+242
-79
lines changed

modules/33acrossBidAdapter.js

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,36 @@ function _createServerRequest({bidRequest, gdprConsent = {}, uspConsent, pageUrl
194194
// therefore in ad targetting process
195195
ttxRequest.id = bidRequest.bidId;
196196

197-
// Set GDPR related fields
198-
ttxRequest.user = {
199-
ext: {
200-
consent: gdprConsent.consentString
201-
}
202-
};
203-
ttxRequest.regs = {
204-
ext: {
205-
gdpr: (gdprConsent.gdprApplies === true) ? 1 : 0,
206-
us_privacy: uspConsent || null
207-
}
208-
};
197+
if (gdprConsent.consentString) {
198+
ttxRequest.user = setExtension(
199+
ttxRequest.user,
200+
'consent',
201+
gdprConsent.consentString
202+
)
203+
}
204+
205+
if (Array.isArray(bidRequest.userIdAsEids) && bidRequest.userIdAsEids.length > 0) {
206+
ttxRequest.user = setExtension(
207+
ttxRequest.user,
208+
'eids',
209+
bidRequest.userIdAsEids
210+
)
211+
}
212+
213+
ttxRequest.regs = setExtension(
214+
ttxRequest.regs,
215+
'gdpr',
216+
Number(gdprConsent.gdprApplies)
217+
);
218+
219+
if (uspConsent) {
220+
ttxRequest.regs = setExtension(
221+
ttxRequest.regs,
222+
'us_privacy',
223+
uspConsent
224+
)
225+
}
226+
209227
ttxRequest.ext = {
210228
ttx: {
211229
prebidStartedAt: Date.now(),
@@ -217,11 +235,11 @@ function _createServerRequest({bidRequest, gdprConsent = {}, uspConsent, pageUrl
217235
};
218236

219237
if (bidRequest.schain) {
220-
ttxRequest.source = {
221-
ext: {
222-
schain: bidRequest.schain
223-
}
224-
}
238+
ttxRequest.source = setExtension(
239+
ttxRequest.source,
240+
'schain',
241+
bidRequest.schain
242+
)
225243
}
226244

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

271+
// BUILD REQUESTS: SET EXTENSIONS
272+
function setExtension(obj = {}, key, value) {
273+
return Object.assign({}, obj, {
274+
ext: Object.assign({}, obj.ext, {
275+
[key]: value
276+
})
277+
});
278+
}
279+
253280
// BUILD REQUESTS: SIZE INFERENCE
254281
function _transformSizes(sizes) {
255282
if (utils.isArray(sizes) && sizes.length === 2 && !utils.isArray(sizes[0])) {

0 commit comments

Comments
 (0)