13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
+
16
17
package com .optimizely .ab .android .sdk ;
17
18
18
19
import android .app .Activity ;
21
22
22
23
import com .optimizely .ab .Optimizely ;
23
24
import com .optimizely .ab .UnknownEventTypeException ;
24
- import com .optimizely .ab .UnknownExperimentException ;
25
25
import com .optimizely .ab .config .Experiment ;
26
- import com .optimizely .ab .config .ProjectConfig ;
27
26
import com .optimizely .ab .config .Variation ;
28
27
29
28
import org .slf4j .Logger ;
30
- import org .slf4j .LoggerFactory ;
31
29
32
30
import java .util .Map ;
33
31
@@ -52,10 +50,14 @@ public class AndroidOptimizely {
52
50
}
53
51
54
52
/**
53
+ * Activate an experiment for a user
55
54
* @see Optimizely#activate(String, String)
55
+ * @param experimentKey the experiment key
56
+ * @param userId the user id
57
+ * @return the {@link Variation} the user bucketed into
56
58
*/
57
59
public @ Nullable Variation activate (@ NonNull String experimentKey ,
58
- @ NonNull String userId ) throws UnknownExperimentException {
60
+ @ NonNull String userId ) {
59
61
if (optimizely != null ) {
60
62
return optimizely .activate (experimentKey , userId );
61
63
} else {
@@ -66,11 +68,17 @@ public class AndroidOptimizely {
66
68
}
67
69
68
70
/**
69
- * @see Optimizely#activate(String, String, Map)
71
+ * Activate an experiment for a user
72
+ * @see Optimizely#activate(String, String)
73
+ * @param experimentKey the experiment key
74
+ * @param userId the user id
75
+ * @param attributes a map of attributes about the user
76
+ * @return the {@link Variation} the user bucketed into
70
77
*/
78
+ @ SuppressWarnings ("WeakerAccess" )
71
79
public @ Nullable Variation activate (@ NonNull String experimentKey ,
72
80
@ NonNull String userId ,
73
- @ NonNull Map <String , String > attributes ) throws UnknownExperimentException {
81
+ @ NonNull Map <String , String > attributes ) {
74
82
if (optimizely != null ) {
75
83
return optimizely .activate (experimentKey , userId , attributes );
76
84
} else {
@@ -81,37 +89,12 @@ public class AndroidOptimizely {
81
89
}
82
90
83
91
/**
84
- * @see Optimizely#activate(Experiment, String)
85
- */
86
- public @ Nullable Variation activate (@ NonNull Experiment experiment ,
87
- @ NonNull String userId ) {
88
- if (optimizely != null ) {
89
- return optimizely .activate (experiment , userId );
90
- } else {
91
- logger .warn ("Optimizely is not initialized, can't activate experiment {} for user {}" ,
92
- experiment .getKey (), userId );
93
- return null ;
94
- }
95
- }
96
-
97
- public @ Nullable Variation activate (@ NonNull Experiment experiment ,
98
- @ NonNull String userId ,
99
- @ NonNull Map <String , String > attributes ) {
100
- if (optimizely != null ) {
101
- return optimizely .activate (experiment , userId , attributes );
102
- } else {
103
- logger .warn ("Optimizely is not initialized, can't activate experiment {} for user {} " +
104
- "with attributes" , experiment .getKey (), userId );
105
- return null ;
106
- }
107
- }
108
-
109
-
110
- /**
111
- * @see Optimizely#track(String, String)
92
+ * Track an event for a user
93
+ * @param eventName the name of the event
94
+ * @param userId the user id
112
95
*/
113
96
public void track (@ NonNull String eventName ,
114
- @ NonNull String userId ) throws UnknownEventTypeException {
97
+ @ NonNull String userId ) {
115
98
if (optimizely != null ) {
116
99
optimizely .track (eventName , userId );
117
100
} else {
@@ -120,7 +103,10 @@ public void track(@NonNull String eventName,
120
103
}
121
104
122
105
/**
123
- * @see Optimizely#track(String, String, Map)
106
+ * Track an event for a user
107
+ * @param eventName the name of the event
108
+ * @param userId the user id
109
+ * @param attributes a map of attributes about the user
124
110
*/
125
111
public void track (@ NonNull String eventName ,
126
112
@ NonNull String userId ,
@@ -134,7 +120,10 @@ public void track(@NonNull String eventName,
134
120
}
135
121
136
122
/**
137
- * @see Optimizely#track(String, String, long)
123
+ * Track an event for a user
124
+ * @param eventName the name of the event
125
+ * @param userId the user id
126
+ * @param eventValue a value to tie to the event
138
127
*/
139
128
public void track (@ NonNull String eventName ,
140
129
@ NonNull String userId ,
@@ -148,12 +137,17 @@ public void track(@NonNull String eventName,
148
137
}
149
138
150
139
/**
151
- * @see Optimizely#track(String, String, Map, long)
140
+ * Track an event for a user with attributes and a value
141
+ * @see Optimizely#track(String, String, Map, Long)
142
+ * @param eventName the String name of the event
143
+ * @param userId the String user id
144
+ * @param attributes the attributes of the event
145
+ * @param eventValue the value of the event
152
146
*/
153
147
public void track (@ NonNull String eventName ,
154
148
@ NonNull String userId ,
155
149
@ NonNull Map <String , String > attributes ,
156
- long eventValue ) throws UnknownEventTypeException {
150
+ long eventValue ) {
157
151
if (optimizely != null ) {
158
152
optimizely .track (eventName , userId , attributes , eventValue );
159
153
} else {
@@ -162,26 +156,16 @@ public void track(@NonNull String eventName,
162
156
}
163
157
}
164
158
165
-
166
159
/**
160
+ * Get the variation the user is bucketed into
167
161
* @see Optimizely#getVariation(Experiment, String)
162
+ * @param experimentKey a String experiment key
163
+ * @param userId a String user id
164
+ * @return a variation for the provided experiment key and user id
168
165
*/
169
- public @ Nullable Variation getVariation (@ NonNull Experiment experiment ,
170
- @ NonNull String userId ) throws UnknownExperimentException {
171
- if (optimizely != null ) {
172
- return optimizely .getVariation (experiment , userId );
173
- } else {
174
- logger .warn ("Optimizely is not initialized, could not get variation for experiment {} " +
175
- "for user {}" , experiment .getKey (), userId );
176
- return null ;
177
- }
178
- }
179
-
180
- /**
181
- * @see Optimizely#getVariation(String, String)
182
- */
166
+ @ SuppressWarnings ("WeakerAccess" )
183
167
public @ Nullable Variation getVariation (@ NonNull String experimentKey ,
184
- @ NonNull String userId ) throws UnknownExperimentException {
168
+ @ NonNull String userId ) {
185
169
if (optimizely != null ) {
186
170
return optimizely .getVariation (experimentKey , userId );
187
171
} else {
@@ -192,8 +176,14 @@ public void track(@NonNull String eventName,
192
176
}
193
177
194
178
/**
195
- * @see Optimizely#getVariation(String, String, Map)
179
+ * Get the variation the user is bucketed into
180
+ * @see Optimizely#getVariation(Experiment, String)
181
+ * @param experimentKey a String experiment key
182
+ * @param userId a String userId
183
+ * @param attributes a map of attributes
184
+ * @return the variation for the provided experiment key, user id, and attributes
196
185
*/
186
+ @ SuppressWarnings ("WeakerAccess" )
197
187
public @ Nullable Variation getVariation (@ NonNull String experimentKey ,
198
188
@ NonNull String userId ,
199
189
@ NonNull Map <String , String > attributes ) {
0 commit comments