pub struct DynamicReporter { /* private fields */ }Expand description
Forwarding wrapper that routes to one of two adapters at runtime.
Single-threaded — held inside OpenedTelemetry as
Rc<DynamicReporter> and registered into the app-state registry.
record() tees each event into a recent_log ring buffer in
addition to forwarding to the active adapter. The PrivacySettings
widget reads recent_log to populate the “Inspect data sent”
accordion. The recent log is not the adapter’s outbound queue
— events stay in the recent log even after the adapter has flushed
them, until evicted by the ring buffer’s capacity.
Implementations§
Source§impl DynamicReporter
impl DynamicReporter
pub fn new( anonymous: Option<Rc<dyn UsageReporter>>, pseudonymous: Option<Rc<dyn UsageReporter>>, default: TelemetryMode, consent: ConsentStore, recent_log: Arc<InMemoryEventQueue>, ) -> Self
pub fn recent_log(&self) -> &Arc<InMemoryEventQueue> ⓘ
Sourcepub fn recent_log_revision(&self) -> Signal<u64>
pub fn recent_log_revision(&self) -> Signal<u64>
Signal bumped on every event recorded into the recent-log
ring buffer (and on discard_pending). The PrivacySettings
widget binds to it for BindingLevel::Rebuild so the
“Inspect data sent” accordion stays in sync without polling.
pub fn active_mode(&self) -> TelemetryMode
Sourcepub fn set_active_mode(&self, mode: TelemetryMode)
pub fn set_active_mode(&self, mode: TelemetryMode)
Atomically swap the active mode. Caller is responsible for the
pre/post-conditions: erase_remote_data before leaving
pseudonymous, discard_pending to drop the queue, then
consent.reset() to force re-prompt.
Sourcepub fn supports_mode_switch(&self) -> bool
pub fn supports_mode_switch(&self) -> bool
true iff the bundle was constructed with both adapters; only
then is the mode switch UI shown.
Sourcepub fn has_mode(&self, mode: TelemetryMode) -> bool
pub fn has_mode(&self, mode: TelemetryMode) -> bool
true iff the given mode has an adapter configured.
pub fn consent(&self) -> &ConsentStore
Trait Implementations§
Source§impl Debug for DynamicReporter
impl Debug for DynamicReporter
Source§impl UsageReporter for DynamicReporter
impl UsageReporter for DynamicReporter
Source§fn record(&self, event: &Event<'_>)
fn record(&self, event: &Event<'_>)
Granted. Errors are buffered internally — there is no
return value because the caller cannot meaningfully react.Source§fn flush(&self) -> Result<(), TelemetryError>
fn flush(&self) -> Result<(), TelemetryError>
Self::discard_pending.Source§fn discard_pending(&self) -> Result<(), TelemetryError>
fn discard_pending(&self) -> Result<(), TelemetryError>
Denied or Unknown, the
buffered events are no longer permitted to leave the device.Source§fn erase_remote_data(&self) -> Result<(), TelemetryError>
fn erase_remote_data(&self) -> Result<(), TelemetryError>
TelemetryError::ErasureUnsupported so the widget can hide
the button.Source§fn fetch_remote_data(&self) -> Result<RemoteDataExport, TelemetryError>
fn fetch_remote_data(&self) -> Result<RemoteDataExport, TelemetryError>
RemoteDataExport.
Anonymous mode: returns TelemetryError::FetchUnsupported.Source§fn install_id(&self) -> Option<&str>
fn install_id(&self) -> Option<&str>
Some(uuid) in pseudonymous mode, None in anonymous mode.
Surfaced verbatim by the consent widget for user inspection.Source§fn adapter_name(&self) -> &'static str
fn adapter_name(&self) -> &'static str
"plausible", "posthog", "otlp", "stub". Shown in the
widget’s “what gets sent” tab.