Skip to content

Commit f9817b1

Browse files
mamaticsa1omon
authored andcommitted
Integrate id link system (prebid#3965)
* 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
1 parent 5f74875 commit f9817b1

File tree

5 files changed

+175
-21
lines changed

5 files changed

+175
-21
lines changed

integrationExamples/gpt/userId_example.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@
162162
// foo: '9879878907987',
163163
// bar:'93939'
164164
// }
165+
}, {
166+
name: 'identityLink',
167+
params: {
168+
pid: '14' // Set your real identityLink placement ID here
169+
},
170+
storage: {
171+
type: 'cookie',
172+
name: 'idl_env',
173+
expires: 60
174+
}
165175
}],
166176
syncDelay: 5000
167177
}

modules/identityLinkSystem.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* This module adds IdentityLink to the User ID module
3+
* The {@link module:modules/userId} module is required
4+
* @module modules/identityLinkSubmodule
5+
* @requires module:modules/userId
6+
*/
7+
8+
import * as utils from '../src/utils.js'
9+
import {ajax} from '../src/ajax.js';
10+
import {submodule} from '../src/hook';
11+
12+
/** @type {Submodule} */
13+
export const identityLinkSubmodule = {
14+
/**
15+
* used to link submodule with config
16+
* @type {string}
17+
*/
18+
name: 'identityLink',
19+
/**
20+
* decode the stored id value for passing to bid requests
21+
* @function
22+
* @param {string} value
23+
* @returns {{idl_env:string}}
24+
*/
25+
decode(value) {
26+
return { 'idl_env': value }
27+
},
28+
/**
29+
* performs action to obtain id and return a value in the callback's response argument
30+
* @function
31+
* @param {SubmoduleParams} [configParams]
32+
* @returns {function(callback:function)}
33+
*/
34+
getId(configParams) {
35+
if (!configParams || typeof configParams.pid !== 'string') {
36+
utils.logError('identityLink submodule requires partner id to be defined');
37+
return;
38+
}
39+
// use protocol relative urls for http or https
40+
const url = `https://api.rlcdn.com/api/identity?pid=${configParams.pid}&rt=envelope`;
41+
42+
return function (callback) {
43+
ajax(url, response => {
44+
let responseObj;
45+
if (response) {
46+
try {
47+
responseObj = JSON.parse(response);
48+
} catch (error) {
49+
utils.logError(error);
50+
}
51+
}
52+
callback(responseObj.envelope);
53+
}, undefined, { method: 'GET' });
54+
}
55+
}
56+
};
57+
58+
submodule('userId', identityLinkSubmodule);

modules/userId/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
* @typedef {Object} SubmoduleParams
5151
* @property {(string|undefined)} partner - partner url param value
5252
* @property {(string|undefined)} url - webservice request url used to load Id data
53+
* @property {(string|undefined)} pid - placement id url param value
5354
*/
5455

5556
/**

modules/userId/userId.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ pbjs.setConfig({
3232
name: "id5id",
3333
expires: 5
3434
}
35+
}, {
36+
name: 'identityLink',
37+
params: {
38+
pid: '999' // Set your real identityLink placement ID here
39+
},
40+
storage: {
41+
type: 'cookie',
42+
name: 'idl_env',
43+
expires: 60
44+
}
3545
}],
3646
syncDelay: 5000
3747
}
@@ -60,6 +70,16 @@ pbjs.setConfig({
6070
name: "pubcid",
6171
expires: 60
6272
}
73+
}, {
74+
name: 'identityLink',
75+
params: {
76+
pid: '999' // Set your real identityLink placement ID here
77+
},
78+
storage: {
79+
type: 'html5',
80+
name: 'idl_env',
81+
expires: 60
82+
}
6383
}],
6484
syncDelay: 5000
6585
}

0 commit comments

Comments
 (0)