Skip to content

Instantly share code, notes, and snippets.

@asaschachar
Last active September 9, 2022 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save asaschachar/738cf138f09117e0dd77257f133a2019 to your computer and use it in GitHub Desktop.
Save asaschachar/738cf138f09117e0dd77257f133a2019 to your computer and use it in GitHub Desktop.
const optimizelySDK = require('@optimizely/optimizely-sdk');
optimizelySDK.setLogLevel('info');
optimizelySDK.setLogger(optimizelySDK.logging.createLogger())
const optimizelyClientInstance = optimizelySDK.createInstance({
sdkKey: 'gz2y11nXJN2YF3kD4ifK5',
datafileOptions: {
autoUpdate: true,
updateInterval: 1000, // 1 second in milliseconds
},
});
module.exports = optimizelyClientInstance;
var express = require('express');
var router = express.Router();
const optimizelyClientInstance = require('../optimizely.js');
/* GET home page. */
router.get('/', function(req, res, next) {
const enabled = optimizelyClientInstance.isFeatureEnabled('hello_world', 'user123');
const title = enabled
? 'Feature flag is on!'
: 'Feature flag is off!'
res.render('index', { title: title });
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment