#[cfg(feature = "analytics")]
mod event;
#[cfg(feature = "analytics")]
mod wsl;
use crate::AppEnvironment;
use crate::StartupOptions;
pub struct ViewerAnalytics {
#[cfg(feature = "analytics")]
app_env: AppEnvironment,
#[cfg(feature = "analytics")]
analytics: Option<&'static re_analytics::Analytics>,
}
impl ViewerAnalytics {
#[allow(unused_mut, clippy::let_and_return)]
pub fn new(startup_options: &StartupOptions, app_env: AppEnvironment) -> Self {
re_tracing::profile_function!();
#[cfg(feature = "analytics")]
{
let analytics = if startup_options.is_in_notebook {
None
} else {
re_analytics::Analytics::global_or_init()
};
Self { app_env, analytics }
}
#[cfg(not(feature = "analytics"))]
{
let _ = (startup_options, app_env);
Self {}
}
}
#[allow(unused_variables)]
pub fn on_viewer_started(
&self,
build_info: re_build_info::BuildInfo,
egui_ctx: &egui::Context,
adapter_backend: wgpu::Backend,
device_tier: re_renderer::device_caps::DeviceCapabilityTier,
) {
re_tracing::profile_function!();
#[cfg(feature = "analytics")]
{
let Some(analytics) = self.analytics.as_ref() else {
return;
};
analytics.record(event::identify(
analytics.config(),
build_info,
&self.app_env,
));
analytics.record(event::viewer_started(
&self.app_env,
egui_ctx,
adapter_backend,
device_tier,
));
}
}
pub fn on_open_recording(&self, entity_db: &re_entity_db::EntityDb) {
#[cfg(feature = "analytics")]
{
if entity_db.store_kind() != re_log_types::StoreKind::Recording {
return;
}
let Some(analytics) = self.analytics.as_ref() else {
return;
};
if let Some(event) = event::open_recording(&self.app_env, entity_db) {
analytics.record(event);
}
}
#[cfg(not(feature = "analytics"))]
let _ = entity_db;
}
}