1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16+
1617package com .optimizely .ab .android .sdk ;
1718
1819import android .app .Activity ;
2122
2223import com .optimizely .ab .Optimizely ;
2324import com .optimizely .ab .UnknownEventTypeException ;
24- import com .optimizely .ab .UnknownExperimentException ;
2525import com .optimizely .ab .config .Experiment ;
26- import com .optimizely .ab .config .ProjectConfig ;
2726import com .optimizely .ab .config .Variation ;
2827
2928import org .slf4j .Logger ;
30- import org .slf4j .LoggerFactory ;
3129
3230import java .util .Map ;
3331
@@ -52,10 +50,14 @@ public class AndroidOptimizely {
5250 }
5351
5452 /**
53+ * Activate an experiment for a user
5554 * @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
5658 */
5759 public @ Nullable Variation activate (@ NonNull String experimentKey ,
58- @ NonNull String userId ) throws UnknownExperimentException {
60+ @ NonNull String userId ) {
5961 if (optimizely != null ) {
6062 return optimizely .activate (experimentKey , userId );
6163 } else {
@@ -66,11 +68,17 @@ public class AndroidOptimizely {
6668 }
6769
6870 /**
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
7077 */
78+ @ SuppressWarnings ("WeakerAccess" )
7179 public @ Nullable Variation activate (@ NonNull String experimentKey ,
7280 @ NonNull String userId ,
73- @ NonNull Map <String , String > attributes ) throws UnknownExperimentException {
81+ @ NonNull Map <String , String > attributes ) {
7482 if (optimizely != null ) {
7583 return optimizely .activate (experimentKey , userId , attributes );
7684 } else {
@@ -81,37 +89,12 @@ public class AndroidOptimizely {
8189 }
8290
8391 /**
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
11295 */
11396 public void track (@ NonNull String eventName ,
114- @ NonNull String userId ) throws UnknownEventTypeException {
97+ @ NonNull String userId ) {
11598 if (optimizely != null ) {
11699 optimizely .track (eventName , userId );
117100 } else {
@@ -120,7 +103,10 @@ public void track(@NonNull String eventName,
120103 }
121104
122105 /**
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
124110 */
125111 public void track (@ NonNull String eventName ,
126112 @ NonNull String userId ,
@@ -134,7 +120,10 @@ public void track(@NonNull String eventName,
134120 }
135121
136122 /**
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
138127 */
139128 public void track (@ NonNull String eventName ,
140129 @ NonNull String userId ,
@@ -148,12 +137,17 @@ public void track(@NonNull String eventName,
148137 }
149138
150139 /**
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
152146 */
153147 public void track (@ NonNull String eventName ,
154148 @ NonNull String userId ,
155149 @ NonNull Map <String , String > attributes ,
156- long eventValue ) throws UnknownEventTypeException {
150+ long eventValue ) {
157151 if (optimizely != null ) {
158152 optimizely .track (eventName , userId , attributes , eventValue );
159153 } else {
@@ -162,26 +156,16 @@ public void track(@NonNull String eventName,
162156 }
163157 }
164158
165-
166159 /**
160+ * Get the variation the user is bucketed into
167161 * @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
168165 */
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" )
183167 public @ Nullable Variation getVariation (@ NonNull String experimentKey ,
184- @ NonNull String userId ) throws UnknownExperimentException {
168+ @ NonNull String userId ) {
185169 if (optimizely != null ) {
186170 return optimizely .getVariation (experimentKey , userId );
187171 } else {
@@ -192,8 +176,14 @@ public void track(@NonNull String eventName,
192176 }
193177
194178 /**
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
196185 */
186+ @ SuppressWarnings ("WeakerAccess" )
197187 public @ Nullable Variation getVariation (@ NonNull String experimentKey ,
198188 @ NonNull String userId ,
199189 @ NonNull Map <String , String > attributes ) {
0 commit comments