The Mobile SDK team here at Segment is excited to introduce Analytics-CSharp, a new SDK for use in .NET, Xamarin, and Unity. Several customers reached out about their desire for a well-supported analytics solution for their games and applications in the Unity 3d engine. We took the opportunity to modernize our support for Xamarin and .NET at the same time since Unity supports .NET Standard 2.0. As a result, we now have a single library with first class support across three platforms!
The new Analytics-CSharp SDK is available on Nuget, the standard package manager for .NET and Xamarin. In order to best support Unity, it’s also available through a popular third-party repository, OpenUPM. In all cases, it’s quick and easy to install directly from your IDE or with a simple CLI command. No manipulating of files or tweaking linker settings required!
To modernize our old .NET and Xamarin SDKs, we focused on the following areas: interface and performance.
The new SDK implements the same plugin architecture used by our next-generation libraries to provide a higher level of extensibility and flexibility. All of our SDKs feature destination plugins to channel analytics data directly from a mobile device to the many available data consumers such as Mixpanel. Our latest SDKs expand on this architecture by defining new plugin interfaces that can act at different points in the information pipeline. This allows you to write simple classes that could, for example, transform values to match a previous version or filter events before they are sent to your destinations. This can streamline how you instrument your application, limit excessive data, and match formatting for various services.
We have also made improvements to performance, both in terms of thread management and operations per minute. Our new threading library minimizes performance impacts to your application by handling analytics processing and communication in the background. We’ve also focused on reducing the overhead of processing events and lowering CPU usage. Our new Analytics library will have a minimal impact on the battery life of mobile devices, which in turn leads to more game play.
Let’s walk through adding Analytics to an Application. We’ll demo Unity’s Dragon Crashers UI Toolkit sample, but the changes here will be the same on any .NET platform, whether it’s Xamarin or a server application.
(https://assetstore.unity.com/packages/essentials/tutorial-projects/ui-toolkit-sample-dragon-crashers-231178)
Starting the Project
After creating an empty project, add the Dragon Crashers sample from Unity’s asset store. The import will overwrite your project with the sample’s resources. After it completes, try out the game, buy armor, and fight a dragon!