Training
Module
Use Power Apps Instrumentation with Application Insights - Training
This module explores how to set up a Microsoft Power Apps canvas app to send telemetry to Application Insights.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Important
Visual Studio App Center is scheduled for retirement on March 31, 2025. While you can continue to use Visual Studio App Center until it is fully retired, there are several recommended alternatives that you may consider migrating to.
App Center Analytics helps you understand user behavior and customer engagement to improve your app. The SDK automatically captures session count and device properties like model, OS version, etc. You can define your own custom events to measure things that matter to you. All the information captured is available in the App Center portal for you to analyze the data.
Follow the Get started section if you haven't set up the SDK in your application yet.
Once you add App Center Analytics to your app and start the SDK, it will automatically track sessions and device properties like OS Version, model, etc. without writing any additional code.
The SDK automatically reports a user's country code if the device has a mobile data modem and a SIM card installed. WiFi-only devices won't report a country code by default. To set the country code of those users, you must retrieve your user's location yourself and use the SetCountryCode:
method in the SDK:
AppCenter.SetCountryCode("en");
Note
For country code to be displayed on Analytics sessions, AppCenter.SetCountryCode
must be called prior to calling
AppCenter.Start
.
You can track your own custom events with up to 20 properties to understand the interaction between your users and the app.
Once you've started the SDK, use the TrackEvent()
method to track your events with properties. You can send up to 200 distinct event names. Also, there's a maximum limit of 256 characters per event name and 125 characters per event property name and event property value.
Analytics.TrackEvent("Video clicked", new Dictionary<string, string> {
{ "Category", "Music" },
{ "FileName", "favorite.avi"}
});
Properties for events are entirely optional – if you just want to track an event, use this sample instead:
Analytics.TrackEvent("Video clicked");
You can enable and disable App Center Analytics at runtime. If you disable it, the SDK won't collect any more analytics information for the app.
Analytics.SetEnabledAsync(false);
To enable App Center Analytics again, use the same API but pass true
as a parameter.
Analytics.SetEnabledAsync(true);
You don't need to await this call to make other API calls (such as IsEnabledAsync
) consistent.
The state is persisted in the device's storage across application launches.
Note
This method must only be used after Analytics
has been started.
You can also check if App Center Analytics is enabled or not.
bool isEnabled = await Analytics.IsEnabledAsync();
Note
This method must only be used after Analytics
has been started, it will always return false
before start.
By default, the session ID depends on the lifecycle of the application. If you want to control the start of a new session manually, follow the next steps:
Note
Pay attention that each call of Analytics.StartSession() API will generate a new session. If in manual session tracker mode this API will not be called then all sending logs will have a null session value.
Note
Pay attention that after a new application launch the session id will be regenerated.
Analytics.EnableManualSessionTracker();
StartSession
API after the AppCenter.Start
:Analytics.StartSession();
By default, the SDK stores up to 10 MB of logs in the storage.
When there isn't any network connectivity, the SDK saves up to 10 MB of logs in the local storage. Once the storage is full, the SDK will start discarding old logs to make room for the new logs. Once the device gets internet access back, the SDK will send logs in the batch of 50 or after every 6 seconds.
The App Center SDK uploads logs in a batch of 50 and if the SDK doesn't have 50 logs to send, it will still send logs after 6 seconds. There can be a maximum of three batches sent in parallel.
App Center SDK supports back-off retries on recoverable network errors. Below is the retry logic:
Back-off logic
Training
Module
Use Power Apps Instrumentation with Application Insights - Training
This module explores how to set up a Microsoft Power Apps canvas app to send telemetry to Application Insights.