fix: 优化用户属性打点逻辑
							parent
							
								
									4246251295
								
							
						
					
					
						commit
						314aaaa88b
					
				|  | @ -59,8 +59,7 @@ namespace Guru | |||
|         { | ||||
|             if (!IsInitialSuccess) | ||||
|             { | ||||
|                 UnityEngine.Debug.LogWarning($"{Tag} :: SetScreen {screen} has been cached before SDK init!"); | ||||
|                 CacheUserProperty(KeyCachedScreen, $"{screen},{extra}"); | ||||
|                 UnityEngine.Debug.LogWarning($"{Tag} :: SetScreen {screen} can not be set before SDK init!"); | ||||
|                 return; | ||||
|             } | ||||
|             Analytics.SetCurrentScreen(screen, extra); | ||||
|  | @ -363,33 +362,6 @@ namespace Guru | |||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         private static void ConsumeAllCachedUserProperty() | ||||
|         { | ||||
|             if (_userPropertyCacheData == null || _userPropertyCacheData.Count == 0) return; | ||||
|             var keys = _userPropertyCacheData.Keys.ToArray(); | ||||
|             int i = 0; | ||||
|             int count = keys.Length; | ||||
|             var key = ""; | ||||
|             while (i < count) | ||||
|             { | ||||
|                 key = keys[i]; | ||||
|                 if (key == KeyCachedScreen) | ||||
|                 { | ||||
|                     var arr = _userPropertyCacheData[key].Split(','); | ||||
|                     string screenName = "", className = ""; | ||||
|                     if(arr.Length > 0) screenName = arr[0]; | ||||
|                     if(arr.Length > 1) className = arr[1]; | ||||
|                     SetScreen(screenName, className); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     InternalSetUserProperty(key, _userPropertyCacheData[key]); | ||||
|                 } | ||||
| 
 | ||||
|                 i++; | ||||
|             } | ||||
|             _userPropertyCacheData.Clear(); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         /// <summary> | ||||
|  | @ -399,24 +371,10 @@ namespace Guru | |||
|         /// <param name="value"></param> | ||||
|         public static void SetUserProperty(string key, string value) | ||||
|         { | ||||
|             if (!IsInitialSuccess) | ||||
|             { | ||||
|                 CacheUserProperty(key , value); | ||||
|                 UnityEngine.Debug.LogWarning($"{Tag} :: SetUserProperty {key}:{value} Has been cached before SDK init!"); | ||||
|                 return; | ||||
|             } | ||||
|              | ||||
|             ConsumeAllCachedUserProperty(); // 消耗所有的缓存值 | ||||
|              | ||||
|             InternalSetUserProperty(key, value); | ||||
|         } | ||||
| 
 | ||||
|         private static void InternalSetUserProperty(string key, string value) | ||||
|         { | ||||
|             RecordUserPropertyKey(key); // 补全属性打点 | ||||
|             RecordUserPropertyKey(key); // 记录属性打点 | ||||
|             Analytics.SetUserProperty(key, value); | ||||
|         } | ||||
| 
 | ||||
|          | ||||
|         public static void SetUID(string uid) | ||||
|         { | ||||
|             SetUserProperty(Consts.PropertyUserID, uid); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue