Added new statistics for measuring new user retention, tasks created after 1, 2, 3 weeks

pull/14/head
Sam Bosley 13 years ago
parent ec4e3e61aa
commit 95706b246f

@ -219,15 +219,33 @@ public class TaskDao extends DatabaseDao<Task> {
ContentValues values = item.getSetValues();
boolean result = super.createNew(item);
if(result) {
if(Preferences.getBoolean(AstridPreferences.P_FIRST_ACTION, false)) {
StatisticsService.reportEvent(StatisticsConstants.USER_FIRST_TASK);
Preferences.setBoolean(AstridPreferences.P_FIRST_ACTION, false);
}
userRetentionMetrics();
afterSave(item, values);
}
return result;
}
private void userRetentionMetrics() {
if(Preferences.getBoolean(AstridPreferences.P_FIRST_ACTION, false)) {
StatisticsService.reportEvent(StatisticsConstants.USER_FIRST_TASK);
Preferences.setBoolean(AstridPreferences.P_FIRST_ACTION, false);
}
long firstLaunchTime = Preferences.getLong(AstridPreferences.P_FIRST_LAUNCH, 0);
long now = DateUtilities.now();
long timeSinceFirst = now - firstLaunchTime;
if (timeSinceFirst < DateUtilities.ONE_WEEK && !Preferences.getBoolean(StatisticsConstants.TASK_ONE_WEEK, false)) {
StatisticsService.reportEvent(StatisticsConstants.TASK_ONE_WEEK);
Preferences.setBoolean(StatisticsConstants.TASK_ONE_WEEK, true);
} else if (timeSinceFirst < 2 * DateUtilities.ONE_WEEK && !Preferences.getBoolean(StatisticsConstants.TASK_TWO_WEEKS, false)) {
StatisticsService.reportEvent(StatisticsConstants.TASK_TWO_WEEKS);
Preferences.setBoolean(StatisticsConstants.TASK_TWO_WEEKS, true);
} else if (timeSinceFirst < 3 * DateUtilities.ONE_WEEK && !Preferences.getBoolean(StatisticsConstants.TASK_THREE_WEEKS, false)) {
StatisticsService.reportEvent(StatisticsConstants.TASK_THREE_WEEKS);
Preferences.setBoolean(StatisticsConstants.TASK_THREE_WEEKS, true);
}
}
/**
* Sets default reminders for the given task if reminders are not set
* @param item

@ -28,6 +28,7 @@ import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
@ -131,6 +132,10 @@ public class StartupService {
}
if (latestSetVersion == 0) {
if (Preferences.getLong(AstridPreferences.P_FIRST_LAUNCH, -1) < 0) {
Preferences.setLong(AstridPreferences.P_FIRST_LAUNCH, DateUtilities.now());
}
int defaultTheme = abChooser.getChoiceForOption(ABOptions.AB_THEME_KEY);
if (defaultTheme == 0)
Preferences.setString(R.string.p_theme, "white");
@ -138,6 +143,7 @@ public class StartupService {
Preferences.setString(R.string.p_theme, "black");
} else {
abChooser.setChoiceForOption(ABOptions.AB_THEME_KEY, 0);
Preferences.setLong(AstridPreferences.P_FIRST_LAUNCH, 0);
}
int version = 0;

@ -58,5 +58,9 @@ public class StatisticsConstants {
public static final String REPEAT_TASK_CREATE = "repeat-task-create";
public static final String ACTFM_LIST_SHARED = "actfm-list-shared";
public static final String TASK_ONE_WEEK = "task-created-one-week";
public static final String TASK_TWO_WEEKS = "task-created-two-weeks";
public static final String TASK_THREE_WEEKS = "task-created-three-weeks";
}

@ -177,6 +177,9 @@ public class ABOptions {
private static final String[] AB_THEME_DESCRIPTIONS = { "ab-theme-white", "ab-theme-black" };
private static final String[] AB_THEME_EVENTS = { StatisticsConstants.USER_FIRST_TASK,
StatisticsConstants.USER_FIRST_LIST,
StatisticsConstants.ACTFM_NEW_USER };
StatisticsConstants.ACTFM_NEW_USER,
StatisticsConstants.TASK_ONE_WEEK,
StatisticsConstants.TASK_TWO_WEEKS,
StatisticsConstants.TASK_THREE_WEEKS };
}

@ -21,6 +21,8 @@ public class AstridPreferences {
public static final String P_UPGRADE_FROM = "uf"; //$NON-NLS-1$
public static final String P_FIRST_LAUNCH = "fltime"; //$NON-NLS-1$
/** Set preference defaults, if unset. called at startup */
public static void setPreferenceDefaults() {
Context context = ContextManager.getContext();

Loading…
Cancel
Save