Report ab test event info when assigning a task

pull/14/head
Sam Bosley 12 years ago
parent 589ba589a2
commit 190b5dcf74

@ -69,6 +69,7 @@ import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.service.abtesting.ABTestEventReportingService;
import com.todoroo.astrid.sync.SyncV2Provider.SyncExceptionHandler;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.utility.Flags;
@ -95,6 +96,7 @@ public final class ActFmSyncService {
@Autowired TagDataDao tagDataDao;
@Autowired UpdateDao updateDao;
@Autowired MetadataDao metadataDao;
@Autowired ABTestEventReportingService abTestEventReportingService;
public static final long TIME_BETWEEN_TRIES = 5 * DateUtilities.ONE_MINUTE;
@ -382,6 +384,8 @@ public final class ActFmSyncService {
params.add("repeat"); params.add(recurrence);
}
boolean sharing = false;
if(values.containsKey(Task.USER_ID.name) && task.getTransitory(TaskService.TRANS_ASSIGNED) != null) {
if(task.getValue(Task.USER_ID) == Task.USER_ID_EMAIL) {
try {
@ -403,6 +407,7 @@ public final class ActFmSyncService {
else
params.add(task.getValue(Task.USER_ID));
}
sharing = true;
}
if (values.containsKey(Task.SHARED_WITH.name)) {
@ -422,6 +427,18 @@ public final class ActFmSyncService {
} catch (JSONException e) {
Log.e("Error parsing shared_with", task.getValue(Task.SHARED_WITH), e);
}
sharing = true;
}
if (sharing) {
JSONArray abTestInfo = abTestEventReportingService.getTestsWithVariantsArray();
try {
for (int i = 0; i < abTestInfo.length(); i++) {
params.add("ab_variants[]"); params.add(abTestInfo.getString(i));
}
} catch (JSONException e) {
Log.e("Error parsing AB test info", abTestInfo.toString(), e);
}
}
if(Flags.checkAndClear(Flags.TAGS_CHANGED) || newlyCreated) {

@ -1,6 +1,7 @@
package com.todoroo.astrid.service.abtesting;
import java.io.IOException;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
@ -41,6 +42,9 @@ public final class ABTestEventReportingService {
@Autowired
private ABTestInvoker abTestInvoker;
@Autowired
private ABTests abTests;
public ABTestEventReportingService() {
DependencyInjectionService.getInstance().inject(this);
}
@ -88,6 +92,16 @@ public final class ABTestEventReportingService {
}
}
public JSONArray getTestsWithVariantsArray() {
JSONArray array = new JSONArray();
Set<String> tests = abTests.getAllTestKeys();
for (String key : tests) {
array.put(key + ":" + abTests.getDescriptionForTestOption(key, ABChooser.readChoiceForTest(key)));
}
return array;
}
private void handleException(Exception e) {
Log.e("analytics", "analytics-error", e);
}

Loading…
Cancel
Save