Feature Flag Decision

A Feature Flag has an on state and an off state. A different feature is configured for each state. When a user accesses a feature that has a Feature Flag applied, the on or off state must be returned. You can perform this state decision through the Hackle SDK.

is_feature_on

By passing a Feature Key to the is_feature_on() method, you can receive the state result for the user. Then implement logic based on the state.

In the example code below, Feature Key 42 is passed, and the User Identifier for the user whose state is to be determined is "ae03e1adf".

from hackle.model import HackleUser

# 기능 키가 42인 기능 플래그에서 사용자의 상태를 결정합니다.
# 결정하지 못하는 상황인 경우 false(꺼짐 상태)를 반환합니다.

user = HackleUser.builder() \
                 .device_id('ae2182e0') \
                 .build()

feature_on = hackle_client.is_feature_on(feature_key=42, user=user)

# 할당받은 그룹에 대한 로직
if feature_on == True:
    # ON 기능
elif feature_on == False:
    # OFF 기능

feature_flag_detail

The feature_flag_detail() method works the same as the is_feature_on() method and additionally provides the reason for the state decision. It is useful for checking whether Override is working correctly or when the result ratio seems unusual relative to the configured Traffic Allocation.

You must pass the Feature Key as a parameter. In the example code below, Feature Key 42 is passed.

The state decision reason is returned in the form of SDK_NOT_READY. Refer to the table below for details.

Decision Reason
Description
Distribution Result

SDK_NOT_READY

The SDK is not ready to use. (e.g., initialization attempted with an invalid SDK Key)

Default state (off)

FEATURE_FLAG_NOT_FOUND

No Feature Flag was found for the provided Feature Key. The Feature Key may be incorrect, or the Feature Flag may be archived.

Default state (off)

FEATURE_FLAG_INACTIVE

The Feature Flag is in the off state.

Default state (off)

INDIVIDUAL_TARGET_MATCH

Matched by Individual Targeting.

State configured by Individual Targeting

TARGET_RULE_MATCH

Matched by User Targeting.

State configured by User Targeting

DEFAULT_RULE

Did not match either Individual Targeting or User Targeting.

State configured by default rule

EXCEPTION

An unknown error occurred.

Default state (off)

circle-info

When using the Python SDK, duplicate exposure events for the same Feature Flag Distribution result generated by the same user within 1 minute are deduplicated.

Events within 1 minute are counted as one.

Feature Flag Parameter Settings

  • You can also receive the parameter values for the state decision through the feature_flag_detail() method.

  • You can use the config object and get() method to retrieve and use the Parameter Settings values configured on the Feature Flag screen. If you change a value on the Feature Flag parameter settings screen, the updated value is applied to your code.

circle-info

Parameter settings are available for SDK version 3.1.0 and above.

  • The parameterKey of the get() method is the key configured in the Feature Flag parameter settings, and defaultValue is the value returned when the state decision fails or an invalid parameter type value is provided.

  • To receive the configured information correctly, you must enter a value of the type that matches the parameter type you configured in defaultValue.

  • Since JSON type can be received as a string, you must enter the defaultValue as a string type for JSON type.

  • The parameter types provided by the SDK are string, number, and boolean. The JSON type configured on the Feature Flag screen can be received as a string. The default value for JSON type must be entered as a string type.

Last updated