update: 重构 networkstatus 方法和规范值
							parent
							
								
									48c5235335
								
							
						
					
					
						commit
						fd01939a5f
					
				|  | @ -1,8 +1,9 @@ | ||||||
| using System; | 
 | ||||||
| using System.Collections.Generic; |  | ||||||
| 
 | 
 | ||||||
| namespace Guru | namespace Guru | ||||||
| { | { | ||||||
|  |     using System; | ||||||
|  |     using UnityEngine.Serialization; | ||||||
|      |      | ||||||
|     [Serializable] |     [Serializable] | ||||||
|     public class GuruServicesConfig |     public class GuruServicesConfig | ||||||
|  | @ -61,7 +62,7 @@ namespace Guru | ||||||
|         public string DMAMapRule() => parameters?.dma_map_rule ?? ""; |         public string DMAMapRule() => parameters?.dma_map_rule ?? ""; | ||||||
|         public bool UseUUID() => parameters?.using_uuid ?? false; |         public bool UseUUID() => parameters?.using_uuid ?? false; | ||||||
|         public bool KeywordsEnabled() => parameters?.enable_keywords ?? 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 int LevelEndSuccessNum() => parameters?.level_end_success_num ?? 50; | ||||||
|         public string CdnHost() => parameters?.cdn_host ?? ""; |         public string CdnHost() => parameters?.cdn_host ?? ""; | ||||||
|         public bool UsingUUID() => parameters?.using_uuid ?? true; |         public bool UsingUUID() => parameters?.using_uuid ?? true; | ||||||
|  | @ -91,7 +92,7 @@ namespace Guru | ||||||
|     [Serializable] |     [Serializable] | ||||||
|     public class GuruParameters |     public class GuruParameters | ||||||
|     { |     { | ||||||
|         public int token_vaild_time = 604800; |         public int token_valid_time = 604800; | ||||||
|         public int level_end_success_num = 50; |         public int level_end_success_num = 50; | ||||||
|         public bool enable_keywords = false; |         public bool enable_keywords = false; | ||||||
|         public double tch_020 = 0; |         public double tch_020 = 0; | ||||||
|  |  | ||||||
|  | @ -21,14 +21,7 @@ namespace Guru | ||||||
|         /// <param name="priority"></param> |         /// <param name="priority"></param> | ||||||
|         public static void LogEvent(string eventName, Dictionary<string, dynamic> data = null, int priority = -1) |         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); |             if(priority < 0) priority = GetEventPriorityInt(eventName); | ||||||
|              |  | ||||||
|             Analytics.Track(eventName, data, null, priority); |             Analytics.Track(eventName, data, null, priority); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -344,7 +344,6 @@ namespace Guru | ||||||
| #endif | #endif | ||||||
|              |              | ||||||
|             LogI($"#5 --- sync sdk time ---"); |             LogI($"#5 --- sync sdk time ---"); | ||||||
|             // TODO: 本调用放在这里不合适, 应该和 Firebase 解耦 |  | ||||||
|             LogSDKInitTime((DateTime.Now.ToUniversalTime() - _initTime).TotalSeconds); |             LogSDKInitTime((DateTime.Now.ToUniversalTime() - _initTime).TotalSeconds); | ||||||
|         } |         } | ||||||
|          |          | ||||||
|  | @ -687,22 +686,28 @@ namespace Guru | ||||||
| 
 | 
 | ||||||
|          |          | ||||||
|         private NetworkStatusMonitor _networkStatusMonitor; |         private NetworkStatusMonitor _networkStatusMonitor; | ||||||
|         private string _networkStatus; |         private string _lastNetworkStatus; | ||||||
|          |          | ||||||
|         private void InitNetworkMonitor() |         private void InitNetworkMonitor() | ||||||
|         { |         { | ||||||
|             // SetUserProperty(Consts.PropertyNetwork, GetNetworkStatus()); |             // SetUserProperty(Consts.PropertyNetwork, GetNetworkStatus()); | ||||||
|             // TODO: 下个版本加入真正的自动更新网络状态的实现 |             _networkStatusMonitor = new NetworkStatusMonitor(status => | ||||||
|  |             { | ||||||
|  |                 SetUserProperty(Consts.PropertyNetwork, status); | ||||||
|  |             }, lastStatus => | ||||||
|  |             { | ||||||
|  |                 LogEvent("guru_offline", new Dictionary<string, dynamic>() | ||||||
|  |                 { | ||||||
|  |                     ["from"] = lastStatus | ||||||
|  |                 }); | ||||||
|  |             }); | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         private string GetNetworkStatus() |         /// <summary> | ||||||
|         { |         /// 获取当前的网络状态 | ||||||
|             if(_networkStatusMonitor == null) |         /// </summary> | ||||||
|             { |         /// <returns></returns> | ||||||
|                 _networkStatusMonitor = new NetworkStatusMonitor(); |         private string GetNetworkStatus() => _networkStatusMonitor.GetNetworkStatus(); | ||||||
|             } |  | ||||||
|             return _networkStatusMonitor.GetNetworkStatus(); |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|          |          | ||||||
|         #endregion |         #endregion | ||||||
|  | @ -736,9 +741,6 @@ namespace Guru | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|          |          | ||||||
|          |  | ||||||
|          |  | ||||||
|          |  | ||||||
|         private void OnGetFirebaseId(string fid) |         private void OnGetFirebaseId(string fid) | ||||||
|         { |         { | ||||||
|             // 初始化 Adjust 服务 |             // 初始化 Adjust 服务 | ||||||
|  | @ -824,13 +826,7 @@ namespace Guru | ||||||
|             SetUserProperty("adjust_id", adjustId); |             SetUserProperty("adjust_id", adjustId); | ||||||
|             Debug.Log($"[SDK] --- Firebase + Adjust ID: {adjustId}"); |             Debug.Log($"[SDK] --- Firebase + Adjust ID: {adjustId}"); | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
| 		 |  | ||||||
| 		 |  | ||||||
| 		 |  | ||||||
| 		 |  | ||||||
| 		 |  | ||||||
| 
 |  | ||||||
|         #endregion |         #endregion | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
		Loading…
	
		Reference in New Issue