Skip to content

Commit

Permalink
Integrate id link system (#3965)
Browse files Browse the repository at this point in the history
* idLink - integrate new submodule idLinkSystem in to userId module

* idLink - Fix unit tests

* identityLink - Change submodule name from idLink to identityLink

* Identity Link - Remove identity link to be default submodule
  • Loading branch information
mamatic authored and Isaac Dettman committed Jul 23, 2019
1 parent 4a3372d commit 05cf0d2
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 21 deletions.
10 changes: 10 additions & 0 deletions integrationExamples/gpt/userId_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@
// foo: '9879878907987',
// bar:'93939'
// }
}, {
name: 'identityLink',
params: {
pid: '14' // Set your real identityLink placement ID here
},
storage: {
type: 'cookie',
name: 'idl_env',
expires: 60
}
}],
syncDelay: 5000
}
Expand Down
58 changes: 58 additions & 0 deletions modules/identityLinkSystem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* This module adds IdentityLink to the User ID module
* The {@link module:modules/userId} module is required
* @module modules/identityLinkSubmodule
* @requires module:modules/userId
*/

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

/** @type {Submodule} */
export const identityLinkSubmodule = {
/**
* used to link submodule with config
* @type {string}
*/
name: 'identityLink',
/**
* decode the stored id value for passing to bid requests
* @function
* @param {string} value
* @returns {{idl_env:string}}
*/
decode(value) {
return { 'idl_env': value }
},
/**
* performs action to obtain id and return a value in the callback's response argument
* @function
* @param {SubmoduleParams} [configParams]
* @returns {function(callback:function)}
*/
getId(configParams) {
if (!configParams || typeof configParams.pid !== 'string') {
utils.logError('identityLink submodule requires partner id to be defined');
return;
}
// use protocol relative urls for http or https
const url = `https://api.rlcdn.com/api/identity?pid=${configParams.pid}&rt=envelope`;

return function (callback) {
ajax(url, response => {
let responseObj;
if (response) {
try {
responseObj = JSON.parse(response);
} catch (error) {
utils.logError(error);
}
}
callback(responseObj.envelope);
}, undefined, { method: 'GET' });
}
}
};

submodule('userId', identityLinkSubmodule);
1 change: 1 addition & 0 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
* @typedef {Object} SubmoduleParams
* @property {(string|undefined)} partner - partner url param value
* @property {(string|undefined)} url - webservice request url used to load Id data
* @property {(string|undefined)} pid - placement id url param value
*/

/**
Expand Down
20 changes: 20 additions & 0 deletions modules/userId/userId.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ pbjs.setConfig({
name: "id5id",
expires: 5
}
}, {
name: 'identityLink',
params: {
pid: '999' // Set your real identityLink placement ID here
},
storage: {
type: 'cookie',
name: 'idl_env',
expires: 60
}
}],
syncDelay: 5000
}
Expand Down Expand Up @@ -60,6 +70,16 @@ pbjs.setConfig({
name: "pubcid",
expires: 60
}
}, {
name: 'identityLink',
params: {
pid: '999' // Set your real identityLink placement ID here
},
storage: {
type: 'html5',
name: 'idl_env',
expires: 60
}
}],
syncDelay: 5000
}
Expand Down
Loading

0 comments on commit 05cf0d2

Please sign in to comment.