DeskMetrics Analytics for .NET and Mono - Complete API reference

You probably went through the three minute tutorial, and learnt the basics of DeskMetrics Analytics, such as downloading our SWC, adding it as a compiler reference and making a simple example using the DeskMetrics Analytics’ platform. If you haven’t done so, we recommend checking it out it before reading the complete documentation.

Basic information about DeskMetrics Analytics API

The DeskMetrics Analytics dotNet API is, basically, a wrapper for the DeskMetrics Analytics web service API. Its basic role is to take the data collected, serialize it into a JSON string and finally send it to DeskMetrics’ servers.

There are a few more features, like caching and background data sending (through a separate thread); If you are curious about our implementation, check our C# API code at Github

The DeskMetrics.Watcher class

This is the basic DeskMetrics Analytics API class. Its basic usage looks like:

using DeskMetrics;

//...

Watcher watcher = new Watcher();

//as the application starts:

watcher.Start("your_app_id","1.0");

//as your application ends:

watcher.Stop();

These are the two basic methods of the Watcher object.

Note

You can get your application id at http://analytics.deskmetrics.com/

The Watcher object has the following methods:

void Start(string AppID, string AppVersion)

Required function. Initializes the application by collecting some environment characteristics like operating system, Java and .NET version, processor, RAM usage and totals.

void Stop()

Required function. Must be called just before the application closes.

void SendDataAsync()

This method sends the data stats that were cached locally until now. It is specially useful for applications that are never supposed to be closed. It is also asynchronous, so your users won’t experience lags or performance issues.

void TrackEvent(string Category, string Name)

Simplest event tracking. You can use it on button clicks, form loads or another user-triggered event.

void TrackEventValue(string Category, string Name, string Value)

Tracks events with the extra “Value” option.

void TrackCustomData(string CustomDataName, string CustomDataValue)

Tracks custom data, like an specific user input. It can be useful when you want to get custom data without using TrackLog or TrackEventValue.

void TrackCustomDataR(string CustomDataName, string CustomDataValue)

Tracks custom data in real time, without waiting for the scheduler to send it later. It throws an exception if the server communication can’t be established (e.g. no internet access).

void TrackCachedCustomDataR(string CustomDataName, string CustomDataValue)

Just like TrackCustomDataR, but it stores the custom data if it can’t be sent in real time.

void TrackEventPeriod(string EventCategory, string EventName, int EventTime, bool Completed)

This method can be used to track time-consuming operations (like a form-fill by a user or a disk defragmentation by some utility tool).

The EventTime parameter is the time spent on the event (in seconds) and the Completed parameter is used to inform DeskMetrics Analytics if the event was successfully completed (false if it was cancelled/aborted or true, otherwise).

void TrackLog(string Message)

Simple log tracking.

void TrackException(Exception ApplicationException)

Tracks an exception with its attributes (stack trace, source, target site and message).

Services Services

Services object. Useful for some proxy and timeout configurations. See its documentation below.

The Deskmetrics.Service class

Responsible for the DeskMetrics Analytics API’s communication layer. It has some public attributes which can be used to configure some aspects of the network communication between DeskMetrics Analytics’ users and servers.

string ProxyHost

Default: null. Specify a proxy host or IP.

string ProxyUserName

Default: null. Specify a proxy user name, if the proxy has authentication.

string ProxyPassword

Default: null. Specify a password for accessing the proxy.

int ProxyPort

Default: null. Specify the proxy port.

int PostPort

Default: 80. Specify which port will be used to send data to DeskMetrics Analytics’ server. It supports two values: 80 (http) and 443 (https);

int PostTimeOut

Default: 25000. Timeout value in milliseconds.