One Logo Pool Ball
MetricKit · IOS API REFERENCE

MetricManager

class · iOS 27.0+ · SDK 27.1

final class MetricManager

Members (7)

get · iOS 27.0+

metricReports

TypeScript
get metricReports(): SDKHandle
Swift declaration
final var metricReports: some AsyncSequence<MetricReport, Never> { get }

Daily metric report Delivers metric entries that match enabled StateReporting domains as well as non-state-aggregated metric entries.

method · iOS 27.0+

trackLaunchTask

TypeScript
trackLaunchTask(id: LaunchTaskID, onTrackingError: (((arg0: MetricManager_LaunchTaskError) => void)) | null, operation: (() => Promise<unknown>)): Promise<unknown>
Swift declaration
@MainActor final func trackLaunchTask<Result, Failure>(id: LaunchTaskID, onTrackingError: ((MetricManager.LaunchTaskError) -> Void)? = nil, _ operation: () async throws(Failure) -> Result) async throws(Failure) -> Result where Failure : Error

Measures an extended launch task for asynchronous work. Use this method to track asynchronous work that extends your app's launch time. - Parameters: - id: A unique identifier for this launch task - onTrackingError: Optional error handler called if tracking fails - operation: The async work to measure - Returns: The result of the operation closure - Throws: Rethrows any error from the operation closure - Note: The first task must start before or during the initial scene setup - Note: Maximum 16 concurrent tasks allowed - Note: Task IDs must not exceed 128 characters ## Usage ```swift await manager.trackLaunchTask(id: "load-data") { // Asynchronous work } ```

get · iOS 27.0+

diagnosticReports

TypeScript
get diagnosticReports(): SDKHandle
Swift declaration
final var diagnosticReports: some AsyncSequence<DiagnosticReport, Never> { get }

Event-based diagnostic report

init · iOS 27.0+

init

TypeScript
static initEnabledStateReportingDomains(enabledStateReportingDomains: Array<StateReportingDomain>): MetricManager
Swift declaration
init(enabledStateReportingDomains: Set<StateReportingDomain>)

Creates a new MetricManager instance with StateReporting domains enabled for metrics aggregation - Parameter enabledStateReportingDomains: The StateReporting domains to enable for metrics aggregation. Metrics will be delivered with StateReporting context, broken down by the application states recorded in the specified domains. This manager will receive state entries matching the enabled domains as well as interval entries including the full day aggregate.

get · iOS 27.0+

enabledStateReportingDomains

TypeScript
get enabledStateReportingDomains(): Array<StateReportingDomain>
Swift declaration
final var enabledStateReportingDomains: Set<StateReportingDomain> { get }

StateReporting domains enabled for metrics aggregation When set, metrics will be delivered with StateReporting stable state context, broken down by the application states recorded in the specified domains. This manager will receive metric entries matching the enabled domains as well as non-state-aggregated metric entries. ## Example ```swift let manager = MetricManager(enabledStateReportingDomains: [ "com.myapp.gameplay", "com.myapp.experiments" ]) // Emit states using StateReporting directly let reporter = StateReporter.reporter(for: "com.myapp.gameplay", stableState: GameState.self) for await report in manager.metricReports { for entry in report.stateEntries { let domain = entry.state.domain } // Full day aggregate let fullDay = report.intervalEntries.fullDayEntry } ```

static · iOS 27.0+

logHandle

TypeScript
static logHandle(category: string): SDKHandle
Swift declaration
static func logHandle(category: String) -> OSLog

Returns a log handle used for writing custom metric events. - Parameter category: A developer-specified string containing the name of the category of custom metrics written in the log. - Returns: A customized `OSLog` object used for writing custom metrics of the same category. - Note: The object returned by this method saves only custom signpost metrics. Other kinds of `os_log` messages are not persisted.

init · iOS 27.0+

init

TypeScript
static init(): MetricManager
Swift declaration
convenience init()

Creates a new MetricManager instance without StateReporting domains

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

MetricManager.trackLaunchTask(id:onTrackingError:_:)

synchronous callback requires a nonescaping JS-thread call

All MetricKit types →