Add project open event
Give the caller of report_app_event() the choice of whether to immediately flush the queue or not.
This commit is contained in:
parent
72b3a1dd9a
commit
b1870af386
6 changed files with 17 additions and 9 deletions
|
@ -340,18 +340,18 @@ impl Telemetry {
|
||||||
self.report_clickhouse_event(event, telemetry_settings, false)
|
self.report_clickhouse_event(event, telemetry_settings, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// app_events are called at app open and app close, so flush is set to immediately send
|
|
||||||
pub fn report_app_event(
|
pub fn report_app_event(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
telemetry_settings: TelemetrySettings,
|
telemetry_settings: TelemetrySettings,
|
||||||
operation: &'static str,
|
operation: &'static str,
|
||||||
|
immediate_flush: bool,
|
||||||
) {
|
) {
|
||||||
let event = ClickhouseEvent::App {
|
let event = ClickhouseEvent::App {
|
||||||
operation,
|
operation,
|
||||||
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_clickhouse_event(event, telemetry_settings, true)
|
self.report_clickhouse_event(event, telemetry_settings, immediate_flush)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn milliseconds_since_first_event(&self) -> i64 {
|
fn milliseconds_since_first_event(&self) -> i64 {
|
||||||
|
|
|
@ -173,7 +173,7 @@ impl Telemetry {
|
||||||
#[cfg(not(any(test, feature = "test-support")))]
|
#[cfg(not(any(test, feature = "test-support")))]
|
||||||
fn shutdown_telemetry(self: &Arc<Self>, cx: &mut AppContext) -> impl Future<Output = ()> {
|
fn shutdown_telemetry(self: &Arc<Self>, cx: &mut AppContext) -> impl Future<Output = ()> {
|
||||||
let telemetry_settings = TelemetrySettings::get_global(cx).clone();
|
let telemetry_settings = TelemetrySettings::get_global(cx).clone();
|
||||||
self.report_app_event(telemetry_settings, "close");
|
self.report_app_event(telemetry_settings, "close", true);
|
||||||
Task::ready(())
|
Task::ready(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,18 +364,18 @@ impl Telemetry {
|
||||||
self.report_clickhouse_event(event, telemetry_settings, false)
|
self.report_clickhouse_event(event, telemetry_settings, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// app_events are called at app open and app close, so flush is set to immediately send
|
|
||||||
pub fn report_app_event(
|
pub fn report_app_event(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
telemetry_settings: TelemetrySettings,
|
telemetry_settings: TelemetrySettings,
|
||||||
operation: &'static str,
|
operation: &'static str,
|
||||||
|
immediate_flush: bool,
|
||||||
) {
|
) {
|
||||||
let event = ClickhouseEvent::App {
|
let event = ClickhouseEvent::App {
|
||||||
operation,
|
operation,
|
||||||
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
milliseconds_since_first_event: self.milliseconds_since_first_event(),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_clickhouse_event(event, telemetry_settings, true)
|
self.report_clickhouse_event(event, telemetry_settings, immediate_flush)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn milliseconds_since_first_event(&self) -> i64 {
|
fn milliseconds_since_first_event(&self) -> i64 {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use anyhow::{anyhow, Context, Result};
|
||||||
use call::ActiveCall;
|
use call::ActiveCall;
|
||||||
use client::{
|
use client::{
|
||||||
proto::{self, PeerId},
|
proto::{self, PeerId},
|
||||||
Client, Status, TypedEnvelope, UserStore,
|
Client, Status, TelemetrySettings, TypedEnvelope, UserStore,
|
||||||
};
|
};
|
||||||
use collections::{hash_map, HashMap, HashSet};
|
use collections::{hash_map, HashMap, HashSet};
|
||||||
use drag_and_drop::DragAndDrop;
|
use drag_and_drop::DragAndDrop;
|
||||||
|
@ -1462,6 +1462,10 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open(&mut self, _: &Open, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
|
pub fn open(&mut self, _: &Open, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
|
||||||
|
let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
|
||||||
|
self.client()
|
||||||
|
.telemetry()
|
||||||
|
.report_app_event(telemetry_settings, "open project", false);
|
||||||
let mut paths = cx.prompt_for_paths(PathPromptOptions {
|
let mut paths = cx.prompt_for_paths(PathPromptOptions {
|
||||||
files: true,
|
files: true,
|
||||||
directories: true,
|
directories: true,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use anyhow::{anyhow, Context as _, Result};
|
||||||
use call::ActiveCall;
|
use call::ActiveCall;
|
||||||
use client::{
|
use client::{
|
||||||
proto::{self, PeerId},
|
proto::{self, PeerId},
|
||||||
Client, Status, TypedEnvelope, UserStore,
|
Client, Status, TelemetrySettings, TypedEnvelope, UserStore,
|
||||||
};
|
};
|
||||||
use collections::{hash_map, HashMap, HashSet};
|
use collections::{hash_map, HashMap, HashSet};
|
||||||
use dock::{Dock, DockPosition, Panel, PanelButtons, PanelHandle};
|
use dock::{Dock, DockPosition, Panel, PanelButtons, PanelHandle};
|
||||||
|
@ -1250,6 +1250,10 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open(&mut self, _: &Open, cx: &mut ViewContext<Self>) {
|
pub fn open(&mut self, _: &Open, cx: &mut ViewContext<Self>) {
|
||||||
|
let telemetry_settings = TelemetrySettings::get_global(cx).clone();
|
||||||
|
self.client()
|
||||||
|
.telemetry()
|
||||||
|
.report_app_event(telemetry_settings, "open project", false);
|
||||||
let paths = cx.prompt_for_paths(PathPromptOptions {
|
let paths = cx.prompt_for_paths(PathPromptOptions {
|
||||||
files: true,
|
files: true,
|
||||||
directories: true,
|
directories: true,
|
||||||
|
|
|
@ -174,7 +174,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
client
|
client
|
||||||
.telemetry()
|
.telemetry()
|
||||||
.report_app_event(telemetry_settings, event_operation);
|
.report_app_event(telemetry_settings, event_operation, true);
|
||||||
|
|
||||||
let app_state = Arc::new(AppState {
|
let app_state = Arc::new(AppState {
|
||||||
languages,
|
languages,
|
||||||
|
|
|
@ -184,7 +184,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
client
|
client
|
||||||
.telemetry()
|
.telemetry()
|
||||||
.report_app_event(telemetry_settings, event_operation);
|
.report_app_event(telemetry_settings, event_operation, true);
|
||||||
|
|
||||||
let app_state = Arc::new(AppState {
|
let app_state = Arc::new(AppState {
|
||||||
languages: languages.clone(),
|
languages: languages.clone(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue