Skip to content

Commit

Permalink
feat: ✨ Fetch and show analytics reports object
Browse files Browse the repository at this point in the history
Fetched the /v1/statistics endpoint and showed its result object in a new component called AnalyticsReports
  • Loading branch information
rique223 committed Sep 12, 2023
1 parent 5cdc9e5 commit 59a1a5a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions apps/meteor/client/views/admin/viewLogs/AnalyticsReports.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Box } from '@rocket.chat/fuselage';
import React from 'react';

import { useAnalyticsObject } from './hooks/useAnalyticsObject';

const AnalyticsReports = () => {
const analytics = useAnalyticsObject();

return (
<Box display='flex' flexDirection='column' padding={8} flexGrow={1} color='default' bg='neutral' borderRadius='x4' overflow='scroll'>
<pre>{JSON.stringify(analytics, null, '\t')}</pre>
</Box>
);
};

export default AnalyticsReports;
3 changes: 2 additions & 1 deletion apps/meteor/client/views/admin/viewLogs/ViewLogsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { ReactElement } from 'react';
import React, { useState } from 'react';

import Page from '../../../components/Page';
import AnalyticsReports from './AnalyticsReports';
import ServerLogs from './ServerLogs';

const ViewLogsPage = (): ReactElement => {
Expand All @@ -23,7 +24,7 @@ const ViewLogsPage = (): ReactElement => {
{t('Analytic_reports')}
</Tabs.Item>
</Tabs>
<ServerLogs />
{tab === 'Logs' ? <ServerLogs /> : <AnalyticsReports />}
</Page.Content>
</Page>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useEndpoint } from '@rocket.chat/ui-contexts';
import { useQuery } from '@tanstack/react-query';

export const useAnalyticsObject = () => {
const getAnalytics = useEndpoint('GET', '/v1/statistics');

return useQuery(['analytics'], () => getAnalytics({}));
};

0 comments on commit 59a1a5a

Please sign in to comment.