Mobile Build Services
Analytics and Diagnostics
The course is part of this learning path
This course dives into creating a DevOps strategy for mobile applications using the Visual Studio App Center. The App Center gives us a centralized location where we can implement build services, carry out mobile UI testing with multiple devices sets, create public and private distribution groups, and perform release management for our distribution groups.
Build services include tvOS, iOS, Android, Xamarin, and more. UI testing includes UI testing across many popular flagship devices and uses a tier system to gradually cycle out older devices as newer ones become available. Distribution groups allow for deploying new releases to multiple types of users and can be utilized across multiple applications or projects. This course explains many of the options and services available in the App Center and provides guided demonstrations with a mobile app to show how each of these available services works.
By the end of this course, you should know how to utilize App Center to implement a DevOps strategy for integrating and deploying a mobile application. If you have any feedback relating to this course, please contact us at firstname.lastname@example.org.
- Create an App Center account and build a new application
- Perform UI tests in both the App Center CLI and Azure DevOps pipeline
- Create public and private distribution groups and release apps to them
- Understand and use the analytics and diagnostics provided by App Center
This course is intended for DevOps and IT professionals who are looking to implement a DevOps strategy for mobile applications using Visual Studio App Center to build, test, distribute, and deploy their mobile applications. This course is also useful for those preparing to take Microsoft's AZ-400 exam.
To get the most out of this course, you should know how to build and upload mobile applications if you are not using the build tools provided by the App Center. You should know how to work with Node package manager and have NPM installed or know how to install it. You should also be fairly comfortable with using command-line interface tools.
You can find the project files for a sample mobile application in the following GitHub repository: https://github.com/kelsosharp/MobileDevOps
In this demo, on App Center Analytics and Diagnostics, I will show you the steps you need to take to enable App Center, to track your application and implement basic event logging and error handling using the App Centers APIs.
I'm gonna show you how to set up an Android Xamarin application. The process will differ depending on the operating system and platform you're using to write your mobile application. You can find the steps to accomplish this task for each of the platforms on the main overview page for the app you wish to create.
I already have the application open and ready in visual studio. So let's go and take a look. If you'd like to follow along, you can clone the mobile application from a GitHub repository at the following URL.
We will be modifying the main activity CS file. This is the file I have open now. The first step we need to take is to add the App Center Analytics and Apps Center Crashes NuGet packages. Both of these are dependent on the App Center NuGet package, and it will be installed as a dependency of either of the two other packages.
So to install the NuGet packages, I'll right-click on our main DevOps project and select manage NuGet packages. You can also select the tools menu and the manage NuGet packages and then manage NuGet packages for solutions option if you prefer. After the package manager window has loaded, I'll click the browse and then type in microsoft.appcenter and filter the list of packages down. First I will install the App Center analytics package, and then I'll install the App Center crashes package. During the install, it will ask you to accept the package license agreement, and we can go ahead and click okay.
Once the packages are installed, we can go back to the main activity class and add the three using statements for App Center, App Center analytics, and Apps Center crashes to the using statement area.
Now that we have a reference to the App Center packages, we will need to start the analytics process thread. We can do this by using the App Center start method. We will need to use the App Center secret that you have on the main overview page of your app, in the App Center, you add this as a string to the first parameter of the start method. The second and third parameters are passing in the system type declaration for the analytics and crash classes.
We can now run this application on a device emulator, and it will show up on the main analytics page in App Center. Obviously there's not going to be a lot of useful data at this point, but I'm sure that you can imagine what this will look like with hundreds or even thousands of devices using your application.
The next thing we're gonna do is log in event to the log flow area in App Center. To do that, we just call it track event method on the analytic static object and pass in a string that has the message we want to add to the event log. So I'll just add the appcenter.track event call with the message letting us know that the main activity class has been executed.
I'm adding this code to the onCreate method of the main activity class. This will execute just before the main screen is loaded on the device. This is a good place to add the start method we added earlier. And as for the rest of the code snippets that we will add today, these can be added virtually anywhere you would add event logging or error handling normally in an application.
We will just quickly check out the Log Flow area in the Analytics section and make sure our event was passed in the App Center. And we can see there that it shows up in our logs.
Now we will add a bit of error handling. App Center diagnostics will report, both handled and unhandled exceptions and provide you with a stack trace of the crash. If you need more information, you can create a dictionary with a key value pair of type string and add additional data to send the App Center.
In order to generate an exception for this demonstration, the crash aesthetic object of the App Center NuGet package has a method called generate test crash. This takes no arguments, but we'll throw an exception for you.
We're gonna use this method within a try-catch block to add some additional data that we can send back to App Center using the crashes track error method. The benefit here is that we can use this to test error handling without actually crashing the application on the device. It becomes a handled error and the application carries on like nothing's wrong. And the user is not aware that there's even an issue.
It will take a few minutes to show up in the apps in our log flow area, but handled and unhandled exceptions will show up this log under the analytics tab.
Now on the diagnostics page, we can see that we had four crashes and they happen in the onCreate method of the main activity class. When we click on the error in the list, we can see more detailed information, things like the number of reports, percentage of users this issue is affecting, along with devices and operating systems affected. This is awesome information to have when we're trying to narrow down the exact cause of a bug.
To get even more detailed information on our crashes. We can have a look at the report tab. We can find demographics on the device, and this is also where we can find the custom data that we passed to App Center when we caught our error.
Additionally, if we wanted to, if the property's dictionary is not sufficient for our needs, when handling errors. For example, we're using a log file to gather additional information from the device itself and need to send it to the App Center. We can do this as an attachment, which will then be made available for us here.
App Center has provided us with an easily accessible way to get errors and crash data in a very simple and straightforward manner. I'm sure as time goes on, more and more features will be added to App Center to improve our mobile DevOps strategies, and App Center will become an invaluable tool in our DevOps utility belt.
As well being the owner and CTO of Sharp Solutions Group, a software development and IT staffing company based in the Philippines, Kelso is a Microsoft Certified professional and an avid knowledge seeker. His belief is that you need to learn something new each day to stay on top of the constantly changing IT world. He is an avid gamer (both video games and board games) and lives in the Philippines with his wife and soon-to-be-delivered son.