0

I'm in a project where I am building a simulator of a website. I am testing how feature toggling can provide some cons that can help a team release more often than they do now.

One thing I do like to simulate is how the Canary release is working. Lets say I just finished building a new feature and I need to have it tested in production. Canary release is just to push this feature out to a small number of users.

How do you simulate this with code? I'm building the applikation with angular2 anad with typescript. Have created configurationfiles for the features that I can use.

How do you, lets say pick only 5 percents of random people that visit the site to test the specific feature? Is it all done with server configuration (running another build at a different server).

If any could make a code example of how I could simulate this when the application starts, I've be happy.

Have made this code myself:

var switchKey: string = localStorage.getItem('featureSwitch');

    if (this.featureSwitch != null) {
        if (switchKey == "11") {
            this.featureSwitch = 1;
            localStorage.setItem('featureSwitch', this.featureSwitch.toString());
        }

    }
    else {
        if (switchKey != null) {
            if (switchKey == "11") {
                this.featureSwitch = 1;
                localStorage.setItem('featureSwitch', this.featureSwitch.toString());
            }
            else {
                this.featureSwitch = Number(switchKey) + 1;
                localStorage.setItem('featureSwitch', this.featureSwitch.toString());
            }
        }
        else {
            this.featureSwitch = 1;
            localStorage.setItem('featureSwitch', this.featureSwitch.toString());
        }

    }

This is maybe a bad example, cause I don't think it will work on a live site (on the internet), this is only tested on a localhost server. Basically I'm saving a number from 1-11 in localstorage, where I can show a feature based on one or more numbers.

Any have some ideas how I could do this easily?

Mikkel
  • 1,771
  • 11
  • 35
  • 59

1 Answers1

0

Basically I'm saving a number from 1-11 in localstorage, where I can show a feature based on one or more numbers.

You should do canary releases based on users (not browser sessions). Otherwise the user will be surprised as they switch browsers / devices / locations. And you will not know which users are participating in a test (a user can AND can't be in the test if they use two devices).

This needs server side support, the switch belongs in the server.

basarat
  • 261,912
  • 58
  • 460
  • 511