Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gpp update #20

Merged
merged 9 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const SUA_ATTRIBUTES = [

const CERBERUS = Object.freeze({
KEY: 'krg_crb',
SYNC_URL: 'https://crb.kargo.com/api/v1/initsyncrnd/{UUID}?seed={SEED}&idx={INDEX}&gdpr={GDPR}&gdpr_consent={GDPR_CONSENT}&us_privacy={US_PRIVACY}',
SYNC_URL: 'https://crb.kargo.com/api/v1/initsyncrnd/{UUID}?seed={SEED}&idx={INDEX}&gdpr={GDPR}&gdpr_consent={GDPR_CONSENT}&us_privacy={US_PRIVACY}&gpp={GPP_STRING}&gpp_sid={GPP_SID}',
SYNC_COUNT: 5,
PAGE_VIEW_ID: 'pageViewId',
PAGE_VIEW_TIMESTAMP: 'pageViewTimestamp',
Expand Down Expand Up @@ -94,7 +94,7 @@ function buildRequests(validBidRequests, bidderRequest) {
]
},
imp: impressions,
user: getUserIds(tdidAdapter, bidderRequest.uspConsent, bidderRequest.gdprConsent, firstBidRequest.userIdAsEids),
user: getUserIds(tdidAdapter, bidderRequest.uspConsent, bidderRequest.gdprConsent, firstBidRequest.userIdAsEids, bidderRequest.gppConsent),
});

const reqCount = getRequestCount()
Expand Down Expand Up @@ -229,19 +229,17 @@ function interpretResponse(response, bidRequest) {
return bidResponses;
}

function getUserSyncs(syncOptions, responses, gdprConsent, usPrivacy) {
function getUserSyncs(syncOptions, responses, gdprConsent, usPrivacy, gppConsent) {
const syncs = [];
const seed = _generateRandomUUID();
const clientId = getClientId();

var gdpr = (gdprConsent && gdprConsent.gdprApplies) ? 1 : 0;
var gdprConsentString = (gdprConsent && gdprConsent.consentString) ? gdprConsent.consentString : '';
<<<<<<< HEAD
=======

var gppString = (gppConsent && gppConsent.consentString) ? gppConsent.consentString : '';
var gppApplicableSections = (gppConsent && gppConsent.applicableSections && Array.isArray(gppConsent.applicableSections)) ? gppConsent.applicableSections.join(',') : '';

>>>>>>> f703768cc (Linting)
// don't sync if opted out via usPrivacy
if (typeof usPrivacy == 'string' && usPrivacy.length == 4 && usPrivacy[0] == 1 && usPrivacy[2] == 'Y') {
return syncs;
Expand All @@ -256,6 +254,8 @@ function getUserSyncs(syncOptions, responses, gdprConsent, usPrivacy) {
.replace('{GDPR}', gdpr)
.replace('{GDPR_CONSENT}', gdprConsentString)
.replace('{US_PRIVACY}', usPrivacy || '')
.replace('{GPP_STRING}', gppString)
.replace('{GPP_SID}', gppApplicableSections)
});
}
}
Expand Down Expand Up @@ -334,7 +334,7 @@ function getLocalStorageSafely(key) {
}
}

function getUserIds(tdidAdapter, usp, gdpr, eids) {
function getUserIds(tdidAdapter, usp, gdpr, eids, gpp) {
const crb = spec._getCrb();
const userIds = {
crbIDs: crb.syncIds || {}
Expand Down Expand Up @@ -380,6 +380,19 @@ function getUserIds(tdidAdapter, usp, gdpr, eids) {
userIds.sharedIDEids = eids;
}

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

return userIds;
}

Expand Down
Loading