Содержание
Flight Context
Flight Context is an object that must be sent to the Evaluate API. This values from this object are used to evaluate the Feature Flag. Values from this object is operated against the configured values in the Feature Flag and the result is calculated. From a client application perspective the Flight Context refers to the contextual information about the current situation, which will determine whether a feature needs to be exposed. In most of the cases, flight context will contain information about the logged-in user (like Email Address, ID, location, etc.). However, if you want other attributes to determine the result of the toggle, you can send those information in the context.
The flight context is sent in the header x-flightcontext
.
For example, let's say your feature flag has the following filter
{
"name": "Country",
"parameters": {
"operator": "In",
"value": "USA,India,UK",
"isActive": "true",
"stageId": "0",
"stageName": "Ring 1",
"flightContextKey": "Country"
}
}
The feature flag with the above filter will return true if the Country of the user is USA, India or UK. The user's country information is sent to the Evaluate API using the x-flightcontext header.
For the below flight context the result will be true
Value | Result | Comments |
---|---|---|
{ "Country": "USA" } |
true | USA is whiteliste |
{ "Country": "India", "UPN": "tonystark@gmail.com" } |
true | Context can have fields other than the required field. If those fields are not configured in the filter, they get ignored. So the UPN field will get ignored |
For the below flight context the result will be false
Value | Result | Comments |
---|---|---|
{ "Country": "Sweden" } |
true | Swededn is not whitelisted |
{ "UPN": "jarvis@gmail.com" } |
false | The required context 'Country' is not in the list |