Skip to content

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

Enhance Browser and OperatingSystem components with size prop support

Bill Yang17baf3402025
diff --git a/client/src/app/[site]/components/shared/icons/Browser.tsx b/client/src/app/[site]/components/shared/icons/Browser.tsx
index b8a456c7c..91360cc91 100644
--- a/client/src/app/[site]/components/shared/icons/Browser.tsx
+++ b/client/src/app/[site]/components/shared/icons/Browser.tsx
@@ -1,6 +1,7 @@
import { m } from "framer-motion";
import { Compass } from "lucide-react";
import Image from "next/image";
+import { cn } from "../../../../../lib/utils";
const BROWSER_TO_LOGO: Record<string, string> = {
Chrome: "Chrome.svg",
@@ -65,19 +66,24 @@ const BROWSER_TO_LOGO: Record<string, string> = {
Waterfox: "Waterfox.svg",
};
-export function Browser({ browser }: { browser: string }) {
+export function Browser({
+ browser,
+ size = 16,
+}: {
+ browser: string;
+ size?: number;
+}) {
return (
<>
{BROWSER_TO_LOGO[browser] ? (
<Image
src={`/browsers/${BROWSER_TO_LOGO[browser]}`}
alt={browser || "Other"}
- className="w-4 h-4"
- width={16}
- height={16}
+ width={size}
+ height={size}
/>
) : (
- <Compass width={16} />
+ <Compass width={size} height={size} />
)}
</>
);
diff --git a/client/src/app/[site]/components/shared/icons/OperatingSystem.tsx b/client/src/app/[site]/components/shared/icons/OperatingSystem.tsx
index 27a2c53d7..917b4bd6b 100644
--- a/client/src/app/[site]/components/shared/icons/OperatingSystem.tsx
+++ b/client/src/app/[site]/components/shared/icons/OperatingSystem.tsx
@@ -24,19 +24,24 @@ const OS_TO_LOGO: Record<string, string> = {
Xbox: "Xbox.svg",
};
-export function OperatingSystem({ os = "" }: { os?: string }) {
+export function OperatingSystem({
+ os = "",
+ size = 16,
+}: {
+ os?: string;
+ size?: number;
+}) {
return (
<>
{OS_TO_LOGO[os] ? (
<Image
src={`/operating-systems/${OS_TO_LOGO[os]}`}
alt={os || "Other"}
- className="w-4 h-4"
- width={16}
- height={16}
+ width={size}
+ height={size}
/>
) : (
- <Compass width={16} />
+ <Compass width={size} height={size} />
)}
</>
);
diff --git a/client/src/app/[site]/replay/components/player/ReplayPlayerTopbar.tsx b/client/src/app/[site]/replay/components/player/ReplayPlayerTopbar.tsx
index 7f3a90b2b..d98f50422 100644
--- a/client/src/app/[site]/replay/components/player/ReplayPlayerTopbar.tsx
+++ b/client/src/app/[site]/replay/components/player/ReplayPlayerTopbar.tsx
@@ -3,6 +3,12 @@ import Link from "next/link";
import { useParams } from "next/navigation";
import { useGetSessionReplayEvents } from "../../../../../api/analytics/sessionReplay/useGetSessionReplayEvents";
import { useReplayStore } from "../replayStore";
+import {
+ BrowserTooltipIcon,
+ CountryFlagTooltipIcon,
+ DeviceTypeTooltipIcon,
+ OperatingSystemTooltipIcon,
+} from "../../../../../components/TooltipIcons/TooltipIcons";
export function ReplayPlayerTobar() {
const params = useParams();
@@ -13,7 +19,7 @@ export function ReplayPlayerTobar() {
if (!data?.metadata) {
return (
- <div className="border border-neutral-800 bg-neutral-900 px-2 py-2 rounded-lg">
+ <div className="border border-neutral-800 bg-neutral-900 px-2 py-2 rounded-t-lg">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<div className="h-4 w-32 bg-neutral-700 rounded animate-pulse" />
@@ -34,20 +40,21 @@ export function ReplayPlayerTobar() {
const getDisplayPath = (url: string): string => {
try {
const urlObj = new URL(url);
- return urlObj.pathname + urlObj.search + urlObj.hash;
+ return urlObj.hostname + urlObj.pathname + urlObj.search + urlObj.hash;
} catch {
return url;
}
};
return (
- <div className="border border-neutral-800 bg-neutral-900 px-2 py-2 rounded-lg">
+ <div className="border border-neutral-800 bg-neutral-900 px-2 py-2 rounded-t-lg">
<div className="flex items-center justify-between">
{/* Left side: Page path with external link */}
<div className="flex items-center gap-1 min-w-0 flex-1">
<span className="text-xs text-neutral-300 truncate" title={pageUrl}>
- {pageUrl}
+ {getDisplayPath(pageUrl)}
</span>
+
{pageUrl && (
<Link
href={pageUrl}
@@ -63,6 +70,29 @@ export function ReplayPlayerTobar() {
{/* Right side: Screen dimensions */}
<div className="flex items-center gap-2 text-xs text-neutral-400 flex-shrink-0">
+ <CountryFlagTooltipIcon
+ country={metadata.country}
+ city={metadata.city}
+ region={metadata.region}
+ className="w-4 h-4"
+ />
+ <BrowserTooltipIcon
+ browser={metadata.browser}
+ browser_version={metadata.browser_version}
+ size={13}
+ />
+ <OperatingSystemTooltipIcon
+ operating_system={metadata.operating_system}
+ operating_system_version={metadata.operating_system_version}
+ size={13}
+ />
+ <DeviceTypeTooltipIcon
+ device_type={metadata.device_type}
+ screen_width={metadata.screen_width}
+ screen_height={metadata.screen_height}
+ size={16}
+ />
+
<span>{screenDimensions}</span>
</div>
</div>
diff --git a/client/src/components/TooltipIcons/TooltipIcons.tsx b/client/src/components/TooltipIcons/TooltipIcons.tsx
index 90e735523..3f6ad60a8 100644
--- a/client/src/components/TooltipIcons/TooltipIcons.tsx
+++ b/client/src/components/TooltipIcons/TooltipIcons.tsx
@@ -7,24 +7,32 @@ import { getCountryName } from "../../lib/utils";
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
// DeviceIcon component for displaying mobile/desktop icons
-function DeviceIcon({ deviceType }: { deviceType: string }) {
+function DeviceIcon({
+ deviceType,
+ size = 16,
+}: {
+ deviceType: string;
+ size?: number;
+}) {
const type = deviceType.toLowerCase();
if (type.includes("mobile") || type.includes("tablet")) {
- return <Smartphone className="w-4 h-4" />;
+ return <Smartphone width={size} height={size} />;
}
- return <Laptop className="w-4 h-4" />;
+ return <Laptop width={size} height={size} />;
}
export function CountryFlagTooltipIcon({
country,
city,
region,
+ className,
}: {
country: string;
city: string;
region: string;
+ className?: string;
}) {
const getFullLocation = <
T extends { country: string; city: string; region: string }
@@ -48,7 +56,7 @@ export function CountryFlagTooltipIcon({
<Tooltip>
<TooltipTrigger asChild>
<div className="flex items-center">
- <CountryFlag country={country} />
+ <CountryFlag country={country} className={className} />
</div>
</TooltipTrigger>
<TooltipContent>
@@ -61,15 +69,17 @@ export function CountryFlagTooltipIcon({
export function BrowserTooltipIcon({
browser,
browser_version,
+ size = 16,
}: {
browser: string;
browser_version?: string;
+ size?: number;
}) {
return (
<Tooltip>
<TooltipTrigger asChild>
<div className="flex-shrink-0">
- <Browser browser={browser || "Unknown"} />
+ <Browser browser={browser || "Unknown"} size={size} />
</div>
</TooltipTrigger>
<TooltipContent>
@@ -85,15 +95,17 @@ export function BrowserTooltipIcon({
export function OperatingSystemTooltipIcon({
operating_system,
operating_system_version,
+ size = 16,
}: {
operating_system: string;
operating_system_version?: string;
+ size?: number;
}) {
return (
<Tooltip>
<TooltipTrigger asChild>
<div className="flex-shrink-0">
- <OperatingSystem os={operating_system || ""} />
+ <OperatingSystem os={operating_system || ""} size={size} />
</div>
</TooltipTrigger>
<TooltipContent>
@@ -110,22 +122,26 @@ export function DeviceTypeTooltipIcon({
device_type,
screen_width,
screen_height,
+ size = 18,
}: {
device_type: string;
screen_width?: number;
screen_height?: number;
+ size?: number;
}) {
return (
<Tooltip>
<TooltipTrigger asChild>
<div>
- <DeviceIcon deviceType={device_type || ""} />
+ <DeviceIcon deviceType={device_type || ""} size={size} />
</div>
</TooltipTrigger>
<TooltipContent>
<p>
{device_type || "Unknown device"}
- {screen_width && screen_height && ` ${screen_width}x${screen_height}`}
+ {screen_width &&
+ screen_height &&
+ ` ${screen_width} x ${screen_height}`}
</p>
</TooltipContent>
</Tooltip>