Skip to content

The only tool you need to know what is happening and how to fix it.

more drying out

ddux2c38291cee32
diff --git a/frontend/src/lib/components/issues/event-card.svelte b/frontend/src/lib/components/issues/event-card.svelte
index 6a20c3bd..cb013842 100644
--- a/frontend/src/lib/components/issues/event-card.svelte
+++ b/frontend/src/lib/components/issues/event-card.svelte
@@ -4,6 +4,8 @@
import * as Card from "$lib/components/ui/card";
import { ArrowRight } from "lucide-svelte";
import type { ExceptionOccurrence, LinkedTransaction } from '$lib/types/exceptions';
+ import { formatDuration, getStatusColor } from '$lib/utils/formatters';
+ import { ContextGrid } from '$lib/components/ui/context-grid';
interface Props {
occurrence: ExceptionOccurrence;
@@ -19,23 +21,6 @@
description = "Details for this specific occurrence"
}: Props = $props();
- function formatDuration(nanoseconds: number): string {
- const ms = nanoseconds / 1_000_000;
- if (ms < 1) {
- return `${(nanoseconds / 1000).toFixed(0)}us`;
- } else if (ms < 1000) {
- return `${ms.toFixed(0)}ms`;
- } else {
- return `${(ms / 1000).toFixed(1)}s`;
- }
- }
-
- function getStatusColor(statusCode: number): string {
- if (statusCode >= 200 && statusCode < 300) return 'text-green-500';
- if (statusCode >= 300 && statusCode < 400) return 'text-blue-500';
- if (statusCode >= 400 && statusCode < 500) return 'text-yellow-500';
- return 'text-red-500';
- }
</script>
<Card.Root>
@@ -69,14 +54,7 @@
<hr class="border-border" />
<div>
<p class="text-sm font-medium mb-3">Context</p>
- <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3">
- {#each Object.entries(occurrence.scope).sort((a, b) => a[0].localeCompare(b[0])) as [key, value]}
- <div class="flex flex-col gap-1 p-3 rounded-md bg-muted">
- <span class="text-xs font-medium text-muted-foreground">{key}</span>
- <span class="text-sm font-mono break-all">{value}</span>
- </div>
- {/each}
- </div>
+ <ContextGrid scope={occurrence.scope} />
</div>
{/if}
diff --git a/frontend/src/lib/components/issues/events-table.svelte b/frontend/src/lib/components/issues/events-table.svelte
index 917cf36a..f76ed73d 100644
--- a/frontend/src/lib/components/issues/events-table.svelte
+++ b/frontend/src/lib/components/issues/events-table.svelte
@@ -2,9 +2,9 @@
import { createRowClickHandler } from '$lib/utils/navigation';
import * as Card from "$lib/components/ui/card";
import * as Table from "$lib/components/ui/table";
- import { ArrowRight } from "lucide-svelte";
import { TracewayTableHeader } from "$lib/components/ui/traceway-table-header";
import { TableEmptyState } from "$lib/components/ui/table-empty-state";
+ import { ViewAllTableRow } from "$lib/components/ui/view-all-table-row";
import type { ExceptionOccurrence } from '$lib/types/exceptions';
interface Props {
@@ -84,14 +84,7 @@
</Table.Row>
{/each}
{#if hasMore && showViewAll}
- <Table.Row
- class="cursor-pointer bg-muted/50 hover:bg-muted"
- onclick={createRowClickHandler(`/issues/${exceptionHash}/events`)}
- >
- <Table.Cell colspan={3} class="py-2 text-center text-sm text-muted-foreground">
- View all {total} events <ArrowRight class="inline h-3.5 w-3.5" />
- </Table.Cell>
- </Table.Row>
+ <ViewAllTableRow colspan={3} href={`/issues/${exceptionHash}/events`} label={`View all ${total} events`} />
{/if}
{/if}
</Table.Body>
diff --git a/frontend/src/lib/components/segments/segment-row.svelte b/frontend/src/lib/components/segments/segment-row.svelte
index 808610b6..4b7ea3ae 100644
--- a/frontend/src/lib/components/segments/segment-row.svelte
+++ b/frontend/src/lib/components/segments/segment-row.svelte
@@ -1,6 +1,7 @@
<script lang="ts">
import type { Segment } from '$lib/types/segments';
import { cn } from '$lib/utils';
+ import { formatDuration } from '$lib/utils/formatters';
type Props = {
segment: Segment;
@@ -41,13 +42,6 @@
const segmentColor = $derived(getSegmentColor(segment.name));
- function formatDuration(nanoseconds: number): string {
- const ms = nanoseconds / 1_000_000;
- if (ms < 1) return `${(nanoseconds / 1000).toFixed(0)}µs`;
- if (ms < 1000) return `${ms.toFixed(1)}ms`;
- return `${(ms / 1000).toFixed(2)}s`;
- }
-
// Tooltip state
let isHovered = $state(false);
let tooltipX = $state(0);
diff --git a/frontend/src/lib/components/ui/context-grid/context-grid.svelte b/frontend/src/lib/components/ui/context-grid/context-grid.svelte
new file mode 100644
index 00000000..44c47589
--- /dev/null
+++ b/frontend/src/lib/components/ui/context-grid/context-grid.svelte
@@ -0,0 +1,26 @@
+<script lang="ts">
+ let {
+ scope,
+ sorted = true
+ }: {
+ scope: Record<string, string>;
+ sorted?: boolean;
+ } = $props();
+
+ const entries = $derived(() => {
+ const items = Object.entries(scope);
+ if (sorted) {
+ return items.sort((a, b) => a[0].localeCompare(b[0]));
+ }
+ return items;
+ });
+</script>
+
+<div class="grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3">
+ {#each entries() as [key, value]}
+ <div class="flex flex-col gap-1 rounded-md bg-muted p-3">
+ <span class="text-xs font-medium text-muted-foreground">{key}</span>
+ <span class="font-mono text-sm break-all">{value}</span>
+ </div>
+ {/each}
+</div>
diff --git a/frontend/src/lib/components/ui/context-grid/index.ts b/frontend/src/lib/components/ui/context-grid/index.ts
new file mode 100644
index 00000000..d646d67f
--- /dev/null
+++ b/frontend/src/lib/components/ui/context-grid/index.ts
@@ -0,0 +1 @@
+export { default as ContextGrid } from './context-grid.svelte';
diff --git a/frontend/src/lib/components/ui/impact-badge/impact-badge.svelte b/frontend/src/lib/components/ui/impact-badge/impact-badge.svelte
new file mode 100644
index 00000000..45db5497
--- /dev/null
+++ b/frontend/src/lib/components/ui/impact-badge/impact-badge.svelte
@@ -0,0 +1,53 @@
+<script lang="ts">
+ import { TriangleAlert } from 'lucide-svelte';
+
+ type ImpactLevel = 'critical' | 'high' | 'medium' | null;
+
+ let {
+ level,
+ showIcon
+ }: {
+ level: ImpactLevel;
+ showIcon?: boolean;
+ } = $props();
+
+ // Default showIcon to true for critical and high levels
+ const shouldShowIcon = $derived(showIcon ?? (level === 'critical' || level === 'high'));
+
+ const config = $derived(() => {
+ switch (level) {
+ case 'critical':
+ return {
+ bg: 'bg-red-500/15',
+ text: 'text-red-600 dark:text-red-400',
+ label: 'Critical'
+ };
+ case 'high':
+ return {
+ bg: 'bg-orange-500/15',
+ text: 'text-orange-600 dark:text-orange-400',
+ label: 'High'
+ };
+ case 'medium':
+ return {
+ bg: 'bg-yellow-500/15',
+ text: 'text-yellow-600 dark:text-yellow-500',
+ label: 'Medium'
+ };
+ default:
+ return null;
+ }
+ });
+</script>
+
+{#if config()}
+ <span
+ class="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium {config()
+ ?.bg} {config()?.text}"
+ >
+ {#if shouldShowIcon}
+ <TriangleAlert class="h-3 w-3" />
+ {/if}
+ {config()?.label}
+ </span>
+{/if}
diff --git a/frontend/src/lib/components/ui/impact-badge/index.ts b/frontend/src/lib/components/ui/impact-badge/index.ts
new file mode 100644
index 00000000..d2b229d5
--- /dev/null
+++ b/frontend/src/lib/components/ui/impact-badge/index.ts
@@ -0,0 +1 @@
+export { default as ImpactBadge } from './impact-badge.svelte';
diff --git a/frontend/src/lib/components/ui/pagination-footer/index.ts b/frontend/src/lib/components/ui/pagination-footer/index.ts
new file mode 100644
index 00000000..28f0feb0
--- /dev/null
+++ b/frontend/src/lib/components/ui/pagination-footer/index.ts
@@ -0,0 +1 @@
+export { default as PaginationFooter } from './pagination-footer.svelte';
diff --git a/frontend/src/lib/components/ui/pagination-footer/pagination-footer.svelte b/frontend/src/lib/components/ui/pagination-footer/pagination-footer.svelte
new file mode 100644
index 00000000..423f47b6
--- /dev/null
+++ b/frontend/src/lib/components/ui/pagination-footer/pagination-footer.svelte
@@ -0,0 +1,108 @@
+<script lang="ts">
+ import { Button } from '$lib/components/ui/button';
+ import * as Select from '$lib/components/ui/select';
+ import { ChevronLeft, ChevronRight } from 'lucide-svelte';
+
+ let {
+ currentPage,
+ totalPages,
+ pageSize,
+ totalItems,
+ itemsShown,
+ onPageChange,
+ onPageSizeChange,
+ loading = false,
+ pageSizeOptions = [10, 20, 50, 100],
+ itemLabel = 'item'
+ }: {
+ currentPage: number;
+ totalPages: number;
+ pageSize: number;
+ totalItems: number;
+ itemsShown?: number;
+ onPageChange: (page: number) => void;
+ onPageSizeChange: (size: number) => void;
+ loading?: boolean;
+ pageSizeOptions?: number[];
+ itemLabel?: string;
+ } = $props();
+
+ const selectOptions = $derived(
+ pageSizeOptions.map((size) => ({ value: size.toString(), label: size.toString() }))
+ );
+
+ const pageSizeLabel = $derived(
+ selectOptions.find((o) => o.value === pageSize.toString())?.label ?? pageSize.toString()
+ );
+
+ function handlePrevPage() {
+ if (currentPage > 1) {
+ onPageChange(currentPage - 1);
+ }
+ }
+
+ function handleNextPage() {
+ if (currentPage < totalPages) {
+ onPageChange(currentPage + 1);
+ }
+ }
+
+ function handlePageSizeSelect(value: string | undefined) {
+ if (value) {
+ onPageSizeChange(parseInt(value));
+ }
+ }
+
+ const displayedPages = $derived(totalPages || 1);
+ const plural = $derived(totalItems === 1 ? '' : 's');
+</script>
+
+<div class="flex items-center justify-between px-2">
+ <div class="flex-1 text-sm text-muted-foreground">
+ {#if itemsShown !== undefined}
+ Showing {itemsShown} of {totalItems} {itemLabel}{plural}
+ {:else}
+ {totalItems} {itemLabel}{plural} total
+ {/if}
+ </div>
+ <div class="flex items-center space-x-6 lg:space-x-8">
+ <div class="flex items-center space-x-2">
+ <p class="text-sm font-medium">Rows per page</p>
+ <Select.Root type="single" value={pageSize.toString()} onValueChange={handlePageSizeSelect}>
+ <Select.Trigger class="h-8 w-[70px]">
+ {pageSizeLabel}
+ </Select.Trigger>
+ <Select.Content side="top">
+ {#each selectOptions as option}
+ <Select.Item value={option.value} label={option.label}>{option.label}</Select.Item>
+ {/each}
+ </Select.Content>
+ </Select.Root>
+ </div>
+ <div class="flex w-[100px] items-center justify-center text-sm font-medium">
+ Page {currentPage} of {displayedPages}
+ </div>
+ <div class="flex items-center space-x-2">
+ <Button
+ variant="outline"
+ size="sm"
+ class="h-8 w-8 p-0"
+ onclick={handlePrevPage}
+ disabled={currentPage <= 1 || loading}
+ >
+ <span class="sr-only">Go to previous page</span>
+ <ChevronLeft class="h-4 w-4" />
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ class="h-8 w-8 p-0"
+ onclick={handleNextPage}
+ disabled={currentPage >= totalPages || loading}
+ >
+ <span class="sr-only">Go to next page</span>
+ <ChevronRight class="h-4 w-4" />
+ </Button>
+ </div>
+ </div>
+</div>
diff --git a/frontend/src/lib/components/ui/view-all-table-row/index.ts b/frontend/src/lib/components/ui/view-all-table-row/index.ts
new file mode 100644
index 00000000..d9927fb0
--- /dev/null
+++ b/frontend/src/lib/components/ui/view-all-table-row/index.ts
@@ -0,0 +1 @@
+export { default as ViewAllTableRow } from './view-all-table-row.svelte';
diff --git a/frontend/src/lib/components/ui/view-all-table-row/view-all-table-row.svelte b/frontend/src/lib/components/ui/view-all-table-row/view-all-table-row.svelte
new file mode 100644
index 00000000..d438ca13
--- /dev/null
+++ b/frontend/src/lib/components/ui/view-all-table-row/view-all-table-row.svelte
@@ -0,0 +1,21 @@
+<script lang="ts">
+ import * as Table from '$lib/components/ui/table';
+ import { ArrowRight } from 'lucide-svelte';
+ import { createRowClickHandler } from '$lib/utils/navigation';
+
+ let {
+ colspan,
+ href,
+ label
+ }: {
+ colspan: number;
+ href: string;
+ label: string;
+ } = $props();
+</script>
+
+<Table.Row class="cursor-pointer bg-muted/50 hover:bg-muted" onclick={createRowClickHandler(href)}>
+ <Table.Cell {colspan} class="py-2 text-center text-sm text-muted-foreground">
+ {label} <ArrowRight class="inline h-3.5 w-3.5" />
+ </Table.Cell>
+</Table.Row>
diff --git a/frontend/src/lib/utils/formatters.ts b/frontend/src/lib/utils/formatters.ts
new file mode 100644
index 00000000..4eccd515
--- /dev/null
+++ b/frontend/src/lib/utils/formatters.ts
@@ -0,0 +1,49 @@
+export function formatDuration(nanoseconds: number): string {
+ const ms = nanoseconds / 1_000_000;
+ if (ms < 1) {
+ return `${(nanoseconds / 1000).toFixed(0)}µs`;
+ } else if (ms < 1000) {
+ return `${ms.toFixed(0)}ms`;
+ } else {
+ return `${(ms / 1000).toFixed(1)}s`;
+ }
+}
+
+export function formatDurationMs(ms: number): string {
+ if (ms < 1) {
+ return `${(ms * 1000).toFixed(0)} µs`;
+ } else if (ms < 1000) {
+ return `${ms.toFixed(0)} ms`;
+ } else {
+ return `${(ms / 1000).toFixed(2)} s`;
+ }
+}
+
+export function getStatusColor(statusCode: number): string {
+ if (statusCode >= 200 && statusCode < 300) return 'text-green-500';
+ if (statusCode >= 300 && statusCode < 400) return 'text-blue-500';
+ if (statusCode >= 400 && statusCode < 500) return 'text-yellow-500';
+ return 'text-red-500';
+}
+
+export function truncateStackTrace(stackTrace: string, maxLength = 70): string {
+ const firstLine = stackTrace.split('\n')[0];
+ if (firstLine.length > maxLength) {
+ return firstLine.slice(0, maxLength) + '...';
+ }
+ return firstLine;
+}
+
+export function formatRelativeTime(dateStr: string): string {
+ const date = new Date(dateStr);
+ const now = new Date();
+ const diffMs = now.getTime() - date.getTime();
+ const diffMins = Math.floor(diffMs / 60000);
+ const diffHours = Math.floor(diffMs / 3600000);
+ const diffDays = Math.floor(diffMs / 86400000);
+
+ if (diffMins < 1) return 'just now';
+ if (diffMins < 60) return `${diffMins}m`;
+ if (diffHours < 24) return `${diffHours}h`;
+ return `${diffDays}d`;
+}
diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte
index fdbca390..120fa0f4 100644
--- a/frontend/src/routes/+page.svelte
+++ b/frontend/src/routes/+page.svelte
@@ -1,12 +1,15 @@
<script lang="ts">
import { onMount } from 'svelte';
import { createRowClickHandler } from '$lib/utils/navigation';
+ import { formatDuration, formatRelativeTime, truncateStackTrace } from '$lib/utils/formatters';
import { LoadingCircle } from '$lib/components/ui/loading-circle';
import * as Table from '$lib/components/ui/table';
import * as Tooltip from '$lib/components/ui/tooltip';
- import { ArrowRight, Info, Gauge, Bug, CircleHelp as CircleQuestionMark, TriangleAlert } from 'lucide-svelte';
+ import { ArrowRight, Info, Gauge, Bug, CircleHelp as CircleQuestionMark } from 'lucide-svelte';
import { TracewayTableHeader } from '$lib/components/ui/traceway-table-header';
+ import { ImpactBadge } from '$lib/components/ui/impact-badge';
import { TableEmptyState } from '$lib/components/ui/table-empty-state';
+ import { ViewAllTableRow } from '$lib/components/ui/view-all-table-row';
import { api } from '$lib/api';
import { ErrorDisplay } from '$lib/components/ui/error-display';
import { projectsState } from '$lib/state/projects.svelte';
@@ -61,31 +64,6 @@
loadDashboard();
});
- function formatRelativeTime(dateStr: string): string {
- const date = new Date(dateStr);
- const now = new Date();
- const diffMs = now.getTime() - date.getTime();
- const diffMins = Math.floor(diffMs / 60000);
- const diffHours = Math.floor(diffMs / 3600000);
- const diffDays = Math.floor(diffMs / 86400000);
-
- if (diffMins < 1) return 'just now';
- if (diffMins < 60) return `${diffMins}m`;
- if (diffHours < 24) return `${diffHours}h`;
- return `${diffDays}d`;
- }
-
- function formatDuration(nanoseconds: number): string {
- const ms = nanoseconds / 1_000_000;
- if (ms < 1) {
- return `${(nanoseconds / 1000).toFixed(0)}µs`;
- } else if (ms < 1000) {
- return `${ms.toFixed(0)}ms`;
- } else {
- return `${(ms / 1000).toFixed(1)}s`;
- }
- }
-
// Calculate impact level based on call volume and response time variance
// Returns: 'critical' | 'high' | 'medium' | null (null = not significant)
function getImpactLevel(
@@ -101,13 +79,6 @@
return null;
}
- function truncateStackTrace(stackTrace: string): string {
- const firstLine = stackTrace.split('\n')[0];
- if (firstLine.length > 70) {
- return firstLine.slice(0, 70) + '...';
- }
- return firstLine;
- }
</script>
<div class="space-y-4">
@@ -214,38 +185,11 @@
{formatDuration(endpoint.p95Duration)}
</Table.Cell>
<Table.Cell class="py-3 text-right">
- {#if impactLevel === 'critical'}
- <span
- class="inline-flex items-center gap-1 rounded-full bg-red-500/15 px-2 py-0.5 text-xs font-medium text-red-600 dark:text-red-400"
- >
- <TriangleAlert class="h-3 w-3" />
- Critical
- </span>
- {:else if impactLevel === 'high'}
- <span
- class="inline-flex items-center gap-1 rounded-full bg-orange-500/15 px-2 py-0.5 text-xs font-medium text-orange-600 dark:text-orange-400"
- >
- <TriangleAlert class="h-3 w-3" />
- High
- </span>
- {:else if impactLevel === 'medium'}
- <span
- class="inline-flex items-center gap-1 rounded-full bg-yellow-500/15 px-2 py-0.5 text-xs font-medium text-yellow-600 dark:text-yellow-500"
- >
- Medium
- </span>
- {/if}
+ <ImpactBadge level={impactLevel} />
</Table.Cell>
</Table.Row>
{/each}
- <Table.Row
- class="cursor-pointer bg-muted/50 hover:bg-muted"
- onclick={createRowClickHandler('/transactions')}
- >
- <Table.Cell colspan={5} class="py-2 text-center text-sm text-muted-foreground">
- View all transactions <ArrowRight class="inline h-3.5 w-3.5" />
- </Table.Cell>
- </Table.Row>
+ <ViewAllTableRow colspan={5} href="/transactions" label="View all transactions" />
</Table.Body>
{:else}
<Table.Body>
@@ -312,14 +256,7 @@
</Table.Cell>
</Table.Row>
{/each}
- <Table.Row
- class="cursor-pointer bg-muted/50 hover:bg-muted"
- onclick={createRowClickHandler('/issues')}
- >
- <Table.Cell colspan={3} class="py-2 text-center text-sm text-muted-foreground">
- View all issues <ArrowRight class="inline h-3.5 w-3.5" />
- </Table.Cell>
- </Table.Row>
+ <ViewAllTableRow colspan={3} href="/issues" label="View all issues" />
</Table.Body>
{:else}
<Table.Body>
diff --git a/frontend/src/routes/issues/+page.svelte b/frontend/src/routes/issues/+page.svelte
index a3926f5d..d6644cab 100644
--- a/frontend/src/routes/issues/+page.svelte
+++ b/frontend/src/routes/issues/+page.svelte
@@ -13,6 +13,7 @@
import Archive from '@lucide/svelte/icons/archive';
import { TracewayTableHeader } from '$lib/components/ui/traceway-table-header';
import { TableEmptyState } from '$lib/components/ui/table-empty-state';
+ import { PaginationFooter } from '$lib/components/ui/pagination-footer';
type ExceptionTrendPoint = {
timestamp: string;
@@ -119,8 +120,8 @@
}
}
- function handlePageSizeChange(newPageSize: string) {
- pageSize = parseInt(newPageSize);
+ function handlePageSizeChange(newPageSize: number) {
+ pageSize = newPageSize;
page = 1;
loadData();
}
@@ -344,89 +345,14 @@
</div>
<!-- Pagination Footer -->
- <div class="flex items-center justify-between px-2">
- <div class="flex-1 text-sm text-muted-foreground">
- {#if selectedCount > 0}
- {selectedCount} of {total} row(s) selected.
- {:else}
- {total} issue{total === 1 ? '' : 's'} total
- {/if}
- </div>
- <div class="flex items-center space-x-6 lg:space-x-8">
- <div class="flex items-center space-x-2">
- <p class="text-sm font-medium">Rows per page</p>
- <Select.Root
- type="single"
- value={pageSize.toString()}
- onValueChange={(v) => {
- if (v) {
- handlePageSizeChange(v);
- }
- }}
- >
- <Select.Trigger class="h-8 w-[70px]">
- {pageSizeLabel}
- </Select.Trigger>
- <Select.Content side="top">
- {#each pageSizeOptions as option}
- <Select.Item value={option.value} label={option.label}>{option.label}</Select.Item>
- {/each}
- </Select.Content>
- </Select.Root>
- </div>
- <div class="flex w-[100px] items-center justify-center text-sm font-medium">
- Page {page} of {totalPages || 1}
- </div>
- <div class="flex items-center space-x-2">
- <Button
- variant="outline"
- size="sm"
- class="h-8 w-8 p-0"
- onclick={() => handlePageChange(page - 1)}
- disabled={page <= 1 || loading}
- >
- <span class="sr-only">Go to previous page</span>
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="15"
- height="15"
- viewBox="0 0 15 15"
- fill="none"
- class="lucide lucide-chevron-left h-4 w-4"
- >
- <path
- d="M8.84182 3.13514C9.04327 3.32401 9.05348 3.64042 8.86462 3.84188L5.43521 7.49991L8.86462 11.1579C9.05348 11.3594 9.04327 11.6758 8.84182 11.8647C8.64036 12.0535 8.32394 12.0433 8.13508 11.8419L4.38508 7.84188C4.20477 7.64955 4.20477 7.35027 4.38508 7.15794L8.13508 3.15794C8.32394 2.95648 8.64036 2.94628 8.84182 3.13514Z"
- fill="currentColor"
- fill-rule="evenodd"
- clip-rule="evenodd"
- ></path>
- </svg>
- </Button>
- <Button
- variant="outline"
- size="sm"
- class="h-8 w-8 p-0"
- onclick={() => handlePageChange(page + 1)}
- disabled={page >= totalPages || loading}
- >
- <span class="sr-only">Go to next page</span>
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="15"
- height="15"
- viewBox="0 0 15 15"
- fill="none"
- class="lucide lucide-chevron-right h-4 w-4"
- >
- <path
- d="M6.1584 3.13508C6.35985 2.94621 6.67627 2.95642 6.86514 3.15788L10.6151 7.15788C10.7954 7.3502 10.7954 7.64949 10.6151 7.84182L6.86514 11.8418C6.67627 12.0433 6.35985 12.0535 6.1584 11.8646C5.95694 11.6757 5.94673 11.3593 6.1356 11.1579L9.565 7.49985L6.1356 3.84182C5.94673 3.64036 5.95694 3.32394 6.1584 3.13508Z"
- fill="currentColor"
- fill-rule="evenodd"
- clip-rule="evenodd"
- ></path>
- </svg>
- </Button>
- </div>
- </div>
- </div>
+ <PaginationFooter
+ currentPage={page}
+ {totalPages}
+ {pageSize}
+ totalItems={total}
+ onPageChange={handlePageChange}
+ onPageSizeChange={handlePageSizeChange}
+ {loading}
+ itemLabel="issue"
+ />
</div>
diff --git a/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte b/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
index 5d34b61c..8088f1eb 100644
--- a/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
+++ b/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
@@ -3,6 +3,7 @@
import { page } from '$app/state';
import { goto } from '$app/navigation';
import { createRowClickHandler } from '$lib/utils/navigation';
+ import { truncateStackTrace } from '$lib/utils/formatters';
import { api } from '$lib/api';
import { Button } from "$lib/components/ui/button";
import * as Card from "$lib/components/ui/card";
@@ -13,6 +14,7 @@
import { projectsState } from '$lib/state/projects.svelte';
import { TracewayTableHeader } from "$lib/components/ui/traceway-table-header";
import { TableEmptyState } from "$lib/components/ui/table-empty-state";
+ import { PaginationFooter } from "$lib/components/ui/pagination-footer";
type ExceptionGroup = {
exceptionHash: string;
@@ -91,20 +93,12 @@
}
}
- function handlePageSizeChange(newPageSize: string) {
- pageSize = parseInt(newPageSize);
+ function handlePageSizeChange(newPageSize: number) {
+ pageSize = newPageSize;
currentPage = 1;
loadData();
}
- function truncateStackTrace(stackTrace: string): string {
- const firstLine = stackTrace.split('\n')[0];
- if (firstLine.length > 80) {
- return firstLine.slice(0, 80) + '...';
- }
- return firstLine;
- }
-
onMount(() => {
loadData();
});
@@ -150,7 +144,7 @@
<Card.Header class="pb-3">
<Card.Title class="text-lg">All Events</Card.Title>
<Card.Description class="font-mono text-sm">
- {truncateStackTrace(group.stackTrace)}
+ {truncateStackTrace(group.stackTrace, 80)}
</Card.Description>
</Card.Header>
</Card.Root>
@@ -208,62 +202,16 @@
</div>
<!-- Pagination Footer -->
- <div class="flex items-center justify-between px-2">
- <div class="flex-1 text-sm text-muted-foreground">
- Showing {occurrences.length} of {total} events
- </div>
- <div class="flex items-center space-x-6 lg:space-x-8">
- <div class="flex items-center space-x-2">
- <p class="text-sm font-medium">Rows per page</p>
- <Select.Root
- type="single"
- value={pageSize.toString()}
- onValueChange={(v) => {
- if (v) {
- handlePageSizeChange(v);
- }
- }}
- >
- <Select.Trigger class="h-8 w-[70px]">
- {pageSizeLabel}
- </Select.Trigger>
- <Select.Content side="top">
- {#each pageSizeOptions as option}
- <Select.Item value={option.value} label={option.label}>{option.label}</Select.Item>
- {/each}
- </Select.Content>
- </Select.Root>
- </div>
- <div class="flex w-[100px] items-center justify-center text-sm font-medium">
- Page {currentPage} of {totalPages || 1}
- </div>
- <div class="flex items-center space-x-2">
- <Button
- variant="outline"
- size="sm"
- class="h-8 w-8 p-0"
- onclick={() => handlePageChange(currentPage - 1)}
- disabled={currentPage <= 1 || loading}
- >
- <span class="sr-only">Go to previous page</span>
- <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none" class="lucide lucide-chevron-left h-4 w-4">
- <path d="M8.84182 3.13514C9.04327 3.32401 9.05348 3.64042 8.86462 3.84188L5.43521 7.49991L8.86462 11.1579C9.05348 11.3594 9.04327 11.6758 8.84182 11.8647C8.64036 12.0535 8.32394 12.0433 8.13508 11.8419L4.38508 7.84188C4.20477 7.64955 4.20477 7.35027 4.38508 7.15794L8.13508 3.15794C8.32394 2.95648 8.64036 2.94628 8.84182 3.13514Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path>
- </svg>
- </Button>
- <Button
- variant="outline"
- size="sm"
- class="h-8 w-8 p-0"
- onclick={() => handlePageChange(currentPage + 1)}
- disabled={currentPage >= totalPages || loading}
- >
- <span class="sr-only">Go to next page</span>
- <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none" class="lucide lucide-chevron-right h-4 w-4">
- <path d="M6.1584 3.13508C6.35985 2.94621 6.67627 2.95642 6.86514 3.15788L10.6151 7.15788C10.7954 7.3502 10.7954 7.64949 10.6151 7.84182L6.86514 11.8418C6.67627 12.0433 6.35985 12.0535 6.1584 11.8646C5.95694 11.6757 5.94673 11.3593 6.1356 11.1579L9.565 7.49985L6.1356 3.84182C5.94673 3.64036 5.95694 3.32394 6.1584 3.13508Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path>
- </svg>
- </Button>
- </div>
- </div>
- </div>
+ <PaginationFooter
+ {currentPage}
+ {totalPages}
+ {pageSize}
+ totalItems={total}
+ itemsShown={occurrences.length}
+ onPageChange={handlePageChange}
+ onPageSizeChange={handlePageSizeChange}
+ {loading}
+ itemLabel="event"
+ />
{/if}
</div>
diff --git a/frontend/src/routes/transactions/+page.svelte b/frontend/src/routes/transactions/+page.svelte
index 6763b63f..0ebf99e8 100644
--- a/frontend/src/routes/transactions/+page.svelte
+++ b/frontend/src/routes/transactions/+page.svelte
@@ -2,13 +2,15 @@
import { onMount, onDestroy } from 'svelte';
import { browser } from '$app/environment';
import { api } from '$lib/api';
+ import { formatDuration } from '$lib/utils/formatters';
import * as Table from "$lib/components/ui/table";
import { Button } from "$lib/components/ui/button";
import { LoadingCircle } from "$lib/components/ui/loading-circle";
import * as Select from "$lib/components/ui/select";
- import { TriangleAlert } from "@lucide/svelte";
import { TracewayTableHeader } from "$lib/components/ui/traceway-table-header";
+ import { ImpactBadge } from "$lib/components/ui/impact-badge";
import { TableEmptyState } from "$lib/components/ui/table-empty-state";
+ import { PaginationFooter } from "$lib/components/ui/pagination-footer";
import { TimeRangePicker } from "$lib/components/ui/time-range-picker";
import { CalendarDate, getLocalTimeZone, today } from "@internationalized/date";
import { projectsState } from '$lib/state/projects.svelte';
@@ -186,17 +188,6 @@
loadData(true);
}
- function formatDuration(nanoseconds: number): string {
- const ms = nanoseconds / 1_000_000;
- if (ms < 1) {
- return `${(nanoseconds / 1000).toFixed(0)}µs`;
- } else if (ms < 1000) {
- return `${ms.toFixed(0)}ms`;
- } else {
- return `${(ms / 1000).toFixed(1)}s`;
- }
- }
-
// Format count with k/m suffixes
function formatCount(count: number): string {
if (count >= 1_000_000) {
@@ -257,8 +248,8 @@
}
}
- function handlePageSizeChange(newPageSize: string) {
- pageSize = parseInt(newPageSize);
+ function handlePageSizeChange(newPageSize: number) {
+ pageSize = newPageSize;
page = 1;
loadData(false); // Don't push to history for pagination
}
@@ -416,21 +407,7 @@
{formatDuration(endpoint.p95Duration)}
</Table.Cell>
<Table.Cell class="text-right">
- {#if impactLevel === 'critical'}
- <span class="inline-flex items-center gap-1 rounded-full bg-red-500/15 px-2 py-0.5 text-xs font-medium text-red-600 dark:text-red-400">
- <TriangleAlert class="h-3 w-3" />
- Critical
- </span>
- {:else if impactLevel === 'high'}
- <span class="inline-flex items-center gap-1 rounded-full bg-orange-500/15 px-2 py-0.5 text-xs font-medium text-orange-600 dark:text-orange-400">
- <TriangleAlert class="h-3 w-3" />
- High
- </span>
- {:else if impactLevel === 'medium'}
- <span class="inline-flex items-center gap-1 rounded-full bg-yellow-500/15 px-2 py-0.5 text-xs font-medium text-yellow-600 dark:text-yellow-500">
- Medium
- </span>
- {/if}
+ <ImpactBadge level={impactLevel} />
</Table.Cell>
</Table.Row>
{/each}
@@ -440,61 +417,14 @@
</div>
<!-- Pagination Footer -->
- <div class="flex items-center justify-between px-2">
- <div class="flex-1 text-sm text-muted-foreground">
- {total} endpoint(s) found.
- </div>
- <div class="flex items-center space-x-6 lg:space-x-8">
- <div class="flex items-center space-x-2">
- <p class="text-sm font-medium">Rows per page</p>
- <Select.Root
- type="single"
- value={pageSize.toString()}
- onValueChange={(v) => {
- if (v) {
- handlePageSizeChange(v);
- }
- }}
- >
- <Select.Trigger class="h-8 w-[70px]">
- {pageSizeLabel}
- </Select.Trigger>
- <Select.Content side="top">
- {#each pageSizeOptions as option}
- <Select.Item value={option.value} label={option.label}>{option.label}</Select.Item>
- {/each}
- </Select.Content>
- </Select.Root>
- </div>
- <div class="flex w-[100px] items-center justify-center text-sm font-medium">
- Page {page} of {totalPages || 1}
- </div>
- <div class="flex items-center space-x-2">
- <Button
- variant="outline"
- size="sm"
- class="h-8 w-8 p-0"
- onclick={() => handlePageChange(page - 1)}
- disabled={page <= 1 || loading}
- >
- <span class="sr-only">Go to previous page</span>
- <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none" class="h-4 w-4">
- <path d="M8.84182 3.13514C9.04327 3.32401 9.05348 3.64042 8.86462 3.84188L5.43521 7.49991L8.86462 11.1579C9.05348 11.3594 9.04327 11.6758 8.84182 11.8647C8.64036 12.0535 8.32394 12.0433 8.13508 11.8419L4.38508 7.84188C4.20477 7.64955 4.20477 7.35027 4.38508 7.15794L8.13508 3.15794C8.32394 2.95648 8.64036 2.94628 8.84182 3.13514Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path>
- </svg>
- </Button>
- <Button
- variant="outline"
- size="sm"
- class="h-8 w-8 p-0"
- onclick={() => handlePageChange(page + 1)}
- disabled={page >= totalPages || loading}
- >
- <span class="sr-only">Go to next page</span>
- <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15" fill="none" class="h-4 w-4">
- <path d="M6.1584 3.13508C6.35985 2.94621 6.67627 2.95642 6.86514 3.15788L10.6151 7.15788C10.7954 7.3502 10.7954 7.64949 10.6151 7.84182L6.86514 11.8418C6.67627 12.0433 6.35985 12.0535 6.1584 11.8646C5.95694 11.6757 5.94673 11.3593 6.1356 11.1579L9.565 7.49985L6.1356 3.84182C5.94673 3.64036 5.95694 3.32394 6.1584 3.13508Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path>
- </svg>
- </Button>
- </div>
- </div>
- </div>
+ <PaginationFooter
+ currentPage={page}
+ {totalPages}
+ {pageSize}
+ totalItems={total}
+ onPageChange={handlePageChange}
+ onPageSizeChange={handlePageSizeChange}
+ {loading}
+ itemLabel="endpoint"
+ />
</div>
diff --git a/frontend/src/routes/transactions/[endpoint]/+page.svelte b/frontend/src/routes/transactions/[endpoint]/+page.svelte
index dbf24aaa..f4bb8f93 100644
--- a/frontend/src/routes/transactions/[endpoint]/+page.svelte
+++ b/frontend/src/routes/transactions/[endpoint]/+page.svelte
@@ -2,6 +2,7 @@
import { onMount } from 'svelte';
import { goto } from '$app/navigation';
import { api } from '$lib/api';
+ import { formatDuration, formatDurationMs, getStatusColor } from '$lib/utils/formatters';
import * as Table from "$lib/components/ui/table";
import { Button } from "$lib/components/ui/button";
import { LoadingCircle } from "$lib/components/ui/loading-circle";
@@ -143,27 +144,6 @@
loadData();
}
- function formatDuration(nanoseconds: number): string {
- const ms = nanoseconds / 1_000_000;
- if (ms < 1) {
- return `${(nanoseconds / 1000).toFixed(2)}µs`;
- } else if (ms < 1000) {
- return `${ms.toFixed(2)}ms`;
- } else {
- return `${(ms / 1000).toFixed(2)}s`;
- }
- }
-
- function formatDurationMs(ms: number): string {
- if (ms < 1) {
- return `${(ms * 1000).toFixed(0)} µs`;
- } else if (ms < 1000) {
- return `${ms.toFixed(0)} ms`;
- } else {
- return `${(ms / 1000).toFixed(2)} s`;
- }
- }
-
function formatBytes(bytes: number): string {
if (bytes < 1024) {
return `${bytes} B`;
@@ -174,18 +154,6 @@
}
}
- function getStatusColor(statusCode: number): string {
- if (statusCode >= 200 && statusCode < 300) {
- return 'text-green-500';
- } else if (statusCode >= 300 && statusCode < 400) {
- return 'text-blue-500';
- } else if (statusCode >= 400 && statusCode < 500) {
- return 'text-yellow-500';
- } else {
- return 'text-red-500';
- }
- }
-
async function loadData() {
loading = true;
error = '';
diff --git a/frontend/src/routes/transactions/[endpoint]/[transactionId]/+page.svelte b/frontend/src/routes/transactions/[endpoint]/[transactionId]/+page.svelte
index a2cc6d65..5768f210 100644
--- a/frontend/src/routes/transactions/[endpoint]/[transactionId]/+page.svelte
+++ b/frontend/src/routes/transactions/[endpoint]/[transactionId]/+page.svelte
@@ -2,6 +2,7 @@
import { onMount } from 'svelte';
import { goto } from '$app/navigation';
import { api } from '$lib/api';
+ import { formatDuration, getStatusColor } from '$lib/utils/formatters';
import { Button } from '$lib/components/ui/button';
import * as Card from '$lib/components/ui/card';
import { LoadingCircle } from '$lib/components/ui/loading-circle';
@@ -9,6 +10,7 @@
import { projectsState } from '$lib/state/projects.svelte';
import { ArrowLeft, ArrowRight, TriangleAlert } from 'lucide-svelte';
import { LabelValue } from '$lib/components/ui/label-value';
+ import { ContextGrid } from '$lib/components/ui/context-grid';
import SegmentWaterfall from '$lib/components/segments/segment-waterfall.svelte';
import SegmentEmptyState from '$lib/components/segments/segment-empty-state.svelte';
import type { TransactionDetailResponse } from '$lib/types/segments';
@@ -45,17 +47,6 @@
}
}
- function formatDuration(nanoseconds: number): string {
- const ms = nanoseconds / 1_000_000;
- if (ms < 1) {
- return `${(nanoseconds / 1000).toFixed(2)}us`;
- } else if (ms < 1000) {
- return `${ms.toFixed(2)}ms`;
- } else {
- return `${(ms / 1000).toFixed(2)}s`;
- }
- }
-
function formatBytes(bytes: number): string {
if (bytes < 1024) {
return `${bytes} B`;
@@ -66,13 +57,6 @@
}
}
- function getStatusColor(statusCode: number): string {
- if (statusCode >= 200 && statusCode < 300) return 'text-green-500';
- if (statusCode >= 300 && statusCode < 400) return 'text-blue-500';
- if (statusCode >= 400 && statusCode < 500) return 'text-yellow-500';
- return 'text-red-500';
- }
-
function getBackUrl(): string {
const params = new URLSearchParams();
if (data.preset) {
@@ -192,14 +176,7 @@
<hr class="border-border" />
<div>
<p class="mb-3 text-sm font-medium">Context</p>
- <div class="grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3">
- {#each Object.entries(response.transaction.scope).sort( (a, b) => a[0].localeCompare(b[0]) ) as [key, value]}
- <div class="flex flex-col gap-1 rounded-md bg-muted p-3">
- <span class="text-xs font-medium text-muted-foreground">{key}</span>
- <span class="font-mono text-sm break-all">{value}</span>
- </div>
- {/each}
- </div>
+ <ContextGrid scope={response.transaction.scope} />
</div>
{/if}
</Card.Content>