1 parent
78346795eb
commit
d05d9c4f34
73 files changed
+1262
-161
No files matched your search
@@ -26,7 +26,7 @@ export function usePropertyFieldsQuery(
|
||||
? `/websites/${websiteId}/event-data/fields`
|
||||
: `/websites/${websiteId}/session-data/properties`,
|
||||
{
|
||||
...(source === 'event' ? { event: eventName } : {}),
|
||||
...(source === 'event' && eventName ? { event: eventName } : {}),
|
||||
startAt,
|
||||
endAt,
|
||||
unit,
|
||||
@@ -34,7 +34,7 @@ export function usePropertyFieldsQuery(
|
||||
...params,
|
||||
},
|
||||
),
|
||||
enabled: !!(websiteId && (source === 'session' || eventName)),
|
||||
enabled: !!websiteId,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
@@ -40,7 +40,7 @@ export function usePropertyValuesQuery(
|
||||
? `/websites/${websiteId}/event-data/values`
|
||||
: `/websites/${websiteId}/session-data/values`,
|
||||
{
|
||||
...(source === 'event' ? { event: eventName } : {}),
|
||||
...(source === 'event' && eventName ? { event: eventName } : {}),
|
||||
startAt,
|
||||
endAt,
|
||||
unit,
|
||||
@@ -51,7 +51,7 @@ export function usePropertyValuesQuery(
|
||||
...params,
|
||||
},
|
||||
),
|
||||
enabled: !!(websiteId && propertyName && (source === 'session' || eventName)),
|
||||
enabled: !!(websiteId && propertyName),
|
||||
...options,
|
||||
});
|
||||
}
|
||||
@@ -8,9 +8,10 @@ export function useFilterParameters({
|
||||
}: {
|
||||
includePagination?: boolean;
|
||||
} = {}) {
|
||||
const { query } = useNavigation();
|
||||
const { pathname, query } = useNavigation();
|
||||
const share = useShare();
|
||||
const allowFilter = share?.parameters?.allowFilter !== false;
|
||||
const isEventsPath = pathname.endsWith('/events');
|
||||
|
||||
return useMemo(() => {
|
||||
const filterParams: Record<string, any> = {};
|
||||
@@ -18,7 +19,11 @@ export function useFilterParameters({
|
||||
if (allowFilter) {
|
||||
for (const key of Object.keys(query)) {
|
||||
const baseName = key.replace(/\d+$/, '');
|
||||
if (FILTER_COLUMNS[baseName]) {
|
||||
if (
|
||||
FILTER_COLUMNS[baseName] ||
|
||||
/^spf\d+$/.test(key) ||
|
||||
(isEventsPath && /^epf\d+$/.test(key))
|
||||
) {
|
||||
filterParams[key] = query[key];
|
||||
}
|
||||
}
|
||||
@@ -39,5 +44,5 @@ export function useFilterParameters({
|
||||
}
|
||||
|
||||
return params;
|
||||
}, [allowFilter, includePagination, query]);
|
||||
}, [allowFilter, includePagination, isEventsPath, query]);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { FILTER_COLUMNS, OPERATORS } from '@/lib/constants';
|
||||
import { parseSessionPropertyFilters, parseUniversalEventPropertyFilters } from '@/lib/params';
|
||||
import { safeDecodeURIComponent } from '@/lib/url';
|
||||
import { useShare } from './context/useShare';
|
||||
import { useFields } from './useFields';
|
||||
@@ -8,7 +9,7 @@ import { useOperatorLabels } from './useOperatorLabels';
|
||||
|
||||
export function useFilters() {
|
||||
const { t, labels } = useMessages();
|
||||
const { query } = useNavigation();
|
||||
const { pathname, query } = useNavigation();
|
||||
const { fields } = useFields();
|
||||
const operatorLabels = useOperatorLabels();
|
||||
const share = useShare();
|
||||
@@ -85,6 +86,9 @@ export function useFilters() {
|
||||
return arr;
|
||||
}, [])
|
||||
: [];
|
||||
const eventPropertyFilters =
|
||||
allowFilter && pathname.endsWith('/events') ? parseUniversalEventPropertyFilters(query) : [];
|
||||
const sessionPropertyFilters = allowFilter ? parseSessionPropertyFilters(query) : [];
|
||||
|
||||
const getFilters = (type: string) => {
|
||||
return (
|
||||
@@ -96,5 +100,14 @@ export function useFilters() {
|
||||
);
|
||||
};
|
||||
|
||||
return { fields, operators, filters, operatorLabels, typeFilters, getFilters };
|
||||
return {
|
||||
fields,
|
||||
operators,
|
||||
filters,
|
||||
eventPropertyFilters,
|
||||
sessionPropertyFilters,
|
||||
operatorLabels,
|
||||
typeFilters,
|
||||
getFilters,
|
||||
};
|
||||
}
|
||||
@@ -11,6 +11,8 @@ export function useOperatorLabels(): Record<string, string> {
|
||||
[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),
|
||||
|
||||
Reference in new issue
Block a user