Skip to content

Commit

Permalink
Merge branch 'develop' into chore/setup-wizard-step-four
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoevanp authored Sep 27, 2023
2 parents f95ebc1 + 699f10d commit 643766c
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-monkeys-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Changed the name of the administration Logs page to "Records", implemented a tab layout in this page and added a new tab called "Analytic reports" that shows the most recent result of the statistics endpoint.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type DateRangePickerProps = Omit<ComponentProps<typeof Box>, 'onChange'> & {
onChange(range: { start: string; end: string }): void;
};

const formatToDateInput = (date: Moment) => date.format('YYYY-MM-DD');
const formatToDateInput = (date: Moment) => date.locale('en').format('YYYY-MM-DD');

const todayDate = formatToDateInput(moment());

Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/client/views/admin/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ declare module '@rocket.chat/ui-contexts' {
pattern: '/admin/registration/:page?';
};
'admin-view-logs': {
pathname: '/admin/logs';
pattern: '/admin/logs';
pathname: '/admin/records';
pattern: '/admin/records';
};
'federation-dashboard': {
pathname: '/admin/federation';
Expand Down Expand Up @@ -193,7 +193,7 @@ registerAdminRoute('/registration/:page?', {
component: lazy(() => import('./cloud/CloudRoute')),
});

registerAdminRoute('/logs', {
registerAdminRoute('/records', {
name: 'admin-view-logs',
component: lazy(() => import('./viewLogs/ViewLogsRoute')),
});
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/client/views/admin/sidebarItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export const {
permissionGranted: (): boolean => hasPermission('run-import'),
},
{
href: '/admin/logs',
i18nLabel: 'Logs',
href: '/admin/records',
i18nLabel: 'Records',
icon: 'post',
permissionGranted: (): boolean => hasPermission('view-logs'),
},
Expand Down
38 changes: 38 additions & 0 deletions apps/meteor/client/views/admin/viewLogs/AnalyticsReports.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Box, Icon, Skeleton } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import React from 'react';

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

const AnalyticsReports = () => {
const t = useTranslation();

const { data, isLoading, isSuccess, isError } = useAnalyticsObject();

return (
<>
<Box p={20} pbe={28} mbe={24}>
<Box display='flex' flexDirection='row' alignItems='center' mbe={20}>
<Box display='flex' justifyContent='center' alignItems='center' borderRadius={2} p={4} mie={8} bg='status-background-info'>
<Icon name='info' size={20} color='info' />
</Box>
<Box fontScale='h4'>{t('How_and_why_we_collect_usage_data')}</Box>
</Box>
<Box fontScale='p1'>{t('Analytics_page_briefing')}</Box>
</Box>
<Box display='flex' flexDirection='column' padding={8} flexGrow={1} color='default' bg='neutral' borderRadius={4} overflow='scroll'>
{isSuccess && <pre>{JSON.stringify(data, null, '\t')}</pre>}
{isError && t('Something_went_wrong_try_again_later')}
{isLoading && (
<>
<Skeleton />
<Skeleton />
<Skeleton />
</>
)}
</Box>
</>
);
};

export default AnalyticsReports;
18 changes: 15 additions & 3 deletions apps/meteor/client/views/admin/viewLogs/ViewLogsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import { Tabs } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React from 'react';
import React, { useState } from 'react';

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

const ViewLogsPage = (): ReactElement => {
const t = useTranslation();

const [tab, setTab] = useState('Logs');

return (
<Page>
<Page.Header title={t('Logs')} />
<Page.Header title={t('Records')} />
<Page.Content>
<ServerLogs />
<Tabs mbe={24}>
<Tabs.Item onClick={() => setTab('Logs')} selected={tab === 'Logs'}>
{t('Logs')}
</Tabs.Item>
<Tabs.Item onClick={() => setTab('Analytics')} selected={tab === 'Analytics'}>
{t('Analytic_reports')}
</Tabs.Item>
</Tabs>
{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({}), { staleTime: 10 * 60 * 1000 });
};
4 changes: 4 additions & 0 deletions apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@
"Also_send_to_channel": "Also send to channel",
"Always_open_in_new_window": "Always Open in New Window",
"Always_show_thread_replies_in_main_channel": "Always show thread replies in main channel",
"Analytic_reports": "Analytic reports",
"Analytics": "Analytics",
"Analytics_Description": "See how users interact with your workspace.",
"Analytics_features_enabled": "Features Enabled",
Expand All @@ -423,6 +424,7 @@
"Analytics_features_users_Description": "Tracks custom events related to actions related to users (password reset times, profile picture change, etc).",
"Analytics_Google": "Google Analytics",
"Analytics_Google_id": "Tracking ID",
"Analytics_page_briefing": "Rocket.Chat collects anonymous usage data to identify how many instances are deployed and to improve the product for all users. We take your privacy seriously, so the usage data is encrypted and stored securely.",
"Analyze_practical_usage": "Analyze practical usage statistics about users, messages and channels",
"and": "and",
"And_more": "And {{length}} more",
Expand Down Expand Up @@ -2471,6 +2473,7 @@
"Hospitality_Businness": "Hospitality Business",
"hours": "hours",
"Hours": "Hours",
"How_and_why_we_collect_usage_data": "How and why we collect usage data",
"How_friendly_was_the_chat_agent": "How friendly was the chat agent?",
"How_knowledgeable_was_the_chat_agent": "How knowledgeable was the chat agent?",
"How_long_to_wait_after_agent_goes_offline": "How Long to Wait After Agent Goes Offline",
Expand Down Expand Up @@ -4165,6 +4168,7 @@
"Receive_Login_Detection_Emails_Description": "Receive an email each time a new login is detected on your account.",
"Recent_Import_History": "Recent Import History",
"Record": "Record",
"Records": "Records",
"recording": "recording",
"Redirect_URI": "Redirect URI",
"Redirect_URL_does_not_match": "Redirect URL does not match",
Expand Down

0 comments on commit 643766c

Please sign in to comment.