update: 重构 networkstatus 方法和规范值

release/V1.1.0
胡宇飞 2024-08-01 00:17:01 +08:00
parent 48c5235335
commit fd01939a5f
3 changed files with 23 additions and 33 deletions

View File

@ -1,8 +1,9 @@
using System;
using System.Collections.Generic;
namespace Guru
{
using System;
using UnityEngine.Serialization;
[Serializable]
public class GuruServicesConfig
@ -61,7 +62,7 @@ namespace Guru
public string DMAMapRule() => parameters?.dma_map_rule ?? "";
public bool UseUUID() => parameters?.using_uuid ?? false;
public bool KeywordsEnabled() => parameters?.enable_keywords ?? false;
public int TokenValidTime() => parameters?.token_vaild_time ?? 604800;
public int TokenValidTime() => parameters?.token_valid_time ?? 604800;
public int LevelEndSuccessNum() => parameters?.level_end_success_num ?? 50;
public string CdnHost() => parameters?.cdn_host ?? "";
public bool UsingUUID() => parameters?.using_uuid ?? true;
@ -91,7 +92,7 @@ namespace Guru
[Serializable]
public class GuruParameters
{
public int token_vaild_time = 604800;
public int token_valid_time = 604800;
public int level_end_success_num = 50;
public bool enable_keywords = false;
public double tch_020 = 0;

View File

@ -21,14 +21,7 @@ namespace Guru
/// <param name="priority"></param>
public static void LogEvent(string eventName, Dictionary<string, dynamic> data = null, int priority = -1)
{
// if (!IsInitialSuccess)
// {
// UnityEngine.Debug.LogError($"{Tag} :: LogEvent {eventName} :: Please call <GuruSDK.Start()> first, before you call <LogEvent>.");
// return;
// }
if(priority < 0) priority = GetEventPriorityInt(eventName);
Analytics.Track(eventName, data, null, priority);
}

View File

@ -344,7 +344,6 @@ namespace Guru
#endif
LogI($"#5 --- sync sdk time ---");
// TODO: 本调用放在这里不合适, 应该和 Firebase 解耦
LogSDKInitTime((DateTime.Now.ToUniversalTime() - _initTime).TotalSeconds);
}
@ -687,24 +686,30 @@ namespace Guru
private NetworkStatusMonitor _networkStatusMonitor;
private string _networkStatus;
private string _lastNetworkStatus;
private void InitNetworkMonitor()
{
// SetUserProperty(Consts.PropertyNetwork, GetNetworkStatus());
// TODO: 下个版本加入真正的自动更新网络状态的实现
}
private string GetNetworkStatus()
{
if(_networkStatusMonitor == null)
_networkStatusMonitor = new NetworkStatusMonitor(status =>
{
_networkStatusMonitor = new NetworkStatusMonitor();
}
return _networkStatusMonitor.GetNetworkStatus();
SetUserProperty(Consts.PropertyNetwork, status);
}, lastStatus =>
{
LogEvent("guru_offline", new Dictionary<string, dynamic>()
{
["from"] = lastStatus
});
});
}
/// <summary>
/// 获取当前的网络状态
/// </summary>
/// <returns></returns>
private string GetNetworkStatus() => _networkStatusMonitor.GetNetworkStatus();
#endregion
#region Firebase 服务
@ -735,9 +740,6 @@ namespace Guru
SetUID(UID);
}
}
private void OnGetFirebaseId(string fid)
{
@ -824,13 +826,7 @@ namespace Guru
SetUserProperty("adjust_id", adjustId);
Debug.Log($"[SDK] --- Firebase + Adjust ID: {adjustId}");
}
#endregion
}
}