Comments (9)
+1
from dd-sdk-ios.
SwiftUI
Instrumentation APIs have been added in 1.9.0. Our documentation still need to be updated but here some snippets on how to use it:
- View Instrumentation:
import SwiftUI
import Datadog
struct FooView: View {
var body: some View {
FooContent {
...
}
.trackRUMView(name: "Foo")
}
}
- Tap Action Instrumentation:
import SwiftUI
import Datadog
struct BarView: View {
var body: some View {
Button("BarButton") { {
...
}
.trackRUMTapAction(name: "Bar")
}
}
It has been designed to work seamlessly with UIKit
auto-instrumentation for hybrid UIKit+SwiftUI
applications.
I will close this issue, but feel free to add any comment/feedback.
from dd-sdk-ios.
Hey @ferologics! Thanks for using it :)
We keep a stack of appeared view to consistently log start and stop view events, the last item of the stack is the visible one, any items below it have appeared but onDisappear
has not been called. Therefore, they are considered not visible but can be revealed if the last item disappears.
So if we have the following sequence, characteristically of a modal navigation:
- View A
onAppear
- View B
onAppear
- View B
onDisappear
The following events will be logged:
- Start View A
- Stop View A
- Start View B
- Stop View B
- Start View A
from dd-sdk-ios.
Hey @Alexander-techIOS ! Thanks for reaching out 🙂. We plan to support SwiftUI in the future, but I can't give any estimates. Please contact our support so we can track your interest in having SwiftUI compatibility for the iOS RUM SDK 💪.
from dd-sdk-ios.
Hi @ncreated!
I don't sure if it is the same issue but I am trying to integrate Datadog into a SwiftUI app. I understand that Datadog do not support SwiftUI, in terms of RUM, so it won't track the views or actions. But RUM also includes a mode in which it can tracks the request, but it seems to do not work also.
So I want to know if any feature inside Datadog will work on a SwiftUI app
from dd-sdk-ios.
Hello @saj11. Our manual instrumentation API offers a UI framework-agnostic variant which will work with SwiftUI
as well. When using SwiftUI
, you can leverage those two APIs to start and stop the RUM View:
Global.rum.startView(key:)
Global.rum.stopView(key:)
Network requests (auto)instrumentation will only work if there's a RUM View started, so please make sure that you call Global.rum.startView(key:)
from your SwiftUI's
view before the request is sent.
from dd-sdk-ios.
Hello @ncreated according to the manual instrumentation API you shared, Global.rum.startView(viewController: self) is the way to collect RUM resources. So what I don't understand how would that translate in the absence of a UIViewController in the case of swiftUI, the documentation is not clear when it comes to that. Thank you
from dd-sdk-ios.
Hello @hs-echkayben 👋. In case of view controller absence, you can use following APIs on RUMMonitor
:
dd-sdk-ios/Sources/Datadog/DDRUMMonitor.swift
Lines 51 to 69 in b19956c
With that, you can start and stop the view by giving String
key to match its ending with the beginning. In case of SwiftUI, I think this should work fine:
struct ContentView: View {
private let viewKey = "content-view" // must be unique
private let rumViewName = "ContentView"
var body: some View {
// ...
.onAppear {
Global.rum.startView(key: viewKey, name: rumViewName)
}
.onDisappear {
Global.rum.stopView(key: viewKey)
}
}
}
from dd-sdk-ios.
@maxep thanks for the update, this is very helpful! I'm currently integrating I'm curious how does the trackRUMView(name:)
method behave in case onDisappear()
of the view is not called?
from dd-sdk-ios.
Related Issues (20)
- Setting the log verbosity level produces a strict concurrency warning HOT 4
- Support for using `OSLog` HOT 5
- Automatic network requests tracing filters HOT 4
- RUM + Tracer works only one way HOT 2
- iOS Stack Trace for Error Log HOT 2
- Extract OpenTracing dependencies from dd-sdk-ios and use as a dependency HOT 1
- Typo of initialized in a warning message
- RUM implementation in SwiftUI does not work along with UINavigationController HOT 1
- Expose all the properties in PerformancePresetOverride DataDogFeature HOT 1
- Custom attributes weren't sent HOT 2
- What URLSessionDelegate should be used for automatic tracing? HOT 5
- Custom logs endpoint in 2.0 HOT 3
- Unexpected replacing `currentRequest` with `originalRequest` HOT 3
- Support for .NET iOS / .NET MAUI apps HOT 1
- How to flush SDK data for testing purpose? HOT 8
- Please reopen #1618
- Datadog v2.6.0 not sending trace to the dashboard HOT 2
- Crashes in `NetworkInstrumentationFeature.extractTrace` and ` NetworkInstrumentationFeature.intercept` HOT 12
- Network Tracing with swizzling HOT 5
- Adding request-based tags to url session spans HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dd-sdk-ios.