The goal of this lab is route a subset of the microblog’s audience to experience one value of a feature flag, while the rest of the users will see a separate value. The intended sub-group will be created in the CloudBees Feature Management interface and defined by properties in code, and then communicated to the CloudBees Feature Management dashboard through the setup
function in the flags.js
file. This lab will implement logic to display the sidebar only for logged in, Beta Users.
isLoggedIn
and betaAccess
functions are available to be used in the flags.js
file. Make sure you are on the development
branch of the microblog-frontend
repository, navigate to the flags.js
file (src/utils/flags.js
). Click the pencil icon to edit the file. flags.js
to call isLoggedIn
and betaAccess
functions. Import store
and betaAccess
from their respective definition files. Starting on Line 2, include the following import calls:import store from '../store'
import { betaAccess } from './users'
isLoggedIn
and betaAccess
boolean functions have to be communicated to the CloudBees Feature Management dashboard. To accomplish this, set up a setCustomBooleanProperty
call for each of the functions. Before the Rox.register
line, add the following lines:Rox.setCustomBooleanProperty('isLoggedIn', store.getters.isLoggedIn)
Rox.setCustomBooleanProperty('hasBetaAccess', betaAccess())
Review your edits with updated code below:
Create a commit message (e.g. “Added setCustomBooleanProperty”). Commit changes directly to the development
branch.
Once the commit has finished being built on the open pull request, open the new deployment URL and then check the Audit log in the Feature Management dashboard to ensure the new properties have been added.
In the CloudBees Feature Management dashboard, navigate to the Target Groups displayed on the left. Select the Create a New Group button in the middle of the resulting page.
We are going to create a new Target Group, useful when defined by 2 or more customProperties
. Enter BetaUsers as the Name of the new group, a subset that will be defined by the isLoggedIn
and hasBetaAccess
properties.
A microblog user is considered part of the BetaUsers group when both of the following conditions are met:
isLoggedIn
is truehasBetaAccess
is trueisLoggedIn
is true. Then, Add new condition, select the Matches All Conditions option, and the select the hasBetaAccess
Property as is true.Once your BetaUsers New Target Group definition looks similar to screenshot below click Create Group button so it can be used in experiments.
if
condition block so that for a target group that matches any of BetaUsers, the sidebar flag value is true.else
block such that the sidebar flag value will be false. The configuration modifications should match the following screenshot. admin
and the password admin
and then navigate back to the homepage. The sidebar should be hidden!betauser
and betauser
password. Upon, navigating back to the homepage the sidebar is now displayed (you may need to refresh the browser page), as we configured it to be only for Beta Users.Congratulations! You have finished Lab 3 of the CloudBees Feature Management Workshop.
For instructor led workshops please return to the workshop slides