BeaconDocsDashboard

Features

Feature flags

Ship new code switched off, then turn it on for some visitors, then everyone, without another release. If something goes wrong, switch it off.

Create a flag

In Experiments → Feature flags, choose New flag and give it a key. Flags start off. The switch turns one on, and the slider sets how many visitors get it: 10% to begin with, then 50%, then everyone.

In your code

js
if (await beacon('flag', 'new-nav')) {
  showNewNavigation();
} else {
  showOldNavigation();
}

beacon('flag', key) returns a promise of true or false. It's false when the flag is off, when the visitor is outside the share you've set, when the key doesn't exist, or when Beacon can't be reached, so your old code path is always the safe default.

Changes reach sites within a couple of minutes: the tag checks Beacon's settings once per page and keeps them for a minute. A visitor who already got true keeps it as you raise the share.

Who gets it

Like experiments, a flag splits by each visitor, each signed-in user, or a property. Splitting by a property turns a feature on for whole companies at once:

js
beacon('set', { account: currentAccount.id });

if (await beacon('flag', 'beta-dashboard')) {
  enableBetaDashboard();
}

The same hash decides as for experiments, so a server can get the same answer: see On your server (a flag is on when the first bucket is under rollout × 100).

Cleaning up

Once a feature is on for everyone and staying, remove the flag check from your code, then delete the flag. Deleting a flag that's still in your code makes it false, the old path.