mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-14 01:16:17 +02:00
refactor: remove unused feature metrics state (#690)
This commit is contained in:
parent
b7d106d7ab
commit
460a376903
@ -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));
|
|
||||||
};
|
|
||||||
}
|
|
@ -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,
|
|
||||||
};
|
|
@ -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;
|
|
@ -1,6 +1,5 @@
|
|||||||
import { combineReducers } from 'redux';
|
import { combineReducers } from 'redux';
|
||||||
import features from './feature-toggle';
|
import features from './feature-toggle';
|
||||||
import featureMetrics from './feature-metrics';
|
|
||||||
import tagTypes from './tag-type';
|
import tagTypes from './tag-type';
|
||||||
import tags from './tag';
|
import tags from './tag';
|
||||||
import strategies from './strategy';
|
import strategies from './strategy';
|
||||||
@ -13,7 +12,6 @@ import apiCalls from './api-calls';
|
|||||||
|
|
||||||
const unleashStore = combineReducers({
|
const unleashStore = combineReducers({
|
||||||
features,
|
features,
|
||||||
featureMetrics,
|
|
||||||
strategies,
|
strategies,
|
||||||
tagTypes,
|
tagTypes,
|
||||||
tags,
|
tags,
|
||||||
|
Loading…
Reference in New Issue
Block a user