============= PlanOut.js is a JavaScript-based implementation of PlanOut. It provides a complete implementation of the PlanOut native API framework and a PlanOut language interpreter.
PlanOut.js is implemented in ES6, and can also be used with ES5.
PlanOut.js is available on npm and can be installed by running:
npm install planout
PlanOut.js provides an implementation of all PlanOut features (including the experiment class, interpreter, and namespaces).
Here is how you would use PlanOut.js with ES6:
import PlanOut from 'planout';
class MyExperiment extends PlanOut.Experiment {
configure_logger() {
return;
//configure logger
}
log(event) {
//log the event somewhere
}
previously_logged() {
//check if we’ve already logged an event for this user
}
setup() {
//set experiment name, etc.
}
assign(params, args) {
params.set('foo', new PlanOut.Ops.Random.UniformChoice({choices: ['a', 'b'], ‘unit’: args.id}));
}
}
Then, to use this experiment you would simply need to do:
var exp = new MyExperiment({id: user.id });
console.log("User has foo param set to " + exp.get('foo'));
An example of using PlanOut.js with ES5 can be [found here] (https://github.com/facebook/planout/blob/master/alpha/js/examples/sample_planout_es5.js), An example with the PlanOut interpreter can be found here
This project uses Jest for testing. The tests can be found in the tests folder and running the tests simply requires running the command: npm test
If you are making changes to the ES6 implementation, simply run grunt and it will transpile to the corresponding ES5 code.