Instrument Xamarin.Forms
You can now instrument Xamarin.Forms elements using AppDynamics.Agent.Forms. To add the NuGet package Xamarin.Forms, see Instrument Xamarin Applications.
Page Tracking
Using Xamarin.Forms, you can track page usage and see the how your users interacts with your app in a session timeline.
To track pages, you must call TrackPage from the constructor on each page you want to monitor.
public partial class MyPage : ContentPage
{
public MyPage()
{
InitializeComponent();
AppDynamics.Agent.Forms.PageTracker.TrackPage(this);
}
}
Track UI Elements
You can track user interactions with these Ul elements:
- Buttons
- Entries
- ListViews
To instrument a UI element:
-
Attach a property to your views:
CODEappd:UiInstrumentation.IsInstrumented="True" -
Include the namespace:
CODExmlns:appd="clr-namespace:AppDynamics.Agent.Forms;assembly=AppDynamics.Agent.Forms"
Example
Example of an xaml file with instrumented UI elements:
<ContentPage
xmlns:appd="clr-namespace:AppDynamics.Agent.Forms;assembly=AppDynamics.Agent.Forms" >
<StackLayout>
<Button
appd:UiInstrumentation.IsInstrumented="True"
Clicked="OnButtonClicked" />
<Entry
appd:UiInstrumentation.IsInstrumented="True" />
<ListView
appd:UiInstrumentation.IsInstrumented="True">
<ListView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Item l</x:String>
<x:String>Item 2</x:String>
</x:Array>
</ListView.ItemsSource>
</ListView>
</StackLayout>
</ContentPage>
You can also instrument properties from code behind (i.e. in the xaml.cs file):
using AppDynamics.Agent.Forms;
...
var button = new Button();
button.SetValue(UiInstrumentation.IsInstrumentedProperty, true);
The IsInstrumented property tracks the following events:
- Button - Button clicked
- ListView - Item selected
- Entry - Entry focused and entry unfocused