123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- 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
- {
- /// <summary>
- /// 埋点辅助类
- /// TODO:路径追踪埋点
- /// </summary>
- public static class DataTrackingHelper
- {
- /// <summary>
- /// 功能入口路径类型
- /// </summary>
- public static EventType EntryPathEventType;
- /// <summary>
- /// 功能入口路径关键字
- /// </summary>
- public static EntryPathKeyType EntryPathKey;
- /// <summary>
- /// 功能入口路径
- /// </summary>
- public static string EntryPath = "";
- /// <summary>
- /// 是否需要点击后BUYNOW之后清除路径
- /// </summary>
- public static bool IsClearEntryPath = false;
- /// <summary>
- /// 触发埋点事件
- /// </summary>
- /// <param name="name"></param>
- /// <param name="properties"></param>
- public static void SendEvent(string name, IDictionary<string, string> properties = null)
- {
- try
- {
- #if !DEBUG
- Analytics.TrackEvent(name, properties);
- #endif
- }
- catch { }
- }
- public static void SendEvent(EventType type, IDictionary<string, string> properties = null)
- {
- try
- {
- #if !DEBUG
- Analytics.TrackEvent(type.ToString(), properties);
- #endif
- }
- catch { }
- }
- /// <summary>
- /// 适用于只上传单个键值的情况
- /// </summary>
- /// <param name="type"></param>
- /// <param name="key"></param>
- /// <param name="value"></param>
- public static void SendEvent(EventType type, string key, string value)
- {
- try
- {
- #if !DEBUG
- Analytics.TrackEvent(type.ToString(), new Dictionary<string, string>() { [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<string, string>() { [EntryPathKey.ToString()] = EntryPath });
- #else
- //测试付费路径使用
- // AlertsMessage alertsMessage = new AlertsMessage();
- //alertsMessage.ShowDialog("", EntryPathEventType.ToString()+" " + EntryPathKey.ToString() + " " + EntryPath, "ok");
- #endif
- if (IsClearEntryPath) { EntryPath = ""; }
-
- }
- catch { }
- }
- }
- /// <summary>
- /// 添加最后路径
- /// </summary>
- /// <param name="thirdPath"></param>
- public static void AddThirdPath(ThirdPath thirdPath = ThirdPath.Subscribe)
- {
- if (!string.IsNullOrEmpty(EntryPath) && !EntryPath.Contains("None"))
- {
- if (!EntryPath.Contains("_" + thirdPath.ToString()))
- {
- EntryPath = EntryPath + "_" + thirdPath.ToString();
- }
- }
- }
- /// <summary>
- /// 更新第二个路径
- /// </summary>
- public static void UpdateSecondaryPath(SecondaryPath secondaryPath)
- {
- if (!string.IsNullOrEmpty(EntryPath)) { EntryPath = EntryPath.Replace(EntryPath.Substring(EntryPath.IndexOf("_") + 1), secondaryPath.ToString()); }
- }
- /// <summary>
- /// 添加第一个路径和第二个路径
- /// </summary>
- public static void AddFirstAndSecondaryPath(FirstPath firstPath, SecondaryPath secondaryPath)
- {
- EntryPath = firstPath.ToString() + "_" + secondaryPath.ToString();
- }
- public enum EventType
- {
- /// <summary>
- /// LeftSideBar
- /// </summary>
- LeftSideBar,
- /// <summary>
- /// Home
- /// </summary>
- Home,
- /// <summary>
- /// ToolBar
- /// </summary>
- Tbr,
- /// <summary>
- /// SubToolBar
- /// </summary>
- SubTbr,
- /// <summary>
- /// TopToolBar
- /// </summary>
- TopTbr,
- App,
- ActiveDialog,
- OnBrd,
- PDFView,
- /// <summary>
- /// Pop Up Window
- /// </summary>
- PUW,
- /// <summary>
- /// 编辑模块二级菜单埋点
- /// </summary>
- SubTbr_Editor,
- /// <summary>
- /// 页面编辑子功能埋点
- /// </summary>
- SubTbr_PageEdit,
- /// <summary>
- /// 工具子功能埋点
- /// </summary>
- SubTbr_Tools,
- /// <summary>
- /// 注释工具条
- /// </summary>
- SubTbr_Annotation,
- /// <summary>
- /// 编辑PDF
- /// </summary>
- SubTbr_EditPDF,
- /// <summary>
- /// 转档工具条
- /// </summary>
- SubTbr_Converter,
- /// <summary>
- /// 编辑子工具点击采购埋点
- /// </summary>
- Purchase_Editor,
- /// <summary>
- /// 编辑工具子工具点击采购埋点
- /// </summary>
- Purchase_Converter,
- /// <summary>
- /// 页面编辑子工具点击采购埋点
- /// </summary>
- Purchase_PageEdit,
- /// <summary>
- /// 编辑PDF子工具点击采购埋点
- /// </summary>
- Purchase_EditPDF,
- /// <summary>
- /// 标记密文点击采购埋点
- /// </summary>
- Purchase_Redact,
- /// <summary>
- /// 注释子工具点击采购埋点
- /// </summary>
- Purchase_Tools,
- /// <summary>
- /// AI
- /// </summary>
- 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
- {
- /// <summary>
- /// 阅读页
- /// </summary>
- Reading,
- /// <summary>
- /// 主页
- /// </summary>
- 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
- {
- /// <summary>
- /// 点击BuyNow按钮
- /// </summary>
- Subscribe
- }
- }
- }
|