Debug
The SDK is designed to be as silent as possible and use very few resources. You will therefore not get much information by default in your development console. We have 2 different debug log types that can be enabled / disabled at any time: info log and verbose log.
Info Log
Short messages will be output when enabled, explaining when some action is being performed by the SDK.
Enable info log when implementing the SDK, remember to turn it off in production!
ga_set_info_log(true);
Verbose Log
Console output when each event is added (all fields) in JSON string format. This is the data being submitted to the GA servers for each event.
Enable verbose log when troubleshooting events.
ga_set_verbose_log(true);
This can result in a lot of text. When troubleshooting or debugging events it is therefore recommended to enable and disable it around the action you need to inspect:
// enable verbose log
ga_set_verbose_log(true);
// add the event you need to troubleshoot / inspect
ga_add_design_event_with_value("Some:Event", 100);
// disable verbose log
ga_set_verbose_log(false);
Verify Implementation
Enable the Info Log to verify that events are being sent from your game project without any issues being reported.
Events submitted should register after a minor delay in our realtime dashboard in the GameAnalytics tool.
Event Queue
Whenever an event is added (and validated) it is added to a local database queue.
Every 8 seconds the SDK starts a task for submitting queued events since the last submit. This processing is done in a separate low-priority thread that has minimum impact on performance. The payload is gzipped and will therefore only consume a small amount of bandwidth.
When a device is offline the events are still added to the queue. When the device is back online it will submit them.
On Windows, macOS and Linux the uploads themselves are issued once per step by the obj_gameanalytics object that ga_initialize() creates. If that object was not imported with the SDK, the SDK logs a message at ga_initialize() and nothing is submitted on desktop. See the Setup page.
Thread Handling
Almost every piece of this code runs on a dedicated low-priority serial thread queue to avoid UI lag or sudden performance spikes.
The queue executes each task sequentially. If the SDK adds several tasks to the queue then each is executed in turn: a task could be adding an event or submitting all queued events. Consider this example with 3 calls:
// Configure build version
ga_configure_build("alpha 0.1.0");
// Initialize
ga_initialize(
"12341234123412341234123412341234",
"1234123412341234123412341234123412341234"
);
// Add design event
ga_add_design_event("Some:Event");
ga_configure_build is required to be called before ga_initialize is completely finished. The design event call is required after initialize is finished. The queuing makes sure that each task is completely finished before proceeding to the next one.