DeskMetrics Analytics for Java - Complete API reference

You probably went through the three minute tutorial, and learnt the basics of DeskMetrics Analytics, such as downloading our assembly, adding it CLASSPATH 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 API

The DeskMetrics Analytics Java 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 Java API code at Github

The com.DeskMetrics.DeskMetrics class

It is a singleton. For short, you can use it this way:

import com.DeskMetrics.DeskMetrics;

//gets the instance
DeskMetrics tracker = DeskMetrics.getInstance();

//initializes the application. you *must* do it.

tracker.start("your_app_id_here", "1.0");

// call this before the application finishes. you *must* do it

tracker.stop();

Note

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

The complete com.DeskMetrics.DeskMetrics class documentation is shown below:

void start(String appID, String version)

You must call this method. It is responsible for getting environment informations, such as processor, operating system and Java version.

void stop()

You must call this method just before your application ends. It is responsible for sending the data to DeskMetrics Analytics’ servers.

void trackEvent(String category, String name)

Simple event tracking.

void trackEventValue(String category, String name, String value)

Simple event tracking with an extra (“value”) option enabled.

void trackCustomData(String name, String value)

Tracks an customized data (useful for emails, telephone, extra system configuration, etc)

void trackCustomDataR(String name, String value)

Does the same thing as trackCustomData, but sends the data in real time.

void trackLog(String message)

Simple log utility.

void trackEventTimed(String category, String name, int time, boolean finished)

Tracks events related to time and intervals. It is useful for long-time operations (like disk defragmentation, big files download, and so on). Time must be specified in seconds.

void trackException(Exception e)

Tracks an exception and its details, such as stack trace and message.