Skip to main content
Version: Config V1

Unreal Engine SDK Reference

Star on GitHub Build Status

ConfigCat Unreal SDK on GitHub

info

This documentation applies to the v1.x version of the ConfigCat Unreal SDK. For the documentation of the latest release, please refer to this page.

Getting Started:

1. Installing the ConfigCat plugin to your project

Via Unreal Marketplace

Via GitHub clone

Prequesities to cloning manually:

Run the following commands in the root folder of your project (where the .uproject file is located):

mkdir -p Plugins
cd Plugins
git clone https://github.com/configcat/unreal-engine-sdk ConfigCat

2. Enable the ConfigCat plugin in your project

Unreal Engine enable plugin

Navigate to Edit -> Plugins and perform the following steps:

  1. Find the Config Cat plugin and tick the enable checkbox.
  2. Press Restart to load up the editor.

Note: if you are using a locally built plugin, you will need to rebuild from source manually.

3. Set up the ConfigCat settings with your SDK Key

You can configure all ConfigCat related settings inside the ProjectSettings -> Feature Flags -> ConfigCat.

Unreal Engine plugin settings
PropertiesDescription
Sdk KeySDK Key to access your feature flags and configurations. Get it from ConfigCat Dashboard.
Base UrlOptional, sets the CDN base url (forward proxy, dedicated subscription) from where the sdk will download the config JSON.
Data GovernanceOptional, defaults to Global. Describes the location of your feature flag and setting data within the ConfigCat CDN. This parameter needs to be in sync with your Data Governance preferences. More about Data Governance. Available options: Global, EuOnly.
Connect TimeoutOptional, defaults to 8000ms. Sets the amount of milliseconds to wait for the server to make the initial connection (i.e. completing the TCP connection handshake). 0 means it never times out during transfer
Read TimeoutOptional, defaults to 5000ms. Sets the amount of milliseconds to wait for the server to respond before giving up. 0 means it never times out during transfer.
Polling ModeOptional, sets the polling mode for the client. More about polling modes.
Auto Poll IntervalFor PollingMode == Custom, sets at least how often this policy should fetch the latest config JSON and refresh the cache.
Maximum Inititial Wait TimeFor PollingMode == Custom, sets the maximum waiting time between initialization and the first config acquisition in seconds.
Cache Refresh IntervalFor PollingMode == LazyLoad, sets how long the cache will store its value before fetching the latest from the network again.
ProxiesOptional, sets proxy addresses. e.g. { "https": "your_proxy_ip:your_proxy_port" } on each http request
Proxy AuthenticationsOptional, sets proxy authentication on each http request.
Start OfflineOptional, sets the SDK ot be initialized in offline mode.

4. Get your setting value

Unreal Engine Get Value

Anatomy of GetValue

ParametersDescription
KeyREQUIRED. The key of a specific setting or feature flag. Set on ConfigCat Dashboard for each setting.
Default ValueREQUIRED. This value will be returned in case of an error.
UserOptional, User Object. Essential when using Targeting. Read more about Targeting.
Unreal Engine Get Value OverloadsUnreal Engine Get Values Targeted

Anatomy of GetValueDetails()

GetValueDetails() is similar to GetValue() but instead of returning the evaluated value only, it gives more detailed information about the evaluation result.

ParametersDescription
KeyREQUIRED. The key of a specific setting or feature flag. Set on ConfigCat Dashboard for each setting.
Default ValueREQUIRED. This value will be returned in case of an error.
UserOptional, User Object. Essential when using Targeting. Read more about Targeting.
Unreal Engine Get Value Details

The Details result contains the following information:

FieldDescription
ValueThe evaluated value of the feature flag or setting.
KeyThe key of the evaluated feature flag or setting.
Is Default ValueTrue when the default value passed to getValueDetails() is returned due to an error.
ErrorIn case of an error, this field contains the error message.
UserThe User Object that was used for evaluation.
Matched Evaluation Percentage RuleIf the evaluation was based on a percentage rule, this field contains that specific rule.
Matched Evaluation RuleIf the evaluation was based on a Targeting Rule, this field contains that specific rule.
FetchTimeThe last download time of the current config.

User Object

The User Object is essential if you'd like to use ConfigCat's Targeting feature.

Unreal Engine Create User

Customized User Object creation

ArgumentDescription
IdREQUIRED. Unique identifier of a user in your application. Can be any value, even an email address.
EmailOptional parameter for easier Targeting Rule definitions.
CountryOptional parameter for easier Targeting Rule definitions.
CustomOptional dictionary for custom attributes of a user for advanced Targeting Rule definitions. e.g. User role, Subscription type.
Unreal Engine Create User Custom

Default user

There's an option to set a default User Object that will be used at feature flag and setting evaluation. It can be useful when your application has a single user only, or rarely switches users.

You can set the default User Object with the setDefaultUser() method of the ConfigCat client.

Unreal Engine Set Default User

Whenever the GetValue(), GetValueDetails(), GetAllValues(), or GetAllValueDetails() methods are called without an explicit user parameter, the SDK will automatically use the default user as a User Object.

Unreal Engine Default User Example

When the user parameter is specified on the requesting method, it takes precedence over the default user.

Unreal Engine Other User Example

For deleting the default user, you can do the following:

Unreal Engine Clear Default User

Polling Modes

The ConfigCat SDK supports 3 different polling mechanisms to acquire the setting values from ConfigCat. After latest setting values are downloaded, they are stored in the internal cache then all GetValue() calls are served from there. With the following polling modes, you can customize the SDK to best fit to your application's lifecycle.
More about polling modes.

Auto polling (default)

The ConfigCat SDK downloads the latest values and stores them automatically every 60 seconds.

Unreal Engine Polling Mode Auto

Available options:

Option ParameterDescriptionDefault
Auto Poll IntervalPolling interval.60
Max Inititial Wait TimeMaximum waiting time between the client initialization and the first config acquisition in seconds.5

Lazy Loading

When calling getValue() the ConfigCat SDK downloads the latest setting values if they are not present or expired in the cache. In this case the getValue() will return the setting value after the cache is updated.

Unreal Engine Polling Mode Lazy

Available options:

ParameterDescriptionDefault
Cache Refresh IntervalCache TTL.60

Manual Polling

Manual polling gives you full control over when the config JSON (with the setting values) is downloaded. ConfigCat SDK will not update them automatically. Calling ForceRefresh() is your application's responsibility.

Unreal Engine Polling Mode Manual
Unreal Engine Manual Force Refresh

GetValue() returns DefaultValue if the cache is empty. Call ForceRefresh() to update the cache.

Delegates

With the following delegates you can subscribe to particular events fired by the SDK:

  • OnClientReady: This event is sent when the SDK reaches the ready state. If the SDK is initialized with lazy load or manual polling, it's considered ready right after instantiation. If it's using auto polling, the ready state is reached when the SDK has a valid config JSON loaded into memory either from cache or from HTTP. If the config couldn't be loaded neither from cache nor from HTTP the onClientReady event fires when the auto polling's maxInitWaitTimeInSeconds is reached.

  • OnConfigChanged: This event is sent when the SDK loads a valid config JSON into memory from cache, and each subsequent time when the loaded config JSON changes via HTTP.

  • OnFlagEvaluated: This event is sent each time when the SDK evaluates a feature flag or setting. The event sends the same evaluation details that you would get from getValueDetails().

  • OnError: This event is sent when an error occurs within the ConfigCat SDK.

You can subscribe to these events either on SDK initialization:

Unreal Engine Blueprint Event Delegates

Online / Offline mode

In cases when you'd want to prevent the SDK from making HTTP calls, you can put it in offline mode with SetOffline.

In offline mode, the SDK won't initiate HTTP requests and will work only from its cache.

To put the SDK back in online mode, you can use SetOnline;

With IsOffline you can check whether the SDK is in offline mode.

Unreal Engine Blueprint Offline Functionality

Flag Overrides

With flag overrides you can overwrite the feature flags & settings downloaded from the ConfigCat CDN with local values. Moreover, you can specify how the overrides should apply over the downloaded values. The following 3 behaviours are supported:

  • Local only (OverrideBehaviour::LocalOnly): When evaluating values, the SDK will not use feature flags & settings from the ConfigCat CDN, but it will use all feature flags & settings that are loaded from local-override sources.

  • Local over remote (OverrideBehaviour::LocalOverRemote): When evaluating values, the SDK will use all feature flags & settings that are downloaded from the ConfigCat CDN, plus all feature flags & settings that are loaded from local-override sources. If a feature flag or a setting is defined both in the downloaded and the local-override source then the local-override version will take precedence.

  • Remote over local (OverrideBehaviour::RemoteOverLocal): When evaluating values, the SDK will use all feature flags & settings that are downloaded from the ConfigCat CDN, plus all feature flags & settings that are loaded from local-override sources. If a feature flag or a setting is defined both in the downloaded and the local-override source then the downloaded version will take precedence.

You can set up the SDK to load your feature flag & setting overrides from a file or a map.

Unreal Engine Settings Overrides

JSON File

The SDK can be set up to load your feature flag & setting overrides from a file.

File

If specified the SDK will load the JSON data %PROJECT_ROOT/Content/ConfigCat/flags.json file. This file needs to be created manually in the specified folder to ensure it gets packaged in the final executable.

Note: This file needs to be created in your file explorer and cannot be done within Unreal.

JSON File Structure

The SDK supports 2 types of JSON structures to describe feature flags & settings.

1. Simple (key-value) structure
{
"flags": {
"enabledFeature": true,
"disabledFeature": false,
"intSetting": 5,
"doubleSetting": 3.14,
"stringSetting": "test"
}
}

This is the same format that the SDK downloads from the ConfigCat CDN. It allows the usage of all features that are available on the ConfigCat Dashboard.

You can download your current config JSON from ConfigCat's CDN and use it as a baseline.

The URL to your current config JSON is based on your Data Governance settings:

  • GLOBAL: https://cdn-global.configcat.com/configuration-files/{YOUR-SDK-KEY}/config_v5.json
  • EU: https://cdn-eu.configcat.com/configuration-files/{YOUR-SDK-KEY}/config_v5.json
{
"f": {
// list of feature flags & settings
"isFeatureEnabled": {
// key of a particular flag
"v": false, // default value, served when no rules are defined
"i": "430bded3", // variation id (for analytical purposes)
"t": 0, // feature flag's type, possible values:
// 0 -> BOOLEAN
// 1 -> STRING
// 2 -> INT
// 3 -> DOUBLE
"p": [
// list of percentage rules
{
"o": 0, // rule's order
"v": true, // value served when the rule is selected during evaluation
"p": 10, // % value
"i": "bcfb84a7" // variation id (for analytical purposes)
},
{
"o": 1, // rule's order
"v": false, // value served when the rule is selected during evaluation
"p": 90, // % value
"i": "bddac6ae" // variation id (for analytical purposes)
}
],
"r": [
// list of Targeting Rules
{
"o": 0, // rule's order
"a": "Identifier", // comparison attribute
"t": 2, // comparator, possible values:
// 0 -> 'IS ONE OF',
// 1 -> 'IS NOT ONE OF',
// 2 -> 'CONTAINS',
// 3 -> 'DOES NOT CONTAIN',
// 4 -> 'IS ONE OF (SemVer)',
// 5 -> 'IS NOT ONE OF (SemVer)',
// 6 -> '< (SemVer)',
// 7 -> '<= (SemVer)',
// 8 -> '> (SemVer)',
// 9 -> '>= (SemVer)',
// 10 -> '= (Number)',
// 11 -> '<> (Number)',
// 12 -> '< (Number)',
// 13 -> '<= (Number)',
// 14 -> '> (Number)',
// 15 -> '>= (Number)',
// 16 -> 'IS ONE OF (Hashed)',
// 17 -> 'IS NOT ONE OF (Hashed)'
"c": "@example.com", // comparison value
"v": true, // value served when the rule is selected during evaluation
"i": "bcfb84a7" // variation id (for analytical purposes)
}
]
}
}
}

Map

You can set up the SDK to load your feature flag & setting overrides from a map.

Coming soon: Support for Flag overrides via Map #8

info

The Unreal Engine SDK doesn't support programmatically setting a flag map override currently.

GetAllKeys()

You can query the keys of each feature flag and setting with the getAllKeys() method.

Unreal Engine Get All Keys

GetAllValues()

Evaluates and returns the values of all feature flags and settings. Passing a User Object is optional.

Unreal Engine Get All Values

GetAllValueDetails

Evaluates and returns the detailed values of all feature flags and settings. Passing a User Object is optional.

Unreal Engine Get All Value Details

Custom Cache

Coming soon: Support for Custom Cache #9

info

The Unreal Engine SDK doesn't support custom cache implementations currently.

Force refresh

Call the forceRefresh() method on the client to download the latest config JSON and update the cache.

Unreal Engine Blueprint Force Refresh

Using ConfigCat behind a proxy

info

The Unreal Engine HTTP module doesn't support running behinde a proxy.

Changing the default HTTP timeout

Set the maximum wait time for a ConfigCat HTTP response by changing the ConnectTimeoutMs or ReadTimeoutMs in the ConfigCat ProjectSettings. The default ConnectTimeoutMs is 8 seconds. The default ReadTimeoutMs is 5 seconds.

Unreal Engine Settings Http Timeout

Logging

All ConfigCat logs are inside the LogConfigCat category. By default the verbosity is set to Log, but it can be changed to any Verbosity Level.

The verbosity can be changed:

Via Command line arguments:

Run the executable with -LogCmds="LogConfigCat VerbosityLevel". For example: -LogCmds="LogConfigCat Warning" to only show warnings and above.

Via DefaultEngine.ini:

In the [Core.Log] category add LogConfigCat=VerbosityLevel inside the DefaultEngine.ini. For example:

[Core.Log]
LogConfigCat=Warning ;to only show warnings and above

Note: Since the Unreal Engine SDK is a wrapper of the CPP SDK, all logs coming from the CPP SDK are tagged wtih [CPP-SDK].

Info level logging helps to inspect how a feature flag was evaluated:

[Info]: Evaluating getValue(isPOCFeatureEnabled)
User object: {
"Email": "[email protected]",
"Identifier": "435170f4-8a8b-4b67-a723-505ac7cdea92",
}
Evaluating rule: [Email:[email protected]] [CONTAINS] [@something.com] => no match
Evaluating rule: [Email:[email protected]] [CONTAINS] [@example.com] => match, returning: true

Sensitive information handling

The frontend/mobile SDKs are running in your users' browsers/devices. The SDK is downloading a config JSON file from ConfigCat's CDN servers. The URL path for this config JSON file contains your SDK key, so the SDK key and the content of your config JSON file (feature flag keys, feature flag values, Targeting Rules, % rules) can be visible to your users. This SDK key is read-only, it only allows downloading your config JSON file, but nobody can make any changes with it in your ConfigCat account.

If you do not want to expose the SDK key or the content of the config JSON file, we recommend using the SDK in your backend components only. You can always create a backend endpoint using the ConfigCat SDK that can evaluate feature flags for a specific user, and call that backend endpoint from your frontend/mobile applications.

Also, we recommend using confidential targeting comparators in the Targeting Rules of those feature flags that are used in the frontend/mobile SDKs.

Look Under the Hood