Skip to content

Commit

Permalink
refactors code for userIds; updates userId tests (#29) (prebid#11298)
Browse files Browse the repository at this point in the history
Co-authored-by: “Nick <“nick.llerandi”@kargo.com>
  • Loading branch information
nickllerandi and “Nick authored Apr 9, 2024
1 parent ca5162b commit db0b1bd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 20 deletions.
41 changes: 21 additions & 20 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,56 +359,57 @@ function getUserIds(tdidAdapter, usp, gdpr, eids, gpp) {
crbIDs: crb.syncIds || {}
};

// Pull Trade Desk ID from adapter
if (tdidAdapter) {
userIds.tdID = tdidAdapter;
}

// Pull Trade Desk ID from our storage
// Pull Trade Desk ID
if (!tdidAdapter && crb.tdID) {
userIds.tdID = crb.tdID;
} else if (tdidAdapter) {
userIds.tdID = tdidAdapter;
}

// USP
if (usp) {
userIds.usp = usp;
}

try {
if (gdpr) {
userIds['gdpr'] = {
consent: gdpr.consentString || '',
applies: !!gdpr.gdprApplies,
}
}
} catch (e) {
// GDPR
if (gdpr) {
userIds.gdpr = {
consent: gdpr.consentString || '',
applies: !!gdpr.gdprApplies,
};
}

// Kargo ID
if (crb.lexId != null) {
userIds.kargoID = crb.lexId;
}

// Client ID
if (crb.clientId != null) {
userIds.clientID = crb.clientId;
}

// Opt Out
if (crb.optOut != null) {
userIds.optOut = crb.optOut;
}

// User ID Sub-Modules (userIdAsEids)
if (eids != null) {
userIds.sharedIDEids = eids;
}

// GPP
if (gpp) {
const parsedGPP = {}
if (gpp && gpp.consentString) {
parsedGPP.gppString = gpp.consentString
const parsedGPP = {};
if (gpp.consentString) {
parsedGPP.gppString = gpp.consentString;
}
if (gpp && gpp.applicableSections) {
parsedGPP.applicableSections = gpp.applicableSections
if (gpp.applicableSections) {
parsedGPP.applicableSections = gpp.applicableSections;
}
if (!isEmpty(parsedGPP)) {
userIds.gpp = parsedGPP
userIds.gpp = parsedGPP;
}
}

Expand Down
36 changes: 36 additions & 0 deletions test/spec/modules/kargoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ describe('kargo adapter tests', function () {
}
}
]
},
{
'source': 'adquery.io',
'uids': [
{
'id': 'adqueryId-123',
'atype': 1
}
]
},
{
'source': 'criteo.com',
'uids': [
{
'id': 'criteoId-456',
'atype': 1
}
]
}
],
floorData: {
Expand Down Expand Up @@ -582,6 +600,24 @@ describe('kargo adapter tests', function () {
}
}
]
},
{
source: 'adquery.io',
uids: [
{
id: 'adqueryId-123',
atype: 1
}
]
},
{
source: 'criteo.com',
uids: [
{
id: 'criteoId-456',
atype: 1
}
]
}
],
data: [
Expand Down

0 comments on commit db0b1bd

Please sign in to comment.