Three options for localytics data in sync success--failed, errors, or success

pull/14/head
Sam Bosley 14 years ago
parent 1f1d6050f8
commit f97f21ae17

@ -218,6 +218,18 @@ public abstract class SyncProvider<TYPE extends SyncContainer> {
readRemotelyUpdated(data); 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<TYPE> data) throws IOException { protected void readRemotelyUpdated(SyncData<TYPE> data) throws IOException {
int length; int length;
// Rearrange remoteTasks so completed tasks get synchronized first. // Rearrange remoteTasks so completed tasks get synchronized first.

@ -124,7 +124,7 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
protected void performSync() { protected void performSync() {
actFmPreferenceService.recordSyncStart(); actFmPreferenceService.recordSyncStart();
boolean syncSuccess = false; String syncSuccess = "failed";
try { try {
int serverTime = Preferences.getInt(ActFmPreferenceService.PREF_SERVER_TIME, 0); int serverTime = Preferences.getInt(ActFmPreferenceService.PREF_SERVER_TIME, 0);
@ -145,7 +145,7 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
Preferences.setInt(ActFmPreferenceService.PREF_SERVER_TIME, newServerTime); Preferences.setInt(ActFmPreferenceService.PREF_SERVER_TIME, newServerTime);
actFmPreferenceService.recordSuccessfulSync(); actFmPreferenceService.recordSuccessfulSync();
syncSuccess = true; syncSuccess = getFinalSyncStatus();
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH); Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH);
ContextManager.getContext().sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); ContextManager.getContext().sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
@ -155,7 +155,7 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
handleException("actfm-sync", e, false); //$NON-NLS-1$ handleException("actfm-sync", e, false); //$NON-NLS-1$
} finally { } finally {
StatisticsService.reportEvent(StatisticsConstants.ACTFM_SYNC_FINISHED, StatisticsService.reportEvent(StatisticsConstants.ACTFM_SYNC_FINISHED,
"success", Boolean.toString(syncSuccess)); //$NON-NLS-1$ "success", syncSuccess); //$NON-NLS-1$
} }
} }

@ -159,7 +159,7 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
protected void performSync() { protected void performSync() {
boolean syncSuccess = false; String syncSuccess = "failed";
gtasksPreferenceService.recordSyncStart(); gtasksPreferenceService.recordSyncStart();
if(Constants.DEBUG) if(Constants.DEBUG)
Log.e("gtasks-debug", "- -------- SYNC STARTED"); Log.e("gtasks-debug", "- -------- SYNC STARTED");
@ -196,14 +196,15 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
ContextManager.getContext().sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ); ContextManager.getContext().sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
if(Constants.DEBUG) if(Constants.DEBUG)
Log.e("gtasks-debug", "- ------ SYNC FINISHED"); Log.e("gtasks-debug", "- ------ SYNC FINISHED");
syncSuccess = true;
syncSuccess = getFinalSyncStatus();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// occurs when application was closed // occurs when application was closed
} catch (IOException e) { } catch (IOException e) {
handleException("gtasks-sync", e, true); //$NON-NLS-1$ handleException("gtasks-sync", e, true); //$NON-NLS-1$
} finally { } finally {
StatisticsService.reportEvent(StatisticsConstants.GTASKS_SYNC_FINISHED, StatisticsService.reportEvent(StatisticsConstants.GTASKS_SYNC_FINISHED,
"success", Boolean.toString(syncSuccess)); //$NON-NLS-1$ "success", syncSuccess); //$NON-NLS-1$
} }
} }

@ -180,7 +180,7 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
protected void performSync() { protected void performSync() {
preferences.recordSyncStart(); preferences.recordSyncStart();
boolean syncSuccess = false; String syncSuccess = "failed";
try { try {
// load user information // load user information
@ -245,14 +245,14 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
// notification/activities stuff // notification/activities stuff
processNotifications(); processNotifications();
syncSuccess = true; syncSuccess = getFinalSyncStatus();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// occurs when application was closed // occurs when application was closed
} catch (Exception e) { } catch (Exception e) {
handleException("pdv-sync", e, true); //$NON-NLS-1$ handleException("pdv-sync", e, true); //$NON-NLS-1$
} finally { } finally {
StatisticsService.reportEvent(StatisticsConstants.PDV_SYNC_FINISHED, StatisticsService.reportEvent(StatisticsConstants.PDV_SYNC_FINISHED,
"success", Boolean.toString(syncSuccess)); //$NON-NLS-1$ "success", syncSuccess); //$NON-NLS-1$
} }
} }

Loading…
Cancel
Save