2022-07-16 23:28:13 +05:30
|
|
|
import { Tracker } from 'jh_else_ce/tracking/tracker';
|
|
|
|
import { addExperimentContext } from './utils';
|
2021-11-11 11:23:49 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
const Tracking = Object.assign(Tracker, {
|
2021-10-27 15:23:28 +05:30
|
|
|
/**
|
|
|
|
* Returns an implementation of this class in the form of
|
|
|
|
* a Vue mixin.
|
|
|
|
*
|
|
|
|
* @param {Object} opts - default options for all events
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2022-07-16 23:28:13 +05:30
|
|
|
mixin(opts = {}) {
|
2021-10-27 15:23:28 +05:30
|
|
|
return {
|
|
|
|
computed: {
|
|
|
|
trackingCategory() {
|
|
|
|
const localCategory = this.tracking ? this.tracking.category : null;
|
|
|
|
return localCategory || opts.category;
|
|
|
|
},
|
|
|
|
trackingOptions() {
|
|
|
|
const options = addExperimentContext(opts);
|
|
|
|
return { ...options, ...this.tracking };
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
track(action, data = {}) {
|
|
|
|
const category = data.category || this.trackingCategory;
|
|
|
|
const options = {
|
|
|
|
...this.trackingOptions,
|
|
|
|
...data,
|
|
|
|
};
|
|
|
|
|
|
|
|
Tracking.event(category, action, options);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2022-07-16 23:28:13 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default Tracking;
|