### bucketStart Source: https://developer.apple.com/documentation/metrickit/mxhistogrambucket/bucketstart The value of the starting measurement for the bucket. This property is deprecated and should not be used. ```APIDOC ## bucketStart ### Description The value of the starting measurement for the bucket. ### Deprecated This property is deprecated and will not be available in future versions. ### Declaration ```swift var bucketStart: Measurement { get } ``` ``` -------------------------------- ### Post Animation Interval Start with mxSignpostAnimationIntervalBegin Source: https://developer.apple.com/documentation/metrickit/mxmetricmanager-api Posts the start time of an animation interval to the log system. This is used for tracking the beginning of animation events. ```swift func mxSignpostAnimationIntervalBegin(dso: UnsafeRawPointer, log: OSLog, name: StaticString, signpostID: OSSignpostID, StaticString, [any CVarArg]) ``` -------------------------------- ### Launch Task Unknown Error Source: https://developer.apple.com/documentation/metrickit/mxerror/code Use when the task has not been started or has already been finished. ```swift `case launchTaskUnknown` ``` -------------------------------- ### MXHistogramBucket bucketStart Property Declaration Source: https://developer.apple.com/documentation/metrickit/mxhistogrambucket/bucketstart This is the declaration for the deprecated bucketStart property. It returns the starting measurement for the bucket. ```swift var bucketStart: Measurement { get } ``` -------------------------------- ### Get Platform Architecture Source: https://developer.apple.com/documentation/metrickit/mxmetadata Get the name of the processor architecture for the device. ```swift var platformArchitecture: String ``` -------------------------------- ### Get OS Version Source: https://developer.apple.com/documentation/metrickit/mxmetadata Retrieve the operating system version, including type, number, and build number. ```swift var osVersion: String ``` -------------------------------- ### mxSignpostAnimationIntervalBegin Source: https://developer.apple.com/documentation/metrickit/mxmetricmanager-api Posts the start time of an animation interval to the log system. This function is deprecated. ```APIDOC ## func mxSignpostAnimationIntervalBegin ### Description Posts the start time of an animation interval to the log system. ### Parameters - **dso** (UnsafeRawPointer) - Description - **log** (OSLog) - Description - **name** (StaticString) - Description - **signpostID** (OSSignpostID) - Description - **StaticString** (type) - Description - **[any CVarArg]** (type) - Description ### Deprecated This function is deprecated. ``` -------------------------------- ### Get Device Type Source: https://developer.apple.com/documentation/metrickit/mxmetadata Obtain the hardware identifier for the device. ```swift var deviceType: String ``` -------------------------------- ### Get Application Build Version Source: https://developer.apple.com/documentation/metrickit/mxmetadata Retrieve the bundle version of the application from its property list. ```swift var applicationBuildVersion: String ``` -------------------------------- ### Launch Task Past Deadline Error Source: https://developer.apple.com/documentation/metrickit/mxerror/code Use when the start call for a task was made too late. ```swift `case launchTaskPastDeadline` ``` -------------------------------- ### Get Reporting Period Start Time Source: https://developer.apple.com/documentation/metrickit/mxdiagnosticpayload Access the starting timestamp of the reporting period for the diagnostic data. ```swift var timeStampBegin: Date ``` -------------------------------- ### Begin Document Capture Signpost Interval Source: https://developer.apple.com/documentation/metrickit/track-performance-by-app-state-using-metrickit Starts a signpost interval named 'ReceiptScan' for the 'DocumentCapture' category. This should be called when the document scanning workflow begins. ```swift func beginDocumentCapture() { mxSignpost(.begin, log: documentCaptureLog, name: "ReceiptScan") } ``` -------------------------------- ### Get OS Platform Name Source: https://developer.apple.com/documentation/metrickit/osversion/platform Retrieve the name of the operating system platform. Available for iOS, iPadOS, Mac Catalyst, macOS, and visionOS starting from version 27.0+ Beta. ```swift let platform: String ``` -------------------------------- ### AppMetrics Class for Receiving MetricKit Reports Source: https://developer.apple.com/documentation/metrickit/mxmetricmanager This example demonstrates how to create a class that subscribes to and receives MetricKit reports. It includes methods for receiving daily metrics and diagnostics, as well as methods to add and remove the subscriber from the MXMetricManager. ```swift class AppMetrics: NSObject, MXMetricManagerSubscriber { func receiveReports() { let manager = MXMetricManager.shared manager.add(self) } func pauseReports() { let manager = MXMetricManager.shared manager.remove(self) } // Receive daily metrics. func didReceive(_ payloads: [MXMetricPayload]) { // Process metrics. } // Receive diagnostics immediately when available. func didReceive(_ payloads: [MXDiagnosticPayload]) { // Process diagnostics. } } ``` -------------------------------- ### Get Exception Type Source: https://developer.apple.com/documentation/metrickit/crashdiagnostic/exceptiontype Retrieve the name of the Mach exception that caused the app termination. Available on iOS, iPadOS, Mac Catalyst, macOS, and visionOS starting from version 27.0 (Beta). ```swift let exceptionType: Int? ``` -------------------------------- ### MXAppLaunchMetric Properties Source: https://developer.apple.com/documentation/metrickit/mxapplaunchmetric The MXAppLaunchMetric class provides several histogrammed metrics related to app launch and resume times. These include optimized launch time, general launch time, application resume time, and extended launch tasks. ```APIDOC ## Class MXAppLaunchMetric An object representing metrics about app launch time. ### Topics #### Viewing app launch and resume time - `histogrammedOptimizedTimeToFirstDraw`: A histogram of the different amounts of time associated with prewarmed app launches. - `histogrammedTimeToFirstDraw`: A histogram of the different amounts of time taken to launch the app. - `histogrammedApplicationResumeTime`: A histogram of the different amounts of time taken to resume the app from the background. - `histogrammedExtendedLaunch`: A histogram of the different amounts of time taken to launch the app, including the extended launch tasks. ``` -------------------------------- ### Emit States using StateReporter Source: https://developer.apple.com/documentation/metrickit/metricmanager/enabledstatereportingdomains Demonstrates how to obtain a `StateReporter` for a specific domain and emit states. This is useful for providing the application states that will be aggregated with metrics. ```swift // Emit states using StateReporting directly let reporter = StateReporter.reporter(for: "com.myapp.gameplay", stableState: GameState.self) ``` -------------------------------- ### AveragePixelLuminance init(coder:) Source: https://developer.apple.com/documentation/metrickit/averagepixelluminance/init%28coder%3A%29 Initializes a new instance of AveragePixelLuminance from an NSCoder. This is typically used during deserialization. ```APIDOC ## init(coder:) ### Description Initializes a new instance of AveragePixelLuminance from an NSCoder. This is typically used during deserialization. ### Method `init?(coder: NSCoder)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response An initialized `AveragePixelLuminance` object. #### Response Example None ``` -------------------------------- ### Example JSON Structure for Stack Tree Source: https://developer.apple.com/documentation/metrickit/mxcallstacktree/jsonrepresentation%28%29 This is a partial example of the JSON output for a stack tree, illustrating the structure when callStackPerThread is true. It shows nested call stacks and frames. ```json { "callStackTree" : { "callStackPerThread" : true, "callStacks" : [ { "threadAttributed" : false, "callStackRootFrames" : [ { "binaryUUID" : "70B89F27-1634-3580-A695-57CDB41D7743", "offsetIntoBinaryTextSegment" : 165304, "sampleCount" : 1, "binaryName" : "MetricKitTestApp", "address" : 7170766264 "subFrames" : [ { "binaryUUID" : "77A62F2E-8212-30F3-84C1-E8497440ACF8", "offsetIntoBinaryTextSegment" : 6948, "sampleCount" : 1, "binaryName" : "libdyld.dylib", "address" : 7170808612 } ] } ] }, { "threadAttributed" : true, "callStackRootFrames" : [ ... ``` -------------------------------- ### Initialize MetricManager with State Reporting Domains Source: https://developer.apple.com/documentation/metrickit/metricmanager/enabledstatereportingdomains Initialize a `MetricManager` instance and specify the domains for which metrics aggregation should include StateReporting stable state context. Metrics will be delivered with context broken down by application states recorded in the specified domains. ```swift let manager = MetricManager(enabledStateReportingDomains: [ "com.myapp.gameplay", "com.myapp.experiments" ]) ``` -------------------------------- ### MetricManager.LaunchTaskError.Reason.pastDeadline Case Source: https://developer.apple.com/documentation/metrickit/metricmanager/launchtaskerror/reason-swift.enum/pastdeadline Represents the error reason when a task's start call is made too late. Available on iOS, iPadOS, Mac Catalyst, and macOS starting from version 27.0 (Beta). ```swift case pastDeadline ``` -------------------------------- ### Get Bundle Identifier Source: https://developer.apple.com/documentation/metrickit/mxmetadata Retrieve the bundle identifier of the application. ```swift var bundleIdentifier: String ``` -------------------------------- ### init(symbol:converter:) Source: https://developer.apple.com/documentation/metrickit/signalbars/init%28symbol%3Aconverter%3A%29 Initializes a SignalBars object. This is a beta feature and subject to change. ```APIDOC ## init(symbol:converter:) ### Description Initializes a SignalBars object with a given symbol and a unit converter. ### Method `init` (Initializer) ### Parameters #### Path Parameters - **symbol** (String) - Required - The symbol to represent the signal bars. - **converter** (UnitConverter) - Required - The unit converter to use for the signal bars. ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta macOS 27.0+ Beta ``` -------------------------------- ### Basic Usage of trackLaunchTask Source: https://developer.apple.com/documentation/metrickit/metricmanager/tracklaunchtask%28id%3Aontrackingerror%3A_%3A%29-jnu1 Use this snippet to wrap synchronous work that extends your app’s perceived launch time. Measurement begins when the closure starts and ends when it returns. ```swift manager.trackLaunchTask(id: "register-services") { registerAllServices() } ``` -------------------------------- ### mxSignpost Source: https://developer.apple.com/documentation/metrickit/mxmetricmanager-api Posts a single custom metric, the start time of a custom metric, or the end time of a custom metric to the log system. This function is deprecated. ```APIDOC ## func mxSignpost ### Description Posts a single custom metric, the start time of a custom metric, or the end time of a custom metric to the log system. ### Parameters - **OSSignpostType** (type) - Description - **dso** (UnsafeRawPointer) - Description - **log** (OSLog) - Description - **name** (StaticString) - Description - **signpostID** (OSSignpostID) - Description - **StaticString** (type) - Description - **[any CVarArg]** (type) - Description ### Deprecated This function is deprecated. ``` -------------------------------- ### timeStampBegin Source: https://developer.apple.com/documentation/metrickit/mxdiagnosticpayload/timestampbegin The starting time of the reporting period. This property is deprecated. ```APIDOC ## timeStampBegin ### Description The starting time of the reporting period. ### Property `var timeStampBegin: Date { get }` ### Deprecated This property is deprecated in iOS 14.0 and iPadOS 14.0. It was also deprecated in macOS 12.0 and visionOS 1.0. ``` -------------------------------- ### AveragePixelLuminance Initializer Signature Source: https://developer.apple.com/documentation/metrickit/averagepixelluminance/init%28symbol%3Aconverter%3A%29 This is the signature for the `init(symbol:converter:)` initializer for AveragePixelLuminance. It is a dynamic override initializer. ```swift override dynamic init( symbol: String, converter: UnitConverter ) ``` -------------------------------- ### MetricManager.LaunchTaskError.Reason.taskUnknown Source: https://developer.apple.com/documentation/metrickit/metricmanager/launchtaskerror/reason-swift.enum/taskunknown Represents the state where a task has not been started or has already been finished. ```APIDOC ## MetricManager.LaunchTaskError.Reason.taskUnknown ### Description The task hasn’t been started or has already been finished. ### Case ```swift case taskUnknown ``` ### Platforms iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta macOS 27.0+ Beta ``` -------------------------------- ### AveragePixelLuminance.init(symbol:converter:) Source: https://developer.apple.com/documentation/metrickit/averagepixelluminance/init%28symbol%3Aconverter%3A%29 Initializes an AveragePixelLuminance object with a symbol and a unit converter. This is a beta feature available from iOS 27.0 onwards. ```APIDOC ## init(symbol:converter:) ### Description Initializes an AveragePixelLuminance object. ### Parameters #### Path Parameters - **symbol** (String) - Required - The symbol for the luminance. - **converter** (UnitConverter) - Required - The unit converter to use for the luminance. ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta ### Beta Software Notice This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software. ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/metrickit/mxlaunchtaskid/init%28_%3A%29 Creates a task identifier from a string. This initializer is deprecated. ```APIDOC ## init(_:) ### Description Creates a task identifier from a string. ### Parameters #### Raw Value - **rawValue** (String) - The string for the task identifier. ### Deprecated This initializer is deprecated and should not be used in new code. ``` -------------------------------- ### Create and Use Signpost Log Handles Source: https://developer.apple.com/documentation/metrickit/signpostintervalmetric Create a log handle for a specific category and wrap custom operations with mxSignpost to log the beginning and end of an interval. ```swift let networkLog = MetricManager.logHandle(category: "NetworkRequests") func loadProfile() async { mxSignpost(.begin, log: networkLog, name: "fetchUserProfile") await fetchUserProfile() mxSignpost(.end, log: networkLog, name: "fetchUserProfile") } ``` -------------------------------- ### Get Process ID Source: https://developer.apple.com/documentation/metrickit/mxmetadata Obtain the process ID (PID) of the current process. ```swift var pid: pid_t ``` -------------------------------- ### Creating a MetricManager with State Reporting Domains Source: https://developer.apple.com/documentation/metrickit/metricmanager/init%28enabledstatereportingdomains%3A%29 Instantiate `MetricManager` with a set of `StateReportingDomain` values to enable state-contextualized metrics. The `stateEntries` property will be populated with metric values segmented by each recorded app state. ```swift let manager = MetricManager( enabledStateReportingDomains: ["com.example.app.session"] ) ``` -------------------------------- ### Get bundleIdentifier Source: https://developer.apple.com/documentation/metrickit/mxmetadata/bundleidentifier Retrieve the bundle identifier of the current process. This property is read-only. ```swift var bundleIdentifier: String { get } ``` -------------------------------- ### SignalBars Initializers Source: https://developer.apple.com/documentation/metrickit/signalbars Initializers for the SignalBars class. ```APIDOC ## Initializers ### `init?(coder: NSCoder)` Initializes a SignalBars object from a coder. ### `init(symbol: String, converter: UnitConverter)` Initializes a SignalBars object with a symbol and a unit converter. ``` -------------------------------- ### Launch Task Duplicated Error Source: https://developer.apple.com/documentation/metrickit/mxerror/code Use when a task with the same ID has already been started. ```swift `case launchTaskDuplicated` ``` -------------------------------- ### mxSignpostAnimationIntervalBegin Source: https://developer.apple.com/documentation/metrickit/mxsignpostanimationintervalbegin%28dso%3Alog%3Aname%3Asignpostid%3A_%3A_%3A%29 Posts the start time of an animation interval to the log system. This function is intended for internal system use and should be called with the provided parameters to log animation intervals. ```APIDOC ## Function: mxSignpostAnimationIntervalBegin ### Description Posts the start time of an animation interval to the log system. This function is part of MetricKit and is available on iOS, iPadOS, Mac Catalyst, macOS, and visionOS. ### Parameters - **dso** (UnsafeRawPointer) - Optional - A parameter for internal system use. - **log** (OSLog) - Required - A log object to log the signpost to. - **name** (StaticString) - Required - A string containing the developer-assigned name of the custom event. - **signpostID** (OSSignpostID) - Optional - A parameter for internal system use. Defaults to `.exclusive`. - **format** (StaticString) - Optional - A parameter for internal system use. Defaults to `"isAnimation=YES \n%{public, signpost:metrics}%@"`. - **arguments** ([any CVarArg]) - Optional - An array of arguments with a format string, followed by the expected number of arguments in the order that they appear in the string. Defaults to `[Unmanaged.fromOpaque(_MXSignpostMetricsSnapshot()).takeUnretainedValue()]`. ### Discussion Call this function to mark the beginning of an animation interval in the metric kit log. Provide a `log` that you create with `makeLogHandle(category:)`, a `name` for the event, and variable `arguments` for `os_signpost_event_emit`. Don’t alter the parameters `dso`, `signpostID`, or `format`. ``` -------------------------------- ### Initialize MetricManager Source: https://developer.apple.com/documentation/metrickit/monitoring-app-performance-with-metrickit Create a MetricManager instance. Store it in a long-lived property to ensure the subscription remains active. ```swift let manager = MetricManager() ``` -------------------------------- ### MXError.Code launchTaskDuplicated Source: https://developer.apple.com/documentation/metrickit/mxerror/launchtaskduplicated Represents an error where a task with the same ID has already been started. This property is deprecated. ```APIDOC ## launchTaskDuplicated ### Description A task with the same ID has already been started. ### Type `MXError.Code` ### Availability iOS 14.0–16.0 (Deprecated) iPadOS 14.0–16.0 (Deprecated) Mac Catalyst 16.0+ (Deprecated) visionOS 1.0–27.0 (Deprecated) ### See Also - `MXError.Code` - `MXError.errorDomain` (Deprecated) - `MXError.launchTaskInternalFailure` (Deprecated) - `MXError.launchTaskInvalidID` (Deprecated) - `MXError.launchTaskMaxCount` (Deprecated) - `MXError.launchTaskPastDeadline` (Deprecated) - `MXError.launchTaskUnknown` (Deprecated) - `MXError.Code` (Enum) - `MXError.MXErrorDomain` (String) ``` -------------------------------- ### Initialize MetricManager with State Reporting Domains Source: https://developer.apple.com/documentation/metrickit/monitoring-app-performance-with-metrickit Initialize MetricManager with specific StateReportingDomain values to receive per-state metric entries. Define custom domains using extensions. ```swift extension StateReportingDomain { static let experiments: StateReportingDomain = "com.example.app.experiments" } let manager = MetricManager(enabledStateReportingDomains: [.experiments]) ``` -------------------------------- ### jsonRepresentation() Source: https://developer.apple.com/documentation/metrickit/mxsignpostrecord/jsonrepresentation%28%29 This method is deprecated and has been removed. It was previously used to get a JSON representation of the MXSignpostRecord as Data. ```APIDOC ## jsonRepresentation() ### Description This method is deprecated. It previously returned a `Data` object representing the JSON serialization of the `MXSignpostRecord`. ### Method `func jsonRepresentation() -> Data` ### Deprecated Available in iOS 17.0–14.0. Deprecated in iOS 14.0. Available in iPadOS 17.0–14.0. Deprecated in iPadOS 14.0. Available in macOS 17.0+ and macOS 14.0–27.0. Deprecated in macOS 27.0. Available in visionOS 1.0–27.0. Deprecated in visionOS 27.0. ### See Also * Generating a report `func dictionaryRepresentation() -> [AnyHashable : Any]` ``` -------------------------------- ### Objective-C Exception Name Property Source: https://developer.apple.com/documentation/metrickit/mxcrashdiagnosticobjectivecexceptionreason/exceptionname This property was used to get the name of an Objective-C exception. It is now deprecated. ```Objective-C var exceptionName: String { get } ``` -------------------------------- ### MetricManager Initializer Signature Source: https://developer.apple.com/documentation/metrickit/metricmanager/init%28enabledstatereportingdomains%3A%29 This is the signature for the `init(enabledStateReportingDomains:)` initializer. It takes a Set of `StateReportingDomain` as input. ```swift init(enabledStateReportingDomains: Set) ``` -------------------------------- ### init() Source: https://developer.apple.com/documentation/metrickit/metricmanager/init%28%29 Creates a new `MetricManager` instance without state reporting domains. This initializer is used when only interval-based metric data and diagnostic reports are needed, without per-state metrics. Hold the returned instance in a property for as long as you need reports. ```APIDOC ## init() ### Description Creates a new `MetricManager` instance without state reporting domains. This initializer is suitable for interval-based metric data and diagnostic reports, without per-state metrics. ### Method `init()` ### Parameters This initializer does not take any parameters. ### Request Example ```swift let manager = MetricManager() ``` ### Response Returns a new `MetricManager` instance. ### See Also - `init(enabledStateReportingDomains: Set)` ``` -------------------------------- ### Accessing exceptionCode Source: https://developer.apple.com/documentation/metrickit/mxcrashdiagnostic/exceptioncode Use this property to get the encoded processor-specific information for a crash. This property is deprecated. ```swift var exceptionCode: NSNumber? { get } ``` -------------------------------- ### MXSignpostRecord.beginTimeStamp Source: https://developer.apple.com/documentation/metrickit/mxsignpostrecord/begintimestamp The beginTimeStamp property was used to retrieve the start date of a signpost. This property is deprecated and should not be used. ```APIDOC ## MXSignpostRecord.beginTimeStamp ### Description Represents the start date of a signpost. This property is deprecated and has been removed in newer versions of the operating system. ### Availability - iOS 17.0–14.0 - iPadOS 17.0–14.0 - macOS 14.0–27.0 - visionOS 1.0–27.0 ### Deprecated This property is deprecated and will not be available in future versions. ### Declaration ```swift var beginTimeStamp: Date { get } ``` ``` -------------------------------- ### Begin Animation Interval Source: https://developer.apple.com/documentation/metrickit/mxsignpostanimationintervalbegin%28dso%3Alog%3Aname%3Asignpostid%3A_%3A_%3A%29 Call this function to mark the beginning of an animation interval in the metric kit log. Provide a `log` that you create with `makeLogHandle(category:)`, a `name` for the event, and variable `arguments` for `os_signpost_event_emit`. Do not alter the parameters `dso`, `signpostID`, or `format`. ```swift func mxSignpostAnimationIntervalBegin( dso: UnsafeRawPointer = #dsohandle, log: OSLog, name: StaticString, signpostID: OSSignpostID = .exclusive, _ format: StaticString = "isAnimation=YES \n%{public, signpost:metrics}@", _ arguments: [any CVarArg] = [Unmanaged.fromOpaque(_MXSignpostMetricsSnapshot()).takeUnretainedValue()] ) ``` -------------------------------- ### Declare appLaunch MetricGroup Source: https://developer.apple.com/documentation/metrickit/metricgroup/applaunch Declare the static let appLaunch property of type MetricGroup. This is the primary way to access app launch metrics. ```swift static let appLaunch: MetricGroup ``` -------------------------------- ### Measuring Extended Launch Source: https://developer.apple.com/documentation/metrickit/mxmetricmanager Starts or signals the end of an extended launch task for measurement purposes. ```APIDOC ## extendLaunchMeasurement(forTaskID:) ### Description Starts to measure an extended launch task with the given task identifier. ### Parameters #### Path Parameters - **forTaskID** (MXLaunchTaskID) - The task identifier to track launch measurements. ### Class Method `class func extendLaunchMeasurement(forTaskID: MXLaunchTaskID) throws` ## finishExtendedLaunchMeasurement(forTaskID:) ### Description Signals the end of an extended launch task. ### Parameters #### Path Parameters - **forTaskID** (MXLaunchTaskID) - The task identifier to track launch measurements. ### Class Method `class func finishExtendedLaunchMeasurement(forTaskID: MXLaunchTaskID) throws` ``` -------------------------------- ### Instantiate MetricManager Source: https://developer.apple.com/documentation/metrickit/metricmanager Create an instance of MetricManager to receive metric and diagnostic reports. Hold the instance for as long as you need reports. ```swift final class MetricManager ``` -------------------------------- ### MXError.launchTaskDuplicated Code Source: https://developer.apple.com/documentation/metrickit/mxerror/launchtaskduplicated Represents the error code when a task with the same ID has already been started. This property is deprecated. ```swift static var launchTaskDuplicated: MXError.Code { get } ``` -------------------------------- ### Listen for Metric and Diagnostic Reports Source: https://developer.apple.com/documentation/metrickit/track-performance-by-app-state-using-metrickit Start listening for metric and diagnostic reports using async sequences provided by MetricManager. Metric reports contain aggregated performance data, while diagnostic reports include information on crashes and hangs. ```swift func startListening() { metricTask = Task { [weak self] in guard let self else { return } for await report in metricManager.metricReports { await handleMetricReport(report) } } diagnosticTask = Task { [weak self] in guard let self else { return } for await report in metricManager.diagnosticReports { await handleDiagnosticReport(report) } } } ``` -------------------------------- ### Get Region Format Source: https://developer.apple.com/documentation/metrickit/mxmetadata Retrieve the short country code for the device's region format setting. ```swift var regionFormat: String ``` -------------------------------- ### extendLaunchMeasurement(forTaskID:) Source: https://developer.apple.com/documentation/metrickit/mxmetricmanager/extendlaunchmeasurement%28fortaskid%3A%29 Starts to measure an extended launch task with the given task identifier. This method is deprecated and should be used on the main thread. It has limitations on the number of tasks and overlap requirements. ```APIDOC ## extendLaunchMeasurement(forTaskID:) ### Description Starts to measure an extended launch task with the given task identifier. This method is deprecated. ### Method `class func` ### Endpoint `extendLaunchMeasurement(forTaskID: MXLaunchTaskID) throws` ### Parameters #### Path Parameters - **taskID** (MXLaunchTaskID) - Required - The task identifier. Must be a unique, non-null string. ### Discussion Use this method on the main thread to measure an extended launch task. Your app needs to start the first task before or during `scene(_:restoreInteractionStateWith:)`, or before the system calls `sceneDidBecomeActive(_:)` on the first scene to connect, and each task needs to overlap with others. The maximum number of tasks is 16. The extended launch measurement finishes when all running tasks finish. ### See Also - `finishExtendedLaunchMeasurement(forTaskID:)` - `MXLaunchTaskID` ``` -------------------------------- ### AveragePixelLuminance Class Source: https://developer.apple.com/documentation/metrickit/averagepixelluminance Provides information about the AveragePixelLuminance class, its initializers, and type methods. ```APIDOC ## Class AveragePixelLuminance A unit for average pixel luminance measurements. Available in iOS 27.0+ Beta, iPadOS 27.0+ Beta, Mac Catalyst 27.0+ Beta. ```swift @objc final class AveragePixelLuminance ``` ### Discussion This is used as the `Dimension` type in `value`, which has type `AverageStatistics`. The base unit symbol is "apl" (average pixel luminance). This type replaces `MXUnitAveragePixelLuminance`. ### Initializers `init?(coder: NSCoder)` Initializes a new instance of the AveragePixelLuminance class from the given decoder. `init(symbol: String, converter: UnitConverter)` Initializes a new instance of the AveragePixelLuminance class with the specified symbol and unit converter. ### Type Methods `static func baseUnit() -> AveragePixelLuminance` Returns the base unit for average pixel luminance. ``` -------------------------------- ### Get Device Type Source: https://developer.apple.com/documentation/metrickit/mxmetadata/devicetype Retrieve the hardware identifier for the device. This property is deprecated and should not be used in new development. ```swift var deviceType: String { get } ``` -------------------------------- ### Get Reporting Period End Time Source: https://developer.apple.com/documentation/metrickit/mxdiagnosticpayload Access the ending timestamp of the reporting period for the diagnostic data. ```swift var timeStampEnd: Date ``` -------------------------------- ### AveragePixelLuminance Initializer Source: https://developer.apple.com/documentation/metrickit/averagepixelluminance/init%28coder%3A%29 The required dynamic initializer for AveragePixelLuminance, used for decoding objects from an NSCoder. This API is in beta. ```swift required dynamic init?(coder: NSCoder) ``` -------------------------------- ### Extend Launch Measurement Function Signature Source: https://developer.apple.com/documentation/metrickit/mxmetricmanager/extendlaunchmeasurement%28fortaskid%3A%29 This is the Objective-C signature for the `extendLaunchMeasurement(forTaskID:)` method. Use this method on the main thread to measure an extended launch task. ```objc class func extendLaunchMeasurement(forTaskID taskID: MXLaunchTaskID) throws ``` -------------------------------- ### Accessing cumulativeLogicalWrites Source: https://developer.apple.com/documentation/metrickit/mxdiskiometric/cumulativelogicalwrites Get the total amount of data written to disk or other long-term storage. This property is deprecated. ```swift var cumulativeLogicalWrites: Measurement { get } ``` -------------------------------- ### init(rawValue:) Source: https://developer.apple.com/documentation/metrickit/mxerror/code/init%28rawvalue%3A%29 This initializer is deprecated and should not be used in new code. It was used to create an instance of MXError.Code from an integer raw value. ```APIDOC ## init(rawValue:) ### Description Initializes a new instance of MXError.Code with a raw value. This initializer is deprecated. ### Parameters #### Raw Value Parameter - **rawValue** (Int) - Required - The integer value to initialize the MXError.Code with. ### Availability - iOS 16.0–14.0 - iPadOS 16.0–14.0 - Mac Catalyst 16.0+ - visionOS 1.0–27.0 ### Deprecated This initializer is deprecated. ``` -------------------------------- ### SignpostRecord.interval Source: https://developer.apple.com/documentation/metrickit/signpostrecord/interval The time interval for the signpost. For instant signposts, the start and end times are the same, resulting in a duration of 0. ```APIDOC ## SignpostRecord.interval ### Description Represents the time interval for a signpost. For signposts that mark an instant in time, the start and end of the interval are identical, meaning the duration is zero. ### Property - **interval** (DateInterval) - The time interval associated with the signpost. ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta macOS 27.0+ Beta ### Example ```swift let interval: DateInterval ``` ``` -------------------------------- ### applicationLaunchMetrics Property Source: https://developer.apple.com/documentation/metrickit/mxmetricpayload/applicationlaunchmetrics Retrieves the app launch and resume metrics for the reporting period. This property is deprecated and should not be used in new development. ```swift var applicationLaunchMetrics: MXAppLaunchMetric? { get } ``` -------------------------------- ### osVersion Instance Property Signature Source: https://developer.apple.com/documentation/metrickit/mxmetadata/osversion This is the signature for the `osVersion` instance property. It returns a String representing the OS version. ```swift var osVersion: String { get } ``` -------------------------------- ### TotalDiskSpaceCapacityMetric Structure Source: https://developer.apple.com/documentation/metrickit/totaldiskspacecapacitymetric Defines the structure for the TotalDiskSpaceCapacityMetric. Available on iOS, iPadOS, and Mac Catalyst starting from version 27.0. ```swift struct TotalDiskSpaceCapacityMetric ``` -------------------------------- ### MetricManager.LaunchTaskError.Reason.pastDeadline Source: https://developer.apple.com/documentation/metrickit/metricmanager/launchtaskerror/reason-swift.enum/pastdeadline The `pastDeadline` case signifies that the start call for a launch task was made too late, past its designated deadline. ```APIDOC ## MetricManager.LaunchTaskError.Reason.pastDeadline ### Description The start call was made too late. ### Enum Case `case pastDeadline` ### Supported Platforms iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta macOS 27.0+ Beta ``` -------------------------------- ### MXMetaData init(coder:) Source: https://developer.apple.com/documentation/metrickit/mxmetadata/init%28coder%3A%29 This initializer is deprecated and should not be used in new development. It was used for initializing MXMetaData from an NSCoder. ```APIDOC ## init(coder:) ### Description This initializer is deprecated and was used for initializing MXMetaData from an NSCoder. Its use is discouraged in favor of other initialization methods. ### Deprecation - iOS: 13.0–14.0 - iPadOS: 13.0–14.0 - Mac Catalyst: 13.1+ - macOS: 12.0–27.0 - visionOS: 1.0–27.0 ### Signature ```swift init?(coder: NSCoder) ``` ``` -------------------------------- ### Get Platform Architecture Source: https://developer.apple.com/documentation/metrickit/diagnosticreport/environment-swift.struct/platformarchitecture Retrieve the name of the processor architecture for the device. Available on iOS, iPadOS, macOS, and visionOS (27.0+). ```swift let platformArchitecture: String ``` -------------------------------- ### init(rawValue:) Source: https://developer.apple.com/documentation/metrickit/mxlaunchtaskid/init%28rawvalue%3A%29 Creates a task identifier from a string. This initializer is deprecated. ```APIDOC ## init(rawValue:) ### Description Creates a task identifier from a string. ### Deprecated This initializer is deprecated for iOS, iPadOS, macOS, and visionOS. ### Parameters #### rawValue - **rawValue** (String) - The string for the task identifier. ### See Also - `init(String)`: Creates a task identifer from a string. ``` -------------------------------- ### MetricResult.extendedLaunch(_:) Source: https://developer.apple.com/documentation/metrickit/metricresult/extendedlaunch%28_%3A%29 Represents an extended launch metric for app performance monitoring. This case is part of the MetricKit framework and is available in beta versions. ```APIDOC ## MetricResult.extendedLaunch(_:) ### Description This case, `extendedLaunch`, is used to capture extended launch metrics for an application. It is part of the `MetricResult` type and is available for iOS, iPadOS, Mac Catalyst, and macOS versions 27.0 and later. ### Case Signature ```swift case extendedLaunch(ExtendedLaunchMetric) ``` ### Availability - iOS 27.0+ (Beta) - iPadOS 27.0+ (Beta) - Mac Catalyst 27.0+ (Beta) - macOS 27.0+ (Beta) ### Related Documentation - Monitoring app performance with MetricKit ### See Also - `case timeToFirstDraw(TimeToFirstDrawMetric)` - `case applicationResumeTime(ApplicationResumeTimeMetric)` - `case optimizedTimeToFirstDraw(OptimizedTimeToFirstDrawMetric)` ``` -------------------------------- ### Get Exception Name Source: https://developer.apple.com/documentation/metrickit/crashdiagnostic/objectivecexceptionreason/exceptionname Retrieve the name of an Objective-C exception. This property is available in beta versions of Apple operating systems. ```swift let exceptionName: String ``` -------------------------------- ### TotalCellularDownloadMetric Structure Source: https://developer.apple.com/documentation/metrickit/totalcellulardownloadmetric Defines the structure for TotalCellularDownloadMetric. Available on iOS, iPadOS, and Mac Catalyst starting from version 27.0 (Beta). ```swift struct TotalCellularDownloadMetric ``` -------------------------------- ### Report Experiment Variant Transitions Source: https://developer.apple.com/documentation/metrickit/track-performance-by-app-state-using-metrickit Create and use a state reporter to log transitions between experiment variants. This helps correlate performance data with specific experiment configurations. ```swift private let expenseReportDetailViewExperimentReporter = MetricManager.stateReporter( for: Experiments.domain.rawValue, stableMetadata: ExperimentContext.self ) func reportExpenseDetailLayoutVariant(variant: Experiments.ExpenseDetailLayout) { expenseReportDetailViewExperimentReporter.reportTransition( to: "Active", stableMetadata: ExperimentContext( experimentID: Experiments.ExpenseDetailLayout.id, variant: variant.rawValue ) ) } ``` -------------------------------- ### MXError.Code.launchTaskUnknown Source: https://developer.apple.com/documentation/metrickit/mxerror/launchtaskunknown Represents an unknown launch task status, meaning the task hasn't started or has already finished. This property is deprecated. ```swift static var launchTaskUnknown: MXError.Code { get } ``` -------------------------------- ### MetricManager Initialization Source: https://developer.apple.com/documentation/metrickit/metricmanager Initializes a MetricManager instance. You can create an instance without state reporting domains or with specific domains enabled for metrics aggregation. ```APIDOC ## Initialization ### `convenience init()` Creates a new `MetricManager` instance without state reporting domains. ### `init(enabledStateReportingDomains: Set)` Creates a new `MetricManager` instance with state reporting domains enabled for metrics aggregation. ### `var enabledStateReportingDomains: Set` StateReporting domains enabled for metrics aggregation. ``` -------------------------------- ### duration Source: https://developer.apple.com/documentation/metrickit/metricreport/intervalentry/duration The duration of this collection interval. Available on iOS, iPadOS, Mac Catalyst, and macOS starting from version 27.0 (Beta). ```APIDOC ## duration ### Description The duration of this collection interval. ### Property - **duration** (Measurement) - The duration of the collection interval. ### Availability iOS 27.0+ (Beta) iPadOS 27.0+ (Beta) Mac Catalyst 27.0+ (Beta) macOS 27.0+ (Beta) ### Swift Example ```swift let duration: Measurement ``` ``` -------------------------------- ### Define CPUInstructionsCountMetric Source: https://developer.apple.com/documentation/metrickit/cpuinstructionscountmetric Defines the structure for the CPUInstructionsCountMetric. This metric is available on iOS, iPadOS, and macOS starting from version 27.0 (Beta). ```swift struct CPUInstructionsCountMetric ``` -------------------------------- ### init(coder:) Source: https://developer.apple.com/documentation/metrickit/mxdiagnosticpayload/init%28coder%3A%29 Initializes an MXDiagnosticPayload object from an NSCoder. This initializer is deprecated and should not be used in new development. ```APIDOC ## init(coder:) ### Description Initializes an MXDiagnosticPayload object from an NSCoder. This initializer is deprecated. ### Method `init?(coder: NSCoder)` ### Availability - iOS 14.0–14.0 (Deprecated) - iPadOS 14.0–14.0 (Deprecated) - macOS Catalyst 14.0+ - macOS 12.0–27.0 (Deprecated) - visionOS 1.0–27.0 (Deprecated) ``` -------------------------------- ### Initializers Source: https://developer.apple.com/documentation/metrickit/mxcallstacktree Initializes an MXCallStackTree object. ```APIDOC ## init?(coder: NSCoder) ### Description Initializes an MXCallStackTree object using an NSCoder. ### Parameters - coder (NSCoder): The coder to use for initialization. ``` -------------------------------- ### Get Bucket Count Source: https://developer.apple.com/documentation/metrickit/mxhistogrambucket/bucketcount Retrieve the number of samples contained within a histogram bucket. This property is deprecated and should not be used in new development. ```swift var bucketCount: Int { get } ``` -------------------------------- ### Get Total Data File Count Source: https://developer.apple.com/documentation/metrickit/mxdiskspaceusagemetric/totaldatafilecount Retrieve the total number of data files in your app's container(s). This property is deprecated. ```swift var totalDataFileCount: Int { get } ``` -------------------------------- ### DiagnosticResult.appLaunch(_:) Source: https://developer.apple.com/documentation/metrickit/diagnosticresult/applaunch%28_%3A%29 Represents an app launch diagnostic result. This case is part of the `DiagnosticResult` enum and is used to encapsulate data related to the performance of an application's launch. ```APIDOC ## DiagnosticResult.appLaunch(_:) ### Description This case within the `DiagnosticResult` enum signifies an app launch diagnostic. It is used to provide specific information about how an application launched. ### Case ```swift case appLaunch(AppLaunchDiagnostic) ``` ### Supported Platforms - iOS 27.0+ (Beta) - iPadOS 27.0+ (Beta) - Mac Catalyst 27.0+ (Beta) - macOS 27.0+ (Beta) ### Mentioned in - Monitoring app performance with MetricKit ``` -------------------------------- ### Get App Launch Duration Source: https://developer.apple.com/documentation/metrickit/mxapplaunchdiagnostic/launchduration Retrieve the total duration of an app's launch. This property is deprecated and should not be used in new development. ```swift var launchDuration: Measurement { get } ``` -------------------------------- ### TotalWiFiUploadMetric Structure Source: https://developer.apple.com/documentation/metrickit/totalwifiuploadmetric Defines the structure for the TotalWiFiUploadMetric. Available on iOS, iPadOS, Mac Catalyst, and macOS starting from version 27.0 (Beta). ```swift struct TotalWiFiUploadMetric ``` -------------------------------- ### Accessing Metric Data Source: https://developer.apple.com/documentation/metrickit/metricreport Demonstrates how to access the full-day aggregate metric data from MetricReport.IntervalEntry and iterate through the results. ```APIDOC ## Accessing Metric Data Access metric data through `intervalEntries`, which contains one or more `MetricReport.IntervalEntry` values. Use the `MetricReport.IntervalEntry` collection’s `fullDayEntry` property to retrieve the full-day aggregate, then iterate its `values` array and switch over each `MetricResult`. ```swift if let entry = report.intervalEntries.fullDayEntry { for result in entry.values { switch result { case .cpuTime(let metric): record(metric) case .peakMemory(let metric): record(metric) @unknown default: break } } } ``` ``` -------------------------------- ### MXMetricPayload init(coder:) Source: https://developer.apple.com/documentation/metrickit/mxmetricpayload/init%28coder%3A%29 This is a deprecated initializer for MXMetricPayload that was used for decoding data from an NSCoder. It is no longer recommended for use. ```APIDOC ## init(coder:) ### Description Deprecated initializer for MXMetricPayload. Use this to decode data from an NSCoder. ### Availability - iOS 13.0–14.0 - iPadOS 13.0–14.0 - Mac Catalyst 13.1+ - macOS 10.15–27.0 - visionOS 1.0–27.0 ### Signature ```swift init?(coder: NSCoder) ``` ``` -------------------------------- ### TotalBackgroundTimeMetric.value Source: https://developer.apple.com/documentation/metrickit/totalbackgroundtimemetric/value The total time the app is active in the background. Available on iOS, iPadOS, and Mac Catalyst starting from version 27.0 (Beta). ```APIDOC ## Instance Property ### value The total time the app is active in the background. **Availability:** - iOS 27.0+ (Beta) - iPadOS 27.0+ (Beta) - Mac Catalyst 27.0+ (Beta) ```swift let value: Measurement ``` ``` -------------------------------- ### Access Diagnostic Report Environment Source: https://developer.apple.com/documentation/metrickit/analyzing-app-performance-with-metrickit The `DiagnosticReport.Environment` provides app-specific context for diagnostic events, including the exact build context. Check this environment to understand the conditions under which a diagnostic event occurred. ```swift let diagnosticReport: DiagnosticReport // ... let environment = diagnosticReport.environment print(environment.bundleIdentifier ?? "Unknown Bundle ID") print(environment.regionFormat ?? "Unknown Region") ``` -------------------------------- ### TotalBackgroundAudioTimeMetric Structure Source: https://developer.apple.com/documentation/metrickit/totalbackgroundaudiotimemetric Defines the structure for the TotalBackgroundAudioTimeMetric. This metric is available on iOS, iPadOS, and Mac Catalyst starting from version 27.0 (Beta). ```swift struct TotalBackgroundAudioTimeMetric ``` -------------------------------- ### MetricResult.hangTime(_:) Source: https://developer.apple.com/documentation/metrickit/metricresult/hangtime%28_%3A%29 Represents the hang time metric, which is available for iOS, iPadOS, Mac Catalyst, and macOS starting from version 27.0 (Beta). ```APIDOC ## hangTime(_:) ### Description This case represents the hang time metric, providing insights into responsiveness and animation performance. It is available on iOS, iPadOS, Mac Catalyst, and macOS. ### Platforms iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta macOS 27.0+ Beta ### Case ```swift case hangTime(HangTimeMetric) ``` ### See Also - `hitchTime(HitchTimeMetric)` - `scrollHitchTime(ScrollHitchTimeMetric)` ``` -------------------------------- ### add(_:) Source: https://developer.apple.com/documentation/metrickit/mxmetricmanager/add%28_%3A%29 Registers an object to receive daily reports of app metrics from the metrics manager. The provided subscriber object must conform to the `MXMetricManagerSubscriber` protocol. ```APIDOC ## add(_:) ### Description Registers to receive a daily report of app metrics from the metrics manager. ### Method Signature ```swift func add(_ subscriber: any MXMetricManagerSubscriber) ``` ### Parameters #### subscriber - **subscriber** (any MXMetricManagerSubscriber) - Required - The object that receives the daily metrics reports. The object must conform to `MXMetricManagerSubscriber`. ### Deprecated This method is deprecated in iOS 13.0–14.0, iPadOS 13.0–14.0, macOS 12.0–27.0, and visionOS 1.0–27.0. ``` -------------------------------- ### platformArchitecture Source: https://developer.apple.com/documentation/metrickit/metricreport/environment-swift.struct/platformarchitecture The name of the processor architecture for the device. Available on iOS, iPadOS, macOS, and Mac Catalyst starting from version 27.0 (Beta). ```APIDOC ## platformArchitecture ### Description The name of the processor architecture for the device. ### Property `let platformArchitecture: String` ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta macOS 27.0+ Beta ``` -------------------------------- ### trackLaunchTask(id:onTrackingError:_:) Async Source: https://developer.apple.com/documentation/metrickit/metricmanager/tracklaunchtask%28id%3Aontrackingerror%3A_%3A%29-48k2s Measures the duration of an asynchronous extended launch task. Measurement begins when the closure starts and ends when the closure returns, regardless of whether the closure throws. ```APIDOC ## trackLaunchTask(id:onTrackingError:_:) Async ### Description Measures the duration of an asynchronous extended launch task. Use this method to wrap asynchronous work that extends your app’s perceived launch time, such as fetching configuration data, loading initial content, or initializing a local database. Measurement begins when the closure starts and ends it when the closure returns, regardless of whether the closure throws. ### Method `async` ### Parameters #### Path Parameters - **id** (LaunchTaskID) - Required - An identifier for the task being measured. - **onTrackingError** ((MetricManager.LaunchTaskError) -> Void)? - Optional - A closure that is called when a `MetricManager.LaunchTaskError` occurs. This closure does not interrupt the tracked work. #### Body Parameters - **operation** (async throws(Failure) -> Result) - Required - An `async` closure wrapping the work to measure. The closure can throw an error of type `Failure` where `Failure` conforms to `Error`. ### Response #### Success Response - **Result** - The result returned by the `operation` closure. ### Example ```swift await manager.trackLaunchTask(id: "initial-data-load") { await loadInitialData() } await manager.trackLaunchTask(id: "initial-data-load", onTrackingError: { error in logger.warning("Tracking error: \(error.reason)") }) { await loadInitialData() } ``` ``` -------------------------------- ### MXLaunchTaskID Source: https://developer.apple.com/documentation/metrickit/mxlaunchtaskid The task identifier to track launch measurements. ```APIDOC ## MXLaunchTaskID ### Description The task identifier to track launch measurements. ### Topics #### Creating a task identifier `init(String)` Creates a task identifer from a string. `init(rawValue: String)` Creates a task identifer from a string. ### Conforms To * `Equatable` * `Hashable` * `RawRepresentable` * `Sendable` * `SendableMetatype` ``` -------------------------------- ### frameCount Source: https://developer.apple.com/documentation/metrickit/metalframeratemetric/framecount The total Metal drawable count. Available on iOS, iPadOS, Mac Catalyst, and macOS starting from version 27.0 (Beta). ```APIDOC ## frameCount ### Description The total Metal drawable count. ### Syntax ```swift var frameCount: Int { get } ``` ### Availability - iOS 27.0+ (Beta) - iPadOS 27.0+ (Beta) - Mac Catalyst 27.0+ (Beta) - macOS 27.0+ (Beta) ``` -------------------------------- ### deviceType Source: https://developer.apple.com/documentation/metrickit/diagnosticreport/environment-swift.struct/devicetype The hardware identifier for the device. Available on iOS, iPadOS, Mac Catalyst, macOS, and visionOS starting from version 27.0 (Beta). ```APIDOC ## deviceType ### Description The hardware identifier for the device. ### Property `let deviceType: String` ### Availability iOS 27.0+ Beta iPadOS 27.0+ Beta Mac Catalyst 27.0+ Beta macOS 27.0+ Beta visionOS 27.0+ Beta ``` -------------------------------- ### trackLaunchTask(id:onTrackingError:_:) Swift Method Source: https://developer.apple.com/documentation/metrickit/metricmanager/tracklaunchtask%28id%3Aontrackingerror%3A_%3A%29-jnu1 Measures the duration of a synchronous extended launch task. It takes a task ID, an optional error handler, and a closure containing the work to be measured. The measurement starts when the closure begins and ends when it completes, whether it returns a value or throws an error. ```APIDOC ## trackLaunchTask(id:onTrackingError:_:) ### Description Measures the duration of a synchronous extended launch task. Use this method to wrap synchronous work that extends your app’s perceived launch time. Measurement begins when the closure starts and ends it when the closure returns, regardless of whether the closure throws. ### Method Signature ```swift @MainActor final func trackLaunchTask( id: LaunchTaskID, onTrackingError: ((MetricManager.LaunchTaskError) -> Void)? = nil, _ operation: () throws(Failure) -> Result ) throws(Failure) -> Result where Failure : Error ``` ### Parameters #### Path Parameters - **id** (LaunchTaskID) - Required - An identifier for the task being measured. - **onTrackingError** ((MetricManager.LaunchTaskError) -> Void)? - Optional - A closure that is called when a `MetricManager.LaunchTaskError` occurs, without interrupting the tracked work. - **operation** (() throws(Failure) -> Result) - Required - A synchronous closure that wraps the work to be measured. This closure can throw an error of type `Failure`. ### Throws This method can throw an error of type `Failure` if the `operation` closure throws an error. ### Example Usage #### Basic Tracking ```swift manager.trackLaunchTask(id: "register-services") { registerAllServices() } ``` #### Tracking with Error Observation ```swift manager.trackLaunchTask(id: "register-services", onTrackingError: { error in logger.warning("Tracking error: \(error.reason)") }) { registerAllServices() } ``` ### Related Types - `MetricManager.LaunchTaskError`: An error that describes a problem that occurred while tracking an extended launch task. - `MetricManager.LaunchTaskID`: An identifier for a task measured as part of an extended app launch. ```