parent
d1dba297a7
commit
561d351b73
|
|
@ -130,14 +130,19 @@ namespace Guru
|
||||||
|
|
||||||
public static void SetCurrentScreen(string screenName, string className)
|
public static void SetCurrentScreen(string screenName, string className)
|
||||||
{
|
{
|
||||||
|
if (!_isInitOnce)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Log.I(TAG,$"SetCurrentScreen -> screenName:{screenName}, className:{className}");
|
Log.I(TAG,$"SetCurrentScreen -> screenName:{screenName}, className:{className}");
|
||||||
GuruAnalytics.Instance.SetScreen(screenName);
|
GuruAnalytics.Instance.SetScreen(screenName);
|
||||||
|
|
||||||
if (!IsReady) return;
|
TrackEvent(EventScreenView, new Dictionary<string, dynamic>()
|
||||||
FirebaseAnalytics.LogEvent(FirebaseAnalytics.EventScreenView,
|
{
|
||||||
new Parameter(FirebaseAnalytics.ParameterScreenClass, className),
|
[ParameterScreenName] = screenName,
|
||||||
new Parameter(FirebaseAnalytics.ParameterScreenName, screenName)
|
[ParameterScreenClass] = className,
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -159,15 +164,40 @@ namespace Guru
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Firebase上报用户属性
|
/// Firebase上报用户属性
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SetUserProperty(string propertyName, string propertyValue)
|
public static void SetUserProperty(string key, string value)
|
||||||
{
|
{
|
||||||
Debug.Log($"{TAG} --- SetUserProperty -> propertyName:{propertyName}, propertyValue:{propertyValue}");
|
if (!_isInitOnce)
|
||||||
|
{
|
||||||
if (!IsReady)
|
throw new Exception($"[{TAG}][SDK] Analytics did not initialized, Call <Analytics.{nameof(InitAnalytics)}()> first!");
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
if (IsDebug && !EnableDebugAnalytics)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"[{TAG}][SDK] --- SetProperty {key}:{value} can not send int Debug mode. Set <InitConfig.EnableDebugAnalytics> with `true`");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 填充相关的追踪事件
|
||||||
|
_guruEventDriver.AddProperty(key, value);
|
||||||
|
_firebaseEventDriver.AddProperty(key, value);
|
||||||
|
Debug.Log($"{TAG} --- SetUserProperty -> propertyName:{key}, propertyValue:{value}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (FirebaseUtil.IsReady)
|
||||||
|
{
|
||||||
|
Crashlytics.LogException(ex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log($"Catch Error: {ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FirebaseAnalytics.SetUserProperty(propertyName, propertyValue);
|
|
||||||
CustomSetUserProperty(propertyName, propertyValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -207,19 +237,19 @@ namespace Guru
|
||||||
// 填充相关的追踪事件
|
// 填充相关的追踪事件
|
||||||
if (eventSetting.EnableGuruAnalytics)
|
if (eventSetting.EnableGuruAnalytics)
|
||||||
{
|
{
|
||||||
_guruEventDriver.Append(new TrackingEvent(eventName, data, eventSetting, priority));
|
_guruEventDriver.AddEvent(eventName, data, eventSetting, priority);
|
||||||
}
|
}
|
||||||
if (eventSetting.EnableFirebaseAnalytics)
|
if (eventSetting.EnableFirebaseAnalytics)
|
||||||
{
|
{
|
||||||
_firebaseEventDriver.Append(new TrackingEvent(eventName, data, eventSetting, priority));
|
_firebaseEventDriver.AddEvent(eventName, data, eventSetting, priority);
|
||||||
}
|
}
|
||||||
if (eventSetting.EnableAdjustAnalytics)
|
if (eventSetting.EnableAdjustAnalytics)
|
||||||
{
|
{
|
||||||
_adjustEventDriver.Append(new TrackingEvent(eventName, data, eventSetting, priority));
|
_adjustEventDriver.AddEvent(eventName, data, eventSetting, priority);
|
||||||
}
|
}
|
||||||
if (eventSetting.EnableFacebookAnalytics)
|
if (eventSetting.EnableFacebookAnalytics)
|
||||||
{
|
{
|
||||||
_fbEventDriver.Append(new TrackingEvent(eventName, data, eventSetting, priority));
|
_fbEventDriver.AddEvent(eventName, data, eventSetting, priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -318,60 +348,9 @@ namespace Guru
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 打点缓存
|
|
||||||
|
|
||||||
private static Queue<TrackingEvent> _savedLogs;
|
|
||||||
|
|
||||||
internal static Queue<TrackingEvent> SavedLogs
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_savedLogs == null) _savedLogs = new Queue<TrackingEvent>(20);
|
|
||||||
return _savedLogs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class TrackingEvent
|
|
||||||
{
|
|
||||||
public string eventName;
|
|
||||||
public int priority;
|
|
||||||
public Dictionary<string, dynamic> data;
|
|
||||||
public Analytics.EventSetting setting;
|
|
||||||
|
|
||||||
public TrackingEvent()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 保存打点信息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="eventName"></param>
|
|
||||||
/// <param name="_data"></param>
|
|
||||||
/// <param name="_setting"></param>
|
|
||||||
/// <param name="_priority"></param>
|
|
||||||
public TrackingEvent(string eventName, Dictionary<string, dynamic> data = null, Analytics.EventSetting setting = null, int priority = -1)
|
|
||||||
{
|
|
||||||
this.eventName = eventName;
|
|
||||||
this.data = data;
|
|
||||||
this.setting = setting;
|
|
||||||
this.priority = priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Flush()
|
|
||||||
{
|
|
||||||
Analytics.TrackEvent(eventName, data, setting, priority);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return $"eventName: {eventName}, data: {data}, setting: {setting}, priority: {priority}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -16,6 +16,8 @@ namespace Guru.Network
|
||||||
private const string NETWORK_STATUS_ETHERNET = "ethernet";
|
private const string NETWORK_STATUS_ETHERNET = "ethernet";
|
||||||
private const string NETWORK_STATUS_VPN = "vpn";
|
private const string NETWORK_STATUS_VPN = "vpn";
|
||||||
private const string NETWORK_STATUS_TETHER = "tether";
|
private const string NETWORK_STATUS_TETHER = "tether";
|
||||||
|
private const string NETWORK_STATUS_BLUETOOTH = "bluetooth";
|
||||||
|
private const string NETWORK_STATUS_OTHER = "other";
|
||||||
|
|
||||||
private bool _isReady = false;
|
private bool _isReady = false;
|
||||||
|
|
||||||
|
|
@ -46,17 +48,20 @@ namespace Guru.Network
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 网络状态列表
|
||||||
|
/// </summary>
|
||||||
private List<string> _statusNameList = new List<string>()
|
private List<string> _statusNameList = new List<string>()
|
||||||
{
|
{
|
||||||
NETWORK_STATUS_NONE,
|
|
||||||
NETWORK_STATUS_ETHERNET,
|
|
||||||
NETWORK_STATUS_WIFI,
|
|
||||||
NETWORK_STATUS_MOBILE,
|
|
||||||
NETWORK_STATUS_VPN,
|
NETWORK_STATUS_VPN,
|
||||||
NETWORK_STATUS_TETHER
|
NETWORK_STATUS_TETHER,
|
||||||
|
NETWORK_STATUS_MOBILE,
|
||||||
|
NETWORK_STATUS_WIFI,
|
||||||
|
NETWORK_STATUS_ETHERNET,
|
||||||
|
NETWORK_STATUS_BLUETOOTH,
|
||||||
|
NETWORK_STATUS_OTHER,
|
||||||
|
NETWORK_STATUS_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void Init(Action<bool> onInitComplete = null)
|
public void Init(Action<bool> onInitComplete = null)
|
||||||
{
|
{
|
||||||
|
|
@ -85,7 +90,7 @@ namespace Guru.Network
|
||||||
statusName = _statusNameList[i];
|
statusName = _statusNameList[i];
|
||||||
if (status.Contains(statusName))
|
if (status.Contains(statusName))
|
||||||
{
|
{
|
||||||
Debug.Log($"{Tag} --- GetNetworkStatus : {statusName}");
|
Debug.Log($"{Tag} --- GetNetworkStatus: [{string.Join(",", status)}]");
|
||||||
return statusName;
|
return statusName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue