debian-mirror-gitlab/app/assets/javascripts/experimentation/experiment_tracking.js

25 lines
588 B
JavaScript
Raw Normal View History

2021-04-17 20:07:23 +05:30
import Tracking from '~/tracking';
import { TRACKING_CONTEXT_SCHEMA } from './constants';
import { getExperimentData } from './utils';
export default class ExperimentTracking {
constructor(experimentName, trackingArgs = {}) {
this.trackingArgs = trackingArgs;
this.data = getExperimentData(experimentName);
}
event(action) {
if (!this.data) {
return false;
}
return Tracking.event(document.body.dataset.page, action, {
...this.trackingArgs,
context: {
schema: TRACKING_CONTEXT_SCHEMA,
data: this.data,
},
});
}
}