25
25
import com .optimizely .ab .config .Experiment ;
26
26
import com .optimizely .ab .config .ProjectConfig ;
27
27
import com .optimizely .ab .config .Variation ;
28
+ import com .optimizely .ab .internal .ReservedEventKey ;
28
29
import com .optimizely .ab .notification .NotificationListener ;
29
30
30
31
import org .slf4j .Logger ;
31
32
33
+ import java .util .Collections ;
32
34
import java .util .HashMap ;
33
35
import java .util .Map ;
34
36
@@ -219,7 +221,7 @@ public void track(@NonNull String eventName,
219
221
@ NonNull String userId ,
220
222
long eventValue ) throws UnknownEventTypeException {
221
223
if (isValid ()) {
222
- optimizely .track (eventName , userId , getDefaultAttributes (), eventValue );
224
+ optimizely .track (eventName , userId , getDefaultAttributes (), Collections . singletonMap ( ReservedEventKey . REVENUE . toString (), eventValue ) );
223
225
} else {
224
226
logger .warn ("Optimizely is not initialized, could not track event {} for user {}" +
225
227
" with value {}" , eventName , userId , eventValue );
@@ -228,7 +230,7 @@ public void track(@NonNull String eventName,
228
230
229
231
/**
230
232
* Track an event for a user with attributes and a value
231
- * @see Optimizely#track(String, String, Map, long )
233
+ * @see Optimizely#track(String, String, Map, Map )
232
234
* @deprecated see {@link Optimizely#track(String, String, Map, Map)} and pass in revenue values as event tags instead.
233
235
* @param eventName the String name of the event
234
236
* @param userId the String user id
@@ -240,157 +242,13 @@ public void track(@NonNull String eventName,
240
242
@ NonNull Map <String , String > attributes ,
241
243
long eventValue ) {
242
244
if (isValid ()) {
243
- optimizely .track (eventName , userId , getAllAttributes (attributes ), eventValue );
245
+ optimizely .track (eventName , userId , getAllAttributes (attributes ), Collections . singletonMap ( ReservedEventKey . REVENUE . toString (), eventValue ) );
244
246
} else {
245
247
logger .warn ("Optimizely is not initialized, could not track event {} for user {}" +
246
248
" with value {} and attributes" , eventName , userId , eventValue );
247
249
}
248
250
}
249
251
250
- /**
251
- * Get the value of a String live variable
252
- * @param variableKey the String key for the variable
253
- * @param userId the user ID
254
- * @param activateExperiment the flag denoting whether to activate an experiment or not
255
- * @return String value of the live variable
256
- */
257
- public @ Nullable String getVariableString (@ NonNull String variableKey ,
258
- @ NonNull String userId ,
259
- boolean activateExperiment ) {
260
- return getVariableString (variableKey , userId , getDefaultAttributes (),
261
- activateExperiment );
262
- }
263
-
264
- /**
265
- * Get the value of a String live variable
266
- * @param variableKey the String key for the variable
267
- * @param userId the user ID
268
- * @param attributes a map of attributes about the user
269
- * @param activateExperiment the flag denoting whether to activate an experiment or not
270
- * @return String value of the live variable
271
- */
272
- public @ Nullable String getVariableString (@ NonNull String variableKey ,
273
- @ NonNull String userId ,
274
- @ NonNull Map <String , String > attributes ,
275
- boolean activateExperiment ) {
276
- if (isValid ()) {
277
- return optimizely .getVariableString (variableKey , userId , getAllAttributes (attributes ),
278
- activateExperiment );
279
- } else {
280
- logger .warn ("Optimizely is not initialized, could not get live variable {} " +
281
- "for user {}" , variableKey , userId );
282
- return null ;
283
- }
284
- }
285
-
286
- /**
287
- * Get the value of a Boolean live variable
288
- * @param variableKey the String key for the variable
289
- * @param userId the user ID
290
- * @param activateExperiment the flag denoting whether to activate an experiment or not
291
- * @return Boolean value of the live variable
292
- */
293
- public @ Nullable Boolean getVariableBoolean (@ NonNull String variableKey ,
294
- @ NonNull String userId ,
295
- boolean activateExperiment ) {
296
- return getVariableBoolean (variableKey , userId , getDefaultAttributes (),
297
- activateExperiment );
298
- }
299
-
300
- /**
301
- * Get the value of a Boolean live variable
302
- * @param variableKey the String key for the variable
303
- * @param userId the user ID
304
- * @param attributes a map of attributes about the user
305
- * @param activateExperiment the flag denoting whether to activate an experiment or not
306
- * @return Boolean value of the live variable
307
- */
308
- public @ Nullable Boolean getVariableBoolean (@ NonNull String variableKey ,
309
- @ NonNull String userId ,
310
- @ NonNull Map <String , String > attributes ,
311
- boolean activateExperiment ) {
312
- if (isValid ()) {
313
- return optimizely .getVariableBoolean (variableKey , userId , getAllAttributes (attributes ),
314
- activateExperiment );
315
- } else {
316
- logger .warn ("Optimizely is not initialized, could not get live variable {} " +
317
- "for user {}" , variableKey , userId );
318
- return null ;
319
- }
320
- }
321
-
322
- /**
323
- * Get the value of a Integer live variable
324
- * @param variableKey the String key for the variable
325
- * @param userId the user ID
326
- * @param activateExperiment the flag denoting whether to activate an experiment or not
327
- * @return Integer value of the live variable
328
- */
329
- public @ Nullable Integer getVariableInteger (@ NonNull String variableKey ,
330
- @ NonNull String userId ,
331
- boolean activateExperiment ) {
332
- return getVariableInteger (variableKey , userId , getDefaultAttributes (),
333
- activateExperiment );
334
- }
335
-
336
- /**
337
- * Get the value of a Integer live variable
338
- * @param variableKey the String key for the variable
339
- * @param userId the user ID
340
- * @param attributes a map of attributes about the user
341
- * @param activateExperiment the flag denoting whether to activate an experiment or not
342
- * @return Integer value of the live variable
343
- */
344
- public @ Nullable Integer getVariableInteger (@ NonNull String variableKey ,
345
- @ NonNull String userId ,
346
- @ NonNull Map <String , String > attributes ,
347
- boolean activateExperiment ) {
348
- if (isValid ()) {
349
- return optimizely .getVariableInteger (variableKey , userId , getAllAttributes (attributes ),
350
- activateExperiment );
351
- } else {
352
- logger .warn ("Optimizely is not initialized, could not get live variable {} " +
353
- "for user {}" , variableKey , userId );
354
- return null ;
355
- }
356
- }
357
-
358
- /**
359
- * Get the value of a Double live variable
360
- * @param variableKey the String key for the variable
361
- * @param userId the user ID
362
- * @param activateExperiment the flag denoting whether to activate an experiment or not
363
- * @return Double value of the live variable
364
- */
365
- public @ Nullable Double getVariableDouble (@ NonNull String variableKey ,
366
- @ NonNull String userId ,
367
- boolean activateExperiment ) {
368
- return getVariableDouble (variableKey , userId , getDefaultAttributes (),
369
- activateExperiment );
370
- }
371
-
372
- /**
373
- * Get the value of a Double live variable
374
- * @param variableKey the String key for the variable
375
- * @param userId the user ID
376
- * @param attributes a map of attributes about the user
377
- * @param activateExperiment the flag denoting whether to activate an experiment or not
378
- * @return Double value of the live variable
379
- */
380
- public @ Nullable Double getVariableDouble (@ NonNull String variableKey ,
381
- @ NonNull String userId ,
382
- @ NonNull Map <String , String > attributes ,
383
- boolean activateExperiment ) {
384
- if (isValid ()) {
385
- return optimizely .getVariableDouble (variableKey , userId , getAllAttributes (attributes ),
386
- activateExperiment );
387
- } else {
388
- logger .warn ("Optimizely is not initialized, could not get live variable {} " +
389
- "for user {}" , variableKey , userId );
390
- return null ;
391
- }
392
- }
393
-
394
252
/**
395
253
* Get the variation the user is bucketed into
396
254
* @see Optimizely#getVariation(Experiment, String)
0 commit comments