mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-12 01:17:04 +02:00
fix: metrics apps should be selected from the longest time span (#5923)
This commit is contained in:
parent
f61750a755
commit
6a55964ce8
@ -3,6 +3,7 @@ import { PageContent } from 'component/common/PageContent/PageContent';
|
|||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
FEATURE_METRIC_HOURS_BACK_DEFAULT,
|
FEATURE_METRIC_HOURS_BACK_DEFAULT,
|
||||||
|
FEATURE_METRIC_HOURS_BACK_MAX,
|
||||||
FeatureMetricsHours,
|
FeatureMetricsHours,
|
||||||
} from './FeatureMetricsHours/FeatureMetricsHours';
|
} from './FeatureMetricsHours/FeatureMetricsHours';
|
||||||
import { IFeatureMetricsRaw } from 'interfaces/featureToggle';
|
import { IFeatureMetricsRaw } from 'interfaces/featureToggle';
|
||||||
@ -21,6 +22,7 @@ import {
|
|||||||
withDefault,
|
withDefault,
|
||||||
} from 'use-query-params';
|
} from 'use-query-params';
|
||||||
import { aggregateFeatureMetrics } from './aggregateFeatureMetrics';
|
import { aggregateFeatureMetrics } from './aggregateFeatureMetrics';
|
||||||
|
import { useExtendedFeatureMetrics } from './useExtendedFeatureMetrics';
|
||||||
|
|
||||||
export const FeatureMetrics = () => {
|
export const FeatureMetrics = () => {
|
||||||
const projectId = useRequiredPathParam('projectId');
|
const projectId = useRequiredPathParam('projectId');
|
||||||
@ -163,9 +165,12 @@ const useFeatureMetricsEnvironments = (
|
|||||||
// Get all application names for a feature. Fetch apps for the max time range
|
// Get all application names for a feature. Fetch apps for the max time range
|
||||||
// so that the list of apps doesn't change when selecting a shorter range.
|
// so that the list of apps doesn't change when selecting a shorter range.
|
||||||
const useFeatureMetricsApplications = (featureId: string): Set<string> => {
|
const useFeatureMetricsApplications = (featureId: string): Set<string> => {
|
||||||
|
const extendedOptions = useExtendedFeatureMetrics();
|
||||||
const { featureMetrics = [] } = useFeatureMetricsRaw(
|
const { featureMetrics = [] } = useFeatureMetricsRaw(
|
||||||
featureId,
|
featureId,
|
||||||
FEATURE_METRIC_HOURS_BACK_DEFAULT,
|
extendedOptions
|
||||||
|
? FEATURE_METRIC_HOURS_BACK_MAX
|
||||||
|
: FEATURE_METRIC_HOURS_BACK_DEFAULT,
|
||||||
);
|
);
|
||||||
|
|
||||||
const applications = featureMetrics.map((metric) => {
|
const applications = featureMetrics.map((metric) => {
|
||||||
|
@ -6,6 +6,7 @@ import { subWeeks, subMonths, differenceInHours } from 'date-fns';
|
|||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag';
|
import { useUiFlag } from 'hooks/useUiFlag';
|
||||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
import { useExtendedFeatureMetrics } from '../useExtendedFeatureMetrics';
|
||||||
|
|
||||||
const StyledTitle = styled('h2')(({ theme }) => ({
|
const StyledTitle = styled('h2')(({ theme }) => ({
|
||||||
margin: 0,
|
margin: 0,
|
||||||
@ -36,9 +37,7 @@ export const FeatureMetricsHours = ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const { isEnterprise } = useUiConfig();
|
const extendedOptions = useExtendedFeatureMetrics();
|
||||||
const extendedUsageMetrics = useUiFlag('extendedUsageMetricsUI');
|
|
||||||
const extendedOptions = isEnterprise() && extendedUsageMetrics;
|
|
||||||
const options = extendedOptions
|
const options = extendedOptions
|
||||||
? [...hourOptions, ...daysOptions]
|
? [...hourOptions, ...daysOptions]
|
||||||
: hourOptions;
|
: hourOptions;
|
||||||
@ -89,3 +88,8 @@ const daysOptions: { key: `${number}`; label: string }[] = [
|
|||||||
label: 'Last 3 months',
|
label: 'Last 3 months',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const FEATURE_METRIC_HOURS_BACK_MAX = differenceInHours(
|
||||||
|
now,
|
||||||
|
subMonths(now, 3),
|
||||||
|
);
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
|
import { useUiFlag } from 'hooks/useUiFlag';
|
||||||
|
|
||||||
|
export const useExtendedFeatureMetrics = () => {
|
||||||
|
const { isEnterprise } = useUiConfig();
|
||||||
|
const extendedUsageMetrics = useUiFlag('extendedUsageMetricsUI');
|
||||||
|
const extendedOptions = isEnterprise() && extendedUsageMetrics;
|
||||||
|
|
||||||
|
return extendedOptions;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user