From 5306922cca02513887556674ef4ae676a8f89a0a Mon Sep 17 00:00:00 2001 From: huyufei Date: Tue, 18 Jun 2024 10:14:33 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=20SDK=20=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BC=98=E5=85=88=E7=BA=A7=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1020598 --user=yufei.hu 【中台】【BI】升级自打点插件至 1.12.0, Native 接口添加 priority 参数和功能 https://www.tapd.cn/33527076/s/1151108 --- Runtime/Code/Model/GuruSDKModel.cs | 14 ++++-- Runtime/Code/SDK/GuruSDK.Analytics.cs | 68 ++++++++++++++++++++++++++- Runtime/Code/SDK/GuruSDK.Const.cs | 13 ++++- 3 files changed, 86 insertions(+), 9 deletions(-) diff --git a/Runtime/Code/Model/GuruSDKModel.cs b/Runtime/Code/Model/GuruSDKModel.cs index c41007f..0298f58 100644 --- a/Runtime/Code/Model/GuruSDKModel.cs +++ b/Runtime/Code/Model/GuruSDKModel.cs @@ -33,6 +33,9 @@ namespace Guru public bool no_ads = false; public List purchased; + + public Dictionary event_priorities; + //-------------- data --------------- private float _lastSavedTime = 0; @@ -153,11 +156,12 @@ namespace Guru public void InitProperties() { - if(_successLevel == null) _successLevel = new BindableProperty(b_level, OnLevelChanged); - if(_totalPlayed == null) _totalPlayed = new BindableProperty(b_play, OnPlayedChanged); - if(_purchasedCount == null) _purchasedCount = new BindableProperty(buy_count, OnPurchasedNumChanged); - if(_uid == null) _uid = new BindableProperty(uid, OnUidChanged); - if(purchased == null) purchased = new List(20); + if (_successLevel == null) _successLevel = new BindableProperty(b_level, OnLevelChanged); + if (_totalPlayed == null) _totalPlayed = new BindableProperty(b_play, OnPlayedChanged); + if (_purchasedCount == null) _purchasedCount = new BindableProperty(buy_count, OnPurchasedNumChanged); + if (_uid == null) _uid = new BindableProperty(uid, OnUidChanged); + if (purchased == null) purchased = new List(20); + if (event_priorities == null) event_priorities = new Dictionary(10); } /// diff --git a/Runtime/Code/SDK/GuruSDK.Analytics.cs b/Runtime/Code/SDK/GuruSDK.Analytics.cs index a9c520f..8449cff 100644 --- a/Runtime/Code/SDK/GuruSDK.Analytics.cs +++ b/Runtime/Code/SDK/GuruSDK.Analytics.cs @@ -30,19 +30,24 @@ namespace Guru public const string EventLevelEndTimeout = "timeout"; #region 通用接口 + /// /// 自定义事件打点 /// /// /// - public static void LogEvent(string eventName, Dictionary data = null) + /// + public static void LogEvent(string eventName, Dictionary data = null, int priority = -1) { if (!IsInitialSuccess) { UnityEngine.Debug.LogError($"{Tag} :: LogEvent {eventName} :: Please call first, before you call ."); return; } - Analytics.Track(eventName, data); + + if(priority < 0) priority = GetEventPriorityInt(eventName); + + Analytics.Track(eventName, data, null, priority); } public static void SetScreen(string screen, string extra = "") @@ -1225,5 +1230,64 @@ namespace Guru CrashlyticsAgent.SetCustomKey(key, value); } #endregion + + #region 优先级设置 + + + /// + /// 设置 + /// + /// + /// + public static void SetEventPriority(EventPriority priority, string[] eventNames) + { + if (!IsInitialSuccess) + { + UnityEngine.Debug.LogError($"{Tag} :: LogEvent {priority} :: Please call first, before you call ."); + return; + } + + if (_model.event_priorities == null) _model.event_priorities = new Dictionary(10); + + int i = 0; + string evt = ""; + while (i < eventNames.Length) + { + evt = eventNames[i]; + if (!string.IsNullOrEmpty(evt)) + { + _model.event_priorities[evt] = (int)priority; + } + i++; + } + } + + public static void SetEventPriority(EventPriority priority, string eventName) + { + if (!IsInitialSuccess) + { + UnityEngine.Debug.LogError($"{Tag} :: LogEvent {priority} :: Please call first, before you call ."); + return; + } + + SetEventPriority(priority, new string[]{eventName}); + } + + public static EventPriority GetEventPriority(string eventName) + { + if (_model.event_priorities != null + && _model.event_priorities.TryGetValue(eventName, out int p)) + { + return (EventPriority)p; + } + return EventPriority.Default; + } + + internal static int GetEventPriorityInt(string eventName) + { + return (int)GetEventPriority(eventName); + } + + #endregion } } \ No newline at end of file diff --git a/Runtime/Code/SDK/GuruSDK.Const.cs b/Runtime/Code/SDK/GuruSDK.Const.cs index cf36410..54e34a7 100644 --- a/Runtime/Code/SDK/GuruSDK.Const.cs +++ b/Runtime/Code/SDK/GuruSDK.Const.cs @@ -2,6 +2,17 @@ namespace Guru { public partial class GuruSDK { + /// + /// 打点优先级 + /// + public enum EventPriority + { + Emergence = 0, + High = 5, + Default = 10, + Low = 15 + } + /// /// Consts values /// @@ -254,8 +265,6 @@ namespace Guru #endregion - - } }