Commit 1c0e06e7 authored by Tiago Cunha's avatar Tiago Cunha

Log if error logs to firebase. Should help

parent b5cf7b21
......@@ -95,10 +95,10 @@ dependencies {
}
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-core:10.0.0'
compile 'com.google.firebase:firebase-crash:10.0.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.android.gms:play-services-gcm:10.0.0'
compile 'com.google.android.gms:play-services-gcm:10.2.0'
compile rootProject.ext.okhttp3
......
......@@ -14,7 +14,7 @@ import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.fragment.chatroom.HomeFragment;
import chat.rocket.android.fragment.chatroom.RoomFragment;
import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.core.interactors.CanCreateRoomInteractor;
import chat.rocket.core.interactors.RoomInteractor;
import chat.rocket.core.interactors.SessionInteractor;
......@@ -91,14 +91,14 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
private void setUserOnlineIfServerAvailable() {
if (hostname != null) {
new MethodCallHelper(this, hostname).setUserPresence(User.STATUS_ONLINE)
.continueWith(new LogcatIfError());
.continueWith(new LogIfError());
}
}
private void setUserAwayIfServerAvailable() {
if (hostname != null) {
new MethodCallHelper(this, hostname).setUserPresence(User.STATUS_AWAY)
.continueWith(new LogcatIfError());
.continueWith(new LogIfError());
}
}
......
......@@ -6,7 +6,7 @@ import android.support.v4.util.Pair;
import chat.rocket.android.BackgroundLooper;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.android.shared.BasePresenter;
import chat.rocket.core.SyncState;
import chat.rocket.core.interactors.MessageInteractor;
......@@ -153,7 +153,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
room -> methodCallHelper.readMessages(room.getRoomId())
.continueWith(new LogcatIfError())
.continueWith(new LogIfError())
);
addSubscription(subscription);
......
......@@ -14,7 +14,7 @@ import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import chat.rocket.android.R;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.android.layouthelper.chatroom.dialog.RoomUserAdapter;
import chat.rocket.android.log.RCLog;
import chat.rocket.core.SyncState;
......@@ -92,7 +92,7 @@ public class UsersOfRoomDialogFragment extends AbstractChatRoomDialogFragment {
ConnectivityManager.getInstance(getContext().getApplicationContext())
.keepAliveServer();
return task;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
@Override
......
......@@ -12,7 +12,7 @@ import org.json.JSONObject;
import java.nio.charset.Charset;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.fragment.AbstractWebViewFragment;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.persistence.realm.models.ddp.RealmMeteorLoginServiceConfiguration;
import chat.rocket.persistence.realm.RealmStore;
......@@ -111,7 +111,7 @@ public abstract class AbstractOAuthFragment extends AbstractWebViewFragment {
private void handleOAuthCallback(final String credentialToken, final String credentialSecret) {
new MethodCallHelper(getContext(), hostname)
.loginWithOAuth(credentialToken, credentialSecret)
.continueWith(new LogcatIfError());
.continueWith(new LogIfError());
}
protected void onOAuthCompleted() {
......
......@@ -4,7 +4,7 @@ import android.support.annotation.NonNull;
import chat.rocket.android.BackgroundLooper;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.shared.BasePresenter;
import chat.rocket.core.interactors.RoomInteractor;
......@@ -67,7 +67,7 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
@Override
public void onLogout() {
if (methodCallHelper != null) {
methodCallHelper.logout().continueWith(new LogcatIfError());
methodCallHelper.logout().continueWith(new LogIfError());
}
}
......@@ -95,7 +95,7 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
private void updateCurrentUserStatus(String status) {
if (methodCallHelper != null) {
methodCallHelper.setUserStatus(status).continueWith(new LogcatIfError());
methodCallHelper.setUserStatus(status).continueWith(new LogIfError());
}
}
}
......@@ -74,7 +74,7 @@ public class FileUploadHelper {
.put(FileUploading.ROOM_ID, roomId)
.put(FileUploading.ERROR, JSONObject.NULL)
)
).continueWith(new LogcatIfError());
).continueWith(new LogIfError());
return uplId;
}
......
package chat.rocket.android.helper;
import com.google.firebase.crash.FirebaseCrash;
import bolts.Continuation;
import bolts.Task;
import chat.rocket.android.BuildConfig;
import chat.rocket.android.log.RCLog;
/**
* Bolts-Task continuation for just logging if error occurred.
*/
public class LogcatIfError implements Continuation {
public class LogIfError implements Continuation {
@Override
public Object then(Task task) throws Exception {
if (task.isFaulted()) {
RCLog.w(task.getError());
if (BuildConfig.DEBUG) {
RCLog.w(task.getError());
}
FirebaseCrash.report(task.getError());
}
return task;
}
......
......@@ -11,7 +11,7 @@ import java.util.Iterator;
import bolts.Task;
import chat.rocket.android.api.DDPClientWrapper;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.log.RCLog;
import chat.rocket.core.models.ServerInfo;
......@@ -135,7 +135,7 @@ public class RocketChatWebSocketThread extends HandlerThread {
session.setError(null);
}
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
/**
......
......@@ -9,7 +9,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.util.Iterator;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.persistence.realm.RealmHelper;
import chat.rocket.android.service.DDPClientRef;
......@@ -68,7 +68,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registrable {
ddpClientRef.get().subscribe(getSubscriptionName(), params).onSuccess(task -> {
if (isUnsubscribed) {
ddpClientRef.get().unsubscribe(task.getResult().id).continueWith(new LogcatIfError());
ddpClientRef.get().unsubscribe(task.getResult().id).continueWith(new LogIfError());
} else {
subscriptionId = task.getResult().id;
}
......@@ -87,7 +87,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registrable {
}).onSuccess(task -> {
rxSubscription = subscribe();
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
} else {
rxSubscription = subscribe();
}
......@@ -122,7 +122,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registrable {
realmHelper.executeTransaction(realm -> {
onDocumentAdded(realm, docEvent);
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
private void onDocumentAdded(Realm realm, DDPSubscription.Added docEvent) throws JSONException {
......@@ -136,7 +136,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registrable {
realmHelper.executeTransaction(realm -> {
onDocumentChanged(realm, docEvent);
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
private void onDocumentChanged(Realm realm, DDPSubscription.Changed docEvent)
......@@ -157,7 +157,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registrable {
realmHelper.executeTransaction(realm -> {
onDocumentRemoved(realm, docEvent);
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
private void onDocumentRemoved(Realm realm, DDPSubscription.Removed docEvent)
......@@ -182,7 +182,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registrable {
rxSubscription.unsubscribe();
}
if (!TextUtils.isEmpty(subscriptionId)) {
ddpClientRef.get().unsubscribe(subscriptionId).continueWith(new LogcatIfError());
ddpClientRef.get().unsubscribe(subscriptionId).continueWith(new LogIfError());
}
}
}
......@@ -5,7 +5,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.persistence.realm.RealmHelper;
import chat.rocket.android.service.DDPClientRef;
......@@ -69,11 +69,11 @@ abstract class AbstractStreamNotifyEventSubscriber extends AbstractDDPDocEventSu
realm.where(getModelClass())
.equalTo(getPrimaryKeyForModel(), target.getString(getPrimaryKeyForModel()))
.findAll().deleteAllFromRealm()
).continueWith(new LogcatIfError());
).continueWith(new LogIfError());
} else { //inserted, updated
realmHelper.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(getModelClass(), customizeFieldJson(target))
).continueWith(new LogcatIfError());
).continueWith(new LogIfError());
}
}
}
......@@ -7,7 +7,7 @@ import io.realm.RealmResults;
import java.util.ArrayList;
import java.util.List;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.persistence.realm.models.ddp.RealmUser;
import chat.rocket.persistence.realm.RealmHelper;
import chat.rocket.android.service.DDPClientRef;
......@@ -67,7 +67,7 @@ public class CurrentUserObserver extends AbstractModelObserver<RealmUser> {
listeners.add(listener);
}
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
@DebugLog
......
......@@ -12,7 +12,7 @@ import java.io.InputStream;
import java.util.List;
import bolts.Task;
import chat.rocket.android.api.FileUploadingHelper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.android.helper.OkHttpHelper;
import chat.rocket.android.log.RCLog;
import chat.rocket.core.SyncState;
......@@ -59,7 +59,7 @@ public class FileUploadingToS3Observer extends AbstractModelObserver<FileUploadi
.equalTo(FileUploading.STORAGE_TYPE, FileUploading.STORAGE_TYPE_S3)
.findAll().deleteAllFromRealm();
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
@Override
......@@ -137,7 +137,7 @@ public class FileUploadingToS3Observer extends AbstractModelObserver<FileUploadi
realm.createOrUpdateObjectFromJson(FileUploading.class, new JSONObject()
.put(FileUploading.ID, uplId)
.put(FileUploading.UPLOADED_SIZE, numBytes)))
.continueWith(new LogcatIfError());
.continueWith(new LogIfError());
}
}
}
......
......@@ -10,7 +10,7 @@ import java.io.InputStream;
import java.util.List;
import bolts.Task;
import chat.rocket.android.api.FileUploadingHelper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.android.helper.OkHttpHelper;
import chat.rocket.android.log.RCLog;
import chat.rocket.core.SyncState;
......@@ -63,7 +63,7 @@ public class FileUploadingWithUfsObserver extends AbstractModelObserver<FileUplo
.endGroup()
.findAll().deleteAllFromRealm();
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
@Override
......
......@@ -12,7 +12,7 @@ import java.util.List;
import bolts.Task;
import chat.rocket.android.RocketChatCache;
import chat.rocket.android.api.RaixPushHelper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.core.SyncState;
import chat.rocket.persistence.realm.models.ddp.RealmPublicSetting;
import chat.rocket.core.PublicSettingsConstants;
......@@ -59,7 +59,7 @@ public class GcmPushRegistrationObserver extends AbstractModelObserver<GcmPushRe
realmHelper.executeTransaction(realm -> {
GcmPushRegistration.queryDefault(realm).findFirst().setSyncState(SyncState.FAILED);
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
return null;
});
......
......@@ -7,7 +7,7 @@ import org.json.JSONObject;
import java.util.List;
import chat.rocket.android.helper.CheckSum;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.core.SyncState;
import chat.rocket.persistence.realm.models.internal.MethodCall;
import chat.rocket.persistence.realm.RealmHelper;
......@@ -45,7 +45,7 @@ public class MethodCallObserver extends AbstractModelObserver<MethodCall> {
.endGroup()
.findAll().deleteAllFromRealm();
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
@Override
......@@ -120,6 +120,6 @@ public class MethodCallObserver extends AbstractModelObserver<MethodCall> {
});
}
return task;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
}
......@@ -7,7 +7,7 @@ import org.json.JSONObject;
import java.util.List;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.core.SyncState;
import chat.rocket.persistence.realm.models.ddp.RealmMessage;
......@@ -36,7 +36,7 @@ public class NewMessageObserver extends AbstractModelObserver<RealmMessage> {
}
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
@Override
......
......@@ -7,7 +7,7 @@ import io.realm.RealmResults;
import java.util.List;
import chat.rocket.android.RocketChatCache;
import chat.rocket.android.api.RaixPushHelper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.persistence.realm.models.internal.GetUsersOfRoomsProcedure;
import chat.rocket.persistence.realm.models.internal.LoadMessageProcedure;
import chat.rocket.persistence.realm.models.internal.MethodCall;
......@@ -73,7 +73,7 @@ public class SessionObserver extends AbstractModelObserver<RealmSession> {
// update push info
pushHelper
.pushSetUser(RocketChatCache.getOrCreatePushId(context))
.continueWith(new LogcatIfError());
.continueWith(new LogIfError());
}
@DebugLog
......@@ -86,6 +86,6 @@ public class SessionObserver extends AbstractModelObserver<RealmSession> {
realm.delete(LoadMessageProcedure.class);
realm.delete(GetUsersOfRoomsProcedure.class);
return null;
}).continueWith(new LogcatIfError());
}).continueWith(new LogIfError());
}
}
......@@ -6,7 +6,7 @@ import io.realm.RealmResults;
import java.util.List;
import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.LogIfError;
import chat.rocket.persistence.realm.models.internal.RealmSession;
import chat.rocket.persistence.realm.RealmHelper;
import chat.rocket.android.service.DDPClientRef;
......@@ -37,6 +37,6 @@ public class TokenLoginObserver extends AbstractModelObserver<RealmSession> {
}
RealmSession session = results.get(0);
methodCall.loginWithToken(session.getToken()).continueWith(new LogcatIfError());
methodCall.loginWithToken(session.getToken()).continueWith(new LogIfError());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment