Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import planout from 'planout';
let globalLog = [];
class DefaultExperiment extends planout.Experiment {
setup() {
this.setName("SampleExperiment");
}
assign(params, args) {
params.set('foo',
new planout.Ops.Random.UniformChoice({
'choices': ['Variation A', 'Variation B'],
'unit': args.id
})
);
params.set('test2',
new planout.Ops.Random.UniformChoice({
'choices': ['Num1', 'Num2'],
'unit': args.id
}
log(stuff) {
globalLog.push(stuff);
}
getParamNames() {
return this.getDefaultParamNames();
}
previouslyLogged() {
return this._exposureLogged;
}
};
class DefaultExperiment2 extends planout.Experiment {
setup() {
this.setName('SampleExperiment2');
}
assign(params, args) {
params.set('foobar',
new planout.Ops.Random.UniformChoice({
'choices': ['Variation A', 'Variation B'],
'unit': args.id
})
);
}
configureLogger() {
return;
}
var Experiment1 = function(args) {
var experiment = new planout.Experiment(args);
experiment.setup = function() { this.set_salt("Exp1"); }
experiment.setup();
experiment.assign = function(params, args) {
params.set('group_size', new planout.Ops.Random.UniformChoice({ 'choices': [1, 10], 'unit': args.userid}));
params.set('specific_goal', new planout.Ops.Random.BernoulliTrial({'p': 0.8, 'unit': args.userid}));
if (params.get('specific_goal')) {
params.set('ratings_per_user_goal', new planout.Ops.Random.UniformChoice({ 'choices': [8, 16, 32, 64], 'unit': args.userid}));
params.set('ratings_goal', params.get('group_size') * params.get('ratings_per_user_goal'));
}
};
experiment.configure_logger = function() { return; }
experiment.log = function(stuff) { return; }
experiment.previously_logged = function() { return; }
return experiment;
};
var Experiment3 = function(args) {
var experiment = new planout.Experiment(args);
experiment.setup = function() { this.set_salt("Exp3"); }
experiment.setup();
experiment.assign = function(params, args) {
params.set('has_banner', new planout.Ops.Random.BernoulliTrial({ 'p': 0.97, 'unit': args.userid}));
var cond_probs = [0.5, 0.95];
params.set('has_feed_stories', new planout.Ops.Random.BernoulliTrial({'p': cond_probs[params.get('has_banner')], 'unit': args.userid}));
params.set('button_text', new planout.Ops.Random.UniformChoice({'choices': ["I'm a voter", "I'm voting"], 'unit': args.userid}))
};
experiment.configure_logger = function() { return; }
experiment.log = function(stuff) { return; }
experiment.previously_logged = function() { return; }
return experiment;
}