using Microsoft.AppCenter.Analytics; using PDF_Master.CustomControl; using System; using System.Collections.Generic; using System.Linq; using System.Security.Policy; using System.Text; using System.Threading.Tasks; namespace PDFReader_WPF.Helper { /// /// 埋点辅助类 /// TODO:路径追踪埋点 /// public static class DataTrackingHelper { /// /// 功能入口路径类型 /// public static EventType EntryPathEventType; /// /// 功能入口路径关键字 /// public static EntryPathKeyType EntryPathKey; /// /// 功能入口路径 /// public static string EntryPath = ""; /// /// 是否需要点击后BUYNOW之后清除路径 /// public static bool IsClearEntryPath = false; /// /// 触发埋点事件 /// /// /// public static void SendEvent(string name, IDictionary properties = null) { try { #if !DEBUG Analytics.TrackEvent(name, properties); #endif } catch { } } public static void SendEvent(EventType type, IDictionary properties = null) { try { #if !DEBUG Analytics.TrackEvent(type.ToString(), properties); #endif } catch { } } /// /// 适用于只上传单个键值的情况 /// /// /// /// public static void SendEvent(EventType type, string key, string value) { try { #if !DEBUG Analytics.TrackEvent(type.ToString(), new Dictionary() { [key] = value }); #else ////测试埋点路径使用 // AlertsMessage alertsMessage = new AlertsMessage(); //alertsMessage.ShowDialog("", type.ToString() + " " + key.ToString() + " " + value, "ok"); #endif } catch { } } public static void SetSendInformation(EventType type, EntryPathKeyType key) { IsClearEntryPath = false; EntryPathEventType = type; EntryPathKey = key; } public static void SendPurchaseEvent() { if (!string.IsNullOrEmpty(EntryPath) && !EntryPath.Contains("None")) { try { #if !DEBUG Analytics.TrackEvent(EntryPathEventType.ToString(), new Dictionary() { [EntryPathKey.ToString()] = EntryPath }); #else //测试付费路径使用 // AlertsMessage alertsMessage = new AlertsMessage(); //alertsMessage.ShowDialog("", EntryPathEventType.ToString()+" " + EntryPathKey.ToString() + " " + EntryPath, "ok"); #endif if (IsClearEntryPath) { EntryPath = ""; } } catch { } } } /// /// 添加最后路径 /// /// public static void AddThirdPath(ThirdPath thirdPath = ThirdPath.Subscribe) { if (!string.IsNullOrEmpty(EntryPath) && !EntryPath.Contains("None")) { if (!EntryPath.Contains("_" + thirdPath.ToString())) { EntryPath = EntryPath + "_" + thirdPath.ToString(); } } } /// /// 更新第二个路径 /// public static void UpdateSecondaryPath(SecondaryPath secondaryPath) { if (!string.IsNullOrEmpty(EntryPath)) { EntryPath = EntryPath.Replace(EntryPath.Substring(EntryPath.IndexOf("_") + 1), secondaryPath.ToString()); } } /// /// 添加第一个路径和第二个路径 /// public static void AddFirstAndSecondaryPath(FirstPath firstPath, SecondaryPath secondaryPath) { EntryPath = firstPath.ToString() + "_" + secondaryPath.ToString(); } public enum EventType { /// /// LeftSideBar /// LeftSideBar, /// /// Home /// Home, /// /// ToolBar /// Tbr, /// /// SubToolBar /// SubTbr, /// /// TopToolBar /// TopTbr, App, ActiveDialog, OnBrd, PDFView, /// /// Pop Up Window /// PUW, /// /// 编辑模块二级菜单埋点 /// SubTbr_Editor, /// /// 页面编辑子功能埋点 /// SubTbr_PageEdit, /// /// 工具子功能埋点 /// SubTbr_Tools, /// /// 注释工具条 /// SubTbr_Annotation, /// /// 编辑PDF /// SubTbr_EditPDF, /// /// 转档工具条 /// SubTbr_Converter, /// /// 编辑子工具点击采购埋点 /// Purchase_Editor, /// /// 编辑工具子工具点击采购埋点 /// Purchase_Converter, /// /// 页面编辑子工具点击采购埋点 /// Purchase_PageEdit, /// /// 编辑PDF子工具点击采购埋点 /// Purchase_EditPDF, /// /// 标记密文点击采购埋点 /// Purchase_Redact, /// /// 注释子工具点击采购埋点 /// Purchase_Tools, /// /// AI /// Purchase_AI, Purchase_Annotation } public enum EntryPathKeyType { SubTbr_Editor, Onbrd_Converter, SubTbr_Converter, SubTbr_PageEdit, Tbr_EditPDF, Tbr_Redact, Tbr_OCR, SubTbr_Tools, Home_Tools, SubTbr_Annotation } public enum FirstPath { /// /// 阅读页 /// Reading, /// /// 主页 /// Home } public enum SecondaryPath { None, Compress, Merge, BatchEncypy, RemovePassword, AddWatermark, BachAddWatermark, RemoveWatermark, AddBackground, RemoveBackground, AddHeaderFooter, AddBates, toWord, toExcel, toPPT, toText, toRTF, toCSV, toHTML, toImage, ConvertPDF, ImagetoPDF, BatchToWord, BatchToExcel, BatchToPPT, BatchToText, BatchToRTF, BatchToCSV, BatchToHtml, BatchToImage, Insert, Rotate, Delete, Extract, EditPDF, Redact, OCR, WebsiteLink, EmailLink, DynamicStamp, CustomStamp, Signature, AddImage, AITranslate, AIRewrite, AICorrect, SetPassword, Crop, EditText, EditImage, Reverse, Replace, Copy, Split, Link, Sign, Stamp } public enum ThirdPath { /// /// 点击BuyNow按钮 /// Subscribe } } }