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.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Funnel report updates. Fixed insights report.
Mike Caocf8d49f8675f
diff --git a/src/app/(main)/reports/[reportId]/FieldFilterEditForm.tsx b/src/app/(main)/reports/[reportId]/FieldFilterEditForm.tsxindex 5612c5540..dc10b724d 100644--- a/src/app/(main)/reports/[reportId]/FieldFilterEditForm.tsx+++ b/src/app/(main)/reports/[reportId]/FieldFilterEditForm.tsx@@ -191,7 +191,7 @@ export default function FieldFilterEditForm({)}</Flexbox><Button variant="primary" onClick={handleAdd} disabled={isDisabled}>- {isNew ? formatMessage(labels.add) : formatMessage(labels.update)}+ {formatMessage(isNew ? labels.add : labels.update)}</Button></FormRow></Form>diff --git a/src/app/(main)/reports/[reportId]/FilterParameters.tsx b/src/app/(main)/reports/[reportId]/FilterParameters.tsxindex edc0ff4ec..3118a6f4b 100644--- a/src/app/(main)/reports/[reportId]/FilterParameters.tsx+++ b/src/app/(main)/reports/[reportId]/FilterParameters.tsx@@ -74,7 +74,8 @@ export function FilterParameters() {return (<ParameterList.Item key={name} onRemove={() => handleRemove(name)}><FilterParameter- {...dateRange}+ startDate={dateRange.startDate}+ endDate={dateRange.endDate}websiteId={websiteId}name={name}label={label}diff --git a/src/app/(main)/reports/[reportId]/ParameterList.tsx b/src/app/(main)/reports/[reportId]/ParameterList.tsxindex 046e85dce..f2ac988fc 100644--- a/src/app/(main)/reports/[reportId]/ParameterList.tsx+++ b/src/app/(main)/reports/[reportId]/ParameterList.tsx@@ -4,6 +4,7 @@ import Icons from 'components/icons';import Empty from 'components/common/Empty';import { useMessages } from 'components/hooks';import styles from './ParameterList.module.css';+import classNames from 'classnames';export interface ParameterListProps {children?: ReactNode;@@ -22,15 +23,17 @@ export function ParameterList({ children }: ParameterListProps) {const Item = ({children,+ className,onClick,onRemove,}: {children?: ReactNode;+ className?: string;onClick?: () => void;onRemove?: () => void;}) => {return (- <div className={styles.item} onClick={onClick}>+ <div className={classNames(styles.item, className)} onClick={onClick}>{children}<Icon onClick={onRemove}><Icons.Close />diff --git a/src/app/(main)/reports/funnel/FunnelChart.module.css b/src/app/(main)/reports/funnel/FunnelChart.module.cssindex 45d0ea616..81b22c787 100644--- a/src/app/(main)/reports/funnel/FunnelChart.module.css+++ b/src/app/(main)/reports/funnel/FunnelChart.module.css@@ -37,7 +37,7 @@.card {display: grid;gap: 20px;- margin-top: 8px;+ margin-top: 14px;}.header {@@ -73,7 +73,7 @@}.item {- font-size: 24px;+ font-size: 20px;color: var(--base900);font-weight: 700;}@@ -83,19 +83,19 @@display: flex;justify-content: space-between;gap: 10px;- font-size: 24px;margin: 10px 0;text-transform: lowercase;}.visitors {color: var(--base900);- font-size: 32px;+ font-size: 24px;font-weight: 900;margin-right: 10px;}.percent {+ font-size: 20px;font-weight: 700;align-self: flex-end;}diff --git a/src/app/(main)/reports/funnel/FunnelParameters.module.css b/src/app/(main)/reports/funnel/FunnelParameters.module.cssindex 81ef9216b..219b98076 100644--- a/src/app/(main)/reports/funnel/FunnelParameters.module.css+++ b/src/app/(main)/reports/funnel/FunnelParameters.module.css@@ -2,8 +2,15 @@display: flex;align-items: center;gap: 10px;+ width: 100%;}.type {color: var(--base700);}++.value {+ display: flex;+ align-self: center;+ gap: 20px;+}diff --git a/src/app/(main)/reports/funnel/FunnelParameters.tsx b/src/app/(main)/reports/funnel/FunnelParameters.tsxindex 248318f13..7b1fb0c81 100644--- a/src/app/(main)/reports/funnel/FunnelParameters.tsx+++ b/src/app/(main)/reports/funnel/FunnelParameters.tsx@@ -41,6 +41,17 @@ export function FunnelParameters() {updateReport({ parameters: { steps: parameters.steps.concat(step) } });};+ const handleUpdateStep = (+ close: () => void,+ index: number,+ step: { type: string; value: string },+ ) => {+ const steps = [...parameters.steps];+ steps[index] = step;+ updateReport({ parameters: { steps } });+ close();+ };+const handleRemoveStep = (index: number) => {const steps = [...parameters.steps];delete steps[index];@@ -57,7 +68,7 @@ export function FunnelParameters() {</Button><Popup alignment="start"><PopupForm>- <FunnelStepAddForm onAdd={handleAddStep} />+ <FunnelStepAddForm onChange={handleAddStep} /></PopupForm></Popup></PopupTrigger>@@ -79,14 +90,30 @@ export function FunnelParameters() {<ParameterList>{steps.map((step: { type: string; value: string }, index: number) => {return (- <ParameterList.Item key={index} onRemove={() => handleRemoveStep(index)}>- <div className={styles.item}>- <div className={styles.type}>- <Icon>{step.type === 'url' ? <Icons.Eye /> : <Icons.Bolt />}</Icon>+ <PopupTrigger key={index}>+ <ParameterList.Item+ className={styles.item}+ onRemove={() => handleRemoveStep(index)}+ >+ <div className={styles.value}>+ <div className={styles.type}>+ <Icon>{step.type === 'url' ? <Icons.Eye /> : <Icons.Bolt />}</Icon>+ </div>+ <div>{step.value}</div></div>- <div>{step.value}</div>- </div>- </ParameterList.Item>+ </ParameterList.Item>+ <Popup alignment="start">+ {(close: () => void) => (+ <PopupForm>+ <FunnelStepAddForm+ type={step.type}+ value={step.value}+ onChange={handleUpdateStep.bind(null, close, index)}+ />+ </PopupForm>+ )}+ </Popup>+ </PopupTrigger>);})}</ParameterList>diff --git a/src/app/(main)/reports/funnel/FunnelStepAddForm.tsx b/src/app/(main)/reports/funnel/FunnelStepAddForm.tsxindex 978747c9c..7d77b0c72 100644--- a/src/app/(main)/reports/funnel/FunnelStepAddForm.tsx+++ b/src/app/(main)/reports/funnel/FunnelStepAddForm.tsx@@ -3,13 +3,18 @@ import { useMessages } from 'components/hooks';import { Button, FormRow, TextField, Flexbox, Dropdown, Item } from 'react-basics';import styles from './FunnelStepAddForm.module.css';-export interface UrlAddFormProps {- defaultValue?: string;- onAdd?: (step: { type: string; value: string }) => void;+export interface FunnelStepAddFormProps {+ type?: string;+ value?: string;+ onChange?: (step: { type: string; value: string }) => void;}-export function FunnelStepAddForm({ defaultValue = '', onAdd }: UrlAddFormProps) {- const [type, setType] = useState('url');+export function FunnelStepAddForm({+ type: defaultType = 'url',+ value: defaultValue = '',+ onChange,+}: FunnelStepAddFormProps) {+ const [type, setType] = useState(defaultType);const [value, setValue] = useState(defaultValue);const { formatMessage, labels } = useMessages();const items = [@@ -19,7 +24,7 @@ export function FunnelStepAddForm({ defaultValue = '', onAdd }: UrlAddFormProps)const isDisabled = !type || !value;const handleSave = () => {- onAdd({ type, value });+ onChange({ type, value });setValue('');};@@ -39,32 +44,36 @@ export function FunnelStepAddForm({ defaultValue = '', onAdd }: UrlAddFormProps)};return (- <FormRow label={formatMessage(labels.addStep)}>- <Flexbox gap={10}>- <Dropdown- className={styles.dropdown}- items={items}- value={type}- renderValue={renderTypeValue}- onChange={(value: any) => setType(value)}- >- {({ value, label }) => {- return <Item key={value}>{label}</Item>;- }}- </Dropdown>- <TextField- className={styles.input}- value={value}- onChange={handleChange}- autoFocus={true}- autoComplete="off"- onKeyDown={handleKeyDown}- />+ <Flexbox direction="column" gap={10}>+ <FormRow label={formatMessage(defaultValue ? labels.update : labels.add)}>+ <Flexbox gap={10}>+ <Dropdown+ className={styles.dropdown}+ items={items}+ value={type}+ renderValue={renderTypeValue}+ onChange={(value: any) => setType(value)}+ >+ {({ value, label }) => {+ return <Item key={value}>{label}</Item>;+ }}+ </Dropdown>+ <TextField+ className={styles.input}+ value={value}+ onChange={handleChange}+ autoFocus={true}+ autoComplete="off"+ onKeyDown={handleKeyDown}+ />+ </Flexbox>+ </FormRow>+ <FormRow><Button variant="primary" onClick={handleSave} disabled={isDisabled}>- {formatMessage(labels.add)}+ {formatMessage(defaultValue ? labels.update : labels.add)}</Button>- </Flexbox>- </FormRow>+ </FormRow>+ </Flexbox>);}diff --git a/src/pages/api/reports/insights.ts b/src/pages/api/reports/insights.tsindex efd3a6b51..ba4f643e5 100644--- a/src/pages/api/reports/insights.ts+++ b/src/pages/api/reports/insights.ts@@ -56,8 +56,8 @@ const schema = {};function convertFilters(filters: any[]) {- return filters.reduce((obj, { name, ...value }) => {- obj[name] = value;+ return filters.reduce((obj, filter) => {+ obj[filter.name] = filter;return obj;}, {});