I've developed a small Xamarin.Forms.Shell app: this app contains 4 tabs, where the default HomePage contains some basic informations.
I'm using AppCenter to track some events, like pages displays, users clicks, APIs calls,...
In the App.xaml.cs
I've specified 2 cases (Debug/prod) to register AppCenter:
protected override void OnStart()
{
// AppCenter
#if DEBUG
AppCenter.Start("ios=xxx;" +
"android=yyy;",
typeof(Analytics), typeof(Crashes));
#else
AppCenter.Start("ios=aaa;" +
"android=bbb;",
typeof(Analytics), typeof(Crashes));
#endif
}
Then, on the HomePage's ViewModel
, I'm doing this:
public HomeViewModel()
{
_eventTracker = new AppCenterEventTracker();
//...
_eventTracker.Display("HomePage");
}
Which refers to:
public virtual void Display(string page, ICollection<KeyValuePair<string, string>> optionalParams = null)
{
var mainParams = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>(EventProperty.Page, page),
};
Analytics.TrackEvent(EventType.Display, BuildParameters(mainParams, optionalParams));
}
On the NewsPage ViewModel
that is displayed through another tab, the code is:
public NewsViewModel()
{
_eventTracker = new AppCenterEventTracker();
//...
_eventTracker.Display("NewsPage");
}
This works well in Debug mode for iOS and Android: I can retrieve this event in AppCenter for all pages (the HomePage and other pages like NewsPage)
But when the app is built in Release mode, or through AppCenter, it's not the case for the HomePage: I only retrieve this event for iOS, but not for Android. For the other pages like NewsPage, I don't encounter any issue: the display is well taken into account...
So I think that the issue is related to the tab that is displayed by default in my app: the HomePage.
Would you have an explanation?
Edit:
Thanks to @Dmitriy Kirakosyan, I did some new tests: I've seen that in Debug mode too, the HomePage display's event is no longer tracked. In AppCenter I can see traces dating back for long weeks ago, but not for the latest weeks.
This could be related to the packages updates (Xamarin.Forms, AppCenter, ...) cause I didn't change the AppCenter initialization or the event tracking...
What is strange is that I can see in Debug mode that AppCenter.Start()
is well called before the HomePage display tracking.
But when I check the values of AppCenter.Configured
or Analytics.IsEnabledAsync()
just before this tracking, there are both False
:
var test1 = AppCenter.Configured;
var test2 = Analytics.IsEnabledAsync().Result;
_eventTracker.Display(EventPage.HomePage);