mirror of
https://github.com/umami-software/umami.git
synced 2026-02-18 03:25:40 +01:00
feat: add properties & activity to event filtering
This commit is contained in:
parent
0c2070771b
commit
ecddac48ef
3 changed files with 11 additions and 5 deletions
|
|
@ -6,12 +6,13 @@ import { useState } from 'react';
|
||||||
import { CHART_COLORS } from '@/lib/constants';
|
import { CHART_COLORS } from '@/lib/constants';
|
||||||
import styles from './EventProperties.module.css';
|
import styles from './EventProperties.module.css';
|
||||||
|
|
||||||
export function EventProperties({ websiteId }: { websiteId: string }) {
|
export function EventProperties({ websiteId, label }: { websiteId: string; label: string }) {
|
||||||
const [propertyName, setPropertyName] = useState('');
|
const [propertyName, setPropertyName] = useState('');
|
||||||
const [eventName, setEventName] = useState('');
|
const [eventName, setEventName] = useState('');
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const { data, isLoading, isFetched, error } = useEventDataProperties(websiteId);
|
const { data: eventData = [], isLoading, isFetched, error } = useEventDataProperties(websiteId);
|
||||||
const { data: values } = useEventDataValues(websiteId, eventName, propertyName);
|
const { data: values } = useEventDataValues(websiteId, eventName, propertyName);
|
||||||
|
const data = label ? eventData.filter(({ eventName }) => eventName === label) : eventData;
|
||||||
const chartData =
|
const chartData =
|
||||||
propertyName && values
|
propertyName && values
|
||||||
? {
|
? {
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,10 @@ import { ReactNode } from 'react';
|
||||||
|
|
||||||
export default function EventsDataTable({
|
export default function EventsDataTable({
|
||||||
websiteId,
|
websiteId,
|
||||||
|
label,
|
||||||
}: {
|
}: {
|
||||||
websiteId?: string;
|
websiteId?: string;
|
||||||
|
label?: string;
|
||||||
teamId?: string;
|
teamId?: string;
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -14,7 +16,10 @@ export default function EventsDataTable({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DataTable queryResult={queryResult} allowSearch={true} autoFocus={false}>
|
<DataTable queryResult={queryResult} allowSearch={true} autoFocus={false}>
|
||||||
{({ data }) => <EventsTable data={data} />}
|
{({ data: eventData = [] }) => {
|
||||||
|
const data = label ? eventData.filter(({ eventName }) => eventName === label) : eventData;
|
||||||
|
return <EventsTable data={data} />;
|
||||||
|
}}
|
||||||
</DataTable>
|
</DataTable>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ export default function EventsPage({ websiteId }) {
|
||||||
<Item key="activity">{formatMessage(labels.activity)}</Item>
|
<Item key="activity">{formatMessage(labels.activity)}</Item>
|
||||||
<Item key="properties">{formatMessage(labels.properties)}</Item>
|
<Item key="properties">{formatMessage(labels.properties)}</Item>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
{tab === 'activity' && <EventsDataTable websiteId={websiteId} />}
|
{tab === 'activity' && <EventsDataTable websiteId={websiteId} label={label} />}
|
||||||
{tab === 'properties' && <EventProperties websiteId={websiteId} />}
|
{tab === 'properties' && <EventProperties websiteId={websiteId} label={label} />}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue