Remote Configurations
GameAnalytics' Remote Configurations feature offers the ability to set up and tune values in your game's dashboard.
These values can be changed on the whim without needing to release a new version of the game.
The remote configs are a custom set of key-pair values.
Set up your Remote Configurations in the GameAnalytics dashboard.
Check the status
Remote Configurations may not be available immediately, as they need to be retrived from the server. The remote configurations may be populated later during the session.
Once the Remote Configurations have been downloaded, isRemoteConfigsReady will return true.
if gameAnalytics.isRemoteConfigsReady():
# your code here...
Remember the remote configs can be populated with an empty dictionary if the device is offline and there are no cached remote configs from a previous session.
Listen for updates
Instead of checking isRemoteConfigsReady yourself, you can register a listener with registerRemoteConfigsListener (SDK 3.1.1 and later). The listener is called when the Remote Configurations are updated, and receives all remote configs as a JSON string (the same content as getRemoteConfigsContentAsString).
func _ready():
var gameAnalytics = Engine.get_singleton("GameAnalytics")
gameAnalytics.registerRemoteConfigsListener(_on_remote_configs_updated)
func _on_remote_configs_updated(configs: String):
# remote configs are now available
print("Remote Configs: " + configs)
var gameAnalytics = Engine.get_singleton("GameAnalytics")
var remoteValue = gameAnalytics.getRemoteConfigsValueAsString("my_key", "my_defaultValue")
- The listener is called on the main thread, so it is safe to update nodes from it.
- You can register the listener before or after calling
init. - You can register more than one listener. Registering the same listener twice has no effect.
- The listener is connected to the
remote_configs_updatedsignal of theGameAnalyticssingleton.
The listener is only called for updates that happen after you register it. If the remote configs may already have been downloaded at that point, also check isRemoteConfigsReady.
Retrieving values from Remote Configurations
Once the remote configurations have been downloaded, you can start using them inside your game. GameAnalytics supports 2 types of remote configurations:
- string
- json object
You can either get individual values by their key or get all remote configurations as a json string and parse it yourself. To get values out of a populated Remote Config you can use the following methods:
# assure that the remote configs have been downloaded
if gameAnalytics.isRemoteConfigsReady():
# retrieve a remote config as string with a fallback value
var remoteValue = gameAnalytics.getRemoteConfigsValueAsString("my_key", "my_defaultValue")
# retrieve a json object configuration
var remoteJson = gameAnalytics.getRemoteConfigsValueAsJSON("my_json_key")
# print all remote configs
print("Remote Configs: " + gameAnalytics.getRemoteConfigsContentAsString())