SDK Features
Debug & Event Verification
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 the Xcode console. We have 2 different debug log types that can be enabled / disabled independently:
- 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!
- Objective-C
- Swift
// Objective-C
[GameAnalytics setEnabledInfoLog:YES];
// Swift
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.
- Objective-C
- Swift
// Objective-C
[GameAnalytics setEnabledVerboseLog:YES];
// Swift
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.
- Objective-C
- Swift
// Objective-C
// enable verbose log
[GameAnalytics setEnabledVerboseLog:YES];
// add event you need to troubleshoot / inspect
[GameAnalytics addDesignEventWithEventId:@"Some:Event" value:@100];
// disable verbose log
[GameAnalytics setEnabledVerboseLog:NO];
// Swift
// enable verbose log
GameAnalytics.setEnabledVerboseLog(true)
// add event you need to troubleshoot / inspect
GameAnalytics.addDesignEvent(withEventId: "Some:Event" value:100)
// disable verbose log
GameAnalytics.setEnabledVerboseLog(false)
Verification
You can 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 dashboard.
Read more about the realtime dashboard and our data processing.
Session Handling
By default the SDK will handle session start/end automatically, but it is also possible to manually control this yourself.
Be aware that the initialization will always automatically start the first session even with manual session handling.
Automatic session handling
The automatic session handling will track the focused time the user is spending in your game – from game launch to the user leaving the game.
session start
On iOS a new session will start once the SDK is initialized or when the game is going to foreground.
session end
A session will end once the game is going to background.
Manual session handling
You can enable/disable manual session handling if you wish to control when sessions end/start.
- Objective-C
- Swift
// Objective-C
[GameAnalytics setEnabledManualSessionHandling:YES];
// Swift
GameAnalytics.setEnabledManualSessionHandling(true)
You will then need to call endSession
and startSession
at the appropriate times.
With manual session handling it is recommended to also call endSession
when the game goes into the background. This will ensure a correct session ending when users click the home or on/off button.
startSession()
This will start a new session if the manual session handling is enabled. If a current session is active then it will end the current session and start a new one.
- Objective-C
- Swift
// Objective-C
[GameAnalytics startSession];
// Swift
GameAnalytics.startSession()
endSession()
This will end a session if the manual session handling is enabled or if a session is already active (initialize
will start a session automatically)
- Objective-C
- Swift
// Objective-C
[GameAnalytics endSession];
// Swift
GameAnalytics.endSession()