update: 更新 SDK 添加优先级设置接口
--story=1020598 --user=yufei.hu 【中台】【BI】升级自打点插件至 1.12.0, Native 接口添加 priority 参数和功能 https://www.tapd.cn/33527076/s/1151108dev
parent
67000cbc63
commit
5306922cca
|
|
@ -33,6 +33,9 @@ namespace Guru
|
||||||
public bool no_ads = false;
|
public bool no_ads = false;
|
||||||
|
|
||||||
public List<PurchasedProduct> purchased;
|
public List<PurchasedProduct> purchased;
|
||||||
|
|
||||||
|
public Dictionary<string, int> event_priorities;
|
||||||
|
|
||||||
//-------------- data ---------------
|
//-------------- data ---------------
|
||||||
|
|
||||||
private float _lastSavedTime = 0;
|
private float _lastSavedTime = 0;
|
||||||
|
|
@ -153,11 +156,12 @@ namespace Guru
|
||||||
|
|
||||||
public void InitProperties()
|
public void InitProperties()
|
||||||
{
|
{
|
||||||
if(_successLevel == null) _successLevel = new BindableProperty<int>(b_level, OnLevelChanged);
|
if (_successLevel == null) _successLevel = new BindableProperty<int>(b_level, OnLevelChanged);
|
||||||
if(_totalPlayed == null) _totalPlayed = new BindableProperty<int>(b_play, OnPlayedChanged);
|
if (_totalPlayed == null) _totalPlayed = new BindableProperty<int>(b_play, OnPlayedChanged);
|
||||||
if(_purchasedCount == null) _purchasedCount = new BindableProperty<int>(buy_count, OnPurchasedNumChanged);
|
if (_purchasedCount == null) _purchasedCount = new BindableProperty<int>(buy_count, OnPurchasedNumChanged);
|
||||||
if(_uid == null) _uid = new BindableProperty<string>(uid, OnUidChanged);
|
if (_uid == null) _uid = new BindableProperty<string>(uid, OnUidChanged);
|
||||||
if(purchased == null) purchased = new List<PurchasedProduct>(20);
|
if (purchased == null) purchased = new List<PurchasedProduct>(20);
|
||||||
|
if (event_priorities == null) event_priorities = new Dictionary<string, int>(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -30,19 +30,24 @@ namespace Guru
|
||||||
public const string EventLevelEndTimeout = "timeout";
|
public const string EventLevelEndTimeout = "timeout";
|
||||||
|
|
||||||
#region 通用接口
|
#region 通用接口
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义事件打点
|
/// 自定义事件打点
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="eventName"></param>
|
/// <param name="eventName"></param>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
public static void LogEvent(string eventName, Dictionary<string, dynamic> data = null)
|
/// <param name="priority"></param>
|
||||||
|
public static void LogEvent(string eventName, Dictionary<string, dynamic> data = null, int priority = -1)
|
||||||
{
|
{
|
||||||
if (!IsInitialSuccess)
|
if (!IsInitialSuccess)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError($"{Tag} :: LogEvent {eventName} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
|
UnityEngine.Debug.LogError($"{Tag} :: LogEvent {eventName} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
|
||||||
return;
|
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 = "")
|
public static void SetScreen(string screen, string extra = "")
|
||||||
|
|
@ -1225,5 +1230,64 @@ namespace Guru
|
||||||
CrashlyticsAgent.SetCustomKey(key, value);
|
CrashlyticsAgent.SetCustomKey(key, value);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 优先级设置
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="priority"></param>
|
||||||
|
/// <param name="eventNames"></param>
|
||||||
|
public static void SetEventPriority(EventPriority priority, string[] eventNames)
|
||||||
|
{
|
||||||
|
if (!IsInitialSuccess)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogError($"{Tag} :: LogEvent {priority} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_model.event_priorities == null) _model.event_priorities = new Dictionary<string, int>(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 <GuruSDK.Start()> first, before you call <LogEvent>.");
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,17 @@ namespace Guru
|
||||||
{
|
{
|
||||||
public partial class GuruSDK
|
public partial class GuruSDK
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 打点优先级
|
||||||
|
/// </summary>
|
||||||
|
public enum EventPriority
|
||||||
|
{
|
||||||
|
Emergence = 0,
|
||||||
|
High = 5,
|
||||||
|
Default = 10,
|
||||||
|
Low = 15
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Consts values
|
/// Consts values
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -254,8 +265,6 @@ namespace Guru
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue