Skip to content

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

Added actions

dduxad5000a19eb6
diff --git a/backend/app/controllers/clientcontrollers/client.controller.go b/backend/app/controllers/clientcontrollers/client.controller.go
index 8613bb19..d7288fcd 100644
--- a/backend/app/controllers/clientcontrollers/client.controller.go
+++ b/backend/app/controllers/clientcontrollers/client.controller.go
@@ -1,10 +1,12 @@
package clientcontrollers
import (
+ "bytes"
"context"
"crypto/sha256"
"database/sql"
"encoding/hex"
+ "encoding/json"
"fmt"
"net/http"
"regexp"
@@ -28,6 +30,19 @@ import (
type clientController struct{}
+// isEmptyRaw reports whether a json.RawMessage carries no meaningful payload —
+// nil, blank, `null`, `[]`, or `{}` all count as empty. Used to drop session
+// recordings that would otherwise just be wasted S3 writes.
+func isEmptyRaw(r json.RawMessage) bool {
+ if len(r) == 0 {
+ return true
+ }
+ trimmed := bytes.TrimSpace(r)
+ return bytes.Equal(trimmed, []byte("null")) ||
+ bytes.Equal(trimmed, []byte("[]")) ||
+ bytes.Equal(trimmed, []byte("{}"))
+}
+
type ReportRequest struct {
CollectionFrames []*clientmodels.CollectionFrame `json:"collectionFrames"`
AppVersion string `json:"appVersion"`
@@ -72,8 +87,12 @@ func (e clientController) Report(c *gin.Context) {
Id uuid.UUID
ProjectId uuid.UUID
ExceptionId uuid.UUID
- Events []byte
- RecordedAt time.Time
+ // Body is the marshaled JSON of the entire ClientSessionRecording
+ // sub-document — events + logs + actions + startedAt/endedAt — exactly
+ // as it lands in S3. App console logs in `logs` are intentionally not
+ // inserted into the OTel logs ClickHouse table; they live only here.
+ Body []byte
+ RecordedAt time.Time
}
var recordingsWork []recordingWork
@@ -153,11 +172,22 @@ func (e clientController) Report(c *gin.Context) {
if !ok {
continue
}
+ // Skip recordings that carry no payload at all. The SDK shouldn't
+ // be sending these, but be defensive — an empty recording would
+ // just be a wasted S3 write and an empty session_recordings row.
+ if isEmptyRaw(sr.Events) && isEmptyRaw(sr.Logs) && isEmptyRaw(sr.Actions) {
+ continue
+ }
+ body, err := json.Marshal(sr)
+ if err != nil {
+ traceway.CaptureException(traceway.NewStackTraceErrorf("failed to marshal session recording: %w", err))
+ continue
+ }
recordingsWork = append(recordingsWork, recordingWork{
Id: uuid.New(),
ProjectId: projectId,
ExceptionId: exceptionId,
- Events: sr.Events,
+ Body: body,
RecordedAt: time.Now().UTC(),
})
}
@@ -247,7 +277,7 @@ func (e clientController) Report(c *gin.Context) {
var successful []models.SessionRecording
for _, rw := range work {
key := fmt.Sprintf("recordings/%s/%s.json", rw.ProjectId, rw.ExceptionId)
- if err := storage.Store.Write(context.Background(), key, rw.Events); err != nil {
+ if err := storage.Store.Write(context.Background(), key, rw.Body); err != nil {
traceway.CaptureException(traceway.NewStackTraceErrorf("failed to write session recording (key=%s): %w", key, err))
continue
}
diff --git a/backend/app/controllers/clientcontrollers/client.controller_test.go b/backend/app/controllers/clientcontrollers/client.controller_test.go
new file mode 100644
index 00000000..394be7c6
--- /dev/null
+++ b/backend/app/controllers/clientcontrollers/client.controller_test.go
@@ -0,0 +1,31 @@
+package clientcontrollers
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestIsEmptyRaw(t *testing.T) {
+ cases := []struct {
+ name string
+ in json.RawMessage
+ want bool
+ }{
+ {"nil", nil, true},
+ {"empty bytes", json.RawMessage(""), true},
+ {"whitespace null", json.RawMessage(" null "), true},
+ {"plain null", json.RawMessage("null"), true},
+ {"empty array", json.RawMessage("[]"), true},
+ {"empty object", json.RawMessage("{}"), true},
+ {"non-empty array", json.RawMessage("[1]"), false},
+ {"non-empty object", json.RawMessage(`{"a":1}`), false},
+ {"string value", json.RawMessage(`"x"`), false},
+ }
+ for _, c := range cases {
+ t.Run(c.name, func(t *testing.T) {
+ if got := isEmptyRaw(c.in); got != c.want {
+ t.Fatalf("isEmptyRaw(%q) = %v, want %v", string(c.in), got, c.want)
+ }
+ })
+ }
+}
diff --git a/backend/app/controllers/exception_stack_trace.controller.go b/backend/app/controllers/exception_stack_trace.controller.go
index f66f18c6..15d9189d 100644
--- a/backend/app/controllers/exception_stack_trace.controller.go
+++ b/backend/app/controllers/exception_stack_trace.controller.go
@@ -1,6 +1,8 @@
package controllers
import (
+ "bytes"
+ "context"
"database/sql"
"encoding/json"
"errors"
@@ -40,10 +42,35 @@ type ExceptionDetailRequest struct {
}
type ExceptionDetailResponse struct {
- Group *models.ExceptionGroup `json:"group"`
- Occurrences []models.ExceptionStackTrace `json:"occurrences"`
- Pagination Pagination `json:"pagination"`
- SessionRecordingEvents json.RawMessage `json:"sessionRecordingEvents,omitempty"`
+ Group *models.ExceptionGroup `json:"group"`
+ Occurrences []models.ExceptionStackTrace `json:"occurrences"`
+ Pagination Pagination `json:"pagination"`
+ SessionRecording json.RawMessage `json:"sessionRecording,omitempty"`
+}
+
+// wrapLegacyRecording handles the case where a recording in blob storage was
+// written before the logs/actions wrapper landed. Older files contain just the
+// events array as their top-level JSON; newer files contain a wrapper object
+// with `events` / `logs` / `actions` / `startedAt` / `endedAt`. Returns the
+// new shape either way so the frontend never branches on file format.
+func wrapLegacyRecording(raw []byte) json.RawMessage {
+ trimmed := bytes.TrimLeft(raw, " \t\r\n")
+ if len(trimmed) > 0 && trimmed[0] == '[' {
+ wrapped := make([]byte, 0, len(raw)+len(`{"events":}`))
+ wrapped = append(wrapped, []byte(`{"events":`)...)
+ wrapped = append(wrapped, raw...)
+ wrapped = append(wrapped, '}')
+ return json.RawMessage(wrapped)
+ }
+ return json.RawMessage(raw)
+}
+
+func loadSessionRecording(ctx context.Context, filePath string) (json.RawMessage, error) {
+ raw, err := storage.Store.Read(ctx, filePath)
+ if err != nil {
+ return nil, err
+ }
+ return wrapLegacyRecording(raw), nil
}
func (e exceptionStackTraceController) FindGrouppedExceptionStackTraces(c *gin.Context) {
@@ -152,9 +179,9 @@ func (e exceptionStackTraceController) FindByHash(c *gin.Context) {
if len(occurrences) > 0 {
filePath, err := repositories.SessionRecordingRepository.FindByExceptionId(c, projectId, occurrences[0].Id)
if err == nil && filePath != "" {
- eventsData, err := storage.Store.Read(c, filePath)
+ recording, err := loadSessionRecording(c, filePath)
if err == nil {
- response.SessionRecordingEvents = json.RawMessage(eventsData)
+ response.SessionRecording = recording
} else {
traceway.CaptureException(fmt.Errorf("failed to read session recording (key=%s): %w", filePath, err))
}
@@ -250,9 +277,9 @@ func (e exceptionStackTraceController) FindById(c *gin.Context) {
filePath, err := repositories.SessionRecordingRepository.FindByExceptionId(c, projectId, exceptionId)
if err == nil && filePath != "" {
- eventsData, err := storage.Store.Read(c, filePath)
+ recording, err := loadSessionRecording(c, filePath)
if err == nil {
- response["sessionRecordingEvents"] = json.RawMessage(eventsData)
+ response["sessionRecording"] = recording
} else {
traceway.CaptureException(fmt.Errorf("failed to read session recording (key=%s): %w", filePath, err))
}
diff --git a/backend/app/controllers/exception_stack_trace_recording_test.go b/backend/app/controllers/exception_stack_trace_recording_test.go
new file mode 100644
index 00000000..7075ee78
--- /dev/null
+++ b/backend/app/controllers/exception_stack_trace_recording_test.go
@@ -0,0 +1,83 @@
+package controllers
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+// Legacy S3 files stored only the events array as their top-level JSON. The
+// new shape is a wrapper object with `events` (and optionally `logs`,
+// `actions`, `startedAt`, `endedAt`). The frontend should always see the
+// wrapper, regardless of when the recording was written.
+func TestWrapLegacyRecording(t *testing.T) {
+ cases := []struct {
+ name string
+ in string
+ // We compare by parsing both sides as JSON to avoid depending on
+ // formatting/whitespace.
+ wantEvents string
+ wantWrap bool
+ }{
+ {
+ name: "legacy events-only array",
+ in: `[{"type":"flutter_video","fps":15}]`,
+ wantEvents: `[{"type":"flutter_video","fps":15}]`,
+ wantWrap: true,
+ },
+ {
+ name: "legacy with leading whitespace",
+ in: "\n [1,2,3]",
+ wantEvents: `[1,2,3]`,
+ wantWrap: true,
+ },
+ {
+ name: "new wrapper object passed through",
+ in: `{"events":[1],"logs":[],"actions":[]}`,
+ wantEvents: `[1]`,
+ wantWrap: false,
+ },
+ {
+ name: "empty new wrapper",
+ in: `{}`,
+ wantEvents: ``, // no events field
+ wantWrap: false,
+ },
+ }
+
+ for _, c := range cases {
+ t.Run(c.name, func(t *testing.T) {
+ got := wrapLegacyRecording([]byte(c.in))
+ var parsed map[string]json.RawMessage
+ if err := json.Unmarshal(got, &parsed); err != nil {
+ t.Fatalf("output not a JSON object: %v\noutput=%s", err, string(got))
+ }
+ events, ok := parsed["events"]
+ if c.wantEvents == "" {
+ if ok {
+ t.Fatalf("expected no events field, got %s", string(events))
+ }
+ return
+ }
+ if !ok {
+ t.Fatalf("missing events field; got %s", string(got))
+ }
+ // Normalize both sides through JSON to ignore whitespace differences.
+ var gotEvents, wantEvents any
+ if err := json.Unmarshal(events, &gotEvents); err != nil {
+ t.Fatalf("events not valid JSON: %v", err)
+ }
+ if err := json.Unmarshal([]byte(c.wantEvents), &wantEvents); err != nil {
+ t.Fatalf("wantEvents not valid JSON: %v", err)
+ }
+ if !jsonEqual(gotEvents, wantEvents) {
+ t.Fatalf("events mismatch:\n got=%v\nwant=%v", gotEvents, wantEvents)
+ }
+ })
+ }
+}
+
+func jsonEqual(a, b any) bool {
+ ja, _ := json.Marshal(a)
+ jb, _ := json.Marshal(b)
+ return string(ja) == string(jb)
+}
diff --git a/backend/app/models/clientmodels/clientmodels.model.go b/backend/app/models/clientmodels/clientmodels.model.go
index 6747048e..c7407456 100644
--- a/backend/app/models/clientmodels/clientmodels.model.go
+++ b/backend/app/models/clientmodels/clientmodels.model.go
@@ -167,6 +167,14 @@ func (c *ClientSpan) ToSpan(traceId uuid.UUID) models.Span {
type ClientSessionRecording struct {
ExceptionId string `json:"exceptionId"`
Events json.RawMessage `json:"events"`
+ // Logs and Actions are opaque to the backend — they ride into S3 alongside
+ // Events without ever being inspected. App console logs from session
+ // recordings are intentionally NOT inserted into the OTel logs ClickHouse
+ // table; they live exclusively inside the S3 recording file.
+ Logs json.RawMessage `json:"logs,omitempty"`
+ Actions json.RawMessage `json:"actions,omitempty"`
+ StartedAt *time.Time `json:"startedAt,omitempty"`
+ EndedAt *time.Time `json:"endedAt,omitempty"`
}
type CollectionFrame struct {
diff --git a/docs/pages/client/flutter/index.mdx b/docs/pages/client/flutter/index.mdx
index 393738ff..16d0e049 100644
--- a/docs/pages/client/flutter/index.mdx
+++ b/docs/pages/client/flutter/index.mdx
@@ -163,28 +163,30 @@ Three kinds of actions are collected:
### Wire shape
-Logs and actions are sent to the backend inside the same `sessionRecordings` entry that carries the MP4 — they're stored under separate `logs` and `actions` arrays:
+Logs and actions are sent to the backend inside the same `sessionRecordings` entry that carries the MP4 — they're stored under separate `logs` and `actions` arrays. Each recording also carries `startedAt` and `endedAt` ISO 8601 timestamps so the backend can align events onto the video timeline (`offsetIntoVideoMs = event.timestamp − recording.startedAt`):
```json
{
"sessionRecordings": [
{
"exceptionId": "...",
+ "startedAt": "2026-04-28T14:30:53.011Z",
+ "endedAt": "2026-04-28T14:31:02.314Z",
"events": [{"type": "flutter_video", "data": "...", "fps": 15}],
"logs": [
- {"type": "log", "timestamp": "...", "level": "info", "message": "user tapped pay"}
+ {"type": "log", "timestamp": "2026-04-28T14:30:54.508Z", "level": "info", "message": "user tapped pay"}
],
"actions": [
- {"type": "navigation", "action": "push", "from": "/", "to": "/cart", "timestamp": "..."},
- {"type": "network", "method": "GET", "url": "...", "statusCode": 200, "durationMs": 86, "timestamp": "..."},
- {"type": "custom", "category": "cart", "name": "add_item", "data": {"sku": "SKU-1"}, "timestamp": "..."}
+ {"type": "navigation", "action": "push", "from": "/", "to": "/cart", "timestamp": "2026-04-28T14:30:53.011Z"},
+ {"type": "network", "method": "GET", "url": "...", "statusCode": 200, "durationMs": 86, "timestamp": "2026-04-28T14:30:54.422Z"},
+ {"type": "custom", "category": "cart", "name": "add_item", "data": {"sku": "SKU-1"}, "timestamp": "2026-04-28T14:30:54.605Z"}
]
}
]
}
```
-A session recording entry is created for every captured exception that has any timeline data — even when `screenCapture: false` and there's no video.
+When the screen recorder is on, `startedAt` and `endedAt` come from the first and last buffered video frames. When there's no video (e.g. `screenCapture: false` with logs/actions only), they fall back to the timestamp range of the buffered events. A session recording entry is created for every captured exception that has any timeline data.
### Network capture on Flutter web
diff --git a/frontend/src/lib/components/issues/event-card.svelte b/frontend/src/lib/components/issues/event-card.svelte
index eb294188..6196b092 100644
--- a/frontend/src/lib/components/issues/event-card.svelte
+++ b/frontend/src/lib/components/issues/event-card.svelte
@@ -2,20 +2,27 @@
import { goto } from '$app/navigation';
import { Button } from '$lib/components/ui/button';
import * as Card from '$lib/components/ui/card';
+ import * as Tabs from '$lib/components/ui/tabs';
import { ArrowRight } from 'lucide-svelte';
- import type { ExceptionOccurrence, LinkedTrace } from '$lib/types/exceptions';
+ import type {
+ ExceptionOccurrence,
+ LinkedTrace,
+ SessionRecording
+ } from '$lib/types/exceptions';
import { formatDuration, getStatusColor, formatDateTime } from '$lib/utils/formatters';
import { getTimezone } from '$lib/state/timezone.svelte';
import { AttributesGrid } from '$lib/components/ui/attributes-grid';
import { LabelValue } from '../ui/label-value';
import { projectsState, isFrontendFramework } from '$lib/state/projects.svelte';
import SessionReplay from './session-replay.svelte';
+ import SessionLogsTable from './session-logs-table.svelte';
+ import SessionActionsTable from './session-actions-table.svelte';
import DistributedTraceCard from '$lib/components/distributed-trace/distributed-trace-card.svelte';
interface Props {
occurrence: ExceptionOccurrence;
linkedTrace: LinkedTrace | null;
- sessionRecordingEvents?: unknown[] | null;
+ sessionRecording?: SessionRecording | null;
title?: string;
description?: string;
timezone?: string;
@@ -24,7 +31,7 @@
let {
occurrence,
linkedTrace,
- sessionRecordingEvents = null,
+ sessionRecording = null,
title = 'Event',
description = 'Details for this specific occurrence',
timezone
@@ -36,18 +43,64 @@
? isFrontendFramework(projectsState.currentProject.framework)
: false
);
+
+ const recordingEvents = $derived(sessionRecording?.events ?? null);
+ const hasReplay = $derived(!!recordingEvents && recordingEvents.length > 0);
+ const logs = $derived(sessionRecording?.logs ?? []);
+ const actions = $derived(sessionRecording?.actions ?? []);
+ const hasLogs = $derived(logs.length > 0);
+ const hasActions = $derived(actions.length > 0);
+ // Logs/actions tables are only meaningful for frontend-framework projects.
+ // Backend / OTel exception pages must look identical to before.
+ const showSessionContext = $derived(isFrontend && (hasLogs || hasActions));
+ const defaultTab = $derived(hasLogs ? 'logs' : 'actions');
</script>
<!-- Session Replay -->
-{#if sessionRecordingEvents && sessionRecordingEvents.length > 0}
+{#if hasReplay}
<Card.Root class="pb-0">
<Card.Header class="gap-0">
<Card.Title>Session Replay</Card.Title>
</Card.Header>
<Card.Content class="p-0">
- {#key sessionRecordingEvents}
- <SessionReplay events={sessionRecordingEvents as any} />
- {/key}
+ {#key recordingEvents}
+ <SessionReplay events={recordingEvents as any} />
+ {/key}
+ </Card.Content>
+ </Card.Root>
+{/if}
+
+<!-- Session Context (logs + actions). Frontend projects only. -->
+{#if showSessionContext}
+ <Card.Root>
+ <Card.Header>
+ <Card.Title>Session Context</Card.Title>
+ <Card.Description>
+ The last seconds of console output and recorded actions before this
+ exception. Times are offsets from the start of the recording.
+ </Card.Description>
+ </Card.Header>
+ <Card.Content>
+ <Tabs.Root value={defaultTab}>
+ <Tabs.List class="mb-4">
+ {#if hasLogs}
+ <Tabs.Trigger value="logs">Logs ({logs.length})</Tabs.Trigger>
+ {/if}
+ {#if hasActions}
+ <Tabs.Trigger value="actions">Actions ({actions.length})</Tabs.Trigger>
+ {/if}
+ </Tabs.List>
+ {#if hasLogs}
+ <Tabs.Content value="logs">
+ <SessionLogsTable {logs} startedAt={sessionRecording?.startedAt} />
+ </Tabs.Content>
+ {/if}
+ {#if hasActions}
+ <Tabs.Content value="actions">
+ <SessionActionsTable {actions} startedAt={sessionRecording?.startedAt} />
+ </Tabs.Content>
+ {/if}
+ </Tabs.Root>
</Card.Content>
</Card.Root>
{/if}
diff --git a/frontend/src/lib/components/issues/session-actions-table.svelte b/frontend/src/lib/components/issues/session-actions-table.svelte
new file mode 100644
index 00000000..ce8d6443
--- /dev/null
+++ b/frontend/src/lib/components/issues/session-actions-table.svelte
@@ -0,0 +1,113 @@
+<script lang="ts">
+ import * as Table from '$lib/components/ui/table';
+ import { TracewayTableHeader } from '$lib/components/ui/traceway-table-header';
+ import { TableEmptyState } from '$lib/components/ui/table-empty-state';
+ import type {
+ SessionActionEvent,
+ SessionNetworkEvent,
+ SessionNavigationEvent,
+ SessionCustomEvent
+ } from '$lib/types/exceptions';
+
+ interface Props {
+ actions: SessionActionEvent[];
+ startedAt?: string;
+ }
+
+ let { actions, startedAt }: Props = $props();
+
+ function formatOffset(timestamp: string): string {
+ if (!startedAt) return timestamp;
+ const start = Date.parse(startedAt);
+ const t = Date.parse(timestamp);
+ if (!Number.isFinite(start) || !Number.isFinite(t)) return timestamp;
+ const deltaMs = t - start;
+ if (Math.abs(deltaMs) >= 1000) {
+ const sign = deltaMs >= 0 ? '+' : '-';
+ return `${sign}${(Math.abs(deltaMs) / 1000).toFixed(2)}s`;
+ }
+ const sign = deltaMs >= 0 ? '+' : '-';
+ return `${sign}${Math.abs(deltaMs)}ms`;
+ }
+
+ function typeColor(type: SessionActionEvent['type']): string {
+ switch (type) {
+ case 'network':
+ return 'text-sky-600 dark:text-sky-400';
+ case 'navigation':
+ return 'text-violet-600 dark:text-violet-400';
+ case 'custom':
+ return 'text-amber-600 dark:text-amber-400';
+ default:
+ return 'text-foreground';
+ }
+ }
+
+ function summary(a: SessionActionEvent): string {
+ switch (a.type) {
+ case 'network': {
+ const n = a as SessionNetworkEvent;
+ const status = n.statusCode ?? (n.error ? 'ERR' : '?');
+ return `${n.method} ${n.url} → ${status} (${n.durationMs}ms)`;
+ }
+ case 'navigation': {
+ const n = a as SessionNavigationEvent;
+ const from = n.from ?? '?';
+ const to = n.to ?? '?';
+ return `${n.action}: ${from} → ${to}`;
+ }
+ case 'custom': {
+ const c = a as SessionCustomEvent;
+ const data = c.data ? ` ${JSON.stringify(c.data)}` : '';
+ return `${c.category}/${c.name}${data}`;
+ }
+ }
+ }
+</script>
+
+<div class="rounded-md border overflow-hidden">
+ <Table.Root>
+ {#if actions.length > 0}
+ <Table.Header>
+ <Table.Row>
+ <TracewayTableHeader
+ label="Time"
+ tooltip="Offset from the start of the session recording"
+ class="w-[110px]"
+ />
+ <TracewayTableHeader
+ label="Type"
+ tooltip="Network / navigation / custom"
+ class="w-[110px]"
+ />
+ <TracewayTableHeader
+ label="Details"
+ tooltip="One-line summary; full payload visible on hover"
+ />
+ </Table.Row>
+ </Table.Header>
+ {/if}
+ <Table.Body>
+ {#if actions.length === 0}
+ <TableEmptyState colspan={3} message="No actions captured for this session." />
+ {:else}
+ {#each actions as entry}
+ <Table.Row>
+ <Table.Cell class="font-mono text-xs text-muted-foreground tabular-nums">
+ {formatOffset(entry.timestamp)}
+ </Table.Cell>
+ <Table.Cell class="font-mono text-xs uppercase {typeColor(entry.type)}">
+ {entry.type}
+ </Table.Cell>
+ <Table.Cell
+ class="font-mono text-xs truncate max-w-[600px]"
+ title={summary(entry)}
+ >
+ {summary(entry)}
+ </Table.Cell>
+ </Table.Row>
+ {/each}
+ {/if}
+ </Table.Body>
+ </Table.Root>
+</div>
diff --git a/frontend/src/lib/components/issues/session-logs-table.svelte b/frontend/src/lib/components/issues/session-logs-table.svelte
new file mode 100644
index 00000000..b5fb838a
--- /dev/null
+++ b/frontend/src/lib/components/issues/session-logs-table.svelte
@@ -0,0 +1,84 @@
+<script lang="ts">
+ import * as Table from '$lib/components/ui/table';
+ import { TracewayTableHeader } from '$lib/components/ui/traceway-table-header';
+ import { TableEmptyState } from '$lib/components/ui/table-empty-state';
+ import type { SessionLogEvent, SessionLogLevel } from '$lib/types/exceptions';
+
+ interface Props {
+ logs: SessionLogEvent[];
+ startedAt?: string;
+ }
+
+ let { logs, startedAt }: Props = $props();
+
+ function formatOffset(timestamp: string): string {
+ if (!startedAt) return timestamp;
+ const start = Date.parse(startedAt);
+ const t = Date.parse(timestamp);
+ if (!Number.isFinite(start) || !Number.isFinite(t)) return timestamp;
+ const deltaMs = t - start;
+ if (Math.abs(deltaMs) >= 1000) {
+ const sign = deltaMs >= 0 ? '+' : '-';
+ return `${sign}${(Math.abs(deltaMs) / 1000).toFixed(2)}s`;
+ }
+ const sign = deltaMs >= 0 ? '+' : '-';
+ return `${sign}${Math.abs(deltaMs)}ms`;
+ }
+
+ function levelColor(level: SessionLogLevel): string {
+ switch (level) {
+ case 'error':
+ return 'text-destructive';
+ case 'warn':
+ return 'text-yellow-600 dark:text-yellow-500';
+ case 'debug':
+ return 'text-muted-foreground';
+ default:
+ return 'text-foreground';
+ }
+ }
+</script>
+
+<div class="rounded-md border overflow-hidden">
+ <Table.Root>
+ {#if logs.length > 0}
+ <Table.Header>
+ <Table.Row>
+ <TracewayTableHeader
+ label="Time"
+ tooltip="Offset from the start of the session recording"
+ class="w-[110px]"
+ />
+ <TracewayTableHeader
+ label="Level"
+ tooltip="Console severity (debug / info / warn / error)"
+ class="w-[80px]"
+ />
+ <TracewayTableHeader label="Message" tooltip="The console line as captured" />
+ </Table.Row>
+ </Table.Header>
+ {/if}
+ <Table.Body>
+ {#if logs.length === 0}
+ <TableEmptyState colspan={3} message="No logs captured for this session." />
+ {:else}
+ {#each logs as entry}
+ <Table.Row>
+ <Table.Cell class="font-mono text-xs text-muted-foreground tabular-nums">
+ {formatOffset(entry.timestamp)}
+ </Table.Cell>
+ <Table.Cell class="font-mono text-xs uppercase {levelColor(entry.level)}">
+ {entry.level}
+ </Table.Cell>
+ <Table.Cell
+ class="font-mono text-xs whitespace-pre-wrap break-all"
+ title={entry.message}
+ >
+ {entry.message}
+ </Table.Cell>
+ </Table.Row>
+ {/each}
+ {/if}
+ </Table.Body>
+ </Table.Root>
+</div>
diff --git a/frontend/src/lib/types/exceptions.ts b/frontend/src/lib/types/exceptions.ts
index f0d8a565..92b22d64 100644
--- a/frontend/src/lib/types/exceptions.ts
+++ b/frontend/src/lib/types/exceptions.ts
@@ -30,3 +30,62 @@ export type LinkedTrace = {
traceType: 'endpoint' | 'task';
distributedTraceId?: string;
};
+
+// Session recording shape returned by the backend's exception detail endpoints.
+// Mirrors the wire format produced by the Flutter and JS SDKs.
+
+export type SessionLogLevel = 'debug' | 'info' | 'warn' | 'error';
+
+export interface SessionLogEvent {
+ type: 'log';
+ timestamp: string;
+ level: SessionLogLevel;
+ message: string;
+}
+
+export interface SessionNetworkEvent {
+ type: 'network';
+ timestamp: string;
+ method: string;
+ url: string;
+ durationMs: number;
+ statusCode?: number;
+ requestBytes?: number;
+ responseBytes?: number;
+ error?: string;
+}
+
+export interface SessionNavigationEvent {
+ type: 'navigation';
+ timestamp: string;
+ /** push | pop | replace | remove */
+ action: string;
+ from?: string;
+ to?: string;
+}
+
+export interface SessionCustomEvent {
+ type: 'custom';
+ timestamp: string;
+ category: string;
+ name: string;
+ data?: Record<string, unknown>;
+}
+
+export type SessionActionEvent =
+ | SessionNetworkEvent
+ | SessionNavigationEvent
+ | SessionCustomEvent;
+
+export interface SessionRecording {
+ /** rrweb events (web SDKs) or MP4 chunk descriptors (Flutter SDK). */
+ events?: unknown[];
+ /** Console output snapshotted at exception capture (last ~10s, ≤200). */
+ logs?: SessionLogEvent[];
+ /** Network / navigation / custom actions snapshotted with the exception. */
+ actions?: SessionActionEvent[];
+ /** ISO 8601 timestamp of the first frame / first event. */
+ startedAt?: string;
+ /** ISO 8601 timestamp of the last frame / last event. */
+ endedAt?: string;
+}
diff --git a/frontend/src/routes/issues/[exceptionHash]/+page.svelte b/frontend/src/routes/issues/[exceptionHash]/+page.svelte
index 0e01644e..5ec84908 100644
--- a/frontend/src/routes/issues/[exceptionHash]/+page.svelte
+++ b/frontend/src/routes/issues/[exceptionHash]/+page.svelte
@@ -14,7 +14,8 @@
import type {
ExceptionGroup,
ExceptionOccurrence,
- LinkedTrace
+ LinkedTrace,
+ SessionRecording
} from '$lib/types/exceptions';
import { createSmartBackHandler } from '$lib/utils/back-navigation';
import { resolve } from '$app/paths';
@@ -26,7 +27,7 @@
let notFound = $state(false);
let total = $state(0);
let linkedTrace = $state<LinkedTrace | null>(null);
- let sessionRecordingEvents = $state<unknown[] | null>(null);
+ let sessionRecording = $state<SessionRecording | null>(null);
let showArchiveDialog = $state(false);
let archiving = $state(false);
@@ -41,7 +42,7 @@
error = '';
notFound = false;
linkedTrace = null;
- sessionRecordingEvents = null;
+ sessionRecording = null;
try {
const exceptionHash = page.params.exceptionHash;
@@ -59,7 +60,7 @@
group = response.group;
occurrences = response.occurrences || [];
total = response.pagination.total;
- sessionRecordingEvents = response.sessionRecordingEvents ?? null;
+ sessionRecording = response.sessionRecording ?? null;
// Load linked trace if the latest occurrence has a traceId
const firstOccurrence = occurrences[0];
@@ -170,7 +171,7 @@
<EventCard
occurrence={latestOccurrence}
{linkedTrace}
- {sessionRecordingEvents}
+ {sessionRecording}
title="Last Event"
description="Details from the most recent occurrence of this exception"
/>
diff --git a/frontend/src/routes/issues/[exceptionHash]/[exceptionId]/+page.svelte b/frontend/src/routes/issues/[exceptionHash]/[exceptionId]/+page.svelte
index 3f327d49..610d853c 100644
--- a/frontend/src/routes/issues/[exceptionHash]/[exceptionId]/+page.svelte
+++ b/frontend/src/routes/issues/[exceptionHash]/[exceptionId]/+page.svelte
@@ -6,7 +6,7 @@
import { getTimezone } from '$lib/state/timezone.svelte';
import { formatDateTime } from '$lib/utils/formatters';
import { StackTraceCard, EventCard, EventsTable, PageHeader } from '$lib/components/issues';
- import type { ExceptionOccurrence, LinkedTrace } from '$lib/types/exceptions';
+ import type { ExceptionOccurrence, LinkedTrace, SessionRecording } from '$lib/types/exceptions';
import { createSmartBackHandler } from '$lib/utils/back-navigation';
import { resolve } from '$app/paths';
import ArchiveConfirmationDialog from '$lib/components/archive-confirmation-dialog.svelte';
@@ -24,7 +24,7 @@
let notFound = $state(false);
let total = $state(0);
let linkedTrace = $state<LinkedTrace | null>(null);
- let sessionRecordingEvents = $state<unknown[] | null>(null);
+ let sessionRecording = $state<SessionRecording | null>(null);
let showArchiveDialog = $state(false);
let archiving = $state(false);
@@ -39,13 +39,13 @@
error = '';
notFound = false;
linkedTrace = null;
- sessionRecordingEvents = null;
+ sessionRecording = null;
try {
// Load the specific exception by ID
const exceptionResponse = await api.post(`/exception-stack-traces/by-id/${data.exceptionId}`, {}, { projectId: projectsState.currentProjectId ?? undefined });
occurrence = exceptionResponse.exception;
- sessionRecordingEvents = exceptionResponse.sessionRecordingEvents ?? null;
+ sessionRecording = exceptionResponse.sessionRecording ?? null;
if (!occurrence) {
notFound = true;
@@ -174,7 +174,7 @@
<EventCard
{occurrence}
{linkedTrace}
- {sessionRecordingEvents}
+ {sessionRecording}
title="Event"
description="Details for this specific occurrence"
/>