Skip to content

Commit 259fb01

Browse files
committed
chore: tighten the changeset
1 parent 27fcb0d commit 259fb01

1 file changed

Lines changed: 5 additions & 16 deletions

File tree

.changeset/chat-transport-onevent.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,11 @@
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, 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.
5+
Add an `onEvent` callback to `TriggerChatTransport` / `useTriggerChatTransport` that emits typed lifecycle events for sends, stream connects, first chunk, and turn completion. Send-success metrics, time-to-first-token, and "sent but never answered" watchdogs become a few lines of client code.
66

77
```ts
8-
const transport = useTriggerChatTransport({
9-
task: "my-chat",
10-
accessToken,
11-
onEvent: (event) => {
12-
if (event.type === "message-sent") {
13-
metrics.timing("chat.send_duration_ms", event.durationMs);
14-
}
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-
}
21-
},
22-
});
8+
onEvent: (event) => {
9+
if (event.type === "message-sent") metrics.timing("chat.send_ms", event.durationMs);
10+
if (event.type === "first-chunk") metrics.timing("chat.ttft_ms", event.sinceSendMs ?? 0);
11+
},
2312
```

0 commit comments

Comments
 (0)