mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
.
This commit is contained in:
@@ -16,8 +16,14 @@ export function useFirstInteractionData() {
|
|||||||
return metricsInfo;
|
return metricsInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function useVisitsTimeline(fromDate: string, toDate: string, slice: Slice) {
|
export async function useVisitsTimeline(slice: Slice, fromDate?: string, toDate?: string) {
|
||||||
const { from, to } = DateService.prepareDateRange(fromDate, toDate, slice);
|
|
||||||
|
const { from, to } = DateService.prepareDateRange(
|
||||||
|
fromDate || DateService.getDefaultRange(slice).from,
|
||||||
|
toDate || DateService.getDefaultRange(slice).to,
|
||||||
|
slice
|
||||||
|
);
|
||||||
|
|
||||||
const activeProject = useActiveProject();
|
const activeProject = useActiveProject();
|
||||||
const response = await $fetch(
|
const response = await $fetch(
|
||||||
`/api/metrics/${activeProject.value?._id}/timeline/visits`, {
|
`/api/metrics/${activeProject.value?._id}/timeline/visits`, {
|
||||||
@@ -25,6 +31,7 @@ export async function useVisitsTimeline(fromDate: string, toDate: string, slice:
|
|||||||
...signHeaders({ 'Content-Type': 'application/json' }),
|
...signHeaders({ 'Content-Type': 'application/json' }),
|
||||||
body: JSON.stringify({ slice, from, to })
|
body: JSON.stringify({ slice, from, to })
|
||||||
});
|
});
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,11 @@ class DateService {
|
|||||||
|
|
||||||
public slicesData = slicesData;
|
public slicesData = slicesData;
|
||||||
|
|
||||||
getDefaultRange(slice: Slice, from?: string, to?: string) {
|
getDefaultRange(slice: Slice) {
|
||||||
|
return {
|
||||||
|
from: new Date(Date.now() - slicesData[slice].fromOffset).toISOString(),
|
||||||
|
to: new Date().toISOString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getQueryDateRange(slice: Slice) {
|
getQueryDateRange(slice: Slice) {
|
||||||
|
|||||||
Reference in New Issue
Block a user