Skip to content

Commit 739bad8

Browse files
New PubProvided Id UserId Submodule (#5767)
* PubProvided Module * - * formatting * formatting * Added rubiconBidAdapter support Added unit tests * formatting * formatting * formatting * formatting * commit to rerun build * type changes * type changes * type changes * Revert "type changes" This reverts commit af408b0 * Revert "type changes" This reverts commit af408b0 * formatting * formatting * formatting * formatting * formatting * Revert "type changes" This reverts commit 114005a * formatting * formatting * formatting * formatting * commit to rerun build * commit to rerun build * commit to rerun build * rubiconBidAdapter changes * rubiconBidAdapter changes * rubiconBidAdapter changes * trigger build * fix * fix * fix * rebuild Co-authored-by: myerkovich <[email protected]>
1 parent eb9cf3f commit 739bad8

File tree

7 files changed

+513
-201
lines changed

7 files changed

+513
-201
lines changed

integrationExamples/gpt/userId_example.html

+24
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,30 @@
134134
// },
135135
userSync: {
136136
userIds: [{
137+
name: "pubProvidedId",
138+
params: {
139+
eids: [{
140+
source: "domain.com",
141+
uids:[{
142+
id: "value read from cookie or local storage",
143+
atype: 1,
144+
ext: {
145+
stype: "ppuid" // allowable options are sha256email, DMP, ppuid for now
146+
}
147+
}]
148+
},{
149+
source: "3rdpartyprovided.com",
150+
uids:[{
151+
id: "value read from cookie or local storage",
152+
atype: 3,
153+
ext: {
154+
stype: "sha256email"
155+
}
156+
}]
157+
}],
158+
eidsFunction: getHashedEmail // any user defined function that exists in the page
159+
}
160+
},{
137161
name: "unifiedId",
138162
params: {
139163
partner: "prebid",

modules/pubProvidedSystem.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* This module adds Publisher Provided ids support to the User ID module
3+
* The {@link module:modules/userId} module is required.
4+
* @module modules/pubProvidedSystem
5+
* @requires module:modules/userId
6+
*/
7+
8+
import {submodule} from '../src/hook.js';
9+
import * as utils from '../src/utils.js';
10+
11+
const MODULE_NAME = 'pubProvidedId';
12+
13+
/** @type {Submodule} */
14+
export const pubProvidedIdSubmodule = {
15+
16+
/**
17+
* used to link submodule with config
18+
* @type {string}
19+
*/
20+
name: MODULE_NAME,
21+
22+
/**
23+
* decode the stored id value for passing to bid request
24+
* @function
25+
* @param {string} value
26+
* @returns {{pubProvidedId: array}} or undefined if value doesn't exists
27+
*/
28+
decode(value) {
29+
const res = value ? {pubProvidedId: value} : undefined;
30+
utils.logInfo('PubProvidedId: Decoded value ' + JSON.stringify(res));
31+
return res;
32+
},
33+
34+
/**
35+
* performs action to obtain id and return a value.
36+
* @function
37+
* @param {SubmoduleParams} [configParams]
38+
* @returns {{id: array}}
39+
*/
40+
getId(configParams) {
41+
let res = [];
42+
if (utils.isArray(configParams.eids)) {
43+
res = res.concat(configParams.eids);
44+
}
45+
if (typeof configParams.eidsFunction === 'function') {
46+
res = res.concat(configParams.eidsFunction());
47+
}
48+
return {id: res};
49+
}
50+
};
51+
52+
// Register submodule for userId
53+
submodule('userId', pubProvidedIdSubmodule);

modules/rubiconBidAdapter.js

+11
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,17 @@ export const spec = {
559559
const configUserId = config.getConfig('user.id');
560560
if (configUserId) {
561561
data['ppuid'] = configUserId;
562+
} else {
563+
// if config.getConfig('user.id') doesn't return anything, then look for the first eid.uids[*].ext.stype === 'ppuid'
564+
for (let i = 0; bidRequest.userIdAsEids && i < bidRequest.userIdAsEids.length; i++) {
565+
if (bidRequest.userIdAsEids[i].uids) {
566+
const pubProvidedId = find(bidRequest.userIdAsEids[i].uids, uid => uid.ext && uid.ext.stype === 'ppuid');
567+
if (pubProvidedId && pubProvidedId.id) {
568+
data['ppuid'] = pubProvidedId.id;
569+
break;
570+
}
571+
}
572+
}
562573
}
563574

564575
if (bidderRequest.gdprConsent) {

modules/userId/eids.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,13 @@ export function createEidsArray(bidRequestUserId) {
190190
let eids = [];
191191
for (const subModuleKey in bidRequestUserId) {
192192
if (bidRequestUserId.hasOwnProperty(subModuleKey)) {
193-
const eid = createEidObject(bidRequestUserId[subModuleKey], subModuleKey);
194-
if (eid) {
195-
eids.push(eid);
193+
if (subModuleKey === 'pubProvidedId') {
194+
eids = eids.concat(bidRequestUserId['pubProvidedId']);
195+
} else {
196+
const eid = createEidObject(bidRequestUserId[subModuleKey], subModuleKey);
197+
if (eid) {
198+
eids.push(eid);
199+
}
196200
}
197201
}
198202
}

test/spec/modules/eids_spec.js

+35-1
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,42 @@ describe('eids array generation for known sub-modules', function() {
261261
}]
262262
});
263263
});
264+
it('pubProvidedId', function() {
265+
const userId = {
266+
pubProvidedId: [{
267+
source: 'example.com',
268+
uids: [{
269+
id: 'value read from cookie or local storage',
270+
ext: {
271+
stype: 'ppuid'
272+
}
273+
}]
274+
}, {
275+
source: 'id-partner.com',
276+
uids: [{
277+
id: 'value read from cookie or local storage'
278+
}]
279+
}]
280+
};
281+
const newEids = createEidsArray(userId);
282+
expect(newEids.length).to.equal(2);
283+
expect(newEids[0]).to.deep.equal({
284+
source: 'example.com',
285+
uids: [{
286+
id: 'value read from cookie or local storage',
287+
ext: {
288+
stype: 'ppuid'
289+
}
290+
}]
291+
});
292+
expect(newEids[1]).to.deep.equal({
293+
source: 'id-partner.com',
294+
uids: [{
295+
id: 'value read from cookie or local storage'
296+
}]
297+
});
298+
});
264299
});
265-
266300
describe('Negative case', function() {
267301
it('eids array generation for UN-known sub-module', function() {
268302
// UnknownCommonId

0 commit comments

Comments
 (0)