Feature Flag Decision

A Feature Flag has two states: on and off. Different features are configured for each state. When a user accesses a feature with a Feature Flag applied, the SDK must return the on or off state. You can use the Hackle SDK to determine this state.

isFeatureOn

Pass the Feature Key to the isFeatureOn() method to receive the state result for the user. Then implement logic based on the state.

In the example code below, Feature Key 42 is passed.

// SDK가 준비된 이후에 실행이 되어야합니다. onReady로 감싸는 것을 잊지 마세요.
hackleClient.onReady(function() {

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

  // 상태 별 로직
  if (isOn) {
    // ON 기능
  } else {
    // OFF 기능
  }
});

featureDetail

The featureDetail() method works the same as the isFeatureOn() method but also provides the reason for the state decision. This is useful for verifying that Override is working correctly or when the distribution result ratio seems inconsistent with 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 format SDK_NOT_READY. See 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)

Feature Flag Parameters

circle-info

This feature is supported in Javascript SDK version 11.7.3 and above.

  • You can also receive the parameter values for the state decision via the featureFlagDetail() method.

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

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

  • To correctly retrieve the configured value, you must enter a value of the type matching the parameter type you configured in defaultValue.

  • JSON type can be received as a string (String), so the defaultValue for JSON type must be entered as a string 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 (String). The default value for JSON type must be entered as a string type.

Last updated