forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrivrAnalyticsAdapter.js
34 lines (28 loc) · 1.23 KB
/
rivrAnalyticsAdapter.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
import {ajax} from '../src/ajax.js';
import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js';
import adapterManager from '../src/adapterManager.js';
import * as utils from '../src/utils.js';
import {getGlobal} from '../src/prebidGlobal.js';
const analyticsType = 'endpoint';
let rivrAnalytics = Object.assign(adapter({analyticsType}), {
track({ eventType, args }) {
if (window.rivraddon && window.rivraddon.analytics && window.rivraddon.analytics.getContext() && window.rivraddon.analytics.trackPbjsEvent) {
utils.logInfo(`ARGUMENTS FOR TYPE: ============= ${eventType}`, args);
window.rivraddon.analytics.trackPbjsEvent({ eventType, args });
}
}
});
// save the base class function
rivrAnalytics.originEnableAnalytics = rivrAnalytics.enableAnalytics;
// override enableAnalytics so we can get access to the config passed in from the page
rivrAnalytics.enableAnalytics = (config) => {
if (window.rivraddon && window.rivraddon.analytics) {
window.rivraddon.analytics.enableAnalytics(config, {utils, ajax, pbjsGlobalVariable: getGlobal()});
rivrAnalytics.originEnableAnalytics(config);
}
};
adapterManager.registerAnalyticsAdapter({
adapter: rivrAnalytics,
code: 'rivr'
});
export default rivrAnalytics;