-
Notifications
You must be signed in to change notification settings - Fork 2.2k
SharedId & PubcommonId: CCPA and COPPA support #6632
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import * as utils from '../src/utils.js'; | |
import {submodule} from '../src/hook.js'; | ||
import {getStorageManager} from '../src/storageManager.js'; | ||
import {ajax} from '../src/ajax.js'; | ||
import { uspDataHandler, coppaDataHandler } from '../src/adapterManager.js'; | ||
|
||
const PUB_COMMON_ID = 'PublisherCommonId'; | ||
const MODULE_NAME = 'pubCommonId'; | ||
|
@@ -142,9 +143,18 @@ function handleResponse(pubcid, callback, config) { | |
* @return {string} | ||
*/ | ||
function sharedIdUrl(consentData) { | ||
if (!consentData || typeof consentData.gdprApplies !== 'boolean' || !consentData.gdprApplies) return SHAREDID_URL; | ||
|
||
return `${SHAREDID_URL}?gdpr=1&gdpr_consent=${consentData.consentString}` | ||
const usPrivacyString = uspDataHandler.getConsentData(); | ||
let sharedIdUrl = SHAREDID_URL; | ||
if (usPrivacyString && typeof usPrivacyString === 'string') { | ||
sharedIdUrl = `${SHAREDID_URL}?us_privacy=${usPrivacyString}`; | ||
} | ||
if (!consentData || typeof consentData.gdprApplies !== 'boolean' || !consentData.gdprApplies) return sharedIdUrl; | ||
if (usPrivacyString) { | ||
sharedIdUrl = `${sharedIdUrl}&gdpr=1&gdpr_consent=${consentData.consentString}` | ||
return sharedIdUrl; | ||
} | ||
sharedIdUrl = `${SHAREDID_URL}?gdpr=1&gdpr_consent=${consentData.consentString}`; | ||
return sharedIdUrl | ||
} | ||
|
||
/** | ||
|
@@ -223,6 +233,11 @@ export const pubCommonIdSubmodule = { | |
* @returns {IdResponse} | ||
*/ | ||
getId: function (config = {}, consentData, storedId) { | ||
const coppa = coppaDataHandler.getCoppa(); | ||
if (coppa) { | ||
utils.logInfo('PubCommonId: coppa not provided, exiting PubCommonId'); | ||
return; | ||
} | ||
const {params: {create = true, pixelUrl, enableSharedId = SHAREDID_DEFAULT_STATE} = {}} = config; | ||
let newId = storedId; | ||
if (!newId) { | ||
|
@@ -263,6 +278,11 @@ export const pubCommonIdSubmodule = { | |
* @returns {IdResponse|undefined} | ||
*/ | ||
extendId: function(config = {}, consentData, storedId) { | ||
const coppa = coppaDataHandler.getCoppa(); | ||
if (coppa) { | ||
utils.logInfo('PubCommonId: coppa not provided, exiting PubCommonId'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above |
||
return; | ||
} | ||
const {params: {extend = false, pixelUrl, enableSharedId = SHAREDID_DEFAULT_STATE} = {}} = config; | ||
|
||
if (extend) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import * as utils from '../src/utils.js' | ||
import {ajax} from '../src/ajax.js'; | ||
import {submodule} from '../src/hook.js'; | ||
import { uspDataHandler, coppaDataHandler } from '../src/adapterManager.js'; | ||
|
||
const MODULE_NAME = 'sharedId'; | ||
const ID_SVC = 'https://id.sharedid.org/id'; | ||
|
@@ -282,9 +283,18 @@ function detectPrng(root) { | |
* @return {string} | ||
*/ | ||
function sharedIdUrl(consentData) { | ||
if (!consentData || typeof consentData.gdprApplies !== 'boolean' || !consentData.gdprApplies) return ID_SVC; | ||
|
||
return `${ID_SVC}?gdpr=1&gdpr_consent=${consentData.consentString}` | ||
const usPrivacyString = uspDataHandler.getConsentData(); | ||
let sharedIdUrl = ID_SVC; | ||
if (usPrivacyString) { | ||
sharedIdUrl = `${ID_SVC}?us_privacy=${usPrivacyString}`; | ||
} | ||
if (!consentData || typeof consentData.gdprApplies !== 'boolean' || !consentData.gdprApplies) return sharedIdUrl; | ||
if (usPrivacyString) { | ||
sharedIdUrl = `${sharedIdUrl}&gdpr=1&gdpr_consent=${consentData.consentString}` | ||
return sharedIdUrl; | ||
} | ||
sharedIdUrl = `${ID_SVC}?gdpr=1&gdpr_consent=${consentData.consentString}`; | ||
return sharedIdUrl | ||
} | ||
|
||
/** @type {Submodule} */ | ||
|
@@ -318,6 +328,11 @@ export const sharedIdSubmodule = { | |
* @returns {sharedId} | ||
*/ | ||
getId(config, consentData) { | ||
const coppa = coppaDataHandler.getCoppa(); | ||
if (coppa) { | ||
utils.logInfo('SharedId: coppa not provided, exiting SharedId'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
return; | ||
} | ||
const resp = function (callback) { | ||
utils.logInfo('SharedId: Sharedid doesnt exists, new cookie creation'); | ||
ajax(sharedIdUrl(consentData), idGenerationCallback(callback), undefined, {method: 'GET', withCredentials: true}); | ||
|
@@ -333,6 +348,11 @@ export const sharedIdSubmodule = { | |
* @returns {{callback: *}} | ||
*/ | ||
extendId(config, consentData, storedId) { | ||
const coppa = coppaDataHandler.getCoppa(); | ||
if (coppa) { | ||
utils.logInfo('SharedId: coppa not provided, exiting SharedId'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
return; | ||
} | ||
const configParams = (config && config.params) || {}; | ||
utils.logInfo('SharedId: Existing shared id ' + storedId.id); | ||
const resp = function (callback) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,9 +126,9 @@ | |
*/ | ||
|
||
/** | ||
* @typedef {Object} RefreshUserIdsOptions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this whole file just seems like whitespace changes now...can you just revert them all since there's no functional change? |
||
* @property {(string[]|undefined)} submoduleNames - submodules to refresh | ||
*/ | ||
* @typedef {Object} RefreshUserIdsOptions | ||
* @property {(string[]|undefined)} submoduleNames - submodules to refresh | ||
*/ | ||
|
||
import find from 'core-js-pure/features/array/find.js'; | ||
import { config } from '../../src/config.js'; | ||
|
@@ -225,7 +225,7 @@ function setPrebidServerEidPermissions(initializedSubmodules) { | |
} | ||
|
||
/** | ||
/** | ||
/** | ||
* @param {SubmoduleStorage} storage | ||
* @param {String|undefined} key optional key of the value | ||
* @returns {string} | ||
|
@@ -341,10 +341,10 @@ function hasGDPRConsent(consentData) { | |
} | ||
|
||
/** | ||
* Find the root domain | ||
* @param {string|undefined} fullDomain | ||
* @return {string} | ||
*/ | ||
* Find the root domain | ||
* @param {string|undefined} fullDomain | ||
* @return {string} | ||
*/ | ||
export function findRootDomain(fullDomain = window.location.hostname) { | ||
if (!coreStorage.cookiesAreEnabled()) { | ||
return fullDomain; | ||
|
@@ -579,9 +579,9 @@ function getUserIdsAsEids() { | |
} | ||
|
||
/** | ||
* This function will be exposed in the global-name-space so that userIds can be refreshed after initialization. | ||
* @param {RefreshUserIdsOptions} options | ||
*/ | ||
* This function will be exposed in the global-name-space so that userIds can be refreshed after initialization. | ||
* @param {RefreshUserIdsOptions} options | ||
*/ | ||
function refreshUserIds(options, callback) { | ||
let submoduleNames = options ? options.submoduleNames : null; | ||
if (!submoduleNames) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this say "coppa not supported" or "IDs not provided for coppa requests"? to me, this message sounds like "coppa config wasn't provided, so we're existing"