Feature Flag Determination

๐Ÿ“˜

Feature flags are only available for SDK version 2.0.0 or higher.

When using feature flags, please apply SDK version 2.0.0 or higher when adding dependencies.

A feature flag has an on and off state. You will set different features according to each state.

Once a feature flag is applied, a specific user from your traffic should be able to either receive an off or on status. This on/off status determination can be done through the Hackle SDK.

is_feature_on

You can pass a feature key to the is_feature_on() method to receive status results for the user. After receiving the status, we can then implement the logic according to each status.

In the example code below, we are passing feature key 42.

In the example code below, we are passing feature key 42, and the user identifier of the user who will receive the status is "ae03e1adf" .

# Determines the status of the feature flag to assign the user in a feature flag with a feature key of 42.
# For undetermined cases, users are assigned to false (off status). 
user = Hackle.user('ae03e1adf')
feature_on = hackle_client.is_feature_on(feature_key=42, user=user)

# Logic by state
if feature_on == True:
    # Logic for on status
elif feature_on == False:
    # Logic for off status

feature_flag_detail

The feature_flag_detail() method works the same as the is_feature_on() method and additionally provides a reason for determining the status of a particular user. This can be useful when you want to check whether the manual allocation is working well or when you think that the traffic allocation you have set is not being reflected in your results.

You must pass a feature key as a parameter. For the example code below, we are passing feature key 42.

decison = hackle_client.feature_flag_detail(feature_key=42, user=user)

# Feature flag on/off results
feature_on = decison.is_on

# Reason for status determination
reason = decision.reason

The reason for the status determination will be in the form of SDK_NOT_READY. Please refer to the table below for the full list of all the different types of reasons.

ReasonDescriptionFeature Status
SDK_NOT_READYThe SDK is not ready to use.
(e.g. Initialization with the wrong SDK key)
Default status(off)
EXPERIMENT_NOT_FOUNDNo feature flags were found for the feature key you passed.
The feature key may be incorrect or the corresponding feature flag may be in an archived state.
Default status(off)
OVERRIDDENThe user has been determined to have a specific feature flag status by manual assignment.Manual assignment
TRAFFIC_ALLOCATEDUser status has been determined.Status determined
INVALID_INPUTThe input value is not valid.
(e.g. A letter type was inputting in a parameter that requires a numeric type)
Default status(off)
EXCEPTIONAn unknown error has occurred.Default status(off)

๐Ÿ“˜

Deduplication of exposure event

If you use Backend-side SDK, Any successive Exposure events within one minute for same Feature Flag from single user will be counted as one.

Feature Flag Parameter

๐Ÿ“˜

Parameter setting is only available for SDK version 3.1.0 or higher.

  • Call feature_flag_fetail() method to obtain parameter values which contains the feature flag status information
  • FeatureFlagDecisioninstance passed through the feature_flag_fetail() method has full parameter setting information.
  • Parameter values you've set on the dashboard exists in the form of key and value, therefore you can use the method below to set the parameter values.
  • You can change feature flag's parameter values flexibly on the Feature Flag > Parameter Settings.
from hackle.model import HackleUser

user = HackleUser(id='ae2182e0')
decision = hackleClient.feature_flag_detail(feature_key=42, user=user)

parameterValue = decision.get('parameterKey', 'defaultValue')

# Example of string type parameter value
strValue = decision.get('parmeterKey', 'defaultValue')