pub struct Analytics {
pub enabled: bool,
pub endpoint: Option<String>,
pub build_version: String,
pub platform: String,
pub session_id: String,
pub stats: SessionStats,
/* private fields */
}Expand description
Opt-in analytics system. Call record() to log events.
tick() batches them and uploads when enough accumulate or on flush.
Fields§
§enabled: boolWhether telemetry is enabled (user opt-in).
endpoint: Option<String>§build_version: String§platform: String§session_id: String§stats: SessionStatsImplementations§
Source§impl Analytics
impl Analytics
pub fn new(build: impl Into<String>, platform: impl Into<String>) -> Self
pub fn enable(&mut self, endpoint: impl Into<String>)
pub fn disable(&mut self)
Sourcepub fn record(&mut self, event: AnalyticsEvent)
pub fn record(&mut self, event: AnalyticsEvent)
Record an analytics event. No-op if disabled.
Sourcepub fn export_csv(&self) -> String
pub fn export_csv(&self) -> String
Export the local event log to CSV.
Sourcepub fn local_log_entries(&self) -> impl Iterator<Item = &(String, String)>
pub fn local_log_entries(&self) -> impl Iterator<Item = &(String, String)>
Get the local log as a string slice view (newest last).
Sourcepub fn clear_local_log(&mut self)
pub fn clear_local_log(&mut self)
Clear the local log.
pub fn session_duration(&self) -> Duration
pub fn uploads_sent(&self) -> u32
Auto Trait Implementations§
impl Freeze for Analytics
impl RefUnwindSafe for Analytics
impl Send for Analytics
impl Sync for Analytics
impl Unpin for Analytics
impl UnsafeUnpin for Analytics
impl UnwindSafe for Analytics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.