diff --git a/RevokeMsgPatcher/FormMain.cs b/RevokeMsgPatcher/FormMain.cs index 1dad97d..db039c9 100644 --- a/RevokeMsgPatcher/FormMain.cs +++ b/RevokeMsgPatcher/FormMain.cs @@ -26,7 +26,7 @@ namespace RevokeMsgPatcher private bool needUpdate = false; private string getPatchJsonStatus = "GETTING"; // GETTING FAIL SUCCESS - private GAHelper ga = new GAHelper(); // Google Analytics 记录 + private readonly GAHelper ga = GAHelper.Instance; // Google Analytics 记录 public void InitModifier() { diff --git a/RevokeMsgPatcher/Utils/GAHelper.cs b/RevokeMsgPatcher/Utils/GAHelper.cs index fa8fd79..81ce3a1 100644 --- a/RevokeMsgPatcher/Utils/GAHelper.cs +++ b/RevokeMsgPatcher/Utils/GAHelper.cs @@ -17,6 +17,24 @@ namespace RevokeMsgPatcher.Utils /// public class GAHelper { + private static GAHelper instance = null; + private static readonly object obj = new object(); + + public static GAHelper Instance + { + get + { + lock (obj) + { + if (instance == null) + { + instance = new GAHelper(); + } + return instance; + } + } + } + // 根据实际情况修改 private static readonly HttpClient client = HttpUtil.Client; diff --git a/RevokeMsgPatcher/Utils/HttpUtil.cs b/RevokeMsgPatcher/Utils/HttpUtil.cs index 08e2ca3..df11aa2 100644 --- a/RevokeMsgPatcher/Utils/HttpUtil.cs +++ b/RevokeMsgPatcher/Utils/HttpUtil.cs @@ -39,6 +39,7 @@ namespace RevokeMsgPatcher.Utils catch (Exception ex) { Console.WriteLine("第" + (i + 1) + "次请求异常:[" + ex.Message + "]\nURL:" + urls[i]); + GAHelper.Instance.RequestPageView($"/main/json/request_ex/{i + 1}/{ex.Message}", "第" + (i + 1) + "次请求异常:[" + ex.Message + "]"); i++; if (i >= urls.Length) {