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

New PubProvided Id UserId Submodule #5767

Merged
merged 38 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b2eeeeb
PubProvided Module
MarkoYerkovichRP Sep 17, 2020
cda2b86
-
MarkoYerkovichRP Sep 17, 2020
93b8468
formatting
MarkoYerkovichRP Sep 17, 2020
3008291
formatting
MarkoYerkovichRP Sep 18, 2020
d51ee5c
Added rubiconBidAdapter support
MarkoYerkovichRP Sep 21, 2020
1a0fe24
formatting
MarkoYerkovichRP Sep 21, 2020
286a90f
Merge branch 'master' into pubProvided
MarkoYerkovichRP Sep 21, 2020
546e331
formatting
MarkoYerkovichRP Sep 21, 2020
974fbba
formatting
MarkoYerkovichRP Sep 21, 2020
983317f
formatting
MarkoYerkovichRP Sep 21, 2020
f0a230c
commit to rerun build
MarkoYerkovichRP Sep 21, 2020
af408b0
type changes
MarkoYerkovichRP Sep 21, 2020
3dd1b99
type changes
MarkoYerkovichRP Sep 21, 2020
114005a
type changes
MarkoYerkovichRP Sep 21, 2020
9f7a32c
Revert "type changes"
MarkoYerkovichRP Sep 22, 2020
e488edb
Revert "type changes"
MarkoYerkovichRP Sep 22, 2020
5d0b2c1
formatting
MarkoYerkovichRP Sep 22, 2020
b296b2e
formatting
MarkoYerkovichRP Sep 22, 2020
bce5b25
formatting
MarkoYerkovichRP Sep 22, 2020
a02bd15
formatting
MarkoYerkovichRP Sep 22, 2020
6339bb0
formatting
MarkoYerkovichRP Sep 22, 2020
2e0f6d8
Revert "type changes"
MarkoYerkovichRP Sep 22, 2020
476519b
formatting
MarkoYerkovichRP Sep 22, 2020
c7818f6
formatting
MarkoYerkovichRP Sep 22, 2020
7c60c34
formatting
MarkoYerkovichRP Sep 22, 2020
8d36ae8
formatting
MarkoYerkovichRP Sep 22, 2020
597e4c0
commit to rerun build
MarkoYerkovichRP Sep 22, 2020
24b571d
commit to rerun build
MarkoYerkovichRP Sep 22, 2020
9a0583d
commit to rerun build
MarkoYerkovichRP Sep 22, 2020
f4cf127
rubiconBidAdapter changes
MarkoYerkovichRP Sep 23, 2020
6c9d5b5
Merge branch 'upstream' into pubProvided
MarkoYerkovichRP Sep 23, 2020
e6fd58f
rubiconBidAdapter changes
MarkoYerkovichRP Sep 23, 2020
76185b2
rubiconBidAdapter changes
MarkoYerkovichRP Sep 23, 2020
91b3106
trigger build
MarkoYerkovichRP Sep 23, 2020
2253c92
fix
MarkoYerkovichRP Sep 23, 2020
59f8356
fix
MarkoYerkovichRP Sep 23, 2020
f67e018
fix
MarkoYerkovichRP Sep 23, 2020
6605e58
rebuild
MarkoYerkovichRP Sep 23, 2020
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
24 changes: 24 additions & 0 deletions integrationExamples/gpt/userId_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,30 @@
// },
userSync: {
userIds: [{
name: "pubProvidedId",
params: {
eids: [{
source: "domain.com",
uids:[{
id: "value read from cookie or local storage",
atype: 1,
ext: {
stype: "ppuid" // allowable options are sha256email, DMP, ppuid for now
}
}]
},{
source: "3rdpartyprovided.com",
uids:[{
id: "value read from cookie or local storage",
atype: 3,
ext: {
stype: "sha256email"
}
}]
}],
eidsFunction: getHashedEmail // any user defined function that exists in the page
}
},{
name: "unifiedId",
params: {
partner: "prebid",
Expand Down
53 changes: 53 additions & 0 deletions modules/pubProvidedSystem.js
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 = 'pubProvidedId';

/** @type {Submodule} */
export const pubProvidedIdSubmodule = {

/**
* 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 {{pubProvidedId: array}} or undefined if value doesn't exists
*/
decode(value) {
const res = value ? {pubProvidedId: value} : undefined;
utils.logInfo('PubProvidedId: 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());
}
return {id: res};
jdwieland8282 marked this conversation as resolved.
Show resolved Hide resolved
}
};

// Register submodule for userId
submodule('userId', pubProvidedIdSubmodule);
11 changes: 11 additions & 0 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,17 @@ export const spec = {
const configUserId = config.getConfig('user.id');
if (configUserId) {
data['ppuid'] = configUserId;
} else {
// if config.getConfig('user.id') doesn't return anything, then look for the first eid.uids[*].ext.stype === 'ppuid'
for (let i = 0; bidRequest.userIdAsEids && i < bidRequest.userIdAsEids.length; i++) {
if (bidRequest.userIdAsEids[i].uids) {
const pubProvidedId = find(bidRequest.userIdAsEids[i].uids, uid => uid.ext && uid.ext.stype === 'ppuid');
if (pubProvidedId && pubProvidedId.id) {
data['ppuid'] = pubProvidedId.id;
break;
}
}
}
}

if (bidderRequest.gdprConsent) {
Expand Down
10 changes: 7 additions & 3 deletions modules/userId/eids.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,13 @@ export function createEidsArray(bidRequestUserId) {
let eids = [];
for (const subModuleKey in bidRequestUserId) {
if (bidRequestUserId.hasOwnProperty(subModuleKey)) {
const eid = createEidObject(bidRequestUserId[subModuleKey], subModuleKey);
if (eid) {
eids.push(eid);
if (subModuleKey === 'pubProvidedId') {
eids = eids.concat(bidRequestUserId['pubProvidedId']);
} else {
const eid = createEidObject(bidRequestUserId[subModuleKey], subModuleKey);
if (eid) {
eids.push(eid);
}
}
}
}
Expand Down
36 changes: 35 additions & 1 deletion test/spec/modules/eids_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,42 @@ describe('eids array generation for known sub-modules', function() {
}]
});
});
it('pubProvidedId', function() {
const userId = {
pubProvidedId: [{
source: 'example.com',
uids: [{
id: 'value read from cookie or local storage',
ext: {
stype: 'ppuid'
}
}]
}, {
source: 'id-partner.com',
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',
uids: [{
id: 'value read from cookie or local storage',
ext: {
stype: 'ppuid'
}
}]
});
expect(newEids[1]).to.deep.equal({
source: 'id-partner.com',
uids: [{
id: 'value read from cookie or local storage'
}]
});
});
});

describe('Negative case', function() {
it('eids array generation for UN-known sub-module', function() {
// UnknownCommonId
Expand Down
Loading