mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
clean up session properties / values
This commit is contained in:
parent
aaf9adacc6
commit
db25f241c0
@ -11,7 +11,7 @@ export function useSessionDataValues(
|
|||||||
const params = useFilterParams(websiteId);
|
const params = useFilterParams(websiteId);
|
||||||
|
|
||||||
return useQuery<any>({
|
return useQuery<any>({
|
||||||
queryKey: ['websites:event-data:values', { websiteId, propertyName, ...params }],
|
queryKey: ['websites:session-data:values', { websiteId, propertyName, ...params }],
|
||||||
queryFn: () => get(`/websites/${websiteId}/session-data/values`, { ...params, propertyName }),
|
queryFn: () => get(`/websites/${websiteId}/session-data/values`, { ...params, propertyName }),
|
||||||
enabled: !!(websiteId && propertyName),
|
enabled: !!(websiteId && propertyName),
|
||||||
...options,
|
...options,
|
||||||
|
@ -3,7 +3,7 @@ import { useAuth, useCors, useValidate } from 'lib/middleware';
|
|||||||
import { NextApiRequestQueryBody } from 'lib/types';
|
import { NextApiRequestQueryBody } from 'lib/types';
|
||||||
import { NextApiResponse } from 'next';
|
import { NextApiResponse } from 'next';
|
||||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||||
import { getEventDataProperties } from 'queries';
|
import { getSessionDataProperties } from 'queries';
|
||||||
import * as yup from 'yup';
|
import * as yup from 'yup';
|
||||||
|
|
||||||
export interface EventDataFieldsRequestQuery {
|
export interface EventDataFieldsRequestQuery {
|
||||||
@ -40,7 +40,7 @@ export default async (
|
|||||||
const startDate = new Date(+startAt);
|
const startDate = new Date(+startAt);
|
||||||
const endDate = new Date(+endAt);
|
const endDate = new Date(+endAt);
|
||||||
|
|
||||||
const data = await getEventDataProperties(websiteId, { startDate, endDate, propertyName });
|
const data = await getSessionDataProperties(websiteId, { startDate, endDate, propertyName });
|
||||||
|
|
||||||
return ok(res, data);
|
return ok(res, data);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import { useAuth, useCors, useValidate } from 'lib/middleware';
|
|||||||
import { NextApiRequestQueryBody } from 'lib/types';
|
import { NextApiRequestQueryBody } from 'lib/types';
|
||||||
import { NextApiResponse } from 'next';
|
import { NextApiResponse } from 'next';
|
||||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||||
import { getEventDataValues } from 'queries';
|
import { getSessionDataValues } from 'queries';
|
||||||
|
|
||||||
import * as yup from 'yup';
|
import * as yup from 'yup';
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export default async (
|
|||||||
const startDate = new Date(+startAt);
|
const startDate = new Date(+startAt);
|
||||||
const endDate = new Date(+endAt);
|
const endDate = new Date(+endAt);
|
||||||
|
|
||||||
const data = await getEventDataValues(websiteId, { startDate, endDate, propertyName });
|
const data = await getSessionDataValues(websiteId, { startDate, endDate, propertyName });
|
||||||
|
|
||||||
return ok(res, data);
|
return ok(res, data);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ async function clickhouseQuery(
|
|||||||
data_type = 4, toString(date_trunc('hour', date_value)),
|
data_type = 4, toString(date_trunc('hour', date_value)),
|
||||||
string_value) as "value",
|
string_value) as "value",
|
||||||
count(*) as "total"
|
count(*) as "total"
|
||||||
from umami.event_data
|
from event_data
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
and data_key = {propertyName:String}
|
and data_key = {propertyName:String}
|
||||||
|
@ -41,7 +41,7 @@ async function relationalQuery(
|
|||||||
async function clickhouseQuery(
|
async function clickhouseQuery(
|
||||||
websiteId: string,
|
websiteId: string,
|
||||||
filters: QueryFilters & { propertyName?: string },
|
filters: QueryFilters & { propertyName?: string },
|
||||||
): Promise<{ propertyName: string; dataType: number; propertyValue: string; total: number }[]> {
|
): Promise<{ propertyName: string; total: number }[]> {
|
||||||
const { rawQuery, parseFilters } = clickhouse;
|
const { rawQuery, parseFilters } = clickhouse;
|
||||||
const { filterQuery, params } = await parseFilters(websiteId, filters, {
|
const { filterQuery, params } = await parseFilters(websiteId, filters, {
|
||||||
columns: { propertyName: 'data_key' },
|
columns: { propertyName: 'data_key' },
|
||||||
@ -65,8 +65,6 @@ async function clickhouseQuery(
|
|||||||
return Object.values(result).map((a: any) => {
|
return Object.values(result).map((a: any) => {
|
||||||
return {
|
return {
|
||||||
propertyName: a.propertyName,
|
propertyName: a.propertyName,
|
||||||
dataType: Number(a.dataType),
|
|
||||||
propertyValue: a.propertyValue,
|
|
||||||
total: Number(a.total),
|
total: Number(a.total),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -51,7 +51,7 @@ async function clickhouseQuery(
|
|||||||
data_type = 4, toString(date_trunc('hour', date_value)),
|
data_type = 4, toString(date_trunc('hour', date_value)),
|
||||||
string_value) as "value",
|
string_value) as "value",
|
||||||
count(*) as "total"
|
count(*) as "total"
|
||||||
from umami.session_data
|
from session_data
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
and data_key = {propertyName:String}
|
and data_key = {propertyName:String}
|
||||||
|
@ -22,6 +22,8 @@ export * from './analytics/pageviews/getPageviewStats';
|
|||||||
export * from './analytics/sessions/createSession';
|
export * from './analytics/sessions/createSession';
|
||||||
export * from './analytics/sessions/getWebsiteSession';
|
export * from './analytics/sessions/getWebsiteSession';
|
||||||
export * from './analytics/sessions/getSessionData';
|
export * from './analytics/sessions/getSessionData';
|
||||||
|
export * from './analytics/sessions/getSessionDataProperties';
|
||||||
|
export * from './analytics/sessions/getSessionDataValues';
|
||||||
export * from './analytics/sessions/getSessionMetrics';
|
export * from './analytics/sessions/getSessionMetrics';
|
||||||
export * from './analytics/sessions/getWebsiteSessions';
|
export * from './analytics/sessions/getWebsiteSessions';
|
||||||
export * from './analytics/sessions/getSessionActivity';
|
export * from './analytics/sessions/getSessionActivity';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user