Azure Application Insights lets you monitor your published Mobile apps
- A subscription to Microsoft Azure
- Visual studio 2013 or later
Create an Application Insights resource
Log in to your azure portal.
In the azure portal, create a new Application Insights resource.
Select Application Type as Windows Phone Application (here you can choose in whichever the application you want to implement Application Insights, In my case it is Windows Phone Application)
Click on Create Button, It will create the Application Insights resource. A resource in Azure is an instance of a service. This resource is where telemetry from your app will be analyzed and presented to you.
Copy the Instrumentation Key
The key identifies the resource. You’ll need it soon, to configure the SDK to send the data to the resource.
Add the Application Insights SDK to your apps
In Visual Studio, add the appropriate SDK to your project.
If it’s a Windows Universal app, repeat the steps for both the Windows Phone project and the Windows project.
Right-click the project in Solution Explorer and choose Manage NuGet Packages.
1. Select Online, Include prerelease, and search for “Application Insights”.
2. Pick the latest version of the appropriate package – one of:
- Application Insights for Windows applications – for Windows Phone and Store apps
- Application Insights for Web Apps
- Application Insights API – for Windows desktop apps
3. Edit ApplicationInsights.config (which has been added by the NuGet install). Insert this just before the closing tag
Windows Universal apps: Repeat the steps for both the Phone and the Store project.
Enable network access for your app
If your app doesn’t already request outgoing network access, you’ll have to add that in the manifest as a required capability.
Run your Project
Run your application with F5 and use it, so as to generate some telemetry.
In Visual Studio, you’ll see a count of the events that have been received.
See Monitor data
Open Application Insights in your azure portal you just created you will be able to see some data in your Application Insights dashboard
From the Overview timeline, click through Users and Sessions charts to see more detailed analytics.
Users are tracked anonymously, so the same user on different devices would be counted twice.
A session is counted when the app is suspended (for more than a brief interval, to avoid counting accidental suspensions).
To discover the paths that users follow through your app, insert page view telemetry into your code:
See the results on the page views chart, and by opening its details:
Click through any page to see the details of specific occurrences.
By inserting code to send custom events from your app, you can track your users’ behavior and the usage of specific features and scenarios.
The data will appear in the Custom Events grid. You can either see an aggregated view in Metrics Explorer, or click through any event to see specific occurrences.
If you want you can also set up some properties and metrics along with the TrackEvent(). Below code explains how to set up properties and metrics.
So, when you go to the dashboard in the Custom Events you will ale to see the track event you created by the code and you will able to see the properties and metrics attached with the track event api.
And if you want to see the attached properties of that particular event just click on it view more information.
Use this to help diagnose problems by sending a ‘breadcrumb trail’ to Application Insights. You can send chunks of diagnostic data, and inspect them in Diagnostic search.
If you want to see the trace results, just open your AI resource and click on Diagnostic Search there you can see the number of traces has occurred.
Exceptions are reported to Application Insights by calling TrackException()
Debug vs Release mode
If you build in debug mode, events are sent as soon as they are generated. If you lose internet connectivity and then exit the app before regaining connectivity, offline telemetry is discarded.
If you build in release configuration, events are stored in the device and sent when the application resumes. Data is also sent on the application’s first use. If there is no internet connectivity upon startup, previous telemetry as well as telemetry for the current lifecycle is stored and sent on the next resume.
Monitor Crash Frequency
If your users experience crashes in your app, you’d like to know about it quickly, and you’d like details about what happened. With Application Insights, you can monitor how frequently crashes occur, get alerts when they occur, and investigate reports of individual incidents.
“Crash” means that the application terminates because of an uncaught exception. If your app catches an exception you can report it with the TrackException() API but continue running. In that case, it will not be logged as a crash.
Set an alert to detect crashes
Click on Alert Rules and then Alert Rules menu will open, in that select Add Alert
To find out if some versions of your app crash more than others, click through the crashes chart and then segment by Application Version:
To discover the exceptions that are causing crashes, open Diagnostic Search. You might want to remove other types of telemetry, to focus on the exceptions:
Click any exception to see its details, including associated properties and stack trace.
See the other exceptions and events that occurred close to that exception:
Using Diagnostic Search in Application Insights
When do you see Diagnostic Search?
You can open diagnostic search explicitly:
Inspect individual items
Select any telemetry item to see key fields and related items. If you want to see the full set of fields, click “…”.
Filter event types
Open the Filter blade and choose the event types you want to see. (If, later, you want to restore the filters with which you opened the blade, click Reset.)
Filter on property values
You can filter events on the values of their properties. The available properties depend on the event types you selected.