2016-11-18 19:38:29 -05:00
|
|
|
/* eslint-disable no-param-reassign */
|
2016-10-20 00:34:16 -04:00
|
|
|
((global) => {
|
|
|
|
global.cycleAnalytics = global.cycleAnalytics || {};
|
|
|
|
|
|
|
|
class CycleAnalyticsService {
|
|
|
|
constructor(options) {
|
|
|
|
this.requestPath = options.requestPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchCycleAnalyticsData(options) {
|
|
|
|
options = options || { startDate: 30 };
|
|
|
|
|
|
|
|
return $.ajax({
|
|
|
|
url: this.requestPath,
|
|
|
|
method: 'GET',
|
|
|
|
dataType: 'json',
|
|
|
|
contentType: 'application/json',
|
|
|
|
data: {
|
|
|
|
cycle_analytics: {
|
2016-11-18 19:38:29 -05:00
|
|
|
start_date: options.startDate,
|
|
|
|
},
|
|
|
|
},
|
2016-10-20 00:34:16 -04:00
|
|
|
});
|
|
|
|
}
|
2016-10-20 19:24:36 -04:00
|
|
|
|
|
|
|
fetchStageData(options) {
|
2016-11-18 19:38:29 -05:00
|
|
|
const {
|
2016-10-20 19:24:36 -04:00
|
|
|
stage,
|
|
|
|
startDate,
|
|
|
|
} = options;
|
|
|
|
|
2016-11-18 14:32:06 -05:00
|
|
|
return $.get(`${this.requestPath}/events/${stage.title.toLowerCase()}.json`, {
|
2016-10-20 19:24:36 -04:00
|
|
|
cycle_analytics: {
|
2016-11-18 19:38:29 -05:00
|
|
|
start_date: startDate,
|
|
|
|
},
|
2016-10-20 19:24:36 -04:00
|
|
|
});
|
|
|
|
}
|
2016-11-18 19:38:29 -05:00
|
|
|
}
|
2016-10-20 00:34:16 -04:00
|
|
|
|
|
|
|
global.cycleAnalytics.CycleAnalyticsService = CycleAnalyticsService;
|
|
|
|
})(window.gl || (window.gl = {}));
|