update: 用户属性上报添加 Network 属性

--story=1021014 --user=yufei.hu 【中台】【SDK】用户属性上报添加 Network 属性 https://www.tapd.cn/33527076/s/1159710
dev
胡宇飞 2024-07-26 11:08:31 +08:00
parent b9291e7885
commit 4721e027b2
2 changed files with 33 additions and 4 deletions

View File

@ -44,8 +44,7 @@ namespace Guru
} }
#endregion #endregion
#region Android System #region Android System
#if UNITY_ANDROID #if UNITY_ANDROID
@ -78,7 +77,5 @@ namespace Guru
#endif #endif
#endregion #endregion
} }
} }

View File

@ -6,6 +6,7 @@ namespace Guru
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Debug = UnityEngine.Debug; using Debug = UnityEngine.Debug;
using Guru.Network;
public partial class GuruSDK: MonoBehaviour public partial class GuruSDK: MonoBehaviour
{ {
@ -152,6 +153,9 @@ namespace Guru
InitThreadHandler(); // 初始化线程处理器 InitThreadHandler(); // 初始化线程处理器
InitServices(); InitServices();
InitNetworkMonitor(); // 网络状态
onComplete?.Invoke(true); onComplete?.Invoke(true);
} }
@ -783,6 +787,34 @@ namespace Guru
#endregion
#region 网络状态上报
private NetworkStatusMonitor _networkStatusMonitor;
private void InitNetworkMonitor()
{
_networkStatusMonitor = new NetworkStatusMonitor();
_networkStatusMonitor.Init(OnNetworkMonitorInitComplete);
}
private void OnNetworkMonitorInitComplete(bool success)
{
if (success)
{
// 上报用户network属性
var status = _networkStatusMonitor.GetNetworkStatus();
SetUserProperty("network", status);
}
else
{
Debug.LogError($"[SDK] --- NetworkStatusMonitor init failed");
}
}
#endregion #endregion
} }
} }