forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpianoDmpAnalyticsAdapter.js
38 lines (31 loc) · 1.07 KB
/
pianoDmpAnalyticsAdapter.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
34
35
36
37
38
import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js';
import adapterManager from '../src/adapterManager.js';
const pianoDmpAnalytics = adapter({ analyticsType: 'bundle', handler: 'on' });
const { enableAnalytics: _enableAnalytics } = pianoDmpAnalytics;
Object.assign(pianoDmpAnalytics, {
/**
* Save event in the global array that will be consumed later by cx.js
*/
track: ({ eventType, args: params }) => {
window.cX.callQueue.push([
'prebid',
{ eventType, params, time: Date.now() },
]);
},
/**
* Before forwarding the call to the original enableAnalytics function -
* create (if needed) the global array that is used to pass events to the cx.js library
* by the 'track' function above.
*/
enableAnalytics: function (...args) {
window.cX = window.cX || {};
window.cX.callQueue = window.cX.callQueue || [];
return _enableAnalytics.call(this, ...args);
},
});
adapterManager.registerAnalyticsAdapter({
adapter: pianoDmpAnalytics,
code: 'pianoDmp',
gvlid: 412,
});
export default pianoDmpAnalytics;