Add telemetry for supermaven (#11821)
Data migration plan:
- [X] Make a duplicate table of `copilot_events`
- Name: `inline_completion_events`
- Omit `suggestion_id` column
- [X-reverted-skipping] In collab, continue to match on copilot_events,
but simply stuff their data into inline_completion_events, to forward it
to the new table
- [skipping] Once collab is deployed, ensure no events are being sent to
copilot_events, migrate `copilot_events` to new table via a transaction
- [skipping] Delete `copilot_events` table
---
- [X] Locally test that copilot events sent from old clients get put
into inline_completions_table
- [X] Locally test that copilot events and supermaven events sent from
new clients get put into inline_completions_table
---
- [X] Why are discard events being spammed?
- A:
8d4315712b/crates/editor/src/editor.rs (L2147)

This will throw off the past results for accepted / dismissed that I was
wanting to use to evaluate Supermaven quality, by comparing its rate
with copilot's rate.
I'm not super thrilled with this fix, but I think it'll do. In the
`supermaven_completions_provider`, we check if there's a `completion_id`
before sending either an accepted or discard completion event. I don't
see a similar construct in the `copilot_completions_provider` to
piggyback off of, so I begrudgingly introduced
`should_allow_event_to_send` and had it follow the same pattern that
`completion_id` does. Maybe there's a better way?
---
Adds events to supermaven suggestions. Makes "CopilotEvents" generic ->
"InlineCompletionEvents".
Release Notes:
- N/A
This commit is contained in:
parent
55f08c0511
commit
b6189b05f9
9 changed files with 123 additions and 42 deletions
|
@ -1,30 +1,46 @@
|
|||
use crate::{Supermaven, SupermavenCompletionStateId};
|
||||
use anyhow::Result;
|
||||
use client::telemetry::Telemetry;
|
||||
use editor::{Direction, InlineCompletionProvider};
|
||||
use futures::StreamExt as _;
|
||||
use gpui::{AppContext, Model, ModelContext, Task};
|
||||
use gpui::{AppContext, EntityId, Model, ModelContext, Task};
|
||||
use language::{language_settings::all_language_settings, Anchor, Buffer};
|
||||
use std::time::Duration;
|
||||
use std::{path::Path, sync::Arc, time::Duration};
|
||||
|
||||
pub const DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(75);
|
||||
|
||||
pub struct SupermavenCompletionProvider {
|
||||
supermaven: Model<Supermaven>,
|
||||
buffer_id: Option<EntityId>,
|
||||
completion_id: Option<SupermavenCompletionStateId>,
|
||||
file_extension: Option<String>,
|
||||
pending_refresh: Task<Result<()>>,
|
||||
telemetry: Option<Arc<Telemetry>>,
|
||||
}
|
||||
|
||||
impl SupermavenCompletionProvider {
|
||||
pub fn new(supermaven: Model<Supermaven>) -> Self {
|
||||
Self {
|
||||
supermaven,
|
||||
buffer_id: None,
|
||||
completion_id: None,
|
||||
file_extension: None,
|
||||
pending_refresh: Task::ready(Ok(())),
|
||||
telemetry: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_telemetry(mut self, telemetry: Arc<Telemetry>) -> Self {
|
||||
self.telemetry = Some(telemetry);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl InlineCompletionProvider for SupermavenCompletionProvider {
|
||||
fn name() -> &'static str {
|
||||
"supermaven"
|
||||
}
|
||||
|
||||
fn is_enabled(&self, buffer: &Model<Buffer>, cursor_position: Anchor, cx: &AppContext) -> bool {
|
||||
if !self.supermaven.read(cx).is_enabled() {
|
||||
return false;
|
||||
|
@ -58,6 +74,15 @@ impl InlineCompletionProvider for SupermavenCompletionProvider {
|
|||
while let Some(()) = completion.updates.next().await {
|
||||
this.update(&mut cx, |this, cx| {
|
||||
this.completion_id = Some(completion.id);
|
||||
this.buffer_id = Some(buffer_handle.entity_id());
|
||||
this.file_extension = buffer_handle.read(cx).file().and_then(|file| {
|
||||
Some(
|
||||
Path::new(file.file_name(cx))
|
||||
.extension()?
|
||||
.to_str()?
|
||||
.to_string(),
|
||||
)
|
||||
});
|
||||
cx.notify();
|
||||
})?;
|
||||
}
|
||||
|
@ -75,11 +100,30 @@ impl InlineCompletionProvider for SupermavenCompletionProvider {
|
|||
}
|
||||
|
||||
fn accept(&mut self, _cx: &mut ModelContext<Self>) {
|
||||
if let Some(telemetry) = self.telemetry.as_ref() {
|
||||
if let Some(_) = self.completion_id {
|
||||
telemetry.report_inline_completion_event(
|
||||
Self::name().to_string(),
|
||||
true,
|
||||
self.file_extension.clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
self.pending_refresh = Task::ready(Ok(()));
|
||||
self.completion_id = None;
|
||||
}
|
||||
|
||||
fn discard(&mut self, _cx: &mut ModelContext<Self>) {
|
||||
if let Some(telemetry) = self.telemetry.as_ref() {
|
||||
if let Some(_) = self.completion_id {
|
||||
telemetry.report_inline_completion_event(
|
||||
Self::name().to_string(),
|
||||
false,
|
||||
self.file_extension.clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
self.pending_refresh = Task::ready(Ok(()));
|
||||
self.completion_id = None;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue