Skip to content

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

Refactor Channel component and update Referrers and Users pages to utilize ChannelIcon for improved visual representation

Bill Yangab6177a90762
diff --git a/client/src/app/[site]/main/components/sections/Referrers.tsx b/client/src/app/[site]/main/components/sections/Referrers.tsx
index 729c4b1b4..efc17a67d 100644
--- a/client/src/app/[site]/main/components/sections/Referrers.tsx
+++ b/client/src/app/[site]/main/components/sections/Referrers.tsx
@@ -1,11 +1,12 @@
"use client";
+import { Expand } from "lucide-react";
import { useState } from "react";
+import { ChannelIcon } from "../../../../../components/Channel";
+import { Favicon } from "../../../../../components/Favicon";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../../../../components/ui/basic-tabs";
+import { Button } from "../../../../../components/ui/button";
import { Card, CardContent } from "../../../../../components/ui/card";
import { StandardSection } from "../../../components/shared/StandardSection/StandardSection";
-import { Button } from "../../../../../components/ui/button";
-import { Expand } from "lucide-react";
-import { Favicon } from "../../../../../components/Favicon";
type Tab = "referrers" | "channels" | "utm_source" | "utm_medium" | "utm_campaign" | "utm_term" | "utm_content";
@@ -62,7 +63,11 @@ export function Referrers() {
getValue={e => e.value}
getKey={e => e.value}
// getLink={(e) => `https://${e.value}`}
- getLabel={e => <div className="flex items-center">{e.value}</div>}
+ getLabel={e => (
+ <div className="flex items-center gap-2">
+ <ChannelIcon channel={e.value} /> {e.value}
+ </div>
+ )}
expanded={expanded}
close={close}
/>
diff --git a/client/src/app/[site]/users/page.tsx b/client/src/app/[site]/users/page.tsx
index 8e57737a4..65c96f64e 100644
--- a/client/src/app/[site]/users/page.tsx
+++ b/client/src/app/[site]/users/page.tsx
@@ -14,10 +14,10 @@ import { DateTime } from "luxon";
import Link from "next/link";
import { useParams } from "next/navigation";
import { useState } from "react";
-import { useGetUsers } from "../../../api/analytics/hooks/useGetUsers";
import { UsersResponse } from "../../../api/analytics/endpoints";
+import { useGetUsers } from "../../../api/analytics/hooks/useGetUsers";
import { Avatar } from "../../../components/Avatar";
-import { extractDomain, getChannelIcon, getDisplayName } from "../../../components/Channel";
+import { ChannelIcon, extractDomain, getDisplayName } from "../../../components/Channel";
import { DisabledOverlay } from "../../../components/DisabledOverlay";
import { ErrorState } from "../../../components/ErrorState";
import { Favicon } from "../../../components/Favicon";
@@ -162,7 +162,7 @@ export default function UsersPage() {
return (
<div className="flex items-center gap-2">
- {getChannelIcon(channel)}
+ <ChannelIcon channel={channel} />
<span>{channel}</span>
</div>
);
diff --git a/client/src/components/Channel.tsx b/client/src/components/Channel.tsx
index 12b6d4326..bf0858a04 100644
--- a/client/src/components/Channel.tsx
+++ b/client/src/components/Channel.tsx
@@ -1,59 +1,60 @@
import {
- Link,
- Search,
+ Calendar,
+ DollarSign,
ExternalLink,
- Users,
- Mail,
+ FileQuestion,
+ FileText,
+ Handshake,
+ Headphones,
HelpCircle,
- MousePointerClick,
- DollarSign,
+ Link,
+ Mail,
Monitor,
- Video,
- Handshake,
- FileText,
+ Search,
ShoppingCart,
- Calendar,
- Headphones,
+ Users,
+ Video,
} from "lucide-react";
-import { Badge } from "./ui/badge";
+import { cn } from "../lib/utils";
import { Favicon } from "./Favicon";
+import { Badge } from "./ui/badge";
-export const getChannelIcon = (channel: string) => {
+export const ChannelIcon = ({ channel, className }: { channel: string; className?: string }) => {
switch (channel) {
case "Direct":
- return <Link className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <Link className={cn("w-4 h-4", className)} />;
case "Organic Search":
- return <Search className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <Search className={cn("w-4 h-4", className)} />;
case "Referral":
- return <ExternalLink className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <ExternalLink className={cn("w-4 h-4", className)} />;
case "Organic Social":
- return <Users className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <Users className={cn("w-4 h-4", className)} />;
case "Email":
- return <Mail className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <Mail className={cn("w-4 h-4", className)} />;
case "Unknown":
- return <HelpCircle className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <HelpCircle className={cn("w-4 h-4", className)} />;
case "Paid Search":
- return <Search className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <Search className={cn("w-4 h-4", className)} />;
case "Paid Unknown":
- return <DollarSign className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <DollarSign className={cn("w-4 h-4", className)} />;
case "Paid Social":
- return <Users className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <Users className={cn("w-4 h-4", className)} />;
case "Display":
- return <Monitor className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <Monitor className={cn("w-4 h-4", className)} />;
case "Organic Video":
- return <Video className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <Video className={cn("w-4 h-4", className)} />;
case "Affiliate":
- return <Handshake className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <Handshake className={cn("w-4 h-4", className)} />;
case "Content":
- return <FileText className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <FileText className={cn("w-4 h-4", className)} />;
case "Organic Shopping":
- return <ShoppingCart className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <ShoppingCart className={cn("w-4 h-4", className)} />;
case "Event":
- return <Calendar className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <Calendar className={cn("w-4 h-4", className)} />;
case "Audio":
- return <Headphones className="w-4 h-4 text-neutral-500 dark:text-neutral-400" />;
+ return <Headphones className={cn("w-4 h-4", className)} />;
default:
- return null;
+ return <FileQuestion className={cn("w-4 h-4", className)} />;
}
};
@@ -148,7 +149,7 @@ export function Channel({ channel, referrer }: { channel: string; referrer: stri
return (
<Badge className="flex items-center gap-1 bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-300">
- {getChannelIcon(channel)}
+ <ChannelIcon channel={channel} />
<span>{channel}</span>
</Badge>
);