-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
New PubProvided Id UserId Submodule #5767
Changes from 11 commits
b2eeeeb
cda2b86
93b8468
3008291
d51ee5c
1a0fe24
286a90f
546e331
974fbba
983317f
f0a230c
af408b0
3dd1b99
114005a
9f7a32c
e488edb
5d0b2c1
b296b2e
bce5b25
a02bd15
6339bb0
2e0f6d8
476519b
c7818f6
7c60c34
8d36ae8
597e4c0
24b571d
9a0583d
f4cf127
6c9d5b5
e6fd58f
76185b2
91b3106
2253c92
59f8356
f67e018
6605e58
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* This module adds Publisher Provided ids support to the User ID module | ||
* The {@link module:modules/userId} module is required. | ||
* @module modules/pubProvidedSystem | ||
* @requires module:modules/userId | ||
*/ | ||
|
||
import {submodule} from '../src/hook.js'; | ||
import * as utils from '../src/utils.js'; | ||
|
||
const MODULE_NAME = 'pubProvided'; | ||
|
||
/** @type {Submodule} */ | ||
export const pubProvidedSubmodule = { | ||
/** | ||
* used to link submodule with config | ||
* @type {string} | ||
*/ | ||
name: MODULE_NAME, | ||
|
||
/** | ||
* decode the stored id value for passing to bid request | ||
* @function | ||
* @param {string} value | ||
* @returns {{pubProvided: array}} or undefined if value doesn't exists | ||
*/ | ||
decode(value) { | ||
const res = value ? {pubProvided: value} : undefined; | ||
utils.logInfo('PubProvided: Decoded value ' + JSON.stringify(res)); | ||
return res; | ||
}, | ||
|
||
/** | ||
* performs action to obtain id and return a value. | ||
* @function | ||
* @param {SubmoduleParams} [configParams] | ||
* @returns {{id: array}} | ||
*/ | ||
getId(configParams) { | ||
let res = []; | ||
smenzer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (utils.isArray(configParams.eids)) { | ||
res = res.concat(configParams.eids); | ||
} | ||
if (typeof configParams.eidsFunction === 'function') { | ||
res = res.concat(configParams.eidsFunction()); | ||
} | ||
res.forEach(id => id.type = 'pubProvided'); | ||
return {id: res}; | ||
jdwieland8282 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}; | ||
|
||
// Register submodule for userId | ||
submodule('userId', pubProvidedSubmodule); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,7 +251,7 @@ export const spec = { | |
const eids = utils.deepAccess(bidderRequest, 'bids.0.userIdAsEids'); | ||
if (eids && eids.length) { | ||
// filter out unsupported id systems | ||
utils.deepSetValue(data, 'user.ext.eids', eids.filter(eid => ['adserver.org', 'pubcid.org', 'liveintent.com', 'liveramp.com', 'sharedid.org'].indexOf(eid.source) !== -1)); | ||
utils.deepSetValue(data, 'user.ext.eids', eids.filter(eid => ['adserver.org', 'pubcid.org', 'liveintent.com', 'liveramp.com', 'sharedid.org'].indexOf(eid.source) !== -1 || eid.type === 'pubProvided')); | ||
|
||
// liveintent requires additional props to be set | ||
const liveIntentEid = find(data.user.ext.eids, eid => eid.source === 'liveintent.com'); | ||
|
@@ -538,6 +538,12 @@ export const spec = { | |
if (sharedId) { | ||
data['eid_sharedid.org'] = `${sharedId.uids[0].id}^${sharedId.uids[0].atype}^${sharedId.uids[0].ext.third}`; | ||
} | ||
const pubProvidedIds = bidRequest.userIdAsEids.filter(eid => eid.type === 'pubProvided'); | ||
if (pubProvidedIds) { | ||
pubProvidedIds.forEach(pubProvidedId => { | ||
data[`${pubProvidedId.source}_id`] = pubProvidedId.uids[0].id; | ||
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. As noted above, I think it would be safer to accept eid.uids[].ext.stype === 'ppuid' on any index of the uids array. More importantly, for the fastlane.json interface, the exchange team wants to receive this on the existing |
||
}); | ||
} | ||
} | ||
|
||
// set ppuid value from config value | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,8 +237,42 @@ describe('eids array generation for known sub-modules', function() { | |
}] | ||
}); | ||
}); | ||
it('PubProvided', function() { | ||
YerkovichM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const userId = { | ||
pubProvided: [{ | ||
source: 'example.com', | ||
type: 'pubProvided', | ||
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 seems like a good alternative to using a generic 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. I will make sure that it will be in the documentation 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. any chance we could take a stab at defining a few conventions in this doc? eg sha256email etc? |
||
uids: [{ | ||
id: 'value read from cookie or local storage', | ||
ext: {} | ||
}] | ||
}, { | ||
source: 'id-partner.com', | ||
type: 'pubProvided', | ||
uids: [{ | ||
id: 'value read from cookie or local storage' | ||
}] | ||
}] | ||
}; | ||
const newEids = createEidsArray(userId); | ||
expect(newEids.length).to.equal(2); | ||
expect(newEids[0]).to.deep.equal({ | ||
source: 'example.com', | ||
type: 'pubProvided', | ||
uids: [{ | ||
id: 'value read from cookie or local storage', | ||
ext: {} | ||
}] | ||
}); | ||
expect(newEids[1]).to.deep.equal({ | ||
source: 'id-partner.com', | ||
type: 'pubProvided', | ||
uids: [{ | ||
id: 'value read from cookie or local storage' | ||
}] | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Negative case', function() { | ||
it('eids array generation for UN-known sub-module', function() { | ||
// UnknownCommonId | ||
|
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.
can we chance "pubProvided" to "pubProvidedId", that matches the convention the other id vendors are using.