Add telemetry::event! (#22146)

CC @JosephTLyons

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-12-17 11:39:18 -07:00 committed by GitHub
parent b17f2089a2
commit 7425d242bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 179 additions and 140 deletions

View file

@ -14,3 +14,4 @@ path = "src/telemetry_events.rs"
[dependencies]
semantic_version.workspace = true
serde.workspace = true
serde_json.workspace = true

View file

@ -2,7 +2,7 @@
use semantic_version::SemanticVersion;
use serde::{Deserialize, Serialize};
use std::{fmt::Display, sync::Arc, time::Duration};
use std::{collections::HashMap, fmt::Display, sync::Arc, time::Duration};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EventRequestBody {
@ -91,6 +91,7 @@ impl Display for AssistantPhase {
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum Event {
Flexible(FlexibleEvent),
Editor(EditorEvent),
InlineCompletion(InlineCompletionEvent),
InlineCompletionRating(InlineCompletionRatingEvent),
@ -106,6 +107,12 @@ pub enum Event {
Repl(ReplEvent),
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FlexibleEvent {
pub event_type: String,
pub event_properties: HashMap<String, serde_json::Value>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EditorEvent {
/// The editor operation performed (open, save)