update: 更新CrashlyticsAgent 的接口

Signed-off-by: huyufei <yufei.hu@castbox.fm>
胡宇飞 2024-08-11 15:03:19 +08:00
parent 2760cb5fb2
commit 9c6f2cf962
1 changed files with 13 additions and 8 deletions

View File

@ -10,13 +10,11 @@ namespace Guru
{
private static bool _initOnce;
private static bool IsFirebaseReady => FirebaseUtil.IsFirebaseInitialized;
private static bool _hasSetUser = false;
/// <summary>
/// 捕获列表
/// </summary>
private static List<LogType> _catchFilter = new List<LogType>()
private static readonly List<LogType> _catchFilter = new List<LogType>()
{
LogType.Exception,
};
@ -24,7 +22,7 @@ namespace Guru
/// <summary>
/// 上报列表
/// </summary>
private static List<LogType> _logFilter = new List<LogType>()
private static readonly List<LogType> _logFilter = new List<LogType>()
{
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);
}
}
}