📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Update errors UI
Blue Mouse3896810b3b54
diff --git a/web/app/pages/Project/Errors/View/ErrorsView.tsx b/web/app/pages/Project/Errors/View/ErrorsView.tsxindex 83d204afd..e1d17aebb 100644--- a/web/app/pages/Project/Errors/View/ErrorsView.tsx+++ b/web/app/pages/Project/Errors/View/ErrorsView.tsx@@ -774,7 +774,7 @@ const ErrorsView = () => {disabled={errorStatusUpdating}onClick={markErrorAsResolved}className={cx(- 'rounded-md bg-gray-100 px-3 py-1.5 text-sm font-medium text-gray-700 hover:bg-gray-200 dark:bg-slate-700 dark:text-gray-50 dark:hover:bg-slate-600',+ 'group relative rounded-md border border-transparent bg-transparent px-3 py-1.5 text-sm font-medium text-gray-700 transition-all hover:border-gray-300 hover:bg-white focus:z-10 focus:ring-1 focus:ring-indigo-500 focus:outline-hidden dark:text-gray-50 hover:dark:border-slate-700/80 dark:hover:bg-slate-800 focus:dark:ring-gray-200',{'cursor-not-allowed opacity-50': errorLoading && !errorStatusUpdating,'animate-pulse cursor-not-allowed': errorStatusUpdating,@@ -789,7 +789,7 @@ const ErrorsView = () => {disabled={errorStatusUpdating}onClick={markErrorAsActive}className={cx(- 'rounded-md bg-gray-100 px-3 py-1.5 text-sm font-medium text-gray-700 hover:bg-gray-200 dark:bg-slate-700 dark:text-gray-50 dark:hover:bg-slate-600',+ 'group relative rounded-md border border-transparent bg-transparent px-3 py-1.5 text-sm font-medium text-gray-700 transition-all hover:border-gray-300 hover:bg-white focus:z-10 focus:ring-1 focus:ring-indigo-500 focus:outline-hidden dark:text-gray-50 hover:dark:border-slate-700/80 dark:hover:bg-slate-800 focus:dark:ring-gray-200',{'cursor-not-allowed opacity-50': errorLoading && !errorStatusUpdating,'animate-pulse cursor-not-allowed': errorStatusUpdating,diff --git a/web/app/pages/Project/View/components/ErrorDetails.tsx b/web/app/pages/Project/View/components/ErrorDetails.tsxindex e7b33d7b2..0511f8958 100644--- a/web/app/pages/Project/View/components/ErrorDetails.tsx+++ b/web/app/pages/Project/View/components/ErrorDetails.tsx@@ -12,13 +12,12 @@ import { useCurrentProject } from '~/providers/CurrentProjectProvider'import { useTheme } from '~/providers/ThemeProvider'import { Badge } from '~/ui/Badge'import Button from '~/ui/Button'+import Flag from '~/ui/Flag'import Loader from '~/ui/Loader'import { Text } from '~/ui/Text'import Tooltip from '~/ui/Tooltip'import { getRelativeDateIfPossible } from '~/utils/date'-import CCRow from './CCRow'-interface ErrorDetailsProps {details: SwetrixErrorDetailsperiod?: string@@ -28,6 +27,14 @@ interface ErrorDetailsProps {projectPassword?: string}+// Info Row (matches UserDetails / SessionDetailView style)+const InfoRow = ({ label, value }: { label: React.ReactNode; value: React.ReactNode }) => (+ <div className='flex items-center justify-between gap-3 border-b border-gray-100 py-2 last:border-0 dark:border-slate-700/50'>+ <span className='shrink-0 text-sm text-gray-600 dark:text-gray-400'>{label}</span>+ <span className='min-w-0 truncate text-right text-sm font-medium text-gray-900 dark:text-white'>{value}</span>+ </div>+)+// Stat Item Componentconst StatItem = ({ icon, label, value }: { icon: React.ReactNode; label: string; value: string | number }) => (<div>@@ -93,16 +100,17 @@ const SessionRow = ({ session }: SessionRowProps) => {className='flex items-center justify-between gap-3 rounded-lg border border-gray-100 bg-gray-50 p-3 transition-colors hover:border-gray-200 hover:bg-gray-100 dark:border-slate-700/50 dark:bg-slate-800/50 dark:hover:border-slate-600 dark:hover:bg-slate-700/50'><div className='flex min-w-0 items-center gap-3'>- <div className='flex items-center gap-1.5'>- {session.cc ? <CCRow size={16} cc={session.cc} language={language} /> : null}+ <div className='flex items-center gap-2'>+ {session.cc ? <Flag className='rounded-xs' country={session.cc} size={16} alt='' aria-hidden='true' /> : null}<BrowserIcon browser={session.br} /><OSIcon os={session.os} theme={theme} /></div>- <div className='min-w-0'>- <Text size='sm' weight='medium' truncate>+ <div className='min-w-0 gap-1'>+ <Text size='xs' weight='medium' truncate>{session.profileId || t('project.unknownUser')}</Text><Text size='xs' colour='muted'>+ {' · '}{lastErrorAt} · {session.errorCount} {t('project.occurrences').toLowerCase()}</Text></div>@@ -127,7 +135,9 @@ export const ErrorDetails = ({const { id } = useCurrentProject()const [isStackTraceExpanded, setIsStackTraceExpanded] = useState(false)- const [isCopied, setIsCopied] = useState(false)+ const [isCopiedStack, setIsCopiedStack] = useState(false)+ const [isCopiedEid, setIsCopiedEid] = useState(false)+ const [isCopiedFile, setIsCopiedFile] = useState(false)// Affected sessions stateconst [sessions, setSessions] = useState<ErrorAffectedSession[]>([])@@ -163,18 +173,63 @@ export const ErrorDetails = ({return { label: t('error.status.resolved'), colour: 'slate' }}, [details.status, t])+ const stackTraceLines = useMemo(+ () => (details.stackTrace ? details.stackTrace.split('\n') : []),+ [details.stackTrace],+ )+ const canLoadMoreSessions = sessions.length < sessionsTotal+ const fileLocation = useMemo(() => {+ if (!details.filename) return ''++ return `${details.filename}${details.lineno ? `:${details.lineno}` : ''}${details.colno ? `:${details.colno}` : ''}`+ }, [details.filename, details.lineno, details.colno])++ // Keep stack trace collapsed by default, but auto-expand very small stacks+ useEffect(() => {+ const shouldExpand = stackTraceLines.length > 0 && stackTraceLines.length <= 8+ setIsStackTraceExpanded(shouldExpand)+ setIsCopiedStack(false)+ setIsCopiedEid(false)+ setIsCopiedFile(false)+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [details.eid])+const handleCopyStackTrace = async () => {if (!details.stackTrace) returntry {await navigator.clipboard.writeText(details.stackTrace)- setIsCopied(true)- setTimeout(() => setIsCopied(false), 2000)+ setIsCopiedStack(true)+ setTimeout(() => setIsCopiedStack(false), 2000)} catch (err) {console.error('Failed to copy stack trace:', err)}}+ const handleCopyEid = async () => {+ if (!details.eid) return++ try {+ await navigator.clipboard.writeText(details.eid)+ setIsCopiedEid(true)+ setTimeout(() => setIsCopiedEid(false), 2000)+ } catch (err) {+ console.error('Failed to copy error id:', err)+ }+ }++ const handleCopyFile = async () => {+ if (!fileLocation) return++ try {+ await navigator.clipboard.writeText(fileLocation)+ setIsCopiedFile(true)+ setTimeout(() => setIsCopiedFile(false), 2000)+ } catch (err) {+ console.error('Failed to copy file location:', err)+ }+ }+const loadSessions = useCallback(async (reset = false) => {if (sessionsLoading) return@@ -260,23 +315,24 @@ export const ErrorDetails = ({return <p className='block text-slate-800 dark:text-slate-300'>{line}</p>}- const stackTraceLines = details.stackTrace ? details.stackTrace.split('\n') : []- const canLoadMoreSessions = sessions.length < sessionsTotal-// Truncate error message for displayconst errorTitle = details.message ? `${details.name}: ${details.message}` : details.nameconst shouldTruncate = errorTitle.length > 120const displayTitle = shouldTruncate ? `${errorTitle.slice(0, 120)}...` : errorTitle+ const stackPreviewCount = 6+ const stackPreviewLines = stackTraceLines.slice(0, stackPreviewCount)+ const stackHiddenCount = Math.max(0, stackTraceLines.length - stackPreviewCount)+return (- <div className='space-y-4'>- {/* Header - Similar to UserDetails */}+ <div className='space-y-6'>+ {/* Header (matches UserDetails vibe) */}<div className='flex items-start gap-4'><div className='flex size-14 shrink-0 items-center justify-center rounded-xl bg-red-100 dark:bg-red-900/30'><BugIcon className='size-7 text-red-600 dark:text-red-400' strokeWidth={1.5} /></div><div className='min-w-0 flex-1'>- <div className='flex items-center gap-2'>+ <div className='flex flex-wrap items-center gap-2'>{shouldTruncate ? (<Tooltiptext={errorTitle}@@ -287,7 +343,7 @@ export const ErrorDetails = ({)}<Badge label={status.label} colour={status.colour} /></div>- <div className='mt-1 flex flex-wrap items-center gap-x-3 gap-y-1'>+ <div className='mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1'>{details.filename ? (<div className='flex items-center gap-1 text-sm text-gray-500 dark:text-gray-400'><FileCodeIcon className='size-3.5' strokeWidth={1.5} />@@ -298,115 +354,215 @@ export const ErrorDetails = ({</span></div>) : null}- <code className='text-xs text-gray-400'>{details.eid}</code></div></div></div>- {/* Stats Card */}- <div className='rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>- <div className='grid grid-cols-2 gap-y-5 sm:grid-cols-3'>- <StatItem- icon={<HashIcon className='h-3.5 w-3.5' />}- label={t('project.occurrences')}- value={details.count || 0}- />- <StatItem- icon={<CalendarIcon className='h-3.5 w-3.5' />}- label={t('dashboard.firstSeen')}- value={firstSeen}- />- <StatItem icon={<CalendarIcon className='h-3.5 w-3.5' />} label={t('dashboard.lastSeen')} value={lastSeen} />- </div>- </div>+ {/* Main Content - Two Column Layout (matches UserDetails / SessionDetailView) */}+ <div className='flex flex-col gap-5 lg:flex-row'>+ {/* Left Column - Summary */}+ <div className='space-y-4 lg:w-[380px]'>+ {/* Stats Card */}+ <div className='rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>+ <div className='grid grid-cols-2 gap-y-5 sm:grid-cols-3 lg:grid-cols-2'>+ <StatItem+ icon={<HashIcon className='h-3.5 w-3.5' />}+ label={t('project.occurrences')}+ value={details.count || 0}+ />+ <StatItem+ icon={<CalendarIcon className='h-3.5 w-3.5' />}+ label={t('dashboard.firstSeen')}+ value={firstSeen || '-'}+ />+ <StatItem+ icon={<CalendarIcon className='h-3.5 w-3.5' />}+ label={t('dashboard.lastSeen')}+ value={lastSeen || '-'}+ />+ </div>+ </div>- {/* Stack Trace */}- {details.stackTrace ? (- <div className='rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>- <div className='mb-3 flex items-center justify-between'>- <button- onClick={() => setIsStackTraceExpanded(!isStackTraceExpanded)}- className='flex items-center text-sm font-medium text-gray-900 hover:text-gray-700 dark:text-gray-50 dark:hover:text-gray-200'- >- {isStackTraceExpanded ? (- <ChevronUpIcon className='mr-1 size-4' />- ) : (- <ChevronDownIcon className='mr-1 size-4' />- )}- {t('project.stackTraceXFrames', { x: stackTraceLines.length })}- </button>-- {isStackTraceExpanded ? (- <button- onClick={handleCopyStackTrace}- className='flex items-center rounded-md border border-gray-200 px-2 py-1 text-xs font-medium text-gray-700 hover:bg-gray-50 dark:border-slate-600 dark:text-gray-200 dark:hover:bg-slate-700'- >- {isCopied ? (- <>- <CheckIcon className='mr-1 size-3.5 text-green-500' />- {t('project.copied')}- </>- ) : (- <>- <ClipboardIcon className='mr-1 size-3.5' />- {t('project.copy')}- </>- )}- </button>- ) : null}+ {/* Metadata Card */}+ <div className='rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>+ <h3 className='mb-3 text-xs font-semibold tracking-wide text-gray-900 uppercase dark:text-gray-50'>+ {t('project.metadata')}+ </h3>+ <div>+ {details.filename ? (+ <InfoRow+ label={+ <span className='flex items-center gap-1.5'>+ <FileCodeIcon className='size-4' strokeWidth={1.5} />+ File+ </span>+ }+ value={+ <span className='flex min-w-0 items-center justify-end gap-1.5'>+ <Tooltip+ text={fileLocation}+ tooltipNode={+ <span className='min-w-0 truncate font-mono text-xs text-gray-700 dark:text-gray-200'>+ {fileLocation}+ </span>+ }+ delay={0}+ />+ <button+ type='button'+ onClick={handleCopyFile}+ className='shrink-0 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-slate-700 dark:hover:text-gray-200'+ aria-label={t('project.copy')}+ >+ {isCopiedFile ? (+ <CheckIcon className='size-4 text-green-500' />+ ) : (+ <ClipboardIcon className='size-4' />+ )}+ </button>+ </span>+ }+ />+ ) : null}+ <InfoRow+ label={+ <span className='flex items-center gap-1.5'>+ <HashIcon className='size-4' strokeWidth={1.5} />+ ID+ </span>+ }+ value={+ <span className='flex items-center justify-end gap-1.5'>+ <code className='text-xs text-gray-400'>{details.eid}</code>+ <button+ type='button'+ onClick={handleCopyEid}+ className='rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-slate-700 dark:hover:text-gray-200'+ aria-label={t('project.copy')}+ >+ {isCopiedEid ? (+ <CheckIcon className='size-4 text-green-500' />+ ) : (+ <ClipboardIcon className='size-4' />+ )}+ </button>+ </span>+ }+ />+ </div></div>+ </div>++ {/* Right Column - Stack Trace & Affected Sessions */}+ <div className='flex-1 space-y-4'>+ {/* Stack Trace */}+ {details.stackTrace ? (+ <div className='rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>+ <div className='mb-3 flex items-center justify-between gap-3'>+ <h3 className='text-xs font-semibold tracking-wide text-gray-900 uppercase dark:text-gray-50'>+ {t('project.stackTraceXFrames', { x: stackTraceLines.length })}+ </h3>+ <div className='flex items-center gap-2'>+ <button+ type='button'+ onClick={handleCopyStackTrace}+ className='flex items-center rounded-md border border-gray-200 px-2 py-1 text-xs font-medium text-gray-700 hover:bg-gray-50 dark:border-slate-600 dark:text-gray-200 dark:hover:bg-slate-700'+ aria-label={t('project.copy')}+ >+ {isCopiedStack ? (+ <>+ <CheckIcon className='mr-1 size-3.5 text-green-500' />+ {t('project.copied')}+ </>+ ) : (+ <>+ <ClipboardIcon className='mr-1 size-3.5' />+ {t('project.copy')}+ </>+ )}+ </button>+ <button+ type='button'+ onClick={() => setIsStackTraceExpanded((v) => !v)}+ className='flex items-center rounded-md border border-gray-200 px-2 py-1 text-xs font-medium text-gray-700 hover:bg-gray-50 dark:border-slate-600 dark:text-gray-200 dark:hover:bg-slate-700'+ aria-expanded={isStackTraceExpanded}+ >+ {isStackTraceExpanded ? (+ <>+ <ChevronUpIcon className='mr-1 size-4' />+ {t('project.showLess')}+ </>+ ) : (+ <>+ <ChevronDownIcon className='mr-1 size-4' />+ {stackHiddenCount > 0+ ? t('project.showMore', { count: stackHiddenCount })+ : t('project.showMore', { count: 0 })}+ </>+ )}+ </button>+ </div>+ </div>- {isStackTraceExpanded ? (- <div className='rounded-lg border border-gray-100 bg-gray-50 dark:border-slate-700 dark:bg-slate-900/50'>- <div className='max-h-80 overflow-auto p-3'>- <div className='space-y-0.5 font-mono text-xs leading-relaxed'>- {stackTraceLines.map((line, index) => (- <div key={index} className='flex'>- <span className='mr-3 inline-block w-6 text-right text-gray-400 select-none dark:text-slate-500'>- {index + 1}- </span>- <div className='min-w-0 flex-1'>{formatStackTraceLine(line)}</div>- </div>- ))}+ <div className='rounded-lg border border-gray-100 bg-gray-50 dark:border-slate-700 dark:bg-slate-900/50'>+ <div className={isStackTraceExpanded ? 'max-h-80 overflow-auto p-3' : 'p-3'}>+ <div className='space-y-0.5 font-mono text-xs leading-relaxed'>+ {(isStackTraceExpanded ? stackTraceLines : stackPreviewLines).map((line, index) => (+ <div key={index} className='flex'>+ <span className='mr-3 inline-block w-6 text-right text-gray-400 select-none dark:text-slate-500'>+ {index + 1}+ </span>+ <div className='min-w-0 flex-1'>{formatStackTraceLine(line)}</div>+ </div>+ ))}+ {!isStackTraceExpanded && stackHiddenCount > 0 ? (+ <div className='pt-2 text-center text-[11px] text-gray-400 dark:text-slate-500'>+ +{stackHiddenCount}{' '}+ {t('project.showMore', { count: stackHiddenCount })+ .toLowerCase()+ .replace(/^\+?\d+\s+/, '')}+ </div>+ ) : null}+ </div></div></div></div>) : null}- </div>- ) : null}-- {/* Affected Sessions */}- <div className='rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>- <h3 className='mb-3 text-xs font-semibold tracking-wide text-gray-900 uppercase dark:text-gray-50'>- {t('project.affectedSessionsList')} {sessionsTotal > 0 ? `(${sessionsTotal})` : ''}- </h3>-- {sessionsLoading && sessions.length === 0 ? (- <Loader />- ) : sessions.length === 0 ? (- <Text as='p' size='sm' colour='muted' className='py-4 text-center'>- {t('project.noAffectedSessions')}- </Text>- ) : (- <div className='space-y-2'>- {_map(sessions, (session) => (- <SessionRow key={session.psid} session={session} />- ))}-- {canLoadMoreSessions ? (- <Button- onClick={() => loadSessions()}- disabled={!!sessionsLoading}- loading={!!sessionsLoading}- className='mt-3 w-full'- secondary- regular- >- {t('project.loadMore')}- </Button>- ) : null}++ {/* Affected Sessions */}+ <div className='rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>+ <h3 className='mb-3 text-xs font-semibold tracking-wide text-gray-900 uppercase dark:text-gray-50'>+ {t('project.affectedSessionsList')} {sessionsTotal > 0 ? `(${sessionsTotal})` : ''}+ </h3>++ {sessionsLoading && sessions.length === 0 ? (+ <Loader />+ ) : sessions.length === 0 ? (+ <Text as='p' size='sm' colour='muted' className='py-4 text-center'>+ {t('project.noAffectedSessions')}+ </Text>+ ) : (+ <div className='space-y-2'>+ {_map(sessions, (session) => (+ <SessionRow key={session.psid} session={session} />+ ))}++ {canLoadMoreSessions ? (+ <Button+ onClick={() => loadSessions()}+ disabled={!!sessionsLoading}+ loading={!!sessionsLoading}+ className='mt-3 w-full'+ secondary+ regular+ >+ {t('project.loadMore')}+ </Button>+ ) : null}+ </div>+ )}</div>- )}+ </div></div></div>)diff --git a/web/app/pages/Project/View/components/RefreshStatsButton.tsx b/web/app/pages/Project/View/components/RefreshStatsButton.tsxindex bae693c53..368dbf55a 100644--- a/web/app/pages/Project/View/components/RefreshStatsButton.tsx+++ b/web/app/pages/Project/View/components/RefreshStatsButton.tsx@@ -73,7 +73,7 @@ export const RefreshStatsButton = ({ onRefresh }: RefreshStatsButtonProps) => {title={t('project.refreshStats')}onClick={handleManualRefresh}className={cn(- 'group relative rounded-md border border-transparent p-2 hover:border-gray-300 hover:bg-white focus:z-10 focus:ring-1 focus:ring-indigo-500 focus:outline-hidden hover:dark:border-slate-700/80 dark:hover:bg-slate-800 focus:dark:ring-gray-200',+ 'group relative rounded-md border border-transparent p-2 transition-all hover:border-gray-300 hover:bg-white focus:z-10 focus:ring-1 focus:ring-indigo-500 focus:outline-hidden hover:dark:border-slate-700/80 dark:hover:bg-slate-800 focus:dark:ring-gray-200',{'cursor-not-allowed opacity-50': authLoading,},