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. Enable info log when implementing the SDK – remember to turn it off in production!

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.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.setEnabledVerboseLog(true)
# add event you need to troubleshoot / inspect
GameAnalytics.addDesignEvent({
"eventId": "Some:Event",
"value": 100
})
# disable verbose log
GameAnalytics.setEnabledVerboseLog(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.

tip

Read more about the realtime dashboard and our data processing.

Session Handling

Sessions are the concept of a user spending focused time in your game – from game launch to the user leaving the game.

Session Start

Adds a session start event (a “user” event). Starts the periodic activation of submitting queued events. Next event submit will fix potential missing session_end event from earlier sessions.

Example:

# start new session
GameAnalytics.startSession();

Session End

Stops the periodic activation of submitting queued events. Queues a session_end event and submits all queued events.

Example:

# end session
GameAnalytics.endSession();

If a session end event hasn’t been sent before the game shuts down, the session end will try to be sent next time the game starts again, as the required information for the session end event (for example session length) is stored in a internal database.

Event Queue

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

Submit Interval

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.

Offline

When a device is offline the events are still added to the queue. Once the device will come back online the queue will resume sending events to the server.

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 add several tasks to the queue then each will be executed in turn. A task could be adding an event or submitting all queued events.

Consider this example with 3 calls.

# Configure build version
GameAnalytics.configureBuild("alpha 0.1.0");
# Initialize
GameAnalytics.initialize({
gameKey: "[GAME KEY HERE]",
secretKey: "[SECRET KEY HERE]"
});
# Add Design event
GameAnalytics.addDesignEvent({
eventId: "Some:Event"
});
info

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.

Platform Builds

iOS

  • Export your project from Godot, it’ll create an Xcode project.
  • Copy the library (.a) you have compiled following the official documentation inside the exported Xcode project. You must override the ‘your_project_name.a’ file with this file.
  • Add the following frameworks to the project:
    • AdSupport
    • SystemConfiguration
    • libsqlite3.tbd
    • libz.tbd
    • libGameAnalytics.a (remember to copy it into the project)
  • Add the -ObjC linker flag to Other Linker Flags in your project’s build settings.

Web

Add this to your HTML template before building for web:

<script type="text/javascript" src="GameAnalytics.js"></script>

Add the GameAnalytics.js (found in the gameanalytics/javascript folder) to web build folder.

Mac

Since compiling everything on OSX is a bit tricky here are some errors you might run into.

error on export path with python 3: run export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/scons before running scons.
rpath error: When executing the editor you might get the following error

dyld: Library not loaded: @rpath/libGameAnalytics.dylib
Referenced from: /Users/mts/dev/github/godot/godot/bin/./godot.osx.tools.x86_64
Reason: image not found
Abort trap: 6

To solve the error, cd into your bin folder and run install_name_tool -add_rpath @executable_path/. godot.osx.tools.x86_64 on the editor executable and all OSX export templates.

packaging engine on OSX

cp -r misc/dist/osx_tools.app ./Godot.app
mkdir -p Godot.app/Contents/MacOS
cp bin/godot.osx.tools.x86_64 Godot.app/Contents/MacOS/Godot
chmod +x Godot.app/Contents/MacOS/Godot

packaging templates on OSX

cp -r misc/dist/osx_template.app .
mkdir osx_template.app/Contents/MacOS
cp bin/godot.osx.opt.x86_64 osx_template.app/Contents/MacOS/godot_osx_release.x86_64
cp bin/godot.osx.opt.debug.x86_64 osx_template.app/Contents/MacOS/godot_osx_debug.x86_64
chmod +x osx_template.app/Contents/MacOS/godot_osx*
zip -q -9 -r osx.zip osx_template.app
rm -rf osx_template.app

Windows

If you wan’t cross compile for Windows using Mingw remember to add the use_mingw=yes like this:

# Just an example some of the other parameters will of course change depending target and bits used
scons platform=windows tools=no target=release_debug use_mingw=yes bits=32