Skip to main content

DynamicReporter

Struct DynamicReporter 

Source
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

Source

pub fn new( anonymous: Option<Rc<dyn UsageReporter>>, pseudonymous: Option<Rc<dyn UsageReporter>>, default: TelemetryMode, consent: ConsentStore, recent_log: Arc<InMemoryEventQueue>, ) -> Self

Source

pub fn recent_log(&self) -> &Arc<InMemoryEventQueue>

Source

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.

Source

pub fn active_mode(&self) -> TelemetryMode

Source

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.

Source

pub fn supports_mode_switch(&self) -> bool

true iff the bundle was constructed with both adapters; only then is the mode switch UI shown.

Source

pub fn has_mode(&self, mode: TelemetryMode) -> bool

true iff the given mode has an adapter configured.

Source

pub fn consent(&self) -> &ConsentStore

Trait Implementations§

Source§

impl Debug for DynamicReporter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl UsageReporter for DynamicReporter

Source§

fn record(&self, event: &Event<'_>)

Invoked synchronously from any thread. MUST NOT block the caller (queue and return). Drops events when consent is not Granted. Errors are buffered internally — there is no return value because the caller cannot meaningfully react.
Source§

fn flush(&self) -> Result<(), TelemetryError>

Best-effort drain of the on-disk queue. Called on graceful exit. Not called on consent revocation — see Self::discard_pending.
Source§

fn discard_pending(&self) -> Result<(), TelemetryError>

Drop the queue without sending. Called when consent is revoked, when the mode is switched, or when the user clicks “Erase my data”. Once consent is Denied or Unknown, the buffered events are no longer permitted to leave the device.
Source§

fn erase_remote_data(&self) -> Result<(), TelemetryError>

GDPR Art. 17. Pseudonymous mode: send DELETE keyed by install_id; clear the local queue. Anonymous mode: returns TelemetryError::ErasureUnsupported so the widget can hide the button.
Source§

fn fetch_remote_data(&self) -> Result<RemoteDataExport, TelemetryError>

GDPR Art. 15 + 20. Pseudonymous mode: fetch all server-side events for this install_id as a RemoteDataExport. Anonymous mode: returns TelemetryError::FetchUnsupported.
Source§

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

"plausible", "posthog", "otlp", "stub". Shown in the widget’s “what gets sent” tab.
Source§

fn endpoint(&self) -> &str

Endpoint URL displayed verbatim in the consent widget.
Source§

fn supported_scopes(&self) -> ConsentScope

Drives the consent widget toggle group: which scopes does this adapter actually use? Toggles for unsupported scopes are hidden, not just disabled.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.