Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Remove deprecated analytics hooks and refactor API structure for funn… (#394)

Bill Yang5a4ef88592e4
diff --git a/client/src/api/analytics/useGetEventNames.ts b/client/src/api/analytics/events/useGetEventNames.ts
similarity index 80%
rename from client/src/api/analytics/useGetEventNames.ts
rename to client/src/api/analytics/events/useGetEventNames.ts
index 0a164dcae..023fe2d31 100644
--- a/client/src/api/analytics/useGetEventNames.ts
+++ b/client/src/api/analytics/events/useGetEventNames.ts
@@ -1,7 +1,11 @@
import { useQuery } from "@tanstack/react-query";
-import { useStore, getFilteredFilters, EVENT_FILTERS } from "../../lib/store";
-import { authedFetch } from "../utils";
-import { getQueryTimeParams } from "./utils";
+import {
+ useStore,
+ getFilteredFilters,
+ EVENT_FILTERS,
+} from "../../../lib/store";
+import { authedFetch } from "../../utils";
+import { getQueryTimeParams } from "../utils";
export type EventName = {
eventName: string;
diff --git a/client/src/api/analytics/useGetEventProperties.ts b/client/src/api/analytics/events/useGetEventProperties.ts
similarity index 83%
rename from client/src/api/analytics/useGetEventProperties.ts
rename to client/src/api/analytics/events/useGetEventProperties.ts
index f55f62dc9..af4412f0e 100644
--- a/client/src/api/analytics/useGetEventProperties.ts
+++ b/client/src/api/analytics/events/useGetEventProperties.ts
@@ -1,7 +1,11 @@
import { useQuery } from "@tanstack/react-query";
-import { useStore, getFilteredFilters, EVENT_FILTERS } from "../../lib/store";
-import { authedFetch } from "../utils";
-import { getQueryTimeParams } from "./utils";
+import {
+ useStore,
+ getFilteredFilters,
+ EVENT_FILTERS,
+} from "../../../lib/store";
+import { authedFetch } from "../../utils";
+import { getQueryTimeParams } from "../utils";
export type EventProperty = {
propertyKey: string;
diff --git a/client/src/api/analytics/useGetEvents.ts b/client/src/api/analytics/events/useGetEvents.ts
similarity index 91%
rename from client/src/api/analytics/useGetEvents.ts
rename to client/src/api/analytics/events/useGetEvents.ts
index 1fda09461..e224ca8dc 100644
--- a/client/src/api/analytics/useGetEvents.ts
+++ b/client/src/api/analytics/events/useGetEvents.ts
@@ -1,8 +1,8 @@
import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
-import { Time } from "../../components/DateSelector/types";
-import { useStore } from "../../lib/store";
-import { authedFetch, getStartAndEndDate } from "../utils";
-import { timeZone } from "../../lib/dateTimeUtils";
+import { Time } from "../../../components/DateSelector/types";
+import { useStore } from "../../../lib/store";
+import { authedFetch, getStartAndEndDate } from "../../utils";
+import { timeZone } from "../../../lib/dateTimeUtils";
export type Event = {
timestamp: string;
diff --git a/client/src/api/analytics/useDeleteFunnel.ts b/client/src/api/analytics/funnels/useDeleteFunnel.ts
similarity index 94%
rename from client/src/api/analytics/useDeleteFunnel.ts
rename to client/src/api/analytics/funnels/useDeleteFunnel.ts
index 2d49be246..3ed884d04 100644
--- a/client/src/api/analytics/useDeleteFunnel.ts
+++ b/client/src/api/analytics/funnels/useDeleteFunnel.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { authedFetch } from "../utils";
+import { authedFetch } from "../../utils";
/**
* Hook for deleting a saved funnel report
diff --git a/client/src/api/analytics/useGetFunnel.ts b/client/src/api/analytics/funnels/useGetFunnel.ts
similarity index 95%
rename from client/src/api/analytics/useGetFunnel.ts
rename to client/src/api/analytics/funnels/useGetFunnel.ts
index 79d223c0a..560cb7364 100644
--- a/client/src/api/analytics/useGetFunnel.ts
+++ b/client/src/api/analytics/funnels/useGetFunnel.ts
@@ -1,9 +1,9 @@
import { Filter } from "@rybbit/shared";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useDebounce } from "@uidotdev/usehooks";
-import { timeZone } from "../../lib/dateTimeUtils";
-import { useStore } from "../../lib/store";
-import { authedFetch } from "../utils";
+import { timeZone } from "../../../lib/dateTimeUtils";
+import { useStore } from "../../../lib/store";
+import { authedFetch } from "../../utils";
export type FunnelStep = {
value: string;
diff --git a/client/src/api/analytics/useGetFunnels.ts b/client/src/api/analytics/funnels/useGetFunnels.ts
similarity index 95%
rename from client/src/api/analytics/useGetFunnels.ts
rename to client/src/api/analytics/funnels/useGetFunnels.ts
index d0390e09e..26dd18e29 100644
--- a/client/src/api/analytics/useGetFunnels.ts
+++ b/client/src/api/analytics/funnels/useGetFunnels.ts
@@ -1,7 +1,7 @@
import { Filter } from "@rybbit/shared";
import { useQuery } from "@tanstack/react-query";
+import { authedFetch } from "../../utils";
import { FunnelStep } from "./useGetFunnel";
-import { authedFetch } from "../utils";
export interface SavedFunnel {
id: number;
diff --git a/client/src/api/analytics/useCreateGoal.ts b/client/src/api/analytics/goals/useCreateGoal.ts
similarity index 96%
rename from client/src/api/analytics/useCreateGoal.ts
rename to client/src/api/analytics/goals/useCreateGoal.ts
index ae9dfc31c..82b92c27f 100644
--- a/client/src/api/analytics/useCreateGoal.ts
+++ b/client/src/api/analytics/goals/useCreateGoal.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { authedFetch } from "../utils";
+import { authedFetch } from "../../utils";
export interface CreateGoalRequest {
siteId: number;
diff --git a/client/src/api/analytics/useDeleteGoal.ts b/client/src/api/analytics/goals/useDeleteGoal.ts
similarity index 89%
rename from client/src/api/analytics/useDeleteGoal.ts
rename to client/src/api/analytics/goals/useDeleteGoal.ts
index b45293072..cab7bd2d8 100644
--- a/client/src/api/analytics/useDeleteGoal.ts
+++ b/client/src/api/analytics/goals/useDeleteGoal.ts
@@ -1,6 +1,6 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { authedFetch } from "../utils";
-import { useStore } from "../../lib/store";
+import { authedFetch } from "../../utils";
+import { useStore } from "../../../lib/store";
export function useDeleteGoal() {
const queryClient = useQueryClient();
diff --git a/client/src/api/analytics/useGetGoal.ts b/client/src/api/analytics/goals/useGetGoal.ts
similarity index 83%
rename from client/src/api/analytics/useGetGoal.ts
rename to client/src/api/analytics/goals/useGetGoal.ts
index 97653f786..0858a9abe 100644
--- a/client/src/api/analytics/useGetGoal.ts
+++ b/client/src/api/analytics/goals/useGetGoal.ts
@@ -1,8 +1,8 @@
import { Filter } from "@rybbit/shared";
import { useQuery } from "@tanstack/react-query";
-import { timeZone } from "../../lib/dateTimeUtils";
-import { useStore } from "../../lib/store";
-import { authedFetch } from "../utils";
+import { timeZone } from "../../../lib/dateTimeUtils";
+import { useStore } from "../../../lib/store";
+import { authedFetch } from "../../utils";
import { Goal } from "./useGetGoals";
interface GetGoalResponse {
diff --git a/client/src/api/analytics/useGetGoals.ts b/client/src/api/analytics/goals/useGetGoals.ts
similarity index 94%
rename from client/src/api/analytics/useGetGoals.ts
rename to client/src/api/analytics/goals/useGetGoals.ts
index 593fb3f24..01be7fec7 100644
--- a/client/src/api/analytics/useGetGoals.ts
+++ b/client/src/api/analytics/goals/useGetGoals.ts
@@ -1,12 +1,12 @@
import { useQuery } from "@tanstack/react-query";
-import { timeZone } from "../../lib/dateTimeUtils";
+import { timeZone } from "../../../lib/dateTimeUtils";
import {
getFilteredFilters,
GOALS_PAGE_FILTERS,
useStore,
-} from "../../lib/store";
-import { authedFetch, getStartAndEndDate } from "../utils";
-import { getQueryTimeParams } from "./utils";
+} from "../../../lib/store";
+import { authedFetch } from "../../utils";
+import { getQueryTimeParams } from "../utils";
export interface Goal {
goalId: number;
diff --git a/client/src/api/analytics/useUpdateGoal.ts b/client/src/api/analytics/goals/useUpdateGoal.ts
similarity index 92%
rename from client/src/api/analytics/useUpdateGoal.ts
rename to client/src/api/analytics/goals/useUpdateGoal.ts
index 5ffd4f531..6945bba9f 100644
--- a/client/src/api/analytics/useUpdateGoal.ts
+++ b/client/src/api/analytics/goals/useUpdateGoal.ts
@@ -1,6 +1,6 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { authedFetch } from "../utils";
-import { useStore } from "../../lib/store";
+import { authedFetch } from "../../utils";
+import { useStore } from "../../../lib/store";
export interface UpdateGoalRequest {
goalId: number;
diff --git a/client/src/api/analytics/useGetPerformanceByDimension.ts b/client/src/api/analytics/performance/useGetPerformanceByDimension.ts
similarity index 94%
rename from client/src/api/analytics/useGetPerformanceByDimension.ts
rename to client/src/api/analytics/performance/useGetPerformanceByDimension.ts
index 9ed2713e9..84160409a 100644
--- a/client/src/api/analytics/useGetPerformanceByDimension.ts
+++ b/client/src/api/analytics/performance/useGetPerformanceByDimension.ts
@@ -1,8 +1,8 @@
import { Filter } from "@rybbit/shared";
import { useQuery, UseQueryResult } from "@tanstack/react-query";
-import { usePerformanceStore } from "../../app/[site]/performance/performanceStore";
-import { useStore } from "../../lib/store";
-import { authedFetch, getQueryParams } from "../utils";
+import { usePerformanceStore } from "../../../app/[site]/performance/performanceStore";
+import { useStore } from "../../../lib/store";
+import { authedFetch, getQueryParams } from "../../utils";
type UseGetPerformanceByDimensionOptions = {
site: number | string;
diff --git a/client/src/api/analytics/useGetPerformanceOverview.ts b/client/src/api/analytics/performance/useGetPerformanceOverview.ts
similarity index 85%
rename from client/src/api/analytics/useGetPerformanceOverview.ts
rename to client/src/api/analytics/performance/useGetPerformanceOverview.ts
index 95fff77f5..8de2ae2a4 100644
--- a/client/src/api/analytics/useGetPerformanceOverview.ts
+++ b/client/src/api/analytics/performance/useGetPerformanceOverview.ts
@@ -1,8 +1,8 @@
import { useQuery } from "@tanstack/react-query";
-import { useStore } from "../../lib/store";
-import { usePerformanceStore } from "../../app/[site]/performance/performanceStore";
-import { authedFetch, getQueryParams } from "../utils";
-import { timeZone } from "../../lib/dateTimeUtils";
+import { useStore } from "../../../lib/store";
+import { usePerformanceStore } from "../../../app/[site]/performance/performanceStore";
+import { authedFetch, getQueryParams } from "../../utils";
+import { timeZone } from "../../../lib/dateTimeUtils";
export type GetPerformanceOverviewResponse = {
current: {
diff --git a/client/src/api/analytics/useGetPerformanceTimeSeries.ts b/client/src/api/analytics/performance/useGetPerformanceTimeSeries.ts
similarity index 89%
rename from client/src/api/analytics/useGetPerformanceTimeSeries.ts
rename to client/src/api/analytics/performance/useGetPerformanceTimeSeries.ts
index f03abf991..64961546c 100644
--- a/client/src/api/analytics/useGetPerformanceTimeSeries.ts
+++ b/client/src/api/analytics/performance/useGetPerformanceTimeSeries.ts
@@ -4,11 +4,11 @@ import {
UseQueryResult,
useQuery,
} from "@tanstack/react-query";
-import { usePerformanceStore } from "../../app/[site]/performance/performanceStore";
-import { timeZone } from "../../lib/dateTimeUtils";
-import { useStore } from "../../lib/store";
-import { APIResponse } from "../types";
-import { authedFetch, getQueryParams } from "../utils";
+import { usePerformanceStore } from "../../../app/[site]/performance/performanceStore";
+import { timeZone } from "../../../lib/dateTimeUtils";
+import { useStore } from "../../../lib/store";
+import { APIResponse } from "../../types";
+import { authedFetch, getQueryParams } from "../../utils";
type PeriodTime = "current" | "previous";
diff --git a/client/src/api/analytics/useSingleCol.ts b/client/src/api/analytics/useSingleCol.ts
index ba5b2c53c..a6e9ce06f 100644
--- a/client/src/api/analytics/useSingleCol.ts
+++ b/client/src/api/analytics/useSingleCol.ts
@@ -1,6 +1,5 @@
import { FilterParameter } from "@rybbit/shared";
import { useQuery, UseQueryResult } from "@tanstack/react-query";
-import { timeZone } from "../../lib/dateTimeUtils";
import { useStore } from "../../lib/store";
import { APIResponse } from "../types";
import { authedFetch, getQueryParams } from "../utils";
@@ -76,51 +75,3 @@ export function useSingleCol({
},
});
}
-
-export function useSingleColRealtime({
- parameter,
- limit = 1000,
- pastMinutesStart = 30,
- pastMinutesEnd = 0,
-}: {
- parameter: FilterParameter;
- limit?: number;
- pastMinutesStart?: number;
- pastMinutesEnd?: number;
-}): UseQueryResult<APIResponse<SingleColResponse[]>> {
- const { site } = useStore();
-
- return useQuery({
- queryKey: [
- parameter,
- site,
- limit,
- pastMinutesStart,
- pastMinutesEnd,
- "realtime",
- ],
- queryFn: () => {
- return authedFetch<APIResponse<SingleColResponse[]>>(
- `/single-col/${site}`,
- {
- timeZone,
- parameter,
- limit,
- pastMinutesStart,
- pastMinutesEnd,
- }
- );
- },
- staleTime: Infinity,
- placeholderData: (_, query: any) => {
- if (!query?.queryKey) return undefined;
- const prevQueryKey = query.queryKey as [string, string, string];
- const [, , prevSite] = prevQueryKey;
-
- if (prevSite === site) {
- return query.state.data;
- }
- return undefined;
- },
- });
-}
diff --git a/client/src/app/[site]/events/components/EventList.tsx b/client/src/app/[site]/events/components/EventList.tsx
index 3454b7553..d85c5c0ea 100644
--- a/client/src/app/[site]/events/components/EventList.tsx
+++ b/client/src/app/[site]/events/components/EventList.tsx
@@ -3,8 +3,8 @@
import NumberFlow from "@number-flow/react";
import { BookOpen, ChevronDown, ChevronRight, Info } from "lucide-react";
import { memo, useState } from "react";
-import { EventName } from "../../../../api/analytics/useGetEventNames";
-import { useGetEventProperties } from "../../../../api/analytics/useGetEventProperties";
+import { EventName } from "../../../../api/analytics/events/useGetEventNames";
+import { useGetEventProperties } from "../../../../api/analytics/events/useGetEventProperties";
import { NothingFound } from "../../../../components/NothingFound";
import { cn } from "../../../../lib/utils";
import { EventProperties } from "./EventProperties";
diff --git a/client/src/app/[site]/events/components/EventLog.tsx b/client/src/app/[site]/events/components/EventLog.tsx
index 9f7c25049..717281e7c 100644
--- a/client/src/app/[site]/events/components/EventLog.tsx
+++ b/client/src/app/[site]/events/components/EventLog.tsx
@@ -1,7 +1,7 @@
"use client";
import { useCallback, useEffect, useRef } from "react";
-import { useGetEventsInfinite } from "../../../../api/analytics/useGetEvents";
+import { useGetEventsInfinite } from "../../../../api/analytics/events/useGetEvents";
import { NothingFound } from "../../../../components/NothingFound";
import { formatter } from "../../../../lib/utils";
import { EventLogItem, EventLogItemSkeleton } from "./EventLogItem";
diff --git a/client/src/app/[site]/events/components/EventLogItem.tsx b/client/src/app/[site]/events/components/EventLogItem.tsx
index 5e9090fa3..53df7f8b2 100644
--- a/client/src/app/[site]/events/components/EventLogItem.tsx
+++ b/client/src/app/[site]/events/components/EventLogItem.tsx
@@ -11,7 +11,7 @@ import { DateTime } from "luxon";
import Link from "next/link";
import { useParams } from "next/navigation";
import { memo } from "react";
-import { Event } from "../../../../api/analytics/useGetEvents";
+import { Event } from "../../../../api/analytics/events/useGetEvents";
import { getCountryName } from "../../../../lib/utils";
import { Browser } from "../../components/shared/icons/Browser";
import { CountryFlag } from "../../components/shared/icons/CountryFlag";
@@ -209,9 +209,7 @@ export const EventLogItemSkeleton = memo(() => {
{/* Left side content */}
<div className="flex items-center gap-2 flex-grow">
<div className="h-4 w-4 bg-neutral-800 rounded-sm animate-pulse flex-shrink-0"></div>
- <div
- className="h-4 w-40 bg-neutral-800 rounded animate-pulse flex-shrink-0"
- ></div>
+ <div className="h-4 w-40 bg-neutral-800 rounded animate-pulse flex-shrink-0"></div>
<div className="flex space-x-1 flex-shrink-0">
<div className="h-4 w-4 bg-neutral-800 rounded-sm animate-pulse"></div>
<div className="h-4 w-4 bg-neutral-800 rounded-sm animate-pulse"></div>
diff --git a/client/src/app/[site]/events/components/EventProperties.tsx b/client/src/app/[site]/events/components/EventProperties.tsx
index 8f86dd506..563e65351 100644
--- a/client/src/app/[site]/events/components/EventProperties.tsx
+++ b/client/src/app/[site]/events/components/EventProperties.tsx
@@ -3,7 +3,7 @@
import NumberFlow from "@number-flow/react";
import { Info } from "lucide-react";
import { memo } from "react";
-import { EventProperty } from "../../../../api/analytics/useGetEventProperties";
+import { EventProperty } from "../../../../api/analytics/events/useGetEventProperties";
import { cn } from "../../../../lib/utils";
interface EventPropertiesProps {
@@ -68,7 +68,10 @@ export function EventProperties({
return (
<div
- className={cn("flex flex-col gap-4 overflow-y-auto pr-2", size === "small" ? "max-h-[30vh]" : "max-h-[60vh]")}
+ className={cn(
+ "flex flex-col gap-4 overflow-y-auto pr-2",
+ size === "small" ? "max-h-[30vh]" : "max-h-[60vh]"
+ )}
>
{sortedKeys.map((key) => {
// Sort property values by count (descending)
@@ -77,7 +80,10 @@ export function EventProperties({
return (
<div
key={key}
- className={cn("flex flex-col gap-1", size === "small" ? "text-xs" : "text-sm")}
+ className={cn(
+ "flex flex-col gap-1",
+ size === "small" ? "text-xs" : "text-sm"
+ )}
>
{/* Property Key Header */}
<div className="font-semibold text-primary py-1 border-b border-neutral-800">
@@ -92,7 +98,10 @@ export function EventProperties({
return (
<div
key={`${property.propertyKey}-${property.propertyValue}`}
- className={cn("relative flex items-center hover:bg-neutral-850 group px-2 rounded-md", size === "small" ? "h-6" : "h-8")}
+ className={cn(
+ "relative flex items-center hover:bg-neutral-850 group px-2 rounded-md",
+ size === "small" ? "h-6" : "h-8"
+ )}
>
<div
className="absolute inset-0 bg-dataviz py-2 opacity-25 rounded-md"
@@ -146,12 +155,18 @@ const EventPropertiesSkeleton = memo(
return (
<div
- className={cn("flex flex-col gap-4 overflow-y-auto pr-2", size === "small" ? "max-h-[30vh]" : "max-h-[60vh]")}
+ className={cn(
+ "flex flex-col gap-4 overflow-y-auto pr-2",
+ size === "small" ? "max-h-[30vh]" : "max-h-[60vh]"
+ )}
>
{Array.from({ length: groupCount }).map((_, groupIndex) => (
<div
key={groupIndex}
- className={cn("flex flex-col gap-1", size === "small" ? "text-xs" : "text-sm")}
+ className={cn(
+ "flex flex-col gap-1",
+ size === "small" ? "text-xs" : "text-sm"
+ )}
>
{/* Property Key Header Skeleton */}
<div className="font-semibold py-1 border-b border-neutral-800">
@@ -172,7 +187,10 @@ const EventPropertiesSkeleton = memo(
return (
<div
key={propIndex}
- className={cn("relative flex items-center px-2 rounded-md", size === "small" ? "h-6" : "h-8")}
+ className={cn(
+ "relative flex items-center px-2 rounded-md",
+ size === "small" ? "h-6" : "h-8"
+ )}
>
<div
className="absolute inset-0 bg-neutral-800 py-2 opacity-25 rounded-md animate-pulse"
diff --git a/client/src/app/[site]/events/page.tsx b/client/src/app/[site]/events/page.tsx
index 98db419ba..be7483f26 100644
--- a/client/src/app/[site]/events/page.tsx
+++ b/client/src/app/[site]/events/page.tsx
@@ -2,7 +2,7 @@
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { EVENT_FILTERS } from "@/lib/store";
-import { useGetEventNames } from "../../../api/analytics/useGetEventNames";
+import { useGetEventNames } from "../../../api/analytics/events/useGetEventNames";
import { DisabledOverlay } from "../../../components/DisabledOverlay";
import { useSetPageTitle } from "../../../hooks/useSetPageTitle";
import { SubHeader } from "../components/SubHeader/SubHeader";
diff --git a/client/src/app/[site]/funnels/components/CreateFunnel.tsx b/client/src/app/[site]/funnels/components/CreateFunnel.tsx
index 7eb1eb185..249187d28 100644
--- a/client/src/app/[site]/funnels/components/CreateFunnel.tsx
+++ b/client/src/app/[site]/funnels/components/CreateFunnel.tsx
@@ -4,7 +4,7 @@ import {
FunnelStep,
useGetFunnel,
useSaveFunnel,
-} from "@/api/analytics/useGetFunnel";
+} from "../../../../api/analytics/funnels/useGetFunnel";
import { Time } from "@/components/DateSelector/types";
import { Button } from "@/components/ui/button";
import {
diff --git a/client/src/app/[site]/funnels/components/EditFunnel.tsx b/client/src/app/[site]/funnels/components/EditFunnel.tsx
index 2774e27aa..d61680ee9 100644
--- a/client/src/app/[site]/funnels/components/EditFunnel.tsx
+++ b/client/src/app/[site]/funnels/components/EditFunnel.tsx
@@ -4,8 +4,8 @@ import {
FunnelStep,
useGetFunnel,
useSaveFunnel,
-} from "@/api/analytics/useGetFunnel";
-import { SavedFunnel } from "@/api/analytics/useGetFunnels";
+} from "../../../../api/analytics/funnels/useGetFunnel";
+import { SavedFunnel } from "../../../../api/analytics/funnels/useGetFunnels";
import { Time } from "@/components/DateSelector/types";
import {
Dialog,
diff --git a/client/src/app/[site]/funnels/components/Funnel.tsx b/client/src/app/[site]/funnels/components/Funnel.tsx
index bd7e76c96..3e63d2563 100644
--- a/client/src/app/[site]/funnels/components/Funnel.tsx
+++ b/client/src/app/[site]/funnels/components/Funnel.tsx
@@ -1,10 +1,9 @@
"use client";
-import { FunnelResponse } from "@/api/analytics/useGetFunnel";
import { DateSelector } from "@/components/DateSelector/DateSelector";
import { Time } from "@/components/DateSelector/types";
import { round } from "lodash";
-import { ArrowDown, ArrowRight, ChevronRight } from "lucide-react";
+import { FunnelResponse } from "../../../../api/analytics/funnels/useGetFunnel";
export type FunnelChartData = {
stepName: string;
diff --git a/client/src/app/[site]/funnels/components/FunnelForm.tsx b/client/src/app/[site]/funnels/components/FunnelForm.tsx
index 2b3d6d2c1..6c5daa233 100644
--- a/client/src/app/[site]/funnels/components/FunnelForm.tsx
+++ b/client/src/app/[site]/funnels/components/FunnelForm.tsx
@@ -1,4 +1,3 @@
-import { FunnelResponse, FunnelStep } from "@/api/analytics/useGetFunnel";
import { Time } from "@/components/DateSelector/types";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
@@ -16,9 +15,12 @@ import { ThreeDotLoader } from "../../../../components/Loaders";
import { Filter } from "@rybbit/shared";
import { FilterComponent } from "../../components/shared/Filters/FilterComponent";
import { Funnel } from "./Funnel";
-import { SavedFunnel } from "../../../../api/analytics/useGetFunnels";
import { Switch } from "../../../../components/ui/switch";
import { Label } from "../../../../components/ui/label";
+import {
+ FunnelResponse,
+ FunnelStep,
+} from "../../../../api/analytics/funnels/useGetFunnel";
interface FunnelFormProps {
name: string;
diff --git a/client/src/app/[site]/funnels/components/FunnelRow.tsx b/client/src/app/[site]/funnels/components/FunnelRow.tsx
index 7f75d2ff5..b85884295 100644
--- a/client/src/app/[site]/funnels/components/FunnelRow.tsx
+++ b/client/src/app/[site]/funnels/components/FunnelRow.tsx
@@ -1,8 +1,8 @@
"use client";
-import { useDeleteFunnel } from "@/api/analytics/useDeleteFunnel";
-import { useGetFunnel } from "@/api/analytics/useGetFunnel";
-import { SavedFunnel } from "@/api/analytics/useGetFunnels";
+import { useDeleteFunnel } from "../../../../api/analytics/funnels/useDeleteFunnel";
+import { useGetFunnel } from "../../../../api/analytics/funnels/useGetFunnel";
+import { SavedFunnel } from "../../../../api/analytics/funnels/useGetFunnels";
import { ConfirmationModal } from "@/components/ConfirmationModal";
import { DateRangeMode, Time } from "@/components/DateSelector/types";
import { Button } from "@/components/ui/button";
diff --git a/client/src/app/[site]/funnels/page.tsx b/client/src/app/[site]/funnels/page.tsx
index 21dc27712..e8e3c3a1c 100644
--- a/client/src/app/[site]/funnels/page.tsx
+++ b/client/src/app/[site]/funnels/page.tsx
@@ -1,6 +1,9 @@
"use client";
-import { SavedFunnel, useGetFunnels } from "@/api/analytics/useGetFunnels";
+import {
+ SavedFunnel,
+ useGetFunnels,
+} from "../../../api/analytics/funnels/useGetFunnels";
import { Skeleton } from "@/components/ui/skeleton";
import { useStore } from "@/lib/store";
import { ArrowRight, FilterIcon } from "lucide-react";
diff --git a/client/src/app/[site]/goals/components/GoalCard.tsx b/client/src/app/[site]/goals/components/GoalCard.tsx
index 1787768d2..4d038495c 100644
--- a/client/src/app/[site]/goals/components/GoalCard.tsx
+++ b/client/src/app/[site]/goals/components/GoalCard.tsx
@@ -2,8 +2,7 @@
import { FileText, MousePointerClick, Edit, Trash2 } from "lucide-react";
import { useState } from "react";
-import { useDeleteGoal } from "../../../../api/analytics/useDeleteGoal";
-import { Goal } from "../../../../api/analytics/useGetGoals";
+import { useDeleteGoal } from "../../../../api/analytics/goals/useDeleteGoal";
import {
AlertDialog,
AlertDialogAction,
@@ -21,6 +20,7 @@ import {
TooltipContent,
TooltipTrigger,
} from "../../../../components/ui/tooltip";
+import { Goal } from "../../../../api/analytics/goals/useGetGoals";
interface GoalCardProps {
goal: Goal;
diff --git a/client/src/app/[site]/goals/components/GoalFormModal.tsx b/client/src/app/[site]/goals/components/GoalFormModal.tsx
index 0acdcf076..e48b1f397 100644
--- a/client/src/app/[site]/goals/components/GoalFormModal.tsx
+++ b/client/src/app/[site]/goals/components/GoalFormModal.tsx
@@ -5,9 +5,8 @@ import { FileText, MousePointerClick } from "lucide-react";
import { useState } from "react";
import { useForm } from "react-hook-form";
import * as z from "zod";
-import { useCreateGoal } from "../../../../api/analytics/useCreateGoal";
-import { Goal } from "../../../../api/analytics/useGetGoals";
-import { useUpdateGoal } from "../../../../api/analytics/useUpdateGoal";
+import { useCreateGoal } from "../../../../api/analytics/goals/useCreateGoal";
+import { Goal } from "../../../../api/analytics/goals/useGetGoals";
import { Button } from "../../../../components/ui/button";
import {
Dialog,
@@ -29,6 +28,7 @@ import { Input } from "../../../../components/ui/input";
import { Label } from "../../../../components/ui/label";
import { Switch } from "../../../../components/ui/switch";
import { cn } from "../../../../lib/utils";
+import { useUpdateGoal } from "../../../../api/analytics/goals/useUpdateGoal";
// Define form schema
const formSchema = z
@@ -220,7 +220,10 @@ export default function GoalFormModal({
variant={
field.value === "path" ? "default" : "outline"
}
- className={cn("flex-1 flex items-center justify-center gap-2", field.value === "path" && "border-blue-500")}
+ className={cn(
+ "flex-1 flex items-center justify-center gap-2",
+ field.value === "path" && "border-blue-500"
+ )}
onClick={() => field.onChange("path")}
>
<FileText className="w-4 h-4 text-blue-500" />
@@ -231,7 +234,10 @@ export default function GoalFormModal({
variant={
field.value === "event" ? "default" : "outline"
}
- className={cn("flex-1 flex items-center justify-center gap-2", field.value === "event" && "border-amber-500")}
+ className={cn(
+ "flex-1 flex items-center justify-center gap-2",
+ field.value === "event" && "border-amber-500"
+ )}
onClick={() => field.onChange("event")}
>
<MousePointerClick className="w-4 h-4 text-amber-500" />
diff --git a/client/src/app/[site]/goals/components/GoalsList.tsx b/client/src/app/[site]/goals/components/GoalsList.tsx
index 89cada5ac..d7c43948e 100644
--- a/client/src/app/[site]/goals/components/GoalsList.tsx
+++ b/client/src/app/[site]/goals/components/GoalsList.tsx
@@ -1,9 +1,12 @@
"use client";
-import { Goal, PaginationMeta } from "../../../../api/analytics/useGetGoals";
import GoalCard from "./GoalCard";
import { Button } from "../../../../components/ui/button";
import { ChevronLeft, ChevronRight } from "lucide-react";
+import {
+ Goal,
+ PaginationMeta,
+} from "../../../../api/analytics/goals/useGetGoals";
interface GoalsListProps {
goals: Goal[];
diff --git a/client/src/app/[site]/goals/page.tsx b/client/src/app/[site]/goals/page.tsx
index 343bb9ea4..4a440d480 100644
--- a/client/src/app/[site]/goals/page.tsx
+++ b/client/src/app/[site]/goals/page.tsx
@@ -4,7 +4,7 @@ import { useState } from "react";
import {
useGetGoals,
useGetGoalsPastMinutes,
-} from "../../../api/analytics/useGetGoals";
+} from "../../../api/analytics/goals/useGetGoals";
import { DisabledOverlay } from "../../../components/DisabledOverlay";
import { NothingFound } from "../../../components/NothingFound";
import { useSetPageTitle } from "../../../hooks/useSetPageTitle";
diff --git a/client/src/app/[site]/main/components/sections/Events.tsx b/client/src/app/[site]/main/components/sections/Events.tsx
index f2838aeb0..c620e17aa 100644
--- a/client/src/app/[site]/main/components/sections/Events.tsx
+++ b/client/src/app/[site]/main/components/sections/Events.tsx
@@ -10,7 +10,7 @@ import {
CardContent,
CardLoader,
} from "../../../../../components/ui/card";
-import { useGetEventNames } from "../../../../../api/analytics/useGetEventNames";
+import { useGetEventNames } from "../../../../../api/analytics/events/useGetEventNames";
import { EventList } from "../../../events/components/EventList";
type Tab = "events";
diff --git a/client/src/app/[site]/performance/components/PerformanceChart.tsx b/client/src/app/[site]/performance/components/PerformanceChart.tsx
index ca51c6222..fcc18522c 100644
--- a/client/src/app/[site]/performance/components/PerformanceChart.tsx
+++ b/client/src/app/[site]/performance/components/PerformanceChart.tsx
@@ -9,7 +9,7 @@ import { Tilt_Warp } from "next/font/google";
import Image from "next/image";
import Link from "next/link";
import { useState } from "react";
-import { useGetPerformanceTimeSeries } from "../../../../api/analytics/useGetPerformanceTimeSeries";
+import { useGetPerformanceTimeSeries } from "../../../../api/analytics/performance/useGetPerformanceTimeSeries";
import { BucketSelection } from "../../../../components/BucketSelection";
import { authClient } from "../../../../lib/auth";
import { hour12, userLocale } from "../../../../lib/dateTimeUtils";
diff --git a/client/src/app/[site]/performance/components/PerformanceMap.tsx b/client/src/app/[site]/performance/components/PerformanceMap.tsx
index dbbd8600c..285e15bbb 100644
--- a/client/src/app/[site]/performance/components/PerformanceMap.tsx
+++ b/client/src/app/[site]/performance/components/PerformanceMap.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useGetPerformanceByDimension } from "@/api/analytics/useGetPerformanceByDimension";
+import { useGetPerformanceByDimension } from "@/api/analytics/performance/useGetPerformanceByDimension";
import { useMeasure } from "@uidotdev/usehooks";
import { scalePow } from "d3-scale";
import { Feature, GeoJsonObject } from "geojson";
diff --git a/client/src/app/[site]/performance/components/PerformanceOverview.tsx b/client/src/app/[site]/performance/components/PerformanceOverview.tsx
index 82293bfb4..a6ce0e3e8 100644
--- a/client/src/app/[site]/performance/components/PerformanceOverview.tsx
+++ b/client/src/app/[site]/performance/components/PerformanceOverview.tsx
@@ -4,7 +4,7 @@ import { Skeleton } from "@/components/ui/skeleton";
import { cn } from "@/lib/utils";
import NumberFlow from "@number-flow/react";
import { TrendingDown, TrendingUp } from "lucide-react";
-import { useGetPerformanceOverview } from "../../../../api/analytics/useGetPerformanceOverview";
+import { useGetPerformanceOverview } from "../../../../api/analytics/performance/useGetPerformanceOverview";
import { Card, CardContent, CardLoader } from "../../../../components/ui/card";
import { useStore } from "../../../../lib/store";
import { PerformanceMetric, usePerformanceStore } from "../performanceStore";
diff --git a/client/src/app/[site]/performance/components/PerformanceTable.tsx b/client/src/app/[site]/performance/components/PerformanceTable.tsx
index ce34c2591..e7bfea06e 100644
--- a/client/src/app/[site]/performance/components/PerformanceTable.tsx
+++ b/client/src/app/[site]/performance/components/PerformanceTable.tsx
@@ -31,14 +31,10 @@ import { useGetSite } from "../../../../api/admin/sites";
import {
PerformanceByDimensionItem,
useGetPerformanceByDimension,
-} from "../../../../api/analytics/useGetPerformanceByDimension";
+} from "../../../../api/analytics/performance/useGetPerformanceByDimension";
import { TablePagination } from "../../../../components/pagination";
import { FilterParameter } from "@rybbit/shared";
-import {
- useStore,
- addFilter,
- removeFilter,
-} from "../../../../lib/store";
+import { useStore, addFilter, removeFilter } from "../../../../lib/store";
import { PerformanceMetric, usePerformanceStore } from "../performanceStore";
import {
formatMetricValue,
diff --git a/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx b/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx
index facff4ea4..c94c2413d 100644
--- a/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx
+++ b/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx
@@ -6,7 +6,10 @@ import {
import { FileText, Laptop, MousePointerClick, Smartphone } from "lucide-react";
import { DateTime } from "luxon";
import Link from "next/link";
-import { Event, useGetEvents } from "../../../../api/analytics/useGetEvents";
+import {
+ Event,
+ useGetEvents,
+} from "../../../../api/analytics/events/useGetEvents";
import { Skeleton } from "../../../../components/ui/skeleton";
import { cn, getCountryName } from "../../../../lib/utils";
import { Browser } from "../../components/shared/icons/Browser";
diff --git a/server/src/api/analytics/getEventNames.ts b/server/src/api/analytics/events/getEventNames.ts
similarity index 93%
rename from server/src/api/analytics/getEventNames.ts
rename to server/src/api/analytics/events/getEventNames.ts
index 144dcb456..7cc806c60 100644
--- a/server/src/api/analytics/getEventNames.ts
+++ b/server/src/api/analytics/events/getEventNames.ts
@@ -1,11 +1,11 @@
import { FastifyReply, FastifyRequest } from "fastify";
-import clickhouse from "../../db/clickhouse/clickhouse.js";
+import clickhouse from "../../../db/clickhouse/clickhouse.js";
import {
getTimeStatement,
processResults,
getFilterStatement,
-} from "./utils.js";
-import { getUserHasAccessToSitePublic } from "../../lib/auth-utils.js";
+} from "../utils.js";
+import { getUserHasAccessToSitePublic } from "../../../lib/auth-utils.js";
export type GetEventNamesResponse = {
eventName: string;
diff --git a/server/src/api/analytics/getEventProperties.ts b/server/src/api/analytics/events/getEventProperties.ts
similarity index 94%
rename from server/src/api/analytics/getEventProperties.ts
rename to server/src/api/analytics/events/getEventProperties.ts
index d2a9ffe41..1aa7b2a55 100644
--- a/server/src/api/analytics/getEventProperties.ts
+++ b/server/src/api/analytics/events/getEventProperties.ts
@@ -1,11 +1,11 @@
import { FastifyReply, FastifyRequest } from "fastify";
-import clickhouse from "../../db/clickhouse/clickhouse.js";
+import clickhouse from "../../../db/clickhouse/clickhouse.js";
import {
getTimeStatement,
processResults,
getFilterStatement,
-} from "./utils.js";
-import { getUserHasAccessToSitePublic } from "../../lib/auth-utils.js";
+} from "../utils.js";
+import { getUserHasAccessToSitePublic } from "../../../lib/auth-utils.js";
export type GetEventPropertiesResponse = {
propertyKey: string;
diff --git a/server/src/api/analytics/getEvents.ts b/server/src/api/analytics/events/getEvents.ts
similarity index 93%
rename from server/src/api/analytics/getEvents.ts
rename to server/src/api/analytics/events/getEvents.ts
index 2cddfe07e..66e84b208 100644
--- a/server/src/api/analytics/getEvents.ts
+++ b/server/src/api/analytics/events/getEvents.ts
@@ -1,11 +1,11 @@
import { FastifyReply, FastifyRequest } from "fastify";
-import clickhouse from "../../db/clickhouse/clickhouse.js";
+import clickhouse from "../../../db/clickhouse/clickhouse.js";
import {
processResults,
getTimeStatement,
getFilterStatement,
-} from "./utils.js";
-import { getUserHasAccessToSitePublic } from "../../lib/auth-utils.js";
+} from "../utils.js";
+import { getUserHasAccessToSitePublic } from "../../../lib/auth-utils.js";
export type GetEventsResponse = {
timestamp: string;
@@ -132,9 +132,8 @@ export async function getEvents(
},
});
- const events = await processResults<GetEventsResponse[number]>(
- eventsResult
- );
+ const events =
+ await processResults<GetEventsResponse[number]>(eventsResult);
return res.send({
data: events,
diff --git a/server/src/api/analytics/createFunnel.ts b/server/src/api/analytics/funnels/createFunnel.ts
similarity index 91%
rename from server/src/api/analytics/createFunnel.ts
rename to server/src/api/analytics/funnels/createFunnel.ts
index c2f587d18..33b4b16d2 100644
--- a/server/src/api/analytics/createFunnel.ts
+++ b/server/src/api/analytics/funnels/createFunnel.ts
@@ -1,9 +1,9 @@
import { eq } from "drizzle-orm";
import { FastifyReply, FastifyRequest } from "fastify";
-import { db } from "../../db/postgres/postgres.js";
-import { funnels as funnelsTable } from "../../db/postgres/schema.js";
-import { getUserHasAccessToSite } from "../../lib/auth-utils.js";
-import { Filter } from "./types.js";
+import { db } from "../../../db/postgres/postgres.js";
+import { funnels as funnelsTable } from "../../../db/postgres/schema.js";
+import { getUserHasAccessToSite } from "../../../lib/auth-utils.js";
+import { Filter } from "../types.js";
type FunnelStep = {
value: string;
diff --git a/server/src/api/analytics/deleteFunnel.ts b/server/src/api/analytics/funnels/deleteFunnel.ts
similarity index 86%
rename from server/src/api/analytics/deleteFunnel.ts
rename to server/src/api/analytics/funnels/deleteFunnel.ts
index 34ee56e4d..88553cb2e 100644
--- a/server/src/api/analytics/deleteFunnel.ts
+++ b/server/src/api/analytics/funnels/deleteFunnel.ts
@@ -1,8 +1,8 @@
import { eq } from "drizzle-orm";
import { FastifyReply, FastifyRequest } from "fastify";
-import { db } from "../../db/postgres/postgres.js";
-import { funnels as funnelsTable } from "../../db/postgres/schema.js";
-import { getUserHasAccessToSite } from "../../lib/auth-utils.js";
+import { db } from "../../../db/postgres/postgres.js";
+import { funnels as funnelsTable } from "../../../db/postgres/schema.js";
+import { getUserHasAccessToSite } from "../../../lib/auth-utils.js";
export async function deleteFunnel(
request: FastifyRequest<{
diff --git a/server/src/api/analytics/getFunnel.ts b/server/src/api/analytics/funnels/getFunnel.ts
similarity index 96%
rename from server/src/api/analytics/getFunnel.ts
rename to server/src/api/analytics/funnels/getFunnel.ts
index ca0eeca16..31a76228d 100644
--- a/server/src/api/analytics/getFunnel.ts
+++ b/server/src/api/analytics/funnels/getFunnel.ts
@@ -1,15 +1,15 @@
import { FastifyRequest } from "fastify";
import { FastifyReply } from "fastify";
-import clickhouse from "../../db/clickhouse/clickhouse.js";
+import clickhouse from "../../../db/clickhouse/clickhouse.js";
import {
getTimeStatement,
processResults,
getFilterStatement,
patternToRegex,
-} from "./utils.js";
-import { getUserHasAccessToSitePublic } from "../../lib/auth-utils.js";
+} from "../utils.js";
+import { getUserHasAccessToSitePublic } from "../../../lib/auth-utils.js";
import SqlString from "sqlstring";
-import { Filter } from "./types.js";
+import { Filter } from "../types.js";
type FunnelStep = {
value: string;
diff --git a/server/src/api/analytics/getFunnels.ts b/server/src/api/analytics/funnels/getFunnels.ts
similarity index 83%
rename from server/src/api/analytics/getFunnels.ts
rename to server/src/api/analytics/funnels/getFunnels.ts
index 37cc93f93..7167bbb38 100644
--- a/server/src/api/analytics/getFunnels.ts
+++ b/server/src/api/analytics/funnels/getFunnels.ts
@@ -1,8 +1,8 @@
-import { FastifyRequest, FastifyReply } from "fastify";
-import { db } from "../../db/postgres/postgres.js";
-import { funnels as funnelsTable } from "../../db/postgres/schema.js";
-import { getUserHasAccessToSitePublic } from "../../lib/auth-utils.js";
-import { eq, and } from "drizzle-orm";
+import { eq } from "drizzle-orm";
+import { FastifyReply, FastifyRequest } from "fastify";
+import { db } from "../../../db/postgres/postgres.js";
+import { funnels as funnelsTable } from "../../../db/postgres/schema.js";
+import { getUserHasAccessToSitePublic } from "../../../lib/auth-utils.js";
export async function getFunnels(
request: FastifyRequest<{
diff --git a/server/src/api/analytics/createGoal.ts b/server/src/api/analytics/goals/createGoal.ts
similarity index 95%
rename from server/src/api/analytics/createGoal.ts
rename to server/src/api/analytics/goals/createGoal.ts
index 65448ce26..dbbeeec09 100644
--- a/server/src/api/analytics/createGoal.ts
+++ b/server/src/api/analytics/goals/createGoal.ts
@@ -1,7 +1,7 @@
import { FastifyReply, FastifyRequest } from "fastify";
-import { db } from "../../db/postgres/postgres.js";
-import { goals } from "../../db/postgres/schema.js";
-import { getUserHasAccessToSite } from "../../lib/auth-utils.js";
+import { db } from "../../../db/postgres/postgres.js";
+import { goals } from "../../../db/postgres/schema.js";
+import { getUserHasAccessToSite } from "../../../lib/auth-utils.js";
import { z } from "zod";
// Define validation schema for path pattern
diff --git a/server/src/api/analytics/deleteGoal.ts b/server/src/api/analytics/goals/deleteGoal.ts
similarity index 87%
rename from server/src/api/analytics/deleteGoal.ts
rename to server/src/api/analytics/goals/deleteGoal.ts
index f170cb448..033977cb4 100644
--- a/server/src/api/analytics/deleteGoal.ts
+++ b/server/src/api/analytics/goals/deleteGoal.ts
@@ -1,7 +1,7 @@
import { FastifyReply, FastifyRequest } from "fastify";
-import { db } from "../../db/postgres/postgres.js";
-import { goals } from "../../db/postgres/schema.js";
-import { getUserHasAccessToSite } from "../../lib/auth-utils.js";
+import { db } from "../../../db/postgres/postgres.js";
+import { goals } from "../../../db/postgres/schema.js";
+import { getUserHasAccessToSite } from "../../../lib/auth-utils.js";
import { eq } from "drizzle-orm";
export async function deleteGoal(
diff --git a/server/src/api/analytics/getGoal.ts b/server/src/api/analytics/goals/getGoal.ts
similarity index 95%
rename from server/src/api/analytics/getGoal.ts
rename to server/src/api/analytics/goals/getGoal.ts
index 235dc9251..d3b546d2d 100644
--- a/server/src/api/analytics/getGoal.ts
+++ b/server/src/api/analytics/goals/getGoal.ts
@@ -1,15 +1,15 @@
import { FastifyReply, FastifyRequest } from "fastify";
-import { db } from "../../db/postgres/postgres.js";
-import { goals } from "../../db/postgres/schema.js";
-import clickhouse from "../../db/clickhouse/clickhouse.js";
-import { getUserHasAccessToSitePublic } from "../../lib/auth-utils.js";
+import { db } from "../../../db/postgres/postgres.js";
+import { goals } from "../../../db/postgres/schema.js";
+import clickhouse from "../../../db/clickhouse/clickhouse.js";
+import { getUserHasAccessToSitePublic } from "../../../lib/auth-utils.js";
import { eq } from "drizzle-orm";
import {
getFilterStatement,
getTimeStatement,
processResults,
patternToRegex,
-} from "./utils.js";
+} from "../utils.js";
import SqlString from "sqlstring";
export async function getGoal(
diff --git a/server/src/api/analytics/getGoals.ts b/server/src/api/analytics/goals/getGoals.ts
similarity index 97%
rename from server/src/api/analytics/getGoals.ts
rename to server/src/api/analytics/goals/getGoals.ts
index b012c35cd..f94404636 100644
--- a/server/src/api/analytics/getGoals.ts
+++ b/server/src/api/analytics/goals/getGoals.ts
@@ -1,15 +1,15 @@
import { FastifyReply, FastifyRequest } from "fastify";
-import { db } from "../../db/postgres/postgres.js";
-import { goals } from "../../db/postgres/schema.js";
-import clickhouse from "../../db/clickhouse/clickhouse.js";
-import { getUserHasAccessToSitePublic } from "../../lib/auth-utils.js";
+import { db } from "../../../db/postgres/postgres.js";
+import { goals } from "../../../db/postgres/schema.js";
+import clickhouse from "../../../db/clickhouse/clickhouse.js";
+import { getUserHasAccessToSitePublic } from "../../../lib/auth-utils.js";
import { eq, desc, asc, sql } from "drizzle-orm";
import {
getFilterStatement,
getTimeStatement,
processResults,
patternToRegex,
-} from "./utils.js";
+} from "../utils.js";
import SqlString from "sqlstring";
// Types for the response
diff --git a/server/src/api/analytics/updateGoal.ts b/server/src/api/analytics/goals/updateGoal.ts
similarity index 95%
rename from server/src/api/analytics/updateGoal.ts
rename to server/src/api/analytics/goals/updateGoal.ts
index c0aba1dd7..6e88ba825 100644
--- a/server/src/api/analytics/updateGoal.ts
+++ b/server/src/api/analytics/goals/updateGoal.ts
@@ -1,7 +1,7 @@
import { FastifyReply, FastifyRequest } from "fastify";
-import { db } from "../../db/postgres/postgres.js";
-import { goals } from "../../db/postgres/schema.js";
-import { getUserHasAccessToSite } from "../../lib/auth-utils.js";
+import { db } from "../../../db/postgres/postgres.js";
+import { goals } from "../../../db/postgres/schema.js";
+import { getUserHasAccessToSite } from "../../../lib/auth-utils.js";
import { z } from "zod";
import { eq } from "drizzle-orm";
diff --git a/server/src/api/analytics/getPerformanceByDimension.ts b/server/src/api/analytics/performance/getPerformanceByDimension.ts
similarity index 98%
rename from server/src/api/analytics/getPerformanceByDimension.ts
rename to server/src/api/analytics/performance/getPerformanceByDimension.ts
index 03c271009..c38d1e5f6 100644
--- a/server/src/api/analytics/getPerformanceByDimension.ts
+++ b/server/src/api/analytics/performance/getPerformanceByDimension.ts
@@ -1,11 +1,11 @@
import { FastifyReply, FastifyRequest } from "fastify";
-import clickhouse from "../../db/clickhouse/clickhouse.js";
-import { getUserHasAccessToSitePublic } from "../../lib/auth-utils.js";
+import clickhouse from "../../../db/clickhouse/clickhouse.js";
+import { getUserHasAccessToSitePublic } from "../../../lib/auth-utils.js";
import {
getFilterStatement,
getTimeStatement,
processResults,
-} from "./utils.js";
+} from "../utils.js";
interface GetPerformanceByDimensionRequest {
Params: {
diff --git a/server/src/api/analytics/getPerformanceOverview.ts b/server/src/api/analytics/performance/getPerformanceOverview.ts
similarity index 93%
rename from server/src/api/analytics/getPerformanceOverview.ts
rename to server/src/api/analytics/performance/getPerformanceOverview.ts
index b7c0c65b6..80036ea6d 100644
--- a/server/src/api/analytics/getPerformanceOverview.ts
+++ b/server/src/api/analytics/performance/getPerformanceOverview.ts
@@ -1,12 +1,12 @@
import { FastifyReply, FastifyRequest } from "fastify";
-import clickhouse from "../../db/clickhouse/clickhouse.js";
+import clickhouse from "../../../db/clickhouse/clickhouse.js";
import {
getFilterStatement,
getTimeStatement,
processResults,
-} from "./utils.js";
-import { getUserHasAccessToSitePublic } from "../../lib/auth-utils.js";
-import { PerformanceOverviewMetrics } from "./types.js";
+} from "../utils.js";
+import { getUserHasAccessToSitePublic } from "../../../lib/auth-utils.js";
+import { PerformanceOverviewMetrics } from "../types.js";
const getQuery = ({
startDate,
diff --git a/server/src/api/analytics/getPerformanceTimeSeries.ts b/server/src/api/analytics/performance/getPerformanceTimeSeries.ts
similarity index 95%
rename from server/src/api/analytics/getPerformanceTimeSeries.ts
rename to server/src/api/analytics/performance/getPerformanceTimeSeries.ts
index 68238a997..8c5ecfa85 100644
--- a/server/src/api/analytics/getPerformanceTimeSeries.ts
+++ b/server/src/api/analytics/performance/getPerformanceTimeSeries.ts
@@ -1,14 +1,14 @@
import { FastifyReply, FastifyRequest } from "fastify";
-import clickhouse from "../../db/clickhouse/clickhouse.js";
+import clickhouse from "../../../db/clickhouse/clickhouse.js";
import {
getFilterStatement,
getTimeStatement,
processResults,
-} from "./utils.js";
+} from "../utils.js";
import SqlString from "sqlstring";
-import { getUserHasAccessToSitePublic } from "../../lib/auth-utils.js";
-import { validateTimeStatementFillParams } from "./query-validation.js";
-import { TimeBucket, PerformanceTimeSeriesPoint } from "./types.js";
+import { getUserHasAccessToSitePublic } from "../../../lib/auth-utils.js";
+import { validateTimeStatementFillParams } from "../query-validation.js";
+import { TimeBucket, PerformanceTimeSeriesPoint } from "../types.js";
const TimeBucketToFn = {
minute: "toStartOfMinute",
diff --git a/server/src/index.ts b/server/src/index.ts
index b6b514096..b65ea834a 100644
--- a/server/src/index.ts
+++ b/server/src/index.ts
@@ -6,17 +6,17 @@ import { dirname, join } from "path";
import { fileURLToPath } from "url";
import { getAdminSites } from "./api/admin/getAdminSites.js";
import { getAdminOrganizations } from "./api/admin/getAdminOrganizations.js";
-import { createFunnel } from "./api/analytics/createFunnel.js";
-import { createGoal } from "./api/analytics/createGoal.js";
-import { deleteFunnel } from "./api/analytics/deleteFunnel.js";
-import { deleteGoal } from "./api/analytics/deleteGoal.js";
-import { getEventNames } from "./api/analytics/getEventNames.js";
-import { getEventProperties } from "./api/analytics/getEventProperties.js";
-import { getEvents } from "./api/analytics/getEvents.js";
-import { getFunnel } from "./api/analytics/getFunnel.js";
-import { getFunnels } from "./api/analytics/getFunnels.js";
-import { getGoal } from "./api/analytics/getGoal.js";
-import { getGoals } from "./api/analytics/getGoals.js";
+import { createFunnel } from "./api/analytics/funnels/createFunnel.js";
+import { createGoal } from "./api/analytics/goals/createGoal.js";
+import { deleteFunnel } from "./api/analytics/funnels/deleteFunnel.js";
+import { deleteGoal } from "./api/analytics/goals/deleteGoal.js";
+import { getEventNames } from "./api/analytics/events/getEventNames.js";
+import { getEventProperties } from "./api/analytics/events/getEventProperties.js";
+import { getEvents } from "./api/analytics/events/getEvents.js";
+import { getFunnel } from "./api/analytics/funnels/getFunnel.js";
+import { getFunnels } from "./api/analytics/funnels/getFunnels.js";
+import { getGoal } from "./api/analytics/goals/getGoal.js";
+import { getGoals } from "./api/analytics/goals/getGoals.js";
import { getJourneys } from "./api/analytics/getJourneys.js";
import { getLiveSessionLocations } from "./api/analytics/getLiveSessionLocations.js";
import { getLiveUsercount } from "./api/analytics/getLiveUsercount.js";
@@ -24,9 +24,9 @@ import { getOrgEventCount } from "./api/analytics/getOrgEventCount.js";
import { getOverview } from "./api/analytics/getOverview.js";
import { getOverviewBucketed } from "./api/analytics/getOverviewBucketed.js";
import { getPageTitles } from "./api/analytics/getPageTitles.js";
-import { getPerformanceByDimension } from "./api/analytics/getPerformanceByDimension.js";
-import { getPerformanceOverview } from "./api/analytics/getPerformanceOverview.js";
-import { getPerformanceTimeSeries } from "./api/analytics/getPerformanceTimeSeries.js";
+import { getPerformanceByDimension } from "./api/analytics/performance/getPerformanceByDimension.js";
+import { getPerformanceOverview } from "./api/analytics/performance/getPerformanceOverview.js";
+import { getPerformanceTimeSeries } from "./api/analytics/performance/getPerformanceTimeSeries.js";
import { getRetention } from "./api/analytics/getRetention.js";
import { getSession } from "./api/analytics/getSession.js";
import { getSessions } from "./api/analytics/getSessions.js";
@@ -35,7 +35,7 @@ import { getUserInfo } from "./api/analytics/getUserInfo.js";
import { getUserSessionCount } from "./api/analytics/getUserSessionCount.js";
import { getUserSessions } from "./api/analytics/getUserSessions.js";
import { getUsers } from "./api/analytics/getUsers.js";
-import { updateGoal } from "./api/analytics/updateGoal.js";
+import { updateGoal } from "./api/analytics/goals/updateGoal.js";
import { getConfig } from "./api/getConfig.js";
import { addSite } from "./api/sites/addSite.js";
import { changeSiteBlockBots } from "./api/sites/changeSiteBlockBots.js";