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
Variation variation = optimizely.activate("experiment_name", userId); | |
if (variation != null) { | |
if (variation.is("control")) { | |
// execute code for control | |
} else if (variation.is("variation")) { | |
// execute code for variation | |
} | |
} else { | |
// execute default code | |
} |
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
OptimizelyFactory optimizely = new OptimizelyFactory(dataFile); | |
//... | |
//... | |
Sort sortingAlgorithm = optimizelyFactory.getExperimentImpl(“ProductSort”, userId); | |
sort.sort(sampleProductList()); |
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
public ProductSort getExperimentImpl(String experimentName, String userId){ | |
Variation variation = this.optimizelyClient.activate(experimentName, userId); | |
ProductSort retobj = null; | |
if(variation.getKey().equals("PriceProductSort")){ | |
retobj = new CategoryProductSort(); | |
} else if(variation.getKey().equals("NameProductSort")){ | |
retobj = new NameProductSort(); | |
} else if(variation.getKey().equals("CategoryProductSort")){ |
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
public T getExperimentImpl(String experimentName, String userId){ | |
Variation variation = this.optimizelyClient.activate(experimentName, userId); | |
T retobj = null; | |
try { | |
String className = this.packageName + "." + variation.getKey(); | |
Class cls = Class.forName(className); | |
Class partypes[] = new Class[0]; | |
Constructor ct = cls.getConstructor(partypes); |
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
OptimizelyReflectionFactory<ProductSort> optimizely = new OptimizelyReflectionFactory<ProductSort>(); | |
//… | |
//… | |
ProductSort sort = optimizely.getExperimentImpl(“ProductSort”, input); | |
sort.sort(sampleProductList()); |
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
public T getVariableImpl(String featureFlag, String featureVariable, String userId){ | |
String className = this.optimizelyClient.getFeatureVariableString(featureFlag, featureVariable, userId); | |
T retobj = null; | |
try { | |
Class cls = Class.forName(className); | |
Class partypes[] = new Class[0]; | |
Constructor ct = cls.getConstructor(partypes); | |
retobj = (T)ct.newInstance(); |
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
public T getVariableImpl(String featureFlag, String featureVariable, String userId){ | |
String className = this.optimizelyClient.getFeatureVariableString(featureFlag, featureVariable, userId); | |
T retobj = null; | |
try { | |
Class cls = Class.forName(className); | |
Class partypes[] = new Class[0]; | |
Constructor ct = cls.getConstructor(partypes); | |
retobj = (T)ct.newInstance(); |
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
//Business Logic | |
//... | |
Variation variation = this.optimizelyClient.activate(experimentName, userId); | |
if(variation.is("CategoryProductSort")){ | |
CategoryComparator comparator = new CategoryComparator(); | |
Collections.sort(unSortedList, comparator); | |
} else if(variation.is("NameProductSort")){ | |
NameComparator comparator = new NameComparator(); | |
Collections.sort(unSortedList, comparator); |
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
const express = require('express') | |
const app = express() | |
const port = 80 | |
var request = require('request'); | |
var username = <Segment Workspace API username> | |
var password = '' | |
var url = 'https://profiles.segment.com/v1/spaces/<workspace_id>/collections/users/profiles/user_id:' |
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
var variation = optimizelyClient.activate("my_experiment", userId, { | |
industry: "b2b" | |
}); | |
And: | |
optimizelyClient.track("my_event", userId, { | |
industry: "b2b" | |
}); |
OlderNewer