diff --git a/frontend/src/component/insights/Insights.test.tsx b/frontend/src/component/insights/Insights.test.tsx deleted file mode 100644 index 555b0fb7a3..0000000000 --- a/frontend/src/component/insights/Insights.test.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { render } from 'utils/testRenderer'; -import { fireEvent, screen } from '@testing-library/react'; -import { Insights } from './Insights.tsx'; -import { testServerRoute, testServerSetup } from 'utils/testServer'; -import { vi } from 'vitest'; - -const server = testServerSetup(); - -const setupApi = () => { - testServerRoute(server, '/api/admin/insights', { - users: { total: 0, active: 0, inactive: 0 }, - userTrends: [], - projectFlagTrends: [], - metricsSummaryTrends: [], - flags: { total: 0 }, - flagTrends: [], - environmentTypeTrends: [], - lifecycleTrends: [], - creationArchiveTrends: [], - }); - - testServerRoute(server, '/api/admin/projects', { - projects: [ - { name: 'Project A Name', id: 'projectA' }, - { name: 'Project B Name', id: 'projectB' }, - ], - }); -}; - -const currentTime = '2024-04-25T08:05:00.000Z'; - -// todo(lifecycleMetrics): this test won't be relevant anymore because the -// filters are on each section instead of the top-level component. Consider -// rewriting this for the individual section components instead. -test('Filter insights by project and date', async () => { - vi.setSystemTime(currentTime); - setupApi(); - render(); - const addFilter = await screen.findByText('Filter'); - fireEvent.click(addFilter); - const projectFilter = await screen.findByText('Project'); - - // filter by project - fireEvent.click(projectFilter); - await screen.findByText('Project A Name'); - const projectName = await screen.findByText('Project B Name'); - await fireEvent.click(projectName); - expect(window.location.href).toContain('project=IS%3AprojectB'); - - // last month moving window by default - const fromDate = await screen.findByText('03/25/2024'); - await screen.findByText('04/25/2024'); - - // change dates by preset range - fireEvent.click(fromDate); - const previousMonth = await screen.findByText('Previous month'); - fireEvent.click(previousMonth); - await screen.findByText('03/01/2024'); - await screen.findByText('03/31/2024'); - expect(window.location.href).toContain( - '?project=IS%3AprojectB&from=IS%3A2024-03-01&to=IS%3A2024-03-31', - ); -}); diff --git a/frontend/src/component/insights/Insights.tsx b/frontend/src/component/insights/Insights.tsx index 76ab5b3e92..563e23a023 100644 --- a/frontend/src/component/insights/Insights.tsx +++ b/frontend/src/component/insights/Insights.tsx @@ -1,8 +1,6 @@ import type { FC } from 'react'; import { styled } from '@mui/material'; import { InsightsHeader } from './components/InsightsHeader/InsightsHeader.tsx'; -import { useUiFlag } from 'hooks/useUiFlag.ts'; -import { LegacyInsights } from './LegacyInsights.tsx'; import { StyledContainer } from './InsightsCharts.styles.ts'; import { LifecycleInsights } from './sections/LifecycleInsights.tsx'; import { PerformanceInsights } from './sections/PerformanceInsights.tsx'; @@ -12,21 +10,13 @@ const StyledWrapper = styled('div')(({ theme }) => ({ paddingTop: theme.spacing(2), })); -const NewInsights: FC = () => { - return ( - - - - - - - - - ); -}; - -export const Insights: FC<{ withCharts?: boolean }> = (props) => { - const useNewInsights = useUiFlag('lifecycleMetrics'); - - return useNewInsights ? : ; -}; +export const Insights: FC = () => ( + + + + + + + + +); diff --git a/frontend/src/component/insights/InsightsCharts.tsx b/frontend/src/component/insights/InsightsCharts.tsx index ec93c658df..9656343411 100644 --- a/frontend/src/component/insights/InsightsCharts.tsx +++ b/frontend/src/component/insights/InsightsCharts.tsx @@ -127,55 +127,51 @@ export const InsightsCharts: FC = ({ - - - - - - - - - - + + + + + + + + + } elseShow={ - <> - - - - - - - - - - + + + + + + + + + } /> = ({ - - - - - - - - - - + + + + + + + + + } elseShow={ - <> - - - - - - - - - - + + + + + + + + + } /> = ({ ...filterProps }) => { const { projects } = useProjects(); - const FilterComponent = useUiFlag('lifecycleMetrics') - ? FiltersNoPadding - : Filters; const [availableFilters, setAvailableFilters] = useState([]); @@ -81,7 +77,7 @@ export const InsightsFilters: FC = ({ }, [JSON.stringify(projects)]); return ( - ({ - paddingTop: theme.spacing(2), -})); - -const StickyContainer = styled(Sticky)(({ theme }) => ({ - position: 'sticky', - top: 0, - zIndex: theme.zIndex.sticky, - padding: theme.spacing(2, 0), - background: theme.palette.background.application, - transition: 'padding 0.3s ease', -})); - -interface InsightsProps { - withCharts?: boolean; -} - -export const LegacyInsights: FC = ({ withCharts = true }) => { - const stateConfig = { - project: FilterItemParam, - from: withDefault(FilterItemParam, { - values: [format(subMonths(new Date(), 1), 'yyyy-MM-dd')], - operator: 'IS', - }), - to: withDefault(FilterItemParam, { - values: [format(new Date(), 'yyyy-MM-dd')], - operator: 'IS', - }), - }; - const [state, setState] = usePersistentTableState('insights', stateConfig, [ - 'from', - 'to', - ]); - - const { insights, loading } = useInsights( - state.from?.values[0], - state.to?.values[0], - ); - - const projects = state.project?.values ?? [allOption.id]; - - const insightsData = useInsightsData(insights, projects); - - return ( - - - - } - /> - - {withCharts && ( - - )} - - ); -}; diff --git a/frontend/src/component/insights/componentsStat/FlagStats/FlagStats.tsx b/frontend/src/component/insights/componentsStat/FlagStats/FlagStats.tsx index d2eb5399e5..f394c9c78b 100644 --- a/frontend/src/component/insights/componentsStat/FlagStats/FlagStats.tsx +++ b/frontend/src/component/insights/componentsStat/FlagStats/FlagStats.tsx @@ -1,7 +1,5 @@ import Icon from '@mui/material/Icon'; import { Box, Typography, styled } from '@mui/material'; -import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; -import { useUiFlag } from 'hooks/useUiFlag'; import { useId } from 'hooks/useId'; import { ScreenReaderOnly } from 'component/common/ScreenReaderOnly/ScreenReaderOnly'; import { HelpIcon } from 'component/common/HelpIcon/HelpIcon'; @@ -79,27 +77,19 @@ const LabelContainer = styled('div')({ interface IFlagStatsProps { count: number; - flagsPerUser?: string; // todo: remove this prop with the lifecycleMetrics flag isLoading?: boolean; } -export const FlagStats: React.FC = ({ - count, - flagsPerUser, - isLoading, -}) => { - const hideFlagsPerUser = useUiFlag('lifecycleMetrics'); - const labelId = hideFlagsPerUser ? useId() : ''; - const descriptionId = hideFlagsPerUser ? useId() : ''; +export const FlagStats: React.FC = ({ count, isLoading }) => { + const labelId = useId(); + const descriptionId = useId(); return ( <> {isLoading ? ( @@ -112,50 +102,20 @@ export const FlagStats: React.FC = ({ - {hideFlagsPerUser ? ( - - - Total number of flags - - - - - - ) : ( - + + Total number of flags + + - - - award_star - - Insights - - - - Flags per user - - - - {flagsPerUser} - - - } - /> - )} + > + + + ); }; diff --git a/frontend/src/component/insights/sections/PerformanceInsights.tsx b/frontend/src/component/insights/sections/PerformanceInsights.tsx index efc4d4895b..e19f9abd64 100644 --- a/frontend/src/component/insights/sections/PerformanceInsights.tsx +++ b/frontend/src/component/insights/sections/PerformanceInsights.tsx @@ -61,7 +61,6 @@ export const PerformanceInsights: FC = () => { summary, groupedProjectsData, groupedLifecycleData, - userTrends, groupedMetricsData, allMetricsDatapoints, environmentTypeTrends, @@ -69,8 +68,6 @@ export const PerformanceInsights: FC = () => { } = useInsightsData(insights, projects); const { isEnterprise } = useUiConfig(); - const lastUserTrend = userTrends[userTrends.length - 1]; - const usersTotal = lastUserTrend?.total ?? 0; const lastFlagTrend = flagTrends[flagTrends.length - 1]; const flagsTotal = lastFlagTrend?.total ?? 0; @@ -137,14 +134,7 @@ export const PerformanceInsights: FC = () => { - + { - + { strictSchemaValidation: true, reportUnknownFlags: true, customMetrics: true, - lifecycleMetrics: true, impactMetrics: true, paygTrialEvents: true, lifecycleGraphs: true,