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; 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: {isDebug} appId:{appId} deviceInfo:{deviceInfo}"); } public void SetScreen(string screenName) { if(_isShowLog) Debug.Log($"{TAG} SetScreen: {screenName}"); } public void SetAdId(string id) { if(_isShowLog) Debug.Log($"{TAG} SetAdId: {id}"); } public void SetUserProperty(string key, string value) { if(_isShowLog) Debug.Log($"{TAG} SetUserProperty: {key} : {value}"); } public void SetFirebaseId(string id) { if(_isShowLog) Debug.Log($"{TAG} SetFirebaseId: {id}"); } public void SetAdjustId(string id) { if(_isShowLog) Debug.Log($"{TAG} SetAdjustId: {id}"); } public void SetDeviceId(string deviceId) { if(_isShowLog) Debug.Log($"{TAG} SetDeviceId: {deviceId}"); } public void SetUid(string uid) { if(_isShowLog) Debug.Log($"{TAG} SetUid: {uid}"); } 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($"{key} : [int]{v}\n"); break; case "d": sb.Append($"{key} : [double]{v}\n"); break; default: sb.Append($"{key} : [string]{v}\n"); break; } } } Debug.Log($"{TAG} LogEvent: event:{eventName} Properties:\n{sb.ToString()}"); } } } public void ReportEventSuccessRate() { Debug.Log($"{TAG} Log Event Success Rate"); } public void SetTch02Value(double value) { Debug.Log($"{TAG} Tch02MaxValue: {value}"); } } }