To standardise a set of common activation strategies, we also needed to standardise the Unleash context, which contains fields that vary per request, required to implement the activation strategies. These context fields is also the basis for strategy constraints.

The Unleash Context is defined by these fields:

  • userId: String
  • sessionId: String
  • remoteAddress: String
  • properties: Map<String, String>
  • appName: String
  • environment: String

All fields are optional, but if they are not set you will not be able to use certain activation strategies. For example, the userWithId strategy depends on the userId field to identify the userId for the current request. 

Custom context fields

The properties field is more generic and can be used to provide more arbitrary data to strategies. Typical usage is to add more metadata. For instance, you could implement a custom activation strategy,  “betaUser strategy”, which need to read a field from properties to check whether the current user is a beta user.

Static context fields

The “appName” and “environment” fields are considered static context fields. This means that they are not expected to change per request, and configured as part of the SDK initialization, and they will be injected automatically to the “isEnabled” call. (You can however override them in your own context object when calling the isEnabled function)

Strategy constraints

The Unleash Context fields can also be used as pre-conditions for activation strategies. You can read how in the strategy constraints guide