Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

(fix) filters for user flow

kruzhambus721f2a579542
diff --git a/src/api/index.ts b/src/api/index.ts
index 0f1933276..917bec8de 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -927,13 +927,14 @@ export const getUserFlow = (
pid: string,
tb: string = 'hour',
period: string = '3d',
+ filters: string[] = [],
from: string = '',
to: string = '',
timezone: string = '',
) =>
api
.get(
- `log/user-flow?pid=${pid}&timeBucket=${tb}&period=${period}&from=${from}&to=${to}&timezone=${timezone}`,
+ `log/user-flow?pid=${pid}&timeBucket=${tb}&period=${period}&filters=${JSON.stringify(filters)}&from=${from}&to=${to}&timezone=${timezone}`,
)
.then((response) => response.data)
.catch((error) => {
diff --git a/src/pages/Project/View/Panels.tsx b/src/pages/Project/View/Panels.tsx
index f5f3555b2..5df2ba5bc 100644
--- a/src/pages/Project/View/Panels.tsx
+++ b/src/pages/Project/View/Panels.tsx
@@ -752,11 +752,12 @@ interface IPanel {
timezone?: string | null
activeTab?: string
onFragmentChange?: (arg: number) => void
+ filters?: string[]
}
const Panel = ({
name, data, rowMapper, valueMapper, capitalize, linkContent, t, icon, id, hideFilters,
- onFilter, customTabs, pid, period, timeBucket, from, to, timezone, activeTab, onFragmentChange,
+ onFilter, customTabs, pid, period, timeBucket, from, to, timezone, activeTab, onFragmentChange, filters,
}: IPanel): JSX.Element => {
const [page, setPage] = useState(0)
const currentIndex = page * ENTRIES_PER_PANEL
@@ -858,6 +859,7 @@ const Panel = ({
from={from || ''}
to={to || ''}
timezone={timezone || ''}
+ filters={filters || []}
t={t}
/>
<Modal
@@ -883,6 +885,7 @@ const Panel = ({
from={from || ''}
to={to || ''}
timezone={timezone || ''}
+ filters={filters || []}
isReversed={isReversedUserFlow}
t={t}
/>
@@ -1120,6 +1123,7 @@ Panel.defaultProps = {
pid: null,
activeTab: null,
onFragmentChange: () => { },
+ filters: [],
}
const PanelMemo = memo(Panel)
diff --git a/src/pages/Project/View/ViewProject.tsx b/src/pages/Project/View/ViewProject.tsx
index 5079b5bfe..90c1cd20d 100644
--- a/src/pages/Project/View/ViewProject.tsx
+++ b/src/pages/Project/View/ViewProject.tsx
@@ -2141,6 +2141,7 @@ const ViewProject = ({
period={period}
pid={id}
timeBucket={timeBucket}
+ filters={filters}
from={dateRange ? getFormatDate(dateRange[0]) : null}
to={dateRange ? getFormatDate(dateRange[1]) : null}
timezone={timezone}
diff --git a/src/pages/Project/View/components/UserFlow.tsx b/src/pages/Project/View/components/UserFlow.tsx
index 9df8d8639..bfde99c60 100644
--- a/src/pages/Project/View/components/UserFlow.tsx
+++ b/src/pages/Project/View/components/UserFlow.tsx
@@ -38,7 +38,9 @@ const mapDispatchToProps = (dispatch: AppDispatch) => ({
})
const UserFlow = ({
- disableLegend, pid, period, timeBucket, from, to, timezone, userFlowAscendingCache, userFlowDescendingCache, isReversed, setUserFlowAscending, setUserFlowDescending, generateError, t,
+ disableLegend, pid, period, timeBucket, from, to, timezone, userFlowAscendingCache,
+ userFlowDescendingCache, filters,
+ isReversed, setUserFlowAscending, setUserFlowDescending, generateError, t,
}: {
disableLegend?: boolean
pid: string
@@ -58,6 +60,7 @@ const UserFlow = ({
setUserFlowDescending: (data: IUserFlow, id: string, pd: string) => void
generateError: (message: string) => void
t: (key: string) => string
+ filters: string[]
}) => {
const key = getUserFlowCacheKey(pid, period)
const userFlowAscending = userFlowAscendingCache[key]
@@ -66,7 +69,7 @@ const UserFlow = ({
const fetchUserFlow = async () => {
setIsLoading(true)
- await getUserFlow(pid, timeBucket, period, from, to, timezone)
+ await getUserFlow(pid, timeBucket, period, filters, from, to, timezone)
.then((res: {
ascending: IUserFlow
descending: IUserFlow
@@ -93,11 +96,16 @@ const UserFlow = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [period, timeBucket, from, to, timezone, pid])
+ useEffect(() => {
+ fetchUserFlow()
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [filters])
+
if (isLoading) {
return <Loader />
}
- if ((_isEmpty(userFlowAscending) && _isEmpty(userFlowDescending)) || (_isEmpty(userFlowAscending?.nodes) && _isEmpty(userFlowDescending?.links))) {
+ if (_isEmpty(userFlowAscending) || _isEmpty(userFlowDescending) || _isEmpty(userFlowAscending?.nodes) || _isEmpty(userFlowAscending?.links) || _isEmpty(userFlowDescending?.links) || _isEmpty(userFlowDescending?.nodes)) {
return (
<p className='flex mt-4 items-center justify-center text-md text-gray-900 dark:text-gray-50'>
{t('project.userFlow.noData')}