Skip to content

Commit

Permalink
Merge pull request #525 from PubMatic-OpenWrap/feature/UOE-7606
Browse files Browse the repository at this point in the history
UOE-7606: Publink JS changes
  • Loading branch information
pm-nitin-nimbalkar authored May 2, 2022
2 parents 193d5e1 + 9ead802 commit 1406228
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
11 changes: 9 additions & 2 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,13 +704,13 @@ export function updateModuleParams(moduleToUpdate) {
function generateModuleLists() {
let primaryModulesList = CONSTANTS.REFRESH_IDMODULES_LIST.PRIMARY_MODULES;
let scriptBasedModulesList = CONSTANTS.REFRESH_IDMODULES_LIST.SCRIPT_BASED_MODULES;

for (let index in configRegistry) {
let moduleName = configRegistry[index].name;
if (primaryModulesList.indexOf(moduleName) >= 0) {
modulesToRefresh.push(moduleName);
updateModuleParams(configRegistry[index]);
} else if (scriptBasedModulesList.indexOf(moduleName) >= 0) {
}
if (scriptBasedModulesList.indexOf(moduleName) >= 0) {
scriptBasedModulesToRefresh.push(moduleName);
}
}
Expand Down Expand Up @@ -742,6 +742,13 @@ export function reTriggerScriptBasedAPICalls(modulesToRefresh) {
window.ats.start(atsObject);
}
break;
case 'publinkId':
if (window.conversant && isFn(window.conversant.launch)) {
let launchObject = window.conversant.getLauncherObject();
launchObject.emailHashes = userIdentity.emailHash ? [userIdentity.emailHash['MD5'], userIdentity.emailHash['SHA256']] : undefined;
window.conversant.launch('publink', 'start', launchObject);
}
break;
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@
"BID_REJECTED": "bidRejected"
},
"REFRESH_IDMODULES_LIST": {
"PRIMARY_MODULES": ["id5Id"],
"SCRIPT_BASED_MODULES": ["zeotapIdPlus", "identityLink"]
"PRIMARY_MODULES": ["id5Id","publinkId"],
"SCRIPT_BASED_MODULES": ["zeotapIdPlus", "identityLink", "publinkId"]
},
"MODULE_PARAM_TO_UPDATE_FOR_SSO": {
"id5Id": [{
"key": "pd"
}],
"publinkId": [{
"key": "e",
"hashType": "MD5"
}]
}
}
28 changes: 28 additions & 0 deletions test/spec/modules/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2655,5 +2655,33 @@ describe('User ID', function () {
expect(moduleToUpdate.params.pd).to.exist;
expect(moduleToUpdate.params.pd).to.equal(pdString);
});

it('should set the e param for publink if publink module is configured and email hashes are available', function() {
var emailHash = '1edeb32aa0ab4b329a41b431050dcf26';
var moduleToUpdate = {
name: 'publinkId',
storage: {
name: 'pbjs_publink',
type: 'cookie',
expires: 30
},
params: {
site_id: '214393',
api_key: '061065f4-4835-40f4-936e-74e0f3af59b5'
}
};

getGlobal().setUserIdentities(
{
'emailHash': {
'MD5': '1edeb32aa0ab4b329a41b431050dcf26',
'SHA256': '722b8c12e7991f0ebbcc2d7caebe8e12479d26d5dd9cb37f442a55ddc190817a'
}
}
);
updateModuleParams(moduleToUpdate);
expect(moduleToUpdate.params.e).to.exist;
expect(moduleToUpdate.params.e).to.equal(emailHash);
});
});
});

0 comments on commit 1406228

Please sign in to comment.