Statsig: Change default value for a Feature Gate

146 Views Asked by At

How to give default values so that for whatever reason the the initialization fails, We can fallback to the default. I understand that it will default to false currently, right? If i want a feature to be true. How can i do that?

if (!useGate('my_killswitch')) { 
  showFeature(); 
}
1

There are 1 best solutions below

0
On

Feature Gates are always boolean with the default value as false. If you want Feature Gates to work as a negative gate, then you can use the inverse in code.

For instance, instead of naming your gate, launch_cool_new_feature, you could name the gate, block_cool_new_feature and in code, you'd do something like this:

if (statsig.checkGate('block_cool_new_feature')) {
  // Don't show new feature
} else {
  // Show cool new feature
}