Skip to content

Commit fd35eab

Browse files
committed
chore: show the enriched events in the changeset example
1 parent 1b16eff commit fd35eab

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

.changeset/chat-transport-onevent.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"@trigger.dev/sdk": patch
33
---
44

5-
Add an `onEvent` observability callback to `TriggerChatTransport` / `useTriggerChatTransport` that emits typed lifecycle events: `message-sent` and `message-send-failed` (durable send outcomes with source and duration), `stream-connected`, `first-chunk`, `turn-completed`, and `stream-error`. Together these make send-success metrics, time-to-first-token, and "sent but never answered" watchdogs a few lines of client code.
5+
Add an `onEvent` observability callback to `TriggerChatTransport` / `useTriggerChatTransport` that emits typed lifecycle events: `message-sent` and `message-send-failed` (durable send outcomes with source, duration, payload size, and the append's idempotency key), `stream-connected`, `first-chunk` and `turn-completed` (with built-in time-to-first-token and turn latency via `sinceSendMs`), and `stream-error`. Send-success metrics, TTFT, and "sent but never answered" watchdogs become a few lines of client code.
66

77
```ts
88
const transport = useTriggerChatTransport({
@@ -12,6 +12,12 @@ const transport = useTriggerChatTransport({
1212
if (event.type === "message-sent") {
1313
metrics.timing("chat.send_duration_ms", event.durationMs);
1414
}
15+
if (event.type === "first-chunk") {
16+
metrics.timing("chat.ttft_ms", event.sinceSendMs ?? 0);
17+
}
18+
if (event.type === "message-send-failed") {
19+
metrics.increment("chat.send_failed", { status: event.status });
20+
}
1521
},
1622
});
1723
```

0 commit comments

Comments
 (0)