Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assign(params, args) {
/*
Planout uses deterministic hashing to choose assignments. This assures
that the same visitorId will always get the same selection. In addition to
the visitorId, Planout concatenates the params name ('layer_1' or 'layer_2')
with the visitorId to assure that selections are not correlated across params.
*/
params.set('layer_1', new Planout.Ops.Random.UniformChoice({
choices: [
false, // if selected will show base
"layer_1_bucket_A",
"layer_1_bucket_B"
],
unit: args.visitorId
})
);
params.set('layer_2', new Planout.Ops.Random.UniformChoice({
choices: [
false, // if selected will show base
"layer_2_bucket_A",
"layer_2_bucket_B",
"layer_2_bucket_C"
],
unit: args.visitorId
/*
Planout uses deterministic hashing to choose assignments. This assures
that the same visitorId will always get the same selection. In addition to
the visitorId, Planout concatenates the params name ('layer_1' or 'layer_2')
with the visitorId to assure that selections are not correlated across params.
*/
params.set('layer_1', new Planout.Ops.Random.UniformChoice({
choices: [
false, // if selected will show base
"layer_1_bucket_A",
"layer_1_bucket_B"
],
unit: args.visitorId
})
);
params.set('layer_2', new Planout.Ops.Random.UniformChoice({
choices: [
false, // if selected will show base
"layer_2_bucket_A",
"layer_2_bucket_B",
"layer_2_bucket_C"
],
unit: args.visitorId
})
);
}
setupDefaults() {
this.numSegments = 100;
}
setup() {
this.setName('MyNamespace');
this.setPrimaryUnit('id');
}
setupExperiments() {
this.addExperiment('SampleExperiment', DefaultExperiment, 50);
this.addExperiment('SampleExperiment2', DefaultExperiment2, 50);
}
};
class DefaultEmptyNamespace extends planout.Namespace.SimpleNamespace {
setupDefaults() {
this.numSegments = 100;
}
setup() {
this.setName('MyNamespace');
this.setPrimaryUnit('id');
}
setupExperiments() {
return;
}
};
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
})
);
}
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
})
);
}
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;
}
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; }
assign: function(params, args) {
params.set('foo', new planout.Ops.Random.UniformChoice({ 'choices': ['Variation A', 'Variation B'], 'unit': args.id }));
},
configure_logger: function() {
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; }