diff --git a/Runtime/GuruCore/Runtime/Reporter/CrashlyticsAgent.cs b/Runtime/GuruCore/Runtime/Reporter/CrashlyticsAgent.cs index 7c51f0e..0a62dee 100644 --- a/Runtime/GuruCore/Runtime/Reporter/CrashlyticsAgent.cs +++ b/Runtime/GuruCore/Runtime/Reporter/CrashlyticsAgent.cs @@ -10,13 +10,11 @@ namespace Guru { private static bool _initOnce; private static bool IsFirebaseReady => FirebaseUtil.IsFirebaseInitialized; - - private static bool _hasSetUser = false; /// /// 捕获列表 /// - private static List _catchFilter = new List() + private static readonly List _catchFilter = new List() { LogType.Exception, }; @@ -24,7 +22,7 @@ namespace Guru /// /// 上报列表 /// - private static List _logFilter = new List() + private static readonly List _logFilter = new List() { LogType.Exception, LogType.Error, @@ -36,14 +34,17 @@ namespace Guru if (_initOnce) return; _initOnce = true; + // 接受主线程的 Message Application.logMessageReceived -= OnReceivedMessage; Application.logMessageReceived += OnReceivedMessage; + // 接受其他线程的 Message + // Application.logMessageReceivedThreaded -= OnReceivedMessage; + // Application.logMessageReceivedThreaded += OnReceivedMessage; + Crashlytics.IsCrashlyticsCollectionEnabled = true; } - - - + private static string ToLogTypeString(LogType type) { switch (type) @@ -99,6 +100,10 @@ namespace Guru Crashlytics.SetCustomKey(key, value); } - + public static void SetUserId(string uid) + { + if (!IsFirebaseReady) return; + Crashlytics.SetUserId(uid); + } } } \ No newline at end of file