gameanalytics 0.1.5

Haxe SDK for

Released 2016-03-17.

To install, run:

haxelib install gameanalytics 0.1.5

See using Haxelib in Haxelib documentation for more information.

Current version0.1.5
StatisticsInstalled 22 times
Tags analytics

Haxe game analytics

How to install: haxelib install gameanalytics Here's a quick code snippet, explaining how to use the library: (For more info see documentation in code)


//Instantiate new GameAnalytics object with public and private keys
//If the third parameter is true, a sandbox gameanalytics server will be used, so set it to false for production
var ga:GameAnalytics = new GameAnalytics("0123456789abcdef0123456789abcdef", "0123456789abcdef0123456789abcdef01234567", false);
//Now we need to initialize it with success and fail callbacks, platform, os version, device and manufacturer. Some of these parameters may be removed later and auto generated instead.
//IMPORTANT! Platform and os version must follow Game Analytics validation rules (see #1)
ga.Init(onSuccess, onFail, GAPlatform.WINDOWS, GAPlatform.WINDOWS + " 10", "unknown", "manufacturer");
function onSuccess():Void
  //Success callback is called when init request return success.
function onFail(error:String):Void
  //Fail callback basically means that GameAnalytics can't work right now. Offline event caching is not yet available.
  //String parameter may contain useful information on why fail happened
//If you want a callback every time sending events fail or succeed, just rebind OnSubmitSuccess() and OnSubmitFail(reason:String) dynamic methods
ga.OnSubmitFail = onSubmitFail;
function onSubmitFail(reason:String):Void

Sending events

//Events are send by calling Send<Type>Event. They are locally stored and then are submitted in batches to the GA servers
//Call StartPosting() (only once), and all sent events will be periodically submitted to the server
ga.SendBusinessEvent("gems", "green_gem", 1, "USD");
//You can also call ForcePost(), but it's recommended only for a few situations
//For example, when your game is about to be closed you can do the following:
ga.EndSession();//send EndSession event
//For more information on event types and parameters, see documentation in the code

Advanced stuff

//Call Create<Type>Event if you want to get an event and further customize it (e.g. change default fields or set optional values), after that call SendEvent(event)
var e:DesignEvent = ga.CreateDesignEvent("world");
e.value = 4.2;
e.custom_01 = "ninja";
//Send<Type>Event is an alias for SendEvent(Create<Type>Event)