-
Découvrez le nouveau MetricKit
Identifiez et résolvez les problèmes de performances plus rapidement que jamais. Rejoignez-nous pour découvrir comment MetricKit vous fournit des indicateurs de performance essentiels et des diagnostics exploitables afin de vous aider à comprendre exactement où votre app peut être améliorée. Nous abordons également la manière de croiser les indicateurs et diagnostics de votre app par état à l'aide du framework StateReporting. Vous disposez ainsi d'une vue d'ensemble pour identifier des optimisations de l'expérience de votre app.
Chapitres
- 0:01 - Introduction
- 4:07 - Mesures
- 7:13 - Diagnostics
- 10:03 - Contexte
Ressources
- Getting started with StateReporting
- Analyzing app performance with MetricKit
- Monitoring app performance with MetricKit
- Track performance by app state using MetricKit
- MetricKit
Vidéos connexes
WWDC26
-
Rechercher dans cette vidéo…
-
-
4:59 - Receive metrics from MetricKit
// Receive metrics from MetricKit import MetricKit let manager = MetricManager() for await report in manager.metricReports { processReport(report) } -
5:25 - Send your metrics to the server
// Send your metrics to the server import MetricKit for await report in manager.metricReports { let jsonData = try JSONEncoder().encode(report) sendToServer(jsonData) } -
5:44 - Access your performance metrics
// Access your performance metrics import MetricKit for await report in manager.metricReports { let intervalEntries = report.intervalEntries let fullDayEntry = intervalEntries.fullDayEntry for entry in intervalEntries { let memoryMetrics = entry.values.filter { $0.metricGroup == .memory } for metric in memoryMetrics { switch metric { case .peakMemory(let peak): processPeakMemory(peak) default: break } } } } -
8:59 - Receive diagnostics
// Receive diagnostics import MetricKit let manager = MetricManager() for await report in manager.diagnosticReports { processReport(report) } -
9:14 - Send your diagnostic data to the server
// Send your diagnostic data to the server import MetricKit for await report in manager.diagnosticReports { let jsonData = try JSONEncoder().encode(report) sendToServer(jsonData) } -
9:39 - Access your diagnostic data
// Access your diagnostic data import MetricKit for await report in manager.diagnosticReports { switch report.result { case .crash(let crash): let backtrace = crash.callStackTree let reason = crash.terminationReason let category = crash.terminationCategory processCrash(backtrace: backtrace, reason: reason, category: category) case .hang(let hang): processHangDiagnostic(hang) default: break } } -
13:57 - Receive MetricKit data with states
// Receive MetricKit data with states import MetricKit import StateReporting let domain = StateReportingDomain("com.metrickitsample.tabs") let manager = MetricManager(enabledStateReportingDomains: [domain]) // Report transitions throughout the app let reporter = StateReporter.reporter(for: domain.rawValue) reporter.reportTransition(to: "Reports") -
14:21 - Define custom structured types
// Define custom structured types import StateReporting @ReportableMetadata struct ViewConfiguration { let listSize: String let isSorted: Bool } let reporter = StateReporter.reporter( for: domain.rawValue, stableMetadata: ViewConfiguration.self ) reporter.reportTransition( to: "Reports", stableMetadata: ViewConfiguration(listSize: "large", isSorted: false) ) -
15:29 - Send encoded metric reports to the server
// Send encoded metric reports to the server import MetricKit for await report in manager.metricReports { let encoder = JSONEncoder() let formatKey = MetricReport.encodingFormatKey encoder.userInfo[formatKey] = MetricReport.EncodingFormat.byStateReportingDomain let jsonData = try encoder.encode(report) sendToServer(jsonData) }
-