Skip to content

Prebid 8: Renaming TrustPid User ID module to Utiq #9872

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

Merged
merged 20 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"tapadIdSystem",
"teadsIdSystem",
"tncIdSystem",
"trustpidSystem",
"utiqSystem",
"uid2IdSystem",
"unifiedIdSystem",
"verizonMediaIdSystem",
Expand Down
2 changes: 1 addition & 1 deletion modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const SOURCE_RTI_MAPPING = {
'epsilon.com': '', // Publisher Link, publinkId
'audigent.com': '', // Hadron ID from Audigent, hadronId
'pubcid.org': '', // SharedID, pubcid
'trustpid.com': '', // Trustpid
'utiq.com': '', // Utiq
'intimatemerger.com': ''
};
const PROVIDERS = [
Expand Down
6 changes: 3 additions & 3 deletions modules/userId/eids.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export const USER_IDS_CONFIG = {
}
},

// trustpid
'trustpid': {
source: 'trustpid.com',
// utiq
'utiq': {
source: 'utiq.com',
atype: 1,
getValue: function (data) {
return data;
Expand Down
2 changes: 1 addition & 1 deletion modules/userId/eids.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ userIdAsEids = [
}]
},
{
source: 'trustpid.com',
source: 'utiq.com',
uids: [{
id: 'some-random-id-value',
atype: 1
Expand Down
22 changes: 12 additions & 10 deletions modules/userId/userId.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,20 +356,22 @@ pbjs.setConfig({
}
});
```

```

Example showing how to configure a `params` object to pass directly to bid adapters

```

pbjs.setConfig({
userSync: {
userIds: [{
name: 'tncId',
params: {
providerId: "c8549079-f149-4529-a34b-3fa91ef257d1"
}
}],
syncDelay: 5000
}
userSync: {
userIds: [{
name: 'tncId',
params: {
providerId: "c8549079-f149-4529-a34b-3fa91ef257d1"
}
}],
syncDelay: 5000
}
});
```
```
101 changes: 65 additions & 36 deletions modules/trustpidSystem.js → modules/utiqSystem.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/**
* This module adds TrustPid provided by Vodafone Sales and Services Limited to the User ID module
* This module adds Utiq provided by Utiq SA/NV to the User ID module
* The {@link module:modules/userId} module is required
* @module modules/trustpidSystem
* @module modules/utiqSystem
* @requires module:modules/userId
*/
import { logInfo } from '../src/utils.js';
import { submodule } from '../src/hook.js';
import {getStorageManager} from '../src/storageManager.js';
import {MODULE_TYPE_UID} from '../src/activities/modules.js';
import { getStorageManager } from '../src/storageManager.js';
import { MODULE_TYPE_UID } from '../src/activities/modules.js';

const MODULE_NAME = 'trustpid';
const LOG_PREFIX = 'Trustpid module'
const MODULE_NAME = 'utiq';
const LOG_PREFIX = 'Utiq module';
let mnoDomain = '';

export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME});
export const storage = getStorageManager({
moduleType: MODULE_TYPE_UID,
moduleName: MODULE_NAME,
});

/**
* Handle an event for an iframe.
Expand All @@ -33,7 +36,9 @@ function messageHandler(event) {
}
}
} catch (e) {
logInfo(`${LOG_PREFIX}: Unsupported message caught. Origin: ${event.origin}, data: ${event.data}.`);
logInfo(
`${LOG_PREFIX}: Unsupported message caught. Origin: ${event.origin}, data: ${event.data}.`
);
}
}

Expand All @@ -43,43 +48,58 @@ window.addEventListener('message', messageHandler, false);
/**
* Get the "atid" from html5 local storage to make it available to the UserId module.
* @param config
* @returns {{trustpid: (*|string)}}
* @returns {{utiq: (*|string)}}
*/
function getTrustpidFromStorage() {
function getUtiqFromStorage() {
// Get the domain either from localStorage or global
let domain = JSON.parse(storage.getDataFromLocalStorage('fcIdConnectDomain')) || mnoDomain;
let domain =
JSON.parse(storage.getDataFromLocalStorage('fcIdConnectDomain')) ||
mnoDomain;
logInfo(`${LOG_PREFIX}: Local storage domain: ${domain}`);

if (!domain) {
logInfo(`${LOG_PREFIX}: Local storage domain not found, returning null`);
return {
trustpid: null,
utiq: null,
};
}

let fcIdConnectObject;
let fcIdConnectData = JSON.parse(storage.getDataFromLocalStorage('fcIdConnectData'));
logInfo(`${LOG_PREFIX}: Local storage fcIdConnectData: ${JSON.stringify(fcIdConnectData)}`);
let fcIdConnectData = JSON.parse(
storage.getDataFromLocalStorage('fcIdConnectData')
);
logInfo(
`${LOG_PREFIX}: Local storage fcIdConnectData: ${JSON.stringify(
fcIdConnectData
)}`
);

if (fcIdConnectData &&
if (
fcIdConnectData &&
fcIdConnectData.connectId &&
Array.isArray(fcIdConnectData.connectId.idGraph) &&
fcIdConnectData.connectId.idGraph.length > 0) {
fcIdConnectObject = fcIdConnectData.connectId.idGraph.find(item => {
fcIdConnectData.connectId.idGraph.length > 0
) {
fcIdConnectObject = fcIdConnectData.connectId.idGraph.find((item) => {
return item.domain === domain;
});
}
logInfo(`${LOG_PREFIX}: Local storage fcIdConnectObject for domain: ${JSON.stringify(fcIdConnectObject)}`);
logInfo(
`${LOG_PREFIX}: Local storage fcIdConnectObject for domain: ${JSON.stringify(
fcIdConnectObject
)}`
);

return {
trustpid: (fcIdConnectObject && fcIdConnectObject.atid)
? fcIdConnectObject.atid
: null,
utiq:
fcIdConnectObject && fcIdConnectObject.atid
? fcIdConnectObject.atid
: null,
};
}

/** @type {Submodule} */
export const trustpidSubmodule = {
export const utiqSubmodule = {
/**
* Used to link submodule with config
* @type {string}
Expand All @@ -88,40 +108,45 @@ export const trustpidSubmodule = {
/**
* Decodes the stored id value for passing to bid requests.
* @function
* @returns {{trustpid: string} | null}
* @returns {{utiq: string} | null}
*/
decode(bidId) {
logInfo(`${LOG_PREFIX}: Decoded ID value ${JSON.stringify(bidId)}`);
return bidId.trustpid ? bidId : null;
return bidId.utiq ? bidId : null;
},
/**
* Get the id from helper function and initiate a new user sync.
* @param config
* @returns {{callback: result}|{id: {trustpid: string}}}
* @returns {{callback: result}|{id: {utiq: string}}}
*/
getId: function(config) {
const data = getTrustpidFromStorage();
if (data.trustpid) {
getId: function (config) {
const data = getUtiqFromStorage();
if (data.utiq) {
logInfo(`${LOG_PREFIX}: Local storage ID value ${JSON.stringify(data)}`);
return {id: {trustpid: data.trustpid}};
return { id: { utiq: data.utiq } };
} else {
if (!config) {
config = {};
}
if (!config.params) {
config.params = {};
}
if (typeof config.params.maxDelayTime === 'undefined' || config.params.maxDelayTime === null) {
if (
typeof config.params.maxDelayTime === 'undefined' ||
config.params.maxDelayTime === null
) {
config.params.maxDelayTime = 1000;
}
// Current delay and delay step in milliseconds
let currentDelay = 0;
const delayStep = 50;
const result = (callback) => {
const data = getTrustpidFromStorage();
if (!data.trustpid) {
const data = getUtiqFromStorage();
if (!data.utiq) {
if (currentDelay > config.params.maxDelayTime) {
logInfo(`${LOG_PREFIX}: No trustpid value set after ${config.params.maxDelayTime} max allowed delay time`);
logInfo(
`${LOG_PREFIX}: No utiq value set after ${config.params.maxDelayTime} max allowed delay time`
);
callback(null);
} else {
currentDelay += delayStep;
Expand All @@ -130,8 +155,12 @@ export const trustpidSubmodule = {
}, delayStep);
}
} else {
const dataToReturn = { trustpid: data.trustpid };
logInfo(`${LOG_PREFIX}: Returning ID value data of ${JSON.stringify(dataToReturn)}`);
const dataToReturn = { utiq: data.utiq };
logInfo(
`${LOG_PREFIX}: Returning ID value data of ${JSON.stringify(
dataToReturn
)}`
);
callback(dataToReturn);
}
};
Expand All @@ -140,4 +169,4 @@ export const trustpidSubmodule = {
},
};

submodule('userId', trustpidSubmodule);
submodule('userId', utiqSubmodule);
14 changes: 7 additions & 7 deletions modules/trustpidSystem.md → modules/utiqSystem.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
## trustpid User Id Submodule
## Utiq User ID Submodule

trustpid User Id Module.
Utiq ID Module.

First, make sure to add the trustpid submodule to your Prebid.js package with:
First, make sure to add the utiq submodule to your Prebid.js package with:

```
gulp build --modules=userId,adfBidAdapter,ixBidAdapter,prebidServerBidAdapter,trustpidSystem
gulp build --modules=userId,adfBidAdapter,ixBidAdapter,prebidServerBidAdapter,utiqSystem
```

## Parameter Descriptions

| Params under userSync.userIds[] | Type | Description | Example |
| ------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------- |
| name | String | The name of the module | `"trustpid"` |
| params | Object | Object with configuration parameters for trustpid User Id submodule | - |
| name | String | The name of the module | `"utiq"` |
| params | Object | Object with configuration parameters for utiq User Id submodule | - |
| params.maxDelayTime | Integer | Max amount of time (in seconds) before looking into storage for data | 2500 |
| bidders | Array of Strings | An array of bidder codes to which this user ID may be sent. Currently required and supporting AdformOpenRTB | [`"adf"`, `"adformPBS"`, `"ix"`] |
| storage | Object | Local storage configuration object | - |
| storage.type | String | Type of the storage that would be used to store user ID. Must be `"html5"` to utilise HTML5 local storage. | `"html5"` |
| storage.name | String | The name of the key in local storage where the user ID will be stored. | `"trustpid"` |
| storage.name | String | The name of the key in local storage where the user ID will be stored. | `"utiq"` |
| storage.expires | Integer | How long (in days) the user ID information will be stored. For safety reasons, this information is required. | `1` |
Loading