From 53fbda1f53153673885877835aaa978f7f3f04ed Mon Sep 17 00:00:00 2001 From: huiyadanli Date: Sun, 6 Jun 2021 15:38:22 +0800 Subject: [PATCH] =?UTF-8?q?[+]=20=E6=B7=BB=E5=8A=A0=E5=AF=B9=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E8=A1=A5=E4=B8=81=E8=8E=B7=E5=8F=96=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=E8=B7=9F=E8=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RevokeMsgPatcher/FormMain.cs | 2 +- RevokeMsgPatcher/Utils/GAHelper.cs | 18 ++++++++++++++++++ RevokeMsgPatcher/Utils/HttpUtil.cs | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) 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) {