151 lines
4.4 KiB
C#
151 lines
4.4 KiB
C#
using System.Text;
|
|
using UnityEngine;
|
|
|
|
namespace Guru
|
|
{
|
|
public class AnalyticsAgentStub: IAnalyticsAgent
|
|
{
|
|
|
|
public static readonly string TAG = "[EDT]";
|
|
|
|
private bool _isShowLog = false;
|
|
private bool _isDebug = false;
|
|
|
|
private bool _enableErrorLog;
|
|
|
|
public bool EnableErrorLog
|
|
{
|
|
get => _enableErrorLog;
|
|
set
|
|
{
|
|
Debug.Log($"{TAG} EnableErrorLog:<color=orange>{value}</color>");
|
|
_enableErrorLog = value;
|
|
}
|
|
|
|
}
|
|
|
|
public void Init(string appId, string deviceInfo, bool isDebug = false)
|
|
{
|
|
#if UNITY_EDITOR
|
|
_isShowLog = true;
|
|
#endif
|
|
_isDebug = isDebug;
|
|
if(_isShowLog)
|
|
Debug.Log($"{TAG} init with Debug: <color=orange>{isDebug}</color> appId:{appId} deviceInfo:{deviceInfo}");
|
|
}
|
|
|
|
|
|
public void InitCallback(string objName, string method)
|
|
{
|
|
if(_isShowLog)
|
|
Debug.Log($"{TAG} InitCallback: <color=orange>object:{objName} method:{method}</color>");
|
|
}
|
|
|
|
|
|
public void SetScreen(string screenName)
|
|
{
|
|
if(_isShowLog)
|
|
Debug.Log($"{TAG} SetScreen: <color=orange>{screenName}</color>");
|
|
}
|
|
|
|
public void SetAdId(string id)
|
|
{
|
|
if(_isShowLog)
|
|
Debug.Log($"{TAG} SetAdId: <color=orange>{id}</color>");
|
|
}
|
|
|
|
public void SetUserProperty(string key, string value)
|
|
{
|
|
if(_isShowLog)
|
|
Debug.Log($"{TAG} SetUserProperty: <color=orange>{key} : {value}</color>");
|
|
}
|
|
|
|
public void SetFirebaseId(string id)
|
|
{
|
|
if(_isShowLog)
|
|
Debug.Log($"{TAG} SetFirebaseId: <color=orange>{id}</color>");
|
|
}
|
|
|
|
public void SetAdjustId(string id)
|
|
{
|
|
if(_isShowLog)
|
|
Debug.Log($"{TAG} SetAdjustId: <color=orange>{id}</color>");
|
|
}
|
|
|
|
public void SetDeviceId(string deviceId)
|
|
{
|
|
if(_isShowLog)
|
|
Debug.Log($"{TAG} SetDeviceId: <color=orange>{deviceId}</color>");
|
|
}
|
|
|
|
public void SetUid(string uid)
|
|
{
|
|
if(_isShowLog)
|
|
Debug.Log($"{TAG} SetUid: <color=orange>{uid}</color>");
|
|
}
|
|
|
|
public bool IsDebug => _isDebug;
|
|
|
|
|
|
public void LogEvent(string eventName, string parameters)
|
|
{
|
|
if (_isShowLog)
|
|
{
|
|
var raw = parameters.Split(',');
|
|
if (raw.Length > 0)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
for (int i = 0; i < raw.Length; i++)
|
|
{
|
|
var ss = raw[i];
|
|
if(string.IsNullOrEmpty(ss)) continue;
|
|
|
|
var p = ss.Split(':');
|
|
if (p.Length > 1)
|
|
{
|
|
|
|
var key = p[0];
|
|
var t = p[1].Substring(0, 1);
|
|
var v = p[1].Substring(1, p[1].Length - 1);
|
|
|
|
|
|
// 字符串解析
|
|
switch(t){
|
|
case "i":
|
|
sb.Append($"<color=orange>{key} : [int]{v}</color>\n");
|
|
break;
|
|
case "d":
|
|
sb.Append($"<color=orange>{key} : [double]{v}</color>\n");
|
|
break;
|
|
default:
|
|
sb.Append($"<color=orange>{key} : [string]{v}</color>\n");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
Debug.Log($"{TAG} LogEvent: event:<color=orange>{eventName}</color> Properties:\n{sb.ToString()}");
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ReportEventSuccessRate()
|
|
{
|
|
Debug.Log($"{TAG} Log Event Success Rate");
|
|
}
|
|
|
|
public void SetTch02Value(double value)
|
|
{
|
|
Debug.Log($"{TAG} Tch02MaxValue: {value}");
|
|
}
|
|
|
|
|
|
#region Editor Test API
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |