From 9c6f2cf9623cd43cca780d88b526ea680340c82e Mon Sep 17 00:00:00 2001 From: huyufei Date: Sun, 11 Aug 2024 15:03:19 +0800 Subject: [PATCH] =?UTF-8?q?update=EF=BC=9A=20=E6=9B=B4=E6=96=B0Crashlytics?= =?UTF-8?q?Agent=20=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyufei --- .../Runtime/Reporter/CrashlyticsAgent.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) 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