Skip to content

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

Refactor event icons across components for improved consistency and clarity

Bill Yang18f7e2961fb7
diff --git a/client/src/app/[site]/events/components/EventLogItem.tsx b/client/src/app/[site]/events/components/EventLogItem.tsx
index 1d3a29050..2cc6cb8fe 100644
--- a/client/src/app/[site]/events/components/EventLogItem.tsx
+++ b/client/src/app/[site]/events/components/EventLogItem.tsx
@@ -12,6 +12,7 @@ import { getCountryName } from "../../../../lib/utils";
import { Browser } from "../../components/shared/icons/Browser";
import { CountryFlag } from "../../components/shared/icons/CountryFlag";
import { OperatingSystem } from "../../components/shared/icons/OperatingSystem";
+import { EventIcon, PageviewIcon } from "../../../../components/EventIcons";
// DeviceIcon component for displaying mobile/desktop icons
function DeviceIcon({ deviceType }: { deviceType: string }) {
@@ -71,11 +72,11 @@ export function EventLogItem({ event }: EventLogItemProps) {
{/* Event type icon */}
<div className="flex-shrink-0">
{isPageview ? (
- <Eye className="w-4 h-4 text-blue-500" />
+ <PageviewIcon />
) : isOutbound ? (
<ExternalLink className="w-4 h-4 text-purple-500" />
) : (
- <MousePointerClick className="w-4 h-4 text-amber-500" />
+ <EventIcon />
)}
</div>
diff --git a/client/src/app/[site]/funnels/components/Funnel.tsx b/client/src/app/[site]/funnels/components/Funnel.tsx
index 19c3e9ae5..1e0bbeae9 100644
--- a/client/src/app/[site]/funnels/components/Funnel.tsx
+++ b/client/src/app/[site]/funnels/components/Funnel.tsx
@@ -1,7 +1,8 @@
"use client";
import { round } from "lodash";
-import { FunnelResponse } from "../../../../api/analytics/funnels/useGetFunnel";
+import { FunnelResponse, FunnelStep } from "../../../../api/analytics/funnels/useGetFunnel";
+import { EventIcon, PageviewIcon } from "../../../../components/EventIcons";
export type FunnelChartData = {
stepName: string;
@@ -16,9 +17,10 @@ interface FunnelProps {
isError: boolean;
error: unknown;
isPending: boolean;
+ steps: FunnelStep[];
}
-export function Funnel({ data, isError, error, isPending }: FunnelProps) {
+export function Funnel({ data, steps, isError, error, isPending }: FunnelProps) {
// Prepare chart data
const chartData =
data?.map(step => ({
@@ -63,21 +65,29 @@ export function Funnel({ data, isError, error, isPending }: FunnelProps) {
<div className="flex-shrink-0 w-6 h-6 rounded-full bg-neutral-800 flex items-center justify-center text-xs mr-2">
{step.stepNumber}
</div>
- <div className="font-medium text-sm">{step.stepName}</div>
+ <div className="font-medium text-sm flex items-center gap-2">
+ {steps[index].type === "page" ? <PageviewIcon /> : <EventIcon />}
+ {step.stepName}
+ </div>
</div>
{/* Bar and metrics */}
<div className="flex items-center pl-8">
{/* Metrics */}
- <div className="flex-shrink-0 min-w-[130px] mr-4">
+ <div className="flex-shrink-0 min-w-[130px] mr-4 space-y-1">
<div className="flex items-baseline">
<span className="text-base font-semibold">{step.visitors.toLocaleString()}</span>
<span className="text-sm text-neutral-400 ml-1">users</span>
</div>
+ {index !== 0 && (
+ <div className="flex items-baseline text-orange-500 text-xs font-medium">
+ {droppedUsers.toLocaleString()} dropped
+ </div>
+ )}
</div>
{/* Bar */}
- <div className="flex-grow h-10 bg-neutral-800 rounded-md overflow-hidden relative">
+ <div className="flex-grow h-10 bg-neutral-800 rounded-md overflow-hidden relative mt-2">
{/* Relative conversion bar (from previous step) */}
{index > 0 && prevStep && (
<div
@@ -104,27 +114,6 @@ export function Funnel({ data, isError, error, isPending }: FunnelProps) {
</div>
</div>
</div>
-
- {/* Dropoff indicator */}
- {index < chartData.length - 1 && (
- <div className="absolute left-[11px] -bottom-6 top-6 flex flex-col items-center">
- <div className="h-full w-0.5 bg-neutral-800"></div>
- </div>
- )}
-
- {/* Dropoff metrics */}
- {index !== 0 && (
- <div className="pl-8 flex">
- <div className="min-w-[180px] mr-4">
- <div className="flex items-baseline text-orange-500">
- <span className="text-xs font-medium">{droppedUsers.toLocaleString()} dropped</span>
- {/* <span className="text-sm text-neutral-400 ml-1">
- ({dropoffPercent.toFixed(2)}%)
- </span> */}
- </div>
- </div>
- </div>
- )}
</div>
);
})}
diff --git a/client/src/app/[site]/funnels/components/FunnelForm.tsx b/client/src/app/[site]/funnels/components/FunnelForm.tsx
index 3bb3a9388..e5faab410 100644
--- a/client/src/app/[site]/funnels/components/FunnelForm.tsx
+++ b/client/src/app/[site]/funnels/components/FunnelForm.tsx
@@ -140,7 +140,7 @@ export function FunnelForm({
let funnelArea = null;
if (funnelData && funnelData.length) {
- funnelArea = <Funnel data={funnelData} isError={isError} error={error} isPending={isPending} />;
+ funnelArea = <Funnel data={funnelData} isError={isError} error={error} isPending={isPending} steps={steps} />;
}
if (steps.some(step => !step.value)) {
diff --git a/client/src/app/[site]/funnels/components/FunnelRow.tsx b/client/src/app/[site]/funnels/components/FunnelRow.tsx
index f7b17dda6..43dd44047 100644
--- a/client/src/app/[site]/funnels/components/FunnelRow.tsx
+++ b/client/src/app/[site]/funnels/components/FunnelRow.tsx
@@ -13,6 +13,7 @@ import { SavedFunnel } from "../../../../api/analytics/funnels/useGetFunnels";
import { ThreeDotLoader } from "../../../../components/Loaders";
import { EditFunnelDialog } from "./EditFunnel";
import { Funnel } from "./Funnel";
+import { EventIcon, PageviewIcon } from "../../../../components/EventIcons";
interface FunnelRowProps {
funnel: SavedFunnel;
@@ -77,9 +78,9 @@ export function FunnelRow({ funnel, index }: FunnelRowProps) {
<TooltipTrigger asChild>
<span className="rounded bg-neutral-100 dark:bg-neutral-800 px-1.5 py-0.5 whitespace-nowrap overflow-hidden text-ellipsis flex items-center cursor-default">
{step.type === "page" ? (
- <Eye className="h-3 w-3 mr-1 text-blue-400" />
+ <PageviewIcon className="h-3 w-3 mr-1" />
) : (
- <MousePointerClick className="h-3 w-3 mr-1 text-amber-400" />
+ <EventIcon className="h-3 w-3 mr-1" />
)}
<span className="max-w-[120px] overflow-hidden text-ellipsis inline-block">
{step.name || step.value}
@@ -156,7 +157,7 @@ export function FunnelRow({ funnel, index }: FunnelRowProps) {
Error loading funnel: {error instanceof Error ? error.message : "Unknown error"}
</div>
) : data && data.length > 0 ? (
- <Funnel data={data} isError={isError} error={error} isPending={isPending} />
+ <Funnel data={data} steps={funnel.steps} isError={isError} error={error} isPending={isPending} />
) : (
<div className="text-center p-6 text-neutral-500">No funnel data available</div>
)}
diff --git a/client/src/app/[site]/globe/components/GlobeSessions.tsx b/client/src/app/[site]/globe/components/GlobeSessions.tsx
index b96c59d34..1b59f85f4 100644
--- a/client/src/app/[site]/globe/components/GlobeSessions.tsx
+++ b/client/src/app/[site]/globe/components/GlobeSessions.tsx
@@ -1,4 +1,4 @@
-import { ArrowRight, ChevronDown, ChevronUp, ExternalLink, Eye, MousePointerClick } from "lucide-react";
+import { ArrowRight, ChevronDown, ChevronUp, ExternalLink } from "lucide-react";
import { DateTime } from "luxon";
import Link from "next/link";
import { useMemo, useState } from "react";
@@ -6,6 +6,7 @@ import { animals, colors, uniqueNamesGenerator } from "unique-names-generator";
import { useCurrentSite } from "../../../../api/admin/sites";
import { GetSessionsResponse, useGetSessionsInfinite } from "../../../../api/analytics/userSessions";
import { Channel } from "../../../../components/Channel";
+import { EventIcon, PageviewIcon } from "../../../../components/EventIcons";
import {
BrowserTooltipIcon,
CountryFlagTooltipIcon,
@@ -115,7 +116,7 @@ function SessionCard({ session }: { session: GetSessionsResponse[number] }) {
<Tooltip>
<TooltipTrigger asChild>
<Badge className="flex items-center gap-1 bg-neutral-800 text-gray-300">
- <Eye className="w-4 h-4 text-blue-500" />
+ <PageviewIcon />
<span>{formatter(session.pageviews)}</span>
</Badge>
</TooltipTrigger>
@@ -124,7 +125,7 @@ function SessionCard({ session }: { session: GetSessionsResponse[number] }) {
<Tooltip>
<TooltipTrigger asChild>
<Badge className="flex items-center gap-1 bg-neutral-800 text-gray-300">
- <MousePointerClick className="w-4 h-4 text-amber-500" />
+ <EventIcon />
<span>{formatter(session.events)}</span>
</Badge>
</TooltipTrigger>
diff --git a/client/src/app/[site]/goals/components/GoalCard.tsx b/client/src/app/[site]/goals/components/GoalCard.tsx
index d6b6bbf9d..65913a474 100644
--- a/client/src/app/[site]/goals/components/GoalCard.tsx
+++ b/client/src/app/[site]/goals/components/GoalCard.tsx
@@ -1,9 +1,10 @@
"use client";
-import { Edit, Eye, MousePointerClick, Trash2 } from "lucide-react";
+import { Edit, Trash2 } from "lucide-react";
import { useState } from "react";
import { useDeleteGoal } from "../../../../api/analytics/goals/useDeleteGoal";
import { Goal } from "../../../../api/analytics/goals/useGetGoals";
+import { EventIcon, PageviewIcon } from "../../../../components/EventIcons";
import {
AlertDialog,
AlertDialogAction,
@@ -46,7 +47,7 @@ export default function GoalCard({ goal, siteId }: GoalCardProps) {
{goal.goalType === "path" ? (
<Tooltip>
<TooltipTrigger asChild>
- <Eye className="w-4 h-4 text-blue-400" />
+ <PageviewIcon />
</TooltipTrigger>
<TooltipContent>
<p>Page Goal</p>
@@ -55,7 +56,7 @@ export default function GoalCard({ goal, siteId }: GoalCardProps) {
) : (
<Tooltip>
<TooltipTrigger asChild>
- <MousePointerClick className="w-4 h-4 text-amber-400" />
+ <EventIcon />
</TooltipTrigger>
<TooltipContent>
<p>Event Goal</p>
diff --git a/client/src/app/[site]/goals/components/GoalFormModal.tsx b/client/src/app/[site]/goals/components/GoalFormModal.tsx
index e2a91d4d7..42528fb72 100644
--- a/client/src/app/[site]/goals/components/GoalFormModal.tsx
+++ b/client/src/app/[site]/goals/components/GoalFormModal.tsx
@@ -1,7 +1,6 @@
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
-import { Eye, MousePointerClick } from "lucide-react";
import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import * as z from "zod";
@@ -9,6 +8,7 @@ import { useCreateGoal } from "../../../../api/analytics/goals/useCreateGoal";
import { Goal } from "../../../../api/analytics/goals/useGetGoals";
import { useUpdateGoal } from "../../../../api/analytics/goals/useUpdateGoal";
import { useSingleCol } from "../../../../api/analytics/useSingleCol";
+import { EventIcon, PageviewIcon } from "../../../../components/EventIcons";
import { Button } from "../../../../components/ui/button";
import {
Dialog,
@@ -229,12 +229,12 @@ export default function GoalFormModal({ siteId, goal, trigger }: GoalFormModalPr
<div className="flex items-center gap-2 mt-1">
{field.value === "path" ? (
<div className="flex items-center gap-1 bg-neutral-800/50 py-2 px-3 rounded">
- <Eye className="w-4 h-4 text-blue-500" />
+ <PageviewIcon />
<span>Page Goal</span>
</div>
) : (
<div className="flex items-center gap-1 bg-neutral-800/50 py-2 px-3 rounded">
- <MousePointerClick className="w-4 h-4 text-amber-500" />
+ <EventIcon />
<span>Event Goal</span>
</div>
)}
@@ -251,7 +251,7 @@ export default function GoalFormModal({ siteId, goal, trigger }: GoalFormModalPr
)}
onClick={() => field.onChange("path")}
>
- <Eye className="w-4 h-4 text-blue-500" />
+ <PageviewIcon />
<span>Page Goal</span>
</Button>
<Button
@@ -263,7 +263,7 @@ export default function GoalFormModal({ siteId, goal, trigger }: GoalFormModalPr
)}
onClick={() => field.onChange("event")}
>
- <MousePointerClick className="w-4 h-4 text-amber-500" />
+ <EventIcon />
<span>Event Goal</span>
</Button>
</div>
diff --git a/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx b/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx
index 3243cd19a..327ebeb87 100644
--- a/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx
+++ b/client/src/app/[site]/realtime/RealtimeEvents/RealtimeEvents.tsx
@@ -1,8 +1,9 @@
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
-import { Eye, Laptop, MousePointerClick, Smartphone } from "lucide-react";
+import { Laptop, Smartphone } from "lucide-react";
import { DateTime } from "luxon";
import Link from "next/link";
import { Event, useGetEvents } from "../../../../api/analytics/events/useGetEvents";
+import { EventIcon, PageviewIcon } from "../../../../components/EventIcons";
import { Skeleton } from "../../../../components/ui/skeleton";
import { cn, getCountryName } from "../../../../lib/utils";
import { Browser } from "../../components/shared/icons/Browser";
@@ -44,13 +45,7 @@ function EventCard({ event }: { event: Event }) {
<Link href={`user/${event.user_id}`} target="_blank" rel="noopener noreferrer">
<div className="mb-3 rounded-lg bg-neutral-850/50 border border-neutral-800 overflow-hidden p-3 flex flex-col filter backdrop-blur-sm hover:bg-neutral-800/70 transition-all duration-200">
<div className="flex items-center gap-2 text-sm text-neutral-100 mb-2">
- <div className="flex items-center gap-2">
- {isPageview ? (
- <Eye className="w-4 h-4 text-blue-500" />
- ) : (
- <MousePointerClick className="w-4 h-4 text-amber-500" />
- )}
- </div>
+ <div className="flex items-center gap-2">{isPageview ? <PageviewIcon /> : <EventIcon />}</div>
{event.type === "pageview" ? (
<div>
diff --git a/client/src/app/[site]/user/[userId]/page.tsx b/client/src/app/[site]/user/[userId]/page.tsx
index ad2c12b23..229a2bbe3 100644
--- a/client/src/app/[site]/user/[userId]/page.tsx
+++ b/client/src/app/[site]/user/[userId]/page.tsx
@@ -30,6 +30,7 @@ import { CountryFlag } from "../../components/shared/icons/CountryFlag";
import { OperatingSystem } from "../../components/shared/icons/OperatingSystem";
import { MobileSidebar } from "../../components/Sidebar/MobileSidebar";
import { VisitCalendar } from "./components/Calendar";
+import { EventIcon, PageviewIcon } from "../../../../components/EventIcons";
export default function UserPage() {
useSetPageTitle("Rybbit · User");
@@ -177,14 +178,14 @@ export default function UserPage() {
</div>
<div className="bg-neutral-900 p-3 rounded-lg flex flex-col gap-1 border border-neutral-800 flex-grow">
<div className="text-xs text-neutral-400 flex items-center gap-1">
- <Eye className="w-4 h-4" />
+ <PageviewIcon />
Pageviews
</div>
<div className="font-semibold">{data?.pageviews}</div>
</div>
<div className="bg-neutral-900 p-3 rounded-lg flex flex-col gap-1 border border-neutral-800 flex-grow">
<div className="text-xs text-neutral-400 flex items-center gap-1">
- <MousePointerClick className="w-4 h-4" />
+ <EventIcon />
Events
</div>
<div className="font-semibold">{data?.events}</div>
diff --git a/client/src/components/EventIcons.tsx b/client/src/components/EventIcons.tsx
new file mode 100644
index 000000000..5d0988acd
--- /dev/null
+++ b/client/src/components/EventIcons.tsx
@@ -0,0 +1,10 @@
+import { Eye, MousePointerClick } from "lucide-react";
+import { cn } from "../lib/utils";
+
+export function PageviewIcon({ className }: { className?: string }) {
+ return <Eye className={cn("h-4 w-4 text-blue-400", className)} />;
+}
+
+export function EventIcon({ className }: { className?: string }) {
+ return <MousePointerClick className={cn("h-4 w-4 text-amber-400", className)} />;
+}
diff --git a/client/src/components/Sessions/SessionCard.tsx b/client/src/components/Sessions/SessionCard.tsx
index 6d7294aad..36b80814e 100644
--- a/client/src/components/Sessions/SessionCard.tsx
+++ b/client/src/components/Sessions/SessionCard.tsx
@@ -1,6 +1,6 @@
import { Skeleton } from "@/components/ui/skeleton";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
-import { ArrowRight, ChevronDown, ChevronRight, Eye, MousePointerClick } from "lucide-react";
+import { ArrowRight, ChevronDown, ChevronRight } from "lucide-react";
import { DateTime } from "luxon";
import { memo, useState } from "react";
import { GetSessionsResponse } from "../../api/analytics/userSessions";
@@ -8,6 +8,7 @@ import { formatDuration, hour12, userLocale } from "../../lib/dateTimeUtils";
import { cn, formatter } from "../../lib/utils";
import { Avatar } from "../Avatar";
import { Channel } from "../Channel";
+import { EventIcon, PageviewIcon } from "../EventIcons";
import {
BrowserTooltipIcon,
CountryFlagTooltipIcon,
@@ -76,7 +77,7 @@ export function SessionCard({ session, onClick, userId }: SessionCardProps) {
<Tooltip>
<TooltipTrigger asChild>
<Badge className="flex items-center gap-1 bg-neutral-800 text-gray-300">
- <Eye className="w-4 h-4 text-blue-500" />
+ <PageviewIcon />
<span>{formatter(session.pageviews)}</span>
</Badge>
</TooltipTrigger>
@@ -85,7 +86,7 @@ export function SessionCard({ session, onClick, userId }: SessionCardProps) {
<Tooltip>
<TooltipTrigger asChild>
<Badge className="flex items-center gap-1 bg-neutral-800 text-gray-300">
- <MousePointerClick className="w-4 h-4 text-amber-500" />
+ <EventIcon />
<span>{formatter(session.events)}</span>
</Badge>
</TooltipTrigger>
diff --git a/client/src/components/Sessions/SessionDetails.tsx b/client/src/components/Sessions/SessionDetails.tsx
index cee376bf3..dbaefa2d9 100644
--- a/client/src/components/Sessions/SessionDetails.tsx
+++ b/client/src/components/Sessions/SessionDetails.tsx
@@ -4,18 +4,7 @@ import { Badge } from "@/components/ui/badge";
import { Skeleton } from "@/components/ui/skeleton";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
-import {
- ArrowRight,
- Clock,
- ExternalLink,
- Eye,
- Loader2,
- Monitor,
- MousePointerClick,
- Smartphone,
- Tablet,
- TriangleAlert,
-} from "lucide-react";
+import { ArrowRight, Clock, ExternalLink, Loader2, Monitor, Smartphone, Tablet, TriangleAlert } from "lucide-react";
import { DateTime } from "luxon";
import Link from "next/link";
import { useParams } from "next/navigation";
@@ -28,6 +17,7 @@ import { formatDuration, hour12 } from "../../lib/dateTimeUtils";
import { useGetRegionName } from "../../lib/geo";
import { cn, getCountryName, getLanguageName } from "../../lib/utils";
import { Avatar } from "../Avatar";
+import { EventIcon, PageviewIcon } from "../EventIcons";
import { Button } from "../ui/button";
// Component to display a single pageview or event
@@ -90,13 +80,13 @@ function PageviewItem({
<div className="flex items-center flex-1 py-1">
<div className="flex-shrink-0 mr-3">
{isEvent ? (
- <MousePointerClick className="w-4 h-4 text-amber-500" />
+ <EventIcon />
) : isError ? (
<TriangleAlert className="w-4 h-4 text-red-500" />
) : isOutbound ? (
<ExternalLink className="w-4 h-4 text-purple-500" />
) : (
- <Eye className="w-4 h-4 text-blue-500" />
+ <PageviewIcon />
)}
</div>