Skip to content

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

feat: updated ui to correctly display flutter stack traces

ddux953570e829c2
diff --git a/frontend/src/lib/components/issues/events-table.svelte b/frontend/src/lib/components/issues/events-table.svelte
index f8147ca7..53397642 100644
--- a/frontend/src/lib/components/issues/events-table.svelte
+++ b/frontend/src/lib/components/issues/events-table.svelte
@@ -8,6 +8,7 @@
import type { ExceptionOccurrence } from '$lib/types/exceptions';
import { formatDateTime } from '$lib/utils/formatters';
import { getTimezone } from '$lib/state/timezone.svelte';
+ import { projectsState, isFrontendFramework } from '$lib/state/projects.svelte';
interface Props {
occurrences: ExceptionOccurrence[];
@@ -30,6 +31,11 @@
}: Props = $props();
const tz = $derived(timezone ?? getTimezone());
+ const isFrontend = $derived(
+ projectsState.currentProject?.framework
+ ? isFrontendFramework(projectsState.currentProject.framework)
+ : false
+ );
function getRowUrl(occurrence: ExceptionOccurrence): string {
return `/issues/${exceptionHash}/${occurrence.id}`;
@@ -55,6 +61,7 @@
label="Recorded At"
tooltip="When this occurrence was recorded"
/>
+ {#if !isFrontend}
<TracewayTableHeader
label="Server"
tooltip="Server instance where error occurred"
@@ -63,12 +70,13 @@
label="Trace"
tooltip="Trace ID if this occurred during a request"
/>
+ {/if}
</Table.Row>
</Table.Header>
{/if}
<Table.Body>
{#if occurrences.length === 0}
- <TableEmptyState colspan={3} message="No occurrences found." />
+ <TableEmptyState colspan={isFrontend ? 1 : 3} message="No occurrences found." />
{:else}
{#each occurrences as occurrence}
<Table.Row
@@ -81,16 +89,18 @@
<span class="ml-2 text-xs text-muted-foreground">(current)</span>
{/if}
</Table.Cell>
+ {#if !isFrontend}
<Table.Cell class="font-mono text-sm text-muted-foreground">
{occurrence.serverName || '-'}
</Table.Cell>
<Table.Cell class="font-mono text-sm">
{occurrence.traceId || '-'}
</Table.Cell>
+ {/if}
</Table.Row>
{/each}
{#if hasMore && showViewAll}
- <ViewAllTableRow colspan={3} href={`/issues/${exceptionHash}/events`} label={`View all ${total} events`} />
+ <ViewAllTableRow colspan={isFrontend ? 1 : 3} href={`/issues/${exceptionHash}/events`} label={`View all ${total} events`} />
{/if}
{/if}
</Table.Body>
diff --git a/frontend/src/lib/utils/stack-trace-parser.ts b/frontend/src/lib/utils/stack-trace-parser.ts
index ec660a52..aae1a388 100644
--- a/frontend/src/lib/utils/stack-trace-parser.ts
+++ b/frontend/src/lib/utils/stack-trace-parser.ts
@@ -19,42 +19,55 @@ export type ParsedStackTrace = {
};
function extractPackageName(location: string): string {
- const match = location.match(/node_modules\/([^/]+)/);
- return match ? match[1] : 'library';
+ const nodeMatch = location.match(/node_modules\/([^/]+)/);
+ if (nodeMatch) return nodeMatch[1];
+
+ const dartMatch = location.match(/^(package:[^/]+|dart:[^/]+)/);
+ if (dartMatch) return dartMatch[1];
+
+ return 'library';
}
export function parseStackTrace(raw: string): ParsedStackTrace {
const lines = raw.split('\n');
const frames: StackFrame[] = [];
let firstFrameIndex = -1;
+ let firstFuncNameIndex = -1;
- const locationPattern = /^\s{4}.+:\d+:\d+$/;
+ const locationPattern = /^\s*.+:\d+:\d+$/;
for (let i = 0; i < lines.length; i++) {
if (locationPattern.test(lines[i])) {
- if (firstFrameIndex === -1) firstFrameIndex = i;
-
const location = lines[i].trim();
let functionName: string | null = null;
- if (i > 0) {
- const prevLine = lines[i - 1].trim();
- if (prevLine.endsWith('()')) {
+ for (let j = i - 1; j >= 0; j--) {
+ const prevLine = lines[j].trim();
+ if (prevLine === '') continue;
+ if (!locationPattern.test(lines[j])) {
functionName = prevLine;
+ if (firstFrameIndex === -1) firstFuncNameIndex = j;
}
+ break;
}
+ if (firstFrameIndex === -1) firstFrameIndex = i;
+
frames.push({
functionName,
location,
- isLibrary: location.includes('node_modules')
+ isLibrary: location.includes('node_modules') ||
+ /^(package:flutter\/|dart:|package:collection\/)/.test(location)
});
}
}
+ const errorEndIndex = firstFrameIndex === -1
+ ? lines.length
+ : firstFuncNameIndex !== -1 ? firstFuncNameIndex : firstFrameIndex;
const errorMessage = firstFrameIndex === -1
? raw.trim()
- : lines.slice(0, firstFrameIndex - (frames[0]?.functionName ? 1 : 0)).join('\n').trim();
+ : lines.slice(0, errorEndIndex).join('\n').trim();
const groups: FrameGroup[] = [];
diff --git a/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte b/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
index 8379893d..25033906 100644
--- a/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
+++ b/frontend/src/routes/issues/[exceptionHash]/events/+page.svelte
@@ -13,7 +13,7 @@
import * as Select from "$lib/components/ui/select";
import { LoadingCircle } from "$lib/components/ui/loading-circle";
import { ErrorDisplay } from "$lib/components/ui/error-display";
- import { projectsState } from '$lib/state/projects.svelte';
+ import { projectsState, isFrontendFramework } 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";
@@ -23,6 +23,11 @@
import { resolve } from '$app/paths';
const timezone = $derived(getTimezone());
+ const isFrontend = $derived(
+ projectsState.currentProject?.framework
+ ? isFrontendFramework(projectsState.currentProject.framework)
+ : false
+ );
type ExceptionGroup = {
exceptionHash: string;
@@ -200,6 +205,7 @@
label="Recorded At"
tooltip="When this occurrence was recorded"
/>
+ {#if !isFrontend}
<TracewayTableHeader
label="Server"
tooltip="Server instance where error occurred"
@@ -208,20 +214,21 @@
label="Trace"
tooltip="Trace ID if this occurred during a request"
/>
+ {/if}
</Table.Row>
</Table.Header>
{/if}
<Table.Body>
{#if loading}
<Table.Row>
- <Table.Cell colspan={3} class="h-48">
+ <Table.Cell colspan={isFrontend ? 1 : 3} class="h-48">
<div class="flex items-center justify-center">
<LoadingCircle size="lg" />
</div>
</Table.Cell>
</Table.Row>
{:else if occurrences.length === 0}
- <TableEmptyState colspan={3} message="No events found." />
+ <TableEmptyState colspan={isFrontend ? 1 : 3} message="No events found." />
{:else}
{#each occurrences as occurrence}
<Table.Row
@@ -229,12 +236,14 @@
onclick={createRowClickHandler(`/issues/${page.params.exceptionHash}/${occurrence.id}`, 'preset', 'from', 'to')}
>
<Table.Cell>{formatDateTime(occurrence.recordedAt, { timezone })}</Table.Cell>
+ {#if !isFrontend}
<Table.Cell class="font-mono text-sm text-muted-foreground">
{occurrence.serverName || '-'}
</Table.Cell>
<Table.Cell class="font-mono text-sm">
{occurrence.traceId || '-'}
</Table.Cell>
+ {/if}
</Table.Row>
{/each}
{/if}