|
|
@@ -1041,82 +1041,7 @@ public static class TalkingDataSDK
|
|
|
#endif
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 手动报告错误
|
|
|
- /// </summary>
|
|
|
- public static void OnError(string message, string stackTrace, LogType logType)
|
|
|
- {
|
|
|
- if (talkingdataClass == null)
|
|
|
- return;
|
|
|
- if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
|
|
- {
|
|
|
-#if UNITY_ANDROID
|
|
|
- if (talkingdataClass != null)
|
|
|
- {
|
|
|
- string exceptionMessage = $"{logType}: {message}\n{stackTrace}";
|
|
|
- // 将 Exception 改为 Throwable
|
|
|
- using (AndroidJavaObject javaThrowable = new AndroidJavaObject("java.lang.Throwable", exceptionMessage))
|
|
|
- {
|
|
|
- talkingdataClass.CallStatic("onError", GetCurrentActivity(), javaThrowable);
|
|
|
- }
|
|
|
- }
|
|
|
-#endif
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 手动报告异常
|
|
|
- /// </summary>
|
|
|
- public static void ReportException(System.Exception exception)
|
|
|
- {
|
|
|
- if (talkingdataClass == null)
|
|
|
- {
|
|
|
- talkingdataClass = new AndroidJavaClass(TALKINGDATA_CLASS);
|
|
|
- }
|
|
|
-
|
|
|
- if (Application.platform != RuntimePlatform.OSXEditor && Application.platform != RuntimePlatform.WindowsEditor)
|
|
|
- {
|
|
|
-#if UNITY_ANDROID
|
|
|
- try
|
|
|
- {
|
|
|
- // 将 Exception 改为 Throwable
|
|
|
- using (AndroidJavaObject javaThrowable = new AndroidJavaObject("java.lang.Throwable",
|
|
|
- $"{exception.Message}\n{exception.StackTrace}"))
|
|
|
- {
|
|
|
- talkingdataClass.CallStatic("onError", GetCurrentActivity(), javaThrowable);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (System.Exception e)
|
|
|
- {
|
|
|
- Debug.LogError("报告异常到TalkingData失败: " + e.Message);
|
|
|
- }
|
|
|
-#endif
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 设置是否自动捕获未处理异常
|
|
|
- /// </summary>
|
|
|
- /// <param name="enabled">true:开启, false:关闭</param>
|
|
|
- public static void SetReportUncaughtExceptions(bool enabled)
|
|
|
- {
|
|
|
- if (talkingdataClass == null)
|
|
|
- {
|
|
|
- talkingdataClass = new AndroidJavaClass(TALKINGDATA_CLASS);
|
|
|
- }
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- talkingdataClass.CallStatic("setReportUncaughtExceptions", enabled);
|
|
|
- Debug.Log($"TalkingData自动异常捕获: {(enabled ? "开启" : "关闭")}");
|
|
|
- }
|
|
|
- catch (System.Exception e)
|
|
|
- {
|
|
|
- Debug.LogError("设置TalkingData自动异常捕获失败: " + e.Message);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
public static void SetGlobalKV(string key, object val)
|
|
|
{
|