DeskMetrics Analytics for Delphi - Complete API reference

You probably went through the three minute tutorial, and learnt the basics of DeskMetrics Analytics, such as downloading our library and DLL, adding it as a reference and making a very 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 Delphi API code at Github

Basic example

The basic Delphi API usage looks like:

use DeskMetrics;

//as the application starts:

DeskMetricsStart("your_app_id","1.0");

//as your application ends:

DeskMetricsStop;
function DeskMetricsStart(FApplicationID: PWideChar; FApplicationVersion: PWideChar): Boolean

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

function DeskMetricsStop: Boolean

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

function DeskMetricsSendData: Boolean

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. You should create a thread to call this function, so that your users don’t experience lags or performance issues.

procedure DeskMetricsTrackEvent(FEventCategory, FEventName: PWideChar)

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

procedure DeskMetricsTrackEventValue(FEventCategory, FEventName, FEventValue: PWideChar)

Tracks events with the extra “Value” option.

procedure DeskMetricsTrackCustomData(FName, FValue: PWideChar)

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

function DeskMetricsTrackCustomDataR(FName: PWideChar; FValue: PWideChar): Integer

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)

procedure DeskMetricsTrackEventPeriod(FEventCategory, FEventName: PWideChar; FEventTime: Integer; FEventCompleted: Boolean)

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 to DeskMetrics Analytics if the event was successfully completed (false if it was cancelled/aborted or true, otherwise).

procedure DeskMetricsTrackLog(FMessage: PWideChar)

Simple log tracking.

procedure DeskMetricsTrackException(FExpectionObject: Exception)

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

Note

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