forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelevantAnalyticsAdapter.js
33 lines (27 loc) · 1.1 KB
/
relevantAnalyticsAdapter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js';
import adapterManager from '../src/adapterManager.js';
const relevantAnalytics = adapter({ analyticsType: 'bundle', handler: 'on' });
const { enableAnalytics: orgEnableAnalytics } = relevantAnalytics;
Object.assign(relevantAnalytics, {
/**
* Save event in the global array that will be consumed later by the Relevant Yield library
*/
track: ({ eventType: ev, args }) => {
window.relevantDigital.pbEventLog.push({ ev, args, ts: new Date() });
},
/**
* Before forwarding the call to the original enableAnalytics function -
* create (if needed) the global array that is used to pass events to the Relevant Yield library
* by the 'track' function above.
*/
enableAnalytics: function(...args) {
window.relevantDigital = window.relevantDigital || {};
window.relevantDigital.pbEventLog = window.relevantDigital.pbEventLog || [];
return orgEnableAnalytics.call(this, ...args);
},
});
adapterManager.registerAnalyticsAdapter({
adapter: relevantAnalytics,
code: 'relevant',
});
export default relevantAnalytics;