Commit 61bcc936 authored by Jose Vargas's avatar Jose Vargas

Create constants for the tracking labels

parent b4db572c
export const dateFormatMask = 'mmm dd HH:MM:ss.l';
export const TOKEN_TYPE_POD_NAME = 'TOKEN_TYPE_POD_NAME';
export const tracking = {
USED_SEARCH_BAR: 'used_search_bar',
POD_LOG_CHANGED: 'pod_log_changed',
TIME_RANGE_SET: 'time_range_set',
ENVIRONMENT_SELECTED: 'environment_selected',
};
import Tracking from '~/tracking';
const trackLogs = ({ label, value }) =>
/**
* The value of 1 in count, means there was one action performed
* related to the tracked action, in either of the following categories
* 1. Refreshing the logs
* 2. Select an environment
* 3. Change the time range
* 4. Use the search bar
*/
const trackLogs = label =>
Tracking.event(document.body.dataset.page, 'logs_view', {
label,
property: 'count',
value,
value: 1,
});
export default trackLogs;
......@@ -2,7 +2,7 @@ import { backOff } from '~/lib/utils/common_utils';
import httpStatusCodes from '~/lib/utils/http_status';
import axios from '~/lib/utils/axios_utils';
import { convertToFixedRange } from '~/lib/utils/datetime_range';
import { TOKEN_TYPE_POD_NAME } from '../constants';
import { TOKEN_TYPE_POD_NAME, tracking } from '../constants';
import trackLogs from '../logs_tracking_helper';
import * as types from './mutation_types';
......@@ -82,22 +82,22 @@ export const showFilteredLogs = ({ dispatch, commit }, filters = []) => {
commit(types.SET_CURRENT_POD_NAME, podName);
commit(types.SET_SEARCH, search);
dispatch('fetchLogs', 'used_search_bar');
dispatch('fetchLogs', tracking.USED_SEARCH_BAR);
};
export const showPodLogs = ({ dispatch, commit }, podName) => {
commit(types.SET_CURRENT_POD_NAME, podName);
dispatch('fetchLogs', 'pod_log_changed');
dispatch('fetchLogs', tracking.POD_LOG_CHANGED);
};
export const setTimeRange = ({ dispatch, commit }, timeRange) => {
commit(types.SET_TIME_RANGE, timeRange);
dispatch('fetchLogs', 'time_range_set');
dispatch('fetchLogs', tracking.TIME_RANGE_SET);
};
export const showEnvironment = ({ dispatch, commit }, environmentName) => {
commit(types.SET_PROJECT_ENVIRONMENT, environmentName);
dispatch('fetchLogs', 'enviroment_selected');
dispatch('fetchLogs', tracking.ENVIRONMENT_SELECTED);
};
/**
......@@ -112,24 +112,21 @@ export const fetchEnvironments = ({ commit, dispatch }, environmentsPath) => {
.get(environmentsPath)
.then(({ data }) => {
commit(types.RECEIVE_ENVIRONMENTS_DATA_SUCCESS, data.environments);
dispatch('fetchLogs', 'environment_selected');
dispatch('fetchLogs', tracking.ENVIRONMENT_SELECTED);
})
.catch(() => {
commit(types.RECEIVE_ENVIRONMENTS_DATA_ERROR);
});
};
export const fetchLogs = ({ commit, state }, label) => {
export const fetchLogs = ({ commit, state }, trackingLabel) => {
commit(types.REQUEST_LOGS_DATA);
return requestLogsUntilData({ commit, state })
.then(({ data }) => {
const { pod_name, pods, logs, cursor } = data;
if (logs && logs.length > 0) {
trackLogs({
label,
value: 1,
});
trackLogs(trackingLabel);
}
commit(types.RECEIVE_LOGS_DATA_SUCCESS, { logs, cursor });
commit(types.SET_CURRENT_POD_NAME, pod_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment