consolidated sync events to report one not two

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

@ -123,6 +123,7 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
protected void performSync() {
actFmPreferenceService.recordSyncStart();
boolean syncSuccess = false;
try {
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);
actFmPreferenceService.recordSuccessfulSync();
StatisticsService.reportEvent("actfm-sync-finished"); //$NON-NLS-1$
syncSuccess = true;
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH);
ContextManager.getContext().sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
@ -154,6 +154,9 @@ public class ActFmSyncProvider extends SyncProvider<ActFmTaskContainer> {
// occurs when application was closed
} catch (Exception e) {
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() {
StatisticsService.reportEvent("gtasks-started");
boolean syncSuccess = false;
gtasksPreferenceService.recordSyncStart();
if(Constants.DEBUG)
Log.e("gtasks-debug", "- -------- SYNC STARTED");
@ -191,16 +191,19 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
gtasksTaskListUpdater.updateAllMetadata();
gtasksPreferenceService.recordSuccessfulSync();
StatisticsService.reportEvent("gtasks-sync-finished"); //$NON-NLS-1$
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH);
ContextManager.getContext().sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
if(Constants.DEBUG)
Log.e("gtasks-debug", "- ------ SYNC FINISHED");
syncSuccess = true;
} catch (IllegalStateException e) {
// occurs when application was closed
} catch (Exception e) {
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() {
StatisticsService.reportEvent("pdv-started");
preferences.recordSyncStart();
boolean syncSuccess = false;
try {
// load user information
@ -242,11 +242,14 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
// notification/activities stuff
processNotifications();
StatisticsService.reportEvent("pdv-sync-finished"); //$NON-NLS-1$
syncSuccess = true;
} catch (IllegalStateException e) {
// occurs when application was closed
} catch (Exception e) {
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;
}
StatisticsService.reportEvent("task-repeated"); //$NON-NLS-1$
StatisticsService.reportEvent("v2-task-repeat"); //$NON-NLS-1$
long hideUntil = task.getValue(Task.HIDE_UNTIL);
if(hideUntil > 0 && task.getValue(Task.DUE_DATE) > 0) {

@ -4,6 +4,8 @@
package com.todoroo.astrid.service;
import java.util.HashMap;
import android.content.Context;
import com.localytics.android.LocalyticsSession;
@ -71,12 +73,19 @@ public class StatisticsService {
* Indicates an event should be reported
* @param event
*/
public static void reportEvent(String event) {
public static void reportEvent(String event, String... attributes) {
if(dontCollectStatistics())
return;
if(localyticsSession != null)
localyticsSession.tagEvent(event);
if(localyticsSession != null) {
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() {

Loading…
Cancel
Save