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

Audigent RTD Provider HaloId Support & RTD Phase 3 Compliance #5777

Merged
merged 73 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
6121b4e
real time data module,
omerDotan Aug 25, 2019
1a80b14
change timeout&primary ad server only to auctionDelay
omerDotan Sep 9, 2019
3b85815
support multiple providers
omerDotan Sep 18, 2019
0cb7b69
change promise to callbacks
omerDotan Oct 16, 2019
0908134
bug fixes
omerDotan Nov 3, 2019
cf4c5a9
use Prebid ajax
omerDotan Nov 6, 2019
7beeee3
tests fix
omerDotan Nov 6, 2019
60aaeaa
browsi real time data provider improvements
omerDotan Dec 8, 2019
0e06e6f
real time data module,
omerDotan Aug 25, 2019
e9312c7
change timeout&primary ad server only to auctionDelay
omerDotan Sep 9, 2019
c0901fe
support multiple providers
omerDotan Sep 18, 2019
398f922
change promise to callbacks
omerDotan Oct 16, 2019
b3d0bea
bug fixes
omerDotan Nov 3, 2019
a4f2de6
use Prebid ajax
omerDotan Nov 6, 2019
65ed991
tests fix
omerDotan Nov 6, 2019
15337d2
browsi real time data provider improvements
omerDotan Dec 8, 2019
76b3208
Merge remote-tracking branch 'origin/master'
omerDotan Dec 12, 2019
6a8c111
Merge remote-tracking branch 'upstream/master'
omerDotan Jan 16, 2020
b9b05f0
Merge remote-tracking branch 'upstream/master'
omerDotan Jan 20, 2020
89013d7
Merge remote-tracking branch 'upstream/master'
omerDotan Jan 21, 2020
342484c
Merge remote-tracking branch 'upstream/master'
omerDotan Jan 22, 2020
faa02bf
Merge remote-tracking branch 'upstream/master'
omerDotan Jan 28, 2020
88430b1
Merge remote-tracking branch 'upstream/master'
omerDotan Feb 11, 2020
b73b6d7
Merge remote-tracking branch 'upstream/master'
omerDotan Feb 23, 2020
00c027c
Merge remote-tracking branch 'upstream/master'
omerDotan Apr 2, 2020
51555b6
Merge remote-tracking branch 'upstream/master'
omerDotan Apr 7, 2020
c959997
Merge remote-tracking branch 'upstream/master'
omerDotan Apr 21, 2020
a277d65
Merge remote-tracking branch 'upstream/master'
omerDotan May 4, 2020
ebf1fa8
Merge remote-tracking branch 'upstream/master'
omerDotan May 25, 2020
6ec752e
Merge remote-tracking branch 'upstream/master'
omerDotan May 28, 2020
6af3494
Merge remote-tracking branch 'upstream/master'
omerDotan Jul 13, 2020
f0d9bb7
Merge remote-tracking branch 'upstream/master'
omerDotan Jul 20, 2020
74a4102
RTD module extend #4610
omerDotan Jul 20, 2020
608eabf
Merge remote-tracking branch 'upstream/master'
omerDotan Jul 21, 2020
6bdd935
Merge remote-tracking branch 'upstream/master'
omerDotan Jul 26, 2020
735e8e9
add hook for submodule init
omerDotan Aug 2, 2020
ca43a02
Merge remote-tracking branch 'upstream/master'
omerDotan Aug 10, 2020
959673d
RTD bug fix
omerDotan Aug 23, 2020
8346da4
Merge remote-tracking branch 'upstream/master'
omerDotan Aug 23, 2020
bd7f7d5
Merge branch 'master' into RTD-extend
omerDotan Aug 23, 2020
1fb1f31
remove auction delay and related hooks
omerDotan Aug 26, 2020
1f5a82e
Merge remote-tracking branch 'upstream/master'
omerDotan Aug 27, 2020
1c0d024
Merge remote-tracking branch 'upstream/master'
omerDotan Sep 14, 2020
f757932
Merge branch 'master' into RTD-phase3
omerDotan Sep 14, 2020
6c7cac7
Merge remote-tracking branch 'upstream/master'
omerDotan Sep 21, 2020
17d7150
Merge branch 'master' into RTD-phase3
omerDotan Sep 21, 2020
90e8249
update audigent rtd provider
Jan 7, 2020
243cf99
style update
Sep 21, 2020
c64556b
change onDone() logic
Sep 23, 2020
1543516
Merge remote-tracking branch 'upstream/master'
omerDotan Sep 23, 2020
3345930
Merge branch 'master' into RTD-phase3
omerDotan Sep 23, 2020
6e7805b
RTD phase 3
omerDotan Sep 23, 2020
3fe6729
return on data unavailable
Sep 23, 2020
3dc857c
api endpoint update
Sep 29, 2020
f1f9d11
Merge remote-tracking branch 'browsi/RTD-phase3' into rtd3
Sep 29, 2020
dd3a80a
update audigent RTD provider for new spec
Sep 30, 2020
5c9d00b
design changes
omerDotan Oct 4, 2020
efe5ddf
Merge remote-tracking branch 'upstream/master'
omerDotan Oct 4, 2020
0bfb153
Merge branch 'master' into RTD-phase3
omerDotan Oct 4, 2020
06b069e
fix loop continuation
bretg Oct 9, 2020
db41bf8
proper fix this time
bretg Oct 9, 2020
6c4ec0d
linter
bretg Oct 9, 2020
d009945
Merge remote-tracking branch 'browsi/RTD-phase3' into rtd3
Oct 12, 2020
a329e4a
update rtd parameters, onDone semantics
Oct 12, 2020
578049e
reduce loops
omerDotan Oct 13, 2020
cd50737
Merge remote-tracking branch 'browsi/RTD-phase3'
Oct 14, 2020
aec311a
documentation update
Oct 14, 2020
b876ed0
working update to rtd3 spec, update segment example, documentation
Oct 14, 2020
ede5682
remove unused vars, reference module name
Oct 14, 2020
71b9763
resolve haloid for segments
Oct 16, 2020
0e061c4
update documentation to markdown
Oct 16, 2020
2461a6e
update description in documentation
Oct 16, 2020
b9a971c
minify optimizations
Oct 19, 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
86 changes: 65 additions & 21 deletions integrationExamples/gpt/audigentSegments_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@
{
code: 'test-div',
mediaTypes: {
banner: {
sizes: [[300,250],[300,600],[728,90]]
}
banner: {
sizes: [[300,250],[300,600],[728,90]]
}
},

bids: [
{
bidder: 'rubicon',
Expand Down Expand Up @@ -120,20 +119,9 @@
consentManagement: {
cmpApi: 'iab',
timeout: 1000,
allowAuctionWithoutConsent: true
defaultGdprScope: true
},
// consentManagement: {
// cmpApi: 'static',
// consentData: {
// consentString: 'BOEFEAyOEFEAyAHABDENAI4AAAB9vABAASA'
// vendorData: {
// purposeConsents: {
// '1': true
// }
// }
// }
// },
usersync: {
userSync: {
userIds: [{
name: "unifiedId",
params: {
Expand All @@ -145,6 +133,16 @@
name: "unifiedid",
expires: 30
},
}, {
name: "intentIqId",
params: {
partner: 0, //Set your real IntentIQ partner ID here for production.
},
storage: {
type: "cookie",
name: "intentIqId",
expires: 30
},
}, {
name: "id5Id",
params: {
Expand All @@ -157,6 +155,18 @@
refreshInSeconds: 8*3600 // Refresh frequency of cookies, defaulting to 'expires'
},

}, {
name: "merkleId",
params: {
ptk: '12345678-aaaa-bbbb-cccc-123456789abc', //Set your real merkle partner key here
pubid: 'EXAMPLE' //Set your real merkle publisher id here
},
storage: {
type: "html5",
name: "merkleId",
expires: 30
},

}, {
name: "parrableId",
params: {
Expand All @@ -174,7 +184,7 @@
// foo: '9879878907987',
// bar:'93939'
// }
}, {
}, {
name: 'identityLink',
params: {
pid: '14' // Set your real identityLink placement ID here
Expand All @@ -184,13 +194,46 @@
name: 'idl_env',
expires: 30
}
}, {
name: "sharedId",
params: {
syncTime: 60 // in seconds, default is 24 hours
},
storage: {
type: "cookie",
name: "sharedid",
expires: 28
}
}, {
name: 'lotamePanoramaId'
}, {
name: "liveIntentId",
params: {
publisherId: "9896876"
},
storage: {
type: "cookie",
name: "_li_pbid",
expires: 28
}
}, {
name: "zeotapIdPlus"
}, {
name: 'haloId',
storage: {
type: "cookie",
name: "haloId",
expires: 28
}
}, {
name: "quantcastId"
}],
syncDelay: 5000,
auctionDelay: 1000
auctionDelay: 1000
},
realTimeData: {
auctionDelay: 1000,
dataProviders: [{name: "audigent"}]
dataProviders: [{name: "audigent", waitForIt: true}]
}
});
pbjs.addAdUnits(adUnits);
Expand All @@ -199,7 +242,7 @@

function sendAdserverRequest() {
document.getElementById('tdid').innerHTML = adUnits[0].bids[0].userId['tdid'];
document.getElementById('audigent_segments').innerHTML = JSON.stringify(adUnits[0].bids[0].realTimeData.audigent_segments);
document.getElementById('audigent_segments').innerHTML = JSON.stringify(adUnits[0].bids[0].audigent_segments);

if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
Expand Down Expand Up @@ -246,6 +289,7 @@ <h2>Audigent Segments Prebid</h2>
googletag.cmd.push(function() { googletag.display('test-div'); });
</script>
</div>

TDID:
<div id='tdid'>
</div>
Expand Down
138 changes: 66 additions & 72 deletions modules/audigentRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
* @property {string} pubKey
* @property {string} url
* @property {?string} keyName
* @property {number} auctionDelay
*/

import {config} from '../src/config.js';
import {getGlobal} from '../src/prebidGlobal.js';
import * as utils from '../src/utils.js';
import {submodule} from '../src/hook.js';
Expand All @@ -26,116 +24,112 @@ const storage = getStorageManager();

/** @type {string} */
const MODULE_NAME = 'realTimeData';

/** @type {ModuleParams} */
let _moduleParams = {};
const SUBMODULE_NAME = 'audigent';

/**
* XMLHttpRequest to get data form audigent server
* @param {string} url server url with query params
*/

export function setData(data) {
storage.setDataInLocalStorage('__adgntseg', JSON.stringify(data));
}

function getSegments(adUnits, onDone) {
try {
let jsonData = storage.getDataFromLocalStorage('__adgntseg');
if (jsonData) {
let data = JSON.parse(jsonData);
if (data.audigent_segments) {
let dataToReturn = adUnits.reduce((rp, cau) => {
const adUnitCode = cau && cau.code;
if (!adUnitCode) { return rp }
rp[adUnitCode] = data;
return rp;
}, {});

onDone(dataToReturn);
return;
}
function addSegmentData(adUnits, data) {
adUnits.forEach(adUnit => {
if (adUnit.hasOwnProperty('bids')) {
adUnit.bids.forEach(bid => {
bid.audigent_segments = data;
})
}
getSegmentsAsync(adUnits, onDone);
} catch (e) {
getSegmentsAsync(adUnits, onDone);
}
})

return adUnits;
}

function getSegmentsAsync(adUnits, onDone) {
function getSegments(reqBidsConfigObj, onDone, config, userConsent) {
const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits;

let jsonData = storage.getDataFromLocalStorage('__adgntseg');
antlauzon marked this conversation as resolved.
Show resolved Hide resolved
if (jsonData) {
let data = JSON.parse(jsonData);
if (data.audigent_segments) {
addSegmentData(adUnits, data.audigent_segments);
onDone();
return;
}
}

const userIds = (getGlobal()).getUserIds();
let tdid = null;
if (typeof userIds == 'undefined' || userIds == null) {
onDone();
return;
}

if (userIds && userIds['tdid']) {
tdid = userIds['tdid'];
if (storage.getDataFromLocalStorage('auHaloId')) {
antlauzon marked this conversation as resolved.
Show resolved Hide resolved
let haloId = storage.getDataFromLocalStorage('auHaloId');
userIds.haloId = haloId;
getSegmentsAsync(adUnits, onDone, config, userConsent, userIds);
} else {
onDone({});
var script = document.createElement('script')
script.type = 'text/javascript';

script.onload = function() {
userIds.haloId = storage.getDataFromLocalStorage('auHaloId');
getSegmentsAsync(adUnits, onDone, config, userConsent, userIds);
}

script.src = 'https://id.halo.ad.gt/api/v1/haloid';
document.getElementsByTagName('head')[0].appendChild(script);
}
}

const url = `https://seg.ad.gt/api/v1/rtb_segments?tdid=${tdid}`;
function getSegmentsAsync(adUnits, onDone, config, userConsent, userIds) {
let reqParams = {}
if (typeof config == 'object' && config != null && Object.keys(config).length > 0) {
reqParams = config.params
}

const url = `https://seg.halo.ad.gt/api/v1/rtb_segments`;
ajax(url, {
success: function (response, req) {
if (req.status === 200) {
try {
const data = JSON.parse(response);
if (data && data.audigent_segments) {
addSegmentData(adUnits, data.audigent_segments);
onDone();
setData(data);
let dataToReturn = adUnits.reduce((rp, cau) => {
const adUnitCode = cau && cau.code;
if (!adUnitCode) { return rp }
rp[adUnitCode] = data;
return rp;
}, {});

onDone(dataToReturn);
} else {
onDone({});
onDone();
}
} catch (err) {
utils.logError('unable to parse audigent segment data');
onDone({})
onDone();
}
} else if (req.status === 204) {
// unrecognized site key
onDone({});
// unrecognized partner config
onDone();
}
},
error: function () {
onDone({});
onDone();
utils.logError('unable to get audigent segment data');
}
}
},
JSON.stringify({'userIds': userIds, 'config': reqParams}),
{contentType: 'application/json'}
);
}

export function init(config) {
return true;
}

/** @type {RtdSubmodule} */
export const audigentSubmodule = {
/**
* used to link submodule with realTimeData
* @type {string}
*/
name: 'audigent',
/**
* get data and send back to realTimeData module
* @function
* @param {adUnit[]} adUnits
* @param {function} onDone
*/
getData: getSegments
name: SUBMODULE_NAME,
getBidRequestData: getSegments,
init: init
};

export function init(config) {
const confListener = config.getConfig(MODULE_NAME, ({realTimeData}) => {
try {
_moduleParams = realTimeData.dataProviders && realTimeData.dataProviders.filter(pr => pr.name && pr.name.toLowerCase() === 'audigent')[0].params;
_moduleParams.auctionDelay = realTimeData.auctionDelay;
} catch (e) {
_moduleParams = {};
}
confListener();
});
}

submodule('realTimeData', audigentSubmodule);
init(config);
submodule(MODULE_NAME, audigentSubmodule);
Loading