feat: 添加 Analytics 分析功能(行为追踪、错误码、协议更新)
This commit is contained in:
@@ -6,6 +6,11 @@ extension _ChatBlocEvents on ChatBloc {
|
||||
void _handleEvent(AgUiEvent event) {
|
||||
switch (event.type) {
|
||||
case AgUiEventType.runStarted:
|
||||
final runStartedEvent = event as RunStartedEvent;
|
||||
_recordRunStarted(
|
||||
runId: runStartedEvent.runId,
|
||||
threadId: runStartedEvent.threadId,
|
||||
);
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSending: false,
|
||||
@@ -17,11 +22,14 @@ extension _ChatBlocEvents on ChatBloc {
|
||||
),
|
||||
);
|
||||
case AgUiEventType.runFinished:
|
||||
_trackChatCompleted();
|
||||
_clearRunMetrics();
|
||||
emit(
|
||||
_resetRunState().copyWith(items: _removeToolCallItems(state.items)),
|
||||
);
|
||||
case AgUiEventType.runError:
|
||||
final errorEvent = event as RunErrorEvent;
|
||||
_clearRunMetrics();
|
||||
final isCanceledByUser = errorEvent.code == 'RUN_CANCELED';
|
||||
emit(
|
||||
_resetRunState(
|
||||
@@ -72,6 +80,7 @@ extension _ChatBlocEvents on ChatBloc {
|
||||
}
|
||||
|
||||
void _handleTextMessageEnd(TextMessageEndEvent event) {
|
||||
_recordRunFirstResponse();
|
||||
final timestamp = DateTime.now();
|
||||
final items = _updateOrAddMessage(
|
||||
state.items,
|
||||
|
||||
Reference in New Issue
Block a user