Skip to content

feat: add events page filters #3418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/app/(main)/websites/[websiteId]/events/EventsMetricsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ import MetricCard from '@/components/metrics/MetricCard';
import MetricsBar from '@/components/metrics/MetricsBar';
import { formatLongNumber } from '@/lib/format';
import { Flexbox } from 'react-basics';
import WebsiteFilterButton from '../WebsiteFilterButton';
import styles from '../WebsiteMetricsBar.module.css';

export function EventsMetricsBar({ websiteId }: { websiteId: string }) {
export function EventsMetricsBar({
websiteId,
compareMode = false,
showFilter = false,
}: {
websiteId: string;
compareMode?: boolean;
showFilter?: boolean;
}) {
const { formatMessage, labels } = useMessages();
const { data, isLoading, isFetched, error } = useWebsiteSessionStats(websiteId);

Expand Down Expand Up @@ -34,7 +44,10 @@ export function EventsMetricsBar({ websiteId }: { websiteId: string }) {
formatValue={formatLongNumber}
/>
</MetricsBar>
<WebsiteDateFilter websiteId={websiteId} />
<div className={styles.actions}>
{showFilter && <WebsiteFilterButton websiteId={websiteId} />}
<WebsiteDateFilter websiteId={websiteId} showAllTime={!compareMode} />
</div>
</Flexbox>
);
}
Expand Down
15 changes: 13 additions & 2 deletions src/app/(main)/websites/[websiteId]/events/EventsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,35 @@ import EventsMetricsBar from './EventsMetricsBar';
import EventsChart from '@/components/metrics/EventsChart';
import { GridRow } from '@/components/layout/Grid';
import EventsTable from '@/components/metrics/EventsTable';
import { useMessages } from '@/components/hooks';
import FilterTags from '@/components/metrics/FilterTags';
import { useMessages, useNavigation } from '@/components/hooks';
import { Item, Tabs } from 'react-basics';
import { useState } from 'react';
import EventProperties from './EventProperties';
import { FILTER_COLUMNS } from '@/lib/constants';

export default function EventsPage({ websiteId }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Missing TypeScript type for websiteId prop

Suggested change
export default function EventsPage({ websiteId }) {
export default function EventsPage({ websiteId }: { websiteId: string }) {

const [label, setLabel] = useState(null);
const [tab, setTab] = useState('activity');
const { formatMessage, labels } = useMessages();
const { query } = useNavigation();

const handleLabelClick = (value: string) => {
setLabel(value !== label ? value : '');
};

const params = Object.keys(query).reduce((obj, key) => {
if (FILTER_COLUMNS[key]) {
obj[key] = query[key];
}
return obj;
}, {});

return (
<>
<WebsiteHeader websiteId={websiteId} />
<EventsMetricsBar websiteId={websiteId} />
<FilterTags websiteId={websiteId} params={params} />
<EventsMetricsBar websiteId={websiteId} showFilter={true} />
<GridRow columns="two-one">
<EventsChart websiteId={websiteId} focusLabel={label} />
<EventsTable
Expand Down