June 24th, 2019

Three SDK Tips To Get More From Visual Studio App Center Analytics

Visual Studio App Center Analytics helps you understand how people use your application. The SDK automatically captures several properties like device, OS, country, language etc. and allows you to define your own custom events to measure things that uniquely matter to your business. Once the data is captured, it’s available in the App Center portal where we provide detailed insights.

In this post, I’m going to share how you can best leverage and utilize client-side APIs supported in the App Center SDK to have control and flexibility on storing, prioritizing, and sending the Analytics data to App Center backend.

Set the Priority of Events

Developers instrument different types of events in their app and not all these events have the same level of importance and priority. Some events are important for business needs, so it is a common practice to associate priority with events, making it easier to differentiate. App Center SDK supports an easy way to mark high priority events as Critical in the trackEvent() API. Events tagged as Critical are given preferential treatment over Normal events – both for the purpose of transmission as well as local storage. The critical events will be retrieved from storage first and sent before Normal events. When the local storage is full and new events needs to be stored, the oldest events that have the lowest priority are deleted first to make room for the new ones. The SDK treats events as Normal if the parameter to specify priority isn’t set in trackEvent() API.

Android

Map<String, String> properties = new HashMap<>();

properties.put("Category", "Music");

properties.put("FileName", "favorite.avi");

Analytics.trackEvent(“MyEvent”, properties, Flags.Critical);

 

As a good practice, it’s recommended to mark only certain events as Critical. They should be highly important events that help you understand your business and that you can’t afford to lose.

Set the Time Interval for Sending Data

The flexibility on how often to send analytics events proves to be important as developers can control the frequency of sending their data depending on various characteristics like bandwidth, network usage, battery life, app type etc. They might decide to send the data every few minutes, every few hours, or only once a day. App Center SDK provides an API you can leverage to set the transmission interval for sending Analytics data to our backend. The default SDK interval is every 3 seconds or a batch of 50 logs but using the API below, you customize the time interval. Once set, the SDK will start sending data based on the defined interval.

Android

Analytics.setTransmissionInterval(3600);

The API call above will instruct the SDK to send data every hour.

Pause and Resume Sending Data to App Center Backend

There are scenarios where you want to have fine-grained control on when to send data. For example – you want to wait for WiFi connectivity before sending the data or your app might be performing network intensive operations like a video call where you want to eliminate the contention for network resources. In that case, you can signal the SDK to pause sending the data to App Center backend. Once your important operation is performed, you can resume sending the app data to App Center. You can easily use the client API to enable this functionality. The SDK will continue to store the data in the device local storage when the transmission is paused and will start sending the data again once resumed.

Android

Analytics.pause();

Analytics.resume();

 

You can use these features individually or easily combine them to have greater control and flexibility on sending Analytics data to App Center.

Most of these features are supported in iOS and Android platform for now. Update your app code to add these client SDK features based on your scenarios and share your feedback on App Center GitHub repo.

 

0 comments

Discussion are closed.