Analytics #

Hiro provides a way to easily incorporate analytics and track the performance of your game. You can create custom analytics systems to send events to third-party services, and multiplex these analytics events to one or more analytics systems.

Hiro comes with built-in analytics systems for Firebase, Adjust, AppsFlyer, and Satori.

Initializing the analytics system #

The analytics system can be used to push events to multiple analytics systems which must be passed in as a dependency via the constructor, as well as an ILogger instance. These analytics systems must implement the IAnalyticsSystem interface. Hiro comes pre-packaged with systems for Satori, Firebase, Adjust and AppsFlyer.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
IList<IAnalyticsSystem> supportedAnalyticsSystems;

// Initialize individual analytics systems here e.g. 
// var satoriSystem = new SatoriSystem();
// var firebaseSystem = new FirebaseSystem();
// supportedAnalyticsSystems.Add(satoriSystem);
// supportedAnalyticsSystems.Add(firebaseSystem);

var analyticsSystem = new AnalyticsSystem(supportedAnalyticsSystems, logger);
systems.Add(analyticsSystem);

Satori #

The Satori analytics system pushes events into the Satori Live Ops Server and must be initialized with the connection credentials for the server as well as relies on the IUserSystem.

1
2
3
4
5
6
7
8
var scheme = "https";
var host = "<hostAddress>";
var port = 7450;
var apiKey = "<apiKey>";
var enabled = true;

var satoriSystem = new SatoriSystem(logger, scheme, host, port, apiKey, userSystem, enabled);
supportedAnalyticsSystems.Add(satoriSystem);

Firebase #

The Firebase analytics system pushes events into a configured Firebase instance. You must provide a Firebase configuration JSON file.

1
2
3
var timeBetweenRemoteConfigFetches = TimeSpan.FromHours(12);
var firebaseSystem = new FirebaseSystem(logger, timeBetweenRemoteConfigFetches);
supportedAnalyticsSystems.Add(firebaseSystem);

Adjust #

The Adjust analytics system pushes events into a configured Adjust instance.

1
2
3
AdjustEnvironment environment;
var adjustSystem = new AdjustSystem(userSystem, logger, "<appToken>", environment)
supportedAnalyticsSystems.Add(adjustSystem);

AppsFlyer #

The AppsFlyer analytics system pushes events into a configured AppsFlyer instance.

1
2
3
var appsflyerSystem = new AppsflyerSystem();
appsflyerSystem.Setup("<developmentKey>", "<appId>");
supportedAnalyticsSystems.Add(appsflyerSystem);

Event taxonomy #

Hiro also provides a default taxonomy of events to standardize what should be sent by most games.

EventDescription
InstallWhen players install the game for the first time.
AppLaunchWhen the players log in to the game. This event can be triggered when the game is opened, switched to foreground, or when a new session on the server is established.
AppClosedWhen the players close the game.
SignUpWhen players use a social account method or sign-up by a custom (such as e-mail) method provided within the game.
RewardedVideoShownWhen a Rewarded Video ad is displayed to the players.
BannerShownWhen a Banner is successfully displayed to the players.
InAppPurchaseWhen a player successfully completes and in-app purchase.
LevelStartWhen a player starts a new game or level.
LevelCompleteWhen a player successfully completes a level.
LevelFailedWhen a player fails to complete a level.
LevelRestartWhen a player manually restarts a level. The LevelStart event is always sent along with this event.
LevelAbandonWhen a player manually quits a level or the game.
PowerUpUsedWhen a player uses a power-up.
TutorialBeginWhen players begin the FTUE. Games can have multiple tutorials, to differentiate different tutorials and id parameter should be used.
TutorialStepCompletedWhen players complete a step in a tutorial.
TutorialEndWhen players complete the FTUE.
ScreenViewedWhen a player views a particular screen.
SdkInitializationWhen one of the SDKs used within the game has been initialized successfully or failed to initialize.
SetUserSet the user across all analytics systems.
SetUserPropertySet analytics user property to describe a player. This helps to analyze behaviors of various player segments by applying these properties as filters to your reports.
GameplayDurationWhen the gameplay duration is reached to one of the following levels (ie. 5, 10, 15, 30, 45, 60 minutes). The duration should be calculated as the player’s total time consumed in the game. Session can vary game to game but the general definition is each time a new session id is generated between the server and client.

These events can be logged directly by calling the associated method on the AnalyticsSystem. For example:

1
2
analyticsSystem.Install();
analyticsSystem.GameStart("<gameId>", "<gameType>");

You can also specify exactly which analytics providers you wish to submit the event to. If you omit this then the event will be sent to all.

1
analyticsSystem.TutorialBegin("<tutorialId>", new List<IAnalyticsSystem> { satoriSystem });

Custom events #

You can also send custom events to the analytics systems. The following is an example of a custom event:

1
2
3
4
5
6
7
8
9
var properties = new Dictionary<string, object>
{
    { "deviceId", SystemInfo.deviceUniqueIdentifier },
    { "deviceType", SystemInfo.deviceType },
    { "deviceOS", SystemInfo.operatingSystem },
    { "deviceModel", SystemInfo.deviceModel }
};

analyticsSystem.LogEvent("deviceInfo", properties);