DataTrackingHelper.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. using Microsoft.AppCenter.Analytics;
  2. using PDF_Master.CustomControl;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Security.Policy;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace PDFReader_WPF.Helper
  10. {
  11. /// <summary>
  12. /// 埋点辅助类
  13. /// TODO:路径追踪埋点
  14. /// </summary>
  15. public static class DataTrackingHelper
  16. {
  17. /// <summary>
  18. /// 功能入口路径类型
  19. /// </summary>
  20. public static EventType EntryPathEventType;
  21. /// <summary>
  22. /// 功能入口路径关键字
  23. /// </summary>
  24. public static EntryPathKeyType EntryPathKey;
  25. /// <summary>
  26. /// 功能入口路径
  27. /// </summary>
  28. public static string EntryPath = "";
  29. /// <summary>
  30. /// 是否需要点击后BUYNOW之后清除路径
  31. /// </summary>
  32. public static bool IsClearEntryPath = false;
  33. /// <summary>
  34. /// 触发埋点事件
  35. /// </summary>
  36. /// <param name="name"></param>
  37. /// <param name="properties"></param>
  38. public static void SendEvent(string name, IDictionary<string, string> properties = null)
  39. {
  40. try
  41. {
  42. #if !DEBUG
  43. Analytics.TrackEvent(name, properties);
  44. #endif
  45. }
  46. catch { }
  47. }
  48. public static void SendEvent(EventType type, IDictionary<string, string> properties = null)
  49. {
  50. try
  51. {
  52. #if !DEBUG
  53. Analytics.TrackEvent(type.ToString(), properties);
  54. #endif
  55. }
  56. catch { }
  57. }
  58. /// <summary>
  59. /// 适用于只上传单个键值的情况
  60. /// </summary>
  61. /// <param name="type"></param>
  62. /// <param name="key"></param>
  63. /// <param name="value"></param>
  64. public static void SendEvent(EventType type, string key, string value)
  65. {
  66. try
  67. {
  68. #if !DEBUG
  69. Analytics.TrackEvent(type.ToString(), new Dictionary<string, string>() { [key] = value });
  70. #endif
  71. }
  72. catch { }
  73. }
  74. public static void SetSendInformation(EventType type, EntryPathKeyType key)
  75. {
  76. IsClearEntryPath = false;
  77. EntryPathEventType = type;
  78. EntryPathKey = key;
  79. }
  80. public static void SendPurchaseEvent()
  81. {
  82. if (!string.IsNullOrEmpty(EntryPath) && !EntryPath.Contains("None"))
  83. {
  84. try
  85. {
  86. #if !DEBUG
  87. Analytics.TrackEvent(EntryPathEventType.ToString(), new Dictionary<string, string>() { [EntryPathKey.ToString()] = EntryPath });
  88. #else
  89. //测试付费路径使用
  90. // AlertsMessage alertsMessage = new AlertsMessage();
  91. //alertsMessage.ShowDialog("", EntryPathEventType.ToString()+" " + EntryPathKey.ToString() + " " + EntryPath, "ok");
  92. #endif
  93. if (IsClearEntryPath) { EntryPath = ""; }
  94. }
  95. catch { }
  96. }
  97. }
  98. /// <summary>
  99. /// 添加最后路径
  100. /// </summary>
  101. /// <param name="thirdPath"></param>
  102. public static void AddThirdPath(ThirdPath thirdPath = ThirdPath.Subscribe)
  103. {
  104. if (!string.IsNullOrEmpty(EntryPath) && !EntryPath.Contains("None"))
  105. {
  106. if (!EntryPath.Contains("_" + thirdPath.ToString()))
  107. {
  108. EntryPath = EntryPath + "_" + thirdPath.ToString();
  109. }
  110. }
  111. }
  112. /// <summary>
  113. /// 更新第二个路径
  114. /// </summary>
  115. public static void UpdateSecondaryPath(SecondaryPath secondaryPath)
  116. {
  117. if (!string.IsNullOrEmpty(EntryPath)) { EntryPath = EntryPath.Replace(EntryPath.Substring(EntryPath.IndexOf("_") + 1), secondaryPath.ToString()); }
  118. }
  119. /// <summary>
  120. /// 添加第一个路径和第二个路径
  121. /// </summary>
  122. public static void AddFirstAndSecondaryPath(FirstPath firstPath, SecondaryPath secondaryPath)
  123. {
  124. EntryPath = firstPath.ToString() + "_" + secondaryPath.ToString();
  125. }
  126. public enum EventType
  127. {
  128. /// <summary>
  129. /// LeftSideBar
  130. /// </summary>
  131. LeftSideBar,
  132. /// <summary>
  133. /// Home
  134. /// </summary>
  135. Home,
  136. /// <summary>
  137. /// ToolBar
  138. /// </summary>
  139. Tbr,
  140. /// <summary>
  141. /// SubToolBar
  142. /// </summary>
  143. SubTbr,
  144. /// <summary>
  145. /// TopToolBar
  146. /// </summary>
  147. TopTbr,
  148. App,
  149. ActiveDialog,
  150. OnBrd,
  151. PDFView,
  152. /// <summary>
  153. /// Pop Up Window
  154. /// </summary>
  155. PUW,
  156. /// <summary>
  157. /// 编辑模块二级菜单埋点
  158. /// </summary>
  159. SubTbr_Editor,
  160. /// <summary>
  161. /// 页面编辑子功能埋点
  162. /// </summary>
  163. SubTbr_PageEdit,
  164. /// <summary>
  165. /// 工具子功能埋点
  166. /// </summary>
  167. SubTbr_Tools,
  168. /// <summary>
  169. /// 注释工具条
  170. /// </summary>
  171. SubTbr_Annotation,
  172. /// <summary>
  173. /// 编辑PDF
  174. /// </summary>
  175. SubTbr_EditPDF,
  176. /// <summary>
  177. /// 转档工具条
  178. /// </summary>
  179. SubTbr_Converter,
  180. /// <summary>
  181. /// 编辑子工具点击采购埋点
  182. /// </summary>
  183. Purchase_Editor,
  184. /// <summary>
  185. /// 编辑工具子工具点击采购埋点
  186. /// </summary>
  187. Purchase_Converter,
  188. /// <summary>
  189. /// 页面编辑子工具点击采购埋点
  190. /// </summary>
  191. Purchase_PageEdit,
  192. /// <summary>
  193. /// 编辑PDF子工具点击采购埋点
  194. /// </summary>
  195. Purchase_EditPDF,
  196. /// <summary>
  197. /// 标记密文点击采购埋点
  198. /// </summary>
  199. Purchase_Redact,
  200. /// <summary>
  201. /// 注释子工具点击采购埋点
  202. /// </summary>
  203. Purchase_Tools,
  204. /// <summary>
  205. /// AI
  206. /// </summary>
  207. Purchase_AI,
  208. Purchase_Annotation
  209. }
  210. public enum EntryPathKeyType
  211. {
  212. SubTbr_Editor,
  213. Onbrd_Converter,
  214. SubTbr_Converter,
  215. SubTbr_PageEdit,
  216. Tbr_EditPDF,
  217. Tbr_Redact,
  218. Tbr_OCR,
  219. SubTbr_Tools,
  220. Home_Tools,
  221. SubTbr_Annotation
  222. }
  223. public enum FirstPath
  224. {
  225. /// <summary>
  226. /// 阅读页
  227. /// </summary>
  228. Reading,
  229. /// <summary>
  230. /// 主页
  231. /// </summary>
  232. Home
  233. }
  234. public enum SecondaryPath
  235. {
  236. None,
  237. Compress,
  238. Merge,
  239. BatchEncypy,
  240. RemovePassword,
  241. AddWatermark,
  242. BachAddWatermark,
  243. RemoveWatermark,
  244. AddBackground,
  245. RemoveBackground,
  246. AddHeaderFooter,
  247. AddBates,
  248. toWord,
  249. toExcel,
  250. toPPT,
  251. toText,
  252. toRTF,
  253. toCSV,
  254. toHTML,
  255. toImage,
  256. ConvertPDF,
  257. ImagetoPDF,
  258. BatchToWord,
  259. BatchToExcel,
  260. BatchToPPT,
  261. BatchToText,
  262. BatchToRTF,
  263. BatchToCSV,
  264. BatchToHtml,
  265. BatchToImage,
  266. Insert,
  267. Rotate,
  268. Delete,
  269. Extract,
  270. EditPDF,
  271. Redact,
  272. OCR,
  273. WebsiteLink,
  274. EmailLink,
  275. DynamicStamp,
  276. CustomStamp,
  277. Signature,
  278. AddImage,
  279. AITranslate,
  280. AIRewrite,
  281. AICorrect,
  282. SetPassword,
  283. Crop,
  284. EditText,
  285. EditImage,
  286. Reverse,
  287. Replace,
  288. Copy,
  289. Split,
  290. Link,
  291. Sign,
  292. Stamp
  293. }
  294. public enum ThirdPath
  295. {
  296. /// <summary>
  297. /// 点击BuyNow按钮
  298. /// </summary>
  299. Subscribe
  300. }
  301. }
  302. }