Skip to content

Commit db0b1bd

Browse files
nickllerandi“Nick
and
“Nick
authored
refactors code for userIds; updates userId tests (#29) (prebid#11298)
Co-authored-by: “Nick <“nick.llerandi”@kargo.com>
1 parent ca5162b commit db0b1bd

File tree

2 files changed

+57
-20
lines changed

2 files changed

+57
-20
lines changed

modules/kargoBidAdapter.js

+21-20
Original file line numberDiff line numberDiff line change
@@ -359,56 +359,57 @@ function getUserIds(tdidAdapter, usp, gdpr, eids, gpp) {
359359
crbIDs: crb.syncIds || {}
360360
};
361361

362-
// Pull Trade Desk ID from adapter
363-
if (tdidAdapter) {
364-
userIds.tdID = tdidAdapter;
365-
}
366-
367-
// Pull Trade Desk ID from our storage
362+
// Pull Trade Desk ID
368363
if (!tdidAdapter && crb.tdID) {
369364
userIds.tdID = crb.tdID;
365+
} else if (tdidAdapter) {
366+
userIds.tdID = tdidAdapter;
370367
}
371368

369+
// USP
372370
if (usp) {
373371
userIds.usp = usp;
374372
}
375373

376-
try {
377-
if (gdpr) {
378-
userIds['gdpr'] = {
379-
consent: gdpr.consentString || '',
380-
applies: !!gdpr.gdprApplies,
381-
}
382-
}
383-
} catch (e) {
374+
// GDPR
375+
if (gdpr) {
376+
userIds.gdpr = {
377+
consent: gdpr.consentString || '',
378+
applies: !!gdpr.gdprApplies,
379+
};
384380
}
385381

382+
// Kargo ID
386383
if (crb.lexId != null) {
387384
userIds.kargoID = crb.lexId;
388385
}
389386

387+
// Client ID
390388
if (crb.clientId != null) {
391389
userIds.clientID = crb.clientId;
392390
}
393391

392+
// Opt Out
394393
if (crb.optOut != null) {
395394
userIds.optOut = crb.optOut;
396395
}
397396

397+
// User ID Sub-Modules (userIdAsEids)
398398
if (eids != null) {
399399
userIds.sharedIDEids = eids;
400400
}
401401

402+
// GPP
402403
if (gpp) {
403-
const parsedGPP = {}
404-
if (gpp && gpp.consentString) {
405-
parsedGPP.gppString = gpp.consentString
404+
const parsedGPP = {};
405+
if (gpp.consentString) {
406+
parsedGPP.gppString = gpp.consentString;
406407
}
407-
if (gpp && gpp.applicableSections) {
408-
parsedGPP.applicableSections = gpp.applicableSections
408+
if (gpp.applicableSections) {
409+
parsedGPP.applicableSections = gpp.applicableSections;
409410
}
410411
if (!isEmpty(parsedGPP)) {
411-
userIds.gpp = parsedGPP
412+
userIds.gpp = parsedGPP;
412413
}
413414
}
414415

test/spec/modules/kargoBidAdapter_spec.js

+36
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@ describe('kargo adapter tests', function () {
112112
}
113113
}
114114
]
115+
},
116+
{
117+
'source': 'adquery.io',
118+
'uids': [
119+
{
120+
'id': 'adqueryId-123',
121+
'atype': 1
122+
}
123+
]
124+
},
125+
{
126+
'source': 'criteo.com',
127+
'uids': [
128+
{
129+
'id': 'criteoId-456',
130+
'atype': 1
131+
}
132+
]
115133
}
116134
],
117135
floorData: {
@@ -582,6 +600,24 @@ describe('kargo adapter tests', function () {
582600
}
583601
}
584602
]
603+
},
604+
{
605+
source: 'adquery.io',
606+
uids: [
607+
{
608+
id: 'adqueryId-123',
609+
atype: 1
610+
}
611+
]
612+
},
613+
{
614+
source: 'criteo.com',
615+
uids: [
616+
{
617+
id: 'criteoId-456',
618+
atype: 1
619+
}
620+
]
585621
}
586622
],
587623
data: [

0 commit comments

Comments
 (0)