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

IdentityHubChanges #374

Merged
merged 4 commits into from
Feb 28, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* @requires module:modules/userId
*/

import * as utils from '../../src/utils';
import * as url from '../../src/url';
import * as utils from '../src/utils';
import * as url from '../src/url';
import { submodule } from '../src/hook';

const PUB_COMMON_ID = 'PublisherCommonId';

Expand Down Expand Up @@ -90,3 +91,5 @@ export const pubCommonIdSubmodule = {
}
}
};

submodule('userId', pubCommonIdSubmodule);
91 changes: 91 additions & 0 deletions modules/pubmaticServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const IFRAME = 'iframe';
const IMAGE = 'image';
const REDIRECT = 'redirect';
const DEFAULT_VERSION_ID = '0';
const PUBMATIC_DIGITRUST_KEY = 'nFIn8aLzbd';

const CUSTOM_PARAMS = {
'kadpageurl': '', // Custom page url
Expand Down Expand Up @@ -241,6 +242,95 @@ function _createDummyBids (impData, bidResponses, errorCode) {
}
}

function _getDigiTrustObject(key) {
function getDigiTrustId() {
let digiTrustUser = window.DigiTrust && (config.getConfig('digiTrustId') || window.DigiTrust.getUser({member: key}));
return (digiTrustUser && digiTrustUser.success && digiTrustUser.identity) || null;
}
let digiTrustId = getDigiTrustId();
// Verify there is an ID and this user has not opted out
if (!digiTrustId || (digiTrustId.privacy && digiTrustId.privacy.optout)) {
return null;
}
return digiTrustId;
}

function _handleDigitrustId(eids) {
let digiTrustId = _getDigiTrustObject(PUBMATIC_DIGITRUST_KEY);
if (digiTrustId !== null) {
eids.push({
'source': 'digitru.st',
'uids': [{
'id': digiTrustId.id || '',
'atype': 1,
'ext': {
'keyv': parseInt(digiTrustId.keyv) || 0
}
}]
});
}
}

function _handleTTDId(eids, validBidRequests) {
let ttdId = null;
let adsrvrOrgId = config.getConfig('adsrvrOrgId');
if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) {
ttdId = validBidRequests[0].userId.tdid;
} else if (adsrvrOrgId && utils.isStr(adsrvrOrgId.TDID)) {
ttdId = adsrvrOrgId.TDID;
}

if (ttdId !== null) {
eids.push({
'source': 'adserver.org',
'uids': [{
'id': ttdId,
'atype': 1,
'ext': {
'rtiPartner': 'TDID'
}
}]
});
}
}

/**
* Produces external userid object in ortb 3.0 model.
*/
function _addExternalUserId(eids, value, source, atype) {
if (utils.isStr(value)) {
eids.push({
source,
uids: [{
id: value,
atype
}]
});
}
}

function _handleEids(payload, validBidRequests) {
let eids = [];
_handleDigitrustId(eids);
_handleTTDId(eids, validBidRequests);
const bidRequest = validBidRequests[0];
if (bidRequest && bidRequest.userId) {
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.pubcid`), 'pubcid.org', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.digitrustid.data.id`), 'digitru.st', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5-sync.com', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.criteoId`), 'criteo.com', 1);// replacing criteoRtus
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.idl_env`), 'liveramp.com', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.lipb.lipbid`), 'liveintent.com', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.parrableid`), 'parrable.com', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.britepoolid`), 'britepool.com', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.firstpartyid`), 'firstpartyid', 1);
}
if (eids.length > 0) {
payload.user.ext = {};
payload.user.ext.eids = eids;
}
}

export const spec = {
code: BIDDER_CODE,

Expand Down Expand Up @@ -337,6 +427,7 @@ export const spec = {
startTime: startTime
}
}
_handleEids(payload, validBidRequests);
return {
method: 'POST',
url: utils.getParameterByName('pwtvc') ? ENDPOINT + '?debug=1' : ENDPOINT,
Expand Down
4 changes: 2 additions & 2 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ import {gdprDataHandler} from '../../src/adapterManager';
import CONSTANTS from '../../src/constants.json';
import {module} from '../../src/hook';
// import {unifiedIdSubmodule} from './unifiedIdSystem.js';
import {pubCommonIdSubmodule} from './pubCommonIdSystem.js';
// import {pubCommonIdSubmodule} from '../pubCommonIdSystem';
// import {customIdSubmodule} from './customIdSystem.js';

const MODULE_NAME = 'User ID';
Expand Down Expand Up @@ -553,7 +553,7 @@ export function init(config) {
init(config);

// add submodules after init has been called
attachIdSystem(pubCommonIdSubmodule);
// attachIdSystem(pubCommonIdSubmodule);
// attachIdSystem(unifiedIdSubmodule);
// attachIdSystem(customIdSubmodule);

Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as utils from 'src/utils';
import events from 'src/events';
import CONSTANTS from 'src/constants.json';
import {unifiedIdSubmodule} from 'modules/unifiedIdSystem';
import {pubCommonIdSubmodule} from 'modules/userId/pubCommonIdSystem';
import {pubCommonIdSubmodule} from 'modules/pubCommonIdSystem';
import {britepoolIdSubmodule} from 'modules/britepoolIdSystem';
import {id5IdSubmodule} from 'modules/id5IdSystem';
import {identityLinkSubmodule} from 'modules/identityLinkIdSystem';
Expand Down