1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

refactor: remove unused feature metrics state (#690)

This commit is contained in:
olav 2022-02-09 14:48:32 +01:00 committed by GitHub
parent b7d106d7ab
commit 460a376903
4 changed files with 0 additions and 102 deletions

View File

@ -1,54 +0,0 @@
import api from './api';
export const START_FETCH_FEATURE_METRICS = 'START_FETCH_FEATURE_METRICS';
export const RECEIVE_FEATURE_METRICS = 'RECEIVE_FEATURE_METRICS';
export const ERROR_FETCH_FEATURE_METRICS = 'ERROR_FETCH_FEATURE_METRICS';
export const START_FETCH_SEEN_APP = 'START_FETCH_SEEN_APP';
export const RECEIVE_SEEN_APPS = 'RECEIVE_SEEN_APPS';
export const ERROR_FETCH_SEEN_APP = 'ERROR_FETCH_SEEN_APP';
function receiveFeatureMetrics(json) {
return {
type: RECEIVE_FEATURE_METRICS,
value: json,
receivedAt: Date.now(),
};
}
function receiveSeenApps(json) {
return {
type: RECEIVE_SEEN_APPS,
value: json,
receivedAt: Date.now(),
};
}
function dispatchAndThrow(dispatch, type) {
return error => {
dispatch({ type, error, receivedAt: Date.now() });
// throw error;
};
}
export function fetchFeatureMetrics() {
return dispatch => {
dispatch({ type: START_FETCH_FEATURE_METRICS });
return api
.fetchFeatureMetrics()
.then(json => dispatch(receiveFeatureMetrics(json)))
.catch(dispatchAndThrow(dispatch, ERROR_FETCH_FEATURE_METRICS));
};
}
export function fetchSeenApps() {
return dispatch => {
dispatch({ type: START_FETCH_SEEN_APP });
return api
.fetchSeenApps()
.then(json => dispatch(receiveSeenApps(json)))
.catch(dispatchAndThrow(dispatch, ERROR_FETCH_SEEN_APP));
};
}

View File

@ -1,23 +0,0 @@
import { formatApiPath } from '../../utils/format-path';
import { throwIfNotSuccess } from '../api-helper';
const URI = formatApiPath('api/admin/metrics/feature-toggles');
function fetchFeatureMetrics() {
return fetch(URI, { credentials: 'include' })
.then(throwIfNotSuccess)
.then(response => response.json());
}
const seenURI = formatApiPath('api/admin/metrics/seen-apps');
function fetchSeenApps() {
return fetch(seenURI, { credentials: 'include' })
.then(throwIfNotSuccess)
.then(response => response.json());
}
export default {
fetchFeatureMetrics,
fetchSeenApps,
};

View File

@ -1,23 +0,0 @@
import { Map as $Map, fromJS } from 'immutable';
import { RECEIVE_FEATURE_METRICS, RECEIVE_SEEN_APPS } from './actions';
const metrics = (
state = fromJS({ lastHour: {}, lastMinute: {}, seenApps: {} }),
action
) => {
switch (action.type) {
case RECEIVE_SEEN_APPS:
return state.set('seenApps', new $Map(action.value));
case RECEIVE_FEATURE_METRICS:
return state.withMutations(ctx => {
ctx.set('lastHour', new $Map(action.value.lastHour));
ctx.set('lastMinute', new $Map(action.value.lastMinute));
return ctx;
});
default:
return state;
}
};
export default metrics;

View File

@ -1,6 +1,5 @@
import { combineReducers } from 'redux';
import features from './feature-toggle';
import featureMetrics from './feature-metrics';
import tagTypes from './tag-type';
import tags from './tag';
import strategies from './strategy';
@ -13,7 +12,6 @@ import apiCalls from './api-calls';
const unleashStore = combineReducers({
features,
featureMetrics,
strategies,
tagTypes,
tags,