Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio App Center Analytics Not working for Xamarin Forms Android Project

I am using Visual Studio App Center for my Xamarin Forms Android Application for capturing the Analytics(Events and Crashes)

I am configuring crashes and analytics in OnStart of my App.Xaml.cs

AppCenter.Start($"android={Settings.Current.AppCenterAnalyticsAndroid};" +
typeof(Analytics), typeof(Crashes));

And for invoking the Events I am calling the below Method.

public void TrackEvent(string name, Dictionary<string, string> properties = null)
{
       Analytics.SetEnabledAsync(true).ConfigureAwait(false);
       Analytics.TrackEvent(name, properties);
}

Crashes are logging correctly in App Center But the events are not. Also I can see the corresponding entries in Log Flow

like image 244
StezPet Avatar asked Jan 21 '26 14:01

StezPet


2 Answers

Your app secret string is invalid because it contains + typeof(Analytics), it should be , typeof(Analytics).

Since you used the android key/value delimiter we could extract the appSecret and make it work with Crashes, but typeof(Analytics) ended up in the wrong appSecret parameter string.

like image 125
Guillaume Perrot Avatar answered Jan 23 '26 08:01

Guillaume Perrot


You shouldn't need to add Analytics.SetEnabledAsync(true).ConfigureAwait(false);

Simply Call Analytics.TrackEvent(name, properties); (it doesn't need to be in a task anyways. I track my events in the Construtor of pages, for example.

Also, when you run the application, you get a debug Message confirming that AppCenter has been configured correctly, check if that is the case.

And, it may take a while, for them to appear in the Events.

like image 40
Bruno Caceiro Avatar answered Jan 23 '26 07:01

Bruno Caceiro