Add more open events

project search
diagnostics
welcome page
This commit is contained in:
Joseph T. Lyons 2024-01-15 16:26:04 -05:00
parent e2f08a6cca
commit ba9a9f4f17
13 changed files with 110 additions and 31 deletions

View file

@ -116,7 +116,7 @@ pub enum Event {
milliseconds_since_first_event: i64,
},
App {
operation: &'static str,
operation: String,
milliseconds_since_first_event: i64,
},
Setting {
@ -129,6 +129,10 @@ pub enum Event {
environment: &'static str,
milliseconds_since_first_event: i64,
},
Button {
operation: &'static str,
milliseconds_since_first_event: i64,
},
}
#[cfg(debug_assertions)]
@ -219,7 +223,7 @@ impl Telemetry {
// TestAppContext ends up calling this function on shutdown and it panics when trying to find the TelemetrySettings
#[cfg(not(any(test, feature = "test-support")))]
fn shutdown_telemetry(self: &Arc<Self>) -> impl Future<Output = ()> {
self.report_app_event("close");
self.report_app_event("close".to_string());
// TODO: close final edit period and make sure it's sent
Task::ready(())
}
@ -385,7 +389,7 @@ impl Telemetry {
self.report_event(event)
}
pub fn report_app_event(self: &Arc<Self>, operation: &'static str) {
pub fn report_app_event(self: &Arc<Self>, operation: String) {
let event = Event::App {
operation,
milliseconds_since_first_event: self.milliseconds_since_first_event(),
@ -404,20 +408,6 @@ impl Telemetry {
self.report_event(event)
}
fn milliseconds_since_first_event(&self) -> i64 {
let mut state = self.state.lock();
match state.first_event_datetime {
Some(first_event_datetime) => {
let now: DateTime<Utc> = Utc::now();
now.timestamp_millis() - first_event_datetime.timestamp_millis()
}
None => {
state.first_event_datetime = Some(Utc::now());
0
}
}
}
pub fn log_edit_event(self: &Arc<Self>, environment: &'static str) {
let mut state = self.state.lock();
let period_data = state.event_coalescer.log_event(environment);
@ -434,6 +424,30 @@ impl Telemetry {
}
}
pub fn report_button_event(self: &Arc<Self>, operation: &'static str) {
let event = Event::Button {
operation,
milliseconds_since_first_event: self.milliseconds_since_first_event(),
};
self.report_event(event)
}
fn milliseconds_since_first_event(&self) -> i64 {
let mut state = self.state.lock();
match state.first_event_datetime {
Some(first_event_datetime) => {
let now: DateTime<Utc> = Utc::now();
now.timestamp_millis() - first_event_datetime.timestamp_millis()
}
None => {
state.first_event_datetime = Some(Utc::now());
0
}
}
}
fn report_event(self: &Arc<Self>, event: Event) {
let mut state = self.state.lock();