Overview
The Datadog iOS SDK for RUM allows you to instrument views and actions of SwiftUI
applications. The instrumentation also works with hybrid UIKit
and SwiftUI
applications.
Support for SwiftUI was introduced in the SDK v1.9.0.
Setup
For more information about setup, see iOS and tvOS Monitoring.
Instrument views
To instrument a SwiftUI.View
, add the following method to your view declaration:
import SwiftUI
import DatadogRUM
struct FooView: View {
var body: some View {
FooContent {
...
}
.trackRUMView(name: "Foo")
}
}
The trackRUMView(name:)
method starts and stops a RUM view when the SwiftUI
view appears and disappears from the screen.
Instrument tap actions
To instrument a tap action on a SwiftUI.View
, add the following method to your view declaration:
import SwiftUI
import DatadogRUM
struct BarView: View {
var body: some View {
Button("BarButton") { {
...
}
.trackRUMTapAction(name: "Bar")
}
}
Further reading
Additional helpful documentation, links, and articles: