StateReporter
class · iOS 27.0+ · SDK 27.1
final class StateReporter<StableMetadata, VolatileMetadata> where StableMetadata : ReportableMetadata, VolatileMetadata : ReportableMetadataAn object unique per domain that records state transitions and volatile metadata updates. `StateReporter` is the central object for recording your feature's or subsystem's current state. You obtain an instance through the ``reporter(for:stableMetadata:volatileMetadata:)`` method, which guarantees that every caller using the same domain string receives the same object. Attempting to call the method with different generic type arguments for an already-registered domain is a fatal error. A state is uniquely identified by the combination of a label and stable metadata. A transition to a new state occurs when either changes; reporting the same label and stable metadata is a no-op. *Volatile metadata* provides additional context within an ongoing state and is discarded when the next transition begins. Both stable and volatile metadata are expressed as types conforming to ``ReportableMetadata``, which can be synthesized automatically with the ``ReportableMetadata()`` macro. Call ``reportTransition(to:stableMetadata:volatileMetadata:)`` whenever your feature transitions to a new state. Pass `nil` as the label to signal that no state is active. Call ``reportVolatileMetadataUpdate(_:)`` to update volatile metadata without beginning a new state transition. Calling either method more frequently than user interaction timescales can trigger rate limiting, causing state updates to go unlogged. ```swift let reporter = StateReporter.reporter( for: "com.example.myapp.checkout", stableMetadata:AppMetadata.self, volatileMetadata:SessionMetadata.self ) reporter.reportTransition( to: "paymentSheet", stableMetadata: AppMetadata(userTier: .premium), volatileMetadata: SessionMetadata(cartTotal: 49.99) ) ``` For Objective-C, use ``SRStateReporter``.
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
StateReporter.reportVolatileMetadataUpdate(_:)
This declaration needs Swift generic type arguments. (no canonical witness for VolatileMetadata)
StateReporter.reporter(for:stableMetadata:volatileMetadata:)
The containing type needs Swift generic type arguments. (no canonical witness for StableMetadata, VolatileMetadata)