Contents

SRStateReporter

An object unique per domain that records state transitions and volatile metadata updates.

Declaration

@interface SRStateReporter : NSObject

Overview

SRStateReporter is the central object for recording your feature’s or subsystem’s current state. Obtain an instance through the reporterForDomain: method, which guarantees that every caller using the same domain string receives the same object.

A state is uniquely identified by its label and stable metadata. A transition to a new state occurs when the label or stable metadata changes; reporting the same label and stable metadata as the current state is a no-op. Volatile metadata provides additional context within an ongoing state and is discarded when the next transition begins. Context dictionaries must contain only NSNumber, NSString, or NSDate values.

Call reportTransitionToStateLabel: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.

SRStateReporter *reporter =
    [SRStateReporter reporterForDomain:@"com.example.myapp.checkout"];

[reporter reportTransitionToStateLabel:@"paymentSheet"
                 stableMetadata:@{@"userTier": @"premium"}
                volatileMetadata:@{@"cartTotal": @(49.99)}];

For Swift, use StateReporter.

Topics

Instance Properties

Instance Methods

Type Methods