From f97f21ae1790754d0f3eace8ee6f059f113bc170 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 4 Nov 2011 18:37:21 -0700 Subject: [PATCH] Three options for localytics data in sync success--failed, errors, or success --- api/src/com/todoroo/astrid/sync/SyncProvider.java | 12 ++++++++++++ .../todoroo/astrid/actfm/sync/ActFmSyncProvider.java | 6 +++--- .../astrid/gtasks/sync/GtasksSyncProvider.java | 7 ++++--- .../producteev/sync/ProducteevSyncProvider.java | 6 +++--- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/api/src/com/todoroo/astrid/sync/SyncProvider.java b/api/src/com/todoroo/astrid/sync/SyncProvider.java index 7894d3917..081bf79cd 100644 --- a/api/src/com/todoroo/astrid/sync/SyncProvider.java +++ b/api/src/com/todoroo/astrid/sync/SyncProvider.java @@ -218,6 +218,18 @@ public abstract class SyncProvider { readRemotelyUpdated(data); } + @SuppressWarnings("nls") + protected String getFinalSyncStatus() { + if (getUtilities().getLastError() != null || getUtilities().getLastAttemptedSyncDate() != 0) { + if (getUtilities().getLastAttemptedSyncDate() == 0) + return "errors"; + else + return "failed"; + } else { + return "success"; + } + } + protected void readRemotelyUpdated(SyncData data) throws IOException { int length; // Rearrange remoteTasks so completed tasks get synchronized first. diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncProvider.java index cdf80e3e5..b0c5ebf6d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncProvider.java @@ -124,7 +124,7 @@ public class ActFmSyncProvider extends SyncProvider { protected void performSync() { actFmPreferenceService.recordSyncStart(); - boolean syncSuccess = false; + String syncSuccess = "failed"; try { int serverTime = Preferences.getInt(ActFmPreferenceService.PREF_SERVER_TIME, 0); @@ -145,7 +145,7 @@ public class ActFmSyncProvider extends SyncProvider { Preferences.setInt(ActFmPreferenceService.PREF_SERVER_TIME, newServerTime); actFmPreferenceService.recordSuccessfulSync(); - syncSuccess = true; + syncSuccess = getFinalSyncStatus(); Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH); ContextManager.getContext().sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); @@ -155,7 +155,7 @@ public class ActFmSyncProvider extends SyncProvider { handleException("actfm-sync", e, false); //$NON-NLS-1$ } finally { StatisticsService.reportEvent(StatisticsConstants.ACTFM_SYNC_FINISHED, - "success", Boolean.toString(syncSuccess)); //$NON-NLS-1$ + "success", syncSuccess); //$NON-NLS-1$ } } diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java index 32b623c76..579819ce2 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/sync/GtasksSyncProvider.java @@ -159,7 +159,7 @@ public class GtasksSyncProvider extends SyncProvider { // ---------------------------------------------------------------------- protected void performSync() { - boolean syncSuccess = false; + String syncSuccess = "failed"; gtasksPreferenceService.recordSyncStart(); if(Constants.DEBUG) Log.e("gtasks-debug", "- -------- SYNC STARTED"); @@ -196,14 +196,15 @@ public class GtasksSyncProvider extends SyncProvider { ContextManager.getContext().sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); if(Constants.DEBUG) Log.e("gtasks-debug", "- ------ SYNC FINISHED"); - syncSuccess = true; + + syncSuccess = getFinalSyncStatus(); } catch (IllegalStateException e) { // occurs when application was closed } catch (IOException e) { handleException("gtasks-sync", e, true); //$NON-NLS-1$ } finally { StatisticsService.reportEvent(StatisticsConstants.GTASKS_SYNC_FINISHED, - "success", Boolean.toString(syncSuccess)); //$NON-NLS-1$ + "success", syncSuccess); //$NON-NLS-1$ } } diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java index 9ee7d0a13..397790796 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/sync/ProducteevSyncProvider.java @@ -180,7 +180,7 @@ public class ProducteevSyncProvider extends SyncProvider