Dynatrace.OneAgent.Xamarin 7.2.1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Dynatrace.OneAgent.Xamarin --version 7.2.1
NuGet\Install-Package Dynatrace.OneAgent.Xamarin -Version 7.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dynatrace.OneAgent.Xamarin" Version="7.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dynatrace.OneAgent.Xamarin --version 7.2.1
#r "nuget: Dynatrace.OneAgent.Xamarin, 7.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Dynatrace.OneAgent.Xamarin as a Cake Addin
#addin nuget:?package=Dynatrace.OneAgent.Xamarin&version=7.2.1

// Install Dynatrace.OneAgent.Xamarin as a Cake Tool
#tool nuget:?package=Dynatrace.OneAgent.Xamarin&version=7.2.1

Use this NuGet package to instrument your Xamarin Forms and Native apps with the Dynatrace OneAgent for mobile. Adding the package to your Xamarin projects will allow you to use auto instrumentation for Android and iOS. Additionally the package contains the required stub libraries to add manual instrumentation directly in your C# code.

Requirements of the NuGet package

  • Android: API 15 and above
  • iOS: iOS 6 and above
  • Forms: .NET Standard 1.5 and above

Configuration for Android Auto-Instrumentation

Adding Properties File

The Android Auto-Instrumentation needs some properties in order to work correctly. Those properties can be viewed when you look into the documentation links that are provided at the bottom of this documentation, here.

The properties file shoud be in the assets folder of your Android application and should be called 'Dynatrace.properties'.

Adding Target (Only for Forms based application)

This only needs to be done for Forms applications. The target will invoke the Android auto-instrumentation every time you bundle/build your APK. Open your .csproj file of your Android application with a file editor of your choice and include the following target within the <Project> tag.

<Target Name="DynatraceInstrumentation" AfterTargets="_BuildApkEmbed" Condition="Exists('@(ApkFiles)')">
    <PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
        <PathSeparator>/</PathSeparator>
        <Instrumentor>instrument.sh</Instrumentor>
    </PropertyGroup>

    <PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
        <PathSeparator>\</PathSeparator>
        <Instrumentor>instrument.cmd</Instrumentor>
    </PropertyGroup>
	
    <Error Condition="!Exists('$(ProjectDir)Assets$(PathSeparator)Dynatrace.properties')" Text="Properties File is not available!" />
    <Error Condition="!Exists('%(ApkFiles.Identity)')" Text="APK File(s) is (are) not available!" />
    <Error Condition="!Exists('$(ProjectDir)%(ApkFiles.Identity)')" Text="APK File(s) is (are) not available!" />

	<ItemGroup>
        <FilteredReferencesNuGet Include="@(_ReferencesFromNuGetPackages)" Condition="$([System.String]::new('%(_ReferencesFromNuGetPackages.FullPath)').Contains('Dynatrace.OneAgent.Android.dll'))" />
	    <FilteredReferences Include="@(Reference)" Condition="$([System.String]::new('%(Reference.HintPath)').Contains('Dynatrace.OneAgent'))" />
    </ItemGroup>
	
	<PropertyGroup>
	    <AgentDir Condition="'@(FilteredReferences)' != ''">@(FilteredReferences-&gt;'%(HintPath)')</AgentDir>
        <AgentDir Condition="'@(FilteredReferencesNuGet)' != ''">@(FilteredReferencesNuGet-&gt;'%(FullPath)')</AgentDir>
        <AgentDir Condition="'$(AgentDir.IndexOf(&quot;;&quot;))' != -1">$(AgentDir.Substring(0, $(AgentDir.IndexOf(";"))))</AgentDir>
    </PropertyGroup>

    <Error Condition="!Exists('$(AgentDir.Substring(0, $(AgentDir.LastIndexOf(&quot;$(PathSeparator)lib&quot;))))$(PathSeparator)tools$(PathSeparator)$(Instrumentor)')" Text="Agent component directory not found!" />
    <Exec Command="&#xD;&#xA;     &quot;$(AgentDir.Substring(0, $(AgentDir.LastIndexOf(&quot;$(PathSeparator)lib&quot;))))$(PathSeparator)tools$(PathSeparator)$(Instrumentor)&quot; apk=&quot;$(ProjectDir)%(ApkFiles.Identity)&quot; prop=&quot;$(ProjectDir)Assets$(PathSeparator)Dynatrace.properties&quot;&#xD;&#xA;" />
    <Copy SourceFiles="@(ApkFiles)" DestinationFolder="$(IntermediateOutputPath)android$(PathSeparator)bin$(PathSeparator)orginal$(PathSeparator)" />
    <Copy SourceFiles="$(IntermediateOutputPath)android$(PathSeparator)bin$(PathSeparator)%(ApkFiles.Filename)$(PathSeparator)dist$(PathSeparator)%(ApkFiles.Filename).apk" DestinationFolder="$(IntermediateOutputPath)android$(PathSeparator)bin$(PathSeparator)" />
    <RemoveDir Directories="$(IntermediateOutputPath)android$(PathSeparator)bin$(PathSeparator)%(ApkFiles.Filename)" />
</Target>

Configuration for iOS Auto-Instrumentation

  • Add some properties to the .plist file
  • Add at least one manual call to Dynatrace library

Adding Properties to .plist file

The iOS Auto-Instrumentation needs some properties in order to work correctly. Those properties can be viewed when you look into the documentation links that are provided at the bottom of this documentation, here.

Adding Manual call to the Dynatrace library

The Dynatrace framework would be removed during the build if no call happens to it. In this case it is necessary to add at least one call. Therefore you can use at the beginning of your application

Dynatrace.Start();

Manual Instrumentation in Xamarin Native

This can be done via package DynatraceIOS or DynatraceAndroid. Please refer to the official documentation of the Mobile Agent which contains the description for the API. Be aware that the API might be slightly different because the libraries had to be converted.

Manual Instrumentation in Xamarin Forms

To be able to use the Mobile Agent, even though you are in a Forms application, we added interfaces which can be registered via dependency service. To use those, you have to register them in the Startup of your native application part. Place this code right after Forms.Init() :

Xamarin.Forms.DependencyService.Register<Dynatrace.Dynatrace>();
Xamarin.Forms.DependencyService.Register<Dynatrace.Action>();

Be aware that not all functions are available that are in the available through the native packages DynatraceIOS.* or DynatraceAndroid.* . The following piece of code in your forms application allows you to access the agent:

IDynatrace dynatrace = DependencyService.Get<IDynatrace>();

The only additional functions is the function SetupHttpClient(HttpClient httpClient). Every HttpClient passed to this function will get an additonal handler which will take care of the manual web request instrumentation. All other available functions behave the same as their native counterparts.

Please look into the platform you want to instrument. Both platforms have different requirements. Also pay attention if you use Dynatrace Appmon or Dynatrace Saas/Managed, they mostly need different configurations.

Troubleshooting and current restrictions

  • WebRequests are not automatically instrumented (Android, iOS)
  • Lifecycles are tracked but not reported (iOS)
  • Some User Actions in iOS are not reported. (e.g. didSelectRowAt)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.5 is compatible.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed.  monoandroid41 is compatible. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed.  xamarinios10 is compatible. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.287.1 88 4/11/2024
8.285.2 185 3/12/2024
8.285.1 192 3/7/2024
8.283.1 447 1/29/2024
8.279.1 2,058 11/24/2023
8.277.1 2,014 10/11/2023
8.275.1 970 9/19/2023
8.273.2 2,092 9/8/2023
8.273.1 678 8/23/2023
8.271.2 63,399 7/26/2023
8.271.1 692 7/19/2023
8.269.0 880 6/28/2023
8.267.1 1,227 6/5/2023
8.265.1 1,387 5/3/2023
8.263.2 1,566 4/11/2023
8.263.1 668 4/11/2023
8.261.2 786 4/6/2023
8.261.1 18,025 3/14/2023
8.259.2 3,401 3/1/2023
8.259.1 8,172 2/10/2023
8.257.1 1,973 2/1/2023
8.253.1 9,342 11/3/2022
8.249.0 3,404 9/22/2022
8.247.0 82,515 9/5/2022
8.233.0 14,059 2/11/2022
8.225.0 18,223 8/19/2021
8.219.0 2,112 6/22/2021
8.213.0 24,443 3/9/2021
7.2.12 9,726 8/31/2020
7.2.11 1,514 8/20/2020
7.2.10 2,523 8/5/2020
7.2.9 13,920 3/4/2020
7.2.8 4,891 12/5/2019
7.2.5 6,457 9/27/2019
7.2.4 1,915 8/14/2019
7.2.3 7,396 3/21/2019
7.2.1 18,628 11/23/2018