Skip to content

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

Enhance event tracking by expanding ServiceEventCountResponse structure

Bill Yang5814932988a8
diff --git a/client/src/api/admin/endpoints/adminServiceEventCount.ts b/client/src/api/admin/endpoints/adminServiceEventCount.ts
index cb070b6ed..a248f18f1 100644
--- a/client/src/api/admin/endpoints/adminServiceEventCount.ts
+++ b/client/src/api/admin/endpoints/adminServiceEventCount.ts
@@ -1,12 +1,20 @@
import { authedFetch } from "../../utils";
-export type ServiceEventCountResponse = {
+export type EventCountRow = {
event_date: string;
pageview_count: number;
custom_event_count: number;
performance_count: number;
+ outbound_count: number;
+ error_count: number;
+ button_click_count: number;
+ copy_count: number;
+ form_submit_count: number;
+ input_change_count: number;
event_count: number;
-}[];
+};
+
+export type ServiceEventCountResponse = EventCountRow[];
export type GetServiceEventCountResponse = {
data: ServiceEventCountResponse;
diff --git a/client/src/app/admin/components/shared/ServiceUsageChart.tsx b/client/src/app/admin/components/shared/ServiceUsageChart.tsx
index 1f1477e13..e299c701d 100644
--- a/client/src/app/admin/components/shared/ServiceUsageChart.tsx
+++ b/client/src/app/admin/components/shared/ServiceUsageChart.tsx
@@ -1,13 +1,8 @@
"use client";
import { useGetAdminServiceEventCount } from "@/api/admin/hooks/useAdminServiceEventCount";
-import { timeZone, userLocale } from "@/lib/dateTimeUtils";
-import { useNivoTheme } from "@/lib/nivo";
-import { formatter } from "@/lib/utils";
-import { ResponsiveLine } from "@nivo/line";
-import { useWindowSize } from "@uidotdev/usehooks";
-import { DateTime } from "luxon";
-import { ChartTooltip } from "@/components/charts/ChartTooltip";
+import { timeZone } from "@/lib/dateTimeUtils";
+import { EventUsageChart } from "@/components/EventUsageChart";
interface ServiceUsageChartProps {
startDate?: string;
@@ -16,179 +11,18 @@ interface ServiceUsageChartProps {
}
export function ServiceUsageChart({ startDate, endDate, title }: ServiceUsageChartProps) {
- const { width } = useWindowSize();
- const nivoTheme = useNivoTheme();
-
- // Fetch the data inside the component
const { data, isLoading, error } = useGetAdminServiceEventCount({
startDate,
endDate,
timeZone,
});
- const maxTicks = Math.round((width ?? Infinity) / 200);
-
- const pageviewData =
- data?.data
- ?.map(e => {
- const timestamp = DateTime.fromSQL(e.event_date).toUTC();
- if (timestamp > DateTime.now()) return null;
- return {
- x: timestamp.toFormat("yyyy-MM-dd"),
- y: e.pageview_count,
- currentTime: timestamp,
- };
- })
- .filter(e => e !== null) || [];
-
- const customEventData =
- data?.data
- ?.map(e => {
- const timestamp = DateTime.fromSQL(e.event_date).toUTC();
- if (timestamp > DateTime.now()) return null;
- return {
- x: timestamp.toFormat("yyyy-MM-dd"),
- y: e.custom_event_count,
- currentTime: timestamp,
- };
- })
- .filter(e => e !== null) || [];
-
- const performanceData =
- data?.data
- ?.map(e => {
- const timestamp = DateTime.fromSQL(e.event_date).toUTC();
- if (timestamp > DateTime.now()) return null;
- return {
- x: timestamp.toFormat("yyyy-MM-dd"),
- y: e.performance_count,
- currentTime: timestamp,
- };
- })
- .filter(e => e !== null) || [];
-
- const chartData = [
- {
- id: "pageviews",
- data: pageviewData,
- },
- {
- id: "custom events",
- data: customEventData,
- },
- {
- id: "performance",
- data: performanceData,
- },
- ];
-
- const maxValue = Math.max(
- ...pageviewData.map(d => d.y),
- ...customEventData.map(d => d.y),
- ...performanceData.map(d => d.y),
- 1
- );
-
- if (isLoading) {
- return (
- <div className="h-64 flex items-center justify-center">
- <div className="text-sm text-muted-foreground">Loading usage data...</div>
- </div>
- );
- }
-
- if (error) {
- return (
- <div className="h-64 flex items-center justify-center">
- <div className="text-sm text-muted-foreground">Failed to load usage data</div>
- </div>
- );
- }
-
- const totalEvents = chartData.reduce((acc, curr) => acc + curr.data.reduce((acc, curr) => acc + curr.y, 0), 0);
-
return (
- <div className="h-64">
- <ResponsiveLine
- data={chartData}
- theme={nivoTheme}
- margin={{ top: 10, right: 10, bottom: 25, left: 40 }}
- xScale={{
- type: "time",
- format: "%Y-%m-%d",
- precision: "day",
- useUTC: true,
- }}
- yScale={{
- type: "linear",
- min: 0,
- stacked: false,
- reverse: false,
- max: maxValue,
- }}
- enableGridX={false}
- enableGridY={true}
- gridYValues={5}
- yFormat=" >-.0f"
- axisTop={null}
- axisRight={null}
- axisBottom={{
- tickSize: 0,
- tickPadding: 10,
- tickRotation: 0,
- truncateTickAt: 0,
- tickValues: Math.min(maxTicks, 10),
- format: value => {
- const dt = DateTime.fromJSDate(value).setLocale(userLocale);
- return dt.toFormat("MMM d");
- },
- }}
- axisLeft={{
- tickSize: 0,
- tickPadding: 10,
- tickRotation: 0,
- truncateTickAt: 0,
- tickValues: 5,
- format: formatter,
- }}
- enableTouchCrosshair={true}
- enablePoints={false}
- useMesh={true}
- animate={false}
- enableSlices={"x"}
- colors={["hsl(var(--blue-400))", "hsl(var(--indigo-400))", "hsl(var(--violet-400))"]}
- enableArea={false}
- sliceTooltip={({ slice }: any) => {
- const currentTime = slice.points[0].data.currentTime as DateTime;
-
- const total = slice.points.reduce((acc: number, point: any) => acc + Number(point.data.yFormatted), 0);
-
- return (
- <ChartTooltip>
- <div className="p-3 min-w-[100px]">
- <div className="font-medium mb-1">{currentTime.toLocaleString(DateTime.DATE_SHORT)}</div>
- {slice.points
- .sort((a: any, b: any) => a.seriesId.localeCompare(b.seriesId))
- .map((point: any) => {
- return (
- <div key={point.serieId} className="flex justify-between gap-4">
- <div className="flex items-center gap-2">
- <div className="w-2 h-2 rounded-full" style={{ backgroundColor: point.seriesColor }} />
- <span>{point.seriesId.charAt(0).toUpperCase() + point.seriesId.slice(1)}</span>
- </div>
- <div>{formatter(Number(point.data.yFormatted))}</div>
- </div>
- );
- })}
- <div className="mt-2 flex justify-between border-t border-neutral-100 dark:border-neutral-750 pt-2">
- <div>Total</div>
- <div className="font-semibold">{formatter(total)}</div>
- </div>
- </div>
- </ChartTooltip>
- );
- }}
- />
- </div>
+ <EventUsageChart
+ data={data?.data}
+ isLoading={isLoading}
+ error={error}
+ height="h-64"
+ />
);
}
diff --git a/client/src/components/EventUsageChart.tsx b/client/src/components/EventUsageChart.tsx
new file mode 100644
index 000000000..ac589eabe
--- /dev/null
+++ b/client/src/components/EventUsageChart.tsx
@@ -0,0 +1,284 @@
+"use client";
+
+import { EventCountRow } from "@/api/admin/endpoints/adminServiceEventCount";
+import { ChartTooltip } from "@/components/charts/ChartTooltip";
+import { userLocale } from "@/lib/dateTimeUtils";
+import { useNivoTheme } from "@/lib/nivo";
+import { formatter } from "@/lib/utils";
+import { ResponsiveLine } from "@nivo/line";
+import { useWindowSize } from "@uidotdev/usehooks";
+import { DateTime } from "luxon";
+import { useState } from "react";
+
+const CHART_COLORS = [
+ "#60a5fa", // blue-400 (pageviews)
+ "#fbbf24", // amber-400 (custom events)
+ "#a78bfa", // violet-400 (performance)
+ "#a3e635", // lime-400 (outbound)
+ "#f87171", // red-400 (error)
+ "#4ade80", // green-400 (button click)
+ "#38bdf8", // sky-400 (copy)
+ "#c084fc", // purple-400 (form submit)
+ "#f472b6", // pink-400 (input change)
+];
+
+export interface EventUsageChartProps {
+ data: EventCountRow[] | undefined;
+ isLoading: boolean;
+ error: unknown;
+ height?: string;
+ maxTickCount?: number;
+}
+
+export function EventUsageChart({
+ data,
+ isLoading,
+ error,
+ height = "h-48",
+ maxTickCount = 10,
+}: EventUsageChartProps) {
+ const { width } = useWindowSize();
+ const nivoTheme = useNivoTheme();
+ const [hiddenSeries, setHiddenSeries] = useState<Set<string>>(new Set());
+
+ const maxTicks = Math.round((width ?? Infinity) / 200);
+
+ const mapEventData = (key: keyof EventCountRow) =>
+ data
+ ?.map((e) => {
+ const timestamp = DateTime.fromSQL(e.event_date).toUTC();
+ if (timestamp > DateTime.now()) return null;
+ return {
+ x: timestamp.toFormat("yyyy-MM-dd"),
+ y: e[key] as number,
+ currentTime: timestamp,
+ };
+ })
+ .filter((e) => e !== null) || [];
+
+ const allSeries = [
+ { id: "pageviews", data: mapEventData("pageview_count") },
+ { id: "custom events", data: mapEventData("custom_event_count") },
+ { id: "performance", data: mapEventData("performance_count") },
+ { id: "outbound", data: mapEventData("outbound_count") },
+ { id: "error", data: mapEventData("error_count") },
+ { id: "button click", data: mapEventData("button_click_count") },
+ { id: "copy", data: mapEventData("copy_count") },
+ { id: "form submit", data: mapEventData("form_submit_count") },
+ { id: "input change", data: mapEventData("input_change_count") },
+ ];
+
+ const activeIndices = allSeries
+ .map((s, i) => (s.data.some((d) => d.y > 0) ? i : -1))
+ .filter((i) => i !== -1);
+
+ const activeSeries = activeIndices.map((i) => allSeries[i]);
+ const activeColors = activeIndices.map((i) => CHART_COLORS[i]);
+
+ const seriesTotals = activeSeries
+ .map((series, i) => ({
+ id: series.id,
+ total: series.data.reduce((acc, d) => acc + d.y, 0),
+ color: activeColors[i],
+ }))
+ .sort((a, b) => b.total - a.total);
+
+ const visibleSeries = activeSeries.filter((s) => !hiddenSeries.has(s.id));
+ const visibleColors = activeSeries
+ .map((s, i) => ({ color: activeColors[i], hidden: hiddenSeries.has(s.id) }))
+ .filter((c) => !c.hidden)
+ .map((c) => c.color);
+
+ const maxValue = Math.max(
+ ...visibleSeries.flatMap((series) => series.data.map((d) => d.y)),
+ 1
+ );
+
+ const totalEvents = seriesTotals.reduce((acc, s) => acc + s.total, 0);
+
+ const toggleSeries = (id: string) => {
+ setHiddenSeries((prev) => {
+ const next = new Set(prev);
+ if (next.has(id)) {
+ next.delete(id);
+ } else {
+ next.add(id);
+ }
+ return next;
+ });
+ };
+
+ return (
+ <div className="flex gap-6">
+ <div className={`${height} flex-1 min-w-0`}>
+ {isLoading ? (
+ <div className="h-full flex items-center justify-center">
+ <div className="text-sm text-muted-foreground">
+ Loading usage data...
+ </div>
+ </div>
+ ) : error ? (
+ <div className="h-full flex items-center justify-center">
+ <div className="text-sm text-muted-foreground">
+ Failed to load usage data
+ </div>
+ </div>
+ ) : visibleSeries.length === 0 ? (
+ <div className="h-full flex items-center justify-center">
+ <div className="text-sm text-muted-foreground">No data</div>
+ </div>
+ ) : (
+ <ResponsiveLine
+ data={visibleSeries}
+ theme={nivoTheme}
+ margin={{ top: 10, right: 10, bottom: 25, left: 40 }}
+ xScale={{
+ type: "time",
+ format: "%Y-%m-%d",
+ precision: "day",
+ useUTC: true,
+ }}
+ yScale={{
+ type: "linear",
+ min: 0,
+ stacked: false,
+ reverse: false,
+ max: maxValue,
+ }}
+ enableGridX={false}
+ enableGridY={true}
+ gridYValues={5}
+ yFormat=" >-.0f"
+ axisTop={null}
+ axisRight={null}
+ axisBottom={{
+ tickSize: 0,
+ tickPadding: 10,
+ tickRotation: 0,
+ truncateTickAt: 0,
+ tickValues: Math.min(maxTicks, maxTickCount),
+ format: (value) => {
+ const dt = DateTime.fromJSDate(value).setLocale(userLocale);
+ return dt.toFormat("MMM d");
+ },
+ }}
+ axisLeft={{
+ tickSize: 0,
+ tickPadding: 10,
+ tickRotation: 0,
+ truncateTickAt: 0,
+ tickValues: 5,
+ format: formatter,
+ }}
+ enableTouchCrosshair={true}
+ enablePoints={false}
+ useMesh={true}
+ animate={false}
+ enableSlices={"x"}
+ colors={visibleColors}
+ enableArea={false}
+ sliceTooltip={({ slice }: any) => {
+ const currentTime = slice.points[0].data
+ .currentTime as DateTime;
+ const total = slice.points.reduce(
+ (acc: number, point: any) =>
+ acc + Number(point.data.yFormatted),
+ 0
+ );
+
+ return (
+ <ChartTooltip>
+ <div className="p-3 min-w-[100px]">
+ <div className="font-medium mb-1">
+ {currentTime.toLocaleString(DateTime.DATE_MED)}
+ </div>
+ {slice.points
+ .sort(
+ (a: any, b: any) =>
+ Number(b.data.yFormatted) -
+ Number(a.data.yFormatted)
+ )
+ .map((point: any) => (
+ <div
+ key={point.serieId}
+ className="flex justify-between gap-4"
+ >
+ <div className="flex items-center gap-2">
+ <div
+ className="w-2 h-2 rounded-full"
+ style={{
+ backgroundColor: point.seriesColor,
+ }}
+ />
+ <span>
+ {point.seriesId.charAt(0).toUpperCase() +
+ point.seriesId.slice(1)}
+ </span>
+ </div>
+ <div>
+ {Number(
+ point.data.yFormatted
+ ).toLocaleString()}
+ </div>
+ </div>
+ ))}
+ <div className="mt-2 flex justify-between border-t border-neutral-100 dark:border-neutral-750 pt-2">
+ <div>Total</div>
+ <div className="font-semibold">
+ {total.toLocaleString()}
+ </div>
+ </div>
+ </div>
+ </ChartTooltip>
+ );
+ }}
+ />
+ )}
+ </div>
+ <div className="flex flex-col justify-center text-xs min-w-[140px] gap-1.5">
+ {seriesTotals.map((s) => {
+ const isHidden = hiddenSeries.has(s.id);
+ return (
+ <div
+ key={s.id}
+ className="flex items-center justify-between gap-3 cursor-pointer select-none"
+ onClick={() => toggleSeries(s.id)}
+ >
+ <div className="flex items-center gap-1.5">
+ <div
+ className="w-2 h-2 rounded-full shrink-0 transition-opacity"
+ style={{
+ backgroundColor: s.color,
+ opacity: isHidden ? 0.3 : 1,
+ }}
+ />
+ <span
+ className={`truncate transition-opacity ${
+ isHidden
+ ? "text-neutral-400 dark:text-neutral-600 line-through"
+ : "text-neutral-600 dark:text-neutral-400"
+ }`}
+ >
+ {s.id.charAt(0).toUpperCase() + s.id.slice(1)}
+ </span>
+ </div>
+ <span
+ className={`font-medium tabular-nums transition-opacity ${
+ isHidden ? "opacity-30" : ""
+ }`}
+ >
+ {s.total.toLocaleString()}
+ </span>
+ </div>
+ );
+ })}
+ <div className="flex items-center justify-between gap-3 border-t border-neutral-200 dark:border-neutral-700 pt-1.5 mt-0.5">
+ <span className="text-neutral-600 dark:text-neutral-400">Total</span>
+ <span className="font-semibold tabular-nums">
+ {totalEvents.toLocaleString()}
+ </span>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/client/src/components/UsageChart.tsx b/client/src/components/UsageChart.tsx
index 00cacd20e..4d0ca2337 100644
--- a/client/src/components/UsageChart.tsx
+++ b/client/src/components/UsageChart.tsx
@@ -1,28 +1,11 @@
"use client";
-import { useNivoTheme } from "@/lib/nivo";
-import { ResponsiveLine } from "@nivo/line";
-import { useWindowSize } from "@uidotdev/usehooks";
+
import { DateTime } from "luxon";
import { useState } from "react";
import { useGetOrgEventCount } from "../api/analytics/hooks/useGetOrgEventCount";
-import { userLocale } from "../lib/dateTimeUtils";
-import { formatter } from "../lib/utils";
import { Badge } from "./ui/badge";
-import { ChartTooltip } from "./charts/ChartTooltip";
import { Tabs, TabsList, TabsTrigger } from "./ui/tabs";
-
-// Colors matching EVENT_TYPE_CONFIG order: pageview, custom_event, performance, outbound, error, button_click, copy, form_submit, input_change
-const CHART_COLORS = [
- "#60a5fa", // blue-400 (pageviews)
- "#fbbf24", // amber-400 (custom events)
- "#a78bfa", // violet-400 (performance)
- "#a3e635", // lime-400 (outbound)
- "#f87171", // red-400 (error)
- "#4ade80", // green-400 (button click)
- "#38bdf8", // sky-400 (copy)
- "#c084fc", // purple-400 (form submit)
- "#f472b6", // pink-400 (input change)
-];
+import { EventUsageChart } from "./EventUsageChart";
const PERIODS = [
{ value: "7", label: "7D" },
@@ -49,13 +32,10 @@ interface UsageChartProps {
}
export function UsageChart({ organizationId, timeZone = "UTC" }: UsageChartProps) {
- const { width } = useWindowSize();
- const nivoTheme = useNivoTheme();
const [period, setPeriod] = useState<PeriodValue>("30");
const { startDate, endDate } = getPeriodDates(period);
- // Fetch the data inside the component
const { data, isLoading, error } = useGetOrgEventCount({
organizationId,
startDate,
@@ -63,53 +43,8 @@ export function UsageChart({ organizationId, timeZone = "UTC" }: UsageChartProps
timeZone,
});
- const maxTicks = Math.round((width ?? Infinity) / 200);
-
- const mapEventData = (key: keyof NonNullable<typeof data>["data"][number]) =>
- data?.data
- ?.map(e => {
- const timestamp = DateTime.fromSQL(e.event_date).toUTC();
- if (timestamp > DateTime.now()) return null;
- return {
- x: timestamp.toFormat("yyyy-MM-dd"),
- y: e[key] as number,
- currentTime: timestamp,
- };
- })
- .filter(e => e !== null) || [];
-
- const allSeries = [
- { id: "pageviews", data: mapEventData("pageview_count") },
- { id: "custom events", data: mapEventData("custom_event_count") },
- { id: "performance", data: mapEventData("performance_count") },
- { id: "outbound", data: mapEventData("outbound_count") },
- { id: "error", data: mapEventData("error_count") },
- { id: "button click", data: mapEventData("button_click_count") },
- { id: "copy", data: mapEventData("copy_count") },
- { id: "form submit", data: mapEventData("form_submit_count") },
- { id: "input change", data: mapEventData("input_change_count") },
- ];
-
- const activeIndices = allSeries
- .map((s, i) => (s.data.some(d => d.y > 0) ? i : -1))
- .filter(i => i !== -1);
- const chartData = activeIndices.map(i => allSeries[i]);
- const activeColors = activeIndices.map(i => CHART_COLORS[i]);
-
- const maxValue = Math.max(
- ...chartData.flatMap(series => series.data.map(d => d.y)),
- 1
- );
-
- const seriesTotals = chartData
- .map((series, i) => ({
- id: series.id,
- total: series.data.reduce((acc, d) => acc + d.y, 0),
- color: activeColors[i],
- }))
- .sort((a, b) => b.total - a.total);
-
- const totalEvents = seriesTotals.reduce((acc, s) => acc + s.total, 0);
+ const totalEvents =
+ data?.data?.reduce((acc, e) => acc + e.event_count, 0) ?? 0;
const periodLabel = period === "all" ? "All Time" : `Last ${period} Days`;
@@ -132,117 +67,12 @@ export function UsageChart({ organizationId, timeZone = "UTC" }: UsageChartProps
</TabsList>
</Tabs>
</div>
- <div className="flex gap-6">
- <div className="h-48 flex-1 min-w-0">
- {isLoading ? (
- <div className="h-full flex items-center justify-center">
- <div className="text-sm text-muted-foreground">Loading usage data...</div>
- </div>
- ) : error ? (
- <div className="h-full flex items-center justify-center">
- <div className="text-sm text-muted-foreground">Failed to load usage data</div>
- </div>
- ) : (
- <ResponsiveLine
- data={chartData}
- theme={nivoTheme}
- margin={{ top: 10, right: 10, bottom: 25, left: 35 }}
- xScale={{
- type: "time",
- format: "%Y-%m-%d",
- precision: "day",
- useUTC: true,
- }}
- yScale={{
- type: "linear",
- min: 0,
- stacked: false,
- reverse: false,
- max: maxValue,
- }}
- enableGridX={false}
- enableGridY={true}
- gridYValues={5}
- yFormat=" >-.0f"
- axisTop={null}
- axisRight={null}
- axisBottom={{
- tickSize: 0,
- tickPadding: 10,
- tickRotation: 0,
- truncateTickAt: 0,
- tickValues: Math.min(maxTicks, 6),
- format: value => {
- const dt = DateTime.fromJSDate(value).setLocale(userLocale);
- return dt.toFormat("MMM d");
- },
- }}
- axisLeft={{
- tickSize: 0,
- tickPadding: 10,
- tickRotation: 0,
- truncateTickAt: 0,
- tickValues: 5,
- format: formatter,
- }}
- enableTouchCrosshair={true}
- enablePoints={false}
- useMesh={true}
- animate={false}
- enableSlices={"x"}
- colors={activeColors}
- enableArea={false}
- sliceTooltip={({ slice }: any) => {
- const currentTime = slice.points[0].data.currentTime as DateTime;
-
- const total = slice.points.reduce((acc: number, point: any) => acc + Number(point.data.yFormatted), 0);
-
- return (
- <ChartTooltip>
- <div className="p-3 min-w-[100px]">
- <div className="font-medium mb-1">{currentTime.toLocaleString(DateTime.DATE_MED)}</div>
- {slice.points
- .sort((a: any, b: any) => Number(b.data.yFormatted) - Number(a.data.yFormatted))
- .map((point: any) => {
- return (
- <div key={point.serieId} className="flex justify-between gap-4">
- <div className="flex items-center gap-2">
- <div className="w-2 h-2 rounded-full" style={{ backgroundColor: point.seriesColor }} />
- <span>{point.seriesId.charAt(0).toUpperCase() + point.seriesId.slice(1)}</span>
- </div>
- <div>{Number(point.data.yFormatted).toLocaleString()}</div>
- </div>
- );
- })}
- <div className="mt-2 flex justify-between border-t border-neutral-100 dark:border-neutral-750 pt-2">
- <div>Total</div>
- <div className="font-semibold">{total.toLocaleString()}</div>
- </div>
- </div>
- </ChartTooltip>
- );
- }}
- />
- )}
- </div>
- <div className="flex flex-col justify-center text-xs min-w-[140px] gap-1.5">
- {seriesTotals.map(s => (
- <div key={s.id} className="flex items-center justify-between gap-3">
- <div className="flex items-center gap-1.5">
- <div className="w-2 h-2 rounded-full shrink-0" style={{ backgroundColor: s.color }} />
- <span className="text-neutral-600 dark:text-neutral-400 truncate">
- {s.id.charAt(0).toUpperCase() + s.id.slice(1)}
- </span>
- </div>
- <span className="font-medium tabular-nums">{s.total.toLocaleString()}</span>
- </div>
- ))}
- <div className="flex items-center justify-between gap-3 border-t border-neutral-200 dark:border-neutral-700 pt-1.5 mt-0.5">
- <span className="text-neutral-600 dark:text-neutral-400">Total</span>
- <span className="font-semibold tabular-nums">{totalEvents.toLocaleString()}</span>
- </div>
- </div>
- </div>
+ <EventUsageChart
+ data={data?.data}
+ isLoading={isLoading}
+ error={error}
+ maxTickCount={6}
+ />
</div>
);
}
diff --git a/server/src/api/admin/getAdminServiceEventCount.ts b/server/src/api/admin/getAdminServiceEventCount.ts
index e430440cb..6747e4f1f 100644
--- a/server/src/api/admin/getAdminServiceEventCount.ts
+++ b/server/src/api/admin/getAdminServiceEventCount.ts
@@ -8,6 +8,12 @@ type ServiceEventCountResponse = {
pageview_count: number;
custom_event_count: number;
performance_count: number;
+ outbound_count: number;
+ error_count: number;
+ button_click_count: number;
+ copy_count: number;
+ form_submit_count: number;
+ input_change_count: number;
event_count: number;
}[];
@@ -60,9 +66,15 @@ export async function getAdminServiceEventCount(
countIf(type = 'pageview') as pageview_count,
countIf(type = 'custom_event') as custom_event_count,
countIf(type = 'performance') as performance_count,
+ countIf(type = 'outbound') as outbound_count,
+ countIf(type = 'error') as error_count,
+ countIf(type = 'button_click') as button_click_count,
+ countIf(type = 'copy') as copy_count,
+ countIf(type = 'form_submit') as form_submit_count,
+ countIf(type = 'input_change') as input_change_count,
count() as event_count
FROM events
- WHERE type IN ('pageview', 'custom_event', 'performance')
+ WHERE type IN ('pageview', 'custom_event', 'performance', 'outbound', 'error', 'button_click', 'copy', 'form_submit', 'input_change')
${timeFilter.replace(/event_hour/g, "timestamp")}
GROUP BY event_date
ORDER BY event_date