Last active
July 25, 2019 14:21
-
-
Save erin-at-work/ee3fec48648cd5aa920cb93aaef09d2c to your computer and use it in GitHub Desktop.
Optimizely Rollout example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// optimizely.js | |
import optimizelySDK from '@optimizely/optimizely-sdk' | |
const optimizelyClientInstance = optimizelySDK.createInstance({ | |
datafile: window.optimizelyDatafile, | |
}) | |
export default optimizelyClientInstance | |
/* -- */ | |
import optimizelyClientInstance from './optimizely' | |
const enabled = optimizelyClientInstance.isFeatureEnabled('new_feature', 'user123'); | |
if (enabled) { | |
// Show your feature | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
createInstance, | |
OptimizelyProvider, | |
OptimizelyFeature, | |
} from '@optimizely/react-sdk' | |
const optimizely = createInstance({ | |
sdkKey: 'your-optimizely-sdk-key', | |
}) | |
const optimizely = createInstance({ | |
sdkKey: 'your-optimizely-sdk-key', | |
}) | |
class App extends React.Component { | |
render() { | |
<OptimizelyProvider | |
optimizely={optimizely} | |
timeout={500} | |
userId={window.userId} | |
userAttributes={{ plan_type: 'bronze' }} | |
> | |
<OptimizelyFeature feature="sort-algorithm"> | |
{(isEnabled, variables) => ( | |
<SearchComponent algorithm={variables.algorithm} /> | |
)} | |
</OptimizelyFeature> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment