telemetry_events: Rename AssistantEvent
to AssistantEventData
(#28133)
This PR renames the `AssistantEvent` type to `AssistantEventData`, as it no longer represents the event itself, just the data needed to construct it. Pulling out of https://github.com/zed-industries/zed/pull/25179. Release Notes: - N/A
This commit is contained in:
parent
8ab252c42d
commit
03aadb4e5b
10 changed files with 25 additions and 25 deletions
|
@ -28,7 +28,7 @@ use std::{
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
|
use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
|
||||||
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};
|
use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase};
|
||||||
|
|
||||||
pub struct BufferCodegen {
|
pub struct BufferCodegen {
|
||||||
alternatives: Vec<Entity<CodegenAlternative>>,
|
alternatives: Vec<Entity<CodegenAlternative>>,
|
||||||
|
@ -601,7 +601,7 @@ impl CodegenAlternative {
|
||||||
|
|
||||||
let error_message = result.as_ref().err().map(|error| error.to_string());
|
let error_message = result.as_ref().err().map(|error| error.to_string());
|
||||||
report_assistant_event(
|
report_assistant_event(
|
||||||
AssistantEvent {
|
AssistantEventData {
|
||||||
conversation_id: None,
|
conversation_id: None,
|
||||||
message_id,
|
message_id,
|
||||||
kind: AssistantKind::Inline,
|
kind: AssistantKind::Inline,
|
||||||
|
|
|
@ -31,7 +31,7 @@ use project::LspAction;
|
||||||
use project::{CodeAction, ProjectTransaction};
|
use project::{CodeAction, ProjectTransaction};
|
||||||
use prompt_store::PromptBuilder;
|
use prompt_store::PromptBuilder;
|
||||||
use settings::{Settings, SettingsStore};
|
use settings::{Settings, SettingsStore};
|
||||||
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};
|
use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase};
|
||||||
use terminal_view::{TerminalView, terminal_panel::TerminalPanel};
|
use terminal_view::{TerminalView, terminal_panel::TerminalPanel};
|
||||||
use text::{OffsetRangeExt, ToPoint as _};
|
use text::{OffsetRangeExt, ToPoint as _};
|
||||||
use ui::prelude::*;
|
use ui::prelude::*;
|
||||||
|
@ -402,7 +402,7 @@ impl InlineAssistant {
|
||||||
codegen_ranges.push(anchor_range);
|
codegen_ranges.push(anchor_range);
|
||||||
|
|
||||||
if let Some(model) = LanguageModelRegistry::read_global(cx).inline_assistant_model() {
|
if let Some(model) = LanguageModelRegistry::read_global(cx).inline_assistant_model() {
|
||||||
self.telemetry.report_assistant_event(AssistantEvent {
|
self.telemetry.report_assistant_event(AssistantEventData {
|
||||||
conversation_id: None,
|
conversation_id: None,
|
||||||
kind: AssistantKind::Inline,
|
kind: AssistantKind::Inline,
|
||||||
phase: AssistantPhase::Invoked,
|
phase: AssistantPhase::Invoked,
|
||||||
|
@ -987,7 +987,7 @@ impl InlineAssistant {
|
||||||
.map(|language| language.name())
|
.map(|language| language.name())
|
||||||
});
|
});
|
||||||
report_assistant_event(
|
report_assistant_event(
|
||||||
AssistantEvent {
|
AssistantEventData {
|
||||||
conversation_id: None,
|
conversation_id: None,
|
||||||
kind: AssistantKind::Inline,
|
kind: AssistantKind::Inline,
|
||||||
message_id,
|
message_id,
|
||||||
|
|
|
@ -6,7 +6,7 @@ use language_model::{
|
||||||
ConfiguredModel, LanguageModelRegistry, LanguageModelRequest, report_assistant_event,
|
ConfiguredModel, LanguageModelRegistry, LanguageModelRequest, report_assistant_event,
|
||||||
};
|
};
|
||||||
use std::{sync::Arc, time::Instant};
|
use std::{sync::Arc, time::Instant};
|
||||||
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};
|
use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase};
|
||||||
use terminal::Terminal;
|
use terminal::Terminal;
|
||||||
|
|
||||||
pub struct TerminalCodegen {
|
pub struct TerminalCodegen {
|
||||||
|
@ -79,7 +79,7 @@ impl TerminalCodegen {
|
||||||
|
|
||||||
let error_message = result.as_ref().err().map(|error| error.to_string());
|
let error_message = result.as_ref().err().map(|error| error.to_string());
|
||||||
report_assistant_event(
|
report_assistant_event(
|
||||||
AssistantEvent {
|
AssistantEventData {
|
||||||
conversation_id: None,
|
conversation_id: None,
|
||||||
kind: AssistantKind::InlineTerminal,
|
kind: AssistantKind::InlineTerminal,
|
||||||
message_id,
|
message_id,
|
||||||
|
|
|
@ -18,7 +18,7 @@ use language_model::{
|
||||||
};
|
};
|
||||||
use prompt_store::PromptBuilder;
|
use prompt_store::PromptBuilder;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};
|
use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase};
|
||||||
use terminal_view::TerminalView;
|
use terminal_view::TerminalView;
|
||||||
use ui::prelude::*;
|
use ui::prelude::*;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
@ -292,7 +292,7 @@ impl TerminalInlineAssistant {
|
||||||
let codegen = assist.codegen.read(cx);
|
let codegen = assist.codegen.read(cx);
|
||||||
let executor = cx.background_executor().clone();
|
let executor = cx.background_executor().clone();
|
||||||
report_assistant_event(
|
report_assistant_event(
|
||||||
AssistantEvent {
|
AssistantEventData {
|
||||||
conversation_id: None,
|
conversation_id: None,
|
||||||
kind: AssistantKind::InlineTerminal,
|
kind: AssistantKind::InlineTerminal,
|
||||||
message_id: codegen.message_id.clone(),
|
message_id: codegen.message_id.clone(),
|
||||||
|
|
|
@ -57,7 +57,7 @@ use std::{
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
|
use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
|
||||||
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};
|
use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase};
|
||||||
use terminal_view::terminal_panel::TerminalPanel;
|
use terminal_view::terminal_panel::TerminalPanel;
|
||||||
use text::{OffsetRangeExt, ToPoint as _};
|
use text::{OffsetRangeExt, ToPoint as _};
|
||||||
use theme::ThemeSettings;
|
use theme::ThemeSettings;
|
||||||
|
@ -315,7 +315,7 @@ impl InlineAssistant {
|
||||||
if let Some(ConfiguredModel { model, .. }) =
|
if let Some(ConfiguredModel { model, .. }) =
|
||||||
LanguageModelRegistry::read_global(cx).default_model()
|
LanguageModelRegistry::read_global(cx).default_model()
|
||||||
{
|
{
|
||||||
self.telemetry.report_assistant_event(AssistantEvent {
|
self.telemetry.report_assistant_event(AssistantEventData {
|
||||||
conversation_id: None,
|
conversation_id: None,
|
||||||
kind: AssistantKind::Inline,
|
kind: AssistantKind::Inline,
|
||||||
phase: AssistantPhase::Invoked,
|
phase: AssistantPhase::Invoked,
|
||||||
|
@ -892,7 +892,7 @@ impl InlineAssistant {
|
||||||
.map(|language| language.name())
|
.map(|language| language.name())
|
||||||
});
|
});
|
||||||
report_assistant_event(
|
report_assistant_event(
|
||||||
AssistantEvent {
|
AssistantEventData {
|
||||||
conversation_id: None,
|
conversation_id: None,
|
||||||
kind: AssistantKind::Inline,
|
kind: AssistantKind::Inline,
|
||||||
message_id,
|
message_id,
|
||||||
|
@ -3148,7 +3148,7 @@ impl CodegenAlternative {
|
||||||
|
|
||||||
let error_message = result.as_ref().err().map(|error| error.to_string());
|
let error_message = result.as_ref().err().map(|error| error.to_string());
|
||||||
report_assistant_event(
|
report_assistant_event(
|
||||||
AssistantEvent {
|
AssistantEventData {
|
||||||
conversation_id: None,
|
conversation_id: None,
|
||||||
message_id,
|
message_id,
|
||||||
kind: AssistantKind::Inline,
|
kind: AssistantKind::Inline,
|
||||||
|
|
|
@ -27,7 +27,7 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};
|
use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase};
|
||||||
use terminal::Terminal;
|
use terminal::Terminal;
|
||||||
use terminal_view::TerminalView;
|
use terminal_view::TerminalView;
|
||||||
use theme::ThemeSettings;
|
use theme::ThemeSettings;
|
||||||
|
@ -324,7 +324,7 @@ impl TerminalInlineAssistant {
|
||||||
let codegen = assist.codegen.read(cx);
|
let codegen = assist.codegen.read(cx);
|
||||||
let executor = cx.background_executor().clone();
|
let executor = cx.background_executor().clone();
|
||||||
report_assistant_event(
|
report_assistant_event(
|
||||||
AssistantEvent {
|
AssistantEventData {
|
||||||
conversation_id: None,
|
conversation_id: None,
|
||||||
kind: AssistantKind::InlineTerminal,
|
kind: AssistantKind::InlineTerminal,
|
||||||
message_id: codegen.message_id.clone(),
|
message_id: codegen.message_id.clone(),
|
||||||
|
@ -1183,7 +1183,7 @@ impl Codegen {
|
||||||
|
|
||||||
let error_message = result.as_ref().err().map(|error| error.to_string());
|
let error_message = result.as_ref().err().map(|error| error.to_string());
|
||||||
report_assistant_event(
|
report_assistant_event(
|
||||||
AssistantEvent {
|
AssistantEventData {
|
||||||
conversation_id: None,
|
conversation_id: None,
|
||||||
kind: AssistantKind::InlineTerminal,
|
kind: AssistantKind::InlineTerminal,
|
||||||
message_id,
|
message_id,
|
||||||
|
|
|
@ -40,7 +40,7 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};
|
use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase};
|
||||||
use text::{BufferSnapshot, ToPoint};
|
use text::{BufferSnapshot, ToPoint};
|
||||||
use ui::IconName;
|
use ui::IconName;
|
||||||
use util::{ResultExt, TryFutureExt, post_inc};
|
use util::{ResultExt, TryFutureExt, post_inc};
|
||||||
|
@ -2498,7 +2498,7 @@ impl AssistantContext {
|
||||||
.language()
|
.language()
|
||||||
.map(|language| language.name());
|
.map(|language| language.name());
|
||||||
report_assistant_event(
|
report_assistant_event(
|
||||||
AssistantEvent {
|
AssistantEventData {
|
||||||
conversation_id: Some(this.id.0.clone()),
|
conversation_id: Some(this.id.0.clone()),
|
||||||
kind: AssistantKind::Panel,
|
kind: AssistantKind::Panel,
|
||||||
phase: AssistantPhase::Response,
|
phase: AssistantPhase::Response,
|
||||||
|
|
|
@ -17,7 +17,7 @@ use std::io::Write;
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};
|
use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};
|
||||||
use telemetry_events::{AssistantEvent, AssistantPhase, Event, EventRequestBody, EventWrapper};
|
use telemetry_events::{AssistantEventData, AssistantPhase, Event, EventRequestBody, EventWrapper};
|
||||||
use util::{ResultExt, TryFutureExt};
|
use util::{ResultExt, TryFutureExt};
|
||||||
use worktree::{UpdatedEntriesSet, WorktreeId};
|
use worktree::{UpdatedEntriesSet, WorktreeId};
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ impl Telemetry {
|
||||||
drop(state);
|
drop(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_assistant_event(self: &Arc<Self>, event: AssistantEvent) {
|
pub fn report_assistant_event(self: &Arc<Self>, event: AssistantEventData) {
|
||||||
let event_type = match event.phase {
|
let event_type = match event.phase {
|
||||||
AssistantPhase::Response => "Assistant Responded",
|
AssistantPhase::Response => "Assistant Responded",
|
||||||
AssistantPhase::Invoked => "Assistant Invoked",
|
AssistantPhase::Invoked => "Assistant Invoked",
|
||||||
|
|
|
@ -5,13 +5,13 @@ use gpui::BackgroundExecutor;
|
||||||
use http_client::{AsyncBody, HttpClient, Method, Request as HttpRequest};
|
use http_client::{AsyncBody, HttpClient, Method, Request as HttpRequest};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};
|
use telemetry_events::{AssistantEventData, AssistantKind, AssistantPhase};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
pub const ANTHROPIC_PROVIDER_ID: &str = "anthropic";
|
pub const ANTHROPIC_PROVIDER_ID: &str = "anthropic";
|
||||||
|
|
||||||
pub fn report_assistant_event(
|
pub fn report_assistant_event(
|
||||||
event: AssistantEvent,
|
event: AssistantEventData,
|
||||||
telemetry: Option<Arc<Telemetry>>,
|
telemetry: Option<Arc<Telemetry>>,
|
||||||
client: Arc<dyn HttpClient>,
|
client: Arc<dyn HttpClient>,
|
||||||
model_api_key: Option<String>,
|
model_api_key: Option<String>,
|
||||||
|
@ -32,7 +32,7 @@ pub fn report_assistant_event(
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn report_anthropic_event(
|
async fn report_anthropic_event(
|
||||||
event: AssistantEvent,
|
event: AssistantEventData,
|
||||||
client: Arc<dyn HttpClient>,
|
client: Arc<dyn HttpClient>,
|
||||||
model_api_key: Option<String>,
|
model_api_key: Option<String>,
|
||||||
) -> Result<(), AnthropicError> {
|
) -> Result<(), AnthropicError> {
|
||||||
|
|
|
@ -96,7 +96,7 @@ pub enum Event {
|
||||||
InlineCompletion(InlineCompletionEvent),
|
InlineCompletion(InlineCompletionEvent),
|
||||||
InlineCompletionRating(InlineCompletionRatingEvent),
|
InlineCompletionRating(InlineCompletionRatingEvent),
|
||||||
Call(CallEvent),
|
Call(CallEvent),
|
||||||
Assistant(AssistantEvent),
|
Assistant(AssistantEventData),
|
||||||
Cpu(CpuEvent),
|
Cpu(CpuEvent),
|
||||||
Memory(MemoryEvent),
|
Memory(MemoryEvent),
|
||||||
App(AppEvent),
|
App(AppEvent),
|
||||||
|
@ -162,7 +162,7 @@ pub struct CallEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct AssistantEvent {
|
pub struct AssistantEventData {
|
||||||
/// Unique random identifier for each assistant tab (None for inline assist)
|
/// Unique random identifier for each assistant tab (None for inline assist)
|
||||||
pub conversation_id: Option<String>,
|
pub conversation_id: Option<String>,
|
||||||
/// Server-generated message ID (only supported for some providers)
|
/// Server-generated message ID (only supported for some providers)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue