Skip to content

Commit

Permalink
code review feedback. HEM sources order & var rename
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosfelix committed Jan 8, 2025
1 parent 02d485d commit ae94372
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions modules/33acrossIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function getStoredValue(key, enabledStorageTypes) {
return storedValue;
}

function filterEnabledSupplementalIds({ tp, fp, hem }, { storeFpid, storeTpid, privacyConsent }) {
function filterEnabledSupplementalIds({ tp, fp, hem }, { storeFpid, storeTpid, envelopeAvailable }) {
const ids = [];

if (storeFpid) {
Expand All @@ -154,38 +154,38 @@ function filterEnabledSupplementalIds({ tp, fp, hem }, { storeFpid, storeTpid, p
* [
* <storage key>,
* < ID value to store or remove >,
* < clear flag: indicates if existing storage item should be removed or not when the new ID is falsy>
* < clear flag: indicates if existing storage item should be removed or not based on certain condition>
* ]
*/
[STORAGE_FPID_KEY, fp, true],
[STORAGE_HEM_KEY, hem, privacyConsent === false] // hashed email should be cleared if there's no privacy consent.
[STORAGE_FPID_KEY, fp, !fp],
[STORAGE_HEM_KEY, hem, !envelopeAvailable] // Clear hashed email if envelope is not available
);
}

if (storeTpid) {
ids.push([STORAGE_TPID_KEY, tp, true]);
ids.push([STORAGE_TPID_KEY, tp, !tp]);
}

return ids;
}

function handleEnabledSupplementalId(supplementalId, storageConfig) {
function updateSupplementalIdStorage(supplementalId, storageConfig) {
const [ key, id, clear ] = supplementalId;

if (id) {
storeValue(key, id, storageConfig);
if (clear) {
deleteFromStorage(key);

return;
}

if (clear) {
deleteFromStorage(key);
if (id) {
storeValue(key, id, storageConfig);
}
}

function handleSupplementalIds(ids, { enabledStorageTypes, expires, ...options }) {
filterEnabledSupplementalIds(ids, options).forEach((supplementalId) => {
handleEnabledSupplementalId(supplementalId, {
updateSupplementalIdStorage(supplementalId, {
enabledStorageTypes,
expires
})
Expand Down Expand Up @@ -268,7 +268,7 @@ export const thirtyThreeAcrossIdSubmodule = {
}, {
storeFpid,
storeTpid,
privacyConsent: !!responseObj.envelope,
envelopeAvailable: !!responseObj.envelope,
enabledStorageTypes,
expires: storageConfig.expires
});
Expand Down
4 changes: 2 additions & 2 deletions modules/33acrossIdSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ The following settings are available in the `params` property in `userSync.userI

### HEM Collection

33Across ID System supports user's hashed emails (HEMs). HEMs could be collected from 3 different
sources: `hem` configuration parameter, global `_33across.hem.sha256` field or from storage (cookie or local storage).
33Across ID System supports user's hashed emails (HEMs). HEMs could be collected from 3 different sources in following
priority order: `hem` configuration parameter, global `_33across.hem.sha256` field or from storage (cookie or local storage).

0 comments on commit ae94372

Please sign in to comment.