Skip to main content

SDK features

Debugging

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
  • verbose log

Info log

Short messages will be output when enabled explaining when some action is being performed by the SDK. Sometimes cropping text / values to make it more readable.

warning

Enable info log when implementing the SDK – remember to turn it off in production!

gameanalytics::GameAnalytics::setEnabledInfoLog(true);
Info/GameAnalytics: Add DESIGN event: {eventId:someEvent, value:0}
Info/GameAnalytics: Add DESIGN event: {eventId:someOtherEvent, value:100}
Info/GameAnalytics: Add ERROR event: {severity:info, message:This is some in}

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:

gameanalytics::GameAnalytics::setEnabledVerboseLog(true);

This can result in a lot of text. When troubleshooting/debugging events it is therefore recommended to enable/disable when performing the action that need inspection.

Troubleshooting example:

// enable verbose log
gameanalytics::GameAnalytics::setEnabledVerboseLog(true);
// add event you need to troubleshoot / inspect
gameanalytics::GameAnalytics::addDesignEvent("Some:Event", 100);
// disable verbose log
gameanalytics::GameAnalytics::setEnabledVerboseLog(false);

Log file save location

By default the log files are saved in the following location:

  • Windows: %LOCALAPPDATA%/GameAnalytics
  • Mac OSX: ~/GameAnalytics
  • Linux: ~/GameAnalytics

If you wish to save the log files in a custom location you can do so by calling the following function:

GameAnalytics::configureWritablePath(const std::string& writablePath):

Event Queue

Whenever an event is added (and validated) it will be added to a local database queue.

Every 8 seconds the SDK will start a task for submitting queued events since last submit. This processing is done in a separate low-priority thread that will have 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 comes back online it will submit the cached events.

Thread Handling

Almost every piece of this code is run using a dedicated low-priority serial thread queue to avoid UI lag or sudden performance spikes. The queue will execute each task sequentially.

If the SDK adds several tasks to the queue then each will be executed in order. A task can be adding an event or submitting all queued events.

Consider this example with 3 calls:

// Configure build version
gameanalytics::GameAnalytics::configureBuild("alpha 0.1.0");
// Initialize
gameanalytics::GameAnalytics::initialize("12341234123412341234123412341234", "1234123412341234123412341234123412341234");
// Add Design event
gameanalytics::GameAnalytics::addDesignEvent("Some:Event");

The configureBuild is required to be called before initialize is completely finished. The design event call is required after initialize is finished. The queuing will make sure that each task is completely finished before proceeding to the next one.