Skip to content

Feature Toggle Settings Scenarios

Pratik Bhattacharya edited this page Dec 15, 2021 · 13 revisions

Feature Toggle Settings Scenarios

In this section we will discuss the various scenarios that you may encounter while creating/evaluating a feature toggle, and how the feature flag will be configured in those scenarios.

Scenario 1 - Setting up a feature flag with condition that user's email must belong to a list of emails

Feature Flag

{
    "name": "Scenario-1",
    "description": "Mail must belong to any of the configured value",
    "enabled": true,
    "environment": "dev",
    "conditions": {
        "client_filters": [
            {
                "name": "UserMail",
                "parameters": {
                    "operator": "In",
                    "value": "tonystark@gmail.com,jarvis@gmail.com,peter.parker@outlook.com",
                    "isActive": "true",
                    "stageId": "0",
                    "stageName": "Ring 1",
                    "flightContextKey": "UserMail"
                }
            }
        ]
    }
}

X-FlightContext Samples

Value Result Comments
{ "UserMail": "jarvis@gmail.com" } true Email part of the list
{ "UserMail": "bruce.wayne@gmail.com" } false Email not part of the list

Scenario 2 - Setting up a feature flag with condition that user's email must belong to a list of emails or the user must be from USA

Feature Flag

{
    "name": "Scenario-1",
    "description": "Mail must belong to any of the configured value",
    "enabled": true,
    "environment": "dev",
    "conditions": {
        "client_filters": [
            {
                "name": "UserMail",
                "parameters": {
                    "operator": "In",
                    "value": "tonystark@gmail.com,jarvis@gmail.com,peter.parker@outlook.com",
                    "isActive": "true",
                    "stageId": "0",
                    "stageName": "Ring 1",
                    "flightContextKey": "UserMail"
                }
            },
            {
                "name": "Country",
                "parameters": {
                    "operator": "Equals",
                    "value": "USA",
                    "isActive": "true",
                    "stageId": "0",
                    "stageName": "Ring 1",
                    "flightContextKey": "Country"
                }
            }
        ]
    }
}

X-FlightContext Samples

Value Result Comments
{ "UserMail": "jarvis@gmail.com", "Country": "USA" } true Both email and country matches
{ "UserMail": "bruce.wayne@gmail.com", "Country": "USA" } true Email not part of the list but country passes
{ "UserMail": "bruce.wayne@gmail.com", "Country": "UK" } false Not email nor country passes

Scenario 3 - Setting up a feature flag with condition that user's email must belong to a list of emails (but flight context key is different)

Feature Flag

{
    "name": "Scenario-1",
    "description": "Mail must belong to any of the configured value",
    "enabled": true,
    "environment": "dev",
    "conditions": {
        "client_filters": [
            {
                "name": "UserMail",
                "parameters": {
                    "operator": "In",
                    "value": "tonystark@gmail.com,jarvis@gmail.com,peter.parker@outlook.com",
                    "isActive": "true",
                    "stageId": "0",
                    "stageName": "Ring 1",
                    "flightContextKey": "MailAddress"
                }
            }
        ]
    }
}

X-FlightContext Samples

Value Result Comments
{ "MailAddress": "jarvis@gmail.com" } true Email part of the list
{ "UserMail": "jarvis@gmail.com" } false The required key MailAddress is not present in the context
{ "MailAddress": "jarvis@gmail.com" } false Email not part of the list

Clone this wiki locally