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

Integrate id link system #3965

Merged
merged 10 commits into from
Jul 23, 2019
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