Skip to content

Commit f9de142

Browse files
fix example by creating new user each time so that events can be done multiple times (#257)
1 parent 43a343a commit f9de142

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

java-quickstart/src/main/java/com/optimizely/Example.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.util.HashMap;
1313
import java.util.Map;
1414

15+
import java.util.Random;
16+
1517
public class Example {
1618
public static void main(String[] args) {
1719

@@ -20,12 +22,14 @@ public static void main(String[] args) {
2022
try {
2123
Optimizely optimizely = Optimizely.builder(datafile, new AsyncEventHandler(100,2)).build();
2224
System.out.println("hello world");
25+
Random random = new Random();
26+
String user = String.valueOf(random.nextInt());
2327
Map<String,String> attributes = null;//new HashMap<>();
2428
//attributes.put("browser_type", "crome");
25-
Variation v = optimizely.activate("background_experiment", "testuserid", attributes);
29+
Variation v = optimizely.activate("background_experiment", user, attributes);
2630
if (v != null) {
2731
System.out.println(String.format("Found variation %s", v.getKey()));
28-
optimizely.track("sample_conversion", "testuserid", attributes);
32+
optimizely.track("sample_conversion", user, attributes);
2933
Thread.sleep(10000);
3034
}
3135
else {

0 commit comments

Comments
 (0)