We want to instrument a iOS mobile application buil on SwiftUI. Will this work nicely with Dynatrace mobile app SDK?
Can find only a bit on this internally but it looks like it’s not something that we will auto-instrument at least not at this time. But since it’s just Swift I see no reason you couldn’t manually instrument it using the iOS OneAgent SDK.
I can confirm that pure SwiftUI is not yet supported, auto-instrumentation will not work for most UI elements and needs to be performed manually. Webrequest instrumentation will still work, but automatic linking to lifecycle action will not work for pure SwiftUI apps. In some scenarios automatic linking to manual actions might work. The SDK for manual instrumentation will work.
Thanks for your input!
With the latest release of the iOS agent (8.249) we have implemented auto-instrumentation of SwiftUI. Further improvements are on the way.
For more info please visit the documentation.
Hi,
I am trying to override the captured control titles. I saw on the documentation the properties dtxCustomControlName, dtxCustomCellName and dtxCustomCellName.
Is there anything for SwiftUI?
I want to display something better than “Touch on CollectionViewCell @0:1” for example.
Thanks
Did you check our documentation in that regard? Is there any specific feature missing that you’re looking after? https://docs.dynatrace.com/docs/observe/digital-experience/mobile-applications/instrument-ios-app/instrumentation/instrument-swiftui-controls#swiftui-control-labels
I did check this documentation before. I saw the option:
Button("Login", action: {
/* perform login */
}).withCustomInstrumentationConfig(.useControlName("Login Button"))
But when I try to use useControlName, it says that is has not member with this name.
I checked the SwiftUIInstrumentationConfigParam and I only found those three options: skipInstrumentation, useDefaultControlName, doNotReportStateVariable
How do I set my own control name?
Thanks
The useControlName property was introduced in the 8.317 release of the iOS agent. This will work for most of the instrumented controls, such as buttons, toggles, pickers, sliders, etc.
However, in your case, “Touch on CollectionViewCell @0:1” is an action that is generated by the UIKit instrumentation of UICollectionView, which exists under the hood when you create a SwiftUI List. Currently, this naming can’t be modified.
Is it a limitation from SwiftUI? Or is something that I can expect support from Dynatrace in the future? Thanks
Generally, we’re much more limited in terms of instrumentation when it comes to SwiftUI due to its declarative nature. Currently, we can detect a SwiftUI list interaction when either its selection property changes or it contains navigation links (declared as NavigationLink or navigationDestination view modifier).
In all other cases, the instrumentation is handled by the iOS agent and not the SwiftUI instrumentor via the UICollectionView, and customising UIKit behavior from SwiftUI code is more complex.
We do, however, regularly reevaluate different approaches, and we may improve support in the future.