consolidated sync events to report one not two

pull/14/head
Tim Su 15 years ago
parent 3db04edd0d
commit 0258377d8b

@ -123,6 +123,7 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
protected void performSync() { protected void performSync() {
actFmPreferenceService.recordSyncStart(); actFmPreferenceService.recordSyncStart();
boolean syncSuccess = false;
try { try {
int serverTime = Preferences.getInt(ActFmPreferenceService.PREF_SERVER_TIME, 0); int serverTime = Preferences.getInt(ActFmPreferenceService.PREF_SERVER_TIME, 0);
@ -145,8 +146,7 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
Preferences.setInt(ActFmPreferenceService.PREF_SERVER_TIME, serverTime); Preferences.setInt(ActFmPreferenceService.PREF_SERVER_TIME, serverTime);
actFmPreferenceService.recordSuccessfulSync(); actFmPreferenceService.recordSuccessfulSync();
StatisticsService.reportEvent("actfm-sync-finished"); //$NON-NLS-1$ syncSuccess = true;
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);
@ -154,6 +154,9 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
// occurs when application was closed // occurs when application was closed
} catch (Exception e) { } catch (Exception e) {
handleException("actfm-sync", e, true); //$NON-NLS-1$ handleException("actfm-sync", e, true); //$NON-NLS-1$
} finally {
StatisticsService.reportEvent("actfm-sync-finished",
"success", Boolean.toString(syncSuccess)); //$NON-NLS-1$
} }
} }

@ -166,7 +166,7 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
protected void performSync() { protected void performSync() {
StatisticsService.reportEvent("gtasks-started"); boolean syncSuccess = false;
gtasksPreferenceService.recordSyncStart(); gtasksPreferenceService.recordSyncStart();
if(Constants.DEBUG) if(Constants.DEBUG)
Log.e("gtasks-debug", "- -------- SYNC STARTED"); Log.e("gtasks-debug", "- -------- SYNC STARTED");
@ -191,16 +191,19 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
gtasksTaskListUpdater.updateAllMetadata(); gtasksTaskListUpdater.updateAllMetadata();
gtasksPreferenceService.recordSuccessfulSync(); gtasksPreferenceService.recordSuccessfulSync();
StatisticsService.reportEvent("gtasks-sync-finished"); //$NON-NLS-1$
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);
if(Constants.DEBUG) if(Constants.DEBUG)
Log.e("gtasks-debug", "- ------ SYNC FINISHED"); Log.e("gtasks-debug", "- ------ SYNC FINISHED");
syncSuccess = true;
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// occurs when application was closed // occurs when application was closed
} catch (Exception e) { } catch (Exception e) {
handleException("gtasks-sync", e, true); //$NON-NLS-1$ handleException("gtasks-sync", e, true); //$NON-NLS-1$
} finally {
StatisticsService.reportEvent("gtasks-sync-finished",
"success", Boolean.toString(syncSuccess)); //$NON-NLS-1$
} }
} }

@ -178,8 +178,8 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
protected void performSync() { protected void performSync() {
StatisticsService.reportEvent("pdv-started");
preferences.recordSyncStart(); preferences.recordSyncStart();
boolean syncSuccess = false;
try { try {
// load user information // load user information
@ -242,11 +242,14 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
// notification/activities stuff // notification/activities stuff
processNotifications(); processNotifications();
StatisticsService.reportEvent("pdv-sync-finished"); //$NON-NLS-1$ syncSuccess = true;
} 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 {
StatisticsService.reportEvent("pdv-sync-finished",
"success", Boolean.toString(syncSuccess)); //$NON-NLS-1$
} }
} }

@ -54,7 +54,7 @@ public class RepeatTaskCompleteListener extends BroadcastReceiver {
return; return;
} }
StatisticsService.reportEvent("task-repeated"); //$NON-NLS-1$ StatisticsService.reportEvent("v2-task-repeat"); //$NON-NLS-1$
long hideUntil = task.getValue(Task.HIDE_UNTIL); long hideUntil = task.getValue(Task.HIDE_UNTIL);
if(hideUntil > 0 && task.getValue(Task.DUE_DATE) > 0) { if(hideUntil > 0 && task.getValue(Task.DUE_DATE) > 0) {

@ -4,6 +4,8 @@
package com.todoroo.astrid.service; package com.todoroo.astrid.service;
import java.util.HashMap;
import android.content.Context; import android.content.Context;
import com.localytics.android.LocalyticsSession; import com.localytics.android.LocalyticsSession;
@ -71,12 +73,19 @@ public class StatisticsService {
* Indicates an event should be reported * Indicates an event should be reported
* @param event * @param event
*/ */
public static void reportEvent(String event) { public static void reportEvent(String event, String... attributes) {
if(dontCollectStatistics()) if(dontCollectStatistics())
return; return;
if(localyticsSession != null) if(localyticsSession != null) {
localyticsSession.tagEvent(event); if(attributes.length > 0) {
HashMap<String, String> attrMap = new HashMap<String, String>();
for(int i = 1; i < attributes.length; i += 2)
attrMap.put(attributes[i-1], attributes[i]);
localyticsSession.tagEvent(event, attrMap);
} else
localyticsSession.tagEvent(event);
}
} }
private static boolean dontCollectStatistics() { private static boolean dontCollectStatistics() {

Loading…
Cancel
Save