Skip to content

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

Refactor ErrorDetails, ErrorListItem, and ErrorListSkeleton components for improved styling and functionality

Bill Yangdfbf00221206
diff --git a/client/src/app/[site]/errors/components/ErrorDetails.tsx b/client/src/app/[site]/errors/components/ErrorDetails.tsx
index f3c1fe75a..044236ecf 100644
--- a/client/src/app/[site]/errors/components/ErrorDetails.tsx
+++ b/client/src/app/[site]/errors/components/ErrorDetails.tsx
@@ -9,7 +9,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip
import { userLocale } from "@/lib/dateTimeUtils";
import { useGetRegionName } from "@/lib/geo";
import { getTimezone } from "@/lib/store";
-import { getCountryName, truncateString } from "@/lib/utils";
+import { getCountryName, getUserDisplayName, truncateString } from "@/lib/utils";
import { AlertTriangle, Code, Hash, Laptop, Loader2, Smartphone, TriangleAlert, User } from "lucide-react";
import { DateTime } from "luxon";
import Link from "next/link";
@@ -19,6 +19,7 @@ import { ErrorState } from "../../../../components/ErrorState";
import { Browser } from "../../components/shared/icons/Browser";
import { CountryFlag } from "../../components/shared/icons/CountryFlag";
import { OperatingSystem } from "../../components/shared/icons/OperatingSystem";
+import { Avatar } from "../../../../components/Avatar";
interface ErrorDetailsProps {
errorMessage: string;
@@ -54,17 +55,13 @@ function ErrorEventItem({ errorEvent }: { errorEvent: ErrorEvent }) {
return location || "Unknown location";
};
- const formatTimestamp = (timestamp: string) => {
- return DateTime.fromSQL(timestamp, { zone: getTimezone() }).setLocale(userLocale).toRelative();
- };
-
return (
- <div className="border border-neutral-100 dark:border-neutral-800 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50">
+ <div className="border border-neutral-100 dark:border-neutral-850 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50">
{/* Header with timestamp and basic info */}
<div className="flex items-center justify-between mb-3">
<div className="flex items-center gap-4">
<span className="text-sm text-neutral-700 dark:text-neutral-200">
- {formatTimestamp(errorEvent.timestamp)}
+ { DateTime.fromSQL(errorEvent.timestamp, { zone: "utc" }).setZone(getTimezone()).toRelative()}
</span>
<div className="flex items-center gap-2">
{errorEvent.country && (
@@ -124,26 +121,16 @@ function ErrorEventItem({ errorEvent }: { errorEvent: ErrorEvent }) {
</Link>
</div>
<div className="flex items-center gap-2">
- {/* Session ID */}
- <Tooltip>
- <TooltipTrigger asChild>
- <Badge variant="outline" className="text-xs">
- <Hash className="w-3 h-3 mr-1" />
- {errorEvent.session_id.substring(0, 8)}
- </Badge>
- </TooltipTrigger>
- <TooltipContent>Session ID: {errorEvent.session_id}</TooltipContent>
- </Tooltip>
+
- {/* User ID if available */}
{errorEvent.user_id && (
<Tooltip>
<TooltipTrigger asChild>
<Link href={`/${site}/user/${encodeURIComponent(errorEvent.user_id)}`}>
- <Badge variant="outline" className="text-xs">
- <User className="w-3 h-3 mr-1" />
- {errorEvent.user_id.substring(0, 12)}
- </Badge>
+ <Avatar
+ size={24}
+ id={errorEvent.user_id}
+ />
</Link>
</TooltipTrigger>
<TooltipContent>User ID: {errorEvent.user_id}</TooltipContent>
@@ -167,7 +154,7 @@ function ErrorEventItem({ errorEvent }: { errorEvent: ErrorEvent }) {
{/* Stack trace if available */}
{errorEvent.stack && (
- <div className="mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700">
+ <div className="mt-3 pt-3 border-t border-neutral-100 dark:border-neutral-850">
<div className="flex items-start gap-2">
<Code className="w-4 h-4 text-neutral-900 dark:text-neutral-100 mt-0.5 shrink-0" />
<div className="flex-1 min-w-0">
@@ -226,12 +213,12 @@ export function ErrorDetails({ errorMessage }: ErrorDetailsProps) {
if (isLoading) {
return (
- <div className="p-4 bg-white dark:bg-neutral-900 border-t border-neutral-100 dark:border-neutral-800">
+ <div className="p-4 bg-white dark:bg-neutral-900 border-t border-neutral-100 dark:border-neutral-850">
<div className="space-y-3">
{Array.from({ length: 3 }).map((_, index) => (
<div
key={index}
- className="border border-neutral-100 dark:border-neutral-800 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50"
+ className="border border-neutral-100 dark:border-neutral-850 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50"
>
{/* Header with timestamp and icons */}
<div className="flex items-center justify-between mb-3">
@@ -246,7 +233,6 @@ export function ErrorDetails({ errorMessage }: ErrorDetailsProps) {
<Skeleton className="h-4 w-48" /> {/* URL */}
</div>
<div className="flex items-center gap-2">
- <Skeleton className="h-5 w-16 rounded-full" /> {/* Session badge */}
<Skeleton className="h-5 w-16 rounded-full" /> {/* User badge */}
</div>
</div>
@@ -265,7 +251,7 @@ export function ErrorDetails({ errorMessage }: ErrorDetailsProps) {
{/* Stack trace section (randomly show/hide) */}
{Math.random() > 0.5 && (
- <div className="mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700">
+ <div className="mt-3 pt-3 border-t border-neutral-100 dark:border-neutral-850">
<div className="flex items-start gap-2">
<Skeleton className="h-4 w-4 mt-0.5" /> {/* Code icon */}
<div className="flex-1 min-w-0">
@@ -294,7 +280,7 @@ export function ErrorDetails({ errorMessage }: ErrorDetailsProps) {
if (!allErrorEvents || allErrorEvents.length === 0) {
return (
- <div className="p-4 bg-white dark:bg-neutral-900 border-t border-neutral-100 dark:border-neutral-800">
+ <div className="p-4 bg-white dark:bg-neutral-900 border-t border-neutral-100 dark:border-neutral-850">
<div className="text-center text-neutral-500 dark:text-neutral-400">
<AlertTriangle className="w-6 h-6 mx-auto mb-2" />
<p>No error events found</p>
@@ -305,7 +291,7 @@ export function ErrorDetails({ errorMessage }: ErrorDetailsProps) {
}
return (
- <div className="p-4 bg-white dark:bg-neutral-900 border-t border-neutral-100 dark:border-neutral-800 space-y-3 max-h-[70vh] overflow-y-auto">
+ <div className="p-4 bg-white dark:bg-neutral-900 border-t border-neutral-100 dark:border-neutral-850 space-y-3 max-h-[70vh] overflow-y-auto">
{allErrorEvents.map((errorEvent, index) => (
<ErrorEventItem key={`${errorEvent.session_id}-${errorEvent.timestamp}-${index}`} errorEvent={errorEvent} />
))}
diff --git a/client/src/app/[site]/errors/components/ErrorListItem.tsx b/client/src/app/[site]/errors/components/ErrorListItem.tsx
index c2685629f..8791ff9c2 100644
--- a/client/src/app/[site]/errors/components/ErrorListItem.tsx
+++ b/client/src/app/[site]/errors/components/ErrorListItem.tsx
@@ -30,7 +30,7 @@ export function ErrorListItem({ errorData }: ErrorListItemProps) {
return (
<div
- className="mb-3 rounded-lg bg-white dark:bg-neutral-900 border border-neutral-100 dark:border-neutral-800"
+ className="mb-3 rounded-lg bg-white dark:bg-neutral-900 border border-neutral-100 dark:border-neutral-850"
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
>
diff --git a/client/src/app/[site]/errors/components/ErrorListSkeleton.tsx b/client/src/app/[site]/errors/components/ErrorListSkeleton.tsx
index b34e95d32..02bc3835f 100644
--- a/client/src/app/[site]/errors/components/ErrorListSkeleton.tsx
+++ b/client/src/app/[site]/errors/components/ErrorListSkeleton.tsx
@@ -10,7 +10,7 @@ export function ErrorListSkeleton({ count = 5 }: ErrorListSkeletonProps) {
return (
<>
{Array.from({ length: count }).map((_, index) => (
- <div key={index} className="mb-3 rounded-lg bg-white dark:bg-neutral-900 border border-neutral-100 dark:border-neutral-800">
+ <div key={index} className="mb-3 rounded-lg bg-white dark:bg-neutral-900 border border-neutral-100 dark:border-neutral-850">
<div className="p-3">
<div className="flex flex-col md:flex-row justify-between items-start md:items-center w-full gap-4">
{/* Left side: Error name and message */}