Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Merge branch 'dev' into feat-funnel-per-step-filters

Mike Caofb785180d522
diff --cc src/app/(main)/websites/[websiteId]/(reports)/funnels/Funnel.tsx
index 13567c049,dc11544d9..589831cf5
--- a/src/app/(main)/websites/[websiteId]/(reports)/funnels/Funnel.tsx
+++ b/src/app/(main)/websites/[websiteId]/(reports)/funnels/Funnel.tsx
@@@ -1,25 -1,28 +1,27 @@@
import { Box, Column, Dialog, Grid, Icon, ProgressBar, Row, Text } from '@umami/react-zen';
import { LoadingPanel } from '@/components/common/LoadingPanel';
- import { useMessages, useOperatorLabels, useResultQuery } from '@/components/hooks';
-import { useMessages, useNavigation, useResultQuery } from '@/components/hooks';
++import { useMessages, useNavigation, useOperatorLabels, useResultQuery } from '@/components/hooks';
import { File, User } from '@/components/icons';
import { ReportEditButton } from '@/components/input/ReportEditButton';
import { ChangeLabel } from '@/components/metrics/ChangeLabel';
import { Lightning } from '@/components/svg';
import { formatLongNumber } from '@/lib/format';
+import type { FunnelResult } from '@/queries/sql/reports/getFunnel';
import { FunnelEditForm } from './FunnelEditForm';
-type FunnelResult = {
+interface FunnelProps {
+ id: string;
+ name: string;
type: string;
- value: string;
- visitors: number;
- previous: number;
- dropped: number;
- dropoff: number;
- remaining: number;
-};
+ parameters: Record<string, any>;
+ websiteId: string;
+}
- export function Funnel({ id, name, type, parameters, websiteId }: FunnelProps) {
- const { formatMessage, labels } = useMessages();
+ export function Funnel({ id, name, type, parameters, websiteId }) {
+ const { t, labels } = useMessages();
+ const { pathname } = useNavigation();
+ const isSharePage = pathname.includes('/share/');
- const { data, error, isLoading } = useResultQuery(type, {
+ const { data, error, isLoading } = useResultQuery<Array<FunnelResult>>(type, {
websiteId,
...parameters,
});
@@@ -88,30 -87,15 +88,30 @@@
<Column gap>
<Row alignItems="center" justifyContent="space-between" gap>
<Text color="muted">
- {formatMessage(isPage ? labels.viewedPage : labels.triggeredEvent)}
+ {t(isPage ? labels.viewedPage : labels.triggeredEvent)}
</Text>
- <Text color="muted">{formatMessage(labels.conversionRate)}</Text>
+ <Text color="muted">{t(labels.conversionRate)}</Text>
</Row>
<Row alignItems="center" justifyContent="space-between" gap>
- <Row alignItems="center" gap>
- <Icon>{type === 'path' ? <File /> : <Lightning />}</Icon>
- <Text>{value}</Text>
- </Row>
+ <Column gap="1">
+ <Row alignItems="center" gap>
+ <Icon>{type === 'path' ? <File /> : <Lightning />}</Icon>
+ <Text>{value}</Text>
+ </Row>
+ {filters?.map((f, i) => (
+ <Row key={i} gap="1" style={{ paddingLeft: 28 }}>
+ <Text size="1" color="muted">
+ {f.property}
+ </Text>
+ <Text size="1" color="muted" transform="lowercase">
+ {operatorLabels[f.operator] ?? f.operator}
+ </Text>
+ <Text size="1" color="muted">
+ {f.value}
+ </Text>
+ </Row>
+ ))}
+ </Column>
<Row alignItems="center" gap>
{index > 0 && (
<ChangeLabel value={-dropped} title={`${-Math.round(dropoff * 100)}%`}>
diff --cc src/components/hooks/useFilters.ts
index a20cb53da,57d9177cd..4fc979ca2
--- a/src/components/hooks/useFilters.ts
+++ b/src/components/hooks/useFilters.ts
@@@ -3,36 -3,62 +3,64 @@@ import { safeDecodeURIComponent } from
import { useFields } from './useFields';
import { useMessages } from './useMessages';
import { useNavigation } from './useNavigation';
+import { useOperatorLabels } from './useOperatorLabels';
export function useFilters() {
- const { formatMessage, labels } = useMessages();
+ const { t, labels } = useMessages();
const { query } = useNavigation();
const { fields } = useFields();
+ const operatorLabels = useOperatorLabels();
const operators = [
- { name: 'eq', type: 'string', label: formatMessage(labels.is) },
- { name: 'neq', type: 'string', label: formatMessage(labels.isNot) },
- { name: 'c', type: 'string', label: formatMessage(labels.contains) },
- { name: 'dnc', type: 'string', label: formatMessage(labels.doesNotContain) },
- { name: 'i', type: 'array', label: formatMessage(labels.includes) },
- { name: 'dni', type: 'array', label: formatMessage(labels.doesNotInclude) },
- { name: 't', type: 'boolean', label: formatMessage(labels.isTrue) },
- { name: 'f', type: 'boolean', label: formatMessage(labels.isFalse) },
- { name: 'eq', type: 'number', label: formatMessage(labels.is) },
- { name: 'neq', type: 'number', label: formatMessage(labels.isNot) },
- { name: 'gt', type: 'number', label: formatMessage(labels.greaterThan) },
- { name: 'lt', type: 'number', label: formatMessage(labels.lessThan) },
- { name: 'gte', type: 'number', label: formatMessage(labels.greaterThanEquals) },
- { name: 'lte', type: 'number', label: formatMessage(labels.lessThanEquals) },
- { name: 'bf', type: 'date', label: formatMessage(labels.before) },
- { name: 'af', type: 'date', label: formatMessage(labels.after) },
- { name: 'eq', type: 'uuid', label: formatMessage(labels.is) },
+ { name: 'eq', type: 'string', label: t(labels.is) },
+ { name: 'neq', type: 'string', label: t(labels.isNot) },
+ { name: 'c', type: 'string', label: t(labels.contains) },
+ { name: 'dnc', type: 'string', label: t(labels.doesNotContain) },
+ { name: 're', type: 'string', label: t(labels.regexMatch) },
+ { name: 'nre', type: 'string', label: t(labels.regexNotMatch) },
+ { name: 'i', type: 'array', label: t(labels.includes) },
+ { name: 'dni', type: 'array', label: t(labels.doesNotInclude) },
+ { name: 't', type: 'boolean', label: t(labels.isTrue) },
+ { name: 'f', type: 'boolean', label: t(labels.isFalse) },
+ { name: 'eq', type: 'number', label: t(labels.is) },
+ { name: 'neq', type: 'number', label: t(labels.isNot) },
+ { name: 'gt', type: 'number', label: t(labels.greaterThan) },
+ { name: 'lt', type: 'number', label: t(labels.lessThan) },
+ { name: 'gte', type: 'number', label: t(labels.greaterThanEquals) },
+ { name: 'lte', type: 'number', label: t(labels.lessThanEquals) },
+ { name: 'bf', type: 'date', label: t(labels.before) },
+ { name: 'af', type: 'date', label: t(labels.after) },
+ { name: 'eq', type: 'uuid', label: t(labels.is) },
];
+ const operatorLabels = {
+ [OPERATORS.equals]: t(labels.is),
+ [OPERATORS.notEquals]: t(labels.isNot),
+ [OPERATORS.set]: t(labels.isSet),
+ [OPERATORS.notSet]: t(labels.isNotSet),
+ [OPERATORS.contains]: t(labels.contains),
+ [OPERATORS.doesNotContain]: t(labels.doesNotContain),
+ [OPERATORS.regex]: t(labels.regexMatch),
+ [OPERATORS.notRegex]: t(labels.regexNotMatch),
+ [OPERATORS.true]: t(labels.true),
+ [OPERATORS.false]: t(labels.false),
+ [OPERATORS.greaterThan]: t(labels.greaterThan),
+ [OPERATORS.lessThan]: t(labels.lessThan),
+ [OPERATORS.greaterThanEquals]: t(labels.greaterThanEquals),
+ [OPERATORS.lessThanEquals]: t(labels.lessThanEquals),
+ [OPERATORS.before]: t(labels.before),
+ [OPERATORS.after]: t(labels.after),
+ };
+
const typeFilters = {
- string: [OPERATORS.equals, OPERATORS.notEquals, OPERATORS.contains, OPERATORS.doesNotContain],
+ string: [
+ OPERATORS.equals,
+ OPERATORS.notEquals,
+ OPERATORS.contains,
+ OPERATORS.doesNotContain,
+ OPERATORS.regex,
+ OPERATORS.notRegex,
+ ],
array: [OPERATORS.contains, OPERATORS.doesNotContain],
boolean: [OPERATORS.true, OPERATORS.false],
number: [
diff --cc src/components/input/LookupField.tsx
index 301a6ca6c,5b448c8f8..65dc730a1
--- a/src/components/input/LookupField.tsx
+++ b/src/components/input/LookupField.tsx
@@@ -9,22 -9,10 +9,15 @@@ export interface LookupFieldProps exten
type: string;
value: string;
onChange: (value: string) => void;
+ /**
+ * `FormField` injects `onChange` via `cloneElement`, overwriting any custom handler.
+ * Use `onValueChange` for side effects that must survive that override.
+ */
+ onValueChange?: (value: string) => void;
}
- export function LookupField({
- websiteId,
- type,
- value,
- onChange,
- onValueChange,
- ...props
- }: LookupFieldProps) {
- const { formatMessage, messages } = useMessages();
-export function LookupField({ websiteId, type, value, onChange, ...props }: LookupFieldProps) {
++export function LookupField({ websiteId, type, value, onChange, onValueChange, ...props }: LookupFieldProps) {
+ const { t, messages } = useMessages();
const [search, setSearch] = useState(value);
const searchValue = useDebounce(search, 300);
const startDate = subMonths(endOfDay(new Date()), 6);