Skip to content

copper/statsmix_jar

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 

Repository files navigation

StatsMix Java Library

This library offers easy access to the StatsMix API using Java. See http://www.statsmix.com/developers/documentation for more information about the StatsMix API. What is StatsMix?

StatsMix makes it easy to track, chart, and share application and business metrics. Use StatsMix to:

  • Log every time a particular event happens (such as a user creating a new blog post)
  • View a real-time chart of these application events in StatsMix's web UI
  • Share the charts with users inside and outside your organization
  • Create and share custom dashboards that aggregate multiple metrics together

To get started, you'll need an API key for StatsMix. You can get a free developer account here: http://www.statsmix.com/try?plan=developer

Full gem documentation is at http://www.statsmix.com/developers/java_library

Download and Install

Include these jars in your build path:
The jar file: [statsmix-1.1.0.jar] dl_jar
It's dependencies: [statsmix-lib-dependencies.tar.gz] dl_dep
Links to all the depedencies if you need to resolve version errors:

Usage

###Initialize Create a new StatsMix Client

import com.statsmix.*
Client smClient = new Client("YOUR_API_KEY");

###Track The track method sends a request to the track API, and returns the XML response as a string. The following snippets were taken from [this example file.] track_exmpl

Basic Tracking. Adds a new stat with default value of 1 to the metric.

smClient.track("Metric Name");

Track with a value other than one

smClient.track("Metric Name", 5.2);

Track with additional properties

List<NameValuePair> properties = new ArrayList<NameValuePair>(2);
properties.add(new BasicNameValuePair("value", "5.2"));  //if you do not include the value, it will default to 1
properties.add(new BasicNameValuePair("ref_id", "java01"));
properties.add(new BasicNameValuePair("generated_at", getDateTime()));
smClient.track("Metric Name", properties);

Track with meta data

JSONObject meta = new JSONObject();
meta.put("food", "ice cream");
meta.put("calories", 500);
smClient.track("Metric Name", properties, meta);

A method for formating the date

public String getDateTime() {
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    Date date = new Date();
    return dateFormat.format(date);
}

Releases

No releases published

Packages

No packages published